79
79
data : $data
80
80
} ,
81
81
error : function ( response ) {
82
- $ ( '.redux-action_bar input' ) . prop ( 'disabled' , false ) ;
82
+ var input = $ ( '.redux-action_bar input' ) ;
83
+
84
+ input . prop ( 'disabled' , false ) ;
83
85
84
86
if ( true === redux . optName . args . dev_mode ) {
85
87
console . log ( response . responseText ) ;
91
93
redux . optName . args . ajax_save = false ;
92
94
93
95
$ ( button ) . trigger ( 'click' ) ;
94
- $ ( '.redux-action_bar input' ) . prop ( 'disabled' , true ) ;
96
+ input . prop ( 'disabled' , true ) ;
95
97
}
96
98
} ,
97
99
success : function ( response ) {
@@ -158,7 +160,7 @@ function colorValidate( field ) {
158
160
function colorNameToHex ( colour ) {
159
161
'use strict' ;
160
162
161
- var tcolour = colour . replace ( / ^ \s \s * / , '' ) . replace ( / \s \s * $ / , '' ) . replace ( '#' , '' ) ;
163
+ var tcolour = colour . replace ( / ^ \s + / , '' ) . replace ( / \s + $ / , '' ) . replace ( '#' , '' ) ;
162
164
163
165
var colours = {
164
166
'aliceblue' : '#f0f8ff' ,
@@ -685,6 +687,7 @@ function colorNameToHex( colour ) {
685
687
function ( ) {
686
688
var opt_name ;
687
689
var tempArr = [ ] ;
690
+ var container ;
688
691
689
692
$ . fn . isOnScreen = function ( ) {
690
693
var win ;
@@ -718,7 +721,9 @@ function colorNameToHex( colour ) {
718
721
$ ( '.wp-full-overlay-sidebar' ) . addClass ( 'redux-container' ) ;
719
722
}
720
723
721
- $ ( '.redux-container' ) . each (
724
+ container = $ ( '.redux-container' ) ;
725
+
726
+ container . each (
722
727
function ( ) {
723
728
opt_name = $ . redux . getOptName ( this ) ;
724
729
@@ -730,7 +735,7 @@ function colorNameToHex( colour ) {
730
735
}
731
736
) ;
732
737
733
- $ ( '.redux- container' ) . on (
738
+ container . on (
734
739
'click' ,
735
740
function ( ) {
736
741
opt_name = $ . redux . getOptName ( this ) ;
@@ -819,7 +824,6 @@ function colorNameToHex( colour ) {
819
824
820
825
$ . redux . getOptName = function ( el ) {
821
826
var metabox ;
822
- var li ;
823
827
var optName ;
824
828
var item = $ ( el ) ;
825
829
@@ -829,7 +833,7 @@ function colorNameToHex( colour ) {
829
833
optName = $ ( el ) . parents ( '.redux-wrap-div' ) . data ( 'opt-name' ) ;
830
834
}
831
835
832
- // Compatibility for metaboxes
836
+ // Compatibility for metaboxes.
833
837
if ( undefined === optName ) {
834
838
metabox = $ ( el ) . parents ( '.postbox' ) ;
835
839
if ( 0 === metabox . length ) {
@@ -956,7 +960,10 @@ function colorNameToHex( colour ) {
956
960
function ( key , value ) {
957
961
var fieldset = $ ( '#' + redux . optName . args . opt_name + '-' + value . id ) ;
958
962
959
- fieldset . addClass ( 'redux-field-error' ) ;
963
+ if ( '' !== value . msg ) {
964
+ fieldset . addClass ( 'redux-field-error' ) ;
965
+ }
966
+
960
967
if ( 0 === fieldset . parent ( ) . find ( '.redux-th-error' ) . length ) {
961
968
fieldset . append ( '<div class="redux-th-error">' + value . msg + '</div>' ) ;
962
969
} else {
@@ -1019,7 +1026,9 @@ function colorNameToHex( colour ) {
1019
1026
function ( key , value ) {
1020
1027
var fieldset = $ ( '#' + redux . optName . args . opt_name + '-' + value . id ) ;
1021
1028
1022
- fieldset . addClass ( 'redux-field-warning' ) ;
1029
+ if ( '' !== value . msg ) {
1030
+ fieldset . addClass ( 'redux-field-warning' ) ;
1031
+ }
1023
1032
1024
1033
if ( 0 === fieldset . parent ( ) . find ( '.redux-th-warning' ) . length ) {
1025
1034
fieldset . append ( '<div class="redux-th-warning">' + value . msg + '</div>' ) ;
@@ -1309,7 +1318,6 @@ function redux_change( variable ) {
1309
1318
1310
1319
( function ( $ ) {
1311
1320
var rContainer ;
1312
- var opt_name ;
1313
1321
var parentID ;
1314
1322
var id ;
1315
1323
var th ;
@@ -1324,12 +1332,6 @@ function redux_change( variable ) {
1324
1332
1325
1333
rContainer = $ ( variable ) . parents ( '.redux-container:first' ) ;
1326
1334
1327
- if ( redux . customizer ) {
1328
- opt_name = $ ( '.redux-customizer-opt-name' ) . data ( 'opt-name' ) ;
1329
- } else {
1330
- opt_name = $ . redux . getOptName ( rContainer ) ;
1331
- }
1332
-
1333
1335
$ ( 'body' ) . trigger ( 'check_dependencies' , variable ) ;
1334
1336
1335
1337
if ( variable . hasClass ( 'compiler' ) ) {
@@ -1360,12 +1362,12 @@ function redux_change( variable ) {
1360
1362
$ ( variable ) . parents ( '.redux-container:first' ) . find ( '.redux-field-errors' ) . slideUp ( ) ;
1361
1363
$ ( '#redux_metaboxes_errors' ) . slideUp ( ) ;
1362
1364
} else {
1363
- errorsLeft = ( parseInt ( th . find ( '.redux-menu-error:first' ) . text ( ) , 0 ) - 1 ) ;
1365
+ errorsLeft = ( parseInt ( th . find ( 'li .redux-menu-error:first' ) . text ( ) , 0 ) - 1 ) ;
1364
1366
1365
1367
if ( errorsLeft <= 0 ) {
1366
1368
th . find ( '.redux-menu-error:first' ) . fadeOut ( ) . remove ( ) ;
1367
1369
} else {
1368
- th . find ( '.redux-menu-error:first' ) . text ( errorsLeft ) ;
1370
+ th . find ( 'li .redux-menu-error:first' ) . text ( errorsLeft ) ;
1369
1371
}
1370
1372
1371
1373
rContainer . find ( '.redux-field-errors span' ) . text ( errorCount ) ;
@@ -1393,15 +1395,15 @@ function redux_change( variable ) {
1393
1395
} else {
1394
1396
1395
1397
// Let's count down the warnings now. Fancy. ;).
1396
- warningsLeft = ( parseInt ( th . find ( '.redux-menu-warning:first' ) . text ( ) , 0 ) - 1 ) ;
1398
+ warningsLeft = ( parseInt ( th . find ( 'li .redux-menu-warning:first' ) . text ( ) , 0 ) - 1 ) ;
1397
1399
1398
1400
if ( warningsLeft <= 0 ) {
1399
1401
th . find ( '.redux-menu-warning:first' ) . fadeOut ( ) . remove ( ) ;
1400
1402
} else {
1401
1403
th . find ( '.redux-menu-warning:first' ) . text ( warningsLeft ) ;
1402
1404
}
1403
1405
1404
- rContainer . find ( '.redux-field-warning span' ) . text ( warningCount ) ;
1406
+ rContainer . find ( 'li .redux-field-warning span' ) . text ( warningCount ) ;
1405
1407
}
1406
1408
1407
1409
if ( 0 !== subParent . length ) {
@@ -1465,17 +1467,21 @@ function redux_hook( object, functionName, callback, before ) {
1465
1467
} ;
1466
1468
1467
1469
$ . redux . checkRequired = function ( el ) {
1470
+ var body ;
1471
+
1468
1472
$ . redux . required ( ) ;
1469
1473
1470
- $ ( 'body' ) . on (
1474
+ body = $ ( 'body' ) ;
1475
+
1476
+ body . on (
1471
1477
'change' ,
1472
1478
'.redux-main select, .redux-main radio, .redux-main input[type=checkbox], .redux-main input[type=hidden]' ,
1473
1479
function ( ) {
1474
1480
$ . redux . check_dependencies ( this ) ;
1475
1481
}
1476
1482
) ;
1477
1483
1478
- $ ( ' body' ) . on (
1484
+ body . on (
1479
1485
'check_dependencies' ,
1480
1486
function ( e , variable ) {
1481
1487
e = null ;
@@ -1494,7 +1500,7 @@ function redux_hook( object, functionName, callback, before ) {
1494
1500
1495
1501
// Hide the fold elements on load.
1496
1502
// It's better to do this by PHP but there is no filter in tr tag , so is not possible
1497
- // we going to move each attributes we may need for folding to tr tag.
1503
+ // we're going to move each attributes we may need for folding to tr tag.
1498
1504
$ . each (
1499
1505
redux . opt_names ,
1500
1506
function ( x ) {
@@ -1540,13 +1546,17 @@ function redux_hook( object, functionName, callback, before ) {
1540
1546
} ;
1541
1547
1542
1548
$ . redux . getContainerValue = function ( id ) {
1543
- var value = $ ( '#' + redux . optName . args . opt_name + '-' + id ) . serializeForm ( ) ;
1549
+ var theId ;
1550
+ var value ;
1551
+
1552
+ theId = $ ( '#' + redux . optName . args . opt_name + '-' + id ) ;
1553
+ value = theId . serializeForm ( ) ;
1544
1554
1545
1555
if ( null !== value && 'object' === typeof value && value . hasOwnProperty ( redux . optName . args . opt_name ) ) {
1546
1556
value = value [ redux . optName . args . opt_name ] [ id ] ;
1547
1557
}
1548
1558
1549
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + id ) . hasClass ( 'redux-container-media' ) ) {
1559
+ if ( theId . hasClass ( 'redux-container-media' ) ) {
1550
1560
value = value . url ;
1551
1561
}
1552
1562
@@ -1659,18 +1669,21 @@ function redux_hook( object, functionName, callback, before ) {
1659
1669
var div ;
1660
1670
var rawTable ;
1661
1671
var toFade ;
1672
+ var theId ;
1662
1673
1663
- toFade = $ ( '#' + redux . optName . args . opt_name + '-' + id ) . parents ( 'tr:first' ) ;
1674
+ theId = $ ( '#' + redux . optName . args . opt_name + '-' + id ) ;
1675
+
1676
+ toFade = theId . parents ( 'tr:first' ) ;
1664
1677
if ( 0 === toFade ) {
1665
- toFade = $ ( '#' + redux . optName . args . opt_name + '-' + id ) . parents ( 'li:first' ) ;
1678
+ toFade = theId . parents ( 'li:first' ) ;
1666
1679
}
1667
1680
1668
1681
toFade . fadeOut (
1669
1682
50 ,
1670
1683
function ( ) {
1671
1684
$ ( this ) . addClass ( 'hide' ) ;
1672
1685
1673
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + id ) . hasClass ( 'redux-container-section' ) ) {
1686
+ if ( theId . hasClass ( 'redux-container-section' ) ) {
1674
1687
div = $ ( '#section-' + id ) ;
1675
1688
1676
1689
if ( div . hasClass ( 'redux-section-indent-start' ) ) {
@@ -1679,15 +1692,15 @@ function redux_hook( object, functionName, callback, before ) {
1679
1692
}
1680
1693
}
1681
1694
1682
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + id ) . hasClass ( 'redux-container-info' ) ) {
1695
+ if ( theId . hasClass ( 'redux-container-info' ) ) {
1683
1696
$ ( '#info-' + id ) . fadeOut ( 50 ) . addClass ( 'hide' ) ;
1684
1697
}
1685
1698
1686
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + id ) . hasClass ( 'redux-container-divide' ) ) {
1699
+ if ( theId . hasClass ( 'redux-container-divide' ) ) {
1687
1700
$ ( '#divide-' + id ) . fadeOut ( 50 ) . addClass ( 'hide' ) ;
1688
1701
}
1689
1702
1690
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + id ) . hasClass ( 'redux-container-raw' ) ) {
1703
+ if ( theId . hasClass ( 'redux-container-raw' ) ) {
1691
1704
rawTable = $ ( '#' + redux . optName . args . opt_name + '-' + id ) . parents ( ) . find ( 'table#' + redux . optName . args . opt_name + '-' + id ) ;
1692
1705
rawTable . fadeOut ( 50 ) . addClass ( 'hide' ) ;
1693
1706
}
@@ -1712,12 +1725,15 @@ function redux_hook( object, functionName, callback, before ) {
1712
1725
redux . optName . required_child [ id ] ,
1713
1726
function ( i , parentData ) {
1714
1727
var parentValue ;
1728
+ var parent ;
1729
+
1730
+ parent = $ ( '#' + redux . optName . args . opt_name + '-' + parentData . parent ) ;
1715
1731
1716
1732
i = null ;
1717
1733
1718
- if ( $ ( '#' + redux . optName . args . opt_name + '-' + parentData . parent ) . parents ( 'tr:first' ) . hasClass ( 'hide' ) ) {
1734
+ if ( parent . parents ( 'tr:first' ) . hasClass ( 'hide' ) ) {
1719
1735
show = false ;
1720
- } else if ( $ ( '#' + redux . optName . args . opt_name + '-' + parentData . parent ) . parents ( 'li:first' ) . hasClass ( 'hide' ) ) {
1736
+ } else if ( parent . parents ( 'li:first' ) . hasClass ( 'hide' ) ) {
1721
1737
show = false ;
1722
1738
} else {
1723
1739
if ( false !== show ) {
@@ -2009,30 +2025,33 @@ function redux_hook( object, functionName, callback, before ) {
2009
2025
$ . redux = $ . redux || { } ;
2010
2026
2011
2027
$ . redux . stickyInfo = function ( ) {
2028
+ var sticky = $ ( '#redux-sticky' ) ;
2029
+ var infoBar = $ ( '#info_bar' ) ;
2030
+ var reduxFooter = $ ( '#redux-footer' ) ;
2012
2031
var stickyWidth = $ ( '.redux-main' ) . innerWidth ( ) - 20 ;
2013
- var $width = $ ( '#redux- sticky' ) . offset ( ) . left ;
2032
+ var $width = sticky . offset ( ) . left ;
2014
2033
2015
2034
$ ( '.redux-save-warn' ) . css ( 'left' , $width + 'px' ) ;
2016
2035
2017
- if ( ! $ ( '#info_bar' ) . isOnScreen ( ) && ! $ ( '#redux-footer-sticky' ) . isOnScreen ( ) ) {
2018
- $ ( '#redux-footer' ) . css (
2036
+ if ( ! infoBar . isOnScreen ( ) && ! $ ( '#redux-footer-sticky' ) . isOnScreen ( ) ) {
2037
+ reduxFooter . css (
2019
2038
{ position : 'fixed' , bottom : '0' , width : stickyWidth , right : 21 }
2020
2039
) ;
2021
2040
2022
- $ ( '#redux-footer' ) . addClass ( 'sticky-footer-fixed' ) ;
2041
+ reduxFooter . addClass ( 'sticky-footer-fixed' ) ;
2023
2042
$ ( '#redux-sticky-padder' ) . show ( ) ;
2024
2043
} else {
2025
- $ ( '#redux-footer' ) . css (
2044
+ reduxFooter . css (
2026
2045
{ background : '#eee' , position : 'inherit' , bottom : 'inherit' , width : 'inherit' }
2027
2046
) ;
2028
2047
2029
2048
$ ( '#redux-sticky-padder' ) . hide ( ) ;
2030
- $ ( '#redux-footer' ) . removeClass ( 'sticky-footer-fixed' ) ;
2049
+ reduxFooter . removeClass ( 'sticky-footer-fixed' ) ;
2031
2050
}
2032
- if ( ! $ ( '#info_bar' ) . isOnScreen ( ) ) {
2033
- $ ( '#redux- sticky' ) . addClass ( 'sticky-save-warn' ) ;
2051
+ if ( ! infoBar . isOnScreen ( ) ) {
2052
+ sticky . addClass ( 'sticky-save-warn' ) ;
2034
2053
} else {
2035
- $ ( '#redux- sticky' ) . removeClass ( 'sticky-save-warn' ) ;
2054
+ sticky . removeClass ( 'sticky-save-warn' ) ;
2036
2055
}
2037
2056
} ;
2038
2057
} ) ( jQuery ) ;
@@ -2073,9 +2092,9 @@ function redux_hook( object, functionName, callback, before ) {
2073
2092
link = elements . slice ( index + 1 , index + 2 ) ;
2074
2093
}
2075
2094
2076
- el = link . parents ( '.redux-container:first' ) ;
2077
- relid = link . data ( 'rel' ) ; // The group ID of interest.
2078
- oldid = el . find ( '.redux-group-tab-link-li.active:first .redux-group-tab-link-a' ) . data ( 'rel' ) ;
2095
+ el = link . parents ( '.redux-container:first' ) ;
2096
+ relid = link . data ( 'rel' ) ; // The group ID of interest.
2097
+ oldid = el . find ( '.redux-group-tab-link-li.active:first .redux-group-tab-link-a' ) . data ( 'rel' ) ;
2079
2098
opt_name = $ . redux . getOptName ( el ) ;
2080
2099
2081
2100
if ( oldid === relid ) {
0 commit comments