| 1 |
(function($, exports){ |
| 2 |
|
| 3 |
var timeout = null; |
| 4 |
|
| 5 |
$(document).ready(function(){ |
| 6 |
var api = wp.customize; |
| 7 |
if ( $('#css_editor').length < 1 ) { |
| 8 |
return ; |
| 9 |
} |
| 10 |
var css_editor = ace.edit("css_editor"); |
| 11 |
css_editor.$blockScrolling = Infinity; |
| 12 |
|
| 13 |
// init the ace editor |
| 14 |
css_editor.setTheme("ace/theme/github"); |
| 15 |
css_editor.getSession().setMode("ace/mode/css"); |
| 16 |
|
| 17 |
// hide the textarea and enable the ace editor |
| 18 |
var textarea = $('#css_editor_textarea').hide(); |
| 19 |
css_editor.getSession().setValue(textarea.val()); |
| 20 |
|
| 21 |
var customizer_overlay = $('.wp-full-overlay'); |
| 22 |
|
| 23 |
// open the ace editor section when we click on the panel |
| 24 |
$('#accordion-section-live_css_edit_section').on('click', function(){ |
| 25 |
customizer_overlay.addClass('editor_opened'); |
| 26 |
}); |
| 27 |
|
| 28 |
$(document).on('click', '.customize-section-back', function(){ |
| 29 |
customizer_overlay.removeClass('editor_opened'); |
| 30 |
}); |
| 31 |
|
| 32 |
// each time a change is triggered also make those edits in the preview |
| 33 |
css_editor.getSession().on('change', function(e) { |
| 34 |
textarea.val(css_editor.getSession().getValue()); |
| 35 |
textarea.trigger('change'); |
| 36 |
}); |
| 37 |
|
| 38 |
}); |
| 39 |
})(jQuery, window); |
| 40 |
|