From 2c1897b373fa578c54a4f8a9a115fdca8747b5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 9 Oct 2020 12:20:09 -0400 Subject: [PATCH] feat: #8734, move slideout to package.json --- install/package.json | 1 + public/src/admin/.eslintrc | 4 +- public/src/admin/admin.js | 82 +++++++++++++------------- public/vendor/slideout/slideout.min.js | 1 - src/meta/js.js | 2 +- 5 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 public/vendor/slideout/slideout.min.js diff --git a/install/package.json b/install/package.json index dd91f0d3d6..df75656b96 100644 --- a/install/package.json +++ b/install/package.json @@ -116,6 +116,7 @@ "serve-favicon": "^2.5.0", "sharp": "0.26.1", "sitemap": "^6.1.0", + "slideout": "1.0.1", "socket.io": "2.3.0", "socket.io-adapter-cluster": "^1.0.1", "socket.io-adapter-postgres": "^1.2.1", diff --git a/public/src/admin/.eslintrc b/public/src/admin/.eslintrc index 8fdbda84ef..2d4ef534de 100644 --- a/public/src/admin/.eslintrc +++ b/public/src/admin/.eslintrc @@ -1,7 +1,5 @@ { "globals": { - "Sortable": true, - "Slideout": true, - "NProgress": true + "Sortable": true } } \ No newline at end of file diff --git a/public/src/admin/admin.js b/public/src/admin/admin.js index bada187b54..11806711bc 100644 --- a/public/src/admin/admin.js +++ b/public/src/admin/admin.js @@ -151,58 +151,60 @@ } function configureSlidemenu() { - var env = utils.findBootstrapEnvironment(); + require(['slideout'], function (Slideout) { + var env = utils.findBootstrapEnvironment(); + + var slideout = new Slideout({ + panel: document.getElementById('panel'), + menu: document.getElementById('menu'), + padding: 256, + tolerance: 70, + }); - var slideout = new Slideout({ - panel: document.getElementById('panel'), - menu: document.getElementById('menu'), - padding: 256, - tolerance: 70, - }); + if (env === 'md' || env === 'lg') { + slideout.disableTouch(); + } - if (env === 'md' || env === 'lg') { - slideout.disableTouch(); - } + $('#mobile-menu').on('click', function () { + slideout.toggle(); + }); - $('#mobile-menu').on('click', function () { - slideout.toggle(); - }); + $('#menu a').on('click', function () { + slideout.close(); + }); - $('#menu a').on('click', function () { - slideout.close(); - }); + $(window).on('resize', function () { + slideout.close(); - $(window).on('resize', function () { - slideout.close(); + env = utils.findBootstrapEnvironment(); - env = utils.findBootstrapEnvironment(); + if (env === 'md' || env === 'lg') { + slideout.disableTouch(); + $('#header').css({ + position: 'relative', + }); + } else { + slideout.enableTouch(); + $('#header').css({ + position: 'fixed', + }); + } + }); - if (env === 'md' || env === 'lg') { - slideout.disableTouch(); + function onOpeningMenu() { $('#header').css({ - position: 'relative', - }); - } else { - slideout.enableTouch(); - $('#header').css({ - position: 'fixed', + top: ($('#panel').position().top * -1) + 'px', + position: 'absolute', }); } - }); - - function onOpeningMenu() { - $('#header').css({ - top: ($('#panel').position().top * -1) + 'px', - position: 'absolute', - }); - } - slideout.on('open', onOpeningMenu); + slideout.on('open', onOpeningMenu); - slideout.on('close', function () { - $('#header').css({ - top: '0px', - position: 'fixed', + slideout.on('close', function () { + $('#header').css({ + top: '0px', + position: 'fixed', + }); }); }); } diff --git a/public/vendor/slideout/slideout.min.js b/public/vendor/slideout/slideout.min.js deleted file mode 100644 index 8827fb5a48..0000000000 --- a/public/vendor/slideout/slideout.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else{var e;"undefined"!=typeof window?e=window:"undefined"!=typeof global?e=global:"undefined"!=typeof self&&(e=self),e.Slideout=t()}}(function(){var t,e,n;return function i(t,e,n){function o(r,a){if(!e[r]){if(!t[r]){var u=typeof require=="function"&&require;if(!a&&u)return u(r,!0);if(s)return s(r,!0);var l=new Error("Cannot find module '"+r+"'");throw l.code="MODULE_NOT_FOUND",l}var f=e[r]={exports:{}};t[r][0].call(f.exports,function(e){var n=t[r][1][e];return o(n?n:e)},f,f.exports,i,t,e,n)}return e[r].exports}var s=typeof require=="function"&&require;for(var r=0;rt._tolerance?t.open():t.close()}t._moved=false};this.panel.addEventListener(f.end,this._onTouchEndFn);this._onTouchMoveFn=function(e){if(r||t._preventOpen||typeof e.touches==="undefined"||d(e.target)){return}var n=e.touches[0].clientX-t._startOffsetX;var i=t._currentOffsetX=n;if(Math.abs(i)>t._padding){return}if(Math.abs(n)>20){t._opening=true;var o=n*t._orientation;if(t._opened&&o>0||!t._opened&&o<0){return}if(!t._moved){t.emit("translatestart")}if(o<=0){i=n+t._padding*t._orientation;t._opening=false}if(!(t._moved&&u.classList.contains("slideout-open"))){u.classList.add("slideout-open")}t.panel.style[h+"transform"]=t.panel.style.transform="translateX("+i+"px)";t.emit("translate",i);t._moved=true}};this.panel.addEventListener(f.move,this._onTouchMoveFn);return this};_.prototype.enableTouch=function(){this._touch=true;return this};_.prototype.disableTouch=function(){this._touch=false;return this};_.prototype.destroy=function(){this.close();a.removeEventListener(f.move,this._preventMove);this.panel.removeEventListener(f.start,this._resetTouchFn);this.panel.removeEventListener("touchcancel",this._onTouchCancelFn);this.panel.removeEventListener(f.end,this._onTouchEndFn);this.panel.removeEventListener(f.move,this._onTouchMoveFn);a.removeEventListener("scroll",this._onScrollFn);this.open=this.close=function(){};return this};e.exports=_},{decouple:2,emitter:3}],2:[function(t,e,n){"use strict";var i=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||function(t){window.setTimeout(t,1e3/60)}}();function o(t,e,n){var o,s=false;function r(t){o=t;a()}function a(){if(!s){i(u);s=true}}function u(){n.call(t,o);s=false}t.addEventListener(e,r,false);return r}e.exports=o},{}],3:[function(t,e,n){"use strict";var i=function(t,e){if(!(t instanceof e)){throw new TypeError("Cannot call a class as a function")}};n.__esModule=true;var o=function(){function t(){i(this,t)}t.prototype.on=function e(t,n){this._eventCollection=this._eventCollection||{};this._eventCollection[t]=this._eventCollection[t]||[];this._eventCollection[t].push(n);return this};t.prototype.once=function n(t,e){var n=this;function i(){n.off(t,i);e.apply(this,arguments)}i.listener=e;this.on(t,i);return this};t.prototype.off=function o(t,e){var n=undefined;if(!this._eventCollection||!(n=this._eventCollection[t])){return this}n.forEach(function(t,i){if(t===e||t.listener===e){n.splice(i,1)}});if(n.length===0){delete this._eventCollection[t]}return this};t.prototype.emit=function s(t){var e=this;for(var n=arguments.length,i=Array(n>1?n-1:0),o=1;o