| 1 |
(function($, exports){ |
| 2 |
$(document).ready(function(){ |
| 3 |
var api = parent.wp.customize, |
| 4 |
wp_settings = api.settings.settings; |
| 5 |
api.previewer.bind('highlight',function(e){ |
| 6 |
$('.customizerHighlight').removeClass('customizerHighlight'); |
| 7 |
|
| 8 |
if ( $(e).length > 0 ) { |
| 9 |
$(e).each(function(){ |
| 10 |
$(this).addClass('customizerHighlight'); |
| 11 |
}); |
| 12 |
} |
| 13 |
}); |
| 14 |
|
| 15 |
$.each( customify_settings.settings, function( key, el){ |
| 16 |
|
| 17 |
if ( typeof wp_settings[key] !== "undefined" && typeof el.css !== "undefined" && typeof el.live !== 'undefined' && el.live === true ) { |
| 18 |
|
| 19 |
var sliced_id = key.slice(0, -1); |
| 20 |
sliced_id = sliced_id.replace(customify_settings.options_name + '[', ''); |
| 21 |
|
| 22 |
api( key, function (setting) { |
| 23 |
|
| 24 |
setting.bind(function (to) { |
| 25 |
var properties = []; |
| 26 |
|
| 27 |
$.each(el.css, function (counter, property_config) { |
| 28 |
|
| 29 |
properties[property_config.property] = property_config.selector; |
| 30 |
if ( typeof property_config.callback_filter !== "undefined" ) { |
| 31 |
properties['callback'] = property_config.callback_filter; |
| 32 |
} |
| 33 |
|
| 34 |
var css_update_args = { |
| 35 |
properties: properties, |
| 36 |
propertyValue: to |
| 37 |
}; |
| 38 |
|
| 39 |
if ( typeof this.unit !== 'undefined' ) { |
| 40 |
css_update_args.unit = this.unit; |
| 41 |
} |
| 42 |
|
| 43 |
var req_Exp_for_multiple_replace = new RegExp('-', 'g'); |
| 44 |
$( '#dynamic_setting_' + sliced_id + '_property_' + property_config.property.replace(req_Exp_for_multiple_replace, '_') ).cssUpdate( css_update_args ); |
| 45 |
}); |
| 46 |
|
| 47 |
}); |
| 48 |
}); |
| 49 |
} else if ( typeof el.live === "object" && el.live.length > 0 ) { |
| 50 |
|
| 51 |
// if the live parameter is an object it means that is a list of css classes |
| 52 |
// these classes should be affected by the change of the text fields |
| 53 |
var field_class = el.live.join(); |
| 54 |
|
| 55 |
// if this field is allowed to modify text then we'll edit this live |
| 56 |
if ( $.inArray( el.type, ['text', 'textarea', 'ace_editor']) > -1 ) { |
| 57 |
wp.customize( key, function( value ) { |
| 58 |
value.bind( function( text ) { |
| 59 |
$( field_class ).text( text ); |
| 60 |
} ); |
| 61 |
} ); |
| 62 |
} |
| 63 |
} |
| 64 |
}); |
| 65 |
|
| 66 |
|
| 67 |
api( 'live_css_edit', function (setting) { |
| 68 |
setting.bind(function (new_text) { |
| 69 |
$('#customify_css_editor_output' ).text(new_text); |
| 70 |
}); |
| 71 |
}); |
| 72 |
}); |
| 73 |
})(jQuery, window); |
| 74 |
|