Skip to content

Commit

Permalink
[mms] Added standardized/normalized mousewheelY javascript event hand…
Browse files Browse the repository at this point in the history
…ling to HordeCore.

Naturally, can't use it in the one place I was thinking - viewport.js -
since that library doesn't require HordeCore.  But will probably be
useful in the future.
  • Loading branch information
slusarz committed Nov 7, 2013
1 parent 0d123dc commit 880b5db
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
48 changes: 46 additions & 2 deletions framework/Core/js/hordecore.js
Expand Up @@ -542,14 +542,31 @@ var HordeCore = {

initHandler: function(type)
{
var h, t;

if (!this.handlers[type]) {
switch (type) {
case 'click':
case 'dblclick':
this.handlers[type] = this.clickHandler.bindAsEventListener(this);
document.observe(type, this.handlers[type]);
h = this.clickHandler;
t = [ type ];
break;

case 'mousewheelY':
h = this.mousewheelYHandler;
t = ('onwheel' in document || (document.documentMode >= 9))
? [ 'wheel' ]
: [ 'mousewheel', 'DomMouseScroll' ];
break;

default:
return;
}

this.handlers[type] = h.bindAsEventListener(this);
t.each(function(e) {
document.observe(e, this.handlers[type]);
}, this);
}
},

Expand All @@ -575,6 +592,33 @@ var HordeCore = {
}
},

// 'HordeCore:mousewheelY' is fired on a vertical mouse wheel scroll event
// for every element up to the document root. The memo attribute is
// an integer: either -1 or 1.
//
// @since 2.11.0
mousewheelYHandler: function(e)
{
var delta = 0;

if (e.wheelDelta) {
delta = e.wheelDelta;
}
if (e.detail) {
delta = e.detail * -1;
}
if (e.deltaY) {
delta = e.deltaY * -1;
}
if (!Object.isUndefined(e.wheelDeltaY)) {
delta = e.wheelDeltaY;
}

if (delta) {
e.element().fire('HordeCore:mousewheelY', (delta > 0) ? 1 : -1);
}
},

tasksHandler: function(e)
{
var t = e.tasks || {};
Expand Down
8 changes: 4 additions & 4 deletions framework/Core/package.xml
Expand Up @@ -28,7 +28,7 @@
<email>mrubinsk@horde.org</email>
<active>yes</active>
</developer>
<date>2013-10-29</date>
<date>2013-11-06</date>
<version>
<release>2.11.0</release>
<api>2.11.0</api>
Expand All @@ -39,6 +39,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Added standardized/normalized mousewheelY javascript event handling to HordeCore.
* [mms] Add nonce generation/checking to Horde_Session.
* [mms] Application hook methods moved from Horde:: to Horde_Core_Hooks::.
* [mms] Add &apos;fallback&apos; option for the Horde_Registry#appInit() &apos;authentication&apos; parameter.
Expand All @@ -50,7 +51,6 @@
<dir name="Horde">
<dir name="Core">
<file name="COPYING" role="doc" />
<file name="UPGRADING" role="doc" />
</dir> <!-- /doc/Horde/Core -->
</dir> <!-- /doc/Horde -->
</dir> <!-- /doc -->
Expand Down Expand Up @@ -1442,7 +1442,6 @@
<phprelease>
<filelist>
<install as="COPYING" name="doc/Horde/Core/COPYING" />
<install as="UPGRADING" name="doc/Horde/Core/UPGRADING" />
<install as="js/accesskeys.js" name="js/accesskeys.js" />
<install as="js/addressbooksprefs.js" name="js/addressbooksprefs.js" />
<install as="js/alarmprefs.js" name="js/alarmprefs.js" />
Expand Down Expand Up @@ -3224,9 +3223,10 @@
<stability>
<release>stable</release>
<api>stable</api></stability>
<date>2013-10-29</date>
<date>2013-11-06</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Added standardized/normalized mousewheelY javascript event handling to HordeCore.
* [mms] Add nonce generation/checking to Horde_Session.
* [mms] Application hook methods moved from Horde:: to Horde_Core_Hooks::.
* [mms] Add &apos;fallback&apos; option for the Horde_Registry#appInit() &apos;authentication&apos; parameter.
Expand Down

0 comments on commit 880b5db

Please sign in to comment.