Code Duplication    Length = 63-63 lines in 4 locations

controls/js/src/typography-legacy.js 1 location

@@ 107-169 (lines=63) @@
104
	 * Adds the font-families to the font-family dropdown
105
	 * and instantiates selectWoo.
106
	 */
107
	renderFontSelector: function() {
108
109
		var control         = this,
110
		    selector        = control.selector + ' .font-family select',
111
		    data            = [],
112
		    standardFonts   = [],
113
		    googleFonts     = [],
114
		    value           = control.getValue(),
115
		    fonts           = control.getFonts(),
116
		    fontSelect;
117
118
		// Format standard fonts as an array.
119
		if ( ! _.isUndefined( fonts.standard ) ) {
120
			_.each( fonts.standard, function( font ) {
121
				standardFonts.push({
122
					id: font.family.replace( /"/g, '&#39' ),
123
					text: font.label
124
				});
125
			});
126
		}
127
128
		// Format google fonts as an array.
129
		if ( ! _.isUndefined( fonts.standard ) ) {
130
			_.each( fonts.google, function( font ) {
131
				googleFonts.push({
132
					id: font.family,
133
					text: font.label
134
				});
135
			});
136
		}
137
138
		// Combine forces and build the final data.
139
		data = [
140
			{ text: 'Standard Fonts', children: standardFonts },
141
			{ text: 'Google Fonts',   children: googleFonts }
142
		];
143
144
		// Instantiate selectWoo with the data.
145
		fontSelect = jQuery( selector ).selectWoo({
146
			data: data
147
		});
148
149
		// Set the initial value.
150
		if ( value['font-family'] ) {
151
			fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
152
		}
153
154
		// When the value changes
155
		fontSelect.on( 'change', function() {
156
157
			// Set the value.
158
			control.saveValue( 'font-family', jQuery( this ).val() );
159
160
			// Re-init the font-backup selector.
161
			control.renderBackupFontSelector();
162
163
			// Re-init variants selector.
164
			control.renderVariantSelector();
165
166
			// Re-init subsets selector.
167
			control.renderSubsetSelector();
168
		});
169
	},
170
171
	/**
172
	 * Adds the font-families to the font-family dropdown

controls/js/src/typography.js 1 location

@@ 99-161 (lines=63) @@
96
	 * Adds the font-families to the font-family dropdown
97
	 * and instantiates selectWoo.
98
	 */
99
	renderFontSelector: function() {
100
101
		var control         = this,
102
		    selector        = control.selector + ' .font-family select',
103
		    data            = [],
104
		    standardFonts   = [],
105
		    googleFonts     = [],
106
		    value           = control.setting._value,
107
		    fonts           = control.getFonts(),
108
		    fontSelect;
109
110
		// Format standard fonts as an array.
111
		if ( ! _.isUndefined( fonts.standard ) ) {
112
			_.each( fonts.standard, function( font ) {
113
				standardFonts.push({
114
					id: font.family.replace( /"/g, '&#39' ),
115
					text: font.label
116
				});
117
			});
118
		}
119
120
		// Format google fonts as an array.
121
		if ( ! _.isUndefined( fonts.google ) ) {
122
			_.each( fonts.google, function( font ) {
123
				googleFonts.push({
124
					id: font.family,
125
					text: font.family
126
				});
127
			});
128
		}
129
130
		// Combine forces and build the final data.
131
		data = [
132
			{ text: kirkiL10n.standardFonts, children: standardFonts },
133
			{ text: kirkiL10n.googleFonts, children: googleFonts }
134
		];
135
136
		// Instantiate selectWoo with the data.
137
		fontSelect = jQuery( selector ).selectWoo({
138
			data: data
139
		});
140
141
		// Set the initial value.
142
		if ( value['font-family'] ) {
143
			fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
144
		}
145
146
		// When the value changes
147
		fontSelect.on( 'change', function() {
148
149
			// Set the value.
150
			control.saveValue( 'font-family', jQuery( this ).val() );
151
152
			// Re-init the font-backup selector.
153
			control.renderBackupFontSelector();
154
155
			// Re-init variants selector.
156
			control.renderVariantSelector();
157
158
			// Re-init subsets selector.
159
			control.renderSubsetSelector();
160
		});
161
	},
162
163
	/**
164
	 * Adds the font-families to the font-family dropdown

controls/js/script-legacy.js 1 location

@@ 3348-3410 (lines=63) @@
3345
	 * Adds the font-families to the font-family dropdown
3346
	 * and instantiates selectWoo.
3347
	 */
3348
	renderFontSelector: function() {
3349
3350
		var control         = this,
3351
		    selector        = control.selector + ' .font-family select',
3352
		    data            = [],
3353
		    standardFonts   = [],
3354
		    googleFonts     = [],
3355
		    value           = control.getValue(),
3356
		    fonts           = control.getFonts(),
3357
		    fontSelect;
3358
3359
		// Format standard fonts as an array.
3360
		if ( ! _.isUndefined( fonts.standard ) ) {
3361
			_.each( fonts.standard, function( font ) {
3362
				standardFonts.push({
3363
					id: font.family.replace( /"/g, '&#39' ),
3364
					text: font.label
3365
				});
3366
			});
3367
		}
3368
3369
		// Format google fonts as an array.
3370
		if ( ! _.isUndefined( fonts.standard ) ) {
3371
			_.each( fonts.google, function( font ) {
3372
				googleFonts.push({
3373
					id: font.family,
3374
					text: font.label
3375
				});
3376
			});
3377
		}
3378
3379
		// Combine forces and build the final data.
3380
		data = [
3381
			{ text: 'Standard Fonts', children: standardFonts },
3382
			{ text: 'Google Fonts',   children: googleFonts }
3383
		];
3384
3385
		// Instantiate selectWoo with the data.
3386
		fontSelect = jQuery( selector ).selectWoo({
3387
			data: data
3388
		});
3389
3390
		// Set the initial value.
3391
		if ( value['font-family'] ) {
3392
			fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
3393
		}
3394
3395
		// When the value changes
3396
		fontSelect.on( 'change', function() {
3397
3398
			// Set the value.
3399
			control.saveValue( 'font-family', jQuery( this ).val() );
3400
3401
			// Re-init the font-backup selector.
3402
			control.renderBackupFontSelector();
3403
3404
			// Re-init variants selector.
3405
			control.renderVariantSelector();
3406
3407
			// Re-init subsets selector.
3408
			control.renderSubsetSelector();
3409
		});
3410
	},
3411
3412
	/**
3413
	 * Adds the font-families to the font-family dropdown

controls/js/script.js 1 location

@@ 3299-3361 (lines=63) @@
3296
	 * Adds the font-families to the font-family dropdown
3297
	 * and instantiates selectWoo.
3298
	 */
3299
	renderFontSelector: function() {
3300
3301
		var control         = this,
3302
		    selector        = control.selector + ' .font-family select',
3303
		    data            = [],
3304
		    standardFonts   = [],
3305
		    googleFonts     = [],
3306
		    value           = control.setting._value,
3307
		    fonts           = control.getFonts(),
3308
		    fontSelect;
3309
3310
		// Format standard fonts as an array.
3311
		if ( ! _.isUndefined( fonts.standard ) ) {
3312
			_.each( fonts.standard, function( font ) {
3313
				standardFonts.push({
3314
					id: font.family.replace( /"/g, '&#39' ),
3315
					text: font.label
3316
				});
3317
			});
3318
		}
3319
3320
		// Format google fonts as an array.
3321
		if ( ! _.isUndefined( fonts.google ) ) {
3322
			_.each( fonts.google, function( font ) {
3323
				googleFonts.push({
3324
					id: font.family,
3325
					text: font.family
3326
				});
3327
			});
3328
		}
3329
3330
		// Combine forces and build the final data.
3331
		data = [
3332
			{ text: kirkiL10n.standardFonts, children: standardFonts },
3333
			{ text: kirkiL10n.googleFonts, children: googleFonts }
3334
		];
3335
3336
		// Instantiate selectWoo with the data.
3337
		fontSelect = jQuery( selector ).selectWoo({
3338
			data: data
3339
		});
3340
3341
		// Set the initial value.
3342
		if ( value['font-family'] ) {
3343
			fontSelect.val( value['font-family'].replace( /'/g, '"' ) ).trigger( 'change' );
3344
		}
3345
3346
		// When the value changes
3347
		fontSelect.on( 'change', function() {
3348
3349
			// Set the value.
3350
			control.saveValue( 'font-family', jQuery( this ).val() );
3351
3352
			// Re-init the font-backup selector.
3353
			control.renderBackupFontSelector();
3354
3355
			// Re-init variants selector.
3356
			control.renderVariantSelector();
3357
3358
			// Re-init subsets selector.
3359
			control.renderSubsetSelector();
3360
		});
3361
	},
3362
3363
	/**
3364
	 * Adds the font-families to the font-family dropdown