diff options
author | ji.ji <ji.ji@samsung.com> | 2013-05-23 15:54:51 +0900 |
---|---|---|
committer | ji.ji <ji.ji@samsung.com> | 2013-05-23 15:54:51 +0900 |
commit | 92e456bad07c49404137bb0a1eda55247df00900 (patch) | |
tree | 27ff6a541ba6feead83b84d6094b007eaf10331e /js/app.ui.templateManager.js | |
parent | 2f3a5afd00fa5a85fa15a242c9f389c21f2be296 (diff) | |
download | EventManager-92e456bad07c49404137bb0a1eda55247df00900.tar.gz EventManager-92e456bad07c49404137bb0a1eda55247df00900.tar.bz2 EventManager-92e456bad07c49404137bb0a1eda55247df00900.zip |
[EventManager]update EventManager(tizen_2.1)
Change-Id: Iced9d4257f4a429547aaa81f39098552f59cc1f1
Diffstat (limited to 'js/app.ui.templateManager.js')
-rw-r--r-- | js/app.ui.templateManager.js | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/js/app.ui.templateManager.js b/js/app.ui.templateManager.js index 68c6678..c1db140 100644 --- a/js/app.ui.templateManager.js +++ b/js/app.ui.templateManager.js @@ -1,4 +1,4 @@ -/*global tizen, $, app */ +/*global tizen, $, app, ModifierManager */ /** * @class TemplateManager */ @@ -20,6 +20,7 @@ function TemplateManager() { * UI module initialisation */ init: function init() { + this.modifiers = new ModifierManager().getAll(); }, /** @@ -95,16 +96,36 @@ function TemplateManager() { * @param {string} tplParams */ getCompleted: function TemplateManager_getCompleted(tplHtml, tplParams) { - var tplParam, replaceRegExp; + var tplParam; for (tplParam in tplParams) { if (tplParams.hasOwnProperty(tplParam)) { - replaceRegExp = new RegExp(['%', tplParam, '%'].join(''), 'g'); - tplHtml = tplHtml.replace(replaceRegExp, tplParams[tplParam]); + tplHtml = this.passThruModifiers(tplHtml, tplParam, tplParams[tplParam]); } } return tplHtml; + }, + + passThruModifiers: function (tplHtml, tplParam, content) { + var regModOn = new RegExp('%' + tplParam + '\\|([a-zA-Z]){1,}%', 'g'), + regModOff = new RegExp(['%', tplParam, '%'].join(''), 'g'), + regModGet = new RegExp('%' + tplParam + '\\|(.+?)%'), + modifier; + + if (regModOn.test(tplHtml)) { + modifier = tplHtml.match(regModGet)[1]; + try { + content = this.modifiers[modifier](content); + } catch (error) { + console.error('unknown modifier: ' + modifier); + } + tplHtml = tplHtml.replace(regModOn, content); + } else { + tplHtml = tplHtml.replace(regModOff, content); + } + + return tplHtml; } }; |