Skip to content

Commit

Permalink
parse the whole line for table json, so intermediate elements like sp…
Browse files Browse the repository at this point in the history
…an.url do not break the payload.
  • Loading branch information
clkao committed Nov 5, 2012
1 parent 831e838 commit 9a3e7fe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
19 changes: 7 additions & 12 deletions src/js/datatables.ls
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ exports.aceInitialized = (hook, context) ->
editorInfo.ace_doDatatableOptions = (_ Datatables.doDatatableOptions).bind context

exports.acePostWriteDomLineHTML = (hook_name, {node}, cb) ->
children = node.children
i = 0
while i < children.length
element = children[i++]
continue if (element.className.indexOf 'list') isnt -1 or (element.className.indexOf 'tag') isnt -1 or (element.className.indexOf 'url') isnt -1
lineText = element.innerText ? element.textContent
if lineText and (lineText.indexOf '\uFFF9') isnt -1
dtAttrs = if typeof exports.Datatables isnt 'undefined' then exports.Datatables.attributes else null
dtAttrs = dtAttrs or ''
code = fromEscapedJSON lineText
DatatablesRenderer.render {}, element, code, dtAttrs
exports.Datatables.attributes = null
lineText = node.textContent
if lineText and (lineText.indexOf '\uFFF9') isnt -1
dtAttrs = if typeof exports.Datatables isnt 'undefined' then exports.Datatables.attributes else null
dtAttrs = dtAttrs or ''
code = fromEscapedJSON lineText
DatatablesRenderer.render {}, node, code, dtAttrs
exports.Datatables.attributes = null

exports.eejsBlock_scripts = (hook_name, args, cb) ->
args.content = args.content + (require 'ep_etherpad-lite/node/eejs/').require 'ep_tables/templates/datatablesScripts.ejs'
Expand Down
27 changes: 8 additions & 19 deletions static/js/datatables.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,16 @@ exports.aceInitialized = function(hook, context){
return editorInfo.ace_doDatatableOptions = _(Datatables.doDatatableOptions).bind(context);
};
exports.acePostWriteDomLineHTML = function(hook_name, arg$, cb){
var node, children, i, element, lineText, ref$, dtAttrs, code, results$ = [];
var node, lineText, dtAttrs, code;
node = arg$.node;
children = node.children;
i = 0;
while (i < children.length) {
element = children[i++];
if (element.className.indexOf('list') !== -1 || element.className.indexOf('tag') !== -1 || element.className.indexOf('url') !== -1) {
continue;
}
lineText = (ref$ = element.innerText) != null
? ref$
: element.textContent;
if (lineText && lineText.indexOf('\uFFF9') !== -1) {
dtAttrs = typeof exports.Datatables !== 'undefined' ? exports.Datatables.attributes : null;
dtAttrs = dtAttrs || '';
code = fromEscapedJSON(lineText);
DatatablesRenderer.render({}, element, code, dtAttrs);
results$.push(exports.Datatables.attributes = null);
}
lineText = node.textContent;
if (lineText && lineText.indexOf('\uFFF9') !== -1) {
dtAttrs = typeof exports.Datatables !== 'undefined' ? exports.Datatables.attributes : null;
dtAttrs = dtAttrs || '';
code = fromEscapedJSON(lineText);
DatatablesRenderer.render({}, node, code, dtAttrs);
return exports.Datatables.attributes = null;
}
return results$;
};
exports.eejsBlock_scripts = function(hook_name, args, cb){
return args.content = args.content + require('ep_etherpad-lite/node/eejs/').require('ep_tables/templates/datatablesScripts.ejs');
Expand Down

0 comments on commit 9a3e7fe

Please sign in to comment.