forked from withanage/lens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
339 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
var _ = require('underscore'); | ||
var Document = require('../../../substance/document'); | ||
|
||
// Lens.HTMLTable | ||
// ----------------- | ||
// | ||
|
||
var HTMLTable = function(node, doc) { | ||
Document.Node.call(this, node, doc); | ||
}; | ||
|
||
// Type definition | ||
// ----------------- | ||
// | ||
|
||
HTMLTable.type = { | ||
"id": "html_table", | ||
"parent": "content", | ||
"properties": { | ||
"source_id": "string", | ||
"label": "string", | ||
"content": "string", | ||
"footers": ["array", "string"], | ||
"caption": "caption" | ||
} | ||
}; | ||
|
||
HTMLTable.config = { | ||
"zoomable": true | ||
}; | ||
|
||
|
||
// This is used for the auto-generated docs | ||
// ----------------- | ||
// | ||
|
||
HTMLTable.description = { | ||
"name": "HTMLTable", | ||
"remarks": [ | ||
"A table figure which is expressed in HTML notation" | ||
], | ||
"properties": { | ||
"source_id": "string", | ||
"label": "Label shown in the resource header.", | ||
"title": "Full table title", | ||
"content": "HTML data", | ||
"footers": "HTMLTable footers expressed as an array strings", | ||
"caption": "References a caption node, that has all the content" | ||
} | ||
}; | ||
|
||
|
||
// Example HTMLTable | ||
// ----------------- | ||
// | ||
|
||
HTMLTable.example = { | ||
"id": "html_table_1", | ||
"type": "html_table", | ||
"label": "HTMLTable 1.", | ||
"title": "Lorem ipsum table", | ||
"content": "<table>...</table>", | ||
"footers": [], | ||
"caption": "caption_1" | ||
}; | ||
|
||
HTMLTable.Prototype = function() { | ||
|
||
this.getCaption = function() { | ||
if (this.properties.caption) return this.document.get(this.properties.caption); | ||
}; | ||
|
||
this.getHeader = function() { | ||
return this.properties.label; | ||
}; | ||
}; | ||
|
||
HTMLTable.Prototype.prototype = Document.Node.prototype; | ||
HTMLTable.prototype = new HTMLTable.Prototype(); | ||
HTMLTable.prototype.constructor = HTMLTable; | ||
|
||
Document.Node.defineProperties(HTMLTable); | ||
|
||
module.exports = HTMLTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
"use strict"; | ||
|
||
var _ = require("underscore"); | ||
var NodeView = require("../node").View; | ||
var $$ = require("../../../substance/application").$$; | ||
var ResourceView = require('../../resource_view'); | ||
|
||
// Substance.Paragraph.View | ||
// ========================================================================== | ||
|
||
var HTMLTableView = function(node, viewFactory, options) { | ||
NodeView.call(this, node, viewFactory); | ||
|
||
// Mix-in | ||
ResourceView.call(this, options); | ||
|
||
}; | ||
|
||
HTMLTableView.Prototype = function() { | ||
|
||
// Mix-in | ||
_.extend(this, ResourceView.prototype); | ||
|
||
this.isZoomable = true; | ||
|
||
this.renderBody = function() { | ||
|
||
// The actual content | ||
// -------- | ||
// | ||
|
||
var tableWrapper = $$('.table-wrapper', { | ||
html: this.node.content // HTML table content | ||
}); | ||
|
||
this.content.appendChild(tableWrapper); | ||
|
||
// Display footers (optional) | ||
// -------- | ||
// | ||
|
||
var footers = $$('.footers', { | ||
children: _.map(this.node.footers, function(footer) { | ||
return $$('.footer', { html: "<b>"+footer.label+"</b> " + footer.content }); | ||
}) | ||
}); | ||
|
||
// Display caption | ||
|
||
|
||
if (this.node.caption) { | ||
var captionView = this.createView(this.node.caption); | ||
this.content.appendChild(captionView.render().el); | ||
} | ||
|
||
this.content.appendChild(footers); | ||
}; | ||
|
||
}; | ||
|
||
HTMLTableView.Prototype.prototype = NodeView.prototype; | ||
HTMLTableView.prototype = new HTMLTableView.Prototype(); | ||
|
||
module.exports = HTMLTableView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
Model: require('./html_table'), | ||
View: require('./html_table_view') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.