From 7b5e73b6007475c70d1831192bc84e3f2adc2750 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Wed, 24 Aug 2011 10:05:52 +0000 Subject: [PATCH] Added support for attribute descriptor 'translate': '\!no_lang', fixed problem with selectbox options not being read from sel_options, removed attributes from init function as they were either outdated or not used --- etemplate/js/et2_checkbox.js | 2 +- etemplate/js/et2_date.js | 2 +- etemplate/js/et2_description.js | 4 ++-- etemplate/js/et2_grid.js | 2 +- etemplate/js/et2_hbox.js | 2 +- etemplate/js/et2_hrule.js | 2 +- etemplate/js/et2_number.js | 2 +- etemplate/js/et2_radiobox.js | 2 +- etemplate/js/et2_selectbox.js | 14 +++++++------- etemplate/js/et2_tabs.js | 5 ++--- etemplate/js/et2_template.js | 2 +- etemplate/js/et2_textbox.js | 2 +- etemplate/js/et2_widget.js | 11 +++++------ etemplate/js/test/et2_test_timesheet_edit.json | 2 +- etemplate/js/test/et2_test_timesheet_edit.xet | 2 +- 15 files changed, 27 insertions(+), 29 deletions(-) diff --git a/etemplate/js/et2_checkbox.js b/etemplate/js/et2_checkbox.js index d29f419582..9e1d96454f 100644 --- a/etemplate/js/et2_checkbox.js +++ b/etemplate/js/et2_checkbox.js @@ -50,7 +50,7 @@ var et2_checkbox = et2_inputWidget.extend({ } }, - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.input = null; diff --git a/etemplate/js/et2_date.js b/etemplate/js/et2_date.js index e297e17c96..124fed879a 100644 --- a/etemplate/js/et2_date.js +++ b/etemplate/js/et2_date.js @@ -37,7 +37,7 @@ var et2_date = et2_inputWidget.extend({ */ date: new Date(), - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.input = null; diff --git a/etemplate/js/et2_description.js b/etemplate/js/et2_description.js index 8b98d3ee34..6acbfc16f9 100644 --- a/etemplate/js/et2_description.js +++ b/etemplate/js/et2_description.js @@ -27,7 +27,7 @@ var et2_description = et2_baseWidget.extend({ "name": "Caption", "type": "string", "description": "Displayed text", - "translate": true + "translate": "!no_lang" }, /** @@ -78,7 +78,7 @@ var et2_description = et2_baseWidget.extend({ legacyOptions: ["font_style", "href", "activate_links", "for", "extra_link_target", "extra_link_popup", "extra_link_title"], - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.value = ""; diff --git a/etemplate/js/et2_grid.js b/etemplate/js/et2_grid.js index 477fa8409a..6bd9ccc9a6 100644 --- a/etemplate/js/et2_grid.js +++ b/etemplate/js/et2_grid.js @@ -23,7 +23,7 @@ */ var et2_grid = et2_DOMWidget.extend({ - init: function(_parent) { + init: function() { // Create the table body and the table this.tbody = $j(document.createElement("tbody")); this.table = $j(document.createElement("table")) diff --git a/etemplate/js/et2_hbox.js b/etemplate/js/et2_hbox.js index 1e1a29acdf..e208fdc26c 100644 --- a/etemplate/js/et2_hbox.js +++ b/etemplate/js/et2_hbox.js @@ -24,7 +24,7 @@ var et2_hbox = et2_baseWidget.extend({ createNamespace: true, - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.alignData = { diff --git a/etemplate/js/et2_hrule.js b/etemplate/js/et2_hrule.js index f3e6521685..cd666af8d3 100644 --- a/etemplate/js/et2_hrule.js +++ b/etemplate/js/et2_hrule.js @@ -21,7 +21,7 @@ */ var et2_hrule = et2_baseWidget.extend({ - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.setDOMNode(document.createElement("hr")); diff --git a/etemplate/js/et2_number.js b/etemplate/js/et2_number.js index 0b2d8bfbf3..8d0816caae 100644 --- a/etemplate/js/et2_number.js +++ b/etemplate/js/et2_number.js @@ -40,7 +40,7 @@ var et2_number = et2_textbox.extend({ } }, - init: function(_parent) { + init: function() { this._super.apply(this, arguments); }, diff --git a/etemplate/js/et2_radiobox.js b/etemplate/js/et2_radiobox.js index 5c30187eff..b7590d3af0 100644 --- a/etemplate/js/et2_radiobox.js +++ b/etemplate/js/et2_radiobox.js @@ -43,7 +43,7 @@ var et2_radiobox = et2_inputWidget.extend({ } }, - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.input = null; diff --git a/etemplate/js/et2_selectbox.js b/etemplate/js/et2_selectbox.js index 8d5138132e..164275f41a 100644 --- a/etemplate/js/et2_selectbox.js +++ b/etemplate/js/et2_selectbox.js @@ -52,17 +52,17 @@ var et2_selectbox = et2_inputWidget.extend({ legacyOptions: ["rows"], - init: function(_parent, _attrs) { + init: function() { this._super.apply(this, arguments); // Only allow options inside this element this.supportedWidgetClasses = [et2_option]; // Legacy options could have row count or empty label in first slot - if(typeof _attrs.rows == "string" && isNaN(_attrs.rows)) { - this.options.empty_label = _attrs.rows; - this.options.rows = 1; - } + if(typeof this.options.rows == "string" && isNaN(this.options.rows)) { + this.options.empty_label = this.options.rows; + this.options.rows = 1; + } if(this.options.rows > 1) this.options.multiple = true; this.createInputWidget(); }, @@ -149,7 +149,7 @@ var et2_selectbox = et2_inputWidget.extend({ } // Create the widget and add it as a child - this.addChild(et2_createWidget("option", attrs)); + et2_createWidget("option", attrs, this); } } }); @@ -165,7 +165,7 @@ et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select-cat", */ var et2_selectbox_ro = et2_selectbox.extend({ - init: function(_parent, _attrs) { + init: function() { this._super.apply(this, arguments); this.supportedWidgetClasses = []; diff --git a/etemplate/js/et2_tabs.js b/etemplate/js/et2_tabs.js index 34adb8b476..962c60a1ee 100644 --- a/etemplate/js/et2_tabs.js +++ b/etemplate/js/et2_tabs.js @@ -27,7 +27,7 @@ var et2_tabbox = et2_DOMWidget.extend({ * Currently selected tab */ selected_index: 0, - init: function(_parent, _type) { + init: function() { // Create the outer tabbox container this.container = $j(document.createElement("div")) .addClass("et2_tabbox"); @@ -47,8 +47,7 @@ var et2_tabbox = et2_DOMWidget.extend({ this.tabData = []; }, - destroy: function(_parent, _type) { - + destroy: function() { this._super.apply(this, arguments); this.container = null; diff --git a/etemplate/js/et2_template.js b/etemplate/js/et2_template.js index 595beec143..daab619ec7 100644 --- a/etemplate/js/et2_template.js +++ b/etemplate/js/et2_template.js @@ -49,7 +49,7 @@ var et2_template = et2_DOMWidget.extend({ /** * Initializes this template widget as a simple container. */ - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.proxiedTemplate = null; diff --git a/etemplate/js/et2_textbox.js b/etemplate/js/et2_textbox.js index 8e058042fb..4104634db9 100644 --- a/etemplate/js/et2_textbox.js +++ b/etemplate/js/et2_textbox.js @@ -52,7 +52,7 @@ var et2_textbox = et2_inputWidget.extend({ }, }, - init: function(_parent) { + init: function() { this._super.apply(this, arguments); this.input = null; diff --git a/etemplate/js/et2_widget.js b/etemplate/js/et2_widget.js index 4ca5544da9..6e9d01331a 100644 --- a/etemplate/js/et2_widget.js +++ b/etemplate/js/et2_widget.js @@ -514,14 +514,13 @@ var et2_widget = Class.extend({ } // Translate the attributes - if (!_attrs["no_lang"]) + for (var key in _attrs) { - for (var key in _attrs) + if (_attrs[key] && typeof this.attributes[key] != "undefined") { - if (typeof this.attributes[key] != "undefined" && this.attributes[key].translate) - { - _attrs[key] = egw.lang(_attrs[key]); - } + if (this.attributes[key].translate === true || + (this.attributes[key].translate === "!no_lang" && !_attrs["no_lang"])) + _attrs[key] = egw.lang(_attrs[key]); } } }, diff --git a/etemplate/js/test/et2_test_timesheet_edit.json b/etemplate/js/test/et2_test_timesheet_edit.json index f62e2547d2..6494185413 100644 --- a/etemplate/js/test/et2_test_timesheet_edit.json +++ b/etemplate/js/test/et2_test_timesheet_edit.json @@ -70,7 +70,7 @@ var timesheet_data = { "button[save]":false, "button[save_new]":false, "button[apply]":false, - "ts_owner":true, +/* "ts_owner":true,*/ "tabs":{ "customfields":true } diff --git a/etemplate/js/test/et2_test_timesheet_edit.xet b/etemplate/js/test/et2_test_timesheet_edit.xet index 8918aa2bf4..35add6213d 100644 --- a/etemplate/js/test/et2_test_timesheet_edit.xet +++ b/etemplate/js/test/et2_test_timesheet_edit.xet @@ -129,7 +129,7 @@ - +