diff --git a/gulpfile.js b/gulpfile.js index e591f1d3..014c39d0 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,6 +1,19 @@ var elixir = require ('laravel-elixir'); +require ('laravel-elixir-remove') + elixir (function (mix) { + var defaultColor = "green"; + var colors = ["blue", "seagreen", 'orange', "green", 'purple', 'red']; + var outputName; + colors.forEach (function (color) { + outputName = color === defaultColor ? 'app.css' : 'app-' + color + ".css"; + mix.copy ('resources/assets/sass/admin/_themes/' + color + '-theme.scss', 'public/css/admin/theme.scss') + .sass ([ + 'admin/**/!(_imports|_variables|*-theme)*.scss', + '../admin/css' + ], 'public/css/admin/' + outputName, null, {includePaths: ['bower_components', 'resources/assets/sass/admin']}) + }) // vendor files mix @@ -12,27 +25,14 @@ elixir (function (mix) { 'metisMenu/dist/metisMenu.min.js', 'tinycolor/dist/tinycolor-min.js', 'jquery.are-you-sure/jquery.are-you-sure.js', - '../resources/assets/admin/js/app.js', - ], 'public/js/vendor.js', 'bower_components'); - - var defaultColor = "green"; - var colors = ["blue", "seagreen", 'orange', "green", 'purple', 'red']; - var outputName; - colors.forEach (function (color) { - outputName = color == defaultColor ? 'app.css' : 'app-' + color + ".css"; - mix.copy ('resources/assets/sass/admin/_themes/' + color + '-theme.scss', 'public/css/admin/theme.scss'); - mix.sass ([ - 'admin/**/!(_imports|_variables|*-theme)*.scss', - '../admin/css/custom.css' - - ], 'public/css/admin/' + outputName, null, {includePaths: ['bower_components', 'resources/assets/sass/admin']}); - }) - - mix.copy ('bower_components/font-awesome/css/font-awesome.min.css', 'public/css'); - mix.copy ('bower_components/font-awesome/fonts', 'public/fonts'); - mix.sass (['bootstrap/bootstrap.scss'], 'public/css/admin/bootstrap.css'); - mix.styles ([ - '../../../public/css/admin/bootstrap.css', - '../../../bower_components/animate.css/animate.css', - ], 'public/css/admin/style.css'); + '../resources/assets/admin/js/*.js', + ], 'public/js/vendor.js', 'bower_components') + .copy ('bower_components/font-awesome/css/font-awesome.min.css', 'public/css') + .copy ('bower_components/font-awesome/fonts', 'public/fonts') + .sass (['bootstrap/bootstrap.scss'], 'public/css/admin/bootstrap.css') + .styles ([ + '../../../public/css/admin/bootstrap.css', + '../../../bower_components/animate.css/animate.css', + ], 'public/css/admin/style.css') + .remove ('public/css/admin/theme.scss'); }); diff --git a/package-lock.json b/package-lock.json index 175a299a..bb35f0ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -121,6 +121,29 @@ "integrity": "sha1-5zA08A3MH0CHYAj9IP6ud71LfC8=", "dev": true }, + "array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha1-mjRBDk9OPaI96jdb5b5w8kd47Dk=", + "requires": { + "array-uniq": "1.0.3" + } + }, + "array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=" + }, + "arrify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", + "integrity": "sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=" + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, "block-stream": { "version": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz", "integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=", @@ -135,12 +158,78 @@ "integrity": "sha1-Vdvr7wrZFVOC2enT5JfBNyNFtEo=", "dev": true }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", "integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=", "dev": true }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "del": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/del/-/del-2.2.2.tgz", + "integrity": "sha1-wSyYHQZ4RshLyvhiz/kw2Qf/0ag=", + "requires": { + "globby": "5.0.0", + "is-path-cwd": "1.0.0", + "is-path-in-cwd": "1.0.0", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1", + "rimraf": "2.6.2" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + }, + "dependencies": { + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + } + } + }, + "globby": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-5.0.0.tgz", + "integrity": "sha1-69hGZ8oNuzMLmbz8aOrCvFQ3Dg0=", + "requires": { + "array-union": "1.0.2", + "arrify": "1.0.1", + "glob": "7.1.2", + "object-assign": "4.1.1", + "pify": "2.3.0", + "pinkie-promise": "2.0.1" + } + }, "gulp": { "version": "3.9.1", "resolved": "https://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz", @@ -1617,11 +1706,41 @@ "integrity": "sha1-0mMTX0MwfALGAq/I/pWXDAFRNp4=", "dev": true }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } + }, "inherits": { "version": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "is-path-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-cwd/-/is-path-cwd-1.0.0.tgz", + "integrity": "sha1-0iXsIxMuie3Tj9p2dHLmLmXxEG0=" + }, + "is-path-in-cwd": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz", + "integrity": "sha1-ZHdYK4IU1gI0YJRWcAO+ip6sBNw=", + "requires": { + "is-path-inside": "1.0.0" + } + }, + "is-path-inside": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.0.tgz", + "integrity": "sha1-/AbloWg/vaE95mev9xe7wQpI838=", + "requires": { + "path-is-inside": "1.0.2" + } + }, "is-plain-object": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", @@ -5010,6 +5129,12 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -5021,12 +5146,6 @@ "strip-ansi": "3.0.1" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", - "dev": true - }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", @@ -5459,6 +5578,14 @@ } } }, + "laravel-elixir-remove": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/laravel-elixir-remove/-/laravel-elixir-remove-0.2.1.tgz", + "integrity": "sha1-BmbTw/JFSLcV1DFdjLFQ9ejENkI=", + "requires": { + "del": "2.2.2" + } + }, "lodash": { "version": "4.17.4", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", @@ -5471,6 +5598,19 @@ "integrity": "sha1-JMS/zWsvuji/0FlNsRedjptlZWE=", "dev": true }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "1.1.8" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, "object.defaults": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/object.defaults/-/object.defaults-1.1.0.tgz", @@ -5523,6 +5663,24 @@ } } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1.0.2" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=" + }, "path-parse": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.5.tgz", @@ -5535,6 +5693,32 @@ "integrity": "sha1-M+8wxcd9TqIcWlOGnZG1bY8lVeU=", "dev": true }, + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=" + }, + "pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha1-clVrgM+g1IqXToDnckjoDtT3+HA=" + }, + "pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha1-ITXW36ejWMBprJsXh3YogihFD/o=", + "requires": { + "pinkie": "2.0.4" + } + }, + "rimraf": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.2.tgz", + "integrity": "sha512-lreewLK/BlghmxtfH36YYVg1i8IAce4TI7oao75I1g245+6BctqTVQiBP3YUJ9C6DQOXJmkYR9X9fCLtCOJc5w==", + "requires": { + "glob": "7.1.2" + } + }, "safe-buffer": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", @@ -5573,6 +5757,11 @@ } } } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/package.json b/package.json index 870e41b2..6a7c2584 100644 --- a/package.json +++ b/package.json @@ -10,5 +10,8 @@ "jquery": "^3.2.1", "laravel-elixir": "^6.0.0-11", "lodash": "^4.16.2" + }, + "dependencies": { + "laravel-elixir-remove": "^0.2.1" } } diff --git a/resources/assets/admin/js/app.js b/resources/assets/admin/js/app.js index 4c48a5cc..5ca40345 100644 --- a/resources/assets/admin/js/app.js +++ b/resources/assets/admin/js/app.js @@ -1,437 +1,9 @@ -var config = window.config = {}; - -// Config reference element -var $ref = $ ("#ref"); - -// Configure responsive bootstrap toolkit -config.ResponsiveBootstrapToolkitVisibilityDivs = { - 'xs': $ ('
'), - 'sm': $ (''), - 'md': $ (''), - 'lg': $ (''), - 'xl': $ ('') -}; - -ResponsiveBootstrapToolkit.use ('Custom', config.ResponsiveBootstrapToolkitVisibilityDivs); - -//validation configuration -config.validations = { - debug: true, - errorClass: 'has-error', - validClass: 'success', - errorElement: "span", - - // add error class - highlight: function (element, errorClass, validClass) { - $ (element).parents ("div.form-group") - .addClass (errorClass) - .removeClass (validClass); - }, - - // add error class - unhighlight: function (element, errorClass, validClass) { - $ (element).parents (".has-error") - .removeClass (errorClass) - .addClass (validClass); - }, - - // submit handler - submitHandler: function (form) { - form.submit (); - } -}; - -//delay time configuration -config.delayTime = 50; - -// chart configurations -config.chart = {}; - -/*********************************************** - * Animation Settings - ***********************************************/ -function animate(options) { - var animationName = "animated " + options.name; - var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend"; - $ (options.selector) - .addClass (animationName) - .one (animationEnd, - function () { - $ (this).removeClass (animationName); - } - ); -} - -$ (function () { - var $itemActions = $ (".item-actions-dropdown"); - - $ (document).on ('click', function (e) { - if (!$ (e.target).closest ('.item-actions-dropdown').length) { - $itemActions.removeClass ('active'); - } - }); - - $ ('.item-actions-toggle-btn').on ('click', function (e) { - e.preventDefault (); - - var $thisActionList = $ (this).closest ('.item-actions-dropdown'); - - $itemActions.not ($thisActionList).removeClass ('active'); - - $thisActionList.toggleClass ('active'); - }); -}); - -function setSameHeights($container) { - - $container = $container || $ ('.sameheight-container'); - - var viewport = ResponsiveBootstrapToolkit.current (); - - $container.each (function () { - - var $items = $ (this).find (".sameheight-item"); - - // Get max height of items in container - var maxHeight = 0; - - $items.each (function () { - $ (this).css ({height: 'auto'}); - maxHeight = Math.max (maxHeight, $ (this).innerHeight ()); - }); - - // Set heights of items - $items.each (function () { - // Ignored viewports for item - var excludedStr = $ (this).data ('exclude') || ''; - var excluded = excludedStr.split (','); - - // Set height of element if it's not excluded on - if (excluded.indexOf (viewport) === -1) { - $ (this).innerHeight (maxHeight); - } - }); - }); -} - -$ (function () { - animate ({ - name: 'flipInY', - selector: '.error-card > .error-title-block' - }); - - setTimeout (function () { - var $el = $ ('.error-card > .error-container'); - - animate ({ - name: 'fadeInUp', - selector: $el - }); - - $el.addClass ('visible'); - }, 500); -}); - -$ (function () { - - $ ('#sidebar-menu, #customize-menu').metisMenu ({ - activeClass: 'open' - }); - - $ ('#sidebar-collapse-btn').on ('click', function (event) { - event.preventDefault (); - - $ ("#app").toggleClass ("sidebar-open"); - }); - - $ ("#sidebar-overlay").on ('click', function () { - $ ("#app").removeClass ("sidebar-open"); - }); - -}); -$ (function () { - - $ ('.actions-list > li').on ('click', '.check', function (e) { - e.preventDefault (); - - $ (this).parents ('.tasks-item') - .find ('.checkbox') - .prop ("checked", true); - - // removeActionList (); - }); - -}); - -$ (function () { - $ ('.nav-profile > li > a').on ('click', function () { - var $el = $ (this).next (); - - animate ({ - name: 'flipInX', - selector: $el - }); - }); -}); - -$ (function () { - // Local storage settings - var themeSettings = getThemeSettings (); - - // Elements - - var $app = $ ('#app'); - var $styleLink = $ ('#theme-style'); - var $customizeMenu = $ ('#customize-menu'); - - // Color switcher - var $customizeMenuColorBtns = $customizeMenu.find ('.color-item'); - - // Position switchers - var $customizeMenuRadioBtns = $customizeMenu.find ('.radio'); - - /************************************************ - * Initial State - *************************************************/ - - setThemeSettings (); - - setSameHeights (); - - /************************************************ - * Events - *************************************************/ - - // set theme type - $customizeMenuColorBtns.on ('click', function () { - themeSettings.themeName = $ (this).data ('theme'); - - setThemeSettings (); - }); - - $customizeMenuRadioBtns.on ('click', function () { - - var optionName = $ (this).prop ('name'); - themeSettings[optionName] = $ (this).val (); - - setThemeSettings (); - }); - - function setThemeSettings() { - setThemeState () - .delay (config.delayTime) - .queue (function (next) { - - setThemeColor (); - setThemeControlsState (); - saveThemeSettings (); - - $ (document).trigger ("themechange"); - - next (); - }); - } - - /************************************************ - * Update theme based on options - *************************************************/ - - function setThemeState() { - // set theme type - if (themeSettings.themeName) { - $styleLink.attr ('href', window.cssPath + '/app-' + themeSettings.themeName + '.css'); - } - else { - $styleLink.attr ('href', window.cssPath + '/app.css'); - } - // App classes - $app.removeClass ('header-fixed footer-fixed sidebar-fixed'); - - // set header - $app.addClass (themeSettings.headerPosition); - - // set footer - $app.addClass (themeSettings.footerPosition); - - // set footer - $app.addClass (themeSettings.sidebarPosition); - - return $app; - } - - /************************************************ - * Update theme controls based on options - *************************************************/ - - function setThemeControlsState() { - // set color switcher - $customizeMenuColorBtns.each (function () { - if ($ (this).data ('theme') === themeSettings.themeName) { - $ (this).addClass ('active'); - } - else { - $ (this).removeClass ('active'); - } - }); - - // set radio buttons - $customizeMenuRadioBtns.each (function () { - var name = $ (this).prop ('name'); - var value = $ (this).val (); - - if (themeSettings[name] === value) { - $ (this).prop ("checked", true); - } - else { - $ (this).prop ("checked", false); - } - }); - } - - /************************************************ - * Update theme color - *************************************************/ - function setThemeColor() { - config.chart.colorPrimary = tinycolor ($ref.find (".chart .color-primary").css ("color")); - config.chart.colorSecondary = tinycolor ($ref.find (".chart .color-secondary").css ("color")); - } - - /************************************************ - * Storage Functions - *************************************************/ - - function getThemeSettings() { - var settings = (localStorage.getItem ('themeSettings')) ? JSON.parse (localStorage.getItem ('themeSettings')) : {}; - - settings.headerPosition = settings.headerPosition || ''; - settings.sidebarPosition = settings.sidebarPosition || ''; - settings.footerPosition = settings.footerPosition || ''; - - return settings; - } - - function saveThemeSettings() { - localStorage.setItem ('themeSettings', JSON.stringify (themeSettings)); - } - -}); - -/** - * Makes slug from input string - * - * @param text - * @param trimSpaces - * - * @returns {string} - */ -function slugify(text, trimSpaces) { - text = text.toString ().toLowerCase (); - - if (trimSpaces) - text = text.trim (); - - return text.replace (/ /g, '-') - .replace (/[àáâãäå]/g, "a") - .replace (/[čç]/g, "c") - .replace (/[ěèéêë]/g, "e") - .replace (/[ùúûüů]/g, "u") - .replace (/[ìíîï]/g, "i") - .replace (/[ňńñ]/g, "n") - .replace (/[òóôõö]/g, "o") - .replace (/[ýÿ]/g, "y") - .replace (/œ/g, "oe") - .replace (/ď/g, "d") - .replace (/ř/g, "r") - .replace (/š/g, "s") - .replace (/ž/g, "z") - .replace (/ť/g, "t") - .replace (/æ/g, "ae") - .replace (/[^a-z0-9\-]+/g, '') - .replace (/--+/g, '-'); -} - // bind some custom methods $ (document).ready (function () { $ ("body").addClass ("loaded"); - var notification = $ ('.notification'); - if (notification.length) { - - notification.click (function () { - $ (this).fadeOut ('fast'); - }); - - setTimeout (function () { - notification.fadeOut (1500) - }, 5 * 1000) - } - - var previousTitle, previousMessage; - - $ ('.confirm').click (function (e) { - - var titleElement = $ ('#confirmation-title'); - var messageElement = $ ('#confirmation-message'); - - previousTitle = titleElement.text (); - previousMessage = messageElement.text (); - - var confirmTitle = $ (this).data ('title'); - var confirmMessage = $ (this).data ('message'); - - var tag = $ (this).prop ('tagName'); - if (tag === 'A') { - var href = $ (this).attr ('href'); - - $ ('#confirm-button').attr ('href', href); - } else if (tag === 'BUTTON') { - var form = $ (this).closest ('form'); - $ ('#confirm-button').click (function () { - form.submit (); - }) - } - - if (confirmTitle) - titleElement.text (confirmTitle); - - if (confirmMessage) - messageElement.text (confirmMessage); - - $ ('#confirm-modal').modal ('show'); - - $ ('.main-wrapper').addClass ('blur'); - - e.preventDefault (); - }); - - $ ('#confirm-modal').on ('hidden.bs.modal', function () { - $ ('#confirmation-title').text (previousTitle); - $ ('#confirmation-message').text (previousMessage); - $ ('.main-wrapper').removeClass ('blur'); - }); - - $ ('#lockUrl').change (function () { - $ ('.slug-source').keyup (); - }); - - $ ('.slug-target').keyup (function () { - $ (this).val (slugify ($ (this).val (), false)); - $ ('#lockUrl').prop ('checked', true); - }); - - $ ('.slug-source').keyup (function () { - var source = $ (this); - var target = $ ('.slug-target'); - var locked = $ ('#lockUrl'); - - if (!locked.is (':checked')) - target.val (slugify (source.val (), true)); - }); - - $ (function () { - $ ('[data-toggle="tooltip"]').tooltip () - }); + $ ('[data-toggle="tooltip"]').tooltip () // find if any error occured and mark tab with that error $ ('.has-error').each (function () { @@ -443,7 +15,6 @@ $ (document).ready (function () { $ ('#removeTitlePhoto').click (function () { $ ('#titlePhotoContainer').remove (); - // $('existingTitlePhoto').val(null); }); $ ('form').areYouSure (); diff --git a/resources/assets/admin/js/confirmModal.js b/resources/assets/admin/js/confirmModal.js new file mode 100644 index 00000000..93c3c603 --- /dev/null +++ b/resources/assets/admin/js/confirmModal.js @@ -0,0 +1,43 @@ +var previousTitle, previousMessage; + +$ ('.confirm').click (function (e) { + + var titleElement = $ ('#confirmation-title'); + var messageElement = $ ('#confirmation-message'); + + previousTitle = titleElement.text (); + previousMessage = messageElement.text (); + + var confirmTitle = $ (this).data ('title'); + var confirmMessage = $ (this).data ('message'); + + var tag = $ (this).prop ('tagName'); + if (tag === 'A') { + var href = $ (this).attr ('href'); + + $ ('#confirm-button').attr ('href', href); + } else if (tag === 'BUTTON') { + var form = $ (this).closest ('form'); + $ ('#confirm-button').click (function () { + form.submit (); + }) + } + + if (confirmTitle) + titleElement.text (confirmTitle); + + if (confirmMessage) + messageElement.text (confirmMessage); + + $ ('#confirm-modal').modal ('show'); + + $ ('.main-wrapper').addClass ('blur'); + + e.preventDefault (); +}); + +$ ('#confirm-modal').on ('hidden.bs.modal', function () { + $ ('#confirmation-title').text (previousTitle); + $ ('#confirmation-message').text (previousMessage); + $ ('.main-wrapper').removeClass ('blur'); +}); \ No newline at end of file diff --git a/resources/assets/admin/js/notification.js b/resources/assets/admin/js/notification.js new file mode 100644 index 00000000..44a7f6fd --- /dev/null +++ b/resources/assets/admin/js/notification.js @@ -0,0 +1,11 @@ +var notification = $ ('.notification'); +if (notification.length) { + + notification.click (function () { + $ (this).fadeOut ('fast'); + }); + + setTimeout (function () { + notification.fadeOut (1500) + }, 5 * 1000) +} \ No newline at end of file diff --git a/resources/assets/admin/js/slugify.js b/resources/assets/admin/js/slugify.js new file mode 100644 index 00000000..9892f153 --- /dev/null +++ b/resources/assets/admin/js/slugify.js @@ -0,0 +1,51 @@ +/** + * Makes slug from input string + * + * @param text + * @param trimSpaces + * + * @returns {string} + */ +function slugify(text, trimSpaces) { + text = text.toString ().toLowerCase (); + + if (trimSpaces) + text = text.trim (); + + return text.replace (/ /g, '-') + .replace (/[àáâãäå]/g, "a") + .replace (/[čç]/g, "c") + .replace (/[ěèéêë]/g, "e") + .replace (/[ùúûüů]/g, "u") + .replace (/[ìíîï]/g, "i") + .replace (/[ňńñ]/g, "n") + .replace (/[òóôõö]/g, "o") + .replace (/[ýÿ]/g, "y") + .replace (/œ/g, "oe") + .replace (/ď/g, "d") + .replace (/ř/g, "r") + .replace (/š/g, "s") + .replace (/ž/g, "z") + .replace (/ť/g, "t") + .replace (/æ/g, "ae") + .replace (/[^a-z0-9\-]+/g, '') + .replace (/--+/g, '-'); +} + +$ ('#lockUrl').change (function () { + $ ('.slug-source').keyup (); +}); + +$ ('.slug-target').keyup (function () { + $ (this).val (slugify ($ (this).val (), false)); + $ ('#lockUrl').prop ('checked', true); +}); + +$ ('.slug-source').keyup (function () { + var source = $ (this); + var target = $ ('.slug-target'); + var locked = $ ('#lockUrl'); + + if (!locked.is (':checked')) + target.val (slugify (source.val (), true)); +}); diff --git a/resources/assets/admin/js/theme.js b/resources/assets/admin/js/theme.js new file mode 100644 index 00000000..506a8f9b --- /dev/null +++ b/resources/assets/admin/js/theme.js @@ -0,0 +1,316 @@ +var config = window.config = {}; + +// Config reference element +var $ref = $ ("#ref"); + +// Configure responsive bootstrap toolkit +config.ResponsiveBootstrapToolkitVisibilityDivs = { + 'xs': $ (''), + 'sm': $ (''), + 'md': $ (''), + 'lg': $ (''), + 'xl': $ ('') +}; + +ResponsiveBootstrapToolkit.use ('Custom', config.ResponsiveBootstrapToolkitVisibilityDivs); + +//validation configuration +config.validations = { + debug: true, + errorClass: 'has-error', + validClass: 'success', + errorElement: "span", + + // add error class + highlight: function (element, errorClass, validClass) { + $ (element).parents ("div.form-group") + .addClass (errorClass) + .removeClass (validClass); + }, + + // add error class + unhighlight: function (element, errorClass, validClass) { + $ (element).parents (".has-error") + .removeClass (errorClass) + .addClass (validClass); + }, + + // submit handler + submitHandler: function (form) { + form.submit (); + } +}; + +//delay time configuration +config.delayTime = 50; + +// chart configurations +config.chart = {}; + +/*********************************************** + * Animation Settings + ***********************************************/ +function animate(options) { + var animationName = "animated " + options.name; + var animationEnd = "webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend"; + $ (options.selector) + .addClass (animationName) + .one (animationEnd, + function () { + $ (this).removeClass (animationName); + } + ); +} + +$ (function () { + var $itemActions = $ (".item-actions-dropdown"); + + $ (document).on ('click', function (e) { + if (!$ (e.target).closest ('.item-actions-dropdown').length) { + $itemActions.removeClass ('active'); + } + }); + + $ ('.item-actions-toggle-btn').on ('click', function (e) { + e.preventDefault (); + + var $thisActionList = $ (this).closest ('.item-actions-dropdown'); + + $itemActions.not ($thisActionList).removeClass ('active'); + + $thisActionList.toggleClass ('active'); + }); +}); + +function setSameHeights($container) { + + $container = $container || $ ('.sameheight-container'); + + var viewport = ResponsiveBootstrapToolkit.current (); + + $container.each (function () { + + var $items = $ (this).find (".sameheight-item"); + + // Get max height of items in container + var maxHeight = 0; + + $items.each (function () { + $ (this).css ({height: 'auto'}); + maxHeight = Math.max (maxHeight, $ (this).innerHeight ()); + }); + + // Set heights of items + $items.each (function () { + // Ignored viewports for item + var excludedStr = $ (this).data ('exclude') || ''; + var excluded = excludedStr.split (','); + + // Set height of element if it's not excluded on + if (excluded.indexOf (viewport) === -1) { + $ (this).innerHeight (maxHeight); + } + }); + }); +} + +$ (function () { + animate ({ + name: 'flipInY', + selector: '.error-card > .error-title-block' + }); + + setTimeout (function () { + var $el = $ ('.error-card > .error-container'); + + animate ({ + name: 'fadeInUp', + selector: $el + }); + + $el.addClass ('visible'); + }, 500); +}); + +$ (function () { + + $ ('#sidebar-menu, #customize-menu').metisMenu ({ + activeClass: 'open' + }); + + $ ('#sidebar-collapse-btn').on ('click', function (event) { + event.preventDefault (); + + $ ("#app").toggleClass ("sidebar-open"); + }); + + $ ("#sidebar-overlay").on ('click', function () { + $ ("#app").removeClass ("sidebar-open"); + }); + +}); +$ (function () { + + $ ('.actions-list > li').on ('click', '.check', function (e) { + e.preventDefault (); + + $ (this).parents ('.tasks-item') + .find ('.checkbox') + .prop ("checked", true); + + // removeActionList (); + }); + +}); + +$ (function () { + $ ('.nav-profile > li > a').on ('click', function () { + var $el = $ (this).next (); + + animate ({ + name: 'flipInX', + selector: $el + }); + }); +}); + +$ (function () { + // Local storage settings + var themeSettings = getThemeSettings (); + + // Elements + + var $app = $ ('#app'); + var $styleLink = $ ('#theme-style'); + var $customizeMenu = $ ('#customize-menu'); + + // Color switcher + var $customizeMenuColorBtns = $customizeMenu.find ('.color-item'); + + // Position switchers + var $customizeMenuRadioBtns = $customizeMenu.find ('.radio'); + + /************************************************ + * Initial State + *************************************************/ + + setThemeSettings (); + + setSameHeights (); + + /************************************************ + * Events + *************************************************/ + + // set theme type + $customizeMenuColorBtns.on ('click', function () { + themeSettings.themeName = $ (this).data ('theme'); + + setThemeSettings (); + }); + + $customizeMenuRadioBtns.on ('click', function () { + + var optionName = $ (this).prop ('name'); + themeSettings[optionName] = $ (this).val (); + + setThemeSettings (); + }); + + function setThemeSettings() { + setThemeState () + .delay (config.delayTime) + .queue (function (next) { + + setThemeColor (); + setThemeControlsState (); + saveThemeSettings (); + + $ (document).trigger ("themechange"); + + next (); + }); + } + + /************************************************ + * Update theme based on options + *************************************************/ + + function setThemeState() { + // set theme type + if (themeSettings.themeName) { + $styleLink.attr ('href', window.cssPath + '/app-' + themeSettings.themeName + '.css'); + } + else { + $styleLink.attr ('href', window.cssPath + '/app.css'); + } + // App classes + $app.removeClass ('header-fixed footer-fixed sidebar-fixed'); + + // set header + $app.addClass (themeSettings.headerPosition); + + // set footer + $app.addClass (themeSettings.footerPosition); + + // set footer + $app.addClass (themeSettings.sidebarPosition); + + return $app; + } + + /************************************************ + * Update theme controls based on options + *************************************************/ + + function setThemeControlsState() { + // set color switcher + $customizeMenuColorBtns.each (function () { + if ($ (this).data ('theme') === themeSettings.themeName) { + $ (this).addClass ('active'); + } + else { + $ (this).removeClass ('active'); + } + }); + + // set radio buttons + $customizeMenuRadioBtns.each (function () { + var name = $ (this).prop ('name'); + var value = $ (this).val (); + + if (themeSettings[name] === value) { + $ (this).prop ("checked", true); + } + else { + $ (this).prop ("checked", false); + } + }); + } + + /************************************************ + * Update theme color + *************************************************/ + function setThemeColor() { + config.chart.colorPrimary = tinycolor ($ref.find (".chart .color-primary").css ("color")); + config.chart.colorSecondary = tinycolor ($ref.find (".chart .color-secondary").css ("color")); + } + + /************************************************ + * Storage Functions + *************************************************/ + + function getThemeSettings() { + var settings = (localStorage.getItem ('themeSettings')) ? JSON.parse (localStorage.getItem ('themeSettings')) : {}; + + settings.headerPosition = settings.headerPosition || ''; + settings.sidebarPosition = settings.sidebarPosition || ''; + settings.footerPosition = settings.footerPosition || ''; + + return settings; + } + + function saveThemeSettings() { + localStorage.setItem ('themeSettings', JSON.stringify (themeSettings)); + } +}); \ No newline at end of file