| 1 |
/* global redux, confirm, relid:true, jsonView */ |
| 2 |
|
| 3 |
(function( $ ) { |
| 4 |
'use strict'; |
| 5 |
|
| 6 |
$.redux = $.redux || {}; |
| 7 |
|
| 8 |
$( document ).ready( |
| 9 |
function() { |
| 10 |
$.fn.isOnScreen = function() { |
| 11 |
if ( !window ) { |
| 12 |
return; |
| 13 |
} |
| 14 |
|
| 15 |
var win = $( window ); |
| 16 |
var viewport = { |
| 17 |
top: win.scrollTop(), |
| 18 |
}; |
| 19 |
|
| 20 |
viewport.right = viewport.left + win.width(); |
| 21 |
viewport.bottom = viewport.top + win.height(); |
| 22 |
|
| 23 |
var bounds = this.offset(); |
| 24 |
|
| 25 |
bounds.right = bounds.left + this.outerWidth(); |
| 26 |
bounds.bottom = bounds.top + this.outerHeight(); |
| 27 |
|
| 28 |
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)); |
| 29 |
}; |
| 30 |
|
| 31 |
$.redux.hideFields(); |
| 32 |
$.redux.checkRequired(); |
| 33 |
$.redux.initEvents(); |
| 34 |
$.redux.initQtip(); |
| 35 |
$.redux.tabCheck(); |
| 36 |
$.redux.notices(); |
| 37 |
$.redux.tabControl(); |
| 38 |
} |
| 39 |
); |
| 40 |
|
| 41 |
$.redux.ajax_save = function( button ) { |
| 42 |
|
| 43 |
var overlay = $( document.getElementById( 'redux_ajax_overlay' ) ); |
| 44 |
overlay.fadeIn(); |
| 45 |
|
| 46 |
// Add the loading mechanism |
| 47 |
jQuery( '.redux-action_bar .spinner' ).addClass( 'is-active' ); |
| 48 |
|
| 49 |
jQuery( '.redux-action_bar input' ).attr( 'disabled', 'disabled' ); |
| 50 |
var $notification_bar = jQuery( document.getElementById( 'redux_notification_bar' ) ); |
| 51 |
$notification_bar.slideUp(); |
| 52 |
jQuery( '.redux-save-warn' ).slideUp(); |
| 53 |
jQuery( '.redux_ajax_save_error' ).slideUp( |
| 54 |
'medium', function() { |
| 55 |
jQuery( this ).remove(); |
| 56 |
} |
| 57 |
); |
| 58 |
|
| 59 |
var $parent = jQuery( document.getElementById( "redux-form-wrapper" ) ); |
| 60 |
|
| 61 |
// Editor field doesn't auto save. Have to call it. Boo. |
| 62 |
if ( redux.fields.hasOwnProperty( "editor" ) ) { |
| 63 |
$.each( |
| 64 |
redux.fields.editor, function( $key, $index ) { |
| 65 |
if ( typeof(tinyMCE) !== 'undefined' ) { |
| 66 |
var editor = tinyMCE.get( $key ); |
| 67 |
if ( editor ) { |
| 68 |
editor.save(); |
| 69 |
} |
| 70 |
} |
| 71 |
} |
| 72 |
); |
| 73 |
} |
| 74 |
|
| 75 |
var $data = $parent.serialize(); |
| 76 |
// add values for checked and unchecked checkboxes fields |
| 77 |
$parent.find( 'input[type=checkbox]' ).each( |
| 78 |
function() { |
| 79 |
if ( typeof $( this ).attr( 'name' ) !== "undefined" ) { |
| 80 |
var chkVal = $( this ).is( ':checked' ) ? $( this ).val() : "0"; |
| 81 |
$data += "&" + $( this ).attr( 'name' ) + "=" + chkVal; |
| 82 |
} |
| 83 |
} |
| 84 |
); |
| 85 |
|
| 86 |
|
| 87 |
if ( button.attr( 'name' ) != "redux_save" ) { |
| 88 |
$data += "&" + button.attr( 'name' ) + "=" + button.val(); |
| 89 |
} |
| 90 |
|
| 91 |
var $nonce = $parent.attr( "data-nonce" ); |
| 92 |
|
| 93 |
jQuery.ajax( |
| 94 |
{ |
| 95 |
type: "post", |
| 96 |
dataType: "json", |
| 97 |
url: ajaxurl, |
| 98 |
data: { |
| 99 |
action: redux.args.opt_name + "_ajax_save", |
| 100 |
nonce: $nonce, |
| 101 |
'opt_name': redux.args.opt_name, |
| 102 |
data: $data |
| 103 |
}, |
| 104 |
error: function( response ) { |
| 105 |
if ( !window.console ) console = {}; |
| 106 |
console.log = console.log || function( name, data ) {}; |
| 107 |
console.log( redux.ajax.console ); |
| 108 |
console.log( response.responseText ); |
| 109 |
jQuery( '.redux-action_bar input' ).removeAttr( 'disabled' ); |
| 110 |
overlay.fadeOut( 'fast' ); |
| 111 |
jQuery( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); |
| 112 |
alert( redux.ajax.alert ); |
| 113 |
}, |
| 114 |
success: function( response ) { |
| 115 |
if ( response.action && response.action == "reload" ) { |
| 116 |
location.reload( true ); |
| 117 |
} else if ( response.status == "success" ) { |
| 118 |
jQuery( '.redux-action_bar input' ).removeAttr( 'disabled' ); |
| 119 |
overlay.fadeOut( 'fast' ); |
| 120 |
jQuery( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); |
| 121 |
redux.options = response.options; |
| 122 |
//redux.defaults = response.defaults; |
| 123 |
redux.errors = response.errors; |
| 124 |
redux.warnings = response.warnings; |
| 125 |
|
| 126 |
$notification_bar.html( response.notification_bar ).slideDown( 'fast' ); |
| 127 |
if ( response.errors !== null || response.warnings !== null ) { |
| 128 |
$.redux.notices(); |
| 129 |
} |
| 130 |
var $save_notice = $( document.getElementById( 'redux_notification_bar' ) ).find( '.saved_notice' ); |
| 131 |
$save_notice.slideDown(); |
| 132 |
$save_notice.delay( 4000 ).slideUp(); |
| 133 |
} else { |
| 134 |
jQuery( '.redux-action_bar input' ).removeAttr( 'disabled' ); |
| 135 |
jQuery( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); |
| 136 |
overlay.fadeOut( 'fast' ); |
| 137 |
jQuery( '.wrap h2:first' ).parent().append( '<div class="error redux_ajax_save_error" style="display:none;"><p>' + response.status + '</p></div>' ); |
| 138 |
jQuery( '.redux_ajax_save_error' ).slideDown(); |
| 139 |
jQuery( "html, body" ).animate( {scrollTop: 0}, "slow" ); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
); |
| 144 |
return false; |
| 145 |
}; |
| 146 |
|
| 147 |
$.redux.initEvents = function() { |
| 148 |
$( '.redux-presets-bar' ).on( |
| 149 |
'click', function() { |
| 150 |
window.onbeforeunload = null; |
| 151 |
} |
| 152 |
); |
| 153 |
|
| 154 |
|
| 155 |
$( '#toplevel_page_' + redux.args.slug + ' .wp-submenu a, #wp-admin-bar-' + redux.args.slug + ' a.ab-item' ).click( |
| 156 |
function( e ) { |
| 157 |
|
| 158 |
if ( ( $( '#toplevel_page_' + redux.args.slug ).hasClass( 'wp-menu-open' ) || $( this ).hasClass( 'ab-item' ) ) && !$( this ).parents( 'ul.ab-submenu:first' ).hasClass( 'ab-sub-secondary' ) && $( this ).attr( 'href' ).toLowerCase().indexOf( redux.args.slug + "&tab=" ) >= 0 ) { |
| 159 |
e.preventDefault(); |
| 160 |
var url = $( this ).attr( 'href' ).split( '&tab=' ); |
| 161 |
$( '#' + url[1] + '_section_group_li_a' ).click(); |
| 162 |
$( this ).parents( 'ul:first' ).find( '.current' ).removeClass( 'current' ); |
| 163 |
$( this ).addClass( 'current' ); |
| 164 |
$( this ).parent().addClass( 'current' ); |
| 165 |
return false; |
| 166 |
} |
| 167 |
} |
| 168 |
); |
| 169 |
|
| 170 |
// Save button clicked |
| 171 |
$( '.redux-action_bar input, #redux-import-action input' ).on( |
| 172 |
'click', function( e ) { |
| 173 |
if ( $( this ).attr( 'name' ) == redux.args.opt_name + '[defaults]' ) { |
| 174 |
// Defaults button clicked |
| 175 |
if ( !confirm( redux.args.reset_confirm ) ) { |
| 176 |
return false; |
| 177 |
} |
| 178 |
} else if ( $( this ).attr( 'name' ) == redux.args.opt_name + '[defaults-section]' ) { |
| 179 |
// Default section clicked |
| 180 |
if ( !confirm( redux.args.reset_section_confirm ) ) { |
| 181 |
return false; |
| 182 |
} |
| 183 |
} else if ( $( this ).attr( 'name' ) == 'import' ) { |
| 184 |
if ( !confirm( redux.args.import_section_confirm ) ) { |
| 185 |
return false; |
| 186 |
} |
| 187 |
} |
| 188 |
|
| 189 |
window.onbeforeunload = null; |
| 190 |
|
| 191 |
if ( redux.args.ajax_save === true ) { |
| 192 |
$.redux.ajax_save( $( this ) ); |
| 193 |
e.preventDefault(); |
| 194 |
} else { |
| 195 |
location.reload( true ); |
| 196 |
} |
| 197 |
} |
| 198 |
); |
| 199 |
|
| 200 |
$( '.expand_options' ).click( |
| 201 |
function( e ) { |
| 202 |
|
| 203 |
e.preventDefault(); |
| 204 |
|
| 205 |
var container = $( '.redux-container' ); |
| 206 |
if ( $( container ).hasClass( 'fully-expanded' ) ) { |
| 207 |
$( container ).removeClass( 'fully-expanded' ); |
| 208 |
|
| 209 |
var tab = $.cookie( "redux_current_tab" ); |
| 210 |
|
| 211 |
$( '.redux-container:first' ).find( '#' + tab + '_section_group' ).fadeIn( |
| 212 |
200, function() { |
| 213 |
if ( $( '.redux-container:first' ).find( '#redux-footer' ).length !== 0 ) { |
| 214 |
$.redux.stickyInfo(); // race condition fix |
| 215 |
} |
| 216 |
$.redux.initFields(); |
| 217 |
} |
| 218 |
); |
| 219 |
} |
| 220 |
|
| 221 |
$.redux.expandOptions( $( this ).parents( '.redux-container:first' ) ); |
| 222 |
|
| 223 |
return false; |
| 224 |
} |
| 225 |
); |
| 226 |
|
| 227 |
if ( $( '.saved_notice' ).is( ':visible' ) ) { |
| 228 |
$( '.saved_notice' ).slideDown(); |
| 229 |
} |
| 230 |
|
| 231 |
$( document.body ).on( |
| 232 |
'change', '.redux-field input, .redux-field textarea, .redux-field select', function() { |
| 233 |
if ( !$( this ).hasClass( 'noUpdate' ) ) { |
| 234 |
redux_change( $( this ) ); |
| 235 |
} |
| 236 |
} |
| 237 |
); |
| 238 |
|
| 239 |
var stickyHeight = $( '#redux-footer' ).height(); |
| 240 |
|
| 241 |
$( '#redux-sticky-padder' ).css( |
| 242 |
{ |
| 243 |
height: stickyHeight |
| 244 |
} |
| 245 |
); |
| 246 |
$( '#redux-footer-sticky' ).removeClass( 'hide' ); |
| 247 |
|
| 248 |
if ( $( '#redux-footer' ).length !== 0 ) { |
| 249 |
$( window ).scroll( |
| 250 |
function() { |
| 251 |
$.redux.stickyInfo(); |
| 252 |
} |
| 253 |
); |
| 254 |
|
| 255 |
$( window ).resize( |
| 256 |
function() { |
| 257 |
$.redux.stickyInfo(); |
| 258 |
} |
| 259 |
); |
| 260 |
} |
| 261 |
|
| 262 |
$( '.saved_notice' ).delay( 4000 ).slideUp(); |
| 263 |
|
| 264 |
|
| 265 |
}; |
| 266 |
|
| 267 |
$.redux.hideFields = function() { |
| 268 |
$( "label[for='redux_hide_field']" ).each( |
| 269 |
function( idx, val ) { |
| 270 |
var tr = $( this ).parent().parent(); |
| 271 |
$( tr ).addClass( 'hidden' ); |
| 272 |
} |
| 273 |
); |
| 274 |
}; |
| 275 |
|
| 276 |
$.redux.checkRequired = function() { |
| 277 |
$.redux.required(); |
| 278 |
|
| 279 |
$( "body" ).on( |
| 280 |
'change', |
| 281 |
'.redux-main select, .redux-main radio, .redux-main input[type=checkbox], .redux-main input[type=hidden]', |
| 282 |
function( e ) { |
| 283 |
$.redux.check_dependencies( this ); |
| 284 |
} |
| 285 |
); |
| 286 |
|
| 287 |
$( "body" ).on( |
| 288 |
'check_dependencies', function( e, variable ) { |
| 289 |
$.redux.check_dependencies( variable ); |
| 290 |
} |
| 291 |
); |
| 292 |
|
| 293 |
$( '.redux-container td > fieldset:empty,td > div:empty' ).parent().parent().hide(); |
| 294 |
}; |
| 295 |
|
| 296 |
$.redux.initQtip = function() { |
| 297 |
if ( $().qtip ) { |
| 298 |
// Shadow |
| 299 |
var shadow = ''; |
| 300 |
var tip_shadow = redux.args.hints.tip_style.shadow; |
| 301 |
|
| 302 |
if ( tip_shadow === true ) { |
| 303 |
shadow = 'qtip-shadow'; |
| 304 |
} |
| 305 |
|
| 306 |
// Color |
| 307 |
var color = ''; |
| 308 |
var tip_color = redux.args.hints.tip_style.color; |
| 309 |
|
| 310 |
if ( tip_color !== '' ) { |
| 311 |
color = 'qtip-' + tip_color; |
| 312 |
} |
| 313 |
|
| 314 |
// Rounded |
| 315 |
var rounded = ''; |
| 316 |
var tip_rounded = redux.args.hints.tip_style.rounded; |
| 317 |
|
| 318 |
if ( tip_rounded === true ) { |
| 319 |
rounded = 'qtip-rounded'; |
| 320 |
} |
| 321 |
|
| 322 |
// Tip style |
| 323 |
var style = ''; |
| 324 |
var tip_style = redux.args.hints.tip_style.style; |
| 325 |
|
| 326 |
if ( tip_style !== '' ) { |
| 327 |
style = 'qtip-' + tip_style; |
| 328 |
} |
| 329 |
|
| 330 |
var classes = shadow + ',' + color + ',' + rounded + ',' + style + ',redux-qtip'; |
| 331 |
classes = classes.replace( /,/g, ' ' ); |
| 332 |
|
| 333 |
// Get position data |
| 334 |
var myPos = redux.args.hints.tip_position.my; |
| 335 |
var atPos = redux.args.hints.tip_position.at; |
| 336 |
|
| 337 |
// Gotta be lowercase, and in proper format |
| 338 |
myPos = $.redux.verifyPos( myPos.toLowerCase(), true ); |
| 339 |
atPos = $.redux.verifyPos( atPos.toLowerCase(), false ); |
| 340 |
|
| 341 |
// Tooltip trigger action |
| 342 |
var showEvent = redux.args.hints.tip_effect.show.event; |
| 343 |
var hideEvent = redux.args.hints.tip_effect.hide.event; |
| 344 |
|
| 345 |
// Tip show effect |
| 346 |
var tipShowEffect = redux.args.hints.tip_effect.show.effect; |
| 347 |
var tipShowDuration = redux.args.hints.tip_effect.show.duration; |
| 348 |
|
| 349 |
// Tip hide effect |
| 350 |
var tipHideEffect = redux.args.hints.tip_effect.hide.effect; |
| 351 |
var tipHideDuration = redux.args.hints.tip_effect.hide.duration; |
| 352 |
|
| 353 |
$( 'div.redux-dev-qtip' ).each( |
| 354 |
function() { |
| 355 |
$( this ).qtip( |
| 356 |
{ |
| 357 |
content: { |
| 358 |
text: $( this ).attr( 'qtip-content' ), |
| 359 |
title: $( this ).attr( 'qtip-title' ) |
| 360 |
}, |
| 361 |
show: { |
| 362 |
effect: function() { |
| 363 |
$( this ).slideDown( 500 ); |
| 364 |
}, |
| 365 |
event: 'mouseover', |
| 366 |
}, |
| 367 |
hide: { |
| 368 |
effect: function() { |
| 369 |
$( this ).slideUp( 500 ); |
| 370 |
}, |
| 371 |
event: 'mouseleave', |
| 372 |
}, |
| 373 |
style: { |
| 374 |
classes: 'qtip-shadow qtip-light', |
| 375 |
}, |
| 376 |
position: { |
| 377 |
my: 'top center', |
| 378 |
at: 'bottom center', |
| 379 |
}, |
| 380 |
} |
| 381 |
); |
| 382 |
} |
| 383 |
); |
| 384 |
|
| 385 |
$( 'div.redux-hint-qtip' ).each( |
| 386 |
function() { |
| 387 |
$( this ).qtip( |
| 388 |
{ |
| 389 |
content: { |
| 390 |
text: $( this ).attr( 'qtip-content' ), |
| 391 |
title: $( this ).attr( 'qtip-title' ) |
| 392 |
}, |
| 393 |
show: { |
| 394 |
effect: function() { |
| 395 |
switch ( tipShowEffect ) { |
| 396 |
case 'slide': |
| 397 |
$( this ).slideDown( tipShowDuration ); |
| 398 |
break; |
| 399 |
case 'fade': |
| 400 |
$( this ).fadeIn( tipShowDuration ); |
| 401 |
break; |
| 402 |
default: |
| 403 |
$( this ).show(); |
| 404 |
break; |
| 405 |
} |
| 406 |
}, |
| 407 |
event: showEvent, |
| 408 |
}, |
| 409 |
hide: { |
| 410 |
effect: function() { |
| 411 |
switch ( tipHideEffect ) { |
| 412 |
case 'slide': |
| 413 |
$( this ).slideUp( tipHideDuration ); |
| 414 |
break; |
| 415 |
case 'fade': |
| 416 |
$( this ).fadeOut( tipHideDuration ); |
| 417 |
break; |
| 418 |
default: |
| 419 |
$( this ).hide( tipHideDuration ); |
| 420 |
break; |
| 421 |
} |
| 422 |
}, |
| 423 |
event: hideEvent, |
| 424 |
}, |
| 425 |
style: { |
| 426 |
classes: classes, |
| 427 |
}, |
| 428 |
position: { |
| 429 |
my: myPos, |
| 430 |
at: atPos, |
| 431 |
}, |
| 432 |
} |
| 433 |
); |
| 434 |
} |
| 435 |
); |
| 436 |
// }); |
| 437 |
|
| 438 |
$( 'input[qtip-content]' ).each( |
| 439 |
function() { |
| 440 |
$( this ).qtip( |
| 441 |
{ |
| 442 |
content: { |
| 443 |
text: $( this ).attr( 'qtip-content' ), |
| 444 |
title: $( this ).attr( 'qtip-title' ) |
| 445 |
}, |
| 446 |
show: 'focus', |
| 447 |
hide: 'blur', |
| 448 |
style: classes, |
| 449 |
position: { |
| 450 |
my: myPos, |
| 451 |
at: atPos, |
| 452 |
}, |
| 453 |
} |
| 454 |
); |
| 455 |
} |
| 456 |
); |
| 457 |
} |
| 458 |
}; |
| 459 |
|
| 460 |
$.redux.tabCheck = function() { |
| 461 |
$( '.redux-group-tab-link-a' ).click( |
| 462 |
function() { |
| 463 |
var link = $( this ); |
| 464 |
if ( link.parent().hasClass( 'empty_section' ) && link.parent().hasClass( 'hasSubSections' ) ) { |
| 465 |
var elements = $( this ).closest( 'ul' ).find( '.redux-group-tab-link-a' ); |
| 466 |
var index = elements.index( this ); |
| 467 |
link = elements.slice( index + 1, index + 2 ); |
| 468 |
} |
| 469 |
var el = link.parents( '.redux-container:first' ); |
| 470 |
var relid = link.data( 'rel' ); // The group ID of interest |
| 471 |
var oldid = el.find( '.redux-group-tab-link-li.active:first .redux-group-tab-link-a' ).data( 'rel' ); |
| 472 |
|
| 473 |
//console.log('id: '+relid+' oldid: '+oldid); |
| 474 |
|
| 475 |
if ( oldid === relid ) { |
| 476 |
return; |
| 477 |
} |
| 478 |
|
| 479 |
$( '#currentSection' ).val( relid ); |
| 480 |
if ( !link.parents( '.postbox-container:first' ).length ) { |
| 481 |
// Set the proper page cookie |
| 482 |
$.cookie( |
| 483 |
'redux_current_tab', relid, { |
| 484 |
expires: 7, |
| 485 |
path: '/' |
| 486 |
} |
| 487 |
); |
| 488 |
} |
| 489 |
|
| 490 |
if ( el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).length ) { |
| 491 |
var parentID = el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).attr( 'id' ).split( '_' ); |
| 492 |
parentID = parentID[0]; |
| 493 |
} |
| 494 |
|
| 495 |
el.find( '#toplevel_page_' + redux.args.slug + ' .wp-submenu a.current' ).removeClass( 'current' ); |
| 496 |
el.find( '#toplevel_page_' + redux.args.slug + ' .wp-submenu li.current' ).removeClass( 'current' ); |
| 497 |
|
| 498 |
el.find( '#toplevel_page_' + redux.args.slug + ' .wp-submenu a' ).each( |
| 499 |
function() { |
| 500 |
var url = $( this ).attr( 'href' ).split( '&tab=' ); |
| 501 |
if ( url[1] == relid || url[1] == parentID ) { |
| 502 |
$( this ).addClass( 'current' ); |
| 503 |
$( this ).parent().addClass( 'current' ); |
| 504 |
} |
| 505 |
} |
| 506 |
); |
| 507 |
|
| 508 |
if ( el.find( '#' + oldid + '_section_group_li' ).find( '#' + oldid + '_section_group_li' ).length ) { |
| 509 |
//console.log('RELID is child of oldid'); |
| 510 |
el.find( '#' + oldid + '_section_group_li' ).addClass( 'activeChild' ); |
| 511 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ); |
| 512 |
} else if ( el.find( '#' + relid + '_section_group_li' ).parents( '#' + oldid + '_section_group_li' ).length || el.find( '#' + oldid + '_section_group_li' ).parents( 'ul.subsection' ).find( '#' + relid + '_section_group_li' ).length ) { |
| 513 |
//console.log('RELID is sibling or child of OLDID'); |
| 514 |
if ( el.find( '#' + relid + '_section_group_li' ).parents( '#' + oldid + '_section_group_li' ).length ) { |
| 515 |
//console.log('child of oldid'); |
| 516 |
el.find( '#' + oldid + '_section_group_li' ).addClass( 'activeChild' ).removeClass( 'active' ); |
| 517 |
} else { |
| 518 |
//console.log('sibling'); |
| 519 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); |
| 520 |
el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); |
| 521 |
} |
| 522 |
el.find( '#' + relid + '_section_group_li' ).removeClass( 'activeChild' ).addClass( 'active' ); |
| 523 |
} else { |
| 524 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); |
| 525 |
|
| 526 |
if ( el.find( '#' + oldid + '_section_group_li' ).find( 'ul.subsection' ).length ) { |
| 527 |
//console.log('oldid is parent'); |
| 528 |
//console.log('#' + relid + '_section_group_li'); |
| 529 |
|
| 530 |
el.find( '#' + oldid + '_section_group_li' ).find( 'ul.subsection' ).slideUp( |
| 531 |
'fast', function() { |
| 532 |
el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ).removeClass( 'activeChild' ); |
| 533 |
} |
| 534 |
); |
| 535 |
var newParent = el.find( '#' + relid + '_section_group_li' ).parents( '.hasSubSections:first' ); |
| 536 |
|
| 537 |
if ( newParent.length > 0 ) { |
| 538 |
el.find( '#' + relid + '_section_group_li' ).removeClass( 'active' ); |
| 539 |
relid = newParent.find( '.redux-group-tab-link-a:first' ).data( 'rel' ); |
| 540 |
//console.log(relid); |
| 541 |
if ( newParent.hasClass( 'empty_section' ) ) { |
| 542 |
newParent.find( '.subsection li:first' ).addClass( 'active' ); |
| 543 |
el.find( '#' + relid + '_section_group_li' ).removeClass( 'active' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); |
| 544 |
newParent = newParent.find( '.subsection li:first' ); |
| 545 |
relid = newParent.find( '.redux-group-tab-link-a:first' ).data( 'rel' ); |
| 546 |
//console.log('Empty section, do the next one?'); |
| 547 |
} else { |
| 548 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); |
| 549 |
} |
| 550 |
} |
| 551 |
} else if ( el.find( '#' + oldid + '_section_group_li' ).parents( 'ul.subsection' ).length ) { |
| 552 |
//console.log('oldid is a child'); |
| 553 |
if ( !el.find( '#' + oldid + '_section_group_li' ).parents( '#' + relid + '_section_group_li' ).length ) { |
| 554 |
//console.log('oldid is child, but not of relid'); |
| 555 |
el.find( '#' + oldid + '_section_group_li' ).parents( 'ul.subsection' ).slideUp( |
| 556 |
'fast', function() { |
| 557 |
el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); |
| 558 |
el.find( '#' + oldid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).removeClass( 'active' ).removeClass( 'activeChild' ); |
| 559 |
el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); |
| 560 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); |
| 561 |
} |
| 562 |
); |
| 563 |
} else { |
| 564 |
//console.log('oldid is child, but not of relid2'); |
| 565 |
el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); |
| 566 |
} |
| 567 |
} else { |
| 568 |
//console.log('Normal remove active from child'); |
| 569 |
el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); |
| 570 |
if ( el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).length ) { |
| 571 |
//console.log('here'); |
| 572 |
el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); |
| 573 |
el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); |
| 574 |
} |
| 575 |
} |
| 576 |
} |
| 577 |
|
| 578 |
// Show the group |
| 579 |
el.find( '#' + oldid + '_section_group' ).hide(); |
| 580 |
|
| 581 |
el.find( '#' + relid + '_section_group' ).fadeIn( |
| 582 |
200, function() { |
| 583 |
if ( el.find( '#redux-footer' ).length !== 0 ) { |
| 584 |
$.redux.stickyInfo(); // race condition fix |
| 585 |
} |
| 586 |
$.redux.initFields(); |
| 587 |
} |
| 588 |
); |
| 589 |
$( '#toplevel_page_' + redux.args.slug ).find( '.current' ).removeClass( 'current' ); |
| 590 |
|
| 591 |
} |
| 592 |
); |
| 593 |
|
| 594 |
if ( redux.last_tab !== undefined ) { |
| 595 |
$( '#' + redux.last_tab + '_section_group_li_a' ).click(); |
| 596 |
return; |
| 597 |
} |
| 598 |
|
| 599 |
var tab = decodeURI( (new RegExp( 'tab' + '=' + '(.+?)(&|$)' ).exec( location.search ) || ['', ''])[1] ); |
| 600 |
|
| 601 |
if ( tab !== "" ) { |
| 602 |
if ( $.cookie( "redux_current_tab_get" ) !== tab ) { |
| 603 |
$.cookie( |
| 604 |
'redux_current_tab', tab, { |
| 605 |
expires: 7, |
| 606 |
path: '/' |
| 607 |
} |
| 608 |
); |
| 609 |
$.cookie( |
| 610 |
'redux_current_tab_get', tab, { |
| 611 |
expires: 7, |
| 612 |
path: '/' |
| 613 |
} |
| 614 |
); |
| 615 |
|
| 616 |
$( '#' + tab + '_section_group_li' ).click(); |
| 617 |
} |
| 618 |
} else if ( $.cookie( 'redux_current_tab_get' ) !== "" ) { |
| 619 |
$.removeCookie( 'redux_current_tab_get' ); |
| 620 |
} |
| 621 |
|
| 622 |
var sTab = $( '#' + $.cookie( "redux_current_tab" ) + '_section_group_li_a' ); |
| 623 |
|
| 624 |
// Tab the first item or the saved one |
| 625 |
if ( $.cookie( "redux_current_tab" ) === null || typeof ($.cookie( "redux_current_tab" )) === "undefined" || sTab.length === 0 ) { |
| 626 |
$( '.redux-container' ).find( '.redux-group-tab-link-a:first' ).click(); |
| 627 |
} else { |
| 628 |
sTab.click(); |
| 629 |
} |
| 630 |
|
| 631 |
}; |
| 632 |
|
| 633 |
$.redux.initFields = function() { |
| 634 |
$( ".redux-group-tab:visible" ).find( ".redux-field-init:visible" ).each( |
| 635 |
function() { |
| 636 |
|
| 637 |
var type = $( this ).attr( 'data-type' ); |
| 638 |
//console.log(type); |
| 639 |
//if ( typeof redux.field_objects != 'undefined' && redux.field_objects[type] && redux.field_objects[type] ) { |
| 640 |
if ( type in redux.field_objects && typeof redux.field_objects[type].init == 'function' ) { |
| 641 |
redux.field_objects[type].init(); |
| 642 |
} |
| 643 |
if ( !redux.customizer && $( this ).hasClass( 'redux_remove_th' ) ) { |
| 644 |
|
| 645 |
var tr = $( this ).parents( 'tr:first' ); |
| 646 |
var th = tr.find( 'th:first' ); |
| 647 |
if ( th.html() && th.html().length > 0 ) { |
| 648 |
$( this ).prepend( th.html() ); |
| 649 |
$( this ).find( '.redux_field_th' ).css( 'padding', '0 0 10px 0' ); |
| 650 |
} |
| 651 |
$( this ).parent().attr( 'colspan', '2' ); |
| 652 |
th.remove(); |
| 653 |
} |
| 654 |
} |
| 655 |
); |
| 656 |
}; |
| 657 |
|
| 658 |
$.redux.notices = function() { |
| 659 |
if ( redux.errors && redux.errors.errors ) { |
| 660 |
$.each( |
| 661 |
redux.errors.errors, function( sectionID, sectionArray ) { |
| 662 |
$.each( |
| 663 |
sectionArray.errors, function( key, value ) { |
| 664 |
$( "#" + redux.args.opt_name + '-' + value.id ).addClass( "redux-field-error" ); |
| 665 |
if ( $( "#" + redux.args.opt_name + '-' + value.id ).parent().find( '.redux-th-error' ).length === 0 ) { |
| 666 |
$( "#" + redux.args.opt_name + '-' + value.id ).append( '<div class="redux-th-error">' + value.msg + '</div>' ); |
| 667 |
} else { |
| 668 |
$( "#" + redux.args.opt_name + '-' + value.id ).parent().find( '.redux-th-error' ).html( value.msg ).css( |
| 669 |
'display', 'block' |
| 670 |
); |
| 671 |
} |
| 672 |
} |
| 673 |
); |
| 674 |
} |
| 675 |
); |
| 676 |
$( '.redux-container' ).each( |
| 677 |
function() { |
| 678 |
var container = $( this ); |
| 679 |
// Ajax cleanup |
| 680 |
container.find( '.redux-menu-error' ).remove(); |
| 681 |
var totalErrors = container.find( '.redux-field-error' ).length; |
| 682 |
if ( totalErrors > 0 ) { |
| 683 |
container.find( ".redux-field-errors span" ).text( totalErrors ); |
| 684 |
container.find( ".redux-field-errors" ).slideDown(); |
| 685 |
container.find( '.redux-group-tab' ).each( |
| 686 |
function() { |
| 687 |
var total = $( this ).find( '.redux-field-error' ).length; |
| 688 |
if ( total > 0 ) { |
| 689 |
var sectionID = $( this ).attr( 'id' ).split( '_' ); |
| 690 |
sectionID = sectionID[0]; |
| 691 |
container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).prepend( '<span class="redux-menu-error">' + total + '</span>' ); |
| 692 |
container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).addClass( "hasError" ); |
| 693 |
var subParent = container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).parents( '.hasSubSections:first' ); |
| 694 |
if ( subParent ) { |
| 695 |
subParent.find( '.redux-group-tab-link-a:first' ).addClass( 'hasError' ); |
| 696 |
} |
| 697 |
} |
| 698 |
} |
| 699 |
); |
| 700 |
} |
| 701 |
} |
| 702 |
); |
| 703 |
} |
| 704 |
if ( redux.warnings && redux.warnings.warnings ) { |
| 705 |
$.each( |
| 706 |
redux.warnings.warnings, function( sectionID, sectionArray ) { |
| 707 |
$.each( |
| 708 |
sectionArray.warnings, function( key, value ) { |
| 709 |
$( "#" + redux.args.opt_name + '-' + value.id ).addClass( "redux-field-warning" ); |
| 710 |
if ( $( "#" + redux.args.opt_name + '-' + value.id ).parent().find( '.redux-th-warning' ).length === 0 ) { |
| 711 |
$( "#" + redux.args.opt_name + '-' + value.id ).append( '<div class="redux-th-warning">' + value.msg + '</div>' ); |
| 712 |
} else { |
| 713 |
$( "#" + redux.args.opt_name + '-' + value.id ).parent().find( '.redux-th-warning' ).html( value.msg ).css( |
| 714 |
'display', 'block' |
| 715 |
); |
| 716 |
} |
| 717 |
} |
| 718 |
); |
| 719 |
} |
| 720 |
); |
| 721 |
$( '.redux-container' ).each( |
| 722 |
function() { |
| 723 |
var container = $( this ); |
| 724 |
// Ajax cleanup |
| 725 |
container.find( '.redux-menu-warning' ).remove(); |
| 726 |
var totalWarnings = container.find( '.redux-field-warning' ).length; |
| 727 |
if ( totalWarnings > 0 ) { |
| 728 |
container.find( ".redux-field-warnings span" ).text( totalWarnings ); |
| 729 |
container.find( ".redux-field-warnings" ).slideDown(); |
| 730 |
container.find( '.redux-group-tab' ).each( |
| 731 |
function() { |
| 732 |
var total = $( this ).find( '.redux-field-warning' ).length; |
| 733 |
if ( total > 0 ) { |
| 734 |
var sectionID = $( this ).attr( 'id' ).split( '_' ); |
| 735 |
sectionID = sectionID[0]; |
| 736 |
container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).prepend( '<span class="redux-menu-warning">' + total + '</span>' ); |
| 737 |
container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).addClass( "hasWarning" ); |
| 738 |
var subParent = container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).parents( '.hasSubSections:first' ); |
| 739 |
if ( subParent ) { |
| 740 |
subParent.find( '.redux-group-tab-link-a:first' ).addClass( 'hasWarning' ); |
| 741 |
} |
| 742 |
} |
| 743 |
} |
| 744 |
); |
| 745 |
} |
| 746 |
} |
| 747 |
); |
| 748 |
} |
| 749 |
}; |
| 750 |
|
| 751 |
$.redux.tabControl = function() { |
| 752 |
$( '.redux-section-tabs div' ).hide(); |
| 753 |
$( '.redux-section-tabs div:first' ).show(); |
| 754 |
$( '.redux-section-tabs ul li:first' ).addClass( 'active' ); |
| 755 |
|
| 756 |
$( '.redux-section-tabs ul li a' ).click( |
| 757 |
function() { |
| 758 |
$( '.redux-section-tabs ul li' ).removeClass( 'active' ); |
| 759 |
$( this ).parent().addClass( 'active' ); |
| 760 |
|
| 761 |
var currentTab = $( this ).attr( 'href' ); |
| 762 |
|
| 763 |
$( '.redux-section-tabs div' ).hide(); |
| 764 |
$( currentTab ).fadeIn( |
| 765 |
'medium', function() { |
| 766 |
$.redux.initFields(); |
| 767 |
} |
| 768 |
); |
| 769 |
|
| 770 |
return false; |
| 771 |
} |
| 772 |
); |
| 773 |
}; |
| 774 |
|
| 775 |
$.redux.required = function() { |
| 776 |
|
| 777 |
// Hide the fold elements on load , |
| 778 |
// It's better to do this by PHP but there is no filter in tr tag , so is not possible |
| 779 |
// we going to move each attributes we may need for folding to tr tag |
| 780 |
$.each( |
| 781 |
redux.folds, function( i, v ) { |
| 782 |
var fieldset = $( '#' + redux.args.opt_name + '-' + i ); |
| 783 |
|
| 784 |
fieldset.parents( 'tr:first' ).addClass( 'fold' ); |
| 785 |
|
| 786 |
if ( v == "hide" ) { |
| 787 |
fieldset.parents( 'tr:first' ).addClass( 'hide' ); |
| 788 |
|
| 789 |
if ( fieldset.hasClass( 'redux-container-section' ) ) { |
| 790 |
var div = $( '#section-' + i ); |
| 791 |
|
| 792 |
if ( div.hasClass( 'redux-section-indent-start' ) ) { |
| 793 |
$( '#section-table-' + i ).hide().addClass( 'hide' ); |
| 794 |
div.hide().addClass( 'hide' ); |
| 795 |
} |
| 796 |
} |
| 797 |
|
| 798 |
if ( fieldset.hasClass( 'redux-container-info' ) ) { |
| 799 |
$( '#info-' + i ).hide().addClass( 'hide' ); |
| 800 |
} |
| 801 |
|
| 802 |
if ( fieldset.hasClass( 'redux-container-divide' ) ) { |
| 803 |
$( '#divide-' + i ).hide().addClass( 'hide' ); |
| 804 |
} |
| 805 |
|
| 806 |
if ( fieldset.hasClass( 'redux-container-raw' ) ) { |
| 807 |
var rawTable = fieldset.parents().find( 'table#' + redux.args.opt_name + '-' + i ); |
| 808 |
rawTable.hide().addClass( 'hide' ); |
| 809 |
} |
| 810 |
} |
| 811 |
} |
| 812 |
); |
| 813 |
}; |
| 814 |
|
| 815 |
$.redux.get_container_value = function( id ) { |
| 816 |
var value = $( '#' + redux.args.opt_name + '-' + id ).serializeForm(); |
| 817 |
|
| 818 |
if ( value !== null && typeof value === 'object' && value.hasOwnProperty( redux.args.opt_name ) ) { |
| 819 |
value = value[redux.args.opt_name][id]; |
| 820 |
} |
| 821 |
if ( $( '#' + redux.args.opt_name + '-' + id ).hasClass( 'redux-container-media' ) ) { |
| 822 |
value = value.url; |
| 823 |
} |
| 824 |
return value; |
| 825 |
}; |
| 826 |
|
| 827 |
$.redux.check_dependencies = function( variable ) { |
| 828 |
if ( redux.required === null ) { |
| 829 |
return; |
| 830 |
} |
| 831 |
|
| 832 |
var current = $( variable ), |
| 833 |
id = current.parents( '.redux-field:first' ).data( 'id' ); |
| 834 |
|
| 835 |
if ( !redux.required.hasOwnProperty( id ) ) { |
| 836 |
return; |
| 837 |
} |
| 838 |
|
| 839 |
var container = current.parents( '.redux-field-container:first' ), |
| 840 |
is_hidden = container.parents( 'tr:first' ).hasClass( 'hide' ); |
| 841 |
|
| 842 |
if ( !container.parents( 'tr:first' ).length ) { |
| 843 |
is_hidden = container.parents( '.customize-control:first' ).hasClass( 'hide' ); |
| 844 |
} |
| 845 |
|
| 846 |
$.each( |
| 847 |
redux.required[id], function( child, dependents ) { |
| 848 |
|
| 849 |
var current = $( this ), |
| 850 |
show = false, |
| 851 |
childFieldset = $( '#' + redux.args.opt_name + '-' + child ), |
| 852 |
tr = childFieldset.parents( 'tr:first' ); |
| 853 |
|
| 854 |
if ( !is_hidden ) { |
| 855 |
show = $.redux.check_parents_dependencies( child ); |
| 856 |
} |
| 857 |
|
| 858 |
if ( show === true ) { |
| 859 |
// Shim for sections |
| 860 |
if ( childFieldset.hasClass( 'redux-container-section' ) ) { |
| 861 |
var div = $( '#section-' + child ); |
| 862 |
|
| 863 |
if ( div.hasClass( 'redux-section-indent-start' ) && div.hasClass( 'hide' ) ) { |
| 864 |
$( '#section-table-' + child ).fadeIn( 300 ).removeClass( 'hide' ); |
| 865 |
div.fadeIn( 300 ).removeClass( 'hide' ); |
| 866 |
} |
| 867 |
} |
| 868 |
|
| 869 |
if ( childFieldset.hasClass( 'redux-container-info' ) ) { |
| 870 |
$( '#info-' + child ).fadeIn( 300 ).removeClass( 'hide' ); |
| 871 |
} |
| 872 |
|
| 873 |
if ( childFieldset.hasClass( 'redux-container-divide' ) ) { |
| 874 |
$( '#divide-' + child ).fadeIn( 300 ).removeClass( 'hide' ); |
| 875 |
} |
| 876 |
|
| 877 |
if ( childFieldset.hasClass( 'redux-container-raw' ) ) { |
| 878 |
var rawTable = childFieldset.parents().find( 'table#' + redux.args.opt_name + '-' + child ); |
| 879 |
rawTable.fadeIn( 300 ).removeClass( 'hide' ); |
| 880 |
} |
| 881 |
|
| 882 |
tr.fadeIn( |
| 883 |
300, function() { |
| 884 |
$( this ).removeClass( 'hide' ); |
| 885 |
if ( redux.required.hasOwnProperty( child ) ) { |
| 886 |
$.redux.check_dependencies( $( '#' + redux.args.opt_name + '-' + child ).children().first() ); |
| 887 |
} |
| 888 |
$.redux.initFields(); |
| 889 |
} |
| 890 |
); |
| 891 |
if ( childFieldset.hasClass( 'redux-container-section' ) || childFieldset.hasClass( 'redux-container-info' ) ) { |
| 892 |
tr.css( {display: 'none'} ); |
| 893 |
} |
| 894 |
} else if ( show === false ) { |
| 895 |
tr.fadeOut( |
| 896 |
100, function() { |
| 897 |
$( this ).addClass( 'hide' ); |
| 898 |
if ( redux.required.hasOwnProperty( child ) ) { |
| 899 |
//console.log('Now check, reverse: '+child); |
| 900 |
$.redux.required_recursive_hide( child ); |
| 901 |
} |
| 902 |
} |
| 903 |
); |
| 904 |
} |
| 905 |
|
| 906 |
current.find( 'select, radio, input[type=checkbox]' ).trigger( 'change' ); |
| 907 |
} |
| 908 |
); |
| 909 |
}; |
| 910 |
|
| 911 |
$.redux.required_recursive_hide = function( id ) { |
| 912 |
var toFade = $( '#' + redux.args.opt_name + '-' + id ).parents( 'tr:first' ); |
| 913 |
|
| 914 |
toFade.fadeOut( |
| 915 |
50, function() { |
| 916 |
$( this ).addClass( 'hide' ); |
| 917 |
|
| 918 |
if ( $( '#' + redux.args.opt_name + '-' + id ).hasClass( 'redux-container-section' ) ) { |
| 919 |
var div = $( '#section-' + id ); |
| 920 |
if ( div.hasClass( 'redux-section-indent-start' ) ) { |
| 921 |
$( '#section-table-' + id ).fadeOut( 50 ).addClass( 'hide' ); |
| 922 |
div.fadeOut( 50 ).addClass( 'hide' ); |
| 923 |
} |
| 924 |
} |
| 925 |
|
| 926 |
if ( $( '#' + redux.args.opt_name + '-' + id ).hasClass( 'redux-container-info' ) ) { |
| 927 |
$( '#info-' + id ).fadeOut( 50 ).addClass( 'hide' ); |
| 928 |
} |
| 929 |
|
| 930 |
if ( $( '#' + redux.args.opt_name + '-' + id ).hasClass( 'redux-container-divide' ) ) { |
| 931 |
$( '#divide-' + id ).fadeOut( 50 ).addClass( 'hide' ); |
| 932 |
} |
| 933 |
|
| 934 |
if ( $( '#' + redux.args.opt_name + '-' + id ).hasClass( 'redux-container-raw' ) ) { |
| 935 |
var rawTable = $( '#' + redux.args.opt_name + '-' + id ).parents().find( 'table#' + redux.args.opt_name + '-' + id ); |
| 936 |
rawTable.fadeOut( 50 ).addClass( 'hide' ); |
| 937 |
} |
| 938 |
|
| 939 |
if ( redux.required.hasOwnProperty( id ) ) { |
| 940 |
$.each( |
| 941 |
redux.required[id], function( child ) { |
| 942 |
$.redux.required_recursive_hide( child ); |
| 943 |
} |
| 944 |
); |
| 945 |
} |
| 946 |
} |
| 947 |
); |
| 948 |
}; |
| 949 |
|
| 950 |
$.redux.check_parents_dependencies = function( id ) { |
| 951 |
var show = ""; |
| 952 |
|
| 953 |
if ( redux.required_child.hasOwnProperty( id ) ) { |
| 954 |
$.each( |
| 955 |
redux.required_child[id], function( i, parentData ) { |
| 956 |
if ( $( '#' + redux.args.opt_name + '-' + parentData.parent ).parents( 'tr:first' ).hasClass( 'hide' ) ) { |
| 957 |
show = false; |
| 958 |
} else { |
| 959 |
if ( show !== false ) { |
| 960 |
var parentValue = $.redux.get_container_value( parentData.parent ); |
| 961 |
show = $.redux.check_dependencies_visibility( parentValue, parentData ); |
| 962 |
} |
| 963 |
} |
| 964 |
} |
| 965 |
); |
| 966 |
} else { |
| 967 |
show = true; |
| 968 |
} |
| 969 |
return show; |
| 970 |
}; |
| 971 |
|
| 972 |
$.redux.check_dependencies_visibility = function( parentValue, data ) { |
| 973 |
var show = false, |
| 974 |
checkValue_array, |
| 975 |
checkValue = data.checkValue, |
| 976 |
operation = data.operation, |
| 977 |
arr; |
| 978 |
|
| 979 |
if ($.isPlainObject( parentValue )) { |
| 980 |
parentValue = Object.keys( parentValue ).map( |
| 981 |
function( key ) { |
| 982 |
return [key, parentValue[key]]; |
| 983 |
} |
| 984 |
); |
| 985 |
} |
| 986 |
|
| 987 |
switch ( operation ) { |
| 988 |
case '=': |
| 989 |
case 'equals': |
| 990 |
if ( $.isArray( parentValue ) ) { |
| 991 |
$( parentValue[0] ).each( |
| 992 |
function( idx, val ) { |
| 993 |
if ( $.isArray( checkValue ) ) { |
| 994 |
$( checkValue ).each( |
| 995 |
function( i, v ) { |
| 996 |
if ( val == v ) { |
| 997 |
show = true; |
| 998 |
return true; |
| 999 |
} |
| 1000 |
} |
| 1001 |
); |
| 1002 |
} else { |
| 1003 |
if ( val == checkValue ) { |
| 1004 |
show = true; |
| 1005 |
return true; |
| 1006 |
} |
| 1007 |
} |
| 1008 |
} |
| 1009 |
); |
| 1010 |
} else { |
| 1011 |
if ( $.isArray( checkValue ) ) { |
| 1012 |
$( checkValue ).each( |
| 1013 |
function( i, v ) { |
| 1014 |
if ( parentValue == v ) { |
| 1015 |
show = true; |
| 1016 |
} |
| 1017 |
} |
| 1018 |
); |
| 1019 |
} else { |
| 1020 |
if ( parentValue == checkValue ) { |
| 1021 |
show = true; |
| 1022 |
} |
| 1023 |
} |
| 1024 |
} |
| 1025 |
break; |
| 1026 |
|
| 1027 |
case '!=': |
| 1028 |
case 'not': |
| 1029 |
if ( $.isArray( parentValue ) ) { |
| 1030 |
$( parentValue[0] ).each( |
| 1031 |
function( idx, val ) { |
| 1032 |
if ( $.isArray( checkValue ) ) { |
| 1033 |
$( checkValue ).each( |
| 1034 |
function( i, v ) { |
| 1035 |
if ( val != v ) { |
| 1036 |
show = true; |
| 1037 |
return true; |
| 1038 |
} |
| 1039 |
} |
| 1040 |
); |
| 1041 |
} else { |
| 1042 |
if ( val != checkValue ) { |
| 1043 |
show = true; |
| 1044 |
return true; |
| 1045 |
} |
| 1046 |
} |
| 1047 |
} |
| 1048 |
); |
| 1049 |
} else { |
| 1050 |
if ( $.isArray( checkValue ) ) { |
| 1051 |
$( checkValue ).each( |
| 1052 |
function( i, v ) { |
| 1053 |
if ( parentValue != v ) { |
| 1054 |
show = true; |
| 1055 |
} |
| 1056 |
} |
| 1057 |
); |
| 1058 |
} else { |
| 1059 |
if ( parentValue != checkValue ) { |
| 1060 |
show = true; |
| 1061 |
} |
| 1062 |
} |
| 1063 |
} |
| 1064 |
break; |
| 1065 |
|
| 1066 |
case '>': |
| 1067 |
case 'greater': |
| 1068 |
case 'is_larger': |
| 1069 |
if ( parseFloat( parentValue ) > parseFloat( checkValue ) ) { |
| 1070 |
show = true; |
| 1071 |
} |
| 1072 |
break; |
| 1073 |
|
| 1074 |
case '>=': |
| 1075 |
case 'greater_equal': |
| 1076 |
case 'is_larger_equal': |
| 1077 |
if ( parseFloat( parentValue ) >= parseFloat( checkValue ) ) { |
| 1078 |
show = true; |
| 1079 |
} |
| 1080 |
break; |
| 1081 |
|
| 1082 |
case '<': |
| 1083 |
case 'less': |
| 1084 |
case 'is_smaller': |
| 1085 |
if ( parseFloat( parentValue ) < parseFloat( checkValue ) ) { |
| 1086 |
show = true; |
| 1087 |
} |
| 1088 |
break; |
| 1089 |
|
| 1090 |
case '<=': |
| 1091 |
case 'less_equal': |
| 1092 |
case 'is_smaller_equal': |
| 1093 |
if ( parseFloat( parentValue ) <= parseFloat( checkValue ) ) { |
| 1094 |
show = true; |
| 1095 |
} |
| 1096 |
break; |
| 1097 |
|
| 1098 |
case 'contains': |
| 1099 |
if ( $.isPlainObject( parentValue ) ) { |
| 1100 |
parentValue = Object.keys( parentValue ).map( |
| 1101 |
function( key ) { |
| 1102 |
return [key, parentValue[key]]; |
| 1103 |
} |
| 1104 |
); |
| 1105 |
} |
| 1106 |
|
| 1107 |
if ( $.isPlainObject( checkValue ) ) { |
| 1108 |
checkValue = Object.keys( checkValue ).map( |
| 1109 |
function( key ) { |
| 1110 |
return [key, checkValue[key]]; |
| 1111 |
} |
| 1112 |
); |
| 1113 |
} |
| 1114 |
|
| 1115 |
if ( $.isArray( checkValue ) ) { |
| 1116 |
$( checkValue ).each( |
| 1117 |
function( idx, val ) { |
| 1118 |
var breakMe = false; |
| 1119 |
var toFind = val[0]; |
| 1120 |
var findVal = val[1]; |
| 1121 |
|
| 1122 |
$( parentValue ).each( |
| 1123 |
function( i, v ) { |
| 1124 |
var toMatch = v[0]; |
| 1125 |
var matchVal = v[1]; |
| 1126 |
|
| 1127 |
if ( toFind === toMatch ) { |
| 1128 |
if ( findVal == matchVal ) { |
| 1129 |
show = true; |
| 1130 |
breakMe = true; |
| 1131 |
|
| 1132 |
return false; |
| 1133 |
} |
| 1134 |
} |
| 1135 |
} |
| 1136 |
); |
| 1137 |
|
| 1138 |
if ( breakMe === true ) { |
| 1139 |
return false; |
| 1140 |
} |
| 1141 |
} |
| 1142 |
); |
| 1143 |
} else { |
| 1144 |
if ( parentValue.toString().indexOf( checkValue ) !== -1 ) { |
| 1145 |
show = true; |
| 1146 |
} |
| 1147 |
} |
| 1148 |
break; |
| 1149 |
|
| 1150 |
case 'doesnt_contain': |
| 1151 |
case 'not_contain': |
| 1152 |
if ( $.isPlainObject( parentValue ) ) { |
| 1153 |
arr = Object.keys( parentValue ).map( |
| 1154 |
function( key ) { |
| 1155 |
return parentValue[key]; |
| 1156 |
} |
| 1157 |
); |
| 1158 |
parentValue = arr; |
| 1159 |
} |
| 1160 |
|
| 1161 |
if ( $.isPlainObject( checkValue ) ) { |
| 1162 |
arr = Object.keys( checkValue ).map( |
| 1163 |
function( key ) { |
| 1164 |
return checkValue[key]; |
| 1165 |
} |
| 1166 |
); |
| 1167 |
checkValue = arr; |
| 1168 |
} |
| 1169 |
|
| 1170 |
if ( $.isArray( checkValue ) ) { |
| 1171 |
$( checkValue ).each( |
| 1172 |
function( idx, val ) { |
| 1173 |
if ( parentValue.toString().indexOf( val ) === -1 ) { |
| 1174 |
show = true; |
| 1175 |
} |
| 1176 |
} |
| 1177 |
); |
| 1178 |
} else { |
| 1179 |
if ( parentValue.toString().indexOf( checkValue ) === -1 ) { |
| 1180 |
show = true; |
| 1181 |
} |
| 1182 |
} |
| 1183 |
break; |
| 1184 |
|
| 1185 |
case 'is_empty_or': |
| 1186 |
if ( parentValue === "" || parentValue == checkValue ) { |
| 1187 |
show = true; |
| 1188 |
} |
| 1189 |
break; |
| 1190 |
|
| 1191 |
case 'not_empty_and': |
| 1192 |
if ( parentValue !== "" && parentValue != checkValue ) { |
| 1193 |
show = true; |
| 1194 |
} |
| 1195 |
break; |
| 1196 |
|
| 1197 |
case 'is_empty': |
| 1198 |
case 'empty': |
| 1199 |
case '!isset': |
| 1200 |
if ( !parentValue || parentValue === "" || parentValue === null ) { |
| 1201 |
show = true; |
| 1202 |
} |
| 1203 |
break; |
| 1204 |
|
| 1205 |
case 'not_empty': |
| 1206 |
case '!empty': |
| 1207 |
case 'isset': |
| 1208 |
if ( parentValue && parentValue !== "" && parentValue !== null ) { |
| 1209 |
show = true; |
| 1210 |
} |
| 1211 |
break; |
| 1212 |
} |
| 1213 |
return show; |
| 1214 |
|
| 1215 |
}; |
| 1216 |
|
| 1217 |
$.redux.verifyPos = function( s, b ) { |
| 1218 |
|
| 1219 |
// trim off spaces |
| 1220 |
s = s.replace( /^\s+|\s+$/gm, '' ); |
| 1221 |
|
| 1222 |
// position value is blank, set the default |
| 1223 |
if ( s === '' || s.search( ' ' ) == -1 ) { |
| 1224 |
if ( b === true ) { |
| 1225 |
return 'top left'; |
| 1226 |
} else { |
| 1227 |
return 'bottom right'; |
| 1228 |
} |
| 1229 |
} |
| 1230 |
|
| 1231 |
// split string into array |
| 1232 |
var split = s.split( ' ' ); |
| 1233 |
|
| 1234 |
// Evaluate first string. Must be top, center, or bottom |
| 1235 |
var paramOne = b ? 'top' : 'bottom'; |
| 1236 |
if ( split[0] == 'top' || split[0] == 'center' || split[0] == 'bottom' ) { |
| 1237 |
paramOne = split[0]; |
| 1238 |
} |
| 1239 |
|
| 1240 |
// Evaluate second string. Must be left, center, or right. |
| 1241 |
var paramTwo = b ? 'left' : 'right'; |
| 1242 |
if ( split[1] == 'left' || split[1] == 'center' || split[1] == 'right' ) { |
| 1243 |
paramTwo = split[1]; |
| 1244 |
} |
| 1245 |
|
| 1246 |
return paramOne + ' ' + paramTwo; |
| 1247 |
}; |
| 1248 |
|
| 1249 |
$.redux.stickyInfo = function() { |
| 1250 |
var stickyWidth = $( '.redux-main' ).innerWidth() - 20; |
| 1251 |
|
| 1252 |
if ( !$( '#info_bar' ).isOnScreen() && !$( '#redux-footer-sticky' ).isOnScreen() ) { |
| 1253 |
$( '#redux-footer' ).css( |
| 1254 |
{ |
| 1255 |
position: 'fixed', |
| 1256 |
bottom: '0', |
| 1257 |
width: stickyWidth, |
| 1258 |
right: 21 |
| 1259 |
} |
| 1260 |
); |
| 1261 |
$( '#redux-footer' ).addClass( 'sticky-footer-fixed' ); |
| 1262 |
$( '.redux-save-warn' ).css( 'left', $( '#redux-sticky' ).offset().left ); |
| 1263 |
$( '#redux-sticky-padder' ).show(); |
| 1264 |
} else { |
| 1265 |
$( '#redux-footer' ).css( |
| 1266 |
{ |
| 1267 |
background: '#eee', |
| 1268 |
position: 'inherit', |
| 1269 |
bottom: 'inherit', |
| 1270 |
width: 'inherit' |
| 1271 |
} |
| 1272 |
); |
| 1273 |
$( '#redux-sticky-padder' ).hide(); |
| 1274 |
$( '#redux-footer' ).removeClass( 'sticky-footer-fixed' ); |
| 1275 |
} |
| 1276 |
if ( !$( '#info_bar' ).isOnScreen() ) { |
| 1277 |
$( '#redux-sticky' ).addClass( 'sticky-save-warn' ); |
| 1278 |
} else { |
| 1279 |
$( '#redux-sticky' ).removeClass( 'sticky-save-warn' ); |
| 1280 |
} |
| 1281 |
}; |
| 1282 |
|
| 1283 |
$.redux.expandOptions = function( parent ) { |
| 1284 |
var trigger = parent.find( '.expand_options' ); |
| 1285 |
var width = parent.find( '.redux-sidebar' ).width() - 1; |
| 1286 |
var id = $( '.redux-group-menu .active a' ).data( 'rel' ) + '_section_group'; |
| 1287 |
|
| 1288 |
if ( trigger.hasClass( 'expanded' ) ) { |
| 1289 |
trigger.removeClass( 'expanded' ); |
| 1290 |
parent.find( '.redux-main' ).removeClass( 'expand' ); |
| 1291 |
|
| 1292 |
parent.find( '.redux-sidebar' ).stop().animate( |
| 1293 |
{ |
| 1294 |
'margin-left': '0px' |
| 1295 |
}, 500 |
| 1296 |
); |
| 1297 |
|
| 1298 |
parent.find( '.redux-main' ).stop().animate( |
| 1299 |
{ |
| 1300 |
'margin-left': width |
| 1301 |
}, 500, function() { |
| 1302 |
parent.find( '.redux-main' ).attr( 'style', '' ); |
| 1303 |
} |
| 1304 |
); |
| 1305 |
|
| 1306 |
parent.find( '.redux-group-tab' ).each( |
| 1307 |
function() { |
| 1308 |
if ( $( this ).attr( 'id' ) !== id ) { |
| 1309 |
$( this ).fadeOut( 'fast' ); |
| 1310 |
} |
| 1311 |
} |
| 1312 |
); |
| 1313 |
// Show the only active one |
| 1314 |
} else { |
| 1315 |
trigger.addClass( 'expanded' ); |
| 1316 |
parent.find( '.redux-main' ).addClass( 'expand' ); |
| 1317 |
|
| 1318 |
parent.find( '.redux-sidebar' ).stop().animate( |
| 1319 |
{ |
| 1320 |
'margin-left': -width - 113 |
| 1321 |
}, 500 |
| 1322 |
); |
| 1323 |
|
| 1324 |
parent.find( '.redux-main' ).stop().animate( |
| 1325 |
{ |
| 1326 |
'margin-left': '-1px' |
| 1327 |
}, 500 |
| 1328 |
); |
| 1329 |
|
| 1330 |
parent.find( '.redux-group-tab' ).fadeIn( |
| 1331 |
'medium', function() { |
| 1332 |
$.redux.initFields(); |
| 1333 |
} |
| 1334 |
); |
| 1335 |
} |
| 1336 |
return false; |
| 1337 |
}; |
| 1338 |
|
| 1339 |
|
| 1340 |
$.redux.scaleToRatio = function( el, maxHeight, maxWidth ) { |
| 1341 |
var ratio = 0; // Used for aspect ratio |
| 1342 |
|
| 1343 |
var width = el.attr( 'data-width' ); |
| 1344 |
if ( !width ) { |
| 1345 |
width = el.width(); |
| 1346 |
el.attr( 'data-width', width ); |
| 1347 |
} |
| 1348 |
var height = el.attr( 'data-height' ); |
| 1349 |
var eHeight = el.height(); |
| 1350 |
if ( !height || eHeight > height ) { |
| 1351 |
height = eHeight; |
| 1352 |
el.attr( 'data-height', height ); |
| 1353 |
el.css( "width", 'auto' ); |
| 1354 |
el.attr( 'data-width', el.width() ); |
| 1355 |
width = el.width(); |
| 1356 |
} |
| 1357 |
|
| 1358 |
|
| 1359 |
// Check if the current width is larger than the max |
| 1360 |
if ( width > maxWidth ) { |
| 1361 |
ratio = maxWidth / width; // get ratio for scaling image |
| 1362 |
el.css( "width", maxWidth ); // Set new width |
| 1363 |
el.css( "height", height * ratio ); // Scale height based on ratio |
| 1364 |
height = height * ratio; // Reset height to match scaled image |
| 1365 |
width = width * ratio; // Reset width to match scaled image |
| 1366 |
|
| 1367 |
} else { |
| 1368 |
el.css( "width", 'auto' ); // Set new height |
| 1369 |
|
| 1370 |
} |
| 1371 |
|
| 1372 |
// Check if current height is larger than max |
| 1373 |
if ( height > maxHeight ) { |
| 1374 |
ratio = maxHeight / height; // get ratio for scaling image |
| 1375 |
el.css( "height", maxHeight ); // Set new height |
| 1376 |
el.css( "width", width * ratio ); // Scale width based on ratio |
| 1377 |
width = width * ratio; // Reset width to match scaled image |
| 1378 |
height = height * ratio; // Reset height to match scaled image |
| 1379 |
|
| 1380 |
|
| 1381 |
} else { |
| 1382 |
el.css( "height", 'auto' ); // Set new height |
| 1383 |
|
| 1384 |
} |
| 1385 |
|
| 1386 |
var test = ($( document.getElementById( 'redux-header' ) ).height() - el.height()) / 2; |
| 1387 |
if ( test > 0 ) { |
| 1388 |
el.css( "margin-top", test ); |
| 1389 |
} else { |
| 1390 |
el.css( "margin-top", 0 ); |
| 1391 |
} |
| 1392 |
|
| 1393 |
if ( $( '#redux-header .redux_field_search' ) ) { |
| 1394 |
$( '#redux-header .redux_field_search' ).css( 'right', ($( el ).width() + 20) ); |
| 1395 |
} |
| 1396 |
|
| 1397 |
|
| 1398 |
}; |
| 1399 |
$.redux.resizeAds = function() { |
| 1400 |
var el = $( '#redux-header' ); |
| 1401 |
var maxWidth; |
| 1402 |
if ( el.length ) { |
| 1403 |
maxWidth = el.width() - el.find( '.display_header' ).width() - 30; |
| 1404 |
} else { |
| 1405 |
el = $( '#customize-info' ); |
| 1406 |
maxWidth = el.width(); |
| 1407 |
} |
| 1408 |
|
| 1409 |
var maxHeight = el.height(); |
| 1410 |
var rAds = el.find( '.rAds' ); |
| 1411 |
|
| 1412 |
$( rAds ).find( 'video' ).each( |
| 1413 |
function() { |
| 1414 |
$.redux.scaleToRatio( $( this ), maxHeight, maxWidth ); |
| 1415 |
} |
| 1416 |
); |
| 1417 |
$( rAds ).find( 'img' ).each( |
| 1418 |
function() { |
| 1419 |
$.redux.scaleToRatio( $( this ), maxHeight, maxWidth ); |
| 1420 |
} |
| 1421 |
); |
| 1422 |
$( rAds ).find( 'div' ).each( |
| 1423 |
function() { |
| 1424 |
$.redux.scaleToRatio( $( this ), maxHeight, maxWidth ); |
| 1425 |
} |
| 1426 |
); |
| 1427 |
|
| 1428 |
if ( rAds.css( 'left' ) == "-99999px" ) { |
| 1429 |
rAds.css( 'display', 'none' ).css( 'left', 'auto' ); |
| 1430 |
} |
| 1431 |
rAds.fadeIn( 'slow' ); |
| 1432 |
}; |
| 1433 |
$( document ).ready( |
| 1434 |
function() { |
| 1435 |
if ( redux.rAds ) { |
| 1436 |
var el; |
| 1437 |
if ( $( '#redux-header' ).length > 0 ) { |
| 1438 |
$( '#redux-header' ).append( '<div class="rAds"></div>' ); |
| 1439 |
el = $( '#redux-header' ); |
| 1440 |
} else { |
| 1441 |
$( '#customize-theme-controls ul' ).first().prepend( |
| 1442 |
'<li id="redux_rAds" class="accordion-section rAdsContainer" style="position: relative;"><div class="rAds"></div></li>' ); |
| 1443 |
el = $( '#redux_rAds' ); |
| 1444 |
} |
| 1445 |
|
| 1446 |
el.css( 'position', 'relative' ); |
| 1447 |
el.find( '.rAds' ).attr( |
| 1448 |
'style', |
| 1449 |
'position:absolute; top: 6px; right: 9px; display:block !important;overflow:hidden;' |
| 1450 |
).css( 'left', '-99999px' ); |
| 1451 |
el.find( '.rAds' ).html( redux.rAds.replace( /<br\s?\/?>/, '' ) ); |
| 1452 |
var rAds = el.find( '.rAds' ); |
| 1453 |
|
| 1454 |
$( rAds ).hide(); |
| 1455 |
rAds.bind( "DOMSubtreeModified", function() { |
| 1456 |
if ( $( this ).html().indexOf( "<a href" ) >= 0 ) { |
| 1457 |
rAds.find( 'img' ).css( 'visibility', 'hidden' ); |
| 1458 |
setTimeout( function() { |
| 1459 |
rAds.show(); |
| 1460 |
$.redux.resizeAds(); |
| 1461 |
}, 400 ); |
| 1462 |
rAds.find( 'img' ).css( 'visibility', 'inherit' ); |
| 1463 |
rAds.unbind( "DOMSubtreeModified" ); |
| 1464 |
} |
| 1465 |
|
| 1466 |
} ); |
| 1467 |
$( window ).resize( |
| 1468 |
function() { |
| 1469 |
$.redux.resizeAds(); |
| 1470 |
} |
| 1471 |
); |
| 1472 |
|
| 1473 |
} |
| 1474 |
} |
| 1475 |
); |
| 1476 |
})( jQuery ); |
| 1477 |
|
| 1478 |
jQuery.noConflict(); |
| 1479 |
|
| 1480 |
var confirmOnPageExit = function( e ) { |
| 1481 |
//return; // ONLY FOR DEBUGGING |
| 1482 |
// If we haven't been passed the event get the window.event |
| 1483 |
e = e || window.event; |
| 1484 |
|
| 1485 |
var message = redux.args.save_pending; |
| 1486 |
|
| 1487 |
// For IE6-8 and Firefox prior to version 4 |
| 1488 |
if ( e ) { |
| 1489 |
e.returnValue = message; |
| 1490 |
} |
| 1491 |
|
| 1492 |
window.onbeforeunload = null; |
| 1493 |
|
| 1494 |
// For Chrome, Safari, IE8+ and Opera 12+ |
| 1495 |
return message; |
| 1496 |
}; |
| 1497 |
|
| 1498 |
function redux_change( variable ) { |
| 1499 |
variable = jQuery(variable); |
| 1500 |
|
| 1501 |
jQuery( 'body' ).trigger( 'check_dependencies', variable ); |
| 1502 |
|
| 1503 |
if ( variable.hasClass( 'compiler' ) ) { |
| 1504 |
jQuery( '#redux-compiler-hook' ).val( 1 ); |
| 1505 |
} |
| 1506 |
|
| 1507 |
// var test = jQuery( variable ).parents( '.redux-field-container:first' ); |
| 1508 |
// if ( test.hasClass( 'redux-container-typography' ) && redux.field_objects.typography ) { |
| 1509 |
// redux.field_objects.typography.change( test ); |
| 1510 |
// } |
| 1511 |
|
| 1512 |
var rContainer = jQuery( variable ).parents( '.redux-container:first' ); |
| 1513 |
|
| 1514 |
var parentID = jQuery( variable ).closest( '.redux-group-tab' ).attr( 'id' ); |
| 1515 |
|
| 1516 |
// Let's count down the errors now. Fancy. ;) |
| 1517 |
var id = parentID.split( '_' ); |
| 1518 |
id = id[0]; |
| 1519 |
|
| 1520 |
var th = rContainer.find( '.redux-group-tab-link-a[data-key="' + id + '"]' ).parents( '.redux-group-tab-link-li:first' ); |
| 1521 |
var subParent = jQuery( '#' + parentID + '_li' ).parents( '.hasSubSections:first' ); |
| 1522 |
|
| 1523 |
if ( jQuery( variable ).parents( 'fieldset.redux-field:first' ).hasClass( 'redux-field-error' ) ) { |
| 1524 |
jQuery( variable ).parents( 'fieldset.redux-field:first' ).removeClass( 'redux-field-error' ); |
| 1525 |
jQuery( variable ).parent().find( '.redux-th-error' ).slideUp(); |
| 1526 |
|
| 1527 |
var errorCount = (parseInt( rContainer.find( '.redux-field-errors span' ).text() ) - 1); |
| 1528 |
|
| 1529 |
if ( errorCount <= 0 ) { |
| 1530 |
//console.log('HERE'); |
| 1531 |
jQuery( '#' + parentID + '_li .redux-menu-error' ).fadeOut( 'fast' ).remove(); |
| 1532 |
jQuery( '#' + parentID + '_li .redux-group-tab-link-a' ).removeClass( 'hasError' ); |
| 1533 |
|
| 1534 |
jQuery( '#' + parentID + '_li' ).parents( '.inside:first' ).find( '.redux-field-errors' ).slideUp(); |
| 1535 |
jQuery( variable ).parents( '.redux-container:first' ).find( '.redux-field-errors' ).slideUp(); |
| 1536 |
jQuery( '#redux_metaboxes_errors' ).slideUp(); |
| 1537 |
} else { |
| 1538 |
|
| 1539 |
var errorsLeft = (parseInt( th.find( '.redux-menu-error:first' ).text() ) - 1); |
| 1540 |
if ( errorsLeft <= 0 ) { |
| 1541 |
th.find( '.redux-menu-error:first' ).fadeOut().remove(); |
| 1542 |
} else { |
| 1543 |
th.find( '.redux-menu-error:first' ).text( errorsLeft ); |
| 1544 |
} |
| 1545 |
|
| 1546 |
rContainer.find( '.redux-field-errors span' ).text( errorCount ); |
| 1547 |
} |
| 1548 |
|
| 1549 |
if ( subParent.length !== 0 ) { |
| 1550 |
if ( subParent.find( '.redux-menu-error' ).length === 0 ) { |
| 1551 |
subParent.find( '.hasError' ).removeClass( 'hasError' ); |
| 1552 |
} |
| 1553 |
} |
| 1554 |
} |
| 1555 |
if ( jQuery( variable ).parents( 'fieldset.redux-field:first' ).hasClass( 'redux-field-warning' ) ) { |
| 1556 |
jQuery( variable ).parents( 'fieldset.redux-field:first' ).removeClass( 'redux-field-warning' ); |
| 1557 |
jQuery( variable ).parent().find( '.redux-th-warning' ).slideUp(); |
| 1558 |
|
| 1559 |
var warningCount = (parseInt( rContainer.find( '.redux-field-warnings span' ).text() ) - 1); |
| 1560 |
|
| 1561 |
if ( warningCount <= 0 ) { |
| 1562 |
//console.log('HERE'); |
| 1563 |
jQuery( '#' + parentID + '_li .redux-menu-warning' ).fadeOut( 'fast' ).remove(); |
| 1564 |
jQuery( '#' + parentID + '_li .redux-group-tab-link-a' ).removeClass( 'hasWarning' ); |
| 1565 |
|
| 1566 |
jQuery( '#' + parentID + '_li' ).parents( '.inside:first' ).find( '.redux-field-warnings' ).slideUp(); |
| 1567 |
jQuery( variable ).parents( '.redux-container:first' ).find( '.redux-field-warnings' ).slideUp(); |
| 1568 |
jQuery( '#redux_metaboxes_warnings' ).slideUp(); |
| 1569 |
} else { |
| 1570 |
// Let's count down the warnings now. Fancy. ;) |
| 1571 |
|
| 1572 |
var warningsLeft = (parseInt( th.find( '.redux-menu-warning:first' ).text() ) - 1); |
| 1573 |
if ( warningsLeft <= 0 ) { |
| 1574 |
th.find( '.redux-menu-warning:first' ).fadeOut().remove(); |
| 1575 |
} else { |
| 1576 |
th.find( '.redux-menu-warning:first' ).text( warningsLeft ); |
| 1577 |
} |
| 1578 |
|
| 1579 |
rContainer.find( '.redux-field-warning span' ).text( warningCount ); |
| 1580 |
|
| 1581 |
} |
| 1582 |
if ( subParent.length !== 0 ) { |
| 1583 |
if ( subParent.find( '.redux-menu-warning' ).length === 0 ) { |
| 1584 |
subParent.find( '.hasWarning' ).removeClass( 'hasWarning' ); |
| 1585 |
} |
| 1586 |
} |
| 1587 |
} |
| 1588 |
// Don't show the changed value notice while save_notice is visible. |
| 1589 |
if ( rContainer.find( '.saved_notice:visible' ).length > 0 ) { |
| 1590 |
return; |
| 1591 |
} |
| 1592 |
|
| 1593 |
if ( !redux.args.disable_save_warn ) { |
| 1594 |
rContainer.find( '.redux-save-warn' ).slideDown(); |
| 1595 |
window.onbeforeunload = confirmOnPageExit; |
| 1596 |
} |
| 1597 |
} |
| 1598 |
|
| 1599 |
function colorValidate( field ) { |
| 1600 |
var value = jQuery( field ).val(); |
| 1601 |
|
| 1602 |
var hex = colorNameToHex( value ); |
| 1603 |
if ( hex !== value.replace( '#', '' ) ) { |
| 1604 |
return hex; |
| 1605 |
} |
| 1606 |
|
| 1607 |
return value; |
| 1608 |
} |
| 1609 |
|
| 1610 |
function colorNameToHex( colour ) { |
| 1611 |
var tcolour = colour.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ).replace( "#", "" ); |
| 1612 |
|
| 1613 |
var colours = { |
| 1614 |
"aliceblue": "#f0f8ff", |
| 1615 |
"antiquewhite": "#faebd7", |
| 1616 |
"aqua": "#00ffff", |
| 1617 |
"aquamarine": "#7fffd4", |
| 1618 |
"azure": "#f0ffff", |
| 1619 |
"beige": "#f5f5dc", |
| 1620 |
"bisque": "#ffe4c4", |
| 1621 |
"black": "#000000", |
| 1622 |
"blanchedalmond": "#ffebcd", |
| 1623 |
"blue": "#0000ff", |
| 1624 |
"blueviolet": "#8a2be2", |
| 1625 |
"brown": "#a52a2a", |
| 1626 |
"burlywood": "#deb887", |
| 1627 |
"cadetblue": "#5f9ea0", |
| 1628 |
"chartreuse": "#7fff00", |
| 1629 |
"chocolate": "#d2691e", |
| 1630 |
"coral": "#ff7f50", |
| 1631 |
"cornflowerblue": "#6495ed", |
| 1632 |
"cornsilk": "#fff8dc", |
| 1633 |
"crimson": "#dc143c", |
| 1634 |
"cyan": "#00ffff", |
| 1635 |
"darkblue": "#00008b", |
| 1636 |
"darkcyan": "#008b8b", |
| 1637 |
"darkgoldenrod": "#b8860b", |
| 1638 |
"darkgray": "#a9a9a9", |
| 1639 |
"darkgreen": "#006400", |
| 1640 |
"darkkhaki": "#bdb76b", |
| 1641 |
"darkmagenta": "#8b008b", |
| 1642 |
"darkolivegreen": "#556b2f", |
| 1643 |
"darkorange": "#ff8c00", |
| 1644 |
"darkorchid": "#9932cc", |
| 1645 |
"darkred": "#8b0000", |
| 1646 |
"darksalmon": "#e9967a", |
| 1647 |
"darkseagreen": "#8fbc8f", |
| 1648 |
"darkslateblue": "#483d8b", |
| 1649 |
"darkslategray": "#2f4f4f", |
| 1650 |
"darkturquoise": "#00ced1", |
| 1651 |
"darkviolet": "#9400d3", |
| 1652 |
"deeppink": "#ff1493", |
| 1653 |
"deepskyblue": "#00bfff", |
| 1654 |
"dimgray": "#696969", |
| 1655 |
"dodgerblue": "#1e90ff", |
| 1656 |
"firebrick": "#b22222", |
| 1657 |
"floralwhite": "#fffaf0", |
| 1658 |
"forestgreen": "#228b22", |
| 1659 |
"fuchsia": "#ff00ff", |
| 1660 |
"gainsboro": "#dcdcdc", |
| 1661 |
"ghostwhite": "#f8f8ff", |
| 1662 |
"gold": "#ffd700", |
| 1663 |
"goldenrod": "#daa520", |
| 1664 |
"gray": "#808080", |
| 1665 |
"green": "#008000", |
| 1666 |
"greenyellow": "#adff2f", |
| 1667 |
"honeydew": "#f0fff0", |
| 1668 |
"hotpink": "#ff69b4", |
| 1669 |
"indianred ": "#cd5c5c", |
| 1670 |
"indigo ": "#4b0082", |
| 1671 |
"ivory": "#fffff0", |
| 1672 |
"khaki": "#f0e68c", |
| 1673 |
"lavender": "#e6e6fa", |
| 1674 |
"lavenderblush": "#fff0f5", |
| 1675 |
"lawngreen": "#7cfc00", |
| 1676 |
"lemonchiffon": "#fffacd", |
| 1677 |
"lightblue": "#add8e6", |
| 1678 |
"lightcoral": "#f08080", |
| 1679 |
"lightcyan": "#e0ffff", |
| 1680 |
"lightgoldenrodyellow": "#fafad2", |
| 1681 |
"lightgrey": "#d3d3d3", |
| 1682 |
"lightgreen": "#90ee90", |
| 1683 |
"lightpink": "#ffb6c1", |
| 1684 |
"lightsalmon": "#ffa07a", |
| 1685 |
"lightseagreen": "#20b2aa", |
| 1686 |
"lightskyblue": "#87cefa", |
| 1687 |
"lightslategray": "#778899", |
| 1688 |
"lightsteelblue": "#b0c4de", |
| 1689 |
"lightyellow": "#ffffe0", |
| 1690 |
"lime": "#00ff00", |
| 1691 |
"limegreen": "#32cd32", |
| 1692 |
"linen": "#faf0e6", |
| 1693 |
"magenta": "#ff00ff", |
| 1694 |
"maroon": "#800000", |
| 1695 |
"mediumaquamarine": "#66cdaa", |
| 1696 |
"mediumblue": "#0000cd", |
| 1697 |
"mediumorchid": "#ba55d3", |
| 1698 |
"mediumpurple": "#9370d8", |
| 1699 |
"mediumseagreen": "#3cb371", |
| 1700 |
"mediumslateblue": "#7b68ee", |
| 1701 |
"mediumspringgreen": "#00fa9a", |
| 1702 |
"mediumturquoise": "#48d1cc", |
| 1703 |
"mediumvioletred": "#c71585", |
| 1704 |
"midnightblue": "#191970", |
| 1705 |
"mintcream": "#f5fffa", |
| 1706 |
"mistyrose": "#ffe4e1", |
| 1707 |
"moccasin": "#ffe4b5", |
| 1708 |
"navajowhite": "#ffdead", |
| 1709 |
"navy": "#000080", |
| 1710 |
"oldlace": "#fdf5e6", |
| 1711 |
"olive": "#808000", |
| 1712 |
"olivedrab": "#6b8e23", |
| 1713 |
"orange": "#ffa500", |
| 1714 |
"orangered": "#ff4500", |
| 1715 |
"orchid": "#da70d6", |
| 1716 |
"palegoldenrod": "#eee8aa", |
| 1717 |
"palegreen": "#98fb98", |
| 1718 |
"paleturquoise": "#afeeee", |
| 1719 |
"palevioletred": "#d87093", |
| 1720 |
"papayawhip": "#ffefd5", |
| 1721 |
"peachpuff": "#ffdab9", |
| 1722 |
"peru": "#cd853f", |
| 1723 |
"pink": "#ffc0cb", |
| 1724 |
"plum": "#dda0dd", |
| 1725 |
"powderblue": "#b0e0e6", |
| 1726 |
"purple": "#800080", |
| 1727 |
"red": "#ff0000", |
| 1728 |
"redux": "#01a3e3", |
| 1729 |
"rosybrown": "#bc8f8f", |
| 1730 |
"royalblue": "#4169e1", |
| 1731 |
"saddlebrown": "#8b4513", |
| 1732 |
"salmon": "#fa8072", |
| 1733 |
"sandybrown": "#f4a460", |
| 1734 |
"seagreen": "#2e8b57", |
| 1735 |
"seashell": "#fff5ee", |
| 1736 |
"sienna": "#a0522d", |
| 1737 |
"silver": "#c0c0c0", |
| 1738 |
"skyblue": "#87ceeb", |
| 1739 |
"slateblue": "#6a5acd", |
| 1740 |
"slategray": "#708090", |
| 1741 |
"snow": "#fffafa", |
| 1742 |
"springgreen": "#00ff7f", |
| 1743 |
"steelblue": "#4682b4", |
| 1744 |
"tan": "#d2b48c", |
| 1745 |
"teal": "#008080", |
| 1746 |
"thistle": "#d8bfd8", |
| 1747 |
"tomato": "#ff6347", |
| 1748 |
"turquoise": "#40e0d0", |
| 1749 |
"violet": "#ee82ee", |
| 1750 |
"wheat": "#f5deb3", |
| 1751 |
"white": "#ffffff", |
| 1752 |
"whitesmoke": "#f5f5f5", |
| 1753 |
"yellow": "#ffff00", |
| 1754 |
"yellowgreen": "#9acd32" |
| 1755 |
}; |
| 1756 |
|
| 1757 |
if ( colours[tcolour.toLowerCase()] !== 'undefined' ) { |
| 1758 |
return colours[tcolour.toLowerCase()]; |
| 1759 |
} |
| 1760 |
|
| 1761 |
return colour; |
| 1762 |
} |
| 1763 |
|
| 1764 |
function redux_hook( object, functionName, callback, before ) { |
| 1765 |
(function( originalFunction ) { |
| 1766 |
object[functionName] = function() { |
| 1767 |
|
| 1768 |
if ( before === true ) { |
| 1769 |
callback.apply( this, [returnValue, originalFunction, arguments] ); |
| 1770 |
} |
| 1771 |
var returnValue = originalFunction.apply( this, arguments ); |
| 1772 |
if ( before !== true ) { |
| 1773 |
callback.apply( this, [returnValue, originalFunction, arguments] ); |
| 1774 |
} |
| 1775 |
|
| 1776 |
return returnValue; |
| 1777 |
}; |
| 1778 |
}( object[functionName] )); |
| 1779 |
} |
| 1780 |
|