diff --git a/bower.json b/bower.json index c4771d4e..88e00a64 100644 --- a/bower.json +++ b/bower.json @@ -25,8 +25,7 @@ "bootstrap-fileinput": "^4.3.3", "bootstrap": "^3.3.6", "sweetalert2": "^4.1.6", - "jqPaginator": "^1.2.0", - "lodash": "^4.17.4" + "jqPaginator": "^1.2.0" }, "resolutions": { "jquery": "1.9.1 - 3" diff --git a/gulpfile.js b/gulpfile.js index 836178e9..d9e0d0ea 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,8 +1,8 @@ /* * @Author: printempw * @Date: 2016-07-21 13:38:26 -* @Last Modified by: printempw -* @Last Modified time: 2017-01-22 20:45:06 + * @Last Modified by: g-plane + * @Last Modified time: 2017-04-26 15:39:46 */ 'use strict'; @@ -25,7 +25,6 @@ var srcPath = 'resources/assets/src/'; var distPath = 'resources/assets/dist/'; var vendorScripts = [ - 'lodash/dist/lodash.min.js', 'jquery/dist/jquery.min.js', 'bootstrap/dist/js/bootstrap.min.js', 'AdminLTE/dist/js/app.min.js', diff --git a/resources/assets/src/scripts/admin.js b/resources/assets/src/scripts/admin.js index 3290ed38..e0e83aec 100644 --- a/resources/assets/src/scripts/admin.js +++ b/resources/assets/src/scripts/admin.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-07-22 14:02:44 * @Last Modified by: g-plane - * @Last Modified time: 2017-04-26 15:31:34 + * @Last Modified time: 2017-04-26 15:37:52 */ 'use strict'; @@ -321,7 +321,7 @@ function changeOwner(pid) { }); }); - $('.swal2-input').on('input', _.debounce(() => { + $('.swal2-input').on('input', debounce(() => { const uid = $('.swal2-input').val(); if (uid > 0) { Promise.resolve($.ajax({ diff --git a/resources/assets/src/scripts/general.js b/resources/assets/src/scripts/general.js index 6294cce3..b5e4f781 100644 --- a/resources/assets/src/scripts/general.js +++ b/resources/assets/src/scripts/general.js @@ -1,8 +1,8 @@ /* * @Author: printempw * @Date: 2016-09-15 10:39:41 -* @Last Modified by: printempw -* @Last Modified time: 2017-01-22 18:51:51 + * @Last Modified by: g-plane + * @Last Modified time: 2017-04-26 15:57:50 */ 'use strict'; @@ -157,6 +157,28 @@ function getQueryString(key) { } } +/** + * Return a debounced function + * + * @param {Function} func + * @param {number} delay + * @param {Array} args + * @param {Object} context + */ +function debounce(func, delay, args = [], context = undefined) { + if (isNaN(delay) || typeof func !== 'function') { + throw new Error('Arguments type of function "debounce" is incorrent!'); + } + + let timer = null; + return function () { + clearTimeout(timer); + timer = setTimeout(() => { + func.apply(context, args); + }, delay); + } +} + // polyfill of String.prototype.endsWith if (!String.prototype.endsWith) { String.prototype.endsWith = function (searchString, position) { diff --git a/resources/assets/src/scripts/user.js b/resources/assets/src/scripts/user.js index 545873d2..90c3bd81 100644 --- a/resources/assets/src/scripts/user.js +++ b/resources/assets/src/scripts/user.js @@ -1,8 +1,8 @@ /* * @Author: printempw * @Date: 2016-07-16 10:02:24 - * @Last Modified by: printempw - * @Last Modified time: 2017-01-20 21:19:07 + * @Last Modified by: g-plane + * @Last Modified time: 2017-04-26 15:53:54 */ 'use strict'; @@ -278,7 +278,7 @@ $(document).ready(function() { }); }).catch(error => showAjaxError); - $('input[name=q]').on('input', _.debounce(() => { + $('input[name=q]').on('input', debounce(() => { const category = $('#skin-category').hasClass('active') ? 'skin' : 'cape'; reloadCloset( category,