[CallLog] updated CallLog sources
authorPiotr Dabrowski <p.dabrowski2@samsung.com>
Tue, 20 Aug 2013 13:21:32 +0000 (15:21 +0200)
committerPiotr Dabrowski <p.dabrowski2@samsung.com>
Tue, 20 Aug 2013 13:21:32 +0000 (15:21 +0200)
Change-Id: I20b70b601449ad31de23ea3b8be96122e14de2eb

css/style.css
images/logs_list_blocked_icon.png [new file with mode: 0644]
js/app.js
js/app.ui.js
js/app.ui.templateManager.js
js/app.ui.templateManager.modifiers.js [new file with mode: 0644]
templates/callItemRow.tpl

index 5e00a55..f45920e 100644 (file)
@@ -240,6 +240,10 @@ li {
        background-image: url('../images/logs_list_rejected_icon.png');
 }
 
+.call.dir_blocked .iconStatus {
+       background-image: url('../images/logs_list_blocked_icon.png');
+}
+
 .noPhoto {
        background-image: url('../images/no_photo.png');
 }
diff --git a/images/logs_list_blocked_icon.png b/images/logs_list_blocked_icon.png
new file mode 100644 (file)
index 0000000..7153ca2
Binary files /dev/null and b/images/logs_list_blocked_icon.png differ
index 74be801..b005fb4 100644 (file)
--- a/js/app.js
+++ b/js/app.js
@@ -19,7 +19,7 @@ var App = null;
                /**
                 * @type Array
                 */
-               requires: ['js/app.config.js', 'js/app.model.js', 'js/app.ui.js', 'js/app.ui.templateManager.js', 'js/app.helpers.js'],
+               requires: ['js/app.config.js', 'js/app.model.js', 'js/app.ui.js', 'js/app.ui.templateManager.js', 'js/app.ui.templateManager.modifiers.js', 'js/app.helpers.js'],
 
                /**
                 * @type Model
index 530b8d3..dae58d7 100644 (file)
@@ -540,7 +540,7 @@ function Ui(contacts) {
                                        }
                                }
                        }
-                       return name || number;
+                       return name || number || 'Unknown';
                },
 
                /**
@@ -677,7 +677,8 @@ function Ui(contacts) {
                                this.updateCallerHeaderAccountId('');
                                this.updateCallerHeaderNumberOfEntries(numberOfEntries);
                        }
-                       $('.contact > .infoContainer > .name').html(name);
+                       $('.contact > .infoContainer > .name')
+                               .html($('<span>').text(name).html());
 
                },
 
index 68c6678..e2a440a 100644 (file)
@@ -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,40 @@ 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 + '\\|(.+?)%'),
+                               specRegExp = new RegExp('\\$','g'),
+                               modifier;
+
+                       if (content && (typeof content === 'string')) {
+                               content = content.replace(specRegExp, '$$$$');
+                       }
+
+                       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;
                }
        };
 
diff --git a/js/app.ui.templateManager.modifiers.js b/js/app.ui.templateManager.modifiers.js
new file mode 100644 (file)
index 0000000..1d57ce7
--- /dev/null
@@ -0,0 +1,36 @@
+/*global $*/
+/**
+ * @class ModifierManager
+ */
+function ModifierManager() {
+       'use strict';
+       this.init();
+}
+
+(function () {
+       'use strict';
+       ModifierManager.prototype = {
+
+               /**
+                * UI module initialisation
+                */
+               init: function () {
+               },
+
+               /**
+                * @return modifiers object
+                */
+               getAll: function () {
+                       return this.modifiers;
+               },
+
+               /**
+                * modifiers definitions
+                */
+               modifiers: {
+                       escape: function escape(str) {
+                               return $('<span>').text(str).html();
+                       }
+               }
+       };
+}());
\ No newline at end of file
index 2ba37fe..9ac9821 100644 (file)
@@ -1,6 +1,6 @@
 <li data-filtertext="%name%" class="%cssClasses%">
        <div class="toRemove hidden"><input type="checkbox" /></div>
-       <div class="numberOrName">%name%</div>
+       <div class="numberOrName">%name|escape%</div>
        <div class="iconStatus"></div>
        <div class="callTime">%callTime%</div>
 </li>
\ No newline at end of file