2010-04-25 00:33:38 +00:00
|
|
|
var I18nLocale = null;
|
2010-05-02 23:33:17 +00:00
|
|
|
var CodeMirrorEditors = [];
|
2010-04-25 00:33:38 +00:00
|
|
|
|
|
|
|
/* ___ growl ___ */
|
|
|
|
|
|
|
|
$.growl.settings.noticeTemplate = '' +
|
|
|
|
'<div class="notice %title%">' +
|
|
|
|
' <p>%message%</p>' +
|
|
|
|
'</div>';
|
|
|
|
|
|
|
|
$.growl.settings.dockCss = {
|
|
|
|
position: 'fixed',
|
|
|
|
bottom: '20px',
|
|
|
|
left: '0px',
|
|
|
|
width: '100%',
|
|
|
|
zIndex: 50000
|
|
|
|
};
|
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
/* ___ codemirror ___ */
|
|
|
|
|
|
|
|
var addCodeMirrorEditor = function(type, el, parser) {
|
2010-06-08 00:45:49 +00:00
|
|
|
if (type == 'liquid') type = 'xml';
|
2010-05-02 23:33:17 +00:00
|
|
|
var parserfile = "parse" + type + ".js";
|
2010-06-08 00:45:49 +00:00
|
|
|
if (parser != undefined) parserfile = parser;
|
2010-05-02 23:33:17 +00:00
|
|
|
|
|
|
|
var editor = CodeMirror.fromTextArea(el.attr('id'), {
|
2010-05-09 12:44:53 +00:00
|
|
|
height: "400px",
|
2010-05-02 23:33:17 +00:00
|
|
|
parserfile: parserfile,
|
2010-06-02 00:39:05 +00:00
|
|
|
stylesheet: [
|
|
|
|
"/stylesheets/admin/plugins/codemirror/csscolors.css",
|
2010-06-08 00:45:49 +00:00
|
|
|
"/stylesheets/admin/plugins/codemirror/xmlcolors.css",
|
2010-06-02 00:39:05 +00:00
|
|
|
"/stylesheets/admin/plugins/codemirror/javascriptcolors.css",
|
|
|
|
"/stylesheets/admin/plugins/codemirror/liquidcolors.css"],
|
2010-05-02 23:33:17 +00:00
|
|
|
path: "/javascripts/admin/plugins/codemirror/",
|
|
|
|
continuousScanning: 500,
|
|
|
|
reindentOnLoad: true,
|
|
|
|
initCallback: function(editor) {
|
|
|
|
jQuery(editor.frame.contentDocument).keypress(function(event) {
|
|
|
|
jQuery(document).trigger(event);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
CodeMirrorEditors.push({ 'el': el, 'editor': editor });
|
|
|
|
}
|
|
|
|
|
2010-06-22 13:04:40 +00:00
|
|
|
/* ___ tinyMCE ___ */
|
|
|
|
|
|
|
|
var TinyMceDefaultSettings = {
|
|
|
|
script_url : '/javascripts/admin/plugins/tiny_mce/tiny_mce.js',
|
|
|
|
theme : 'advanced',
|
|
|
|
skin : 'locomotive',
|
2010-06-24 09:14:08 +00:00
|
|
|
theme_advanced_buttons1 : 'code,|,bold,italic,|,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink,|,formatselect,fontselect,fontsizeselect',
|
|
|
|
theme_advanced_buttons2 : '',
|
2010-06-22 13:04:40 +00:00
|
|
|
theme_advanced_buttons3 : ''
|
|
|
|
};
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
/* ___ global ___ */
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
I18nLocale = $('meta[name=locale]').attr('content');
|
|
|
|
|
2010-05-26 00:41:10 +00:00
|
|
|
// sub menu links
|
|
|
|
$('#submenu ul li.links').hover(function() {
|
|
|
|
$(this).addClass('hover');
|
|
|
|
$(this).find('.popup').show();
|
|
|
|
}, function() {
|
|
|
|
$(this).removeClass('hover');
|
|
|
|
$(this).find('.popup').hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
if ((css = $('#submenu > ul').attr('class')) != '')
|
|
|
|
$('#submenu > ul > li.' + css).addClass('on');
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
// form
|
2010-06-24 09:14:08 +00:00
|
|
|
$('.formtastic li input, .formtastic li textarea, .formtastic li code').focus(function() {
|
|
|
|
$('.formtastic li.error:not(.code) p.inline-errors').fadeOut(200);
|
2010-04-25 00:33:38 +00:00
|
|
|
if ($(this).parent().hasClass('error')) {
|
|
|
|
$(this).nextAll('p.inline-errors').show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.formtastic li.error input').eq(0).focus();
|
|
|
|
|
2010-07-13 00:46:17 +00:00
|
|
|
// save form in AJAX
|
|
|
|
$('form.save-with-shortcut').saveWithShortcut();
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
// editable title (page, ...etc)
|
|
|
|
$('#content h2 a.editable').each(function() {
|
|
|
|
var target = $('#' + $(this).attr('rel')),
|
|
|
|
hint = $(this).attr('title');
|
|
|
|
|
|
|
|
target.parent().hide();
|
|
|
|
|
|
|
|
$(this).click(function(event) {
|
|
|
|
var newValue = prompt(hint, $(this).html());
|
|
|
|
if (newValue && newValue != '') {
|
|
|
|
$(this).html(newValue);
|
|
|
|
target.val(newValue);
|
|
|
|
}
|
|
|
|
event.preventDefault();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
// foldable
|
|
|
|
$('.formtastic fieldset.foldable legend span').append('<em> </em>');
|
|
|
|
$('.formtastic fieldset.foldable.folded ol').hide();
|
|
|
|
$('.formtastic fieldset.foldable legend').click(function() {
|
|
|
|
var parent = $(this).parent(), content = $(this).next();
|
|
|
|
if (parent.hasClass('folded')) {
|
|
|
|
parent.removeClass('folded');
|
2010-05-02 23:33:17 +00:00
|
|
|
content.slideDown('fast', function() { });
|
2010-04-25 00:33:38 +00:00
|
|
|
} else
|
2010-05-02 23:33:17 +00:00
|
|
|
content.slideUp('fast', function() { parent.addClass('folded'); });
|
2010-04-25 00:33:38 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// nifty checkboxes
|
|
|
|
$('.formtastic li.toggle input[type=checkbox]').checkToggle();
|
2010-05-02 23:33:17 +00:00
|
|
|
|
|
|
|
// nifty code editor
|
|
|
|
$('code.html textarea').each(function() { addCodeMirrorEditor('liquid', $(this)); });
|
2010-04-25 00:33:38 +00:00
|
|
|
});
|