From 9a8069a9b57e745ba0324fcafe40693f8adc1f42 Mon Sep 17 00:00:00 2001 From: Christian Binder Date: Thu, 2 Aug 2012 20:39:39 +0000 Subject: [PATCH] activating blur attribute for widget --- etemplate/js/et2_widget_itempicker.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/etemplate/js/et2_widget_itempicker.js b/etemplate/js/et2_widget_itempicker.js index e101c2412f..993bb674a3 100755 --- a/etemplate/js/et2_widget_itempicker.js +++ b/etemplate/js/et2_widget_itempicker.js @@ -35,7 +35,7 @@ var et2_itempicker = et2_inputWidget.extend({ "name": "Application", "type": "string", "default": "", - "description": "Limit to the listed application or applications (comma seperated)" + "description": "Limit to the listed application or applications (comma separated)" }, "blur": { "name": "Placeholder", @@ -137,6 +137,7 @@ var et2_itempicker = et2_inputWidget.extend({ request.term = $j(this).val(); _self.query(request); }); + this.set_blur(this.options.blur, this.search); // Clear button for search this.clear @@ -216,6 +217,28 @@ var et2_itempicker = et2_inputWidget.extend({ this.updateItemList(data); }, + set_blur: function(_value, input) { + if(typeof input == 'undefined') input = this.search; + + if(_value) { + input.attr("placeholder", _value); // HTML5 + if(!input[0].placeholder) { + // Not HTML5 + if(input.val() == "") input.val(_value); + input.focus(input,function(e) { + var placeholder = _value; + if(e.data.val() == placeholder) e.data.val(""); + }).blur(input, function(e) { + var placeholder = _value; + if(e.data.val() == "") e.data.val(placeholder); + }); + if(input.val() == "") input.val(_value); + } + } else { + this.search.removeAttr("placeholder"); + } + }, + transformAttributes: function(_attrs) { this._super.apply(this, arguments);