diff options
Diffstat (limited to 'framework/Web/Javascripts/source')
17 files changed, 477 insertions, 427 deletions
diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index 71c9d73c..907d930e 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -50,18 +50,17 @@ Prado.WebUI.TActiveCheckBox = jQuery.klass(Prado.WebUI.CallbackControl, Prado.WebUI.TActiveRadioButton = jQuery.klass(Prado.WebUI.TActiveCheckBox); -Prado.WebUI.TActiveCheckBoxList = jQuery.extend( +Prado.WebUI.TActiveCheckBoxList = jQuery.klass(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { - Prado.Registry[options.ListID] = this; for(var i = 0; i<options.ItemCount; i++) { - var checkBoxOptions = jQuery.extend( + var checkBoxOptions = jQuery.extend({}, options, { - ID : options.ListID+"_c"+i, + ID : options.ID+"_c"+i, EventTarget : options.ListName+"$c"+i - }, options); + }); new Prado.WebUI.TActiveCheckBox(checkBoxOptions); } } @@ -108,9 +107,9 @@ Prado.WebUI.TJuiAutoComplete = jQuery.klass(Prado.WebUI.TActiveTextBox, }) jQuery('#'+options.ID).autocomplete(this.options) .data( "ui-autocomplete")._renderItem = function( ul, item ) { - return $( "<li>" ) + return jQuery( "<li>" ) .attr( "data-value", item.value ) - .append( $( "<a>" ).html( item.label ) ) + .append( jQuery( "<a>" ).html( item.label ) ) .appendTo( ul ); }; @@ -283,7 +282,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 +327,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 +346,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 +400,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 +412,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..e6616176 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. @@ -66,6 +66,55 @@ Prado.CallbackRequestManager = } msg += e.version+" "+e.time+"\n"; return msg; + }, + + /*! jQuery Ajax Queue - v0.1.2pre - 2013-03-19 + * https://github.com/gnarf37/jquery-ajaxQueue + * Copyright (c) 2013 Corey Frang; Licensed MIT + * Slightly adapted for use within prado by Fabio Bas <ctrlaltca@gmail.com> + */ + + // jQuery on an empty object, we are going to use this as our Queue + ajaxQueue : jQuery({}), + + ajax : function( ajaxOpts ) { + var jqXHR, + dfd = jQuery.Deferred(), + promise = dfd.promise(); + + // run the actual query + function doRequest( next ) { + jqXHR = jQuery.ajax( ajaxOpts ); + jqXHR.done( dfd.resolve ) + .fail( dfd.reject ) + .then( next, next ); + } + + // queue our ajax request + Prado.CallbackRequestManager.ajaxQueue.queue( doRequest ); + + // add the abort method + promise.abort = function( statusText ) { + + // proxy abort to the jqXHR if it is active + if ( jqXHR ) { + return jqXHR.abort( statusText ); + } + + // if there wasn't already a jqXHR we need to remove from queue + var queue = Prado.CallbackRequestManager.ajaxQueue.queue(), + index = jQuery.inArray( doRequest, queue ); + + if ( index > -1 ) { + queue.splice( index, 1 ); + } + + // and then reject the deferred + dfd.rejectWith( ajaxOpts.context || ajaxOpts, [ promise, statusText, "" ] ); + return promise; + }; + + return promise; } }; @@ -202,7 +251,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); @@ -215,7 +264,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, this.options.data = this.getParameters(); this.options.url = this.getCallbackUrl(); - this.request = jQuery.ajax(this.options); + this.request = Prado.CallbackRequestManager.ajax(this.options); }, abort : function() @@ -239,7 +288,7 @@ Prado.CallbackRequest = jQuery.klass(Prado.PostBack, if(this.options.EventTarget) data[Prado.CallbackRequestManager.FIELD_CALLBACK_TARGET] = this.options.EventTarget; - if(this.options.PostInputs != false) + if(this.options.PostInputs != false) return jQuery(form).serialize() + '&' + jQuery.param(data); else return jQuery.param(data); @@ -352,7 +401,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 +457,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 +488,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 +522,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 +609,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 +640,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 +710,7 @@ jQuery(function() // /** // * Prado Callback client-side request handler. // */ -// Prado.CallbackRequestManager = +// Prado.CallbackRequestManager = // { // requestQueue : [], @@ -795,11 +846,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 +915,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;i<assets.length;i++) @@ -873,11 +924,11 @@ if (typeof(Prado.AssetManagerClass)=="undefined") { /** * Extend url to a fully qualified url. - * @param string url + * @param string url */ makeFullUrl: function(url) { - // this is not intended to be a fully blown url "canonicalizator", + // this is not intended to be a fully blown url "canonicalizator", // just to handle the most common and basic asset paths used by Prado if (!this.baseUri) this.baseUri = window.location; @@ -906,7 +957,7 @@ if (typeof(Prado.AssetManagerClass)=="undefined") { /** * Mark asset as being already loaded - * @param string url of the asset + * @param string url of the asset */ markAssetAsLoaded: function(url) { url = this.makeFullUrl(url); @@ -987,7 +1038,7 @@ Prado.ScriptManagerClass = jQuery.klass(Prado.AssetManagerClass, { var urls = new Array(); var scripts = document.getElementsByTagName('script'); for(var i=0;i<scripts.length;i++) - { + { var e = scripts[i]; var src = e.src; if (src!="") urls.push(src); @@ -1011,7 +1062,7 @@ Prado.StyleSheetManagerClass = jQuery.klass(Prado.AssetManagerClass, { var urls = new Array(); var scripts = document.getElementsByTagName('link'); for(var i=0;i<scripts.length;i++) - { + { var e = scripts[i]; var href = e.href; if ((e.rel=="stylesheet") && (href.length>0)) urls.push(href); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/autocomplete.js b/framework/Web/Javascripts/source/prado/activecontrols/autocomplete.js new file mode 100644 index 00000000..180ceecf --- /dev/null +++ b/framework/Web/Javascripts/source/prado/activecontrols/autocomplete.js @@ -0,0 +1,84 @@ +jQuery.noConflict(); + +/** + * TAutoComplete control. + */ +Prado.WebUI.TAutoComplete = Class.create(Autocompleter.Base, Prado.WebUI.TActiveTextBox.prototype); +Prado.WebUI.TAutoComplete = Class.create(Prado.WebUI.TAutoComplete, +{ + initialize : function(options) + { + this.options = options; + this.observers = new Array(); + this.hasResults = false; + this.baseInitialize(options.ID, options.ResultPanel, options); + Object.extend(this.options, + { + onSuccess : this.onComplete.bind(this) + }); + + if(options.AutoPostBack) + this.onInit(options); + + Prado.Registry[options.ID] = this; + }, + + doCallback : function(event, options) + { + if(!this.active) + { + var request = new Prado.CallbackRequest(this.options.EventTarget, options); + request.dispatch(); + Event.stop(event); + } + }, + + //Overrides parent implementation, fires onchange event. + onClick: function(event) + { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.selectEntry(); + this.hide(); + Event.fire(this.element, "change"); + }, + + getUpdatedChoices : function() + { + var options = new Array(this.getToken(),"__TAutoComplete_onSuggest__"); + Prado.Callback(this.options.EventTarget, options, null, this.options); + }, + + /** + * Overrides parent implements, don't update if no results. + */ + selectEntry: function() + { + if(this.hasResults) + { + this.active = false; + this.updateElement(this.getCurrentEntry()); + var options = [this.index, "__TAutoComplete_onSuggestionSelected__"]; + Prado.Callback(this.options.EventTarget, options, null, this.options); + } + }, + + onComplete : function(request, boundary) + { + var result = request.extractContent(boundary); + if(typeof(result) == "string") + { + if(result.length > 0) + { + this.hasResults = true; + this.updateChoices(result); + } + else + { + this.active = false; + this.hasResults = false; + this.hide(); + } + } + } +});
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js index 7fa9e791..9e583c1f 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js @@ -1,20 +1,22 @@ +jQuery.noConflict(); + /** * DropContainer control */ - -Prado.WebUI.DropContainer = jQuery.klass(Prado.WebUI.CallbackControl, + +Prado.WebUI.DropContainer = Class.create(Prado.WebUI.CallbackControl, { onInit: function(options) { this.options = options; - Object.extend (this.options, + Object.extend (this.options, { onDrop: this.onDrop.bind(this) }); - + Droppables.add (options.ID, this.options); }, - + onDrop: function(dragElement, dropElement, event) { var elementId=dragElement.id.replace(/clone_/,""); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js index d2a17c8d..66862584 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js @@ -8,13 +8,13 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, this.editField = null; this.readOnly = options.ReadOnly; - this.options = Object.extend( + this.options = jQuery.extend( { LoadTextFromSource : false, TextMode : 'SingleLine' }, options || {}); - this.element = $(this.options.ID); + this.element = jQuery('#'+this.options.ID).get(0); Prado.WebUI.TInPlaceTextBox.register(this); this.createEditorInput(); this.initializeListeners(); @@ -25,10 +25,10 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, */ initializeListeners : function() { - this.onclickListener = this.enterEditMode.bindAsEventListener(this); + this.onclickListener = this.enterEditMode.bind(this); this.observe(this.element, 'click', this.onclickListener); if (this.options.ExternalControl) - this.observe($(this.options.ExternalControl), 'click', this.onclickListener); + this.observe(jQuery('#'+this.options.ExternalControl).get(0), 'click', this.onclickListener); }, /** @@ -45,9 +45,9 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, this.editField.disabled = false; if(this.options.LoadTextOnEdit) this.loadExternalText(); - Prado.Element.focus(this.editField); + jQuery(this.editField).focus(); if (evt) - Event.stop(evt); + evt.preventDefault(); return false; }, @@ -62,14 +62,14 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, showTextBox : function() { - Element.hide(this.element); - Element.show(this.editField); + jQuery(this.element).hide(); + jQuery(this.editField).show(); }, showLabel : function() { - Element.show(this.element); - Element.hide(this.editField); + jQuery(this.element).show(); + jQuery(this.editField).hide(); }, /** @@ -91,8 +91,8 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); request.setCausesValidation(false); request.setCallbackParameter(options); - request.ActiveControl.onSuccess = this.onloadExternalTextSuccess.bind(this); - request.ActiveControl.onFailure = this.onloadExternalTextFailure.bind(this); + request.options.onSuccess = this.onloadExternalTextSuccess.bind(this); + request.options.onFailure = this.onloadExternalTextFailure.bind(this); request.dispatch(); }, @@ -103,41 +103,44 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, { var cssClass= this.element.className || ''; var inputName = this.options.EventTarget; - var options = {'className' : cssClass, name : inputName, id : this.options.TextBoxID}; + if(this.options.TextMode == 'SingleLine') { + this.editField = document.createElement("input"); if(this.options.MaxLength > 0) - options['maxlength'] = this.options.MaxLength; + this.editField.maxlength = this.options.MaxLength; if(this.options.Columns > 0) - options['size'] = this.options.Columns; - this.editField = INPUT(options); + this.editField.size = this.options.Columns; } else { + this.editField = document.createElement("textarea"); if(this.options.Rows > 0) - options['rows'] = this.options.Rows; + this.editField.rows = this.options.Rows; if(this.options.Columns > 0) - options['cols'] = this.options.Columns; + this.editField.cols = this.options.Columns; if(this.options.Wrap) - options['wrap'] = 'off'; - this.editField = TEXTAREA(options); + this.editField.wrap = 'off'; } + this.editField.className = cssClass; + this.editField.name = inputName; + this.editField.id = this.options.TextBoxID; this.editField.style.display="none"; - this.element.parentNode.insertBefore(this.editField,this.element) - + this.element.parentNode.insertBefore(this.editField, this.element) + //handle return key within single line textbox if(this.options.TextMode == 'SingleLine') { this.observe(this.editField, "keydown", function(e) { - if(Event.keyCode(e) == Event.KEY_RETURN) + if(e.keyCode == 13) //KEY_RETURN { - var target = Event.element(e); + var target = e.target; if(target) { - Event.fireEvent(target, "blur"); - Event.stop(e); + jQuery(target).trigger("blur"); + e.preventDefault(); } } }); @@ -183,15 +186,16 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, onKeyPressed : function(e) { - if (Event.keyCode(e) == Event.KEY_ESC) + if (e.keyCode == 27) //KEY_ESC { this.editField.value = this.getText(); this.isEditing = false; if(this.options.AutoHide) this.showLabel(); } - else if (Event.keyCode(e) == Event.KEY_RETURN && this.options.TextMode != 'MultiLine') - Event.stop(e); + else if (e.keyCode == 13 // KEY_RETURN + && this.options.TextMode != 'MultiLine') + e.preventDefault() }, /** @@ -202,8 +206,8 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, { var request = new Prado.CallbackRequest(this.options.EventTarget, this.options); request.setCallbackParameter(text); - request.ActiveControl.onSuccess = this.onTextChangedSuccess.bind(this); - request.ActiveControl.onFailure = this.onTextChangedFailure.bind(this); + request.options.onSuccess = this.onTextChangedSuccess.bind(this); + request.options.onFailure = this.onTextChangedFailure.bind(this); if(request.dispatch()) { this.isSaving = true; @@ -224,7 +228,7 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, this.isEditing = true; this.editField.disabled = false; this.editField.value = this.getText(); - Prado.Element.focus(this.editField); + jQuery(this.editField).focus(); if(typeof(this.options.onSuccess)=="function") this.options.onSuccess(sender,parameter); }, @@ -266,7 +270,7 @@ Prado.WebUI.TInPlaceTextBox = jQuery.klass(Prado.WebUI.Control, }); -Object.extend(Prado.WebUI.TInPlaceTextBox, +jQuery.extend(Prado.WebUI.TInPlaceTextBox, { //class methods 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/accordion.js b/framework/Web/Javascripts/source/prado/controls/accordion.js index 28075cd6..084aef7f 100644 --- a/framework/Web/Javascripts/source/prado/controls/accordion.js +++ b/framework/Web/Javascripts/source/prado/controls/accordion.js @@ -1,8 +1,9 @@ -/* Simple Accordion Script +/* Simple Accordion Script * Requires Prototype and Script.aculo.us Libraries * By: Brian Crescimanno <brian.crescimanno@gmail.com> * http://briancrescimanno.com * Adapted to Prado & minor improvements: Gabor Berczi <gabor.berczi@devworx.hu> + * jQuery port by Bas Fabio <ctrlaltca@gmail.com> * This work is licensed under the Creative Commons Attribution-Share Alike 3.0 * http://creativecommons.org/licenses/by-sa/3.0/us/ */ @@ -11,9 +12,9 @@ Prado.WebUI.TAccordion = jQuery.klass(Prado.WebUI.Control, { onInit : function(options) { - this.accordion = $(options.ID); + this.accordion = jQuery('#'+options.ID).get(0); this.options = options; - this.hiddenField = $(options.ID+'_1'); + this.hiddenField = jQuery('#'+options.ID+'_1').get(0); if (this.options.maxHeight) { @@ -29,15 +30,15 @@ Prado.WebUI.TAccordion = jQuery.klass(Prado.WebUI.Control, var i = 0; for(var view in this.options.Views) { - var header = $(view+'_0'); + var header = jQuery('#'+view+'_0').get(0); if(header) { this.observe(header, "click", jQuery.proxy(this.elementClicked,this,view)); if(this.hiddenField.value == i) { this.currentView = view; - if($(this.currentView).getHeight() != this.maxHeight) - $(this.currentView).setStyle({height: this.maxHeight+"px"}); + if(jQuery('#'+this.currentView).height() != this.maxHeight) + jQuery('#'+this.currentView).css({height: this.maxHeight+"px"}); } } i++; @@ -48,38 +49,20 @@ Prado.WebUI.TAccordion = jQuery.klass(Prado.WebUI.Control, { for(var viewID in this.options.Views) { - var view = $(viewID); - if(view.getHeight() > this.maxHeight) - this.maxHeight = view.getHeight(); + var view = jQuery('#'+viewID); + if(view.height() > this.maxHeight) + this.maxHeight = view.height(); } }, - elementClicked : function(event,viewID) - { - // dummy effect to force processing of click into the event queue - // is not actually supposed to change the appearance of the accordion - var obj = this; - new Effect.Opacity( - this.element, - { - from: 1.0, to: 1.0, duration: 0.0, - queue: { - position: 'end', - scope: 'accordion' - }, - afterFinish: function() { obj.processElementClick(event, viewID); } - } - ); - }, - - processElementClick : function(event,viewID) + elementClicked : function(viewID, event) { var i = 0; for(var index in this.options.Views) { - if ($(index)) + if (jQuery('#'+index).get(0)) { - var header = $(index+'_0'); + var header = jQuery('#'+index+'_0').get(0); if(index == viewID) { this.oldView = this.currentView; @@ -96,75 +79,31 @@ Prado.WebUI.TAccordion = jQuery.klass(Prado.WebUI.Control, { this.animate(); } else { - $(this.currentView).setStyle({ height: this.maxHeight+"px" }); - $(this.currentView).show(); - $(this.oldView).hide(); - - var oldHeader = $(this.oldView+'_0'); - var currentHeader = $(this.currentView+'_0'); - oldHeader.className=this.options.HeaderCssClass; - currentHeader.className=this.options.ActiveHeaderCssClass; + jQuery('#'+this.currentView).css({ height: this.maxHeight+"px" }); + jQuery('#'+this.currentView).show(); + jQuery('#'+this.oldView).hide(); + + jQuery('#'+this.oldView+'_0').removeClass().addClass(this.options.HeaderCssClass); + jQuery('#'+this.currentView+'_0').removeClass().addClass(this.options.ActiveHeaderCssClass); } } }, animate: function() { - var effects = new Array(); - var options = { - sync: true, - queue: { - position: 'end', - scope: 'accordion' - }, - scaleFrom: 0, - scaleContent: false, - transition: Effect.Transitions.sinoidal, - scaleMode: { - originalHeight: this.maxHeight, - originalWidth: this.accordion.getWidth() - }, - scaleX: false, - scaleY: true - }; - - effects.push(new Effect.Scale(this.currentView, 100, options)); - - options = { - sync: true, - queue: { - position: 'end', - scope: 'accordion' - }, - scaleContent: false, - transition: Effect.Transitions.sinoidal, - scaleX: false, - scaleY: true - }; - - effects.push(new Effect.Scale(this.oldView, 0, options)); - - var oldHeader = $(this.oldView+'_0'); - var currentHeader = $(this.currentView+'_0'); - - new Effect.Parallel(effects, { - duration: this.options.Duration, - fps: 35, - queue: { - position: 'end', - scope: 'accordion' - }, - beforeStart: function() { - $(this.currentView).setStyle({ height: "0px" }); - $(this.currentView).show(); - - oldHeader.className=this.options.HeaderCssClass; - currentHeader.className=this.options.ActiveHeaderCssClass; - }.bind(this), - afterFinish: function() { - $(this.oldView).hide(); - $(this.currentView).setStyle({ height: this.maxHeight+"px" }); - }.bind(this) - }); + jQuery('#'+this.oldView+'_0').removeClass().addClass(this.options.HeaderCssClass); + jQuery('#'+this.currentView+'_0').removeClass().addClass(this.options.ActiveHeaderCssClass); + + jQuery('#'+this.oldView).animate( + {height: 0}, + this.options.Duration, + function() { + jQuery(this).hide() + } + ); + jQuery('#'+this.currentView).css({height: 0}).show().animate( + {height: this.maxHeight+'px'}, + this.options.Duration + ); } }); diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index 0f0b01f4..00a39e66 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;i<this.observers.length;i++) - { + { var o = this.observers[i]; if ((o._element===element) && (o._eventName===eventName) && (o._handler===handler)) { @@ -109,7 +109,7 @@ Prado.WebUI.Control = jQuery.klass({ } return idx; }, - + /** * Degisters an event observer from the list of automatically disposed handlers @@ -133,11 +133,11 @@ Prado.WebUI.Control = jQuery.klass({ * wrapper hasn't been destroyed in the meantime * @param code function or code snippet to execute * @param int number of milliseconds to wait before executing - * @return int unique ID that can be used to cancel the scheduled execution + * @return int unique ID that can be used to cancel the scheduled execution */ setTimeout: function(func, delay) { - if (!jQuery.isFunction(func)) + if (!jQuery.isFunction(func)) { var expr = func; func = function() { return eval(expr); } @@ -209,11 +209,11 @@ Prado.WebUI.Control = jQuery.klass({ this.onDone(); // automatically stop all intervals - while (this.intervals.length>0) + 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,17 +284,17 @@ 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 * inputs to capture x,y clicked point. */ - onPostBack : function(event, options) + onPostBack : function(options, event) { - this.addXYInput(event,options); - new Prado.PostBack(event, options); - this.removeXYInput(event,options); + this.addXYInput(options, event); + new Prado.PostBack(options, event); + this.removeXYInput(options, event); }, /** @@ -302,7 +302,7 @@ Prado.WebUI.TImageButton = jQuery.klass(Prado.WebUI.PostBackControl, * @param event DOM click event. * @param array image button options. */ - addXYInput : function(event,options) + addXYInput : function(options, event) { var imagePos = jQuery(this.element).offset(); var clickedPos = [event.clientX, event.clientY]; @@ -335,7 +335,7 @@ Prado.WebUI.TImageButton = jQuery.klass(Prado.WebUI.PostBackControl, * @param event DOM click event. * @param array image button options. */ - removeXYInput : function(event,options) + removeXYInput : function(options, event) { var id = this.element.id; jQuery('#'+id+'_x').remove(); @@ -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; @@ -496,16 +496,15 @@ jQuery.klass(Prado.WebUI.TTextHighlighter, Prado.WebUI.TCheckBoxList = jQuery.klass(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { - Prado.Registry.set(options.ListID, this); for(var i = 0; i<options.ItemCount; i++) { - var checkBoxOptions = jQuery.extend( + var checkBoxOptions = jQuery.extend({}, options, { - ID : options.ListID+"_c"+i, + ID : options.ID+"_c"+i, EventTarget : options.ListName+"$c"+i - }, options); + }); new Prado.WebUI.TCheckBox(checkBoxOptions); } } @@ -513,16 +512,15 @@ Prado.WebUI.TCheckBoxList = jQuery.klass(Prado.WebUI.Control, Prado.WebUI.TRadioButtonList = jQuery.klass(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { - Prado.Registry.set(options.ListID, this); for(var i = 0; i<options.ItemCount; i++) { - var radioButtonOptions = jQuery.extend( + var radioButtonOptions = jQuery.extend({}, options, { - ID : options.ListID+"_c"+i, + ID : options.ID+"_c"+i, EventTarget : options.ListName+"$c"+i - }, options); + }); new Prado.WebUI.TRadioButton(radioButtonOptions); } } 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 <gabor.berczi@devworx.hu> @@ -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 <textarea> has been removed from DOM tree without deinitialzing the tinyMCE editor first) @@ -139,7 +139,7 @@ Prado.WebUI.THtmlArea = jQuery.klass(Prado.WebUI.Control, } }); -jQuery.extend(Prado.WebUI.THtmlArea, +jQuery.extend(Prado.WebUI.THtmlArea, { pendingRegistrations : [], tinyMCELoadState : 0 diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea4.js b/framework/Web/Javascripts/source/prado/controls/htmlarea4.js index 418a6e19..64a78176 100644 --- a/framework/Web/Javascripts/source/prado/controls/htmlarea4.js +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea4.js @@ -1,6 +1,6 @@ /* - * + * * HtmlArea (tinyMCE 4) wrapper * * @author Gabor Berczi <gabor.berczi@devworx.hu> @@ -39,14 +39,14 @@ Prado.WebUI.THtmlArea4 = 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).html(); + // var curtext = jQuery(this.ID).html(); tinyMCE.execCommand('mceRemoveControl', false, this.ID); - // $(this.ID).html(curtext); + // jQuery(this.ID).html(curtext); } - catch (e) + catch (e) { // suppress error here in case editor can't be properly removed // (happens when <textarea> has been removed from DOM tree without deinitialzing the tinyMCE editor first) diff --git a/framework/Web/Javascripts/source/prado/controls/slider.js b/framework/Web/Javascripts/source/prado/controls/slider.js index 28d7d4ac..e18fde84 100644 --- a/framework/Web/Javascripts/source/prado/controls/slider.js +++ b/framework/Web/Javascripts/source/prado/controls/slider.js @@ -9,33 +9,33 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, { var slider = this; this.options=options || {}; - this.track = $('#'+options.ID+'_track').get(0); - this.handle =$('#'+options.ID+'_handle').get(0); - this.progress = $('#'+options.ID+'_progress').get(0); + this.track = jQuery('#'+options.ID+'_track').get(0); + this.handle =jQuery('#'+options.ID+'_handle').get(0); + this.progress = jQuery('#'+options.ID+'_progress').get(0); this.axis = this.options.axis || 'horizontal'; this.range = this.options.range || [0, 1]; this.value = 0; this.maximum = this.options.maximum || this.range[1]; this.minimum = this.options.minimum || this.range[0]; - this.hiddenField=$('#'+this.options.ID+'_1').get(0); - + this.hiddenField=jQuery('#'+this.options.ID+'_1').get(0); + // Will be used to align the handle onto the track, if necessary this.alignX = parseInt(this.options.alignX || - this.track.offsetLeft); this.alignY = parseInt(this.options.alignY || - this.track.offsetTop); - + this.trackLength = this.maximumOffset() - this.minimumOffset(); - this.handleLength = this.isVertical() ? - (this.handle.offsetHeight != 0 ? - this.handle.offsetHeight : this.handles.style.height.replace(/px$/,"")) : - (this.handle.offsetWidth != 0 ? this.handle.offsetWidth : + this.handleLength = this.isVertical() ? + (this.handle.offsetHeight != 0 ? + this.handle.offsetHeight : this.handles.style.height.replace(/px$/,"")) : + (this.handle.offsetWidth != 0 ? this.handle.offsetWidth : this.handle.style.width.replace(/px$/,"")); - + this.active = false; this.dragging = false; this.disabled = false; if(this.options.disabled) this.setDisabled(); - + // Allowed values array this.allowedValues = this.options.values ? this.options.values.sort() : false; if(this.allowedValues) { @@ -50,15 +50,15 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, // Initialize handle this.setValue(parseFloat(slider.options.sliderValue)); this.observe (this.handle, "mousedown", this.eventMouseDown); - + this.observe (this.track, "mousedown", this.eventMouseDown); if (this.progress) this.observe (this.progress, "mousedown", this.eventMouseDown); - + this.observe (document, "mouseup", this.eventMouseUp); this.observe (document, "mousemove", this.eventMouseMove); - + this.initialized=true; - + if(this.options['AutoPostBack']==true) this.observe(this.hiddenField, "change", jQuery.proxy(this.doPostback,this,options)); }, @@ -67,20 +67,20 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, { new Prado.PostBack(options, event); }, - + setDisabled: function(){ this.disabled = true; }, setEnabled: function(){ this.disabled = false; - }, + }, getNearestValue: function(value){ if(this.allowedValues){ var max = Math.max.apply( Math, this.allowedValues ); var min = Math.min.apply( Math, this.allowedValues ); if(value >= max) return(max); if(value <= min) return(min); - + var offset = Math.abs(this.allowedValues[0] - value); var newValue = this.allowedValues[0]; jQuery.each(this.allowedValues, function(idx, v) { @@ -88,7 +88,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, if(currentOffset <= offset){ newValue = v; offset = currentOffset; - } + } }); return newValue; } @@ -96,7 +96,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, if(value < this.range[0]) return this.range[0]; return value; }, - + setValue: function(sliderValue){ if(!this.active) { this.updateStyles(); @@ -106,47 +106,47 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, this.handle.style[this.isVertical() ? 'top' : 'left'] = pixelValue; if (this.progress) this.progress.style[this.isVertical() ? 'height' : 'width'] = pixelValue; - + //this.drawSpans(); if(!this.dragging || !this.event) this.updateFinished(); }, - + setValueBy: function(delta) { this.setValue(this.value + delta); }, - + translateToPx: function(value) { return Math.round( ((this.trackLength-this.handleLength)/(this.range[1]-this.range[0])) * (value - this.range[0])) + "px"; }, - + translateToValue: function(offset) { return ((offset/(this.trackLength-this.handleLength) * (this.range[1]-this.range[0])) + this.range[0]); }, - + minimumOffset: function(){ return(this.isVertical() ? this.alignY : this.alignX); }, - + maximumOffset: function(){ - return(this.isVertical() ? + return(this.isVertical() ? (this.track.offsetHeight != 0 ? this.track.offsetHeight : - this.track.style.height.replace(/px$/,"")) - this.alignY : - (this.track.offsetWidth != 0 ? this.track.offsetWidth : + this.track.style.height.replace(/px$/,"")) - this.alignY : + (this.track.offsetWidth != 0 ? this.track.offsetWidth : this.track.style.width.replace(/px$/,"")) - this.alignX); }, - + isVertical: function(){ return (this.axis == 'vertical'); }, - + updateStyles: function() { - if (this.active) + if (this.active) jQuery(this.handle).addClass('selected'); else jQuery(this.handle).removeClass('selected'); }, - + startDrag: function(event) { if (event.which === 1) { // left click @@ -158,7 +158,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, if(track==this.track) { var offsets = jQuery(this.track).offset(); this.event = event; - this.setValue(this.translateToValue( + this.setValue(this.translateToValue( (this.isVertical() ? pointer[1]-offsets['top'] : pointer[0]-offsets['left'])-(this.handleLength/2) )); var offsets = jQuery(this.handle).offset(); @@ -174,7 +174,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, event.stopPropagation(); } }, - + update: function(event) { if(this.active) { if(!this.dragging) this.dragging = true; @@ -182,7 +182,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, event.stopPropagation(); } }, - + draw: function(event) { var pointer = [event.pageX, event.pageY]; var offsets = jQuery(this.track).offset(); @@ -193,7 +193,7 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, if(this.initialized && this.options.onSlide) this.options.onSlide(this.value, this); }, - + endDrag: function(event) { if(this.active && this.dragging) { this.finishDrag(event, true); @@ -201,18 +201,18 @@ Prado.WebUI.TSlider = jQuery.klass(Prado.WebUI.PostBackControl, } this.active = false; this.dragging = false; - }, - + }, + finishDrag: function(event, success) { this.active = false; this.dragging = false; this.updateFinished(); }, - + updateFinished: function() { this.hiddenField.value=this.value; this.updateStyles(); - if(this.initialized && this.options.onChange) + if(this.initialized && this.options.onChange) this.options.onChange(this.value, this); this.event = null; if (this.options['AutoPostBack']==true) diff --git a/framework/Web/Javascripts/source/prado/controls/tabpanel.js b/framework/Web/Javascripts/source/prado/controls/tabpanel.js index 78f6478c..866e45fb 100644 --- a/framework/Web/Javascripts/source/prado/controls/tabpanel.js +++ b/framework/Web/Javascripts/source/prado/controls/tabpanel.js @@ -4,7 +4,7 @@ Prado.WebUI.TTabPanel = jQuery.klass(Prado.WebUI.Control, { this.views = options.Views; this.viewsvis = options.ViewsVis; - this.hiddenField = $("#"+options.ID+'_1').get(0); + this.hiddenField = jQuery("#"+options.ID+'_1').get(0); this.activeCssClass = options.ActiveCssClass; this.normalCssClass = options.NormalCssClass; var length = options.Views.length; @@ -18,10 +18,10 @@ Prado.WebUI.TTabPanel = jQuery.klass(Prado.WebUI.Control, if (options.AutoSwitch) this.observe(element, "mouseenter", jQuery.proxy(this.elementClicked,this,item)); } - + if(element) { - var view = $("#"+options.Views[i]).get(0); + var view = jQuery("#"+options.Views[i]).get(0); if (view) if(this.hiddenField.value == i) { diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js index bca801b9..012f2ef8 100644 --- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js +++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js @@ -22,18 +22,18 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, 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; this.positionMode = 'Bottom'; - + Prado.Registry[options.ID] = this; //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 @@ -41,7 +41,7 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, this.trigger = this.control; var triggerEvent = this.options.TriggerEvent || "focus"; } - + // Popup position if(this.options.PositionMode == 'Top') { @@ -51,16 +51,16 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, jQuery.extend(this,options); // generate default date _after_ extending options this.selectedDate = this.newDate(); - + this.observe(this.trigger, triggerEvent, jQuery.proxy(this.show,this)); - + // Listen to change event if needed if (typeof(this.options.OnDateChanged) == "function") { if(this.options.InputMode == "TextBox") { this.observe(this.control, "change", jQuery.proxy(this.onDateChanged,this)); - } + } else { var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); @@ -69,10 +69,10 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, this.observe (day, "change", jQuery.proxy(this.onDateChanged,this)); this.observe (month, "change", jQuery.proxy(this.onDateChanged,this)); this.observe (year, "change", jQuery.proxy(this.onDateChanged,this)); - + } - - + + } }, @@ -407,7 +407,7 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, if (this.options.InputMode == "TextBox") { date=this.control.value; - } + } else { var day = Prado.WebUI.TDatePicker.getDayListControl(this.control).selectedIndex+1; @@ -438,9 +438,9 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, else jQuery(element).trigger("change"); }, - + onChange : function(ref, date, capevents) - { + { if(this.options.InputMode == "TextBox") { this.control.value = this.formatDate(); @@ -587,7 +587,7 @@ Prado.WebUI.TDatePicker = jQuery.klass(Prado.WebUI.Control, } this.observe(document,"keydown", this.documentKeyDownEvent); this.showing = true; - + if(this.positionMode=='Top') { this._calDiv.style.top = ((pos[1]-1) - this.getDatePickerOffsetHeight() - this._calDiv.offsetHeight) + 'px'; @@ -744,16 +744,16 @@ jQuery.extend(Prado.WebUI.TDatePicker, getYearListControl : function(control) { - return $('#'+control.id+"_year").get(0); + return jQuery('#'+control.id+"_year").get(0); }, getMonthListControl : function(control) { - return $('#'+control.id+"_month").get(0); + return jQuery('#'+control.id+"_month").get(0); }, getDayListControl : function(control) { - return $('#'+control.id+"_day").get(0); + return jQuery('#'+control.id+"_day").get(0); } });
\ No newline at end of file diff --git a/framework/Web/Javascripts/source/prado/prado.js b/framework/Web/Javascripts/source/prado/prado.js index 2e3ffbaa..1d69a034 100644 --- a/framework/Web/Javascripts/source/prado/prado.js +++ b/framework/Web/Javascripts/source/prado/prado.js @@ -1,11 +1,11 @@ /* * Low Pro JQ * ---------- - * + * * Author: Dan Webb (dan@danwebb.net) * GIT: github.com:danwrong/low-pro-for-jquery.git * Download: http://github.com/danwrong/low-pro-for-jquery/tree/master/src/lowpro.jquery.js?raw=true - * + * * A jQuery port of the Low Pro behavior framework that was originally written for Prototype. * * Prado actually uses it as a base to emulate OOP subclassing, inheritance and contructor events. @@ -185,9 +185,9 @@ Remote.Link = $.klass(Remote.Base, { onclick: function(e) { - var options = $.extend({ - url: $(this).attr('href'), - type: 'GET' + var options = $.extend({ + url: $(this).attr('href'), + type: 'GET' }, this.options); return e.data.behavior._makeRequest(e.data.behavior.options); } @@ -203,9 +203,9 @@ onsubmit: function(e) { var elm = $(this), data = elm.serializeArray(); - if (e.data.behavior._submitButton) data.push({ - name: e.data.behavior._submitButton.name, - value: e.data.behavior._submitButton.value + if (e.data.behavior._submitButton) data.push({ + name: e.data.behavior._submitButton.name, + value: e.data.behavior._submitButton.value }); var options = $.extend({ @@ -241,7 +241,7 @@ var Prado = * @var Version */ Version: '3.2.3', - + /** * Registry for Prado components * @var Registry @@ -249,7 +249,7 @@ var Prado = Registry: {}, }; -Prado.RequestManager = +Prado.RequestManager = { FIELD_POSTBACK_TARGET : 'PRADO_POSTBACK_TARGET', @@ -262,8 +262,8 @@ Prado.RequestManager = * @param event - Event that triggered this postback * @... {string} FormID - Form that should be posted back * @... {optional boolean} CausesValidation - Validate before PostBack if true - * @... {optional string} ValidationGroup - Group to Validate - * @... {optional string} ID - Validation ID + * @... {optional string} ValidationGroup - Group to Validate + * @... {optional string} ID - Validation ID * @... {optional string} PostBackUrl - Postback URL * @... {optional boolean} TrackFocus - Keep track of focused element if true * @... {string} EventTarget - Id of element that triggered PostBack @@ -289,7 +289,7 @@ Prado.PostBack = jQuery.klass( var form = this.getForm(); 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 event.preventDefault(); } @@ -298,7 +298,7 @@ Prado.PostBack = jQuery.klass( if(this.options['TrackFocus']) { - var lastFocus = $('PRADO_LASTFOCUS'); + var lastFocus = jQuery('#PRADO_LASTFOCUS'); if(lastFocus) { var active = document.activeElement; //where did this come from @@ -356,7 +356,7 @@ Prado.Element = * @param {string} element - Element id * @param {string} method - Name of any {@link Prado.Element.Selection} method * @param {array|boolean|string} value - Values that should be selected - * @param {int} total - Number of elements + * @param {int} total - Number of elements */ select : function(element, method, value, total) { @@ -407,16 +407,16 @@ Prado.Element = offset : 50 }; jQuery.extend(op, options || {}); - $('html, body').animate({ - scrollTop: $("#"+element).offset().top - op.offset + jQuery('html, body').animate({ + scrollTop: jQuery("#"+element).offset().top - op.offset }, op.duration); }, /** - * Sets the options for a select element. + * Sets the options for a select element. * @function ? * @param {string} element - Element id - * @param {array[]} options - Array of options, each an array of structure + * @param {array[]} options - Array of options, each an array of structure * [ "optionText" , "optionValue" , "optionGroup" ] */ setOptions : function(element, options) @@ -436,9 +436,9 @@ Prado.Element = }, /** - * Create opt-group options from an array of options. + * Create opt-group options from an array of options. * @function {array} ? - * @param {array[]} options - Array of options, each an array of structure + * @param {array[]} options - Array of options, each an array of structure * [ "optionText" , "optionValue" , "optionGroup" ] * @returns Array of option DOM elements */ @@ -599,7 +599,7 @@ Prado.Element.Selection = /** * Set selected attribute for elements options by value. * If value is boolean, all elements options selected attribute will be set - * to value. Otherwhise all options that have the given value will be selected. + * to value. Otherwhise all options that have the given value will be selected. * @function ? * @param {element[]} elements - Array of selectable DOM elements * @param {boolean|string} value - Value of options that should be selected or boolean value of selection status @@ -735,7 +735,7 @@ Prado.Element.Selection = var el; for(var i = 0; i < total; i++) { - el = $("#"+element+"_c"+i).get(0); + el = jQuery("#"+element+"_c"+i).get(0); if(el) elements.push(el); } @@ -744,12 +744,12 @@ Prado.Element.Selection = /** * Set checked attribute of elements by value. - * If value is boolean, checked attribute will be set to value. - * Otherwhise all elements that have the given value will be checked. + * If value is boolean, checked attribute will be set to value. + * Otherwhise all elements that have the given value will be checked. * @function ? * @param {element[]} elements - Array of checkable DOM elements * @param {boolean|String} value - Value that should be checked or boolean value of checked status - * + * */ checkValue : function(elements, value) { @@ -767,7 +767,7 @@ Prado.Element.Selection = * @function ? * @param {element[]} elements - Array of checkable DOM elements * @param {string[]} values - Values that should be checked - * + * */ checkValues : function(elements, values) { @@ -928,7 +928,7 @@ jQuery.extend(String.prototype, { /** * Convert period separated function names into a function reference. * <br />Example: - * <pre> + * <pre> * "Prado.AJAX.Callback.Action.setValue".toFunction() * </pre> * @function {function} ? diff --git a/framework/Web/Javascripts/source/prado/ratings/ratings.js b/framework/Web/Javascripts/source/prado/ratings/ratings.js index 1369c740..eb541b99 100644 --- a/framework/Web/Javascripts/source/prado/ratings/ratings.js +++ b/framework/Web/Javascripts/source/prado/ratings/ratings.js @@ -1,78 +1,67 @@ -Prado.WebUI.TRatingList = Base.extend( +Prado.WebUI.TRatingList = jQuery.klass(Prado.WebUI.Control, { selectedIndex : -1, rating: -1, readOnly : false, - constructor : function(options) + onInit : function(options) { - var cap = $(options.CaptionID); - this.options = Object.extend( + var cap = $('#'+options.CaptionID).get(0); + this.options = jQuery.extend( { caption : cap ? cap.innerHTML : '' }, options || {}); - Prado.WebUI.TRatingList.register(this); - this._init(); - Prado.Registry.set(options.ListID, this); - this.selectedIndex = options.SelectedIndex; - this.rating = options.Rating; - this.readOnly = options.ReadOnly - if(options.Rating <= 0 && options.SelectedIndex >= 0) - this.rating = options.SelectedIndex+1; - this.setReadOnly(this.readOnly); - }, + this.radios = []; - _init: function(options) - { - Element.addClassName($(this.options.ListID),this.options.Style); - this.radios = new Array(); - this._mouseOvers = new Array(); - this._mouseOuts = new Array(); - this._clicks = new Array(); - var index=0; - for(var i = 0; i<this.options.ItemCount; i++) + $('#'+options.ID).addClass(options.Style); + for(var i = 0; i<options.ItemCount; i++) { - var radio = $(this.options.ListID+'_c'+i); + var radio = $('#'+options.ID+"_c"+i).get(0); var td = radio.parentNode.parentNode; + if(radio && td.tagName.toLowerCase()=='td') { this.radios.push(radio); - this._mouseOvers.push(this.hover.bindEvent(this,index)); - this._mouseOuts.push(this.recover.bindEvent(this,index)); - this._clicks.push(this.click.bindEvent(this,index)); - index++; - Element.addClassName(td,"rating"); + $(td).addClass("rating"); } } + + this.selectedIndex = options.SelectedIndex; + this.rating = options.Rating; + this.readOnly = options.ReadOnly + if(options.Rating <= 0 && options.SelectedIndex >= 0) + this.rating = options.SelectedIndex+1; + this.setReadOnly(this.readOnly); }, - hover : function(ev,index) + hover : function(index, ev) { if(this.readOnly==true) return; + for(var i = 0; i<this.radios.length; i++) { var node = this.radios[i].parentNode.parentNode; - var action = i <= index ? 'addClassName' : 'removeClassName' - Element[action](node,"rating_hover"); - Element.removeClassName(node,"rating_selected"); - Element.removeClassName(node,"rating_half"); + if(i <= index) + $(node).addClass('rating_hover'); + else + $(node).removeClass('rating_hover'); + $(node).removeClass("rating_selected"); + $(node).removeClass("rating_half"); } this.showCaption(this.getIndexCaption(index)); }, - recover : function(ev,index) + recover : function(index, ev) { if(this.readOnly==true) return; this.showRating(this.rating); this.showCaption(this.options.caption); }, - click : function(ev, index) + click : function(index, ev) { if(this.readOnly==true) return; - for(var i = 0; i<this.radios.length; i++) - this.radios[i].checked = (i == index); this.selectedIndex = index; this.setRating(index+1); @@ -83,13 +72,13 @@ Prado.WebUI.TRatingList = Base.extend( dispatchRequest : function(ev) { - var requestOptions = Object.extend( + var requestOptions =jQuery.extend({}, this.options, { - ID : this.options.ListID+"_c"+this.selectedIndex, + ID : this.options.ID+"_c"+this.selectedIndex, EventTarget : this.options.ListName+"$c"+this.selectedIndex - },this.options); - Prado.PostBack(ev, requestOptions); - }, + }); + new Prado.PostBack(requestOptions, ev); + }, setRating : function(value) { @@ -119,16 +108,19 @@ Prado.WebUI.TRatingList = Base.extend( for(var i = 0; i<this.radios.length; i++) { var node = this.radios[i].parentNode.parentNode; - var action = i > index ? 'removeClassName' : 'addClassName'; - Element[action](node, "rating_selected"); + if(i <= index) + $(node).addClass('rating_selected'); + else + $(node).removeClass('rating_selected'); + if(i==index+1 && hasHalf) - Element.addClassName(node, "rating_half"); + $(node).addClass("rating_half"); else - Element.removeClassName(node, "rating_half"); - Element.removeClassName(node,"rating_hover"); + $(node).removeClass("rating_half"); + $(node).removeClass("rating_hover"); } }, - + getIndexCaption : function(index) { return index > -1 ? this.radios[index].value : this.options.caption; @@ -136,9 +128,8 @@ Prado.WebUI.TRatingList = Base.extend( showCaption : function(value) { - var caption = $(this.options.CaptionID); - if(caption) caption.innerHTML = value; - $(this.options.ListID).title = value; + $('#'+this.options.CaptionID).html(value); + $('#'+this.options.ID).attr( "title", value); }, setCaption : function(value) @@ -152,55 +143,37 @@ Prado.WebUI.TRatingList = Base.extend( this.readOnly = value; for(var i = 0; i<this.radios.length; i++) { - - var action = value ? 'addClassName' : 'removeClassName'; - Element[action](this.radios[i].parentNode.parentNode, "rating_disabled"); - - var action = value ? 'stopObserving' : 'observe'; - var td = this.radios[i].parentNode.parentNode; - Event[action](td, "mouseover", this._mouseOvers[i]); - Event[action](td, "mouseout", this._mouseOuts[i]); - Event[action](td, "click", this._clicks[i]); + var node = this.radios[i].parentNode.parentNode; + if(value) + { + $(node).addClass('rating_disabled'); + $(node).off('mouseover', jQuery.proxy(this.hover, this, i)); + $(node).off('mouseout', jQuery.proxy(this.recover, this, i)); + $(node).off('click', jQuery.proxy(this.click, this, i)); + } else { + $(node).removeClass('rating_disabled'); + $(node).on('mouseover', jQuery.proxy(this.hover, this, i)); + $(node).on('mouseout', jQuery.proxy(this.recover, this, i)); + $(node).on('click', jQuery.proxy(this.click, this, i)); + } } this.showRating(this.rating); } -}, -{ -ratings : {}, -register : function(rating) -{ - Prado.WebUI.TRatingList.ratings[rating.options.ListID] = rating; -}, - -setReadOnly : function(id,value) -{ - Prado.WebUI.TRatingList.ratings[id].setReadOnly(value); -}, - -setRating : function(id,value) -{ - Prado.WebUI.TRatingList.ratings[id].setRating(value); -}, - -setCaption : function(id,value) -{ - Prado.WebUI.TRatingList.ratings[id].setCaption(value); -} }); -Prado.WebUI.TActiveRatingList = Prado.WebUI.TRatingList.extend( -{ +Prado.WebUI.TActiveRatingList = jQuery.klass(Prado.WebUI.TRatingList, +{ dispatchRequest : function(ev) { - var requestOptions = Object.extend( + var requestOptions =jQuery.extend({}, this.options, { - ID : this.options.ListID+"_c"+this.selectedIndex, + ID : this.options.ID+"_c"+this.selectedIndex, EventTarget : this.options.ListName+"$c"+this.selectedIndex - },this.options); + }); var request = new Prado.CallbackRequest(requestOptions.EventTarget, requestOptions); if(request.dispatch()==false) - Event.stop(ev); + ev.preventDefault(); } - + }); |