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