engine/app/assets/javascripts/admin/theme_assets.js

49 lines
1.4 KiB
JavaScript
Raw Normal View History

2010-05-11 21:38:52 +00:00
/* ___ file or text ___ */
var enableFileOrTextToggling = function() {
$('div.hidden').hide();
2010-05-11 21:38:52 +00:00
var fileSelectorFieldset = $('div#file-selector fieldset');
var textSelectorFieldset = $('div#text-selector fieldset');
$('span.alt').click(function(event) {
event.preventDefault();
if ($("div#file-selector").is(":hidden")) {
$("div#text-selector").slideUp("normal", function() {
$("div#file-selector").slideDown();
$("input#theme_asset_performing_plain_text").val(false);
fileSelectorFieldset.trigger('refresh');
});
2010-05-11 21:38:52 +00:00
} else {
$("div#file-selector").slideUp("normal", function() {
$("div#text-selector").slideDown();
$("input#theme_asset_performing_plain_text").val(true);
textSelectorFieldset.trigger('refresh');
});
2010-05-11 21:38:52 +00:00
}
});
2010-06-02 00:39:05 +00:00
}
2010-05-11 21:38:52 +00:00
$(document).ready(function() {
enableFileOrTextToggling();
$('code.stylesheet textarea').each(function() {
addCodeMirrorEditor(null, $(this), 'CSS');
});
$('code.javascript textarea').each(function() {
addCodeMirrorEditor(null, $(this), 'JS');
});
$('select#theme_asset_content_type').bind('change', function() {
var editor = CodeMirrorEditors[0].editor;
editor.setParser($(this).val() == 'stylesheet' ? 'CSSParser' : 'JSParser');
});
$('a#image-picker-link').imagepicker({
insertFn: function(link) {
return link.attr('href');
}
});
});