From 9ba60ba57ccfea1093ebb795d42f6b9cd63b31a2 Mon Sep 17 00:00:00 2001 From: "ctrlaltca@gmail.com" <> Date: Wed, 27 Jul 2011 07:09:09 +0000 Subject: fix for #265 + disable wheel event for TActiveDatePicker to avoid callback floods --- .../source/prado/activecontrols/activedatepicker.js | 6 ++++++ .../Javascripts/source/prado/datepicker/datepicker.js | 19 ++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) (limited to 'framework') diff --git a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js index 8857ee05..2ee97266 100755 --- a/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js +++ b/framework/Web/Javascripts/source/prado/activecontrols/activedatepicker.js @@ -87,5 +87,11 @@ Prado.WebUI.TActiveDatePicker = Class.extend(Prado.WebUI.TDatePicker, // Make callback request var request = new Prado.CallbackRequest(this.options.EventTarget,this.options); request.dispatch(); + }, + + // reimplement parent method to avoid handling mouse whell events, + // since they can cause floods of callback events + mouseWheelChange : function (event) + { } }); diff --git a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js index 8105823a..95ab43e7 100644 --- a/framework/Web/Javascripts/source/prado/datepicker/datepicker.js +++ b/framework/Web/Javascripts/source/prado/datepicker/datepicker.js @@ -303,8 +303,10 @@ Prado.WebUI.TDatePicker.prototype = Event.observe(this._monthSelect, "change", this.monthSelect.bindEvent(this)); Event.observe(this._yearSelect, "change", this.yearSelect.bindEvent(this)); - // ie6 extension + // ie, opera Event.observe(this._calDiv, "mousewheel", this.mouseWheelChange.bindEvent(this)); + // ff + Event.observe(this._calDiv, "DOMMouseScroll", this.mouseWheelChange.bindEvent(this)); Event.observe(calendarBody, "click", this.selectDate.bindEvent(this)); @@ -448,15 +450,18 @@ Prado.WebUI.TDatePicker.prototype = this.setYear(Form.Element.getValue(Event.element(ev))); }, - // ie6 extension - mouseWheelChange : function (e) + mouseWheelChange : function (event) { - if (e == null) e = document.parentWindow.event; - var n = - e.wheelDelta / 120; + var delta = 0; + if (!event) event = document.parentWindow.event; + if (event.wheelDelta) { + delta = event.wheelDelta/120; + if (window.opera) delta = -delta; + } else if (event.detail) { delta = -event.detail/3; } + var d = this.newDate(this.selectedDate); - var m = d.getMonth() + n; + var m = d.getMonth() + Math.round(delta); this.setMonth(m); - return false; }, -- cgit v1.2.3