| @@ -1,135 +1,435 @@ | ||
| 1 | -/* ========= INFORMATION ============================ | |
| 2 | - - author: Dmytro Lobov | |
| 3 | - - url: https://wow-estore.com | |
| 4 | - - email: givememoney1982@gmail.com | |
| 5 | -==================================================== */ | |
| 6 | - | |
| 7 | -'use strict'; | |
| 8 | - | |
| 9 | -jQuery(document).ready(function ($) { | |
| 10 | - //* Include colorpicker | |
| 11 | - | |
| 12 | - $('.wow-plugin .tab-nav li:first').addClass('select'); | |
| 13 | - $('.wow-plugin .tab-panels>div').hide().filter(':first').show(); | |
| 14 | - $('.wow-plugin .tab-nav a').click(function () { | |
| 15 | - $('.wow-plugin .tab-panels>div').hide().filter(this.hash).show(); | |
| 16 | - $('.wow-plugin .tab-nav li').removeClass('select'); | |
| 17 | - $(this).parent().addClass('select'); | |
| 18 | - return false; | |
| 19 | - }); | |
| 20 | - $('.wow-plugin input:checkbox:checked').each(function () { | |
| 21 | - let str = $(this).attr("id"); | |
| 22 | - let check = str.replace("wow_", ""); | |
| 23 | - $("input[name='param[" + check + "]']").val(1); | |
| 24 | - }); | |
| 25 | - | |
| 26 | - $('.wow-plugin input[type="checkbox"]').change(function () { | |
| 27 | - let str = $(this).attr("id"); | |
| 28 | - let check = str.replace("wow_", ""); | |
| 29 | - if ($(this).prop('checked')) { | |
| 30 | - $("input[name='param[" + check + "]']").val(1); | |
| 31 | - } else { | |
| 32 | - $("input[name='param[" + check + "]']").val(0); | |
| 33 | - } | |
| 34 | - }); | |
| 35 | - | |
| 36 | - $('.item-title').children('.faq-title').click(function () { | |
| 37 | - let par = $(this).closest('.items'); | |
| 38 | - $(par).children(".inside").toggle(500); | |
| 39 | - if ($(this).hasClass('togglehide')) { | |
| 40 | - $(this).removeClass('togglehide'); | |
| 41 | - $(this).addClass("toggleshow"); | |
| 42 | - $(this).attr('title', 'Show'); | |
| 43 | - } else { | |
| 44 | - $(this).removeClass('toggleshow'); | |
| 45 | - $(this).addClass("togglehide"); | |
| 46 | - $(this).attr('title', 'Hide'); | |
| 47 | - } | |
| 48 | - }); | |
| 49 | - | |
| 50 | - wow_attach_tooltips($(".wow-help")); | |
| 51 | - | |
| 52 | - $('[data-share]').on('click', function (event) { | |
| 53 | - event.preventDefault(); | |
| 54 | - let network = $(this).data('share'); | |
| 55 | - let url = $('#wp-url').val(); | |
| 56 | - let title = $('#wp-title').val(); | |
| 57 | - | |
| 58 | - let shareUrl; | |
| 59 | - | |
| 60 | - switch (network) { | |
| 61 | - case 'facebook': | |
| 62 | - shareUrl = 'https://www.facebook.com/sharer/sharer.php?u=' + url; | |
| 63 | - break; | |
| 64 | - case 'vk': | |
| 65 | - shareUrl = 'http://vk.com/share.php?url=' + url; | |
| 66 | - break; | |
| 67 | - case 'twitter': | |
| 68 | - shareUrl = 'https://twitter.com/share?url=' + url + '&text=' + title; | |
| 69 | - break; | |
| 70 | - case 'linkedin': | |
| 71 | - shareUrl = 'https://www.linkedin.com/shareArticle?url=' + url + '&title=' + title; | |
| 72 | - break; | |
| 73 | - case 'pinterest': | |
| 74 | - shareUrl = 'https://pinterest.com/pin/create/button/?url=' + url; | |
| 75 | - break; | |
| 76 | - case 'xing': | |
| 77 | - shareUrl = 'https://www.xing.com/spi/shares/new?url=' + url; | |
| 78 | - break; | |
| 79 | - case 'reddit': | |
| 80 | - shareUrl = 'http://www.reddit.com/submit?url=' + url + '&title=' + title; | |
| 81 | - break; | |
| 82 | - case 'blogger': | |
| 83 | - shareUrl = 'https://www.blogger.com/blog-this.g?u=' + url + '&n=' + title; | |
| 84 | - break; | |
| 85 | - case 'telegram': | |
| 86 | - shareUrl = 'https://telegram.me/share/url?url=' + url + '&text=' + title; | |
| 87 | - break; | |
| 88 | - | |
| 89 | - | |
| 90 | - default: | |
| 91 | - shareUrl = ''; | |
| 92 | - } | |
| 93 | - | |
| 94 | - let popupWidth = 550; | |
| 95 | - let popupHeight = 450; | |
| 96 | - let topPosition = (screen.height - popupHeight) / 2; | |
| 97 | - let leftPosition = (screen.width - popupWidth) / 2; | |
| 98 | - let popup = 'width=' + popupWidth + ', height=' + popupHeight + ', top=' + topPosition + ', left=' + leftPosition + | |
| 99 | - ', scrollbars=0, resizable=1, menubar=0, toolbar=0, status=0'; | |
| 100 | - | |
| 101 | - window.open(shareUrl, null, popup); | |
| 102 | - | |
| 103 | - }); | |
| 104 | - | |
| 105 | - $(document).on('click', '.wow-plugin-message .notice-dismiss', function() { | |
| 106 | - $.ajax({ | |
| 107 | - url: ajaxurl, data: { | |
| 108 | - action: 'wp_coder_message', | |
| 109 | - }, | |
| 110 | - }); | |
| 111 | - }); | |
| 112 | - | |
| 113 | -}); | |
| 114 | - | |
| 115 | - | |
| 116 | -function wow_attach_tooltips(selector) { | |
| 117 | - selector.tooltip({ | |
| 118 | - content: function () { | |
| 119 | - return jQuery(this).prop("title") | |
| 120 | - }, | |
| 121 | - tooltipClass: "wow-ui-tooltip", | |
| 122 | - position: { | |
| 123 | - my: "center top", | |
| 124 | - at: "center bottom+10", | |
| 125 | - collision: "flipfit" | |
| 126 | - }, | |
| 127 | - hide: { | |
| 128 | - duration: 200 | |
| 129 | - }, | |
| 130 | - show: { | |
| 131 | - duration: 200 | |
| 132 | - } | |
| 133 | - }) | |
| 134 | -} | |
| 135 | - | |
| 1 | +'use strict'; | |
| 2 | + | |
| 3 | +const settingTabs = function () { | |
| 4 | + const tabs = document.getElementById('settings-tab'); | |
| 5 | + if (!tabs) { | |
| 6 | + return false; | |
| 7 | + } | |
| 8 | + const tabsContent = document.querySelectorAll('#settings-content .tab-content'); | |
| 9 | + | |
| 10 | + const links = tabs.querySelectorAll('a'); | |
| 11 | + links.forEach((link) => { | |
| 12 | + link.addEventListener('click', function () { | |
| 13 | + const attr = link.getAttribute('data-tab'); | |
| 14 | + links.forEach(el => el.classList.remove('nav-tab-active')); | |
| 15 | + tabsContent.forEach(el => el.classList.remove('tab-content-active')); | |
| 16 | + link.classList.add('nav-tab-active'); | |
| 17 | + const tabContent = document.querySelector('[data-content=' + attr + ']'); | |
| 18 | + tabContent.classList.add('tab-content-active'); | |
| 19 | + setLocalStorage(attr); | |
| 20 | + }); | |
| 21 | + }); | |
| 22 | + | |
| 23 | + setTabs(); | |
| 24 | + | |
| 25 | + function setTabs() { | |
| 26 | + if (getLocalStorage() === '') { | |
| 27 | + return false; | |
| 28 | + } | |
| 29 | + const tab = getLocalStorage(); | |
| 30 | + links.forEach(el => el.classList.remove('nav-tab-active')); | |
| 31 | + tabsContent.forEach(el => el.classList.remove('tab-content-active')); | |
| 32 | + const link = tabs.querySelector('a[data-tab="' + tab + '"]'); | |
| 33 | + link.classList.add('nav-tab-active'); | |
| 34 | + const cont = document.querySelector('[data-content=' + tab + ']'); | |
| 35 | + cont.classList.add('tab-content-active'); | |
| 36 | + } | |
| 37 | + | |
| 38 | + function setLocalStorage(attr) { | |
| 39 | + sessionStorage.setItem("wowpTab", attr); | |
| 40 | + } | |
| 41 | + | |
| 42 | + function getLocalStorage() { | |
| 43 | + const tab = sessionStorage.getItem("wowpTab"); | |
| 44 | + if (!tab) { | |
| 45 | + return '' | |
| 46 | + } else { | |
| 47 | + return tab; | |
| 48 | + } | |
| 49 | + } | |
| 50 | +} | |
| 51 | + | |
| 52 | +const codeEditor = function () { | |
| 53 | + const editorSettings = wp.codeEditor.defaultSettings ? _.clone(wp.codeEditor.defaultSettings) : {}; | |
| 54 | + const codemirror_gen = | |
| 55 | + { | |
| 56 | + "indentUnit": 2, | |
| 57 | + "indentWithTabs": true, | |
| 58 | + "inputStyle": "contenteditable", | |
| 59 | + "lineNumbers": true, | |
| 60 | + "lineWrapping": true, | |
| 61 | + "styleActiveLine": true, | |
| 62 | + "continueComments": true, | |
| 63 | + "extraKeys": { | |
| 64 | + "Ctrl-Space": "autocomplete", | |
| 65 | + "Ctrl-\/": "toggleComment", | |
| 66 | + "Cmd-\/": "toggleComment", | |
| 67 | + "Alt-F": "findPersistent", | |
| 68 | + "Ctrl-F": "findPersistent", | |
| 69 | + "Cmd-F": "findPersistent" | |
| 70 | + }, | |
| 71 | + "direction": "ltr", | |
| 72 | + "gutters": ["CodeMirror-lint-markers"], | |
| 73 | + "lint": true, | |
| 74 | + "autoCloseBrackets": true, | |
| 75 | + "autoCloseTags": true, | |
| 76 | + "matchTags": { | |
| 77 | + "bothTags": true | |
| 78 | + }, | |
| 79 | + "tabSize": 2, | |
| 80 | + | |
| 81 | + }; | |
| 82 | + | |
| 83 | + const html_code = document.getElementById('html_code'); | |
| 84 | + if (html_code) { | |
| 85 | + let codemirror_el = | |
| 86 | + { | |
| 87 | + "tagname-lowercase": true, | |
| 88 | + "attr-lowercase": true, | |
| 89 | + "attr-value-double-quotes": false, | |
| 90 | + "doctype-first": false, | |
| 91 | + "tag-pair": true, | |
| 92 | + "spec-char-escape": true, | |
| 93 | + "id-unique": true, | |
| 94 | + "src-not-empty": true, | |
| 95 | + "attr-no-duplication": true, | |
| 96 | + "alt-require": true, | |
| 97 | + "space-tab-mixed-disabled": "tab", | |
| 98 | + "attr-unsafe-chars": true, | |
| 99 | + "mode": 'htmlmixed', | |
| 100 | + | |
| 101 | + }; | |
| 102 | + | |
| 103 | + editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen, codemirror_el,); | |
| 104 | + | |
| 105 | + const htmleditor = wp.codeEditor.initialize(html_code, editorSettings); | |
| 106 | + | |
| 107 | + const htmlNavigationMenu = document.getElementById("htmlNavigationMenu"); | |
| 108 | + | |
| 109 | + htmleditor.codemirror.eachLine(function (line) { | |
| 110 | + const text = line.text; | |
| 111 | + if (text.startsWith("<!-- NAV:")) { | |
| 112 | + let navItem = document.createElement("li"); | |
| 113 | + let navLink = document.createElement("a"); | |
| 114 | + navLink.href = "#"; | |
| 115 | + // navLink.innerText = text.replace("<!-- NAV:", "").trim(); | |
| 116 | + navLink.innerText = text.replace(/<!-- NAV:|-->|<!-- NAV: -->/g, '').trim(); | |
| 117 | + navLink.addEventListener("click", function (e) { | |
| 118 | + e.preventDefault(); | |
| 119 | + | |
| 120 | + // Remove existing highlights from the gutter | |
| 121 | + htmleditor.codemirror.eachLine(function (l) { | |
| 122 | + htmleditor.codemirror.removeLineClass(l, 'gutter', 'highlighted-gutter'); | |
| 123 | + }); | |
| 124 | + | |
| 125 | + // Set cursor and scroll to line | |
| 126 | + htmleditor.codemirror.setCursor(line.lineNo()); | |
| 127 | + let heightOfLine = htmleditor.codemirror.defaultTextHeight(); | |
| 128 | + let verticalPos = line.lineNo() * heightOfLine; | |
| 129 | + htmleditor.codemirror.scrollTo(null, verticalPos); | |
| 130 | + | |
| 131 | + // Highlight the line number in the gutter | |
| 132 | + htmleditor.codemirror.addLineClass(line.lineNo(), 'gutter', 'highlighted-gutter'); | |
| 133 | + | |
| 134 | + htmleditor.codemirror.focus(); | |
| 135 | + }); | |
| 136 | + navItem.appendChild(navLink); | |
| 137 | + htmlNavigationMenu.appendChild(navItem); | |
| 138 | + } | |
| 139 | + }); | |
| 140 | + } | |
| 141 | + | |
| 142 | + const css_code = document.getElementById('css_code'); | |
| 143 | + if (css_code) { | |
| 144 | + let codemirror_el = {"mode": 'css',}; | |
| 145 | + editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen, codemirror_el,); | |
| 146 | + // const tab = document.querySelector('[data-content="css-code"]'); | |
| 147 | + // tab.classList.add('tab-content-active'); | |
| 148 | + const csseditor = wp.codeEditor.initialize(css_code, editorSettings); | |
| 149 | + // tab.classList.remove('tab-content-active'); | |
| 150 | + | |
| 151 | + const cssNavigationMenu = document.getElementById("cssNavigationMenu"); | |
| 152 | + | |
| 153 | + csseditor.codemirror.eachLine(function (line) { | |
| 154 | + const text = line.text; | |
| 155 | + if (text.startsWith("/* NAV:")) { | |
| 156 | + let navItem = document.createElement("li"); | |
| 157 | + let navLink = document.createElement("a"); | |
| 158 | + navLink.href = "#"; | |
| 159 | + // navLink.innerText = text.replace("// NAV:", "").trim(); | |
| 160 | + navLink.innerText = text.replace(/\/\* NAV:|\*\/|\/\* NAV: \*\//g, '').trim(); | |
| 161 | + navLink.addEventListener("click", function (e) { | |
| 162 | + e.preventDefault(); | |
| 163 | + | |
| 164 | + // Remove existing highlights from the gutter | |
| 165 | + csseditor.codemirror.eachLine(function (l) { | |
| 166 | + csseditor.codemirror.removeLineClass(l, 'gutter', 'highlighted-gutter'); | |
| 167 | + }); | |
| 168 | + | |
| 169 | + // Set cursor and scroll to line | |
| 170 | + csseditor.codemirror.setCursor(line.lineNo()); | |
| 171 | + let heightOfLine = csseditor.codemirror.defaultTextHeight(); | |
| 172 | + let verticalPos = line.lineNo() * heightOfLine; | |
| 173 | + csseditor.codemirror.scrollTo(null, verticalPos); | |
| 174 | + | |
| 175 | + // Highlight the line number in the gutter | |
| 176 | + csseditor.codemirror.addLineClass(line.lineNo(), 'gutter', 'highlighted-gutter'); | |
| 177 | + | |
| 178 | + csseditor.codemirror.focus(); | |
| 179 | + }); | |
| 180 | + navItem.appendChild(navLink); | |
| 181 | + cssNavigationMenu.appendChild(navItem); | |
| 182 | + } | |
| 183 | + }); | |
| 184 | + } | |
| 185 | + | |
| 186 | + const js_code = document.getElementById('js_code'); | |
| 187 | + if (js_code) { | |
| 188 | + let codemirror_el = { | |
| 189 | + "boss": true, | |
| 190 | + "curly": true, | |
| 191 | + "eqeqeq": true, | |
| 192 | + "eqnull": true, | |
| 193 | + "es3": true, | |
| 194 | + "expr": true, | |
| 195 | + "immed": true, | |
| 196 | + "noarg": true, | |
| 197 | + "nonbsp": true, | |
| 198 | + "onevar": true, | |
| 199 | + "quotmark": "single", | |
| 200 | + "trailing": true, | |
| 201 | + "undef": true, | |
| 202 | + "unused": true, | |
| 203 | + "browser": true, | |
| 204 | + "globals": { | |
| 205 | + "_": false, | |
| 206 | + "Backbone": false, | |
| 207 | + "jQuery": true, | |
| 208 | + "JSON": false, | |
| 209 | + "wp": false | |
| 210 | + }, | |
| 211 | + "mode": 'javascript', | |
| 212 | + }; | |
| 213 | + editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen, codemirror_el,); | |
| 214 | + // const tab = document.querySelector('[data-content="js-code"]'); | |
| 215 | + // tab.classList.add('tab-content-active'); | |
| 216 | + const jseditor = wp.codeEditor.initialize(js_code, editorSettings); | |
| 217 | + // tab.classList.remove('tab-content-active'); | |
| 218 | + | |
| 219 | + const jsNavigationMenu = document.getElementById("jsNavigationMenu"); | |
| 220 | + | |
| 221 | + jseditor.codemirror.eachLine(function (line) { | |
| 222 | + const text = line.text; | |
| 223 | + if (text.startsWith("// NAV:")) { | |
| 224 | + let navItem = document.createElement("li"); | |
| 225 | + let navLink = document.createElement("a"); | |
| 226 | + navLink.href = "#"; | |
| 227 | + navLink.innerText = text.replace("// NAV:", "").trim(); | |
| 228 | + navLink.addEventListener("click", function (e) { | |
| 229 | + e.preventDefault(); | |
| 230 | + | |
| 231 | + // Remove existing highlights from the gutter | |
| 232 | + jseditor.codemirror.eachLine(function (l) { | |
| 233 | + jseditor.codemirror.removeLineClass(l, 'gutter', 'highlighted-gutter'); | |
| 234 | + }); | |
| 235 | + | |
| 236 | + // Set cursor and scroll to line | |
| 237 | + jseditor.codemirror.setCursor(line.lineNo()); | |
| 238 | + let heightOfLine = jseditor.codemirror.defaultTextHeight(); | |
| 239 | + let verticalPos = line.lineNo() * heightOfLine; | |
| 240 | + jseditor.codemirror.scrollTo(null, verticalPos); | |
| 241 | + | |
| 242 | + // Highlight the line number in the gutter | |
| 243 | + jseditor.codemirror.addLineClass(line.lineNo(), 'gutter', 'highlighted-gutter'); | |
| 244 | + | |
| 245 | + jseditor.codemirror.focus(); | |
| 246 | + }); | |
| 247 | + navItem.appendChild(navLink); | |
| 248 | + jsNavigationMenu.appendChild(navItem); | |
| 249 | + } | |
| 250 | + }); | |
| 251 | + } | |
| 252 | + | |
| 253 | + const php_code = document.getElementById('php_code'); | |
| 254 | + if (php_code) { | |
| 255 | + let codemirror_el = { | |
| 256 | + mode: { | |
| 257 | + name: 'php', | |
| 258 | + startOpen: true | |
| 259 | + } | |
| 260 | + }; | |
| 261 | + editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen, codemirror_el,); | |
| 262 | + // const tab = document.querySelector('[data-content="php-code"]'); | |
| 263 | + // tab.classList.add('tab-content-active'); | |
| 264 | + const phpeditor = wp.codeEditor.initialize(php_code, editorSettings); | |
| 265 | + // tab.classList.remove('tab-content-active'); | |
| 266 | + | |
| 267 | + const phpNavigationMenu = document.getElementById("phpNavigationMenu"); | |
| 268 | + | |
| 269 | + phpeditor.codemirror.eachLine(function (line) { | |
| 270 | + const text = line.text; | |
| 271 | + if (text.startsWith("// NAV:")) { | |
| 272 | + let navItem = document.createElement("li"); | |
| 273 | + let navLink = document.createElement("a"); | |
| 274 | + navLink.href = "#"; | |
| 275 | + navLink.innerText = text.replace("// NAV:", "").trim(); | |
| 276 | + navLink.addEventListener("click", function (e) { | |
| 277 | + e.preventDefault(); | |
| 278 | + | |
| 279 | + // Remove existing highlights from the gutter | |
| 280 | + phpeditor.codemirror.eachLine(function (l) { | |
| 281 | + phpeditor.codemirror.removeLineClass(l, 'gutter', 'highlighted-gutter'); | |
| 282 | + }); | |
| 283 | + | |
| 284 | + // Set cursor and scroll to line | |
| 285 | + phpeditor.codemirror.setCursor(line.lineNo()); | |
| 286 | + let heightOfLine = phpeditor.codemirror.defaultTextHeight(); | |
| 287 | + let verticalPos = line.lineNo() * heightOfLine; | |
| 288 | + phpeditor.codemirror.scrollTo(null, verticalPos); | |
| 289 | + | |
| 290 | + // Highlight the line number in the gutter | |
| 291 | + phpeditor.codemirror.addLineClass(line.lineNo(), 'gutter', 'highlighted-gutter'); | |
| 292 | + | |
| 293 | + phpeditor.codemirror.focus(); | |
| 294 | + }); | |
| 295 | + navItem.appendChild(navLink); | |
| 296 | + phpNavigationMenu.appendChild(navItem); | |
| 297 | + } | |
| 298 | + }); | |
| 299 | + } | |
| 300 | + | |
| 301 | + const global_php = document.getElementById('wpcoder-global-php'); | |
| 302 | + if (global_php) { | |
| 303 | + let codemirror_el = { | |
| 304 | + mode: { | |
| 305 | + name: 'php', | |
| 306 | + startOpen: true, | |
| 307 | + | |
| 308 | + }, | |
| 309 | + firstLineNumber: 4, | |
| 310 | + }; | |
| 311 | + editorSettings.codemirror = _.extend({}, editorSettings.codemirror, codemirror_gen, codemirror_el,); | |
| 312 | + const editor = wp.codeEditor.initialize(global_php, editorSettings); | |
| 313 | + | |
| 314 | + const navigationMenu = document.getElementById("phpNavigationMenu"); | |
| 315 | + | |
| 316 | + editor.codemirror.eachLine(function (line) { | |
| 317 | + const text = line.text; | |
| 318 | + if (text.startsWith("// NAV:")) { | |
| 319 | + let navItem = document.createElement("li"); | |
| 320 | + let navLink = document.createElement("a"); | |
| 321 | + navLink.href = "#"; | |
| 322 | + navLink.innerText = text.replace("// NAV:", "").trim(); | |
| 323 | + navLink.addEventListener("click", function (e) { | |
| 324 | + e.preventDefault(); | |
| 325 | + | |
| 326 | + // Remove existing highlights from the gutter | |
| 327 | + editor.codemirror.eachLine(function (l) { | |
| 328 | + editor.codemirror.removeLineClass(l, 'gutter', 'highlighted-gutter'); | |
| 329 | + }); | |
| 330 | + | |
| 331 | + // Set cursor and scroll to line | |
| 332 | + editor.codemirror.setCursor(line.lineNo()); | |
| 333 | + let heightOfLine = editor.codemirror.defaultTextHeight(); | |
| 334 | + let verticalPos = line.lineNo() * heightOfLine; | |
| 335 | + editor.codemirror.scrollTo(null, verticalPos); | |
| 336 | + | |
| 337 | + // Highlight the line number in the gutter | |
| 338 | + editor.codemirror.addLineClass(line.lineNo(), 'gutter', 'highlighted-gutter'); | |
| 339 | + | |
| 340 | + editor.codemirror.focus(); | |
| 341 | + }); | |
| 342 | + navItem.appendChild(navLink); | |
| 343 | + navigationMenu.appendChild(navItem); | |
| 344 | + } | |
| 345 | + }); | |
| 346 | + | |
| 347 | + | |
| 348 | + } | |
| 349 | + | |
| 350 | +} | |
| 351 | + | |
| 352 | + | |
| 353 | +const changeTemplate = function () { | |
| 354 | + | |
| 355 | + const template = document.getElementById('template'); | |
| 356 | + if (!template) { | |
| 357 | + return false; | |
| 358 | + } | |
| 359 | + | |
| 360 | + | |
| 361 | + template.addEventListener('change', function (event) { | |
| 362 | + | |
| 363 | + const parent = document.getElementById('wpcoder-template'); | |
| 364 | + let type = template.value; | |
| 365 | + type = default_custom_post(type); | |
| 366 | + const elements = parent.querySelectorAll('.wowp-field'); | |
| 367 | + | |
| 368 | + switch (type) { | |
| 369 | + case 'post_all': | |
| 370 | + case 'page_all': | |
| 371 | + elements[1].classList.add('is-hidden'); | |
| 372 | + elements[2].classList.add('is-hidden'); | |
| 373 | + elements[3].classList.add('is-hidden'); | |
| 374 | + break; | |
| 375 | + case 'post_selected': | |
| 376 | + case 'post_in_category': | |
| 377 | + case 'page_selected': | |
| 378 | + case 'archive_category': | |
| 379 | + case 'archive_tag': | |
| 380 | + elements[1].classList.remove('is-hidden'); | |
| 381 | + elements[2].classList.remove('is-hidden'); | |
| 382 | + elements[3].classList.add('is-hidden'); | |
| 383 | + break; | |
| 384 | + case 'page_type': | |
| 385 | + elements[1].classList.remove('is-hidden'); | |
| 386 | + elements[2].classList.add('is-hidden'); | |
| 387 | + elements[3].classList.remove('is-hidden'); | |
| 388 | + break; | |
| 389 | + default: | |
| 390 | + elements[1].classList.add('is-hidden'); | |
| 391 | + elements[2].classList.add('is-hidden'); | |
| 392 | + elements[3].classList.add('is-hidden'); | |
| 393 | + break; | |
| 394 | + | |
| 395 | + } | |
| 396 | + | |
| 397 | + }); | |
| 398 | + | |
| 399 | + function default_custom_post(el) { | |
| 400 | + if (el.includes('custom_post_selected')) { | |
| 401 | + return 'post_selected'; | |
| 402 | + } | |
| 403 | + if (el.includes('custom_post_tax')) { | |
| 404 | + return 'post_category'; | |
| 405 | + } | |
| 406 | + if (el.includes('custom_post_all')) { | |
| 407 | + return 'post_all'; | |
| 408 | + } | |
| 409 | + return el; | |
| 410 | + } | |
| 411 | + | |
| 412 | +} | |
| 413 | + | |
| 414 | + | |
| 415 | +const feature = function () { | |
| 416 | + const texts = document.querySelectorAll('.w_card-description'); | |
| 417 | + | |
| 418 | + if (!texts) { | |
| 419 | + return false; | |
| 420 | + } | |
| 421 | + texts.forEach((el) => { | |
| 422 | + el.addEventListener('click', () => { | |
| 423 | + el.classList.toggle('is-open'); | |
| 424 | + }) | |
| 425 | + }) | |
| 426 | + | |
| 427 | +} | |
| 428 | + | |
| 429 | +document.addEventListener('DOMContentLoaded', function () { | |
| 430 | + | |
| 431 | + new codeEditor; | |
| 432 | + new settingTabs; | |
| 433 | + new changeTemplate; | |
| 434 | + new feature; | |
| 435 | +}) | |