diff --git a/.scripts/assets-build-tool/copy.mjs b/.scripts/assets-build-tool/copy.mjs index 9edc9bed00a..a1f0272d316 100644 --- a/.scripts/assets-build-tool/copy.mjs +++ b/.scripts/assets-build-tool/copy.mjs @@ -1,68 +1,102 @@ import fs from "fs-extra"; -import { glob } from 'glob' +import { glob } from "glob"; import JSON5 from "json5"; import chalk from "chalk"; import path from "path"; let action = process.argv[2]; -const config = JSON5.parse(Buffer.from(process.argv[3], "base64").toString("utf-8")); +const config = JSON5.parse( + Buffer.from(process.argv[3], "base64").toString("utf-8") +); + +let dest = config.dest; + +if (config.dest == undefined) { + if (config.tags.includes("js")) { + dest = config.basePath + "/wwwroot/Scripts/"; + } else if (config.tags.includes("css")) { + dest = config.basePath + "/wwwroot/Styles/"; + } +} if (config.dryRun) { - action = "dry-run"; + action = "dry-run"; } // console.log(`copy ${action}`, config); glob(config.source).then((files) => { + if (files.length == 0) { + console.log(chalk.yellow("No files to copy", config.source)); + return; + } - if (files.length == 0) { - console.log(chalk.yellow("No files to copy", config.source)); - return; - } - - const destExists = fs.existsSync(config.dest); + const destExists = fs.existsSync(dest); - if (destExists) { - const stats = fs.lstatSync(config.dest); - if (!stats.isDirectory()) { - console.log(chalk.red("Destination is not a directory")); - console.log("Files:", files); - console.log("Destination:", config.dest); - return; + if (destExists) { + const stats = fs.lstatSync(dest); + if (!stats.isDirectory()) { + console.log(chalk.red("Destination is not a directory")); + console.log("Files:", files); + console.log("Destination:", dest); + return; + } + console.log( + chalk.yellow( + `Destination ${dest} already exists, files may be overwritten` + ) + ); } - console.log(chalk.yellow(`Destination ${config.dest} already exists, files may be overwritten`)); - } - - let baseFolder; - if (config.source.indexOf("**") > 0) { - baseFolder = config.source.substring(0, config.source.indexOf("**")); - } + let baseFolder; - files.forEach((file) => { - file = file.replace(/\\/g,'/'); - let relativePath; - if (baseFolder) { - relativePath = file.replace(baseFolder, ""); - } else { - relativePath = path.basename(file); + if (config.source.indexOf("**") > 0) { + baseFolder = config.source.substring(0, config.source.indexOf("**")); } - const target = path.join(config.dest, relativePath); + files.forEach((file) => { + file = file.replace(/\\/g, "/"); + let relativePath; + if (baseFolder) { + relativePath = file.replace(baseFolder, ""); + } else { + relativePath = path.basename(file); + } - if (action === "dry-run") { - console.log(`Dry run (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target)); - } else { - fs.stat(file).then((stat) => { - if (!stat.isDirectory()) { - fs.copy(file, target) - .then(() => console.log(`Copied (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target))) - .catch((err) => { - console.log(`${chalk.red("Error copying")} (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target), chalk.red(err)); - throw err; + const target = path.join(dest, relativePath); + + if (action === "dry-run") { + console.log( + `Dry run (${chalk.gray("from")}, ${chalk.cyan("to")})`, + chalk.gray(file), + chalk.cyan(target) + ); + } else { + fs.stat(file).then((stat) => { + if (!stat.isDirectory()) { + fs.copy(file, target) + .then(() => + console.log( + `Copied (${chalk.gray("from")}, ${chalk.cyan( + "to" + )})`, + chalk.gray(file), + chalk.cyan(target) + ) + ) + .catch((err) => { + console.log( + `${chalk.red("Error copying")} (${chalk.gray( + "from" + )}, ${chalk.cyan("to")})`, + chalk.gray(file), + chalk.cyan(target), + chalk.red(err) + ); + throw err; + }); + } }); } - }); - } - }); + }); }); diff --git a/.scripts/assets-build-tool/min.mjs b/.scripts/assets-build-tool/min.mjs index 3b15a6267e6..20ccf30e530 100644 --- a/.scripts/assets-build-tool/min.mjs +++ b/.scripts/assets-build-tool/min.mjs @@ -1,92 +1,147 @@ import fs from "fs-extra"; -import { glob } from 'glob' +import { glob } from "glob"; import JSON5 from "json5"; import chalk from "chalk"; import path from "path"; import swc from "@swc/core"; let action = process.argv[2]; -const config = JSON5.parse(Buffer.from(process.argv[3], "base64").toString("utf-8")); +const config = JSON5.parse( + Buffer.from(process.argv[3], "base64").toString("utf-8") +); + +let dest = config.dest; + +if (config.dest == undefined) { + if (config.tags.includes("js")) { + dest = config.basePath + "/wwwroot/Scripts/"; + } else if (config.tags.includes("css")) { + dest = config.basePath + "/wwwroot/Styles/"; + } +} if (config.dryRun) { - action = "dry-run"; + action = "dry-run"; } // console.log(`minify ${action}`, config); glob(config.source).then((files) => { - if (files.length == 0) { - console.log(chalk.yellow("No files to copy", config.source)); - return; - } - - const destExists = fs.existsSync(config.dest); - - if (destExists) { - const stats = fs.lstatSync(config.dest); - if (!stats.isDirectory()) { - console.log(chalk.red("Destination is not a directory")); - console.log("Files:", files); - console.log("Destination:", config.dest); - return; + if (files.length == 0) { + console.log(chalk.yellow("No files to minify", config.source)); + return; } - console.log(chalk.yellow(`Destination ${config.dest} already exists, files may be overwritten`)); - } - let baseFolder; + const destExists = fs.existsSync(dest); - if (config.source.indexOf("**") > 0) { - baseFolder = config.source.substring(0, config.source.indexOf("**")); - } + if (destExists) { + const stats = fs.lstatSync(dest); + if (!stats.isDirectory()) { + console.log(chalk.red("Destination is not a directory")); + console.log("Files:", files); + console.log("Destination:", dest); + return; + } + console.log( + chalk.yellow( + `Destination ${dest} already exists, files may be overwritten` + ) + ); + } - files.forEach((file) => { - file = file.replace(/\\/g, "/"); - let relativePath; + let baseFolder; - if (baseFolder) { - relativePath = file.replace(baseFolder, ""); - } else { - relativePath = path.basename(file); + if (config.source.indexOf("**") > 0) { + baseFolder = config.source.substring(0, config.source.indexOf("**")); } - const target = path.join(config.dest, relativePath); - - if (action === "dry-run") { - console.log(`Dry run (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target)); - } else { - fs.stat(file).then(async (stat) => { - if (!stat.isDirectory()) { - let fileInfo = path.parse(file); - - if (fileInfo.ext === ".js" || fileInfo.ext === ".css") { - let reader = await fs.readFile(file, "utf8"); - - swc - .minify(reader, { - compress: true, - sourceMap: true, - }) - .then((output) => { - const minifiedTarget = path.join(config.dest, path.parse(target).name + ".min.js"); - fs.outputFile(minifiedTarget, output.code); - console.log(`Minified (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(minifiedTarget)); - - const mappedTarget = path.join(config.dest, path.parse(target).name + ".map"); - fs.outputFile(mappedTarget, output.map); - console.log(`Mapped (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(mappedTarget)); - }); - - fs.copy(file, target) - .then(() => console.log(`Copied (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target))) - .catch((err) => { - console.log(`${chalk.red("Error copying")} (${chalk.gray("from")}, ${chalk.cyan("to")})`, chalk.gray(file), chalk.cyan(target), chalk.red(err)); - throw err; - }); - } else { - console.log("Trying to minify a file with an extension that is not allowed."); - } + files.forEach((file) => { + file = file.replace(/\\/g, "/"); + let relativePath; + + if (baseFolder) { + relativePath = file.replace(baseFolder, ""); + } else { + relativePath = path.basename(file); } - }); - } - }); + + const target = path.join(dest, relativePath); + + if (action === "dry-run") { + console.log( + `Dry run (${chalk.gray("from")}, ${chalk.cyan("to")})`, + chalk.gray(file), + chalk.cyan(target) + ); + } else { + fs.stat(file).then(async (stat) => { + if (!stat.isDirectory()) { + let fileInfo = path.parse(file); + + if (fileInfo.ext === ".js" || fileInfo.ext === ".css") { + let reader = await fs.readFile(file, "utf8"); + + swc.minify(reader, { + compress: true, + sourceMap: true, + }).then((output) => { + const minifiedTarget = path.join( + dest, + path.parse(target).name + ".min.js" + ); + fs.outputFile(minifiedTarget, output.code); + console.log( + `Minified (${chalk.gray("from")}, ${chalk.cyan( + "to" + )})`, + chalk.gray(file), + chalk.cyan(minifiedTarget) + ); + + const mappedTarget = path.join( + dest, + path.parse(target).name + ".map" + ); + fs.outputFile(mappedTarget, output.map); + console.log( + `Mapped (${chalk.gray("from")}, ${chalk.cyan( + "to" + )})`, + chalk.gray(file), + chalk.cyan(mappedTarget) + ); + }); + + fs.copy(file, target) + .then(() => + console.log( + `Copied (${chalk.gray( + "from" + )}, ${chalk.cyan("to")})`, + chalk.gray(file), + chalk.cyan(target) + ) + ) + .catch((err) => { + console.log( + `${chalk.red( + "Error copying" + )} (${chalk.gray("from")}, ${chalk.cyan( + "to" + )})`, + chalk.gray(file), + chalk.cyan(target), + chalk.red(err) + ); + throw err; + }); + } else { + console.log( + "Trying to minify a file with an extension that is not allowed." + ); + } + } + }); + } + }); }); diff --git a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json index aa11cf25808..8dc2eeaedc7 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Assets2.json @@ -3,7 +3,6 @@ "action": "sass", "name": "admin-dashboard", "source": "Assets/scss/dashboard.scss", - "dest": "wwwroot/Styles/", "tags": ["admin", "dashboard", "scss"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Assets2.json b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Assets2.json index eb20096226f..cf3cc05937f 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "content-types", "source": "Assets/js/list-items-filter.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Contents/Assets2.json index 39578cf71de..ae411b455e9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Assets2.json @@ -15,14 +15,12 @@ "action": "min", "name": "content-localization", "source": "Assets/js/audittrail-disabledcontent.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { "action": "min", "name": "content-localization", "source": "Assets/js/content-type-check-all.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Cors/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Cors/Assets2.json index 7927ee82ec9..d77f1aa5a83 100644 --- a/src/OrchardCore.Modules/OrchardCore.Cors/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Cors/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "cors", "source": "Assets/Admin/cors-admin.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Deployment/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Deployment/Assets2.json index cebd6bee51b..b86dac5d75e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Deployment/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Deployment/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "deployment", "source": "Assets/js/steporder.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Flows/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Flows/Assets2.json index 9231388a4bb..9cc5d229623 100644 --- a/src/OrchardCore.Modules/OrchardCore.Flows/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Flows/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "flows", "source": "Assets/js/flows.edit.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { diff --git a/src/OrchardCore.Modules/OrchardCore.Forms/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Forms/Assets2.json index 0a98998942f..75d7db3459a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Forms/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Forms/Assets2.json @@ -3,14 +3,12 @@ "action": "min", "name": "selectOptionsEditor", "source": "Assets/js/SelectOptionsEditor/selectOptionsEditor.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { "action": "min", "name": "formElementLabelManager", "source": "Assets/js/formElementLabelManager.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { diff --git a/src/OrchardCore.Modules/OrchardCore.Html/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Html/Assets2.json index 0b1539489fb..d1a5faff444 100644 --- a/src/OrchardCore.Modules/OrchardCore.Html/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Html/Assets2.json @@ -3,14 +3,12 @@ "action": "min", "name": "trumbowyg.media.tag", "source": "Assets/trumbowyg.media.tag.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { "action": "min", "name": "trumbowyg.media.url", "source": "Assets/trumbowyg.media.url.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Lists/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Lists/Assets2.json index ff130e1c36e..51fce4a6d33 100644 --- a/src/OrchardCore.Modules/OrchardCore.Lists/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Lists/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "ci-list-ordering", "source": "Assets/Scripts/ci-list-ordering.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Localization/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Localization/Assets2.json index 308e7412a67..cda928cc126 100644 --- a/src/OrchardCore.Modules/OrchardCore.Localization/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Localization/Assets2.json @@ -3,7 +3,6 @@ "action": "min", "name": "loc-optionsEditor", "source": "Assets/js/*.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/Assets2.json b/src/OrchardCore.Modules/OrchardCore.Menu/Assets2.json index 956b5fcd114..00410e40700 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/Assets2.json +++ b/src/OrchardCore.Modules/OrchardCore.Menu/Assets2.json @@ -7,16 +7,14 @@ }, { "action": "min", - "name": "nestedSortable", + "name": "menu", "source": "Assets/js/menu.js", - "dest": "wwwroot/Scripts/", "tags": ["admin", "dashboard", "js"] }, { "action": "min", "name": "activate-links", "source": "Assets/js/activate-links.js", - "dest": "wwwroot/Scripts/menu.js", "tags": ["admin", "dashboard", "js"] }, { @@ -29,7 +27,6 @@ "action": "min", "name": "menu-permission-picker", "source": "Assets/js/menu-permission-picker.js", - "dest": "wwwroot/Scripts/menu.js", "tags": ["admin", "dashboard", "js"] } ] diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.js b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.js index 9525d5c6cbf..694f96953b6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.js +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.js @@ -1,40 +1,42 @@ -/* -** NOTE: This file is generated by Gulp and should not be edited directly! -** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. -*/ - // This script is used to add a class on the active link of a menu. // Because Menus are often cached, the class needs to be set dynamically using JavaScript. (function ($) { - $.fn.activateLinks = function (options, cb) { - var settings = $.extend({ - // class to add to the selector - "class": "active", - // custom selector based on the parent of the link - selector: null, - // how many segments to remove from url in order to find active link in menu - traverse: 0 - }, options); - var segments = window.location.href.replace(window.location.protocol + '//' + window.location.host, '').split("/"); - var level = segments.length; - var minLevel = settings.traverse <= 0 ? level : level >= settings.traverse ? level - settings.traverse : level; - while (level >= minLevel) { - var currentUrl = segments.join('/'); - var items = $(this).find('a[href="' + currentUrl + '"]').parent(); - if (settings.selector) { - items = items.find(settings.selector); - } - if (items.length > 0) { - items.addClass(settings["class"]); - if (cb) { - cb(items); + + $.fn.activateLinks = function (options, cb) { + + var settings = $.extend({ + // class to add to the selector + class: "active", + // custom selector based on the parent of the link + selector: null, + // how many segments to remove from url in order to find active link in menu + traverse: 0 + }, options); + + var segments = window.location.href.replace(window.location.protocol + '//' + window.location.host, '').split("/"); + var level = segments.length; + var minLevel = settings.traverse <= 0 ? level : level >= settings.traverse ? level - settings.traverse : level; + + while (level >= minLevel) { + var currentUrl = segments.join('/'); + var items = $(this).find('a[href="' + currentUrl + '"]').parent(); + + if (settings.selector) { + items = items.find(settings.selector); + } + + if (items.length > 0) { + items.addClass(settings.class); + if (cb) { + cb(items); + } + return this; + } + + level -= 1; + segments = segments.slice(0, level); } return this; - } - level -= 1; - segments = segments.slice(0, level); - } - return this; - }; -})(jQuery); \ No newline at end of file + }; +}(jQuery)); diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.map b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.map new file mode 100644 index 00000000000..8f92c968ba5 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.map @@ -0,0 +1 @@ +{"version":3,"sources":[""],"sourcesContent":["// This script is used to add a class on the active link of a menu.\r\n// Because Menus are often cached, the class needs to be set dynamically using JavaScript.\r\n\r\n(function ($) {\r\n\r\n $.fn.activateLinks = function (options, cb) {\r\n\r\n var settings = $.extend({\r\n // class to add to the selector\r\n class: \"active\",\r\n // custom selector based on the parent of the link\r\n selector: null,\r\n // how many segments to remove from url in order to find active link in menu\r\n traverse: 0\r\n }, options);\r\n\r\n var segments = window.location.href.replace(window.location.protocol + '//' + window.location.host, '').split(\"/\");\r\n var level = segments.length;\r\n var minLevel = settings.traverse <= 0 ? level : level >= settings.traverse ? level - settings.traverse : level;\r\n\r\n while (level >= minLevel) {\r\n var currentUrl = segments.join('/');\r\n var items = $(this).find('a[href=\"' + currentUrl + '\"]').parent();\r\n\r\n if (settings.selector) {\r\n items = items.find(settings.selector);\r\n }\r\n\r\n if (items.length > 0) {\r\n items.addClass(settings.class);\r\n if (cb) {\r\n cb(items);\r\n }\r\n return this;\r\n }\r\n\r\n level -= 1;\r\n segments = segments.slice(0, level);\r\n }\r\n return this;\r\n };\r\n}(jQuery));\r\n"],"names":["$","fn","activateLinks","options","cb","settings","extend","class","selector","traverse","segments","window","location","href","replace","protocol","host","split","level","length","minLevel","currentUrl","join","items","find","parent","addClass","slice","jQuery"],"mappings":"CAGC,SAAUA,CAAC,EAERA,EAAEC,EAAE,CAACC,aAAa,CAAG,SAAUC,CAAO,CAAEC,CAAE,EAetC,IAbA,IAAIC,EAAWL,EAAEM,MAAM,CAAC,CAEpBC,MAAO,SAEPC,SAAU,KAEVC,SAAU,CACd,EAAGN,GAECO,EAAWC,OAAOC,QAAQ,CAACC,IAAI,CAACC,OAAO,CAACH,OAAOC,QAAQ,CAACG,QAAQ,CAAG,KAAOJ,OAAOC,QAAQ,CAACI,IAAI,CAAE,IAAIC,KAAK,CAAC,KAC1GC,EAAQR,EAASS,MAAM,CACvBC,EAAWf,EAASI,QAAQ,EAAI,EAAIS,EAAQA,GAASb,EAASI,QAAQ,CAAGS,EAAQb,EAASI,QAAQ,CAAGS,EAElGA,GAASE,GAAU,CACtB,IAAIC,EAAaX,EAASY,IAAI,CAAC,KAC3BC,EAAQvB,EAAE,IAAI,EAAEwB,IAAI,CAAC,WAAaH,EAAa,MAAMI,MAAM,GAM/D,GAJIpB,EAASG,QAAQ,EACjBe,CAAAA,EAAQA,EAAMC,IAAI,CAACnB,EAASG,QAAQ,CAAA,EAGpCe,EAAMJ,MAAM,CAAG,EAAG,CAClBI,EAAMG,QAAQ,CAACrB,EAASE,KAAK,EACzBH,GACAA,EAAGmB,GAEP,KACJ,CAEAL,GAAS,EACTR,EAAWA,EAASiB,KAAK,CAAC,EAAGT,EACjC,CACA,OAAO,IAAI,AACf,CACJ,EAAEU"} \ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.min.js b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.min.js index d986680fd7d..f8961b067de 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.min.js +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/activate-links.min.js @@ -1 +1 @@ -!function(e){e.fn.activateLinks=function(t,r){for(var n=e.extend({class:"active",selector:null,traverse:0},t),i=window.location.href.replace(window.location.protocol+"//"+window.location.host,"").split("/"),o=i.length,s=n.traverse<=0?o:o>=n.traverse?o-n.traverse:o;o>=s;){var a=i.join("/"),l=e(this).find('a[href="'+a+'"]').parent();if(n.selector&&(l=l.find(n.selector)),l.length>0)return l.addClass(n.class),r&&r(l),this;o-=1,i=i.slice(0,o)}return this}}(jQuery); +!function(e){e.fn.activateLinks=function(t,r){for(var n=e.extend({class:"active",selector:null,traverse:0},t),a=window.location.href.replace(window.location.protocol+"//"+window.location.host,"").split("/"),o=a.length,i=n.traverse<=0?o:o>=n.traverse?o-n.traverse:o;o>=i;){var s=a.join("/"),l=e(this).find('a[href="'+s+'"]').parent();if(n.selector&&(l=l.find(n.selector)),l.length>0){l.addClass(n.class),r&&r(l);break}o-=1,a=a.slice(0,o)}return this}}(jQuery); \ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.js b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.js index 6eaa7db0266..1ca41cfa808 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.js +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.js @@ -1,54 +1,45 @@ -/* -** NOTE: This file is generated by Gulp and should not be edited directly! -** Any changes made directly to this file will be overwritten next time its asset group is processed by Gulp. -*/ - function initMenuPermissionsPicker(element) { - // only run script if element exists - if (element) { - var elementId = element.id; - var selectedItems = JSON.parse(element.dataset.selectedItems || "[]"); - var allItems = JSON.parse(element.dataset.allItems || "[]"); - var vueMultiselect = Vue.component('vue-multiselect', window.VueMultiselect["default"]); - var vm = new Vue({ - el: '#' + elementId, - components: { - 'vue-multiselect': vueMultiselect - }, - data: { - value: null, - arrayOfItems: selectedItems, - options: allItems - }, - computed: { - selectedNames: function selectedNames() { - return this.arrayOfItems.map(function (x) { - return x.name; - }).join(','); - } - }, - methods: { - onSelect: function onSelect(selectedOption, name) { - var self = this; - for (i = 0; i < self.arrayOfItems.length; i++) { - if (self.arrayOfItems[i].name === selectedOption.name) { - return; + // only run script if element exists + if (element) { + var elementId = element.id; + var selectedItems = JSON.parse(element.dataset.selectedItems || "[]"); + var allItems = JSON.parse(element.dataset.allItems || "[]"); + + var vueMultiselect = Vue.component('vue-multiselect', window.VueMultiselect.default); + + var vm = new Vue({ + el: '#' + elementId, + components: { 'vue-multiselect': vueMultiselect }, + data: { + value: null, + arrayOfItems: selectedItems, + options: allItems, + }, + computed: { + selectedNames: function () { + return this.arrayOfItems.map(function (x) { return x.name }).join(','); + } + }, + methods: { + onSelect: function (selectedOption, name) { + var self = this; + + for (i = 0; i < self.arrayOfItems.length; i++) { + if (self.arrayOfItems[i].name === selectedOption.name) { + return; + } + } + + self.arrayOfItems.push(selectedOption); + }, + remove: function (item) { + this.arrayOfItems.splice(this.arrayOfItems.indexOf(item), 1) + } } - } - self.arrayOfItems.push(selectedOption); - }, - remove: function remove(item) { - this.arrayOfItems.splice(this.arrayOfItems.indexOf(item), 1); - } - } - }); + }) - /*Hook for other scripts that might want to have access to the view model*/ - var event = new CustomEvent("menu-permission-picker-created", { - detail: { - vm: vm - } - }); - document.querySelector("body").dispatchEvent(event); - } -} \ No newline at end of file + /*Hook for other scripts that might want to have access to the view model*/ + var event = new CustomEvent("menu-permission-picker-created", { detail: { vm: vm } }); + document.querySelector("body").dispatchEvent(event); + } +} diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.map b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.map new file mode 100644 index 00000000000..839de97cd39 --- /dev/null +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.map @@ -0,0 +1 @@ +{"version":3,"sources":[""],"sourcesContent":["function initMenuPermissionsPicker(element) {\r\n // only run script if element exists\r\n if (element) {\r\n var elementId = element.id;\r\n var selectedItems = JSON.parse(element.dataset.selectedItems || \"[]\");\r\n var allItems = JSON.parse(element.dataset.allItems || \"[]\");\r\n\r\n var vueMultiselect = Vue.component('vue-multiselect', window.VueMultiselect.default);\r\n\r\n var vm = new Vue({\r\n el: '#' + elementId,\r\n components: { 'vue-multiselect': vueMultiselect },\r\n data: {\r\n value: null,\r\n arrayOfItems: selectedItems,\r\n options: allItems,\r\n },\r\n computed: {\r\n selectedNames: function () {\r\n return this.arrayOfItems.map(function (x) { return x.name }).join(',');\r\n }\r\n },\r\n methods: {\r\n onSelect: function (selectedOption, name) {\r\n var self = this;\r\n\r\n for (i = 0; i < self.arrayOfItems.length; i++) {\r\n if (self.arrayOfItems[i].name === selectedOption.name) {\r\n return;\r\n }\r\n }\r\n\r\n self.arrayOfItems.push(selectedOption);\r\n },\r\n remove: function (item) {\r\n this.arrayOfItems.splice(this.arrayOfItems.indexOf(item), 1)\r\n }\r\n }\r\n })\r\n\r\n /*Hook for other scripts that might want to have access to the view model*/\r\n var event = new CustomEvent(\"menu-permission-picker-created\", { detail: { vm: vm } });\r\n document.querySelector(\"body\").dispatchEvent(event);\r\n }\r\n}\r\n"],"names":["initMenuPermissionsPicker","element","elementId","id","selectedItems","JSON","parse","dataset","allItems","vueMultiselect","Vue","component","window","VueMultiselect","default","event","CustomEvent","detail","vm","el","components","data","value","arrayOfItems","options","computed","selectedNames","map","x","name","join","methods","onSelect","selectedOption","i","self","length","push","remove","item","splice","indexOf","document","querySelector","dispatchEvent"],"mappings":"AAAA,SAASA,0BAA0BC,CAAO,EAEtC,GAAIA,EAAS,CACT,IAAIC,EAAYD,EAAQE,EAAE,CACtBC,EAAgBC,KAAKC,KAAK,CAACL,EAAQM,OAAO,CAACH,aAAa,EAAI,MAC5DI,EAAWH,KAAKC,KAAK,CAACL,EAAQM,OAAO,CAACC,QAAQ,EAAI,MAElDC,EAAiBC,IAAIC,SAAS,CAAC,kBAAmBC,OAAOC,cAAc,CAACC,OAAO,EAkC/EC,EAAQ,IAAIC,YAAY,iCAAkC,CAAEC,OAAQ,CAAEC,GAhCjE,IAAIR,IAAI,CACbS,GAAI,IAAMjB,EACVkB,WAAY,CAAE,kBAAmBX,CAAe,EAChDY,KAAM,CACFC,MAAO,KACPC,aAAcnB,EACdoB,QAAShB,CACb,EACAiB,SAAU,CACNC,cAAe,WACX,OAAO,IAAI,CAACH,YAAY,CAACI,GAAG,CAAC,SAAUC,CAAC,EAAI,OAAOA,EAAEC,IAAI,AAAC,GAAGC,IAAI,CAAC,IACtE,CACJ,EACAC,QAAS,CACLC,SAAU,SAAUC,CAAc,CAAEJ,CAAI,EAGpC,IAAKK,EAAI,EAAGA,EAAIC,AAFL,IAAI,CAEMZ,YAAY,CAACa,MAAM,CAAEF,IACtC,GAAIC,AAHG,IAAI,CAGFZ,YAAY,CAACW,EAAE,CAACL,IAAI,GAAKI,EAAeJ,IAAI,CACjD,OAIRM,AARW,IAAI,CAQVZ,YAAY,CAACc,IAAI,CAACJ,EAC3B,EACAK,OAAQ,SAAUC,CAAI,EAClB,IAAI,CAAChB,YAAY,CAACiB,MAAM,CAAC,IAAI,CAACjB,YAAY,CAACkB,OAAO,CAACF,GAAO,EAC9D,CACJ,CACJ,EAGiF,CAAE,GACnFG,SAASC,aAAa,CAAC,QAAQC,aAAa,CAAC7B,EACjD,CACJ"} \ No newline at end of file diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.min.js b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.min.js index 091fcc49fba..596a10d616a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.min.js +++ b/src/OrchardCore.Modules/OrchardCore.Menu/wwwroot/Scripts/menu-permission-picker.min.js @@ -1 +1 @@ -function initMenuPermissionsPicker(e){if(e){var t=e.id,n=JSON.parse(e.dataset.selectedItems||"[]"),a=JSON.parse(e.dataset.allItems||"[]"),s=Vue.component("vue-multiselect",window.VueMultiselect.default),r=new Vue({el:"#"+t,components:{"vue-multiselect":s},data:{value:null,arrayOfItems:n,options:a},computed:{selectedNames:function(){return this.arrayOfItems.map((function(e){return e.name})).join(",")}},methods:{onSelect:function(e,t){var n=this;for(i=0;i