redux.js (60434B)
1 /* global redux, tinyMCE, ajaxurl */ 2 3 (function( $ ) { 4 'use strict'; 5 6 $.redux = $.redux || {}; 7 8 $.redux.ajax_save = function( button ) { 9 var $data; 10 var $nonce; 11 12 var overlay = $( document.getElementById( 'redux_ajax_overlay' ) ); 13 var $notification_bar = $( document.getElementById( 'redux_notification_bar' ) ); 14 var $parent = $( button ).parents( '.redux-wrap-div' ).find( 'form' ).first(); 15 16 overlay.fadeIn(); 17 18 // Add the loading mechanism. 19 $( '.redux-action_bar .spinner' ).addClass( 'is-active' ); 20 $( '.redux-action_bar input' ).prop( 'disabled', true ); 21 22 $notification_bar.slideUp(); 23 24 $( '.redux-save-warn' ).slideUp(); 25 $( '.redux_ajax_save_error' ).slideUp( 26 'medium', 27 function() { 28 $( this ).remove(); 29 } 30 ); 31 32 // Editor field doesn't auto save. Have to call it. Boo. 33 if ( redux.optName.hasOwnProperty( 'editor' ) ) { 34 $.each( 35 redux.optName.editor, 36 function( $key ) { 37 var editor; 38 39 if ( 'undefined' !== typeof ( tinyMCE ) ) { 40 editor = tinyMCE.get( $key ); 41 42 if ( editor ) { 43 editor.save(); 44 } 45 } 46 } 47 ); 48 } 49 50 $data = $parent.serialize(); 51 52 // Add values for checked and unchecked checkboxes fields. 53 $parent.find( 'input[type=checkbox]' ).each( 54 function() { 55 var chkVal; 56 57 if ( 'undefined' !== typeof $( this ).attr( 'name' ) ) { 58 chkVal = $( this ).is( ':checked' ) ? $( this ).val() : '0'; 59 60 $data += '&' + $( this ).attr( 'name' ) + '=' + chkVal; 61 } 62 } 63 ); 64 65 if ( 'redux_save' !== button.attr( 'name' ) ) { 66 $data += '&' + button.attr( 'name' ) + '=' + button.val(); 67 } 68 69 $nonce = $parent.attr( 'data-nonce' ); 70 71 $.ajax( 72 { type: 'post', 73 dataType: 'json', 74 url: ajaxurl, 75 data: { 76 action: redux.optName.args.opt_name + '_ajax_save', 77 nonce: $nonce, 78 'opt_name': redux.optName.args.opt_name, 79 data: $data 80 }, 81 error: function( response ) { 82 $( '.redux-action_bar input' ).prop( 'disabled', false ); 83 84 if ( true === redux.optName.args.dev_mode ) { 85 console.log( response.responseText ); 86 87 overlay.fadeOut( 'fast' ); 88 $( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); 89 alert( redux.optName.ajax.alert ); 90 } else { 91 redux.optName.args.ajax_save = false; 92 93 $( button ).trigger( 'click' ); 94 $( '.redux-action_bar input' ).prop( 'disabled', true ); 95 } 96 }, 97 success: function( response ) { 98 var $save_notice; 99 100 if ( response.action && 'reload' === response.action ) { 101 location.reload( true ); 102 } else if ( 'success' === response.status ) { 103 $( '.redux-action_bar input' ).prop( 'disabled', false ); 104 overlay.fadeOut( 'fast' ); 105 $( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); 106 redux.optName.options = response.options; 107 redux.optName.errors = response.errors; 108 redux.optName.warnings = response.warnings; 109 redux.optName.sanitize = response.sanitize; 110 111 $notification_bar.html( response.notification_bar ).slideDown( 'fast' ); 112 if ( null !== response.errors || null !== response.warnings ) { 113 $.redux.notices(); 114 } 115 116 if ( null !== response.sanitize ) { 117 $.redux.sanitize(); 118 } 119 120 $save_notice = $( document.getElementById( 'redux_notification_bar' ) ).find( '.saved_notice' ); 121 122 $save_notice.slideDown(); 123 $save_notice.delay( 4000 ).slideUp(); 124 } else { 125 $( '.redux-action_bar input' ).prop( 'disabled', false ); 126 $( '.redux-action_bar .spinner' ).removeClass( 'is-active' ); 127 overlay.fadeOut( 'fast' ); 128 $( '.wrap h2:first' ).parent().append( '<div class="error redux_ajax_save_error" style="display:none;"><p>' + response.status + '</p></div>' ); 129 $( '.redux_ajax_save_error' ).slideDown(); 130 $( 'html, body' ).animate( 131 { scrollTop: 0 }, 132 'slow' 133 ); 134 } 135 } 136 } 137 ); 138 139 return false; 140 }; 141 })( jQuery ); 142 143 /* jshint unused:false */ 144 145 function colorValidate( field ) { 146 'use strict'; 147 148 var value = jQuery( field ).val(); 149 150 var hex = colorNameToHex( value ); 151 if ( hex !== value.replace( '#', '' ) ) { 152 return hex; 153 } 154 155 return value; 156 } 157 158 function colorNameToHex( colour ) { 159 'use strict'; 160 161 var tcolour = colour.replace( /^\s\s*/, '' ).replace( /\s\s*$/, '' ).replace( '#', '' ); 162 163 var colours = { 164 'aliceblue': '#f0f8ff', 165 'antiquewhite': '#faebd7', 166 'aqua': '#00ffff', 167 'aquamarine': '#7fffd4', 168 'azure': '#f0ffff', 169 'beige': '#f5f5dc', 170 'bisque': '#ffe4c4', 171 'black': '#000000', 172 'blanchedalmond': '#ffebcd', 173 'blue': '#0000ff', 174 'blueviolet': '#8a2be2', 175 'brown': '#a52a2a', 176 'burlywood': '#deb887', 177 'cadetblue': '#5f9ea0', 178 'chartreuse': '#7fff00', 179 'chocolate': '#d2691e', 180 'coral': '#ff7f50', 181 'cornflowerblue': '#6495ed', 182 'cornsilk': '#fff8dc', 183 'crimson': '#dc143c', 184 'cyan': '#00ffff', 185 'darkblue': '#00008b', 186 'darkcyan': '#008b8b', 187 'darkgoldenrod': '#b8860b', 188 'darkgray': '#a9a9a9', 189 'darkgreen': '#006400', 190 'darkkhaki': '#bdb76b', 191 'darkmagenta': '#8b008b', 192 'darkolivegreen': '#556b2f', 193 'darkorange': '#ff8c00', 194 'darkorchid': '#9932cc', 195 'darkred': '#8b0000', 196 'darksalmon': '#e9967a', 197 'darkseagreen': '#8fbc8f', 198 'darkslateblue': '#483d8b', 199 'darkslategray': '#2f4f4f', 200 'darkturquoise': '#00ced1', 201 'darkviolet': '#9400d3', 202 'deeppink': '#ff1493', 203 'deepskyblue': '#00bfff', 204 'dimgray': '#696969', 205 'dodgerblue': '#1e90ff', 206 'firebrick': '#b22222', 207 'floralwhite': '#fffaf0', 208 'forestgreen': '#228b22', 209 'fuchsia': '#ff00ff', 210 'gainsboro': '#dcdcdc', 211 'ghostwhite': '#f8f8ff', 212 'gold': '#ffd700', 213 'goldenrod': '#daa520', 214 'gray': '#808080', 215 'green': '#008000', 216 'greenyellow': '#adff2f', 217 'honeydew': '#f0fff0', 218 'hotpink': '#ff69b4', 219 'indianred ': '#cd5c5c', 220 'indigo ': '#4b0082', 221 'ivory': '#fffff0', 222 'khaki': '#f0e68c', 223 'lavender': '#e6e6fa', 224 'lavenderblush': '#fff0f5', 225 'lawngreen': '#7cfc00', 226 'lemonchiffon': '#fffacd', 227 'lightblue': '#add8e6', 228 'lightcoral': '#f08080', 229 'lightcyan': '#e0ffff', 230 'lightgoldenrodyellow': '#fafad2', 231 'lightgrey': '#d3d3d3', 232 'lightgreen': '#90ee90', 233 'lightpink': '#ffb6c1', 234 'lightsalmon': '#ffa07a', 235 'lightseagreen': '#20b2aa', 236 'lightskyblue': '#87cefa', 237 'lightslategray': '#778899', 238 'lightsteelblue': '#b0c4de', 239 'lightyellow': '#ffffe0', 240 'lime': '#00ff00', 241 'limegreen': '#32cd32', 242 'linen': '#faf0e6', 243 'magenta': '#ff00ff', 244 'maroon': '#800000', 245 'mediumaquamarine': '#66cdaa', 246 'mediumblue': '#0000cd', 247 'mediumorchid': '#ba55d3', 248 'mediumpurple': '#9370d8', 249 'mediumseagreen': '#3cb371', 250 'mediumslateblue': '#7b68ee', 251 'mediumspringgreen': '#00fa9a', 252 'mediumturquoise': '#48d1cc', 253 'mediumvioletred': '#c71585', 254 'midnightblue': '#191970', 255 'mintcream': '#f5fffa', 256 'mistyrose': '#ffe4e1', 257 'moccasin': '#ffe4b5', 258 'navajowhite': '#ffdead', 259 'navy': '#000080', 260 'oldlace': '#fdf5e6', 261 'olive': '#808000', 262 'olivedrab': '#6b8e23', 263 'orange': '#ffa500', 264 'orangered': '#ff4500', 265 'orchid': '#da70d6', 266 'palegoldenrod': '#eee8aa', 267 'palegreen': '#98fb98', 268 'paleturquoise': '#afeeee', 269 'palevioletred': '#d87093', 270 'papayawhip': '#ffefd5', 271 'peachpuff': '#ffdab9', 272 'peru': '#cd853f', 273 'pink': '#ffc0cb', 274 'plum': '#dda0dd', 275 'powderblue': '#b0e0e6', 276 'purple': '#800080', 277 'red': '#ff0000', 278 'redux': '#01a3e3', 279 'rosybrown': '#bc8f8f', 280 'royalblue': '#4169e1', 281 'saddlebrown': '#8b4513', 282 'salmon': '#fa8072', 283 'sandybrown': '#f4a460', 284 'seagreen': '#2e8b57', 285 'seashell': '#fff5ee', 286 'sienna': '#a0522d', 287 'silver': '#c0c0c0', 288 'skyblue': '#87ceeb', 289 'slateblue': '#6a5acd', 290 'slategray': '#708090', 291 'snow': '#fffafa', 292 'springgreen': '#00ff7f', 293 'steelblue': '#4682b4', 294 'tan': '#d2b48c', 295 'teal': '#008080', 296 'thistle': '#d8bfd8', 297 'tomato': '#ff6347', 298 'turquoise': '#40e0d0', 299 'violet': '#ee82ee', 300 'wheat': '#f5deb3', 301 'white': '#ffffff', 302 'whitesmoke': '#f5f5f5', 303 'yellow': '#ffff00', 304 'yellowgreen': '#9acd32' 305 }; 306 307 if ( 'undefined' !== colours[tcolour.toLowerCase()] ) { 308 return colours[tcolour.toLowerCase()]; 309 } 310 311 return colour; 312 } 313 314 (function( $ ) { 315 'use strict'; 316 317 $.redux = $.redux || {}; 318 319 $.redux.expandOptions = function( parent ) { 320 var trigger = parent.find( '.expand_options' ); 321 var width = parent.find( '.redux-sidebar' ).width() - 1; 322 var id = $( '.redux-group-menu .active a' ).data( 'rel' ) + '_section_group'; 323 324 if ( trigger.hasClass( 'expanded' ) ) { 325 trigger.removeClass( 'expanded' ); 326 parent.find( '.redux-main' ).removeClass( 'expand' ); 327 328 parent.find( '.redux-sidebar' ).stop().animate( 329 { 'margin-left': '0px' }, 330 500 331 ); 332 333 parent.find( '.redux-main' ).stop().animate( 334 { 'margin-left': width }, 335 500, 336 function() { 337 parent.find( '.redux-main' ).attr( 'style', '' ); 338 } 339 ); 340 341 parent.find( '.redux-group-tab' ).each( 342 function() { 343 if ( $( this ).attr( 'id' ) !== id ) { 344 $( this ).fadeOut( 'fast' ); 345 } 346 } 347 ); 348 349 // Show the only active one. 350 } else { 351 trigger.addClass( 'expanded' ); 352 parent.find( '.redux-main' ).addClass( 'expand' ); 353 354 parent.find( '.redux-sidebar' ).stop().animate( 355 { 'margin-left': - width - 113 }, 356 500 357 ); 358 359 parent.find( '.redux-main' ).stop().animate( 360 { 'margin-left': '-1px' }, 361 500 362 ); 363 364 parent.find( '.redux-group-tab' ).fadeIn( 365 'medium', 366 function() { 367 $.redux.initFields(); 368 } 369 ); 370 } 371 372 return false; 373 }; 374 })( jQuery ); 375 376 /* global redux, redux_change, jQuery, pagenow, ajaxurl */ 377 378 (function( $ ) { 379 'use strict'; 380 381 $.redux = $.redux || {}; 382 383 $.redux.initEvents = function( el ) { 384 var stickyHeight; 385 var search = window.location.search; 386 var curPage = pagenow; 387 var dialog; 388 var messageDialog; 389 390 if ( 'string' === typeof search && 'string' === typeof curPage && true === redux.optName.args.dev_mode ) { 391 search = search.replace( '?page=', '' ); 392 curPage = curPage.replace( 'toplevel_page_', '' ); 393 394 if ( search === curPage ) { 395 document.addEventListener( 396 'keydown', 397 function( event ) { 398 if ( event.ctrlKey && event.shiftKey && 'H' === event.key ) { 399 dialog.dialog( 'open' ); 400 } 401 } 402 ); 403 404 messageDialog = $( '#redux-dialog-message' ).dialog( 405 { 406 classes: { 407 'ui-dialog': 'redux-message-dialog', 408 'ui-dialog-buttonpane': 'redux-message-dialog-buttonpane', 409 'ui-dialog-title': 'redux-message-dialog-title', 410 'ui-dialog-content': 'redux-message-dialog-content' 411 }, 412 modal: true, 413 autoOpen: false, 414 resizable: false, 415 height: 'auto', 416 width: 400, 417 buttons: { 418 Ok: function() { 419 $( this ).dialog( 'close' ); 420 } 421 } 422 } 423 ); 424 425 dialog = $( '#redux-dialog-confirm' ).dialog( 426 { 427 modal: true, 428 classes: { 429 'ui-dialog': 'redux-support-dialog' 430 }, 431 autoOpen: false, 432 resizable: false, 433 height: 'auto', 434 width: 400, 435 buttons: { 436 Submit: function() { 437 var buttonPane = $( '.redux-message-dialog-buttonpane' ); 438 var dialogTitle = $( '.redux-message-dialog-title' ); 439 var content = $( '.redux-message-dialog-content .redux-message-p' ); 440 441 $.ajax( 442 { type: 'post', 443 dataType: 'json', 444 url: ajaxurl, 445 data: { 446 action: 'redux_submit_support_data', 447 nonce: $( '#redux-dialog-confirm' ).data( 'nonce' ) 448 }, 449 beforeSend: function() { 450 buttonPane.css( { 'display': 'none' } ); 451 $( '#redux-dialog-message .spinner' ).css( { 'visibility': 'visible' } ); 452 453 messageDialog.dialog( 'open' ); 454 }, 455 error: function( response ) { 456 buttonPane.css( { 'display': 'block' } ); 457 dialogTitle.text( 'Error' ); 458 459 console.log( response ); 460 }, 461 success: function( response ) { 462 buttonPane.css( { 'display': 'block' } ); 463 464 if ( response.status && 'success' === response.status ) { 465 dialogTitle.text( 'Information Sent' ); 466 content.html( 'Your support data has been transmitted. The reference number for this transmission is: <strong>' + response.data + '</strong>' ); 467 } else { 468 dialogTitle.text( 'Error' ); 469 content.text( response.data ); 470 } 471 } 472 } 473 ); 474 475 $( this ).dialog( 'close' ); 476 }, 477 Cancel: function() { 478 $( this ).dialog( 'close' ); 479 } 480 } 481 } 482 ); 483 } 484 } 485 486 el.find( '.redux-presets-bar' ).on( 487 'click', 488 function() { 489 window.onbeforeunload = null; 490 } 491 ); 492 493 // Customizer save hook. 494 el.find( '#customize-save-button-wrapper #save' ).on( 495 'click', 496 function() { 497 498 } 499 ); 500 501 el.find( '#toplevel_page_' + redux.optName.args.slug + ' .wp-submenu a, #wp-admin-bar-' + redux.optName.args.slug + ' a.ab-item' ).on( 502 'click', 503 function( e ) { 504 var url; 505 506 if ( ( el.find( '#toplevel_page_' + redux.optName.args.slug ).hasClass( 'wp-menu-open' ) || 507 $( this ).hasClass( 'ab-item' ) ) && 508 ! $( this ).parents( 'ul.ab-submenu:first' ).hasClass( 'ab-sub-secondary' ) && 509 $( this ).attr( 'href' ).toLowerCase().indexOf( redux.optName.args.slug + '&tab=' ) >= 0 ) { 510 511 url = $( this ).attr( 'href' ).split( '&tab=' ); 512 513 e.preventDefault(); 514 515 el.find( '#' + url[1] + '_section_group_li_a' ).trigger( 'click' ); 516 517 $( this ).parents( 'ul:first' ).find( '.current' ).removeClass( 'current' ); 518 $( this ).addClass( 'current' ); 519 $( this ).parent().addClass( 'current' ); 520 521 return false; 522 } 523 } 524 ); 525 526 // Save button clicked. 527 el.find( '.redux-action_bar input, #redux-import-action input' ).on( 528 'click', 529 function( e ) { 530 if ( $( this ).attr( 'name' ) === redux.optName.args.opt_name + '[defaults]' ) { 531 532 // Defaults button clicked. 533 if ( ! confirm( redux.optName.args.reset_confirm ) ) { 534 return false; 535 } 536 } else if ( $( this ).attr( 'name' ) === redux.optName.args.opt_name + '[defaults-section]' ) { 537 538 // Default section clicked. 539 if ( ! confirm( redux.optName.args.reset_section_confirm ) ) { 540 return false; 541 } 542 } else if ( 'import' === $( this ).attr( 'name' ) ) { 543 if ( ! confirm( redux.optName.args.import_section_confirm ) ) { 544 return false; 545 } 546 } 547 548 window.onbeforeunload = null; 549 550 if ( true === redux.optName.args.ajax_save ) { 551 $.redux.ajax_save( $( this ) ); 552 e.preventDefault(); 553 } else { 554 location.reload( true ); 555 } 556 } 557 ); 558 559 $( '.expand_options' ).on( 560 'click', 561 function( e ) { 562 var tab; 563 564 var container = el; 565 566 e.preventDefault(); 567 568 if ( $( container ).hasClass( 'fully-expanded' ) ) { 569 $( container ).removeClass( 'fully-expanded' ); 570 571 tab = $.cookie( 'redux_current_tab_' + redux.optName.args.opt_name ); 572 573 el.find( '#' + tab + '_section_group' ).fadeIn( 574 200, 575 function() { 576 if ( 0 !== el.find( '#redux-footer' ).length ) { 577 $.redux.stickyInfo(); // Race condition fix. 578 } 579 580 $.redux.initFields(); 581 } 582 ); 583 } 584 585 $.redux.expandOptions( $( this ).parents( '.redux-container:first' ) ); 586 587 return false; 588 } 589 ); 590 591 if ( el.find( '.saved_notice' ).is( ':visible' ) ) { 592 el.find( '.saved_notice' ).slideDown(); 593 } 594 595 $( document.body ).on( 596 'change', 597 '.redux-field input, .redux-field textarea, .redux-field select', 598 function() { 599 if ( $( '.redux-container-typography select' ).hasClass( 'ignore-change' ) ) { 600 return; 601 } 602 if ( ! $( this ).hasClass( 'noUpdate' ) && ! $( this ).hasClass( 'no-update' ) ) { 603 redux_change( $( this ) ); 604 } 605 } 606 ); 607 608 stickyHeight = el.find( '#redux-footer' ).height(); 609 610 el.find( '#redux-sticky-padder' ).css( 611 { height: stickyHeight } 612 ); 613 614 el.find( '#redux-footer-sticky' ).removeClass( 'hide' ); 615 616 if ( 0 !== el.find( '#redux-footer' ).length ) { 617 $( window ).on( 618 'scroll', 619 function() { 620 $.redux.stickyInfo(); 621 } 622 ); 623 624 $( window ).on( 625 'resize', 626 function() { 627 $.redux.stickyInfo(); 628 } 629 ); 630 } 631 632 el.find( '.saved_notice' ).delay( 4000 ).slideUp(); 633 }; 634 })( jQuery ); 635 636 /* global redux */ 637 638 (function( $ ) { 639 'use strict'; 640 641 $.redux = $.redux || {}; 642 643 $.redux.initFields = function() { 644 $( '.redux-group-tab:visible' ).find( '.redux-field-init:visible' ).each( 645 function() { 646 var tr; 647 var th; 648 649 var type = $( this ).attr( 'data-type' ); 650 651 if ( 'undefined' !== typeof redux.field_objects && redux.field_objects[type] && redux.field_objects[type] ) { 652 redux.field_objects[type].init(); 653 } 654 655 if ( 'undefined' !== typeof redux.field_objects.pro && ! $.isEmptyObject( redux.field_objects.pro[type] ) && redux.field_objects.pro[type] ) { 656 redux.field_objects.pro[type].init(); 657 } 658 659 if ( ! redux.customizer && $( this ).hasClass( 'redux_remove_th' ) ) { 660 tr = $( this ).parents( 'tr:first' ); 661 th = tr.find( 'th:first' ); 662 663 if ( th.html() && th.html().length > 0 ) { 664 $( this ).prepend( th.html() ); 665 $( this ).find( '.redux_field_th' ).css( 'padding', '0 0 10px 0' ); 666 } 667 668 $( this ).parent().attr( 'colspan', '2' ); 669 670 th.remove(); 671 } 672 } 673 ); 674 }; 675 })( jQuery ); 676 677 /* global redux, document */ 678 679 (function( $ ) { 680 'use strict'; 681 682 $.redux = $.redux || {}; 683 684 $( document ).ready( 685 function() { 686 var opt_name; 687 var tempArr = []; 688 689 $.fn.isOnScreen = function() { 690 var win; 691 var viewport; 692 var bounds; 693 694 if ( ! window ) { 695 return; 696 } 697 698 win = $( window ); 699 viewport = { 700 top: win.scrollTop() 701 }; 702 703 viewport.right = viewport.left + win.width(); 704 viewport.bottom = viewport.top + win.height(); 705 706 bounds = this.offset(); 707 708 bounds.right = bounds.left + this.outerWidth(); 709 bounds.bottom = bounds.top + this.outerHeight(); 710 711 return ( ! ( viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom ) ); 712 }; 713 714 $( 'fieldset.redux-container-divide' ).css( 'display', 'none' ); 715 716 // Weed out multiple instances of duplicate Redux instance. 717 if ( redux.customizer ) { 718 $( '.wp-full-overlay-sidebar' ).addClass( 'redux-container' ); 719 } 720 721 $( '.redux-container' ).each( 722 function() { 723 opt_name = $.redux.getOptName( this ); 724 725 if ( $.inArray( opt_name, tempArr ) === -1 ) { 726 tempArr.push( opt_name ); 727 $.redux.checkRequired( $( this ) ); 728 $.redux.initEvents( $( this ) ); 729 } 730 } 731 ); 732 733 $( '.redux-container' ).on( 734 'click', 735 function() { 736 opt_name = $.redux.getOptName( this ); 737 } 738 ); 739 740 if ( undefined !== redux.optName ) { 741 $.redux.disableFields(); 742 $.redux.hideFields(); 743 $.redux.disableSections(); 744 $.redux.initQtip(); 745 $.redux.tabCheck(); 746 $.redux.notices(); 747 748 if ( 'undefined' === typeof $.redux.flyoutSubmenus ) { 749 $.redux.flyoutSubmenu(); 750 } 751 } 752 } 753 ); 754 755 $.redux.flyoutSubmenu = function() { 756 757 // Close flyouts when a new menu item is activated. 758 $( '.redux-group-tab-link-li a' ).on( 759 'click', 760 function() { 761 if ( true === redux.optName.args.flyout_submenus ) { 762 $( '.redux-group-tab-link-li' ).removeClass( 'redux-section-hover' ); 763 } 764 } 765 ); 766 767 if ( true === redux.optName.args.flyout_submenus ) { 768 769 // Submenus flyout when a main menu item is hovered. 770 $( '.redux-group-tab-link-li.hasSubSections' ).each( 771 function() { 772 $( this ).on( 773 'mouseenter', 774 function() { 775 if ( ! $( this ).hasClass( 'active' ) && ! $( this ).hasClass( 'activeChild' ) ) { 776 $( this ).addClass( 'redux-section-hover' ); 777 } 778 } 779 ); 780 781 $( this ).on( 782 'mouseleave', 783 function() { 784 $( this ).removeClass( 'redux-section-hover' ); 785 } 786 ); 787 } 788 ); 789 } 790 }; 791 792 $.redux.disableSections = function() { 793 $( '.redux-group-tab' ).each( 794 function() { 795 if ( $( this ).hasClass( 'disabled' ) ) { 796 $( this ).find( 'input, select, textarea' ).attr( 'name', '' ); 797 } 798 } 799 ); 800 }; 801 802 $.redux.disableFields = function() { 803 $( 'label[for="redux_disable_field"]' ).each( 804 function() { 805 $( this ).parents( 'tr' ).find( 'fieldset:first' ).find( 'input, select, textarea' ).attr( 'name', '' ); 806 } 807 ); 808 }; 809 810 $.redux.hideFields = function() { 811 $( 'label[for="redux_hide_field"]' ).each( 812 function() { 813 var tr = $( this ).parent().parent(); 814 815 $( tr ).addClass( 'hidden' ); 816 } 817 ); 818 }; 819 820 $.redux.getOptName = function( el ) { 821 var metabox; 822 var li; 823 var optName; 824 var item = $( el ); 825 826 if ( redux.customizer ) { 827 optName = item.find( '.redux-customizer-opt-name' ).data( 'opt-name' ); 828 } else { 829 optName = $( el ).parents( '.redux-wrap-div' ).data( 'opt-name' ); 830 } 831 832 // Compatibility for metaboxes 833 if ( undefined === optName ) { 834 metabox = $( el ).parents( '.postbox' ); 835 if ( 0 === metabox.length ) { 836 metabox = $( el ).parents( '.redux-metabox' ); 837 } 838 if ( 0 !== metabox.length ) { 839 optName = metabox.attr( 'id' ).replace( 'redux-', '' ).split( '-metabox-' )[0]; 840 if ( undefined === optName ) { 841 optName = metabox.attr( 'class' ) 842 .replace( 'redux-metabox', '' ) 843 .replace( 'postbox', '' ) 844 .replace( 'redux-', '' ) 845 .replace( 'hide', '' ) 846 .replace( 'closed', '' ) 847 .trim(); 848 } 849 } else { 850 optName = $( '.redux-ajax-security' ).data( 'opt-name' ); 851 } 852 } 853 if ( undefined === optName ) { 854 optName = $( el ).find( '.redux-form-wrapper' ).data( 'opt-name' ); 855 } 856 857 // Shim, let's just get an opt_name shall we?! 858 if ( undefined === optName ) { 859 optName = redux.opt_names[0]; 860 } 861 862 if ( undefined !== optName ) { 863 redux.optName = window['redux_' + optName.replace( /\-/g, '_' )]; 864 } 865 866 return optName; 867 }; 868 869 $.redux.getSelector = function( selector, fieldType ) { 870 if ( ! selector ) { 871 selector = '.redux-container-' + fieldType + ':visible'; 872 if ( redux.customizer ) { 873 selector = $( document ).find( '.control-section-redux.open' ).find( selector ); 874 } else { 875 selector = $( document ).find( '.redux-group-tab:visible' ).find( selector ); 876 } 877 } 878 return selector; 879 }; 880 })( jQuery ); 881 882 /* global redux */ 883 884 (function( $ ) { 885 'use strict'; 886 887 $.redux = $.redux || {}; 888 889 $.redux.sanitize = function() { 890 if ( redux.optName.sanitize && redux.optName.sanitize.sanitize ) { 891 $.each( 892 redux.optName.sanitize.sanitize, 893 function( sectionID, sectionArray ) { 894 sectionID = null; 895 $.each( 896 sectionArray.sanitize, 897 function( key, value ) { 898 $.redux.fixInput( key, value ); 899 } 900 ); 901 } 902 ); 903 } 904 }; 905 906 $.redux.fixInput = function( key, value ) { 907 var val; 908 var input; 909 var inputVal; 910 var ul; 911 var li; 912 913 if ( 'multi_text' === value.type ) { 914 ul = $( '#' + value.id + '-ul' ); 915 li = $( ul.find( 'li' ) ); 916 917 li.each( 918 function() { 919 input = $( this ).find( 'input' ); 920 inputVal = input.val(); 921 922 if ( inputVal === value.old ) { 923 input.val( value.current ); 924 } 925 } 926 ); 927 928 return; 929 } 930 931 input = $( 'input#' + value.id + '-' + key ); 932 933 if ( 0 === input.length ) { 934 input = $( 'input#' + value.id ); 935 } 936 937 if ( 0 === input.length ) { 938 input = $( 'textarea#' + value.id + '-textarea' ); 939 } 940 941 if ( input.length > 0 ) { 942 val = '' === value.current ? value.default : value.current; 943 944 $( input ).val( val ); 945 } 946 }; 947 948 $.redux.notices = function() { 949 if ( redux.optName.errors && redux.optName.errors.errors ) { 950 $.each( 951 redux.optName.errors.errors, 952 function( sectionID, sectionArray ) { 953 sectionID = null; 954 $.each( 955 sectionArray.errors, 956 function( key, value ) { 957 $( '#' + redux.optName.args.opt_name + '-' + value.id ).addClass( 'redux-field-error' ); 958 if ( 0 === $( '#' + redux.optName.args.opt_name + '-' + value.id ).parent().find( '.redux-th-error' ).length ) { 959 $( '#' + redux.optName.args.opt_name + '-' + value.id ).append( '<div class="redux-th-error">' + value.msg + '</div>' ); 960 } else { 961 $( '#' + redux.optName.args.opt_name + '-' + value.id ).parent().find( '.redux-th-error' ).html( value.msg ).css( 'display', 'block' ); 962 } 963 964 $.redux.fixInput( key, value ); 965 } 966 ); 967 } 968 ); 969 970 $( '.redux-container' ).each( 971 function() { 972 var totalErrors; 973 974 var container = $( this ); 975 976 // Ajax cleanup. 977 container.find( '.redux-menu-error' ).remove(); 978 979 totalErrors = container.find( '.redux-field-error' ).length; 980 981 if ( totalErrors > 0 ) { 982 container.find( '.redux-field-errors span' ).text( totalErrors ); 983 container.find( '.redux-field-errors' ).slideDown(); 984 container.find( '.redux-group-tab' ).each( 985 function() { 986 var sectionID; 987 var subParent; 988 989 var total = $( this ).find( '.redux-field-error' ).length; 990 if ( total > 0 ) { 991 sectionID = $( this ).attr( 'id' ).split( '_' ); 992 993 sectionID = sectionID[0]; 994 container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).prepend( '<span class="redux-menu-error">' + total + '</span>' ); 995 container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).addClass( 'hasError' ); 996 997 subParent = container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).parents( '.hasSubSections:first' ); 998 999 if ( subParent ) { 1000 subParent.find( '.redux-group-tab-link-a:first' ).addClass( 'hasError' ); 1001 } 1002 } 1003 } 1004 ); 1005 } 1006 } 1007 ); 1008 } 1009 1010 if ( redux.optName.warnings && redux.optName.warnings.warnings ) { 1011 $.each( 1012 redux.optName.warnings.warnings, 1013 function( sectionID, sectionArray ) { 1014 sectionID = null; 1015 $.each( 1016 sectionArray.warnings, 1017 function( key, value ) { 1018 $( '#' + redux.optName.args.opt_name + '-' + value.id ).addClass( 'redux-field-warning' ); 1019 1020 if ( 0 === $( '#' + redux.optName.args.opt_name + '-' + value.id ).parent().find( '.redux-th-warning' ).length ) { 1021 $( '#' + redux.optName.args.opt_name + '-' + value.id ).append( '<div class="redux-th-warning">' + value.msg + '</div>' ); 1022 } else { 1023 $( '#' + redux.optName.args.opt_name + '-' + value.id ).parent().find( '.redux-th-warning' ).html( value.msg ).css( 'display', 'block' ); 1024 } 1025 1026 $.redux.fixInput( key, value ); 1027 } 1028 ); 1029 } 1030 ); 1031 1032 $( '.redux-container' ).each( 1033 function() { 1034 var sectionID; 1035 var subParent; 1036 var total; 1037 var totalWarnings; 1038 1039 var container = $( this ); 1040 1041 // Ajax cleanup. 1042 container.find( '.redux-menu-warning' ).remove(); 1043 1044 totalWarnings = container.find( '.redux-field-warning' ).length; 1045 1046 if ( totalWarnings > 0 ) { 1047 container.find( '.redux-field-warnings span' ).text( totalWarnings ); 1048 container.find( '.redux-field-warnings' ).slideDown(); 1049 container.find( '.redux-group-tab' ).each( 1050 function() { 1051 total = $( this ).find( '.redux-field-warning' ).length; 1052 1053 if ( total > 0 ) { 1054 sectionID = $( this ).attr( 'id' ).split( '_' ); 1055 1056 sectionID = sectionID[0]; 1057 container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).prepend( '<span class="redux-menu-warning">' + total + '</span>' ); 1058 container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).addClass( 'hasWarning' ); 1059 1060 subParent = container.find( '.redux-group-tab-link-a[data-key="' + sectionID + '"]' ).parents( '.hasSubSections:first' ); 1061 1062 if ( subParent ) { 1063 subParent.find( '.redux-group-tab-link-a:first' ).addClass( 'hasWarning' ); 1064 } 1065 } 1066 } 1067 ); 1068 } 1069 } 1070 ); 1071 } 1072 }; 1073 })( jQuery ); 1074 1075 /* global redux */ 1076 1077 (function( $ ) { 1078 'use strict'; 1079 1080 $.redux = $.redux || {}; 1081 1082 $.redux.initQtip = function() { 1083 var classes; 1084 1085 // Shadow. 1086 var shadow = ''; 1087 var tipShadow = redux.optName.args.hints.tip_style.shadow; 1088 1089 // Color. 1090 var color = ''; 1091 var tipColor = redux.optName.args.hints.tip_style.color; 1092 1093 // Rounded. 1094 var rounded = ''; 1095 var tipRounded = redux.optName.args.hints.tip_style.rounded; 1096 1097 // Tip style. 1098 var style = ''; 1099 var tipStyle = redux.optName.args.hints.tip_style.style; 1100 1101 // Get position data. 1102 var myPos = redux.optName.args.hints.tip_position.my; 1103 var atPos = redux.optName.args.hints.tip_position.at; 1104 1105 // Tooltip trigger action. 1106 var showEvent = redux.optName.args.hints.tip_effect.show.event; 1107 var hideEvent = redux.optName.args.hints.tip_effect.hide.event; 1108 1109 // Tip show effect. 1110 var tipShowEffect = redux.optName.args.hints.tip_effect.show.effect; 1111 var tipShowDuration = redux.optName.args.hints.tip_effect.show.duration; 1112 1113 // Tip hide effect. 1114 var tipHideEffect = redux.optName.args.hints.tip_effect.hide.effect; 1115 var tipHideDuration = redux.optName.args.hints.tip_effect.hide.duration; 1116 1117 if ( $().qtip ) { 1118 if ( true === tipShadow ) { 1119 shadow = 'qtip-shadow'; 1120 } 1121 1122 if ( '' !== tipColor ) { 1123 color = 'qtip-' + tipColor; 1124 } 1125 1126 if ( true === tipRounded ) { 1127 rounded = 'qtip-rounded'; 1128 } 1129 1130 if ( '' !== tipStyle ) { 1131 style = 'qtip-' + tipStyle; 1132 } 1133 1134 classes = shadow + ',' + color + ',' + rounded + ',' + style + ',redux-qtip'; 1135 classes = classes.replace( /,/g, ' ' ); 1136 1137 // Gotta be lowercase, and in proper format. 1138 myPos = $.redux.verifyPos( myPos.toLowerCase(), true ); 1139 atPos = $.redux.verifyPos( atPos.toLowerCase(), false ); 1140 1141 $( 'div.redux-dev-qtip' ).each( 1142 function() { 1143 $( this ).qtip( 1144 { 1145 content: { 1146 text: $( this ).attr( 'qtip-content' ), 1147 title: $( this ).attr( 'qtip-title' ) 1148 }, show: { 1149 effect: function() { 1150 $( this ).slideDown( 500 ); 1151 }, 1152 event: 'mouseover' 1153 }, hide: { 1154 effect: function() { 1155 $( this ).slideUp( 500 ); 1156 }, 1157 event: 'mouseleave' 1158 }, style: { 1159 classes: 'qtip-shadow qtip-light' 1160 }, position: { 1161 my: 'top center', 1162 at: 'bottom center' 1163 } 1164 } 1165 ); 1166 } 1167 ); 1168 1169 $( 'div.redux-hint-qtip' ).each( 1170 function() { 1171 $( this ).qtip( 1172 { 1173 content: { 1174 text: $( this ).attr( 'qtip-content' ), 1175 title: $( this ).attr( 'qtip-title' ) 1176 }, show: { 1177 effect: function() { 1178 switch ( tipShowEffect ) { 1179 case 'slide': 1180 $( this ).slideDown( tipShowDuration ); 1181 break; 1182 case 'fade': 1183 $( this ).fadeIn( tipShowDuration ); 1184 break; 1185 default: 1186 $( this ).show(); 1187 break; 1188 } 1189 }, 1190 event: showEvent 1191 }, hide: { 1192 effect: function() { 1193 switch ( tipHideEffect ) { 1194 case 'slide': 1195 $( this ).slideUp( tipHideDuration ); 1196 break; 1197 case 'fade': 1198 $( this ).fadeOut( tipHideDuration ); 1199 break; 1200 default: 1201 $( this ).hide( tipHideDuration ); 1202 break; 1203 } 1204 }, 1205 event: hideEvent 1206 }, style: { 1207 classes: classes 1208 }, position: { 1209 my: myPos, 1210 at: atPos 1211 } 1212 } 1213 ); 1214 } 1215 ); 1216 1217 $( 'input[qtip-content]' ).each( 1218 function() { 1219 $( this ).qtip( 1220 { 1221 content: { 1222 text: $( this ).attr( 'qtip-content' ), 1223 title: $( this ).attr( 'qtip-title' ) 1224 }, 1225 show: 'focus', 1226 hide: 'blur', 1227 style: classes, 1228 position: { 1229 my: myPos, 1230 at: atPos 1231 } 1232 } 1233 ); 1234 } 1235 ); 1236 } 1237 }; 1238 1239 $.redux.verifyPos = function( s, b ) { 1240 var split; 1241 var paramOne; 1242 var paramTwo; 1243 1244 // Trim off spaces. 1245 s = s.replace( /^\s+|\s+$/gm, '' ); 1246 1247 // Position value is blank, set the default. 1248 if ( '' === s || - 1 === s.search( ' ' ) ) { 1249 if ( true === b ) { 1250 return 'top left'; 1251 } else { 1252 return 'bottom right'; 1253 } 1254 } 1255 1256 // Split string into array. 1257 split = s.split( ' ' ); 1258 1259 // Evaluate first string. Must be top, center, or bottom. 1260 paramOne = b ? 'top' : 'bottom'; 1261 1262 if ( 'top' === split[0] || 'center' === split[0] || 'bottom' === split[0] ) { 1263 paramOne = split[0]; 1264 } 1265 1266 // Evaluate second string. Must be left, center, or right. 1267 paramTwo = b ? 'left' : 'right'; 1268 1269 if ( 'left' === split[1] || 'center' === split[1] || 'right' === split[1] ) { 1270 paramTwo = split[1]; 1271 } 1272 1273 return paramOne + ' ' + paramTwo; 1274 }; 1275 })( jQuery ); 1276 1277 /* jshint unused:false */ 1278 /* global redux */ 1279 1280 var confirmOnPageExit = function( e ) { 1281 1282 // Return; // ONLY FOR DEBUGGING. 1283 // If we haven't been passed the event get the window.event. 1284 'use strict'; 1285 1286 var message; 1287 1288 e = e || window.event; 1289 1290 message = redux.optName.args.save_pending; 1291 1292 // For IE6-8 and Firefox prior to version 4. 1293 if ( e ) { 1294 e.returnValue = message; 1295 } 1296 1297 window.onbeforeunload = null; 1298 1299 // For Chrome, Safari, IE8+ and Opera 12+. 1300 return message; 1301 }; 1302 1303 function redux_change( variable ) { 1304 'use strict'; 1305 1306 (function( $ ) { 1307 var rContainer; 1308 var opt_name; 1309 var parentID; 1310 var id; 1311 var th; 1312 var subParent; 1313 var errorCount; 1314 var errorsLeft; 1315 var warningCount; 1316 var warningsLeft; 1317 1318 variable = $( variable ); 1319 1320 rContainer = $( variable ).parents( '.redux-container:first' ); 1321 1322 if ( redux.customizer ) { 1323 opt_name = $( '.redux-customizer-opt-name' ).data( 'opt-name' ); 1324 } else { 1325 opt_name = $.redux.getOptName( rContainer ); 1326 } 1327 1328 $( 'body' ).trigger( 'check_dependencies', variable ); 1329 1330 if ( variable.hasClass( 'compiler' ) ) { 1331 $( '#redux-compiler-hook' ).val( 1 ); 1332 } 1333 1334 parentID = $( variable ).closest( '.redux-group-tab' ).attr( 'id' ); 1335 1336 // Let's count down the errors now. Fancy. ;). 1337 id = parentID.split( '_' ); 1338 1339 id = id[0]; 1340 1341 th = rContainer.find( '.redux-group-tab-link-a[data-key="' + id + '"]' ).parents( '.redux-group-tab-link-li:first' ); 1342 subParent = $( '#' + parentID + '_li' ).parents( '.hasSubSections:first' ); 1343 1344 if ( $( variable ).parents( 'fieldset.redux-field:first' ).hasClass( 'redux-field-error' ) ) { 1345 $( variable ).parents( 'fieldset.redux-field:first' ).removeClass( 'redux-field-error' ); 1346 $( variable ).parent().find( '.redux-th-error' ).slideUp(); 1347 1348 errorCount = ( parseInt( rContainer.find( '.redux-field-errors span' ).text(), 0 ) - 1 ); 1349 1350 if ( errorCount <= 0 ) { 1351 $( '#' + parentID + '_li .redux-menu-error' ).fadeOut( 'fast' ).remove(); 1352 $( '#' + parentID + '_li .redux-group-tab-link-a' ).removeClass( 'hasError' ); 1353 $( '#' + parentID + '_li' ).parents( '.inside:first' ).find( '.redux-field-errors' ).slideUp(); 1354 $( variable ).parents( '.redux-container:first' ).find( '.redux-field-errors' ).slideUp(); 1355 $( '#redux_metaboxes_errors' ).slideUp(); 1356 } else { 1357 errorsLeft = ( parseInt( th.find( '.redux-menu-error:first' ).text(), 0 ) - 1 ); 1358 1359 if ( errorsLeft <= 0 ) { 1360 th.find( '.redux-menu-error:first' ).fadeOut().remove(); 1361 } else { 1362 th.find( '.redux-menu-error:first' ).text( errorsLeft ); 1363 } 1364 1365 rContainer.find( '.redux-field-errors span' ).text( errorCount ); 1366 } 1367 1368 if ( 0 !== subParent.length ) { 1369 if ( 0 === subParent.find( '.redux-menu-error' ).length ) { 1370 subParent.find( '.hasError' ).removeClass( 'hasError' ); 1371 } 1372 } 1373 } 1374 1375 if ( $( variable ).parents( 'fieldset.redux-field:first' ).hasClass( 'redux-field-warning' ) ) { 1376 $( variable ).parents( 'fieldset.redux-field:first' ).removeClass( 'redux-field-warning' ); 1377 $( variable ).parent().find( '.redux-th-warning' ).slideUp(); 1378 1379 warningCount = ( parseInt( rContainer.find( '.redux-field-warnings span' ).text(), 0 ) - 1 ); 1380 1381 if ( warningCount <= 0 ) { 1382 $( '#' + parentID + '_li .redux-menu-warning' ).fadeOut( 'fast' ).remove(); 1383 $( '#' + parentID + '_li .redux-group-tab-link-a' ).removeClass( 'hasWarning' ); 1384 $( '#' + parentID + '_li' ).parents( '.inside:first' ).find( '.redux-field-warnings' ).slideUp(); 1385 $( variable ).parents( '.redux-container:first' ).find( '.redux-field-warnings' ).slideUp(); 1386 $( '#redux_metaboxes_warnings' ).slideUp(); 1387 } else { 1388 1389 // Let's count down the warnings now. Fancy. ;). 1390 warningsLeft = ( parseInt( th.find( '.redux-menu-warning:first' ).text(), 0 ) - 1 ); 1391 1392 if ( warningsLeft <= 0 ) { 1393 th.find( '.redux-menu-warning:first' ).fadeOut().remove(); 1394 } else { 1395 th.find( '.redux-menu-warning:first' ).text( warningsLeft ); 1396 } 1397 1398 rContainer.find( '.redux-field-warning span' ).text( warningCount ); 1399 } 1400 1401 if ( 0 !== subParent.length ) { 1402 if ( 0 === subParent.find( '.redux-menu-warning' ).length ) { 1403 subParent.find( '.hasWarning' ).removeClass( 'hasWarning' ); 1404 } 1405 } 1406 } 1407 1408 // Don't show the changed value notice while save_notice is visible. 1409 if ( rContainer.find( '.saved_notice:visible' ).length > 0 ) { 1410 return; 1411 } 1412 1413 if ( ! redux.optName.args.disable_save_warn ) { 1414 rContainer.find( '.redux-save-warn' ).slideDown(); 1415 window.onbeforeunload = confirmOnPageExit; 1416 } 1417 })( jQuery ); 1418 } 1419 1420 /* jshint unused:false */ 1421 1422 function redux_hook( object, functionName, callback, before ) { 1423 'use strict'; 1424 1425 (function( originalFunction ) { 1426 object[functionName] = function() { 1427 var returnValue; 1428 1429 if ( true === before ) { 1430 callback.apply( this, [returnValue, originalFunction, arguments] ); 1431 } 1432 1433 returnValue = originalFunction.apply( this, arguments ); 1434 1435 if ( true !== before ) { 1436 callback.apply( this, [returnValue, originalFunction, arguments] ); 1437 } 1438 1439 return returnValue; 1440 }; 1441 }( object[functionName] ) ); 1442 } 1443 1444 /* global redux */ 1445 1446 (function( $ ) { 1447 'use strict'; 1448 1449 $.redux = $.redux || {}; 1450 1451 $.redux.makeBoolStr = function( val ) { 1452 if ( 'false' === val || false === val || '0' === val || 0 === val || null === val || '' === val ) { 1453 return 'false'; 1454 } else if ( 'true' === val || true === val || '1' === val || 1 === val ) { 1455 return 'true'; 1456 } else { 1457 return val; 1458 } 1459 }; 1460 1461 $.redux.checkRequired = function( el ) { 1462 $.redux.required(); 1463 1464 $( 'body' ).on( 1465 'change', 1466 '.redux-main select, .redux-main radio, .redux-main input[type=checkbox], .redux-main input[type=hidden]', 1467 function() { 1468 $.redux.check_dependencies( this ); 1469 } 1470 ); 1471 1472 $( 'body' ).on( 1473 'check_dependencies', 1474 function( e, variable ) { 1475 e = null; 1476 $.redux.check_dependencies( variable ); 1477 } 1478 ); 1479 1480 if ( redux.customizer ) { 1481 el.find( '.customize-control.redux-field.hide' ).hide(); 1482 } 1483 1484 el.find( '.redux-container td > fieldset:empty,td > div:empty' ).parent().parent().hide(); 1485 }; 1486 1487 $.redux.required = function() { 1488 1489 // Hide the fold elements on load. 1490 // It's better to do this by PHP but there is no filter in tr tag , so is not possible 1491 // we going to move each attributes we may need for folding to tr tag. 1492 $.each( 1493 redux.opt_names, 1494 function( x ) { 1495 $.each( 1496 window['redux_' + redux.opt_names[x].replace( /\-/g, '_' )].folds, 1497 function( i, v ) { 1498 var div; 1499 var rawTable; 1500 1501 var fieldset = $( '#' + redux.opt_names[x] + '-' + i ); 1502 1503 fieldset.parents( 'tr:first, li:first' ).addClass( 'fold' ); 1504 1505 if ( 'hide' === v ) { 1506 fieldset.parents( 'tr:first, li:first' ).addClass( 'hide' ); 1507 1508 if ( fieldset.hasClass( 'redux-container-section' ) ) { 1509 div = $( '#section-' + i ); 1510 1511 if ( div.hasClass( 'redux-section-indent-start' ) ) { 1512 $( '#section-table-' + i ).hide().addClass( 'hide' ); 1513 div.hide().addClass( 'hide' ); 1514 } 1515 } 1516 1517 if ( fieldset.hasClass( 'redux-container-info' ) ) { 1518 $( '#info-' + i ).hide().addClass( 'hide' ); 1519 } 1520 1521 if ( fieldset.hasClass( 'redux-container-divide' ) ) { 1522 $( '#divide-' + i ).hide().addClass( 'hide' ); 1523 } 1524 1525 if ( fieldset.hasClass( 'redux-container-raw' ) ) { 1526 rawTable = fieldset.parents().find( 'table#' + redux.opt_names[x] + '-' + i ); 1527 rawTable.hide().addClass( 'hide' ); 1528 } 1529 } 1530 } 1531 ); 1532 } 1533 ); 1534 }; 1535 1536 $.redux.getContainerValue = function( id ) { 1537 var value = $( '#' + redux.optName.args.opt_name + '-' + id ).serializeForm(); 1538 1539 if ( null !== value && 'object' === typeof value && value.hasOwnProperty( redux.optName.args.opt_name ) ) { 1540 value = value[redux.optName.args.opt_name][id]; 1541 } 1542 1543 if ( $( '#' + redux.optName.args.opt_name + '-' + id ).hasClass( 'redux-container-media' ) ) { 1544 value = value.url; 1545 } 1546 1547 return value; 1548 }; 1549 1550 $.redux.check_dependencies = function( variable ) { 1551 var current; 1552 var id; 1553 var container; 1554 var isHidden; 1555 1556 if ( null === redux.optName.required ) { 1557 return; 1558 } 1559 1560 current = $( variable ); 1561 id = current.parents( '.redux-field:first' ).data( 'id' ); 1562 1563 if ( ! redux.optName.required.hasOwnProperty( id ) ) { 1564 return; 1565 } 1566 1567 container = current.parents( '.redux-field-container:first' ); 1568 isHidden = container.parents( 'tr:first' ).hasClass( 'hide' ); 1569 1570 if ( ! container.parents( 'tr:first' ).length ) { 1571 isHidden = container.parents( '.customize-control:first' ).hasClass( 'hide' ); 1572 } 1573 1574 $.each( 1575 redux.optName.required[id], 1576 function( child ) { 1577 var div; 1578 var rawTable; 1579 var tr; 1580 1581 var current = $( this ); 1582 var show = false; 1583 var childFieldset = $( '#' + redux.optName.args.opt_name + '-' + child ); 1584 1585 tr = childFieldset.parents( 'tr:first' ); 1586 1587 if ( 0 === tr.length ) { 1588 tr = childFieldset.parents( 'li:first' ); 1589 } 1590 1591 if ( ! isHidden ) { 1592 show = $.redux.check_parents_dependencies( child ); 1593 } 1594 1595 if ( true === show ) { 1596 1597 // Shim for sections. 1598 if ( childFieldset.hasClass( 'redux-container-section' ) ) { 1599 div = $( '#section-' + child ); 1600 1601 if ( div.hasClass( 'redux-section-indent-start' ) && div.hasClass( 'hide' ) ) { 1602 $( '#section-table-' + child ).fadeIn( 300 ).removeClass( 'hide' ); 1603 div.fadeIn( 300 ).removeClass( 'hide' ); 1604 } 1605 } 1606 1607 if ( childFieldset.hasClass( 'redux-container-info' ) ) { 1608 $( '#info-' + child ).fadeIn( 300 ).removeClass( 'hide' ); 1609 } 1610 1611 if ( childFieldset.hasClass( 'redux-container-divide' ) ) { 1612 $( '#divide-' + child ).fadeIn( 300 ).removeClass( 'hide' ); 1613 } 1614 1615 if ( childFieldset.hasClass( 'redux-container-raw' ) ) { 1616 rawTable = childFieldset.parents().find( 'table#' + redux.optName.args.opt_name + '-' + child ); 1617 rawTable.fadeIn( 300 ).removeClass( 'hide' ); 1618 } 1619 1620 tr.fadeIn( 1621 300, 1622 function() { 1623 $( this ).removeClass( 'hide' ); 1624 if ( redux.optName.required.hasOwnProperty( child ) ) { 1625 $.redux.check_dependencies( $( '#' + redux.optName.args.opt_name + '-' + child ).children().first() ); 1626 } 1627 1628 $.redux.initFields(); 1629 } 1630 ); 1631 1632 if ( childFieldset.hasClass( 'redux-container-section' ) || childFieldset.hasClass( 'redux-container-info' ) ) { 1633 tr.css( { display: 'none' } ); 1634 } 1635 } else if ( false === show ) { 1636 tr.fadeOut( 1637 100, 1638 function() { 1639 $( this ).addClass( 'hide' ); 1640 if ( redux.optName.required.hasOwnProperty( child ) ) { 1641 $.redux.required_recursive_hide( child ); 1642 } 1643 } 1644 ); 1645 } 1646 1647 current.find( 'select, radio, input[type=checkbox]' ).trigger( 'change' ); 1648 } 1649 ); 1650 }; 1651 1652 $.redux.required_recursive_hide = function( id ) { 1653 var div; 1654 var rawTable; 1655 var toFade; 1656 1657 toFade = $( '#' + redux.optName.args.opt_name + '-' + id ).parents( 'tr:first' ); 1658 if ( 0 === toFade ) { 1659 toFade = $( '#' + redux.optName.args.opt_name + '-' + id ).parents( 'li:first' ); 1660 } 1661 1662 toFade.fadeOut( 1663 50, 1664 function() { 1665 $( this ).addClass( 'hide' ); 1666 1667 if ( $( '#' + redux.optName.args.opt_name + '-' + id ).hasClass( 'redux-container-section' ) ) { 1668 div = $( '#section-' + id ); 1669 1670 if ( div.hasClass( 'redux-section-indent-start' ) ) { 1671 $( '#section-table-' + id ).fadeOut( 50 ).addClass( 'hide' ); 1672 div.fadeOut( 50 ).addClass( 'hide' ); 1673 } 1674 } 1675 1676 if ( $( '#' + redux.optName.args.opt_name + '-' + id ).hasClass( 'redux-container-info' ) ) { 1677 $( '#info-' + id ).fadeOut( 50 ).addClass( 'hide' ); 1678 } 1679 1680 if ( $( '#' + redux.optName.args.opt_name + '-' + id ).hasClass( 'redux-container-divide' ) ) { 1681 $( '#divide-' + id ).fadeOut( 50 ).addClass( 'hide' ); 1682 } 1683 1684 if ( $( '#' + redux.optName.args.opt_name + '-' + id ).hasClass( 'redux-container-raw' ) ) { 1685 rawTable = $( '#' + redux.optName.args.opt_name + '-' + id ).parents().find( 'table#' + redux.optName.args.opt_name + '-' + id ); 1686 rawTable.fadeOut( 50 ).addClass( 'hide' ); 1687 } 1688 1689 if ( redux.optName.required.hasOwnProperty( id ) ) { 1690 $.each( 1691 redux.optName.required[id], 1692 function( child ) { 1693 $.redux.required_recursive_hide( child ); 1694 } 1695 ); 1696 } 1697 } 1698 ); 1699 }; 1700 1701 $.redux.check_parents_dependencies = function( id ) { 1702 var show = ''; 1703 1704 if ( redux.optName.required_child.hasOwnProperty( id ) ) { 1705 $.each( 1706 redux.optName.required_child[id], 1707 function( i, parentData ) { 1708 var parentValue; 1709 1710 i = null; 1711 1712 if ( $( '#' + redux.optName.args.opt_name + '-' + parentData.parent ).parents( 'tr:first' ).hasClass( 'hide' ) ) { 1713 show = false; 1714 } else if ( $( '#' + redux.optName.args.opt_name + '-' + parentData.parent ).parents( 'li:first' ).hasClass( 'hide' ) ) { 1715 show = false; 1716 } else { 1717 if ( false !== show ) { 1718 parentValue = $.redux.getContainerValue( parentData.parent ); 1719 1720 show = $.redux.check_dependencies_visibility( parentValue, parentData ); 1721 } 1722 } 1723 } 1724 ); 1725 } else { 1726 show = true; 1727 } 1728 1729 return show; 1730 }; 1731 1732 $.redux.check_dependencies_visibility = function( parentValue, data ) { 1733 var show = false; 1734 var checkValue = data.checkValue; 1735 var operation = data.operation; 1736 var arr; 1737 1738 if ( $.isPlainObject( parentValue ) ) { 1739 parentValue = Object.keys( parentValue ).map( 1740 function( key ) { 1741 return [key, parentValue[key]]; 1742 } 1743 ); 1744 } 1745 1746 switch ( operation ) { 1747 case '=': 1748 case 'equals': 1749 if ( $.isArray( parentValue ) ) { 1750 $( parentValue[0] ).each( 1751 function( idx, val ) { 1752 idx = null; 1753 1754 if ( $.isArray( checkValue ) ) { 1755 $( checkValue ).each( 1756 function( i, v ) { 1757 i = null; 1758 if ( $.redux.makeBoolStr( val ) === $.redux.makeBoolStr( v ) ) { 1759 show = true; 1760 1761 return true; 1762 } 1763 } 1764 ); 1765 } else { 1766 if ( $.redux.makeBoolStr( val ) === $.redux.makeBoolStr( checkValue ) ) { 1767 show = true; 1768 1769 return true; 1770 } 1771 } 1772 } 1773 ); 1774 } else { 1775 if ( $.isArray( checkValue ) ) { 1776 $( checkValue ).each( 1777 function( i, v ) { 1778 i = null; 1779 1780 if ( $.redux.makeBoolStr( parentValue ) === $.redux.makeBoolStr( v ) ) { 1781 show = true; 1782 } 1783 } 1784 ); 1785 } else { 1786 if ( $.redux.makeBoolStr( parentValue ) === $.redux.makeBoolStr( checkValue ) ) { 1787 show = true; 1788 } 1789 } 1790 } 1791 break; 1792 1793 case '!=': 1794 case 'not': 1795 if ( $.isArray( parentValue ) ) { 1796 $( parentValue[0] ).each( 1797 function( idx, val ) { 1798 idx = null; 1799 1800 if ( $.isArray( checkValue ) ) { 1801 $( checkValue ).each( 1802 function( i, v ) { 1803 i = null; 1804 1805 if ( $.redux.makeBoolStr( val ) !== $.redux.makeBoolStr( v ) ) { 1806 show = true; 1807 1808 return true; 1809 } 1810 } 1811 ); 1812 } else { 1813 if ( $.redux.makeBoolStr( val ) !== $.redux.makeBoolStr( checkValue ) ) { 1814 show = true; 1815 1816 return true; 1817 } 1818 } 1819 } 1820 ); 1821 } else { 1822 if ( $.isArray( checkValue ) ) { 1823 $( checkValue ).each( 1824 function( i, v ) { 1825 i = null; 1826 1827 if ( $.redux.makeBoolStr( parentValue ) !== $.redux.makeBoolStr( v ) ) { 1828 show = true; 1829 } 1830 } 1831 ); 1832 } else { 1833 if ( $.redux.makeBoolStr( parentValue ) !== $.redux.makeBoolStr( checkValue ) ) { 1834 show = true; 1835 } 1836 } 1837 } 1838 break; 1839 1840 case '>': 1841 case 'greater': 1842 case 'is_larger': 1843 if ( parseFloat( parentValue ) > parseFloat( checkValue ) ) { 1844 show = true; 1845 } 1846 break; 1847 1848 case '>=': 1849 case 'greater_equal': 1850 case 'is_larger_equal': 1851 if ( parseFloat( parentValue ) >= parseFloat( checkValue ) ) { 1852 show = true; 1853 } 1854 break; 1855 1856 case '<': 1857 case 'less': 1858 case 'is_smaller': 1859 if ( parseFloat( parentValue ) < parseFloat( checkValue ) ) { 1860 show = true; 1861 } 1862 break; 1863 1864 case '<=': 1865 case 'less_equal': 1866 case 'is_smaller_equal': 1867 if ( parseFloat( parentValue ) <= parseFloat( checkValue ) ) { 1868 show = true; 1869 } 1870 break; 1871 1872 case 'contains': 1873 if ( $.isPlainObject( parentValue ) ) { 1874 parentValue = Object.keys( parentValue ).map( 1875 function( key ) { 1876 return [key, parentValue[key]]; 1877 } 1878 ); 1879 } 1880 1881 if ( $.isPlainObject( checkValue ) ) { 1882 checkValue = Object.keys( checkValue ).map( 1883 function( key ) { 1884 return [key, checkValue[key]]; 1885 } 1886 ); 1887 } 1888 1889 if ( $.isArray( checkValue ) ) { 1890 $( checkValue ).each( 1891 function( idx, val ) { 1892 var breakMe = false; 1893 var toFind = val[0]; 1894 var findVal = val[1]; 1895 1896 idx = null; 1897 1898 $( parentValue ).each( 1899 function( i, v ) { 1900 var toMatch = v[0]; 1901 var matchVal = v[1]; 1902 1903 i = null; 1904 1905 if ( toFind === toMatch ) { 1906 if ( findVal === matchVal ) { 1907 show = true; 1908 breakMe = true; 1909 1910 return false; 1911 } 1912 } 1913 } 1914 ); 1915 1916 if ( true === breakMe ) { 1917 return false; 1918 } 1919 } 1920 ); 1921 } else { 1922 if ( parentValue.toString().indexOf( checkValue ) !== - 1 ) { 1923 show = true; 1924 } 1925 } 1926 break; 1927 1928 case 'doesnt_contain': 1929 case 'not_contain': 1930 if ( $.isPlainObject( parentValue ) ) { 1931 arr = Object.keys( parentValue ).map( 1932 function( key ) { 1933 return parentValue[key]; 1934 } 1935 ); 1936 1937 parentValue = arr; 1938 } 1939 1940 if ( $.isPlainObject( checkValue ) ) { 1941 arr = Object.keys( checkValue ).map( 1942 function( key ) { 1943 return checkValue[key]; 1944 } 1945 ); 1946 1947 checkValue = arr; 1948 } 1949 1950 if ( $.isArray( checkValue ) ) { 1951 $( checkValue ).each( 1952 function( idx, val ) { 1953 idx = null; 1954 1955 if ( parentValue.toString().indexOf( val ) === - 1 ) { 1956 show = true; 1957 } 1958 } 1959 ); 1960 } else { 1961 if ( parentValue.toString().indexOf( checkValue ) === - 1 ) { 1962 show = true; 1963 } 1964 } 1965 break; 1966 1967 case 'is_empty_or': 1968 if ( '' === parentValue || checkValue === parentValue ) { 1969 show = true; 1970 } 1971 break; 1972 1973 case 'not_empty_and': 1974 if ( '' !== parentValue && checkValue !== parentValue ) { 1975 show = true; 1976 } 1977 break; 1978 1979 case 'is_empty': 1980 case 'empty': 1981 case '!isset': 1982 if ( ! parentValue || '' === parentValue || null === parentValue ) { 1983 show = true; 1984 } 1985 break; 1986 1987 case 'not_empty': 1988 case '!empty': 1989 case 'isset': 1990 if ( parentValue && '' !== parentValue && null !== parentValue ) { 1991 show = true; 1992 } 1993 break; 1994 } 1995 1996 return show; 1997 }; 1998 })( jQuery ); 1999 2000 (function( $ ) { 2001 'use strict'; 2002 2003 $.redux = $.redux || {}; 2004 2005 $.redux.stickyInfo = function() { 2006 var stickyWidth = $( '.redux-main' ).innerWidth() - 20; 2007 var $width = $( '#redux-sticky' ).offset().left; 2008 2009 $( '.redux-save-warn' ).css( 'left', $width + 'px' ); 2010 2011 if ( ! $( '#info_bar' ).isOnScreen() && ! $( '#redux-footer-sticky' ).isOnScreen() ) { 2012 $( '#redux-footer' ).css( 2013 { position: 'fixed', bottom: '0', width: stickyWidth, right: 21 } 2014 ); 2015 2016 $( '#redux-footer' ).addClass( 'sticky-footer-fixed' ); 2017 $( '#redux-sticky-padder' ).show(); 2018 } else { 2019 $( '#redux-footer' ).css( 2020 { background: '#eee', position: 'inherit', bottom: 'inherit', width: 'inherit' } 2021 ); 2022 2023 $( '#redux-sticky-padder' ).hide(); 2024 $( '#redux-footer' ).removeClass( 'sticky-footer-fixed' ); 2025 } 2026 if ( ! $( '#info_bar' ).isOnScreen() ) { 2027 $( '#redux-sticky' ).addClass( 'sticky-save-warn' ); 2028 } else { 2029 $( '#redux-sticky' ).removeClass( 'sticky-save-warn' ); 2030 } 2031 }; 2032 })( jQuery ); 2033 2034 /* global redux */ 2035 2036 (function( $ ) { 2037 'use strict'; 2038 2039 $.redux = $.redux || {}; 2040 2041 $.redux.tabCheck = function() { 2042 var link; 2043 var tab; 2044 var sTab; 2045 var cookieName; 2046 var opt_name; 2047 2048 $( '.redux-group-tab-link-a' ).on( 2049 'click', 2050 function() { 2051 var elements; 2052 var index; 2053 var el; 2054 var relid; 2055 var oldid; 2056 var cookieName; 2057 var boxIndex; 2058 var parentID; 2059 var newParent; 2060 2061 link = $( this ); 2062 2063 if ( link.parent().hasClass( 'empty_section' ) && link.parent().hasClass( 'hasSubSections' ) ) { 2064 elements = $( this ).closest( 'ul' ).find( '.redux-group-tab-link-a' ); 2065 index = elements.index( this ); 2066 2067 link = elements.slice( index + 1, index + 2 ); 2068 } 2069 2070 el = link.parents( '.redux-container:first' ); 2071 relid = link.data( 'rel' ); // The group ID of interest. 2072 oldid = el.find( '.redux-group-tab-link-li.active:first .redux-group-tab-link-a' ).data( 'rel' ); 2073 opt_name = $.redux.getOptName( el ); 2074 2075 if ( oldid === relid ) { 2076 return; 2077 } 2078 2079 cookieName = ''; 2080 2081 if ( ! link.parents( '.postbox-container:first' ).length ) { 2082 $( '#currentSection' ).val( relid ); 2083 2084 cookieName = 'redux_current_tab_' + redux.optName.args.opt_name; 2085 } else { 2086 el.prev( '#currentSection' ).val( relid ); 2087 2088 boxIndex = el.data( 'index' ); 2089 2090 if ( '' !== boxIndex ) { 2091 cookieName = 'redux_metabox_' + boxIndex + '_current_tab_' + redux.optName.args.opt_name; 2092 } 2093 } 2094 2095 // Set the proper page cookie. 2096 $.cookie( 2097 cookieName, 2098 relid, 2099 { 2100 expires: 7, 2101 path: '/' 2102 } 2103 ); 2104 2105 if ( el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).length ) { 2106 parentID = el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).attr( 'id' ).split( '_' ); 2107 parentID = parentID[0]; 2108 } 2109 2110 el.find( '#toplevel_page_' + redux.optName.args.slug + ' .wp-submenu a.current' ).removeClass( 'current' ); 2111 el.find( '#toplevel_page_' + redux.optName.args.slug + ' .wp-submenu li.current' ).removeClass( 'current' ); 2112 2113 el.find( '#toplevel_page_' + redux.optName.args.slug + ' .wp-submenu a' ).each( 2114 function() { 2115 var url = $( this ).attr( 'href' ).split( '&tab=' ); 2116 2117 if ( url[1] === relid || url[1] === parentID ) { 2118 $( this ).addClass( 'current' ); 2119 $( this ).parent().addClass( 'current' ); 2120 } 2121 } 2122 ); 2123 2124 if ( el.find( '#' + oldid + '_section_group_li' ).find( '#' + oldid + '_section_group_li' ).length ) { 2125 el.find( '#' + oldid + '_section_group_li' ).addClass( 'activeChild' ); 2126 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ); 2127 } 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 ) { 2128 if ( el.find( '#' + relid + '_section_group_li' ).parents( '#' + oldid + '_section_group_li' ).length ) { 2129 el.find( '#' + oldid + '_section_group_li' ).addClass( 'activeChild' ).removeClass( 'active' ); 2130 } else { 2131 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); 2132 el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); 2133 } 2134 el.find( '#' + relid + '_section_group_li' ).removeClass( 'activeChild' ).addClass( 'active' ); 2135 } else { 2136 setTimeout( 2137 function() { 2138 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); 2139 }, 2140 1 2141 ); 2142 2143 if ( el.find( '#' + oldid + '_section_group_li' ).find( 'ul.subsection' ).length ) { 2144 el.find( '#' + oldid + '_section_group_li' ).find( 'ul.subsection' ).slideUp( 2145 'fast', 2146 function() { 2147 el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ).removeClass( 'activeChild' ); 2148 } 2149 ); 2150 2151 newParent = el.find( '#' + relid + '_section_group_li' ).parents( '.hasSubSections:first' ); 2152 2153 if ( newParent.length > 0 ) { 2154 el.find( '#' + relid + '_section_group_li' ).removeClass( 'active' ); 2155 relid = newParent.find( '.redux-group-tab-link-a:first' ).data( 'rel' ); 2156 2157 if ( newParent.hasClass( 'empty_section' ) ) { 2158 newParent.find( '.subsection li:first' ).addClass( 'active' ); 2159 el.find( '#' + relid + '_section_group_li' ).removeClass( 'active' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); 2160 newParent = newParent.find( '.subsection li:first' ); 2161 relid = newParent.find( '.redux-group-tab-link-a:first' ).data( 'rel' ); 2162 } else { 2163 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ).removeClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); 2164 } 2165 } 2166 } else if ( el.find( '#' + oldid + '_section_group_li' ).parents( 'ul.subsection' ).length ) { 2167 if ( ! el.find( '#' + oldid + '_section_group_li' ).parents( '#' + relid + '_section_group_li' ).length ) { 2168 el.find( '#' + oldid + '_section_group_li' ).parents( 'ul.subsection' ).slideUp( 2169 'fast', 2170 function() { 2171 el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); 2172 el.find( '#' + oldid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).removeClass( 'active' ).removeClass( 'activeChild' ); 2173 el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); 2174 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); 2175 } 2176 ); 2177 } else { 2178 el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); 2179 } 2180 } else { 2181 el.find( '#' + oldid + '_section_group_li' ).removeClass( 'active' ); 2182 2183 if ( el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).length ) { 2184 setTimeout( 2185 function() { 2186 el.find( '#' + relid + '_section_group_li' ).parents( '.redux-group-tab-link-li' ).addClass( 'activeChild' ).find( 'ul.subsection' ).slideDown(); 2187 }, 2188 50 2189 ); 2190 2191 el.find( '#' + relid + '_section_group_li' ).addClass( 'active' ); 2192 } 2193 } 2194 } 2195 2196 // Show the group. 2197 el.find( '#' + oldid + '_section_group' ).hide(); 2198 2199 el.find( '#' + relid + '_section_group' ).fadeIn( 2200 200, 2201 function() { 2202 if ( 0 !== el.find( '#redux-footer' ).length ) { 2203 $.redux.stickyInfo(); // Race condition fix. 2204 } 2205 2206 $.redux.initFields(); 2207 } 2208 ); 2209 2210 $( '#toplevel_page_' + redux.optName.args.slug ).find( '.current' ).removeClass( 'current' ); 2211 } 2212 ); 2213 2214 if ( undefined !== redux.optName.last_tab ) { 2215 $( '#' + redux.optName.last_tab + '_section_group_li_a' ).trigger( 'click' ); 2216 2217 return; 2218 } 2219 2220 tab = decodeURI( ( new RegExp( 'tab=(.+?)(&|$)' ).exec( location.search ) || [''])[1] ); 2221 2222 if ( '' !== tab ) { 2223 if ( $.cookie( 'redux_current_tab_get' ) !== tab ) { 2224 $.cookie( 2225 'redux_current_tab', 2226 tab, 2227 { 2228 expires: 7, 2229 path: '/' 2230 } 2231 ); 2232 2233 $.cookie( 2234 'redux_current_tab_get', 2235 tab, 2236 { 2237 expires: 7, 2238 path: '/' 2239 } 2240 ); 2241 2242 $.cookie( 2243 'redux_current_tab_' + redux.optName.args.opt_name, 2244 tab, 2245 { 2246 expires: 7, 2247 path: '/' 2248 } 2249 ); 2250 2251 $( '#' + tab + '_section_group_li' ).trigger( 'click' ); 2252 } 2253 } else if ( '' !== $.cookie( 'redux_current_tab_get' ) ) { 2254 $.removeCookie( 'redux_current_tab_get' ); 2255 } 2256 2257 $( '.redux-container' ).each( 2258 function() { 2259 var boxIndex; 2260 2261 if ( ! $( this ).parents( '.postbox-container:first' ).length ) { 2262 opt_name = $( '.redux-ajax-security' ).data( 'opt-name' ); 2263 2264 cookieName = 'redux_current_tab_' + opt_name; 2265 2266 sTab = $( this ).find( '#' + $.cookie( cookieName ) + '_section_group_li_a' ); 2267 } else { 2268 opt_name = $.redux.getOptName( this ); 2269 2270 boxIndex = $( this ).data( 'index' ); 2271 2272 if ( '' === boxIndex ) { 2273 boxIndex = 0; 2274 } 2275 2276 cookieName = 'redux_metabox_' + boxIndex + '_current_tab_' + opt_name; 2277 2278 sTab = $( this ).find( '#' + $.cookie( cookieName ) + '_section_group_li_a' ); 2279 } 2280 2281 // Tab the first item or the saved one. 2282 if ( null === $.cookie( cookieName ) || 'undefined' === typeof ( $.cookie( cookieName ) ) || 0 === sTab.length ) { 2283 $( this ).find( '.redux-group-tab-link-a:first' ).trigger( 'click' ); 2284 } else { 2285 sTab.trigger( 'click' ); 2286 } 2287 } 2288 ); 2289 }; 2290 })( jQuery );