[refactor,util,view-tranform][s]: move transform edit preview template out of util into view-transform-dialog.
This commit is contained in:
parent
650d83e6b4
commit
07758bd3b5
54
src/util.js
54
src/util.js
@ -1,38 +1,6 @@
|
||||
/*jshint multistr:true */
|
||||
|
||||
var util = function() {
|
||||
var templates = {
|
||||
transformActions: '<li><a data-action="transform" class="menuAction" href="JavaScript:void(0);">Global transform...</a></li>',
|
||||
editPreview: ' \
|
||||
<div class="expression-preview-table-wrapper"> \
|
||||
<table> \
|
||||
<thead> \
|
||||
<tr> \
|
||||
<th class="expression-preview-heading"> \
|
||||
before \
|
||||
</th> \
|
||||
<th class="expression-preview-heading"> \
|
||||
after \
|
||||
</th> \
|
||||
</tr> \
|
||||
</thead> \
|
||||
<tbody> \
|
||||
{{#rows}} \
|
||||
<tr> \
|
||||
<td class="expression-preview-value"> \
|
||||
{{before}} \
|
||||
</td> \
|
||||
<td class="expression-preview-value"> \
|
||||
{{after}} \
|
||||
</td> \
|
||||
</tr> \
|
||||
{{/rows}} \
|
||||
</tbody> \
|
||||
</table> \
|
||||
</div> \
|
||||
'
|
||||
};
|
||||
|
||||
$.fn.serializeObject = function() {
|
||||
var o = {};
|
||||
var a = this.serializeArray();
|
||||
@ -62,27 +30,7 @@ var util = function() {
|
||||
$('.' + thing).show().css({top: position.top + $(elem.target).height(), left: position.left});
|
||||
}
|
||||
|
||||
function render( template, target, options ) {
|
||||
if ( !options ) options = {data: {}};
|
||||
if ( !options.data ) options = {data: options};
|
||||
var html = $.mustache( templates[template], options.data );
|
||||
var targetDom = null;
|
||||
if (target instanceof jQuery) {
|
||||
targetDom = target;
|
||||
} else {
|
||||
targetDom = $( "." + target + ":first" );
|
||||
}
|
||||
if( options.append ) {
|
||||
targetDom.append( html );
|
||||
} else {
|
||||
targetDom.html( html );
|
||||
}
|
||||
// TODO: remove (commented out as part of Backbon-i-fication
|
||||
// if (template in app.after) app.after[template]();
|
||||
}
|
||||
|
||||
return {
|
||||
position: position,
|
||||
render: render
|
||||
position: position
|
||||
};
|
||||
}();
|
||||
|
||||
@ -121,6 +121,35 @@ my.ColumnTransform = Backbone.View.extend({
|
||||
this.el.remove();
|
||||
},
|
||||
|
||||
editPreviewTemplate: ' \
|
||||
<div class="expression-preview-table-wrapper"> \
|
||||
<table class="table table-condensed"> \
|
||||
<thead> \
|
||||
<tr> \
|
||||
<th class="expression-preview-heading"> \
|
||||
before \
|
||||
</th> \
|
||||
<th class="expression-preview-heading"> \
|
||||
after \
|
||||
</th> \
|
||||
</tr> \
|
||||
</thead> \
|
||||
<tbody> \
|
||||
{{#rows}} \
|
||||
<tr> \
|
||||
<td class="expression-preview-value"> \
|
||||
{{before}} \
|
||||
</td> \
|
||||
<td class="expression-preview-value"> \
|
||||
{{after}} \
|
||||
</td> \
|
||||
</tr> \
|
||||
{{/rows}} \
|
||||
</tbody> \
|
||||
</table> \
|
||||
</div> \
|
||||
',
|
||||
|
||||
onEditorKeydown: function(e) {
|
||||
var self = this;
|
||||
// if you don't setTimeout it won't grab the latest character if you call e.target.value
|
||||
@ -133,7 +162,9 @@ my.ColumnTransform = Backbone.View.extend({
|
||||
return doc.toJSON();
|
||||
});
|
||||
var previewData = costco.previewTransform(docs, editFunc, self.state.currentColumn);
|
||||
util.render('editPreview', 'expression-preview-container', {rows: previewData});
|
||||
var $el = self.el.find('.expression-preview-container');
|
||||
var templated = $.mustache(self.editPreviewTemplate, {rows: previewData.slice(0,4)});
|
||||
$el.html(templated);
|
||||
} else {
|
||||
errors.text(editFunc.errorMessage);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user