From fd1a685c494bc183adae9b1748ee79e66c4ff7c2 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Sat, 24 Mar 2012 21:28:08 +0000 Subject: committed alternative patch for #181 --- .../source/prado/activecontrols/activecontrols3.js | 88 +++--- .../prado/activecontrols/activedatepicker.js | 21 +- .../source/prado/activecontrols/ajax3.js | 2 + .../source/prado/activecontrols/dragdrop.js | 7 +- .../source/prado/activecontrols/inlineeditor.js | 30 +- .../prado/activefileupload/activefileupload.js | 15 +- .../Javascripts/source/prado/controls/accordion.js | 15 +- .../Javascripts/source/prado/controls/controls.js | 303 +++++++++++++++++---- .../Javascripts/source/prado/controls/htmlarea.js | 34 +-- .../Javascripts/source/prado/controls/keyboard.js | 12 +- .../Javascripts/source/prado/controls/slider.js | 31 +-- .../Javascripts/source/prado/controls/tabpanel.js | 37 +-- .../source/prado/scriptaculous-adapter.js | 14 +- .../source/prado/validator/validation3.js | 16 +- 14 files changed, 400 insertions(+), 225 deletions(-) (limited to 'framework/Web') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js index e187f650..2f02594f 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activecontrols3.js @@ -78,9 +78,9 @@ Prado.WebUI.TActiveTextBox = Class.extend(Prado.WebUI.TTextBox, { this.options=options; if(options['TextMode'] != 'MultiLine') - Event.observe(this.element, "keydown", this.handleReturnKey.bind(this)); + this.observe(this.element, "keydown", this.handleReturnKey.bind(this)); if(this.options['AutoPostBack']==true) - Event.observe(this.element, "change", this.doCallback.bindEvent(this,options)); + this.observe(this.element, "change", this.doCallback.bindEvent(this,options)); }, doCallback : function(event, options) @@ -177,26 +177,25 @@ Prado.WebUI.TAutoComplete = Class.extend(Prado.WebUI.TAutoComplete, /** * Time Triggered Callback class. */ -Prado.WebUI.TTimeTriggeredCallback = Base.extend( +Prado.WebUI.TTimeTriggeredCallback = Class.create(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { this.options = Object.extend({ Interval : 1 }, options || {}); - Prado.WebUI.TTimeTriggeredCallback.register(this); - Prado.Registry.set(options.ID, this); + Prado.WebUI.TTimeTriggeredCallback.registerTimer(this); }, startTimer : function() { if(typeof(this.timer) == 'undefined' || this.timer == null) - this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); + this.timer = this.setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); }, stopTimer : function() { if(typeof(this.timer) != 'undefined') { - clearInterval(this.timer); + this.clearInterval(this.timer); this.timer = null; } }, @@ -205,9 +204,9 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( { if(typeof(this.timer) != 'undefined') { - clearInterval(this.timer); + this.clearInterval(this.timer); this.timer = null; - this.timer = setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); + this.timer = this.setInterval(this.onTimerEvent.bind(this),this.options.Interval*1000); } }, @@ -217,19 +216,28 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( request.dispatch(); }, - setInterval : function(value) + setTimerInterval : function(value) { if (this.options.Interval != value){ this.options.Interval = value; this.resetTimer(); } + }, + + onDone: function() + { + this.stopTimer(); } -}, -//class methods +}); + +Object.extend(Prado.WebUI.TTimeTriggeredCallback, { + + //class methods + timers : {}, - register : function(timer) + registerTimer : function(timer) { Prado.WebUI.TTimeTriggeredCallback.timers[timer.options.ID] = timer; }, @@ -246,23 +254,21 @@ Prado.WebUI.TTimeTriggeredCallback = Base.extend( Prado.WebUI.TTimeTriggeredCallback.timers[id].stopTimer(); }, - setInterval : function (id,value) + setTimerInterval : function (id,value) { if(Prado.WebUI.TTimeTriggeredCallback.timers[id]) - Prado.WebUI.TTimeTriggeredCallback.timers[id].setInterval(value); + Prado.WebUI.TTimeTriggeredCallback.timers[id].setTimerInterval(value); } }); -Prado.WebUI.ActiveListControl = Base.extend( +Prado.WebUI.ActiveListControl = Class.create(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { - this.element = $(options.ID); - Prado.Registry.set(options.ID, this); if(this.element) { this.options = options; - Event.observe(this.element, "change", this.doCallback.bind(this)); + this.observe(this.element, "change", this.doCallback.bind(this)); } }, @@ -274,20 +280,19 @@ Prado.WebUI.ActiveListControl = Base.extend( } }); -Prado.WebUI.TActiveDropDownList = Prado.WebUI.ActiveListControl; -Prado.WebUI.TActiveListBox = Prado.WebUI.ActiveListControl; +Prado.WebUI.TActiveDropDownList = Class.create(Prado.WebUI.ActiveListControl); +Prado.WebUI.TActiveListBox = Class.create(Prado.WebUI.ActiveListControl); /** * Observe event of a particular control to trigger a callback request. */ -Prado.WebUI.TEventTriggeredCallback = Base.extend( +Prado.WebUI.TEventTriggeredCallback = Class.create(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { - this.options = options; var element = $(options['ControlID']); if(element) - Event.observe(element, this.getEventName(element), this.doCallback.bind(this)); + this.observe(element, this.getEventName(element), this.doCallback.bind(this)); }, getEventName : function(element) @@ -320,32 +325,30 @@ Prado.WebUI.TEventTriggeredCallback = Base.extend( /** * Observe changes to a property of a particular control to trigger a callback. */ -Prado.WebUI.TValueTriggeredCallback = Base.extend( +Prado.WebUI.TValueTriggeredCallback = Class.create(Prado.WebUI.Control, { count : 1, observing : true, - constructor : function(options) + onInit : function(options) { - this.options = options; this.options.PropertyName = this.options.PropertyName || 'value'; var element = $(options['ControlID']); this.value = element ? element[this.options.PropertyName] : undefined; Prado.WebUI.TValueTriggeredCallback.register(this); - Prado.Registry.set(options.ID, this); this.startObserving(); }, stopObserving : function() { - clearTimeout(this.timer); + this.clearTimeout(this.timer); this.observing = false; }, startObserving : function() { - this.timer = setTimeout(this.checkChanges.bind(this), this.options.Interval*1000); + this.timer = this.setTimeout(this.checkChanges.bind(this), this.options.Interval*1000); }, checkChanges : function() @@ -363,7 +366,7 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend( else this.count = this.count + this.options.Decay; if(this.observing) - this.time = setTimeout(this.checkChanges.bind(this), + this.time = this.setTimeout(this.checkChanges.bind(this), parseInt(this.options.Interval*1000*this.count)); } }, @@ -374,10 +377,19 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend( var param = {'OldValue' : oldValue, 'NewValue' : newValue}; request.setCallbackParameter(param); request.dispatch(); + }, + + onDone : function() + { + if (this.observing) + this.stopObserving(); } -}, -//class methods +}); + +Object.extend(Prado.WebUI.TTimeTriggeredCallback, { + //class methods + timers : {}, register : function(timer) @@ -391,5 +403,5 @@ Prado.WebUI.TValueTriggeredCallback = Base.extend( } }); -Prado.WebUI.TActiveTableCell = Class.extend(Prado.WebUI.CallbackControl); -Prado.WebUI.TActiveTableRow = Class.extend(Prado.WebUI.CallbackControl); +Prado.WebUI.TActiveTableCell = Class.create(Prado.WebUI.CallbackControl); +Prado.WebUI.TActiveTableRow = Class.create(Prado.WebUI.CallbackControl); diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js index 8857ee05..a04a0243 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -1,9 +1,9 @@ /** * TActiveDatePicker control */ -Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, +Prado.WebUI.TActiveDatePicker = Class.create(Prado.WebUI.TDatePicker, { - initialize : function(options) + onInit : function(options) { this.options = options || []; this.control = $(options.ID); @@ -14,9 +14,6 @@ Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, this.positionMode = 'Bottom'; - // Issue 181 - $(this.control).stopObserving(); - //which element to trigger to show the calendar if(this.options.Trigger) { @@ -29,10 +26,6 @@ Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, var triggerEvent = this.options.TriggerEvent || "focus"; } - // Issue 181 - if(this.trigger) - $(this.trigger).stopObserving(); - // Popup position if(this.options.PositionMode == 'Top') { @@ -42,21 +35,21 @@ Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, Object.extend(this,options); if (this.options.ShowCalendar) - Event.observe(this.trigger, triggerEvent, this.show.bindEvent(this)); + this.observe(this.trigger, triggerEvent, this.show.bindEvent(this)); // Listen to change event if(this.options.InputMode == "TextBox") { - Event.observe(this.control, "change", this.onDateChanged.bindEvent(this)); + this.observe(this.control, "change", this.onDateChanged.bindEvent(this)); } else { var day = Prado.WebUI.TDatePicker.getDayListControl(this.control); var month = Prado.WebUI.TDatePicker.getMonthListControl(this.control); var year = Prado.WebUI.TDatePicker.getYearListControl(this.control); - if (day) Event.observe (day, "change", this.onDateChanged.bindEvent(this)); - if (month) Event.observe (month, "change", this.onDateChanged.bindEvent(this)); - if (year) Event.observe (year, "change", this.onDateChanged.bindEvent(this)); + if (day) this.observe (day, "change", this.onDateChanged.bindEvent(this)); + if (month) this.observe (month, "change", this.onDateChanged.bindEvent(this)); + if (year) this.observe (year, "change", this.onDateChanged.bindEvent(this)); } diff --git a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js index 2d410375..11eec5a4 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/ajax3.js @@ -248,6 +248,8 @@ Object.extend(Prado.CallbackRequest, { if(typeof(Logger) != "undefined") self.Exception.onException(null,e); + else + debugger; } } }, diff --git a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js index efec6a69..59c62cc2 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/dragdrop.js @@ -2,11 +2,9 @@ * DropContainer control */ -Prado.WebUI.DropContainer = Class.extend(Prado.WebUI.CallbackControl); - -Object.extend(Prado.WebUI.DropContainer.prototype, +Prado.WebUI.DropContainer = Class.create(Prado.WebUI.CallbackControl, { - initialize: function(options) + onInit: function(options) { this.options = options; Object.extend (this.options, @@ -15,7 +13,6 @@ Object.extend(Prado.WebUI.DropContainer.prototype, }); Droppables.add (options.ID, this.options); - Prado.Registry.set(options.ID, this); }, onDrop: function(dragElement, dropElement, event) diff --git a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js index 74d45515..a53ac8fd 100644 --- a/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/inlineeditor.js @@ -1,6 +1,6 @@ -Prado.WebUI.TInPlaceTextBox = Base.extend( +Prado.WebUI.TInPlaceTextBox = Class.create(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { this.isSaving = false; @@ -18,8 +18,6 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( Prado.WebUI.TInPlaceTextBox.register(this); this.createEditorInput(); this.initializeListeners(); - - Prado.Registry.set(options.ID, this); }, /** @@ -28,13 +26,9 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( initializeListeners : function() { this.onclickListener = this.enterEditMode.bindAsEventListener(this); - Event.observe(this.element, 'click', this.onclickListener); + this.observe(this.element, 'click', this.onclickListener); if (this.options.ExternalControl) - { - // Issue 181 - $(this.options.ExternalControl).stopObserving('click', this.onclickListener); - Event.observe($(this.options.ExternalControl), 'click', this.onclickListener); - } + this.observe($(this.options.ExternalControl), 'click', this.onclickListener); }, /** @@ -132,13 +126,10 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( this.editField.style.display="none"; this.element.parentNode.insertBefore(this.editField,this.element) - // Issue 181 - $(this.editField).stopObserving(); - //handle return key within single line textbox if(this.options.TextMode == 'SingleLine') { - Event.observe(this.editField, "keydown", function(e) + this.observe(this.editField, "keydown", function(e) { if(Event.keyCode(e) == Event.KEY_RETURN) { @@ -152,8 +143,8 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( }); } - Event.observe(this.editField, "blur", this.onTextBoxBlur.bind(this)); - Event.observe(this.editField, "keypress", this.onKeyPressed.bind(this)); + this.observe(this.editField, "blur", this.onTextBoxBlur.bind(this)); + this.observe(this.editField, "keypress", this.onKeyPressed.bind(this)); }, /** @@ -272,8 +263,13 @@ Prado.WebUI.TInPlaceTextBox = Base.extend( if(typeof(this.options.onFailure)=="function") this.options.onFailure(sender,parameter); } -}, +}); + + +Object.extend(Prado.WebUI.TInPlaceTextBox, { + //class methods + textboxes : {}, register : function(obj) diff --git a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js index e25b5bed..b16179c0 100755 --- a/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js +++ b/framework/Web/Javascripts/source/prado/activefileupload/activefileupload.js @@ -1,6 +1,6 @@ -Prado.WebUI.TActiveFileUpload = Base.extend( +Prado.WebUI.TActiveFileUpload = Class.create(Prado.WebUI.Control, { - constructor : function(options) + onInit : function(options) { this.options = options || {}; Prado.WebUI.TActiveFileUpload.register(this); @@ -13,11 +13,9 @@ Prado.WebUI.TActiveFileUpload = Base.extend( this.complete = $(options.completeID); this.error = $(options.errorID); - Prado.Registry.set(options.inputID, this); - // set up events if (options.autoPostBack){ - Event.observe(this.input,"change",this.fileChanged.bind(this)); + this.observe(this.input,"change",this.fileChanged.bind(this)); } }, @@ -74,9 +72,12 @@ Prado.WebUI.TActiveFileUpload = Base.extend( } } -}, +}); + +Object.extend(Prado.WebUI.TActiveFileUpload, { -// class methods + //class methods + controls : {}, register : function(control) diff --git a/framework/Web/Javascripts/source/prado/controls/accordion.js b/framework/Web/Javascripts/source/prado/controls/accordion.js index e6af5e2e..90d01316 100644 --- a/framework/Web/Javascripts/source/prado/controls/accordion.js +++ b/framework/Web/Javascripts/source/prado/controls/accordion.js @@ -7,16 +7,8 @@ * http://creativecommons.org/licenses/by-sa/3.0/us/ */ -Prado.WebUI.TAccordion = Class.create(); -Prado.WebUI.TAccordion.prototype = +Prado.WebUI.TAccordion = Class.create(Prado.WebUI.Control, { - initialize : function(options) - { - this.element = $(options.ID); - this.onInit(options); - Prado.Registry.set(options.ID, this); - }, - onInit : function(options) { this.accordion = $(options.ID); @@ -40,8 +32,7 @@ Prado.WebUI.TAccordion.prototype = var header = $(view+'_0'); if(header) { - Event.stopObserving(header, "click"); - Event.observe(header, "click", this.elementClicked.bindEvent(this,view)); + this.observe(header, "click", this.elementClicked.bindEvent(this,view)); if(this.hiddenField.value == i) { this.currentView = view; @@ -175,5 +166,5 @@ Prado.WebUI.TAccordion.prototype = }.bind(this) }); } -}; +}); diff --git a/framework/Web/Javascripts/source/prado/controls/controls.js b/framework/Web/Javascripts/source/prado/controls/controls.js index 9dadff18..42fc77ff 100644 --- a/framework/Web/Javascripts/source/prado/controls/controls.js +++ b/framework/Web/Javascripts/source/prado/controls/controls.js @@ -1,33 +1,248 @@ Prado.WebUI = Class.create(); -Prado.WebUI.PostBackControl = Class.create(); +Prado.WebUI.Control = Class.create({ -Prado.WebUI.PostBackControl.prototype = -{ initialize : function(options) { - - this._elementOnClick = null, //capture the element's onclick function + this.registered = false; + this.ID = options.ID; + this.element = $(this.ID); + this.observers = new Array(); + this.intervals = new Array(); + var e; + if (e = Prado.Registry.get(this.ID)) + this.replace(e, options); + else + this.register(options); - this.element = $(options.ID); - Prado.Registry.set(options.ID, this); - if(this.element) + if (this === Prado.Registry.get(this.ID)) { - // Issue 181 - this.element.stopObserving(); + this.registered = true; if(this.onInit) this.onInit(options); } }, - onInit : function(options) + /** + * Registers the control wrapper in the Prado client side control registry + * @param array control wrapper options + */ + register : function(options) { - if(typeof(this.element.onclick)=="function") - { - this._elementOnClick = this.element.onclick.bind(this.element); - this.element.onclick = null; + return Prado.Registry.set(options.ID, this); + }, + + /** + * De-registers the control wrapper in the Prado client side control registry + */ + deregister : function() + { + // extra check so we don't ever deregister another wrapper + if (Prado.Registry.get(this.ID)===this) + return Prado.Registry.unset(this.ID); + else + debugger; // invoke debugger - this should never happen + }, + + /** + * Replaces and control wrapper for an already existing control in the Prado client side control registry + * @param object reference to the old wrapper + * @param array control wrapper options + */ + replace : function(oldwrapper, options) + { + // if there's some advanced state management in the wrapper going on, then + // this method could be used either to copy the current state of the control + // 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 + // leaving any references to it) + // + + // 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) + oldwrapper.deinitialize(); + + return this.register(options); + }, + + /** + * 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 + * @param handler event handler function + */ + observe: function(element, eventName, handler) + { + var e = { _element: element, _eventName: eventName, _handler: handler }; + this.observers.push(e); + return Event.observe(e._element,e._eventName,e._handler); + }, + + /** + * Checks whether an event observer is installed and returns its index + * @param element DOM element reference or id the event handler was attached to + * @param string event name observed + * @param handler event handler function + * @result int false if the event handler is not installed, or 1-based index when installed + */ + findObserver: function(element, eventName, handler) + { + var e = { _element: element, _eventName: eventName, _handler: handler }; + var idx = -1; + for(var i=0;i0) + window.clearInterval(this.intervals.pop()); + + // automatically deregister all installed observers + while (this.observers.length>0) + { + var e = this.observers.pop(); + Event.stopObserving(e._element,e._eventName,e._handler); + } + } + else + debugger; // shouldn't happen + + this.deregister(); + + this.registered = false; + } + +}); + +Prado.WebUI.PostBackControl = Class.create(Prado.WebUI.Control, { + + onInit : function(options) + { + this._elementOnClick = null; + + if (!this.element) + debugger; // element not found + else + { + //capture the element's onclick function + if(typeof(this.element.onclick)=="function") + { + this._elementOnClick = this.element.onclick.bind(this.element); + this.element.onclick = null; + } + this.observe(this.element, "click", this.elementClicked.bindEvent(this,options)); + } }, elementClicked : function(event, options) @@ -52,20 +267,20 @@ Prado.WebUI.PostBackControl.prototype = { Prado.PostBack(event,options); } -}; -Prado.WebUI.TButton = Class.extend(Prado.WebUI.PostBackControl); -Prado.WebUI.TLinkButton = Class.extend(Prado.WebUI.PostBackControl); -Prado.WebUI.TCheckBox = Class.extend(Prado.WebUI.PostBackControl); -Prado.WebUI.TBulletedList = Class.extend(Prado.WebUI.PostBackControl); -Prado.WebUI.TImageMap = Class.extend(Prado.WebUI.PostBackControl); +}); + +Prado.WebUI.TButton = Class.create(Prado.WebUI.PostBackControl); +Prado.WebUI.TLinkButton = Class.create(Prado.WebUI.PostBackControl); +Prado.WebUI.TCheckBox = Class.create(Prado.WebUI.PostBackControl); +Prado.WebUI.TBulletedList = Class.create(Prado.WebUI.PostBackControl); +Prado.WebUI.TImageMap = Class.create(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 = Class.extend(Prado.WebUI.PostBackControl); -Object.extend(Prado.WebUI.TImageButton.prototype, +Prado.WebUI.TImageButton = Class.create(Prado.WebUI.PostBackControl, { /** * Override parent onPostBack function, tried to add hidden forms @@ -131,31 +346,29 @@ Object.extend(Prado.WebUI.TImageButton.prototype, /** * Radio button, only initialize if not already checked. */ -Prado.WebUI.TRadioButton = Class.extend(Prado.WebUI.PostBackControl); -Prado.WebUI.TRadioButton.prototype.onRadioButtonInitialize = Prado.WebUI.TRadioButton.prototype.initialize; -Object.extend(Prado.WebUI.TRadioButton.prototype, +Prado.WebUI.TRadioButton = Class.create(Prado.WebUI.PostBackControl, { - initialize : function(options) + initialize : function($super, options) { this.element = $(options['ID']); if(this.element) { if(!this.element.checked) - this.onRadioButtonInitialize(options); + $super(options); } } }); -Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, +Prado.WebUI.TTextBox = Class.create(Prado.WebUI.PostBackControl, { onInit : function(options) { this.options=options; - if(options['TextMode'] != 'MultiLine') - Event.observe(this.element, "keydown", this.handleReturnKey.bind(this)); + if(this.options['TextMode'] != 'MultiLine') + this.observe(this.element, "keydown", this.handleReturnKey.bind(this)); if(this.options['AutoPostBack']==true) - Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options)); + this.observe(this.element, "change", Prado.PostBack.bindEvent(this,options)); }, handleReturnKey : function(e) @@ -183,27 +396,23 @@ Prado.WebUI.TTextBox = Class.extend(Prado.WebUI.PostBackControl, } }); -Prado.WebUI.TListControl = Class.extend(Prado.WebUI.PostBackControl, +Prado.WebUI.TListControl = Class.create(Prado.WebUI.PostBackControl, { onInit : function(options) { - Event.observe(this.element, "change", Prado.PostBack.bindEvent(this,options)); + this.observe(this.element, "change", Prado.PostBack.bindEvent(this,options)); } }); -Prado.WebUI.TListBox = Class.extend(Prado.WebUI.TListControl); -Prado.WebUI.TDropDownList = Class.extend(Prado.WebUI.TListControl); +Prado.WebUI.TListBox = Class.create(Prado.WebUI.TListControl); +Prado.WebUI.TDropDownList = Class.create(Prado.WebUI.TListControl); -Prado.WebUI.DefaultButton = Class.create(); -Prado.WebUI.DefaultButton.prototype = +Prado.WebUI.DefaultButton = Class.create(Prado.WebUI.Control, { - initialize : function(options) + onInit : function(options) { - // Issue 181 - $(options['Panel']).stopObserving(); this.options = options; - this._event = this.triggerEvent.bindEvent(this); - Event.observe(options['Panel'], 'keydown', this._event); + this.observe(options['Panel'], 'keydown', this.triggerEvent.bindEvent(this)); }, triggerEvent : function(ev, target) @@ -223,10 +432,10 @@ Prado.WebUI.DefaultButton.prototype = } } } -}; +}); -Prado.WebUI.TTextHighlighter=Class.create(); -Prado.WebUI.TTextHighlighter.prototype= +Prado.WebUI.TTextHighlighter = Class.create(); +Prado.WebUI.TTextHighlighter.prototype = { initialize:function(id) { diff --git a/framework/Web/Javascripts/source/prado/controls/htmlarea.js b/framework/Web/Javascripts/source/prado/controls/htmlarea.js index 5ee01c05..595b7928 100644 --- a/framework/Web/Javascripts/source/prado/controls/htmlarea.js +++ b/framework/Web/Javascripts/source/prado/controls/htmlarea.js @@ -8,12 +8,12 @@ */ -Prado.WebUI.THtmlArea = Class.create(); -Prado.WebUI.THtmlArea.prototype = +Prado.WebUI.THtmlArea = Class.create(Prado.WebUI.Control, { - initialize : function(options) + initialize: function($super, options) { - this.onInit(options); + options.ID = options.elements; + $super(options); }, onInit : function(options) @@ -22,20 +22,14 @@ Prado.WebUI.THtmlArea.prototype = throw "TinyMCE libraries must be loaded first"; this.options = options; - this.id = options.elements; - - var p = Prado.Registry.get(this.id); - if (p) p.deinitialize(); tinyMCE.init(options); - Prado.Registry.set(this.id, this); - var obj = this; this.ajaxresponder = { onComplete : function(request) { - if(request && request instanceof Prado.AjaxRequest) + if(request && (request instanceof Prado.AjaxRequest)) obj.checkInstance(); } }; @@ -44,18 +38,18 @@ Prado.WebUI.THtmlArea.prototype = checkInstance: function() { - if (!document.getElementById(this.id)) + if (!document.getElementById(this.ID)) this.deinitialize(); }, removePreviousInstance: function() { for(var i=0;i 0 ? selection.values[0] : initial; } -} +}); /** @@ -1906,7 +1908,7 @@ Prado.WebUI.TCaptchaValidator = Class.extend(Prado.WebUI.TBaseValidator, * @class Prado.WebUI.TReCaptchaValidator * @extends Prado.WebUI.TBaseValidator */ -Prado.WebUI.TReCaptchaValidator = Class.extend(Prado.WebUI.TBaseValidator, +Prado.WebUI.TReCaptchaValidator = Class.create(Prado.WebUI.TBaseValidator, { onInit : function() { @@ -1915,8 +1917,8 @@ Prado.WebUI.TReCaptchaValidator = Class.extend(Prado.WebUI.TBaseValidator, if (elements) if (elements.length>=1) { - Event.observe(elements[0],'change',function() { obj.responseChanged() }); - Event.observe(elements[0],'keydown',function() { obj.responseChanged() }); + this.observe(elements[0],'change',function() { obj.responseChanged() }); + this.observe(elements[0],'keydown',function() { obj.responseChanged() }); } }, -- cgit v1.2.3