| @@ -1,138 +1,152 @@ | ||
| 1 | 1 | (function () { var require = undefined; var module = undefined; var exports = undefined; var define = undefined; (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
| 2 | +'use strict'; | |
| 3 | + | |
| 2 | 4 | window.Boxzilla_Admin = require('./admin/_admin.js'); |
| 5 | + | |
| 3 | 6 | },{"./admin/_admin.js":2}],2:[function(require,module,exports){ |
| 4 | 7 | 'use strict'; |
| 5 | 8 | |
| 6 | -var $ = window.jQuery; | |
| 7 | -var Option = require('./_option.js'); | |
| 8 | -var optionControls = document.getElementById('boxzilla-box-options-controls'); | |
| 9 | -var $optionControls = $(optionControls); | |
| 9 | +(function () { | |
| 10 | + 'use strict'; | |
| 10 | 11 | |
| 11 | -// sanity check, are we on the correct page? | |
| 12 | -if( $optionControls.length === 0 ) { | |
| 13 | - return; | |
| 14 | -} | |
| 12 | + var $ = window.jQuery; | |
| 13 | + var Option = require('./_option.js'); | |
| 14 | + var optionControls = document.getElementById('boxzilla-box-options-controls'); | |
| 15 | + var $optionControls = $(optionControls); | |
| 15 | 16 | |
| 16 | -var EventEmitter = require('wolfy87-eventemitter'); | |
| 17 | -var events = new EventEmitter(); | |
| 18 | -var Designer = require('./_designer.js')($, Option, events); | |
| 19 | -var rowTemplate = wp.template('rule-row-template'); | |
| 20 | -var i18n = boxzilla_i18n; | |
| 17 | + // sanity check, are we on the correct page? | |
| 18 | + if ($optionControls.length === 0) { | |
| 19 | + return; | |
| 20 | + } | |
| 21 | 21 | |
| 22 | -// events | |
| 23 | -$optionControls.on('click', ".boxzilla-add-rule", addRuleFields); | |
| 24 | -$optionControls.on('click', ".boxzilla-remove-rule", removeRule); | |
| 25 | -$optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers); | |
| 26 | -$optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions ); | |
| 22 | + var EventEmitter = require('wolfy87-eventemitter'); | |
| 23 | + var events = new EventEmitter(); | |
| 24 | + var Designer = require('./_designer.js')($, Option, events); | |
| 25 | + var rowTemplate = wp.template('rule-row-template'); | |
| 26 | + var i18n = boxzilla_i18n; | |
| 27 | 27 | |
| 28 | -$(window).load(function() { | |
| 29 | - if( typeof(window.tinyMCE) === "undefined" ) { | |
| 30 | - document.getElementById('notice-notinymce').style.display = ''; | |
| 28 | + // events | |
| 29 | + $optionControls.on('click', ".boxzilla-add-rule", addRuleFields); | |
| 30 | + $optionControls.on('click', ".boxzilla-remove-rule", removeRule); | |
| 31 | + $optionControls.on('change', ".boxzilla-rule-condition", setContextualHelpers); | |
| 32 | + $optionControls.find('.boxzilla-auto-show-trigger').on('change', toggleTriggerOptions); | |
| 33 | + | |
| 34 | + $(window).load(function () { | |
| 35 | + if (typeof window.tinyMCE === "undefined") { | |
| 36 | + document.getElementById('notice-notinymce').style.display = ''; | |
| 37 | + } | |
| 38 | + }); | |
| 39 | + | |
| 40 | + // call contextual helper method for each row | |
| 41 | + $('.boxzilla-rule-row').each(setContextualHelpers); | |
| 42 | + | |
| 43 | + function toggleTriggerOptions() { | |
| 44 | + $optionControls.find('.boxzilla-trigger-options').toggle(this.value !== ''); | |
| 31 | 45 | } |
| 32 | -}); | |
| 33 | 46 | |
| 34 | -// call contextual helper method for each row | |
| 35 | -$('.boxzilla-rule-row').each(setContextualHelpers); | |
| 47 | + function removeRule() { | |
| 48 | + $(this).parents('tr').remove(); | |
| 49 | + } | |
| 36 | 50 | |
| 37 | -function toggleTriggerOptions() { | |
| 38 | - $optionControls.find('.boxzilla-trigger-options').toggle( this.value !== '' ); | |
| 39 | -} | |
| 51 | + function setContextualHelpers() { | |
| 40 | 52 | |
| 41 | -function removeRule() { | |
| 42 | - $(this).parents('tr').remove(); | |
| 43 | -} | |
| 53 | + var context = this.tagName.toLowerCase() === "tr" ? this : $(this).parents('tr').get(0); | |
| 54 | + var condition = context.querySelector('.boxzilla-rule-condition').value; | |
| 55 | + var valueInput = context.querySelector('.boxzilla-rule-value'); | |
| 56 | + var qualifierInput = context.querySelector('.boxzilla-rule-qualifier'); | |
| 57 | + var betterInput = valueInput.cloneNode(true); | |
| 58 | + var $betterInput = $(betterInput); | |
| 44 | 59 | |
| 45 | -function setContextualHelpers() { | |
| 60 | + // remove previously added helpers | |
| 61 | + $(context.querySelectorAll('.boxzilla-helper')).remove(); | |
| 46 | 62 | |
| 47 | - var context = ( this.tagName.toLowerCase() === "tr" ) ? this : $(this).parents('tr').get(0); | |
| 48 | - var condition = context.querySelector('.boxzilla-rule-condition').value; | |
| 49 | - var valueInput = context.querySelector('.boxzilla-rule-value'); | |
| 50 | - var qualifierInput = context.querySelector('.boxzilla-rule-qualifier'); | |
| 51 | - var betterInput = valueInput.cloneNode(true); | |
| 52 | - var $betterInput = $(betterInput); | |
| 63 | + // prepare better input | |
| 64 | + betterInput.removeAttribute('name'); | |
| 65 | + betterInput.className = betterInput.className + ' boxzilla-helper'; | |
| 66 | + valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling); | |
| 67 | + $betterInput.change(function () { | |
| 68 | + valueInput.value = this.value; | |
| 69 | + }); | |
| 53 | 70 | |
| 54 | - // remove previously added helpers | |
| 55 | - $(context.querySelectorAll('.boxzilla-helper')).remove(); | |
| 71 | + betterInput.style.display = ''; | |
| 72 | + valueInput.style.display = 'none'; | |
| 73 | + qualifierInput.style.display = ''; | |
| 56 | 74 | |
| 57 | - // prepare better input | |
| 58 | - betterInput.removeAttribute('name'); | |
| 59 | - betterInput.className = betterInput.className + ' boxzilla-helper'; | |
| 60 | - valueInput.parentNode.insertBefore(betterInput, valueInput.nextSibling); | |
| 61 | - $betterInput.change(function() { valueInput.value = this.value; }); | |
| 75 | + // change placeholder for textual help | |
| 76 | + switch (condition) { | |
| 77 | + default: | |
| 78 | + betterInput.placeholder = i18n.enterCommaSeparatedValues; | |
| 79 | + break; | |
| 62 | 80 | |
| 63 | - betterInput.style.display = ''; | |
| 64 | - valueInput.style.display = 'none'; | |
| 65 | - qualifierInput.style.display = ''; | |
| 81 | + case '': | |
| 82 | + case 'everywhere': | |
| 83 | + qualifierInput.value = '1'; | |
| 84 | + valueInput.value = ''; | |
| 85 | + betterInput.style.display = 'none'; | |
| 86 | + qualifierInput.style.display = 'none'; | |
| 87 | + break; | |
| 66 | 88 | |
| 67 | - // change placeholder for textual help | |
| 68 | - switch(condition) { | |
| 69 | - default: | |
| 70 | - betterInput.placeholder = i18n.enterCommaSeparatedValues; | |
| 71 | - break; | |
| 89 | + case 'is_single': | |
| 90 | + case 'is_post': | |
| 91 | + betterInput.placeholder = i18n.enterCommaSeparatedPosts; | |
| 92 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", { multiple: true, multipleSep: "," }); | |
| 93 | + break; | |
| 72 | 94 | |
| 73 | - case '': | |
| 74 | - case 'everywhere': | |
| 75 | - qualifierInput.value = '1'; | |
| 76 | - valueInput.value = ''; | |
| 77 | - betterInput.style.display = 'none'; | |
| 78 | - qualifierInput.style.display = 'none'; | |
| 79 | - break; | |
| 95 | + case 'is_page': | |
| 96 | + betterInput.placeholder = i18n.enterCommaSeparatedPages; | |
| 97 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", { multiple: true, multipleSep: "," }); | |
| 98 | + break; | |
| 80 | 99 | |
| 81 | - case 'is_single': | |
| 82 | - case 'is_post': | |
| 83 | - betterInput.placeholder = i18n.enterCommaSeparatedPosts; | |
| 84 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post", {multiple:true, multipleSep: ","}); | |
| 85 | - break; | |
| 100 | + case 'is_post_type': | |
| 101 | + betterInput.placeholder = i18n.enterCommaSeparatedPostTypes; | |
| 102 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", { multiple: true, multipleSep: "," }); | |
| 103 | + break; | |
| 86 | 104 | |
| 87 | - case 'is_page': | |
| 88 | - betterInput.placeholder = i18n.enterCommaSeparatedPages; | |
| 89 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=page", {multiple:true, multipleSep: ","}); | |
| 90 | - break; | |
| 105 | + case 'is_url': | |
| 106 | + betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls; | |
| 107 | + break; | |
| 91 | 108 | |
| 92 | - case 'is_post_type': | |
| 93 | - betterInput.placeholder = i18n.enterCommaSeparatedPostTypes; | |
| 94 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_type", {multiple:true, multipleSep: ","}); | |
| 95 | - break; | |
| 109 | + case 'is_post_in_category': | |
| 110 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", { multiple: true, multipleSep: "," }); | |
| 111 | + break; | |
| 96 | 112 | |
| 97 | - case 'is_url': | |
| 98 | - betterInput.placeholder = i18n.enterCommaSeparatedRelativeUrls; | |
| 99 | - break; | |
| 113 | + case 'is_post_with_tag': | |
| 114 | + $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", { multiple: true, multipleSep: "," }); | |
| 115 | + break; | |
| 116 | + } | |
| 117 | + } | |
| 100 | 118 | |
| 101 | - case 'is_post_in_category': | |
| 102 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=category", {multiple:true, multipleSep: ","}); | |
| 103 | - break; | |
| 104 | - | |
| 105 | - case 'is_post_with_tag': | |
| 106 | - $betterInput.suggest(ajaxurl + "?action=boxzilla_autocomplete&type=post_tag", {multiple:true, multipleSep: ","}); | |
| 107 | - break; | |
| 119 | + function addRuleFields() { | |
| 120 | + var data = { | |
| 121 | + 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length | |
| 122 | + }; | |
| 123 | + var html = rowTemplate(data); | |
| 124 | + $(document.getElementById('boxzilla-box-rules')).after(html); | |
| 125 | + return false; | |
| 108 | 126 | } |
| 109 | -} | |
| 110 | 127 | |
| 111 | -function addRuleFields() { | |
| 112 | - var data = { | |
| 113 | - 'key': optionControls.querySelectorAll('.boxzilla-rule-row').length | |
| 128 | + module.exports = { | |
| 129 | + 'Designer': Designer, | |
| 130 | + 'Option': Option, | |
| 131 | + 'events': events | |
| 114 | 132 | }; |
| 115 | - var html = rowTemplate(data); | |
| 116 | - $(document.getElementById('boxzilla-box-rules')).after(html); | |
| 117 | - return false; | |
| 118 | -} | |
| 133 | +})(); | |
| 119 | 134 | |
| 120 | -module.exports = { | |
| 121 | - 'Designer': Designer, | |
| 122 | - 'Option': Option, | |
| 123 | - 'events': events | |
| 124 | -}; | |
| 135 | +},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){ | |
| 136 | +'use strict'; | |
| 125 | 137 | |
| 126 | -},{"./_designer.js":3,"./_option.js":4,"wolfy87-eventemitter":5}],3:[function(require,module,exports){ | |
| 127 | -var Designer = function($, Option, events) { | |
| 138 | +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | |
| 128 | 139 | |
| 140 | +var Designer = function Designer($, Option, events) { | |
| 141 | + | |
| 129 | 142 | // vars |
| 130 | 143 | var boxId = document.getElementById('post_ID').value || 0, |
| 131 | - $editor, $editorFrame, | |
| 132 | - $innerEditor, | |
| 133 | - options = {}, | |
| 134 | - visualEditorInitialised = false; | |
| 144 | + $editor, | |
| 145 | + $editorFrame, | |
| 146 | + $innerEditor, | |
| 147 | + options = {}, | |
| 148 | + visualEditorInitialised = false; | |
| 135 | 149 | |
| 136 | 150 | var $appearanceControls = $("#boxzilla-box-appearance-controls"); |
| 137 | 151 | |
| 138 | 152 | // create Option objects |
| @@ -146,9 +160,9 @@ | ||
| 146 | 160 | // functions |
| 147 | 161 | function init() { |
| 148 | 162 | |
| 149 | 163 | // Only run if TinyMCE has actually inited |
| 150 | - if( typeof( window.tinyMCE ) !== "object" || tinyMCE.get('content') === null ) { | |
| 164 | + if (_typeof(window.tinyMCE) !== "object" || tinyMCE.get('content') === null) { | |
| 151 | 165 | return; |
| 152 | 166 | } |
| 153 | 167 | |
| 154 | 168 | // add classes to TinyMCE <html> |
| @@ -177,15 +191,15 @@ | ||
| 177 | 191 | events.trigger('editor.init'); |
| 178 | 192 | } |
| 179 | 193 | |
| 180 | 194 | /** |
| 181 | - * Applies the styles from the options to the TinyMCE Editor | |
| 182 | - * | |
| 183 | - * @return bool | |
| 184 | - */ | |
| 195 | + * Applies the styles from the options to the TinyMCE Editor | |
| 196 | + * | |
| 197 | + * @return bool | |
| 198 | + */ | |
| 185 | 199 | function applyStyles() { |
| 186 | 200 | |
| 187 | - if( ! visualEditorInitialised ) { | |
| 201 | + if (!visualEditorInitialised) { | |
| 188 | 202 | return false; |
| 189 | 203 | } |
| 190 | 204 | |
| 191 | 205 | // apply styles from CSS editor |
| @@ -204,10 +218,10 @@ | ||
| 204 | 218 | return true; |
| 205 | 219 | } |
| 206 | 220 | |
| 207 | 221 | function resetStyles() { |
| 208 | - for( var key in options ) { | |
| 209 | - if( key.substring(0,5) === 'theme' ) { | |
| 222 | + for (var key in options) { | |
| 223 | + if (key.substring(0, 5) === 'theme') { | |
| 210 | 224 | continue; |
| 211 | 225 | } |
| 212 | 226 | |
| 213 | 227 | options[key].clear(); |
| @@ -228,25 +242,25 @@ | ||
| 228 | 242 | 'init': init, |
| 229 | 243 | 'resetStyles': resetStyles, |
| 230 | 244 | 'options': options |
| 231 | 245 | }; |
| 232 | - | |
| 233 | 246 | }; |
| 234 | 247 | |
| 235 | 248 | module.exports = Designer; |
| 249 | + | |
| 236 | 250 | },{}],4:[function(require,module,exports){ |
| 237 | 251 | 'use strict'; |
| 238 | 252 | |
| 239 | 253 | var $ = window.jQuery; |
| 240 | 254 | |
| 241 | -var Option = function( element ) { | |
| 255 | +var Option = function Option(element) { | |
| 242 | 256 | |
| 243 | 257 | // find corresponding element |
| 244 | - if( typeof(element) == "string" ) { | |
| 258 | + if (typeof element == "string") { | |
| 245 | 259 | element = document.getElementById('boxzilla-' + element); |
| 246 | 260 | } |
| 247 | 261 | |
| 248 | - if( ! element ) { | |
| 262 | + if (!element) { | |
| 249 | 263 | console.error("Unable to find option element."); |
| 250 | 264 | } |
| 251 | 265 | |
| 252 | 266 | this.element = element; |
| @@ -251,11 +265,11 @@ | ||
| 251 | 265 | |
| 252 | 266 | this.element = element; |
| 253 | 267 | }; |
| 254 | 268 | |
| 255 | -Option.prototype.getColorValue = function() { | |
| 256 | - if( this.element.value.length > 0 ) { | |
| 257 | - if( $(this.element).hasClass('wp-color-field')) { | |
| 269 | +Option.prototype.getColorValue = function () { | |
| 270 | + if (this.element.value.length > 0) { | |
| 271 | + if ($(this.element).hasClass('wp-color-field')) { | |
| 258 | 272 | return $(this.element).wpColorPicker('color'); |
| 259 | 273 | } else { |
| 260 | 274 | return this.element.value; |
| 261 | 275 | } |
| @@ -263,19 +277,19 @@ | ||
| 263 | 277 | |
| 264 | 278 | return ''; |
| 265 | 279 | }; |
| 266 | 280 | |
| 267 | -Option.prototype.getPxValue = function( fallbackValue ) { | |
| 268 | - if( this.element.value.length > 0 ) { | |
| 269 | - return parseInt( this.element.value ) + "px"; | |
| 281 | +Option.prototype.getPxValue = function (fallbackValue) { | |
| 282 | + if (this.element.value.length > 0) { | |
| 283 | + return parseInt(this.element.value) + "px"; | |
| 270 | 284 | } |
| 271 | 285 | |
| 272 | 286 | return fallbackValue || ''; |
| 273 | 287 | }; |
| 274 | 288 | |
| 275 | -Option.prototype.getValue = function( fallbackValue ) { | |
| 289 | +Option.prototype.getValue = function (fallbackValue) { | |
| 276 | 290 | |
| 277 | - if( this.element.value.length > 0 ) { | |
| 291 | + if (this.element.value.length > 0) { | |
| 278 | 292 | return this.element.value; |
| 279 | 293 | } |
| 280 | 294 | |
| 281 | 295 | return fallbackValue || ''; |
| @@ -280,17 +294,18 @@ | ||
| 280 | 294 | |
| 281 | 295 | return fallbackValue || ''; |
| 282 | 296 | }; |
| 283 | 297 | |
| 284 | -Option.prototype.clear = function() { | |
| 298 | +Option.prototype.clear = function () { | |
| 285 | 299 | this.element.value = ''; |
| 286 | 300 | }; |
| 287 | 301 | |
| 288 | -Option.prototype.setValue = function(value) { | |
| 302 | +Option.prototype.setValue = function (value) { | |
| 289 | 303 | this.element.value = value; |
| 290 | 304 | }; |
| 291 | 305 | |
| 292 | 306 | module.exports = Option; |
| 307 | + | |
| 293 | 308 | },{}],5:[function(require,module,exports){ |
| 294 | 309 | /*! |
| 295 | 310 | * EventEmitter v4.2.11 - git.io/ee |
| 296 | 311 | * Unlicense - http://unlicense.org/ |