1 (function ($, rf) { 2 3 rf.ui = rf.ui || {}; 4 5 var defaultOptions = { 6 useNative: false 7 }; 8 9 rf.ui.Placeholder = rf.BaseComponent.extendClass({ 10 11 name:"Placeholder", 12 13 init: function (componentId, options) { 14 $super.constructor.call(this, componentId); 15 options = $.extend({}, defaultOptions, options); 16 this.attachToDom(this.id); 17 $(function() { 18 options.className = 'rf-plhdr ' + ((options.styleClass) ? options.styleClass : ''); 19 var elements = (options.selector) ? $(options.selector) : $(document.getElementById(options.targetId)); 20 // finds all inputs within the subtree of target elements 21 var inputs = elements.find('*').andSelf().filter(':editable'); 22 inputs.watermark(options.text, options); 23 }); 24 }, 25 // destructor definition 26 destroy: function () { 27 // define destructor if additional cleaning is needed but 28 // in most cases its not nessesary. 29 // call parent’s destructor 30 $super.destroy.call(this); 31 } 32 }); 33 34 // once per all placeholders on a page 35 $(function() { 36 $(document).on('ajaxsubmit', 'form', $.watermark.hideAll); 37 $(document).on('ajaxbegin', 'form', $.watermark.showAll); 38 // need to use setTimeout to allow client's native reset to happen 39 $(document).on('reset', 'form', function() {setTimeout( $.watermark.showAll, 0); }); 40 }); 41 42 // define super class reference - reference to the parent prototype 43 var $super = rf.ui.Placeholder.$super; 44 })(RichFaces.jQuery, RichFaces);