Improve renderer
[tine20] / tine20 / Addressbook / js / AddressRenderer.js
index f29daf4..3c66363 100644 (file)
@@ -15,41 +15,36 @@ Ext.ns('Tine.Addressbook');
  * Undefined fields won't be rendered, this keeps it well reusable for all address like purposes.
  *
  * @namespace   Tine.Addressbook
- * @class       Tine.Addressbook.AddressRenderer
  * @author      Michael Spahn <m.spahn@metaways.de>
  * @singleton
  */
-Tine.Addressbook.AddressRenderer = function () {
+Tine.Addressbook.addressRenderer = function (v, metadata, record, store, a, b, config) {
     var template = new Ext.XTemplate(
         '<tpl for="." class="address">' +
-            '<tpl if="street">{street} <br /></tpl>' +
-            '<tpl if="street2">{street2} <br /></tpl>' +
-            '<tpl if="postalcode">{postalcode}</tpl> <tpl if="locality">{locality}</tpl><br />' +
-            '<tpl if="region">{region} <br /></tpl>' +
-            '<tpl if="country">{country}</tpl>' +
+        '<tpl if="street">{street} <br /></tpl>' +
+        '<tpl if="street2">{street2} <br /></tpl>' +
+        '<tpl if="postalcode">{postalcode}</tpl> <tpl if="locality">{locality}</tpl><br />' +
+        '<tpl if="region">{region} <br /></tpl>' +
+        '<tpl if="country">{country}</tpl>' +
         '</tpl>');
     template.compile();
 
-    return {
-        renderer: function (v, metadata, record, store, a, b, config) {
-            var local = Object.assign({}, config);
-            var keys = Object.keys(local);
+    var local = Object.assign({}, config);
+    var keys = Object.keys(local);
 
-            // According to config, resolve the given fields from record
-            keys.forEach(function(key) {
-                local[key] = Tine.Tinebase.EncodingHelper.encode(record.get(local[key]));
+    // According to config, resolve the given fields from record
+    keys.forEach(function (key) {
+        local[key] = Tine.Tinebase.EncodingHelper.encode(record.get(local[key]));
 
-                // Country code to country name
-                // @todo: Wouldn't it be cool, if this could be managed by the modelconfig as well?
-                if (key === 'country') {
-                    var countryRenderer = Tine.widgets.grid.RendererManager.get("Addressbook", "Addressbook_Model_Contact", "country", "displayPanel");
-                    local[key] = countryRenderer(local[key]);
-                }
-            });
-
-            return template.applyTemplate(local);
+        // Country code to country name
+        // @todo: Wouldn't it be cool, if this could be managed by the modelconfig as well?
+        if (key === 'country') {
+            var countryRenderer = Tine.widgets.grid.RendererManager.get("Addressbook", "Addressbook_Model_Contact", "country", "displayPanel");
+            local[key] = countryRenderer(local[key]);
         }
-    };
-}();
+    });
+
+    return template.applyTemplate(local);
+};
 
-Tine.widgets.grid.RendererManager.register('Addressbook', 'Addressbook_Model_Contact', 'addressblock', Tine.Addressbook.AddressRenderer.renderer, 'displayPanel');
\ No newline at end of file
+Tine.widgets.grid.RendererManager.register('Addressbook', 'Addressbook_Model_Contact', 'addressblock', Tine.Addressbook.addressRenderer, 'displayPanel');
\ No newline at end of file