From cbc3b8a5f64e8dea02d7ffdbbe489dc7a6717843 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Sat, 7 Nov 2020 19:57:18 +0100 Subject: [PATCH] Remove enquire.js --- wcfsetup/install/files/js/3rdParty/enquire.js | 296 ------------------ .../files/js/WoltLabSuite/Core/Bootstrap.js | 4 +- wcfsetup/install/files/js/require.config.js | 2 - .../files/ts/WoltLabSuite/Core/Bootstrap.js | 4 +- 4 files changed, 2 insertions(+), 304 deletions(-) delete mode 100644 wcfsetup/install/files/js/3rdParty/enquire.js diff --git a/wcfsetup/install/files/js/3rdParty/enquire.js b/wcfsetup/install/files/js/3rdParty/enquire.js deleted file mode 100644 index 0a80eeb83e..0000000000 --- a/wcfsetup/install/files/js/3rdParty/enquire.js +++ /dev/null @@ -1,296 +0,0 @@ -/*! - * enquire.js v2.1.2 - Awesome Media Queries in JavaScript - * Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js - * License: MIT (http://www.opensource.org/licenses/mit-license.php) - */ - -;(function (name, context, factory) { - var matchMedia = window.matchMedia; - - if (typeof module !== 'undefined' && module.exports) { - module.exports = factory(matchMedia); - } - else if (typeof define === 'function' && define.amd) { - define(function() { - return (context[name] = factory(matchMedia)); - }); - } - else { - context[name] = factory(matchMedia); - } -}('enquire', this, function (matchMedia) { - - 'use strict'; - - /*jshint unused:false */ - /** - * Helper function for iterating over a collection - * - * @param collection - * @param fn - */ - function each(collection, fn) { - var i = 0, - length = collection.length, - cont; - - for(i; i < length; i++) { - cont = fn(collection[i], i); - if(cont === false) { - break; //allow early exit - } - } - } - - /** - * Helper function for determining whether target object is an array - * - * @param target the object under test - * @return {Boolean} true if array, false otherwise - */ - function isArray(target) { - return Object.prototype.toString.apply(target) === '[object Array]'; - } - - /** - * Helper function for determining whether target object is a function - * - * @param target the object under test - * @return {Boolean} true if function, false otherwise - */ - function isFunction(target) { - return typeof target === 'function'; - } - - /** - * Delegate to handle a media query being matched and unmatched. - * - * @param {object} options - * @param {function} options.match callback for when the media query is matched - * @param {function} [options.unmatch] callback for when the media query is unmatched - * @param {function} [options.setup] one-time callback triggered the first time a query is matched - * @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched? - * @constructor - */ - function QueryHandler(options) { - this.options = options; - !options.deferSetup && this.setup(); - } - QueryHandler.prototype = { - - /** - * coordinates setup of the handler - * - * @function - */ - setup : function() { - if(this.options.setup) { - this.options.setup(); - } - this.initialised = true; - }, - - /** - * coordinates setup and triggering of the handler - * - * @function - */ - on : function() { - !this.initialised && this.setup(); - this.options.match && this.options.match(); - }, - - /** - * coordinates the unmatch event for the handler - * - * @function - */ - off : function() { - this.options.unmatch && this.options.unmatch(); - }, - - /** - * called when a handler is to be destroyed. - * delegates to the destroy or unmatch callbacks, depending on availability. - * - * @function - */ - destroy : function() { - this.options.destroy ? this.options.destroy() : this.off(); - }, - - /** - * determines equality by reference. - * if object is supplied compare options, if function, compare match callback - * - * @function - * @param {object || function} [target] the target for comparison - */ - equals : function(target) { - return this.options === target || this.options.match === target; - } - - }; - /** - * Represents a single media query, manages it's state and registered handlers for this query - * - * @constructor - * @param {string} query the media query string - * @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design - */ - function MediaQuery(query, isUnconditional) { - this.query = query; - this.isUnconditional = isUnconditional; - this.handlers = []; - this.mql = matchMedia(query); - - var self = this; - this.listener = function(mql) { - self.mql = mql; - self.assess(); - }; - this.mql.addListener(this.listener); - } - MediaQuery.prototype = { - - /** - * add a handler for this query, triggering if already active - * - * @param {object} handler - * @param {function} handler.match callback for when query is activated - * @param {function} [handler.unmatch] callback for when query is deactivated - * @param {function} [handler.setup] callback for immediate execution when a query handler is registered - * @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched? - */ - addHandler : function(handler) { - var qh = new QueryHandler(handler); - this.handlers.push(qh); - - this.matches() && qh.on(); - }, - - /** - * removes the given handler from the collection, and calls it's destroy methods - * - * @param {object || function} handler the handler to remove - */ - removeHandler : function(handler) { - var handlers = this.handlers; - each(handlers, function(h, i) { - if(h.equals(handler)) { - h.destroy(); - return !handlers.splice(i,1); //remove from array and exit each early - } - }); - }, - - /** - * Determine whether the media query should be considered a match - * - * @return {Boolean} true if media query can be considered a match, false otherwise - */ - matches : function() { - return this.mql.matches || this.isUnconditional; - }, - - /** - * Clears all handlers and unbinds events - */ - clear : function() { - each(this.handlers, function(handler) { - handler.destroy(); - }); - this.mql.removeListener(this.listener); - this.handlers.length = 0; //clear array - }, - - /* - * Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match - */ - assess : function() { - var action = this.matches() ? 'on' : 'off'; - - each(this.handlers, function(handler) { - handler[action](); - }); - } - }; - /** - * Allows for registration of query handlers. - * Manages the query handler's state and is responsible for wiring up browser events - * - * @constructor - */ - function MediaQueryDispatch () { - if(!matchMedia) { - throw new Error('matchMedia not present, legacy browsers require a polyfill'); - } - - this.queries = {}; - this.browserIsIncapable = !matchMedia('only all').matches; - } - - MediaQueryDispatch.prototype = { - - /** - * Registers a handler for the given media query - * - * @param {string} q the media query - * @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers - * @param {function} options.match fired when query matched - * @param {function} [options.unmatch] fired when a query is no longer matched - * @param {function} [options.setup] fired when handler first triggered - * @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched - * @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers - */ - register : function(q, options, shouldDegrade) { - var queries = this.queries, - isUnconditional = shouldDegrade && this.browserIsIncapable; - - if(!queries[q]) { - queries[q] = new MediaQuery(q, isUnconditional); - } - - //normalise to object in an array - if(isFunction(options)) { - options = { match : options }; - } - if(!isArray(options)) { - options = [options]; - } - each(options, function(handler) { - if (isFunction(handler)) { - handler = { match : handler }; - } - queries[q].addHandler(handler); - }); - - return this; - }, - - /** - * unregisters a query and all it's handlers, or a specific handler for a query - * - * @param {string} q the media query to target - * @param {object || function} [handler] specific handler to unregister - */ - unregister : function(q, handler) { - var query = this.queries[q]; - - if(query) { - if(handler) { - query.removeHandler(handler); - } - else { - query.clear(); - delete this.queries[q]; - } - } - - return this; - } - }; - - return new MediaQueryDispatch(); - -})); \ No newline at end of file diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js index d9b4029283..feba1c976e 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Bootstrap.js @@ -10,7 +10,6 @@ */ define([ "favico", - "enquire", "perfect-scrollbar", "WoltLabSuite/Core/Date/Time/Relative", "Ui/SimpleDropdown", @@ -28,11 +27,10 @@ define([ "Devtools", "Dom/ChangeListener", "StringUtil" -], function (favico, enquire, perfectScrollbar, DateTimeRelative, UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu, UiDialog, UiTooltip, Language, Environment, DatePicker, EventHandler, Core, UiPageAction, Devtools, DomChangeListener, StringUtil) { +], function (favico, perfectScrollbar, DateTimeRelative, UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu, UiDialog, UiTooltip, Language, Environment, DatePicker, EventHandler, Core, UiPageAction, Devtools, DomChangeListener, StringUtil) { "use strict"; // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js window.Favico = favico; - window.enquire = enquire; // non strict equals by intent if (window.WCF == null) window.WCF = {}; diff --git a/wcfsetup/install/files/js/require.config.js b/wcfsetup/install/files/js/require.config.js index 61369552f9..e47d21f948 100644 --- a/wcfsetup/install/files/js/require.config.js +++ b/wcfsetup/install/files/js/require.config.js @@ -1,7 +1,6 @@ //noinspection JSUnresolvedVariable requirejs.config({ paths: { - enquire: '3rdParty/enquire', favico: '3rdParty/favico', 'perfect-scrollbar': '3rdParty/perfect-scrollbar', 'Pica': '3rdParty/pica', @@ -11,7 +10,6 @@ requirejs.config({ zxcvbn: '3rdParty/zxcvbn', }, shim: { - enquire: { exports: 'enquire' }, favico: { exports: 'Favico' }, 'perfect-scrollbar': { exports: 'PerfectScrollbar' } }, diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Bootstrap.js b/wcfsetup/install/files/ts/WoltLabSuite/Core/Bootstrap.js index 30b6d3f74b..ffc85b8c2d 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Bootstrap.js +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Bootstrap.js @@ -11,7 +11,6 @@ define( [ "favico", - "enquire", "perfect-scrollbar", "WoltLabSuite/Core/Date/Time/Relative", "Ui/SimpleDropdown", @@ -30,11 +29,10 @@ define( "Dom/ChangeListener", "StringUtil" ], - function(favico, enquire, perfectScrollbar, DateTimeRelative, UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu, UiDialog, UiTooltip, Language, Environment, DatePicker, EventHandler, Core, UiPageAction, Devtools, DomChangeListener, StringUtil) { + function(favico, perfectScrollbar, DateTimeRelative, UiSimpleDropdown, UiMobile, UiTabMenu, UiFlexibleMenu, UiDialog, UiTooltip, Language, Environment, DatePicker, EventHandler, Core, UiPageAction, Devtools, DomChangeListener, StringUtil) { "use strict"; // perfectScrollbar does not need to be bound anywhere, it just has to be loaded for WCF.js window.Favico = favico; - window.enquire = enquire; // non strict equals by intent if (window.WCF == null) window.WCF = {}; if (window.WCF.Language == null) window.WCF.Language = {}; -- 2.20.1