From: Timo Tijhof Date: Wed, 20 Mar 2019 23:57:38 +0000 (+0000) Subject: resources: Add verifiable upstream for various jquery plugins X-Git-Tag: 1.34.0-rc.0~2443^2 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/pie.php?a=commitdiff_plain;h=d5fe635e18a91769efa22538c2325eab972d9cf7;p=lhc%2Fweb%2Fwiklou.git resources: Add verifiable upstream for various jquery plugins * jStorage: Plain v0.4.12 release. * throttle-debounce: Plain v1.1 release. * jquery.form: Plain release. (But they don't have a git tag for it). * jquery.fullscreen: This was a pre-release committed in 3fe5f92a26f02 to fix a bug in IE11. We modified the header to indiciate which unreleased hash it came from upstream. Shortly after that, upstream released it proper (only the header was different). * hoverIntent: I accidentally modified this file in 2011 with 85d5e617d77a1f. That (insignificant) change is now reverted. Change-Id: Ibb1d368473b2a4b13795afedb66271a44e7e5bae --- diff --git a/maintenance/resources/foreign-resources.yaml b/maintenance/resources/foreign-resources.yaml index 37768cce39..3ecd12e8a3 100644 --- a/maintenance/resources/foreign-resources.yaml +++ b/maintenance/resources/foreign-resources.yaml @@ -90,6 +90,36 @@ jquery.cookie: src: https://raw.githubusercontent.com/carhartl/jquery-cookie/v1.3.1/CHANGELOG.md integrity: sha384-SQOHhLc7PHxHDQpGE/zv9XfXKL0A7OBu8kuyVDnHVp+zSoWyRw4xUJ+LSm5ql4kS +jquery.form: + type: file + src: https://raw.githubusercontent.com/jquery-form/form/ff80d9ddf4/jquery.form.js + integrity: sha384-h4G2CrcSbixzMvrrK259cNBYaL/vS1D4+KdUN9NJDzQnTU1bQ6Avluget+Id13M7 + dest: jquery.form.js + +jquery.fullscreen: + type: file + src: https://raw.githubusercontent.com/theopolisme/jquery-fullscreen/v2.1.0/jquery.fullscreen.js + integrity: sha384-G4KPs2d99tgcsyUnJ3eeZ1r2hEKDwZfc4+/xowL/LIemq2VVwEE8HpVAWt4WYNLR + dest: jquery.fullscreen.js + +jquery.hoverIntent: + type: file + src: https://raw.githubusercontent.com/briancherne/jquery-hoverIntent/823603fdac/jquery.hoverIntent.js + integrity: sha384-lca0haN0hqFGGh2aYUhtAgX9dhVHfQnTADH4svDeM6gcXnL7aFGeAi1NYwipDMyS + dest: jquery.hoverIntent.js + +jquery.jStorage: + type: file + src: https://raw.githubusercontent.com/andris9/jStorage/v0.4.12/jstorage.js + integrity: sha384-geMeN8k803kPp6cqRL4VNfuSM1L8DcbKRk0St/KHJzxgpX9S0y9FA6HxA/JgucrJ + dest: jstorage.js + +jquery.throttle-debounce: + type: file + src: https://raw.githubusercontent.com/cowboy/jquery-throttle-debounce/v1.1/jquery.ba-throttle-debounce.js + integrity: sha384-ULOy4DbAghrCqRcrTJLXOY9e4gDpWh0BeEf6xMSL0VtNudXWggcb6AmrVrl4KDAP + dest: jquery.ba-throttle-debounce.js + moment: type: tar src: https://codeload.github.com/moment/moment/tar.gz/2.24.0 diff --git a/resources/Resources.php b/resources/Resources.php index 86bca6c6c0..aa6e7550f2 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -223,10 +223,10 @@ return [ 'targets' => [ 'desktop', 'mobile' ], ], 'jquery.form' => [ - 'scripts' => 'resources/lib/jquery.form.js', + 'scripts' => 'resources/lib/jquery.form/jquery.form.js', ], 'jquery.fullscreen' => [ - 'scripts' => 'resources/lib/jquery.fullscreen.js', + 'scripts' => 'resources/lib/jquery.fullscreen/jquery.fullscreen.js', ], 'jquery.getAttrs' => [ 'scripts' => 'resources/src/jquery/jquery.getAttrs.js', @@ -240,7 +240,7 @@ return [ 'targets' => [ 'desktop', 'mobile' ], ], 'jquery.hoverIntent' => [ - 'scripts' => 'resources/lib/jquery.hoverIntent.js', + 'scripts' => 'resources/lib/jquery.hoverIntent/jquery.hoverIntent.js', ], 'jquery.i18n' => [ 'scripts' => [ @@ -299,7 +299,7 @@ return [ ], 'jquery.jStorage' => [ 'deprecated' => 'Please use "mediawiki.storage" instead.', - 'scripts' => 'resources/lib/jquery.jStorage.js', + 'scripts' => 'resources/lib/jquery.jStorage/jstorage.js', ], 'jquery.suggestions' => [ 'targets' => [ 'desktop', 'mobile' ], @@ -332,7 +332,7 @@ return [ 'jquery.throttle-debounce' => [ 'deprecated' => 'Please use OO.ui.throttle/debounce instead. See ' . 'https://phabricator.wikimedia.org/T213426', - 'scripts' => 'resources/lib/jquery.ba-throttle-debounce.js', + 'scripts' => 'resources/lib/jquery.throttle-debounce/jquery.ba-throttle-debounce.js', 'targets' => [ 'desktop', 'mobile' ], ], diff --git a/resources/lib/jquery.ba-throttle-debounce.js b/resources/lib/jquery.ba-throttle-debounce.js deleted file mode 100644 index fa30bdfffe..0000000000 --- a/resources/lib/jquery.ba-throttle-debounce.js +++ /dev/null @@ -1,252 +0,0 @@ -/*! - * jQuery throttle / debounce - v1.1 - 3/7/2010 - * http://benalman.com/projects/jquery-throttle-debounce-plugin/ - * - * Copyright (c) 2010 "Cowboy" Ben Alman - * Dual licensed under the MIT and GPL licenses. - * http://benalman.com/about/license/ - */ - -// Script: jQuery throttle / debounce: Sometimes, less is more! -// -// *Version: 1.1, Last updated: 3/7/2010* -// -// Project Home - http://benalman.com/projects/jquery-throttle-debounce-plugin/ -// GitHub - http://github.com/cowboy/jquery-throttle-debounce/ -// Source - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.js -// (Minified) - http://github.com/cowboy/jquery-throttle-debounce/raw/master/jquery.ba-throttle-debounce.min.js (0.7kb) -// -// About: License -// -// Copyright (c) 2010 "Cowboy" Ben Alman, -// Dual licensed under the MIT and GPL licenses. -// http://benalman.com/about/license/ -// -// About: Examples -// -// These working examples, complete with fully commented code, illustrate a few -// ways in which this plugin can be used. -// -// Throttle - http://benalman.com/code/projects/jquery-throttle-debounce/examples/throttle/ -// Debounce - http://benalman.com/code/projects/jquery-throttle-debounce/examples/debounce/ -// -// About: Support and Testing -// -// Information about what version or versions of jQuery this plugin has been -// tested with, what browsers it has been tested in, and where the unit tests -// reside (so you can test it yourself). -// -// jQuery Versions - none, 1.3.2, 1.4.2 -// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome 4-5, Opera 9.6-10.1. -// Unit Tests - http://benalman.com/code/projects/jquery-throttle-debounce/unit/ -// -// About: Release History -// -// 1.1 - (3/7/2010) Fixed a bug in where trailing callbacks -// executed later than they should. Reworked a fair amount of internal -// logic as well. -// 1.0 - (3/6/2010) Initial release as a stand-alone project. Migrated over -// from jquery-misc repo v0.4 to jquery-throttle repo v1.0, added the -// no_trailing throttle parameter and debounce functionality. -// -// Topic: Note for non-jQuery users -// -// jQuery isn't actually required for this plugin, because nothing internal -// uses any jQuery methods or properties. jQuery is just used as a namespace -// under which these methods can exist. -// -// Since jQuery isn't actually required for this plugin, if jQuery doesn't exist -// when this plugin is loaded, the method described below will be created in -// the `Cowboy` namespace. Usage will be exactly the same, but instead of -// $.method() or jQuery.method(), you'll need to use Cowboy.method(). - -(function(window,undefined){ - '$:nomunge'; // Used by YUI compressor. - - // Since jQuery really isn't required for this plugin, use `jQuery` as the - // namespace only if it already exists, otherwise use the `Cowboy` namespace, - // creating it if necessary. - var $ = window.jQuery || window.Cowboy || ( window.Cowboy = {} ), - - // Internal method reference. - jq_throttle; - - // Method: jQuery.throttle - // - // Throttle execution of a function. Especially useful for rate limiting - // execution of handlers on events like resize and scroll. If you want to - // rate-limit execution of a function to a single time, see the - // method. - // - // In this visualization, | is a throttled-function call and X is the actual - // callback execution: - // - // > Throttled with `no_trailing` specified as false or unspecified: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X X X X X X X X X X X - // > - // > Throttled with `no_trailing` specified as true: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X X X X X X X X X - // - // Usage: - // - // > var throttled = jQuery.throttle( delay, [ no_trailing, ] callback ); - // > - // > jQuery('selector').bind( 'someevent', throttled ); - // > jQuery('selector').unbind( 'someevent', throttled ); - // - // This also works in jQuery 1.4+: - // - // > jQuery('selector').bind( 'someevent', jQuery.throttle( delay, [ no_trailing, ] callback ) ); - // > jQuery('selector').unbind( 'someevent', callback ); - // - // Arguments: - // - // delay - (Number) A zero-or-greater delay in milliseconds. For event - // callbacks, values around 100 or 250 (or even higher) are most useful. - // no_trailing - (Boolean) Optional, defaults to false. If no_trailing is - // true, callback will only execute every `delay` milliseconds while the - // throttled-function is being called. If no_trailing is false or - // unspecified, callback will be executed one final time after the last - // throttled-function call. (After the throttled-function has not been - // called for `delay` milliseconds, the internal counter is reset) - // callback - (Function) A function to be executed after delay milliseconds. - // The `this` context and all arguments are passed through, as-is, to - // `callback` when the throttled-function is executed. - // - // Returns: - // - // (Function) A new, throttled, function. - - $.throttle = jq_throttle = function( delay, no_trailing, callback, debounce_mode ) { - // After wrapper has stopped being called, this timeout ensures that - // `callback` is executed at the proper times in `throttle` and `end` - // debounce modes. - var timeout_id, - - // Keep track of the last time `callback` was executed. - last_exec = 0; - - // `no_trailing` defaults to falsy. - if ( typeof no_trailing !== 'boolean' ) { - debounce_mode = callback; - callback = no_trailing; - no_trailing = undefined; - } - - // The `wrapper` function encapsulates all of the throttling / debouncing - // functionality and when executed will limit the rate at which `callback` - // is executed. - function wrapper() { - var that = this, - elapsed = +new Date() - last_exec, - args = arguments; - - // Execute `callback` and update the `last_exec` timestamp. - function exec() { - last_exec = +new Date(); - callback.apply( that, args ); - }; - - // If `debounce_mode` is true (at_begin) this is used to clear the flag - // to allow future `callback` executions. - function clear() { - timeout_id = undefined; - }; - - if ( debounce_mode && !timeout_id ) { - // Since `wrapper` is being called for the first time and - // `debounce_mode` is true (at_begin), execute `callback`. - exec(); - } - - // Clear any existing timeout. - timeout_id && clearTimeout( timeout_id ); - - if ( debounce_mode === undefined && elapsed > delay ) { - // In throttle mode, if `delay` time has been exceeded, execute - // `callback`. - exec(); - - } else if ( no_trailing !== true ) { - // In trailing throttle mode, since `delay` time has not been - // exceeded, schedule `callback` to execute `delay` ms after most - // recent execution. - // - // If `debounce_mode` is true (at_begin), schedule `clear` to execute - // after `delay` ms. - // - // If `debounce_mode` is false (at end), schedule `callback` to - // execute after `delay` ms. - timeout_id = setTimeout( debounce_mode ? clear : exec, debounce_mode === undefined ? delay - elapsed : delay ); - } - }; - - // Set the guid of `wrapper` function to the same of original callback, so - // it can be removed in jQuery 1.4+ .unbind or .die by using the original - // callback as a reference. - if ( $.guid ) { - wrapper.guid = callback.guid = callback.guid || $.guid++; - } - - // Return the wrapper function. - return wrapper; - }; - - // Method: jQuery.debounce - // - // Debounce execution of a function. Debouncing, unlike throttling, - // guarantees that a function is only executed a single time, either at the - // very beginning of a series of calls, or at the very end. If you want to - // simply rate-limit execution of a function, see the - // method. - // - // In this visualization, | is a debounced-function call and X is the actual - // callback execution: - // - // > Debounced with `at_begin` specified as false or unspecified: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X - // > - // > Debounced with `at_begin` specified as true: - // > ||||||||||||||||||||||||| (pause) ||||||||||||||||||||||||| - // > X X - // - // Usage: - // - // > var debounced = jQuery.debounce( delay, [ at_begin, ] callback ); - // > - // > jQuery('selector').bind( 'someevent', debounced ); - // > jQuery('selector').unbind( 'someevent', debounced ); - // - // This also works in jQuery 1.4+: - // - // > jQuery('selector').bind( 'someevent', jQuery.debounce( delay, [ at_begin, ] callback ) ); - // > jQuery('selector').unbind( 'someevent', callback ); - // - // Arguments: - // - // delay - (Number) A zero-or-greater delay in milliseconds. For event - // callbacks, values around 100 or 250 (or even higher) are most useful. - // at_begin - (Boolean) Optional, defaults to false. If at_begin is false or - // unspecified, callback will only be executed `delay` milliseconds after - // the last debounced-function call. If at_begin is true, callback will be - // executed only at the first debounced-function call. (After the - // throttled-function has not been called for `delay` milliseconds, the - // internal counter is reset) - // callback - (Function) A function to be executed after delay milliseconds. - // The `this` context and all arguments are passed through, as-is, to - // `callback` when the debounced-function is executed. - // - // Returns: - // - // (Function) A new, debounced, function. - - $.debounce = function( delay, at_begin, callback ) { - return callback === undefined - ? jq_throttle( delay, at_begin, false ) - : jq_throttle( delay, callback, at_begin !== false ); - }; - -})(this); diff --git a/resources/lib/jquery.form.js b/resources/lib/jquery.form.js deleted file mode 100644 index 13e9a55c58..0000000000 --- a/resources/lib/jquery.form.js +++ /dev/null @@ -1,1089 +0,0 @@ -/*! - * jQuery Form Plugin - * version: 3.14 (30-JUL-2012) - * @requires jQuery v1.3.2 or later - * - * Examples and documentation at: http://malsup.com/jquery/form/ - * Project repository: https://github.com/malsup/form - * Dual licensed under the MIT and GPL licenses: - * http://malsup.github.com/mit-license.txt - * http://malsup.github.com/gpl-license-v2.txt - */ -/*global ActiveXObject alert */ -;(function($) { -"use strict"; - -/* - Usage Note: - ----------- - Do not use both ajaxSubmit and ajaxForm on the same form. These - functions are mutually exclusive. Use ajaxSubmit if you want - to bind your own submit handler to the form. For example, - - $(document).ready(function() { - $('#myForm').on('submit', function(e) { - e.preventDefault(); // <-- important - $(this).ajaxSubmit({ - target: '#output' - }); - }); - }); - - Use ajaxForm when you want the plugin to manage all the event binding - for you. For example, - - $(document).ready(function() { - $('#myForm').ajaxForm({ - target: '#output' - }); - }); - - You can also use ajaxForm with delegation (requires jQuery v1.7+), so the - form does not have to exist when you invoke ajaxForm: - - $('#myForm').ajaxForm({ - delegation: true, - target: '#output' - }); - - When using ajaxForm, the ajaxSubmit function will be invoked for you - at the appropriate time. -*/ - -/** - * Feature detection - */ -var feature = {}; -feature.fileapi = $("").get(0).files !== undefined; -feature.formdata = window.FormData !== undefined; - -/** - * ajaxSubmit() provides a mechanism for immediately submitting - * an HTML form using AJAX. - */ -$.fn.ajaxSubmit = function(options) { - /*jshint scripturl:true */ - - // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) - if (!this.length) { - log('ajaxSubmit: skipping submit process - no element selected'); - return this; - } - - var method, action, url, $form = this; - - if (typeof options == 'function') { - options = { success: options }; - } - - method = this.attr('method'); - action = this.attr('action'); - url = (typeof action === 'string') ? $.trim(action) : ''; - url = url || window.location.href || ''; - if (url) { - // clean url (don't include hash vaue) - url = (url.match(/^([^#]+)/)||[])[1]; - } - - options = $.extend(true, { - url: url, - success: $.ajaxSettings.success, - type: method || 'GET', - iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' - }, options); - - // hook for manipulating the form data before it is extracted; - // convenient for use with rich editors like tinyMCE or FCKEditor - var veto = {}; - this.trigger('form-pre-serialize', [this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); - return this; - } - - // provide opportunity to alter form data before it is serialized - if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSerialize callback'); - return this; - } - - var traditional = options.traditional; - if ( traditional === undefined ) { - traditional = $.ajaxSettings.traditional; - } - - var elements = []; - var qx, a = this.formToArray(options.semantic, elements); - if (options.data) { - options.extraData = options.data; - qx = $.param(options.data, traditional); - } - - // give pre-submit callback an opportunity to abort the submit - if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { - log('ajaxSubmit: submit aborted via beforeSubmit callback'); - return this; - } - - // fire vetoable 'validate' event - this.trigger('form-submit-validate', [a, this, options, veto]); - if (veto.veto) { - log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); - return this; - } - - var q = $.param(a, traditional); - if (qx) { - q = ( q ? (q + '&' + qx) : qx ); - } - if (options.type.toUpperCase() == 'GET') { - options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; - options.data = null; // data is null for 'get' - } - else { - options.data = q; // data is the query string for 'post' - } - - var callbacks = []; - if (options.resetForm) { - callbacks.push(function() { $form.resetForm(); }); - } - if (options.clearForm) { - callbacks.push(function() { $form.clearForm(options.includeHidden); }); - } - - // perform a load on the target only if dataType is not provided - if (!options.dataType && options.target) { - var oldSuccess = options.success || function(){}; - callbacks.push(function(data) { - var fn = options.replaceTarget ? 'replaceWith' : 'html'; - $(options.target)[fn](data).each(oldSuccess, arguments); - }); - } - else if (options.success) { - callbacks.push(options.success); - } - - options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg - var context = options.context || this ; // jQuery 1.4+ supports scope context - for (var i=0, max=callbacks.length; i < max; i++) { - callbacks[i].apply(context, [data, status, xhr || $form, $form]); - } - }; - - // are there files to upload? - var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113) - var hasFileInputs = fileInputs.length > 0; - var mp = 'multipart/form-data'; - var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); - - var fileAPI = feature.fileapi && feature.formdata; - log("fileAPI :" + fileAPI); - var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; - - // options.iframe allows user to force iframe mode - // 06-NOV-09: now defaulting to iframe mode if file input is detected - if (options.iframe !== false && (options.iframe || shouldUseFrame)) { - // hack to fix Safari hang (thanks to Tim Molendijk for this) - // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d - if (options.closeKeepAlive) { - $.get(options.closeKeepAlive, function() { - fileUploadIframe(a); - }); - } - else { - fileUploadIframe(a); - } - } - else if ((hasFileInputs || multipart) && fileAPI) { - fileUploadXhr(a); - } - else { - $.ajax(options); - } - - // clear element array - for (var k=0; k < elements.length; k++) - elements[k] = null; - - // fire 'notify' event - this.trigger('form-submit-notify', [this, options]); - return this; - - // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) - function fileUploadXhr(a) { - var formdata = new FormData(); - - for (var i=0; i < a.length; i++) { - formdata.append(a[i].name, a[i].value); - } - - if (options.extraData) { - for (var p in options.extraData) - if (options.extraData.hasOwnProperty(p)) - formdata.append(p, options.extraData[p]); - } - - options.data = null; - - var s = $.extend(true, {}, $.ajaxSettings, options, { - contentType: false, - processData: false, - cache: false, - type: 'POST' - }); - - if (options.uploadProgress) { - // workaround because jqXHR does not expose upload property - s.xhr = function() { - var xhr = jQuery.ajaxSettings.xhr(); - if (xhr.upload) { - xhr.upload.onprogress = function(event) { - var percent = 0; - var position = event.loaded || event.position; /*event.position is deprecated*/ - var total = event.total; - if (event.lengthComputable) { - percent = Math.ceil(position / total * 100); - } - options.uploadProgress(event, position, total, percent); - }; - } - return xhr; - }; - } - - s.data = null; - var beforeSend = s.beforeSend; - s.beforeSend = function(xhr, o) { - o.data = formdata; - if(beforeSend) - beforeSend.call(this, xhr, o); - }; - $.ajax(s); - } - - // private function for handling file uploads (hat tip to YAHOO!) - function fileUploadIframe(a) { - var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; - var useProp = !!$.fn.prop; - - if ($(':input[name=submit],:input[id=submit]', form).length) { - // if there is an input with a name or id of 'submit' then we won't be - // able to invoke the submit fn on the form (at least not x-browser) - alert('Error: Form elements must not have name or id of "submit".'); - return; - } - - if (a) { - // ensure that every serialized input is still enabled - for (i=0; i < elements.length; i++) { - el = $(elements[i]); - if ( useProp ) - el.prop('disabled', false); - else - el.removeAttr('disabled'); - } - } - - s = $.extend(true, {}, $.ajaxSettings, options); - s.context = s.context || s; - id = 'jqFormIO' + (new Date().getTime()); - if (s.iframeTarget) { - $io = $(s.iframeTarget); - n = $io.attr('name'); - if (!n) - $io.attr('name', id); - else - id = n; - } - else { - $io = $('