Skip to content
This repository was archived by the owner on Jan 24, 2023. It is now read-only.

Commit efa5937

Browse files
committed
v1.0.8
1 parent d14c681 commit efa5937

13 files changed

Lines changed: 445 additions & 272 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
gulpfile.js
77
gulpconfig.json
88
package.json
9+
jsconfig.json
910

1011
# node modules
1112
/node_modules

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [1.0.8] - 2016-08-08
6+
### Fixed
7+
- Fix some code missing in last version
8+
59
## [1.0.7] - 2016-07-29
610
### Fixed
711
- Fix WP editor read more tag image height (thanks @josephbydeign)

admin/js/pine-customize-control-color-scheme.js

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
11
( function( wp, $ ) {
2+
'use strict';
23

3-
wp.customize.ColorSchemeControl = wp.customize.Control.extend({
4+
wp.customize.ColorSchemeControl = wp.customize.Control.extend( {
45
ready: function() {
56
var control = this,
67
radios = $( '.radios', this.container ),
78
selection = $( '.selection', this.container ),
89
$schemes = $( '.scheme', selection ),
910
schemes = control.params.schemes,
1011
colors = control.setting.get() !== 'custom' ? schemes[ control.setting.get() ].colors : {},
11-
colors_handler,
12+
colorsHandler,
1213
apply = $( '.apply-scheme', this.container );
1314

14-
var schemes_colors = [];
15-
16-
colors_handler = function( to ) {
17-
if ( schemes_colors.length == 0 ) {
18-
for ( scheme in schemes ) {
19-
schemes_colors.push( schemes[scheme].color );
20-
21-
$.each( schemes[scheme].colors, function( key, value ) {
22-
if ( wp.customize.has( key ) ) {
23-
wp.customize( key, function( setting ) {
24-
if ( setting.color_scheme_binded !== true ) {
25-
setting.bind( colors_change_handler );
26-
setting.color_scheme_binded = true;
27-
}
28-
} );
29-
}
30-
} );
15+
var schemesColors = [];
16+
17+
var addColorsChangeHandler = function( key ) {
18+
if ( wp.customize.has( key ) ) {
19+
wp.customize( key, function( setting ) {
20+
if ( true !== setting.colorSchemeBinded ) {
21+
setting.bind( colorsChangeHandler );
22+
setting.colorSchemeBinded = true;
23+
}
24+
} );
25+
}
26+
};
27+
28+
colorsHandler = function( to ) {
29+
if ( 0 === schemesColors.length ) {
30+
for ( var scheme in schemes ) {
31+
schemesColors.push( schemes[scheme].color );
32+
33+
$.each( schemes[scheme].colors, addColorsChangeHandler );
3134
}
3235
}
3336

34-
if ( to == 'custom' ) return;
37+
if ( 'custom' === to ) {
38+
return;
39+
}
40+
3541
colors = schemes[ to ].colors;
3642
$.each( colors, function( key, value ) {
3743
if ( wp.customize.has( key ) ) {
@@ -48,53 +54,55 @@
4854
} );
4955
};
5056

51-
var change_handler = function() {
57+
var changeHandler = function() {
5258
var scheme = $( '[data-value="' + control.setting.get() + '"]', selection );
5359
$( '.scheme.selected', selection ).removeClass( 'selected' );
5460

5561
scheme.addClass( 'selected' );
5662
};
5763

58-
var change_timeout = null;
64+
var changeTimeout = null;
5965

60-
var colors_change_handler = function() {
61-
if ( change_timeout !== null )
62-
clearTimeout( change_timeout );
66+
var colorsChangeHandler = function() {
67+
if ( changeTimeout !== null ) {
68+
clearTimeout( changeTimeout );
69+
}
6370

64-
if ( control.setting.get() == 'custom' ) return false;
71+
if ( 'custom' === control.setting.get() ) {
72+
return false;
73+
}
6574

6675
var equal = true;
67-
var is_first = true;
68-
var last_color = '';
69-
var current_color = '';
76+
var isFirst = true;
77+
var lastColor = '';
78+
var currentColor = '';
79+
var allSettings = wp.customize.get();
7080

71-
for ( color in colors ) {
81+
for ( var color in colors ) {
7282
if ( wp.customize.has( color ) ) {
73-
wp.customize( color, function( setting ) {
74-
current_color = setting.get();
75-
} );
83+
currentColor = allSettings[ color ];
7684

77-
if ( ! is_first ) {
78-
if ( last_color !== current_color ) {
85+
if ( ! isFirst ) {
86+
if ( lastColor !== currentColor ) {
7987
equal = false;
8088
break;
8189
}
8290
}
8391
else {
84-
is_first = false;
85-
last_color = current_color;
86-
if ( schemes_colors.indexOf( last_color ) < 0 ) {
92+
isFirst = false;
93+
lastColor = currentColor;
94+
if ( schemesColors.indexOf( lastColor ) < 0 ) {
8795
equal = false;
8896
break;
8997
}
9098
}
9199
}
92100
}
93101

94-
if ( equal == false ) {
95-
change_timeout = setTimeout( function() {
102+
if ( false === equal ) {
103+
changeTimeout = setTimeout( function() {
96104
control.setting.set( 'custom' );
97-
change_timeout = null;
105+
changeTimeout = null;
98106
}, 200 );
99107
}
100108

@@ -104,21 +112,23 @@
104112
radios.hide();
105113
$( '.scheme[data-value="' + control.setting.get() + '"]', selection ).addClass( 'selected' );
106114

107-
control.setting.bind( change_handler );
108-
colors_handler( control.setting.get() );
109-
change_handler();
115+
control.setting.bind( changeHandler );
116+
colorsHandler( control.setting.get() );
117+
changeHandler();
110118

111119
apply.on( 'click', function( event ) {
112120
event.preventDefault();
113121

114-
colors_handler( control.setting.get() );
122+
colorsHandler( control.setting.get() );
115123
} );
116124

117125
$( '.color', $schemes ).on( 'click', function( event ) {
118126
event.preventDefault();
119127

120128
var scheme = $( this ).closest( '.scheme' );
121-
if ( scheme.hasClass( 'selected' ) ) return;
129+
if ( scheme.hasClass( 'selected' ) ) {
130+
return;
131+
}
122132

123133
control.setting.set( scheme.data( 'value' ) );
124134
} );

admin/js/pine-customize-control-layout.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
( function( wp, $ ) {
2+
'use strict';
23

3-
wp.customize.LayoutControl = wp.customize.Control.extend({
4+
wp.customize.LayoutControl = wp.customize.Control.extend( {
45
ready: function() {
56
var control = this,
67
radios = $( '.radios', this.container ),
@@ -13,7 +14,9 @@
1314
event.preventDefault();
1415

1516
var layout = $( this ).closest( '.layout' );
16-
if ( layout.hasClass( 'selected' ) ) return;
17+
if ( layout.hasClass( 'selected' ) ) {
18+
return;
19+
}
1720

1821
var container = layout.closest( '.customize-control-layout' );
1922
$( '.selection .layout', container ).removeClass( 'selected' );
@@ -23,7 +26,7 @@
2326
control.setting.set( layout.data( 'value' ) );
2427
} );
2528
}
26-
});
29+
} );
2730

2831
$.extend( wp.customize.controlConstructor, {
2932
'layout': wp.customize.LayoutControl,

0 commit comments

Comments
 (0)