From c8c6ca3da0c798c459135c63cc98fc0347b6d919 Mon Sep 17 00:00:00 2001 From: Rufus Pollock Date: Fri, 6 Jan 2012 13:42:07 +0000 Subject: [PATCH] [#14,refactor][s]: move all mustache templates used by util that are still in demo.html into util.js templates hash. * This is important as it makes the app standalone and not depdendent on specific html (we plan for explorer to embed in different html frontends). --- demo/index.html | 54 ------------------------------------------------- src/util.js | 49 +++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 55 deletions(-) diff --git a/demo/index.html b/demo/index.html index a02959a9..d46c438c 100755 --- a/demo/index.html +++ b/demo/index.html @@ -85,19 +85,6 @@
  • JSON
  • - - - - - - @@ -393,20 +380,6 @@ - - - - diff --git a/src/util.js b/src/util.js index 009284c4..ea528e3a 100755 --- a/src/util.js +++ b/src/util.js @@ -1,4 +1,51 @@ var util = function() { + var templates = { + transformActions: '
  • Global transform...
  • ' + , columnActions: ' \ +
  • Transform...
  • \ +
  • Delete this column
  • \ + ' + , rowActions: '
  • Delete this row
  • ' + , cellEditor: ' \ + \ + ' + , editPreview: ' \ +
    \ + \ + \ + \ + \ + \ + \ + {{#rows}} \ + \ + \ + \ + \ + {{/rows}} \ + \ +
    \ + before \ + \ + after \ +
    \ + {{before}} \ + \ + {{after}} \ +
    \ +
    \ + ' + }; $.fn.serializeObject = function() { var o = {}; @@ -89,7 +136,7 @@ var util = function() { function render( template, target, options ) { if ( !options ) options = {data: {}}; if ( !options.data ) options = {data: options}; - var html = $.mustache( $( "." + template + "Template:first" ).html(), options.data ); + var html = $.mustache( templates[template], options.data ); if (target instanceof jQuery) { var targetDom = target; } else {