From c39b76f8a9ea4b0fba04accd73448202d65d0aeb Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Fri, 23 Mar 2012 19:25:50 +0000 Subject: [PATCH] Prevent some warnings about attributes --- etemplate/js/et2_extension_nextmatch.js | 5 ++++ etemplate/js/et2_widget_button.js | 32 ++++++++++++++++++++++--- etemplate/js/et2_widget_grid.js | 12 ++++++++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index cd5f3faf46..be37004651 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -1076,6 +1076,11 @@ var et2_nextmatch_header = et2_baseWidget.extend(et2_INextmatchHeader, { "type": "string", "description": "Caption for the nextmatch header", "translate": true + }, + "onchange": { + "name": "onchange", + "type": "string", + "description": "JS code which is executed when the value changes." } }, diff --git a/etemplate/js/et2_widget_button.js b/etemplate/js/et2_widget_button.js index c7a1d5c33f..cebda7516e 100644 --- a/etemplate/js/et2_widget_button.js +++ b/etemplate/js/et2_widget_button.js @@ -35,10 +35,19 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { "type": "string", "description": "Use an icon instead of label (when available)" }, + "ro_image": { + "name": "Read-only Icon", + "type": "string", + "description": "Use this icon instead of hiding for read-only" + }, "onclick": { "name": "onclick", "type": "string", "description": "JS code which gets executed when the button is clicked" + }, + // No such thing as a required button + "needed": { + "ignore": true, } }, @@ -50,7 +59,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { this.btn = null; this.image = null; - if (this.options.image) + if (this.options.image || this.options.ro_image) { this.image = jQuery(document.createElement("img")) .addClass("et2_button et2_button_icon"); @@ -65,9 +74,23 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { } }, + set_ro_image: function(_image) { + if(this.options.readonly) + { + this.set_image(_image); + } + }, + set_image: function(_image) { if(!this.isInTree() || this.image == null) return; + // Silently blank for percentages instead of warning about missing image - use a progress widget + if(_image.match(/[0-9]+\%/)) + { + _image = ""; + //this.egw().debug("warn", "Use a progress widget instead of percentage images", this); + } + this.options.image = _image; var found_image = false; @@ -160,7 +183,7 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { */ getDetachedAttributes: function(_attrs) { - _attrs.push("label", "value", "class", "image", "onclick" ); + _attrs.push("label", "value", "class", "image", "ro_image","onclick" ); }, getDetachedNodes: function() @@ -192,7 +215,10 @@ var et2_button = et2_baseWidget.extend([et2_IInput, et2_IDetachedDOM], { { this.set_image(_values["image"]); } - + if (typeof _values["ro_image"] != "undefined") + { + this.set_ro_image(_values["ro_image"]); + } if (typeof _values["class"] != "undefined") { this.set_class(_values["class"]); diff --git a/etemplate/js/et2_widget_grid.js b/etemplate/js/et2_widget_grid.js index 722ea4a3fe..feddbe05fc 100644 --- a/etemplate/js/et2_widget_grid.js +++ b/etemplate/js/et2_widget_grid.js @@ -26,6 +26,18 @@ */ var et2_grid = et2_DOMWidget.extend([et2_IDetachedDOM], { + attributes: { + // Better to use CSS, no need to warn about it + "border": { + "ignore": true + }, + "spacing": { + "ignore": true + }, + "padding": { + "ignore": true + } + }, init: function() { // Create the table body and the table this.tbody = $j(document.createElement("tbody"));