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