From 2a1b748241d09a600c8f4c3176059c87371f127b Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Sun, 5 Jan 2014 22:42:37 +0100 Subject: Ensure script works in jQuery.noConflict() mode --- .../source/prado/activecontrols/activecontrols3.js | 14 ++-- .../prado/activecontrols/activedatepicker.js | 24 +++---- .../source/prado/activecontrols/ajax3.js | 50 ++++++------- .../prado/activefileupload/activefileupload.js | 28 ++++---- .../source/prado/colorpicker/colorpicker.js | 8 +-- .../Javascripts/source/prado/controls/controls.js | 32 ++++----- .../Javascripts/source/prado/controls/htmlarea.js | 18 ++--- .../Javascripts/source/prado/controls/htmlarea4.js | 10 +-- .../Javascripts/source/prado/controls/slider.js | 84 +++++++++++----------- .../Javascripts/source/prado/controls/tabpanel.js | 6 +- .../source/prado/datepicker/datepicker.js | 34 ++++----- framework/Web/Javascripts/source/prado/prado.js | 56 +++++++-------- 12 files changed, 183 insertions(+), 181 deletions(-) (limited to 'framework/Web/Javascripts') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 71c9d73c..b471a300 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -108,9 +108,9 @@ Prado.WebUI.TJuiAutoComplete = jQuery.klass(Prado.WebUI.TActiveTextBox, }) jQuery('#'+options.ID).autocomplete(this.options) .data( "ui-autocomplete")._renderItem = function( ul, item ) { - return $( "
  • " ) + return jQuery( "
  • " ) .attr( "data-value", item.value ) - .append( $( "" ).html( item.label ) ) + .append( jQuery( "" ).html( item.label ) ) .appendTo( ul ); }; @@ -283,7 +283,7 @@ Prado.WebUI.TEventTriggeredCallback = jQuery.klass(Prado.WebUI.Control, onInit : function(options) { this.options = options || {} ; - var element = $('#'+options['ControlID']).get(0); + var element = jQuery('#'+options['ControlID']).get(0); if(element) this.observe(element, this.getEventName(element), this.doCallback.bind(this)); }, @@ -328,7 +328,7 @@ Prado.WebUI.TValueTriggeredCallback = jQuery.klass(Prado.WebUI.Control, { this.options = options || {} ; this.options.PropertyName = this.options.PropertyName || 'value'; - var element = $('#'+options['ControlID']).get(0); + var element = jQuery('#'+options['ControlID']).get(0); this.value = element ? element[this.options.PropertyName] : undefined; Prado.WebUI.TValueTriggeredCallback.register(this); this.startObserving(); @@ -347,7 +347,7 @@ Prado.WebUI.TValueTriggeredCallback = jQuery.klass(Prado.WebUI.Control, checkChanges : function() { - var element = $('#'+this.options.ControlID).get(0); + var element = jQuery('#'+this.options.ControlID).get(0); if(element) { var value = element[this.options.PropertyName]; @@ -401,7 +401,7 @@ Prado.WebUI.TActiveTableCell = jQuery.klass(Prado.WebUI.CallbackControl); Prado.WebUI.TActiveTableRow = jQuery.klass(Prado.WebUI.CallbackControl); Prado.WebUI.TActiveRatingList = jQuery.klass(Prado.WebUI.TRatingList, -{ +{ dispatchRequest : function(ev) { var requestOptions = jQuery.extend( @@ -413,5 +413,5 @@ Prado.WebUI.TActiveRatingList = jQuery.klass(Prado.WebUI.TRatingList, if(request.dispatch()==false) ev.preventDefault(); } - + }); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js index c0268077..dd0fc6f2 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -6,7 +6,7 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, onInit : function(options) { this.options = options || []; - this.control = $('#'+options.ID).get(0); + this.control = jQuery('#'+options.ID).get(0); this.dateSlot = new Array(42); this.weekSlot = new Array(6); this.minimalDaysInFirstWeek = 4; @@ -17,7 +17,7 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, //which element to trigger to show the calendar if(this.options.Trigger) { - this.trigger = $('#'+this.options.Trigger).get(0) ; + this.trigger = jQuery('#'+this.options.Trigger).get(0) ; var triggerEvent = this.options.TriggerEvent || "click"; } else @@ -25,7 +25,7 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, this.trigger = this.control; var triggerEvent = this.options.TriggerEvent || "focus"; } - + // Popup position if(this.options.PositionMode == 'Top') { @@ -36,12 +36,12 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, if (this.options.ShowCalendar) this.observe(this.trigger, triggerEvent, jQuery.proxy(this.show,this)); - - // Listen to change event + + // Listen to change event if(this.options.InputMode == "TextBox") { this.observe(this.control, "change", jQuery.proxy(this.onDateChanged,this)); - } + } else { var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); @@ -50,11 +50,11 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, if (day) this.observe (day, "change", jQuery.proxy(this.onDateChanged,this)); if (month) this.observe (month, "change", jQuery.proxy(this.onDateChanged,this)); if (year) this.observe (year, "change", jQuery.proxy(this.onDateChanged,this)); - + } - }, - + }, + // Respond to change event on the textbox or dropdown list // This method raises OnDateChanged event on client side if it has been defined, // and raise the callback request @@ -64,7 +64,7 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, if (this.options.InputMode == "TextBox") { date=this.control.value; - } + } else { var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); @@ -76,7 +76,7 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, date=new Date(year, month, day, 0,0,0).SimpleFormat(this.Format, this); } if (typeof(this.options.OnDateChanged) == "function") this.options.OnDateChanged(this, date); - + if(this.options['AutoPostBack']==true) { // Make callback request @@ -84,4 +84,4 @@ Prado.WebUI.TActiveDatePicker = jQuery.klass(Prado.WebUI.TDatePicker, request.dispatch(); } } -}); +}); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 0d306a89..597187bb 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -1,4 +1,4 @@ -Prado.CallbackRequestManager = +Prado.CallbackRequestManager = { /** * Callback request target POST field name. @@ -202,7 +202,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, if(this.options.onPreDispatch) this.options.onPreDispatch(this,null); - + // jQuery don't have all these states.. simulate them to avoid breaking old scripts if (this.options.onLoading) this.options.onLoading(this,null); @@ -352,7 +352,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, */ updatePageState : function(request, datain) { - var pagestate = $("#"+Prado.CallbackRequestManager.FIELD_CALLBACK_PAGESTATE); + var pagestate = jQuery("#"+Prado.CallbackRequestManager.FIELD_CALLBACK_PAGESTATE); var enabled = request.options.EnablePageStateUpdate; var aborted = false; //typeof(self.currentRequest) == 'undefined' || self.currentRequest == null; if(enabled && !aborted && pagestate) @@ -408,7 +408,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, }, /* - * Checks which assets are used by the response and ensures they're loaded + * Checks which assets are used by the response and ensures they're loaded */ loadAssets : function(request, datain, callback) { @@ -439,7 +439,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, }, /* - * Checks which scripts are used by the response and ensures they're loaded + * Checks which scripts are used by the response and ensures they're loaded */ loadScripts : function(request, datain, callback) { @@ -473,10 +473,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { var url = this.ScriptsToLoad.shift(); var obj = this; if ( - Prado.ScriptManager.ensureAssetIsLoaded(url, - function() { - obj.loadNextScript(); - } + Prado.ScriptManager.ensureAssetIsLoaded(url, + function() { + obj.loadNextScript(); + } ) ) this.loadNextScript(); @@ -560,10 +560,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, { var url = this.StyleSheetsToLoad.shift(); var obj = this; if ( - Prado.StyleSheetManager.ensureAssetIsLoaded(url, - function() { - obj.loadNextStyleSheet(); - } + Prado.StyleSheetManager.ensureAssetIsLoaded(url, + function() { + obj.loadNextStyleSheet(); + } ) ) this.loadNextStyleSheet(); @@ -591,8 +591,10 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, if(typeof(Logger) != "undefined") Logger.warn("Invalid action:"+data); } else { - for(var key in json) - this.__run(this, json[key]); + var that = this; + jQuery.each(json, function(idx, item){ + that.__run(that, item); + }); } } }, @@ -659,7 +661,7 @@ jQuery(function() // /** // * Prado Callback client-side request handler. // */ -// Prado.CallbackRequestManager = +// Prado.CallbackRequestManager = // { // requestQueue : [], @@ -795,11 +797,11 @@ jQuery(function() // this.Enabled = true; // this.id = id; // this.randomId = this.randomString(); - + // if(typeof(id)=="string"){ // Prado.CallbackRequestManager.requests[id+"__"+this.randomId] = this; // } - + // Prado.CallbackRequestManager.requests[id+"__"+this.randomId].ActiveControl = this.options; // }, @@ -864,7 +866,7 @@ if (typeof(Prado.AssetManagerClass)=="undefined") { discoverLoadedAssets: function() { // wait until document has finished loading to avoid javascript errors - if (!document.body) return; + if (!document.body) return; var assets = this.findAssetUrlsInMarkup(); for(var i=0;i0)) urls.push(href); diff --git a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js index 29c9e3d4..15998278 100755 --- a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js +++ b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js @@ -4,21 +4,21 @@ Prado.WebUI.TActiveFileUpload = jQuery.klass(Prado.WebUI.Control, { this.options = options || {}; Prado.WebUI.TActiveFileUpload.register(this); - - this.input = $('#'+options.inputID).get(0); - this.flag = $('#'+options.flagID).get(0); - this.form = $('#'+options.formID).get(0); - - this.indicator = $('#'+options.indicatorID).get(0); - this.complete = $('#'+options.completeID).get(0); - this.error = $('#'+options.errorID).get(0); - + + this.input = jQuery('#'+options.inputID).get(0); + this.flag = jQuery('#'+options.flagID).get(0); + this.form = jQuery('#'+options.formID).get(0); + + this.indicator = jQuery('#'+options.indicatorID).get(0); + this.complete = jQuery('#'+options.completeID).get(0); + this.error = jQuery('#'+options.errorID).get(0); + // set up events if (options.autoPostBack){ this.observe(this.input,"change",this.fileChanged.bind(this)); } }, - + fileChanged : function(){ // show the upload indicator, and hide the complete and error indicators (if they areSn't already). this.flag.value = '1'; @@ -43,7 +43,7 @@ Prado.WebUI.TActiveFileUpload = jQuery.klass(Prado.WebUI.Control, this.form.method = this.oldFormMethod; this.form.enctype = this.oldFormEnctype; }, - + finishUpload : function(options){ if (this.options.targetID == options.targetID) @@ -82,7 +82,7 @@ Prado.WebUI.TActiveFileUpload = jQuery.klass(Prado.WebUI.Control, }); -jQuery.extend(Prado.WebUI.TActiveFileUpload, +jQuery.extend(Prado.WebUI.TActiveFileUpload, { //class methods @@ -92,12 +92,12 @@ jQuery.extend(Prado.WebUI.TActiveFileUpload, { Prado.WebUI.TActiveFileUpload.controls[control.options.ID] = control; }, - + onFileUpload : function(options) { Prado.WebUI.TActiveFileUpload.controls[options.clientID].finishUpload(options); }, - + fileChanged : function(controlID){ Prado.WebUI.TActiveFileUpload.controls[controlID].fileChanged(); } diff --git a/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js b/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js index 54680922..9915eb81 100644 --- a/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js +++ b/framework/Web/Javascripts/source/prado/colorpicker/colorpicker.js @@ -93,7 +93,7 @@ Rico.Color.prototype = { toColorPart: function(number) { number = (number > 255 ? 255 : (number < 0 ? 0 : number)); var hex = number.toString(16); - return hex.length < 2 ? "0" + hex : hex; + return hex.length < 2 ? "0" + hex : hex; } }; @@ -265,13 +265,13 @@ Prado.WebUI.TColorPicker = jQuery.klass(Prado.WebUI.Control, { options = jQuery.extend(basics, options); this.options = options; - this.input = $('#'+options['ID']).get(0); - this.button = $('#'+options['ID']+'_button').get(0); + this.input = jQuery('#'+options['ID']).get(0); + this.button = jQuery('#'+options['ID']+'_button').get(0); this._buttonOnClick = jQuery.proxy(this.buttonOnClick, this); if(options['ShowColorPicker']) this.observe(this.button, "click", this._buttonOnClick); this.observe(this.input, "change", jQuery.proxy(this.updatePicker, this)); - + Prado.Registry[options.ID] = this; }, diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index 0f0b01f4..fa01e2e2 100644 --- a/framework/Web/Javascripts/source/prado/controls/controls.js +++ b/framework/Web/Javascripts/source/prado/controls/controls.js @@ -60,11 +60,11 @@ Prado.WebUI.Control = jQuery.klass({ // from the old wrapper to this new one (which then could live on, while the old // one could get destroyed), or to copy the new, changed options to the old wrapper, // (which could then left intact to keep working, while this new wrapper could be - // disposed of by exiting its initialization without installing any handlers or + // disposed of by exiting its initialization without installing any handlers or // leaving any references to it) // - // for now this method is simply deinitializing and deregistering the old wrapper, + // for now this method is simply deinitializing and deregistering the old wrapper, // and then registering the new wrapper for the control id if (oldwrapper.deinitialize) @@ -74,7 +74,7 @@ Prado.WebUI.Control = jQuery.klass({ }, /** - * Registers an event observer which will be automatically disposed of when the wrapper + * Registers an event observer which will be automatically disposed of when the wrapper * is deregistered * @param element DOM element reference or id to attach the event handler to * @param string event name to observe @@ -99,7 +99,7 @@ Prado.WebUI.Control = jQuery.klass({ var e = { _element: element, _eventName: eventName, _handler: handler }; var idx = -1; for(var i=0;i0) + while (this.intervals.length>0) window.clearInterval(this.intervals.pop()); // automatically deregister all installed observers - while (this.observers.length>0) + while (this.observers.length>0) { var e = this.observers.pop(); jQuery(e._element).unbind(e._eventName, e._handler); @@ -235,7 +235,7 @@ Prado.WebUI.PostBackControl = jQuery.klass(Prado.WebUI.Control, { { this._elementOnClick = null; - if (!this.element) + if (!this.element) debugger; // element not found else { @@ -284,7 +284,7 @@ Prado.WebUI.TImageMap = jQuery.klass(Prado.WebUI.PostBackControl); * TImageButton client-side behaviour. With validation, Firefox needs * to capture the x,y point of the clicked image in hidden form fields. */ -Prado.WebUI.TImageButton = jQuery.klass(Prado.WebUI.PostBackControl, +Prado.WebUI.TImageButton = jQuery.klass(Prado.WebUI.PostBackControl, { /** * Override parent onPostBack function, tried to add hidden forms @@ -351,7 +351,7 @@ Prado.WebUI.TRadioButton = jQuery.klass(Prado.WebUI.PostBackControl, { initialize : function($super, options) { - this.element = $("#" + options['ID']).get(0); + this.element = jQuery("#" + options['ID']).get(0); if(this.element) { if(!this.element.checked) @@ -386,14 +386,14 @@ Prado.WebUI.TTextBox = jQuery.klass(Prado.WebUI.PostBackControl, { if(this.options['AutoPostBack']==true) { - $(target).trigger( "change" ); + jQuery(target).trigger( "change" ); e.stopPropagation(); } else { if(this.options['CausesValidation'] && typeof(Prado.Validation) != "undefined") { - if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], $(this.options['ID']))) + if(!Prado.Validation.validate(this.options['FormID'], this.options['ValidationGroup'], jQuery(this.options['ID']))) return e.stopPropagation(); } } @@ -432,10 +432,10 @@ Prado.WebUI.DefaultButton = jQuery.klass(Prado.WebUI.Control, var isTextArea = ev.target.tagName.toLowerCase() == "textarea"; var isHyperLink = ev.target.tagName.toLowerCase() == "a" && ev.target.hasAttribute("href"); var isValidButton = ev.target.tagName.toLowerCase() == "input" && ev.target.type.toLowerCase() == "submit"; - + if(enterPressed && !isTextArea && !isValidButton && !isHyperLink) { - var defaultButton = $('#'+this.options['Target']); + var defaultButton = jQuery('#'+this.options['Target']); if(defaultButton) { this.triggered = true; diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea.js b/framework/Web/Javascripts/source/prado/controls/htmlarea.js index 819e853c..7bf820ab 100644 --- a/framework/Web/Javascripts/source/prado/controls/htmlarea.js +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea.js @@ -1,6 +1,6 @@ /* - * + * * HtmlArea (tinyMCE) wrapper * * @author Gabor Berczi @@ -24,7 +24,7 @@ Prado.WebUI.THtmlArea = jQuery.klass(Prado.WebUI.Control, this.registerInstance(); }, - + registerInstance: function() @@ -38,7 +38,7 @@ Prado.WebUI.THtmlArea = jQuery.klass(Prado.WebUI.Control, { // we're in a callback // try it again in some time, as tinyMCE is most likely still loading - this.setTimeout(this.registerInstance.bind(this), 50); + this.setTimeout(this.registerInstance.bind(this), 50); return; } throw "TinyMCE libraries must be loaded first"; @@ -62,7 +62,7 @@ Prado.WebUI.THtmlArea = jQuery.klass(Prado.WebUI.Control, } } }, - + compressedScriptsLoaded: function() { Prado.WebUI.THtmlArea.tinyMCELoadState = 255; @@ -119,14 +119,14 @@ Prado.WebUI.THtmlArea = jQuery.klass(Prado.WebUI.Control, if (prev) try { - tinyMCE.execCommand('mceFocus', false, this.ID); + tinyMCE.execCommand('mceFocus', false, this.ID); // when removed, tinyMCE restores its content to the textarea. If the textarea content has been // updated in this same callback, it will be overwritten with the old content. Workaround this. - var curtext = $('#'+this.ID).get(0).value; + var curtext = jQuery('#'+this.ID).get(0).value; tinyMCE.execCommand('mceRemoveControl', false, this.ID); - $('#'+this.ID).get(0).value = curtext; + jQuery('#'+this.ID).get(0).value = curtext; } - catch (e) + catch (e) { // suppress error here in case editor can't be properly removed // (happens when