/* yunkong2.template Widget-Set version: "0.5.0" Copyright 10.2015-2016 @@Author@@<@@email@@> */ "use strict"; // add translations for edit mode if (vis.editMode) { $.extend(true, systemDictionary, { "myColor": {"en": "myColor", "de": "mainColor", "ru": "Мой цвет"}, "myColor_tooltip": { "en": "Description of\x0AmyColor", "de": "Beschreibung von\x0AmyColor", "ru": "Описание\x0AmyColor" }, "htmlText": {"en": "htmlText", "de": "htmlText", "ru": "htmlText"}, "group_extraMyset": {"en": "extraMyset", "de": "extraMyset", "ru": "extraMyset"}, "extraAttr": {"en": "extraAttr", "de": "extraAttr", "ru": "extraAttr"} }); } // add translations for non-edit mode $.extend(true, systemDictionary, { "Instance": {"en": "Instance", "de": "Instanz", "ru": "Инстанция"} }); // this code can be placed directly in template.html vis.binds.template = { version: "0.5.0", showVersion: function () { if (vis.binds.template.version) { console.log('Version template: ' + vis.binds.template.version); vis.binds.template.version = null; } }, createWidget: function (widgetID, view, data, style) { var $div = $('#' + widgetID); // if nothing found => wait if (!$div.length) { return setTimeout(function () { vis.binds.template.createWidget(widgetID, view, data, style); }, 100); } var text = ''; text += 'OID: ' + data.oid + '
'; text += 'OID value: ' + vis.states[data.oid + '.val'] + '
'; text += 'Color: ' + data.myColor + '
'; text += 'extraAttr: ' + data.extraAttr + '
'; text += 'Browser instance: ' + vis.instance + '
'; text += 'htmlText:
'; $('#' + widgetID).html(text); // subscribe on updates of value if (data.oid) { vis.states.bind(data.oid + '.val', function (e, newVal, oldVal) { $div.find('.template-value').html(newVal); }); } } }; vis.binds.template.showVersion();