From f97217cfd7640347c21e069afced50a1f3a2937b Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 30 Dec 2013 13:02:37 +0200 Subject: [PATCH 1/5] Add requirejs-text --- bower.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index f58991d20..718c6d4e2 100644 --- a/bower.json +++ b/bower.json @@ -3,7 +3,8 @@ "version": "0.7.2", "devDependencies": { "jasmine": "https://github.com/jcbrand/jasmine.git#1_3_x", - "otr": "0.2.7" + "otr": "0.2.7", + "requirejs-text": "~2.0.10" }, "dependencies": { "requirejs": "2.1.8", @@ -20,7 +21,8 @@ "strophe.muc": "https://raw.github.com/strophe/strophejs-plugins/02310ad1b8da2962cd05b0f4bceaecca134efed4/muc/strophe.muc.js", "otr": "0.2.7", "crypto-js": "~3.1.2", - "almond": "~0.2.6" + "almond": "~0.2.6", + "requirejs-text": "~2.0.10" }, "exportsOverride": {} } From 55b9a4e568ed0c5a22bf2a5ea3f1b57659750960 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Mon, 30 Dec 2013 21:27:57 +0200 Subject: [PATCH 2/5] Initial support for external HTMl templates. Updates #77 --- bower.json | 6 +- converse.js | 292 ++++++------------------ main.js | 24 +- src/templates.js | 31 +++ src/templates/action.html | 4 + src/templates/add_contact_dropdown.html | 8 + src/templates/add_contact_form.html | 9 + src/templates/chatbox.html | 17 ++ src/templates/chatrooms_tab.html | 1 + src/templates/contacts_panel.html | 10 + src/templates/contacts_tab.html | 1 + src/templates/controlbox.html | 5 + src/templates/info.html | 1 + src/templates/login_tab.html | 1 + src/templates/message.html | 4 + src/templates/new_day.html | 1 + src/templates/search_contact.html | 9 + src/templates/toolbar.html | 53 +++++ tests.html | 1 + tests_main.js | 93 ++------ 20 files changed, 275 insertions(+), 296 deletions(-) create mode 100644 src/templates.js create mode 100644 src/templates/action.html create mode 100644 src/templates/add_contact_dropdown.html create mode 100644 src/templates/add_contact_form.html create mode 100644 src/templates/chatbox.html create mode 100644 src/templates/chatrooms_tab.html create mode 100644 src/templates/contacts_panel.html create mode 100644 src/templates/contacts_tab.html create mode 100644 src/templates/controlbox.html create mode 100644 src/templates/info.html create mode 100644 src/templates/login_tab.html create mode 100644 src/templates/message.html create mode 100644 src/templates/new_day.html create mode 100644 src/templates/search_contact.html create mode 100644 src/templates/toolbar.html diff --git a/bower.json b/bower.json index 718c6d4e2..09d0394b3 100644 --- a/bower.json +++ b/bower.json @@ -4,7 +4,8 @@ "devDependencies": { "jasmine": "https://github.com/jcbrand/jasmine.git#1_3_x", "otr": "0.2.7", - "requirejs-text": "~2.0.10" + "requirejs-text": "~2.0.10", + "requirejs-tpl-jfparadis": "*" }, "dependencies": { "requirejs": "2.1.8", @@ -22,7 +23,8 @@ "otr": "0.2.7", "crypto-js": "~3.1.2", "almond": "~0.2.6", - "requirejs-text": "~2.0.10" + "requirejs-text": "~2.0.10", + "requirejs-tpl-jfparadis": "*" }, "exportsOverride": {} } diff --git a/converse.js b/converse.js index e26a26b1a..8f16c39e6 100644 --- a/converse.js +++ b/converse.js @@ -12,27 +12,26 @@ console = { log: function () {}, error: function () {} }; } if (typeof define === 'function' && define.amd) { - define("converse", ["converse-dependencies"], function(otr) { - // Use Mustache style syntax for variable interpolation - _.templateSettings = { - evaluate : /\{\[([\s\S]+?)\]\}/g, - interpolate : /\{\{([\s\S]+?)\}\}/g - }; - if (typeof otr !== "undefined") { - return factory(jQuery, _, otr.OTR, otr.DSA, console); - } else { - return factory(jQuery, _, undefined, undefined, console); + define("converse", + ["converse-dependencies", "converse-templates"], + function(otr, templates) { + if (typeof otr !== "undefined") { + return factory(jQuery, _, otr.OTR, otr.DSA, console, templates); + } else { + return factory(jQuery, _, undefined, undefined, console, templates); + } } - }); + ); } else { // Browser globals + // FIXME _.templateSettings = { evaluate : /\{\[([\s\S]+?)\]\}/g, interpolate : /\{\{([\s\S]+?)\}\}/g }; root.converse = factory(jQuery, _, OTR, DSA, console || {log: function(){}}); } -}(this, function ($, _, OTR, DSA, console) { +}(this, function ($, _, OTR, DSA, console, templates) { $.fn.addHyperlinks = function() { if (this.length > 0) { this.each(function(i, obj) { @@ -86,6 +85,7 @@ }; var converse = { + templates: templates, emit: function(evt, data) { $(this).trigger(evt, data); }, @@ -731,99 +731,6 @@ 'click .toggle-call': 'toggleCall' }, - template: _.template( - '
' + - '' + - '' + - '
{{ fullname }}
' + - '
' + - '

' + - '

' + - '
' + - '
' + - '{[ if ('+converse.show_toolbar+') { ]}' + - '
    '+ - '{[ } ]}' + - '