diff --git a/etemplate/js/et2_core_inputWidget.js b/etemplate/js/et2_core_inputWidget.js index 7d39427ba7..bad4de233b 100644 --- a/etemplate/js/et2_core_inputWidget.js +++ b/etemplate/js/et2_core_inputWidget.js @@ -39,6 +39,11 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], "type": "string", "description": "JS code which is executed when the value changes." }, + "onfocus": { + "name": "onfocus", + "type": "string", + "description": "JS code which get executed when wiget receives focus." + }, "validation_error": { "name": "Validation Error", "type": "string", @@ -70,6 +75,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], if (node) { $j(node).unbind("change.et2_inputWidget"); + $j(node).unbind("focus"); } this._super.apply(this, arguments); @@ -101,6 +107,9 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], $j(node).bind("change.et2_inputWidget", this, function(e) { e.data.change.call(e.data, this); }); + $j(node).bind("focus", this, function(e) { + e.data.focus.call(e.data, this); + }); } this._super.apply(this,arguments); @@ -138,6 +147,25 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener], } return valid; }, + + focus: function(_node) + { + if (this.options.onfocus) + { + if(typeof this.options.onfocus == 'function') + { + // Make sure function gets a reference to the widget + var args = Array.prototype.slice.call(arguments); + if(args.indexOf(this) == -1) args.push(this); + + return this.options.onfocus.apply(this, args); + } + else + { + return (et2_compileLegacyJS(this.options.onfocus, this, _node))(); + } + } + }, set_value: function(_value) { diff --git a/etemplate/js/et2_widget_taglist.js b/etemplate/js/et2_widget_taglist.js index 559e818e46..8a56980fed 100644 --- a/etemplate/js/et2_widget_taglist.js +++ b/etemplate/js/et2_widget_taglist.js @@ -187,6 +187,12 @@ var et2_taglist = et2_selectbox.extend( this.click(event.target, $j(event.target).parent().data("json")); },this)); } + + // onFocus + if (this.options.onfocus) + { + $j(this.taglist).on("focus", jQuery.proxy(this.focus,this)); + } return true; },