From b683b2d3c38b1eaee99c4c5cf7544adb5ccc3344 Mon Sep 17 00:00:00 2001 From: Rafid Aslam Date: Sun, 8 Jan 2017 18:51:14 +0700 Subject: [PATCH] deps: Upgrade and move `jquery-mousewheel` from `static/third` to `npm` - Remove `jquery-mousewheel` from `static/third` and fetch it from npm. - Upgrade `jquery-mousewheel` to 3.1.6. - Bump up the `PROVISION_VERSION` to 4.5. - Change some js code to comply with this `jquery-mousewheel` version. Part of #1709. --- docs/THIRDPARTY | 4 - package.json | 1 + static/js/ui.js | 10 +-- .../jquery-mousewheel/jquery.mousewheel.js | 84 ------------------- version.py | 2 +- zproject/settings.py | 2 +- 6 files changed, 8 insertions(+), 95 deletions(-) delete mode 100755 static/third/jquery-mousewheel/jquery.mousewheel.js diff --git a/docs/THIRDPARTY b/docs/THIRDPARTY index 59e8d3bd2b..9585a1e3be 100644 --- a/docs/THIRDPARTY +++ b/docs/THIRDPARTY @@ -150,10 +150,6 @@ Copyright: 2011-2013 Henrique Boaventura License: Expat Comment: The software has been modified. -Files: static/third/jquery-mousewheel/jquery.mousewheel.js -Copyright: 2011 Brandon Aaron -License: Expat - Files: static/third/jquery-perfect-scrollbar/* Copyright: 2012 HyeonJe Jun License: Expat diff --git a/package.json b/package.json index e783fb5972..38ff19a6bf 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "i18next-browser-languagedetector": "0.3.0", "i18next-localstorage-cache": "0.3.0", "jquery": "1.12.1", + "jquery-mousewheel": "3.1.6", "jquery-validation": "1.15.1", "plotly.js": "1.19.2", "string.prototype.codepointat": "0.2.0", diff --git a/static/js/ui.js b/static/js/ui.js index a1ea6fc320..caf801d36b 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -384,7 +384,7 @@ $(function () { viewport.last_movement_direction = delta; }); - viewport.message_pane.mousewheel(function (e, delta) { + viewport.message_pane.mousewheel(function (e) { // Ignore mousewheel events if a modal is visible. It's weird if the // user can scroll the main view by wheeling over the grayed-out area. // Similarly, ignore events on settings page etc. @@ -393,7 +393,7 @@ $(function () { // select the compose box and then wheel over the message stream. var obscured = exports.home_tab_obscured(); if (!obscured) { - throttled_mousewheelhandler(e, delta); + throttled_mousewheelhandler(e, e.deltaY); } else if (obscured === 'modal') { // The modal itself has a handler invoked before this one (see below). // preventDefault here so that the tab behind the modal doesn't scroll. @@ -413,7 +413,7 @@ $(function () { // propagation in all cases. Also, ignore the event if the // element is already at the top or bottom. Otherwise we get a // new scroll event on the parent (?). - $('.modal-body, .scrolling_list, input, textarea').mousewheel(function (e, delta) { + $('.modal-body, .scrolling_list, input, textarea').mousewheel(function (e) { var self = $(this); var scroll = self.scrollTop(); @@ -422,8 +422,8 @@ $(function () { var max_scroll = this.scrollHeight - self.innerHeight() - 1; e.stopPropagation(); - if ( ((delta > 0) && (scroll <= 0)) - || ((delta < 0) && (scroll >= max_scroll))) { + if ( ((e.deltaY > 0) && (scroll <= 0)) + || ((e.deltaY < 0) && (scroll >= max_scroll))) { e.preventDefault(); } }); diff --git a/static/third/jquery-mousewheel/jquery.mousewheel.js b/static/third/jquery-mousewheel/jquery.mousewheel.js deleted file mode 100755 index 38b60951b2..0000000000 --- a/static/third/jquery-mousewheel/jquery.mousewheel.js +++ /dev/null @@ -1,84 +0,0 @@ -/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net) - * Licensed under the MIT License (LICENSE.txt). - * - * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. - * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. - * Thanks to: Seamus Leahy for adding deltaX and deltaY - * - * Version: 3.0.6 - * - * Requires: 1.2.2+ - */ - -(function($) { - -var types = ['DOMMouseScroll', 'mousewheel']; - -if ($.event.fixHooks) { - for ( var i=types.length; i; ) { - $.event.fixHooks[ types[--i] ] = $.event.mouseHooks; - } -} - -$.event.special.mousewheel = { - setup: function() { - if ( this.addEventListener ) { - for ( var i=types.length; i; ) { - this.addEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = handler; - } - }, - - teardown: function() { - if ( this.removeEventListener ) { - for ( var i=types.length; i; ) { - this.removeEventListener( types[--i], handler, false ); - } - } else { - this.onmousewheel = null; - } - } -}; - -$.fn.extend({ - mousewheel: function(fn) { - return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); - }, - - unmousewheel: function(fn) { - return this.unbind("mousewheel", fn); - } -}); - - -function handler(event) { - var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; - event = $.event.fix(orgEvent); - event.type = "mousewheel"; - - // Old school scrollwheel delta - if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; } - if ( orgEvent.detail ) { delta = -orgEvent.detail/3; } - - // New school multidimensional scroll (touchpads) deltas - deltaY = delta; - - // Gecko - if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { - deltaY = 0; - deltaX = -1*delta; - } - - // Webkit - if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } - if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } - - // Add event and delta to the front of the arguments - args.unshift(event, delta, deltaX, deltaY); - - return ($.event.dispatch || $.event.handle).apply(this, args); -} - -})(jQuery); diff --git a/version.py b/version.py index 942d57573a..65de027ed0 100644 --- a/version.py +++ b/version.py @@ -1,2 +1,2 @@ ZULIP_VERSION = "1.4.1+git" -PROVISION_VERSION = '4.3' +PROVISION_VERSION = '4.4' diff --git a/zproject/settings.py b/zproject/settings.py index 0c69c673f7..4eaa27aaac 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -760,7 +760,7 @@ JS_SPECS = { 'third/jquery-filedrop/jquery.filedrop.js', 'third/jquery-caret/jquery.caret.1.5.2.js', 'node_modules/xdate/src/xdate.js', - 'third/jquery-mousewheel/jquery.mousewheel.js', + 'node_modules/jquery-mousewheel/jquery.mousewheel.js', 'third/jquery-throttle-debounce/jquery.ba-throttle-debounce.js', 'third/jquery-idle/jquery.idle.js', 'third/jquery-autosize/jquery.autosize.js',