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 = '' +
|
2010-07-23 20:20:09 +00:00
|
|
|
'<div class="notice %title%">' +
|
|
|
|
' <p>%message%</p>' +
|
|
|
|
'</div>';
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
$.growl.settings.dockCss = {
|
2010-07-23 20:20:09 +00:00
|
|
|
position: 'fixed',
|
|
|
|
bottom: '20px',
|
|
|
|
left: '0px',
|
|
|
|
width: '100%',
|
|
|
|
zIndex: 50000
|
2010-04-25 00:33:38 +00:00
|
|
|
};
|
|
|
|
|
2010-05-02 23:33:17 +00:00
|
|
|
/* ___ codemirror ___ */
|
|
|
|
|
|
|
|
var addCodeMirrorEditor = function(type, el, parser) {
|
2011-01-12 15:54:09 +00:00
|
|
|
parser = (parser || 'Liquid') + 'Parser';
|
2010-07-23 20:20:09 +00:00
|
|
|
|
|
|
|
var editor = CodeMirror.fromTextArea(el.attr('id'), {
|
2011-06-01 21:43:12 +00:00
|
|
|
height: el.hasClass('small') ? '60px' : '400px',
|
2010-07-23 20:20:09 +00:00
|
|
|
stylesheet: [
|
|
|
|
"/stylesheets/admin/plugins/codemirror/csscolors.css",
|
|
|
|
"/stylesheets/admin/plugins/codemirror/xmlcolors.css",
|
|
|
|
"/stylesheets/admin/plugins/codemirror/javascriptcolors.css",
|
|
|
|
"/stylesheets/admin/plugins/codemirror/liquidcolors.css"],
|
2011-01-12 15:54:09 +00:00
|
|
|
basefiles: '/javascripts/admin/plugins/codemirror/codemirror_base.min.js',
|
2010-07-23 20:20:09 +00:00
|
|
|
continuousScanning: 500,
|
|
|
|
reindentOnLoad: true,
|
|
|
|
initCallback: function(editor) {
|
2011-01-12 15:54:09 +00:00
|
|
|
jQuery(editor.frame.contentDocument).keydown(function(event) {
|
2010-07-23 20:20:09 +00:00
|
|
|
jQuery(document).trigger(event);
|
|
|
|
});
|
2011-01-12 15:54:09 +00:00
|
|
|
editor.setParser(parser);
|
2010-07-23 20:20:09 +00:00
|
|
|
}
|
|
|
|
});
|
2011-01-12 15:54:09 +00:00
|
|
|
|
2010-07-23 20:20:09 +00:00
|
|
|
CodeMirrorEditors.push({ 'el': el, 'editor': editor });
|
2010-05-02 23:33:17 +00:00
|
|
|
}
|
|
|
|
|
2010-06-22 13:04:40 +00:00
|
|
|
/* ___ tinyMCE ___ */
|
|
|
|
|
|
|
|
var TinyMceDefaultSettings = {
|
2010-07-23 20:20:09 +00:00
|
|
|
script_url : '/javascripts/admin/plugins/tiny_mce/tiny_mce.js',
|
|
|
|
theme : 'advanced',
|
2010-09-15 00:21:46 +00:00
|
|
|
skin : 'locomotive',
|
2011-07-03 09:02:52 +00:00
|
|
|
plugins: 'safari,inlinepopups,locomedia,fullscreen',
|
2011-06-21 20:03:24 +00:00
|
|
|
extended_valid_elements: 'iframe[width|height|frameborder|allowfullscreen|src|title]',
|
2011-07-03 09:02:52 +00:00
|
|
|
theme_advanced_buttons1 : 'fullscreen,code,|,bold,italic,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,blockquote,|,link,unlink',
|
2011-06-21 12:47:11 +00:00
|
|
|
theme_advanced_buttons2 : 'formatselect,fontselect,fontsizeselect,|,locomedia',
|
2010-09-06 21:47:03 +00:00
|
|
|
theme_advanced_buttons3 : '',
|
|
|
|
theme_advanced_toolbar_location : "top",
|
|
|
|
theme_advanced_toolbar_align : "left",
|
|
|
|
height: '300',
|
|
|
|
width: '710',
|
2011-02-12 14:00:57 +00:00
|
|
|
inlinepopups_skin: 'locomotive',
|
2011-07-03 09:02:52 +00:00
|
|
|
convert_urls: false,
|
|
|
|
fullscreen_new_window : false,
|
|
|
|
fullscreen_settings : {
|
|
|
|
theme_advanced_path_location : "top"
|
2011-07-19 03:56:26 +00:00
|
|
|
},
|
|
|
|
onchange_callback: function(){
|
|
|
|
if($('#pageeditcontent:visible').length > 0){
|
|
|
|
guiders.next();
|
|
|
|
}
|
2011-07-03 09:02:52 +00:00
|
|
|
}
|
2010-06-22 13:04:40 +00:00
|
|
|
};
|
|
|
|
|
2010-04-25 00:33:38 +00:00
|
|
|
/* ___ global ___ */
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2010-07-23 20:20:09 +00:00
|
|
|
I18nLocale = $('meta[name=locale]').attr('content');
|
|
|
|
|
2010-09-06 21:47:03 +00:00
|
|
|
TinyMceDefaultSettings['language'] = I18nLocale;
|
|
|
|
|
2010-07-23 20:20:09 +00:00
|
|
|
// sub menu links
|
2011-03-03 22:51:07 +00:00
|
|
|
$('#submenu ul li.hoverable').hover(function() {
|
|
|
|
$(this).find('a').addClass('hover');
|
2010-07-23 20:20:09 +00:00
|
|
|
$(this).find('.popup').show();
|
|
|
|
}, function() {
|
2011-03-03 22:51:07 +00:00
|
|
|
$(this).find('a').removeClass('hover');
|
2010-07-23 20:20:09 +00:00
|
|
|
$(this).find('.popup').hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
if ((css = $('#submenu > ul').attr('class')) != '')
|
|
|
|
$('#submenu > ul > li.' + css).addClass('on');
|
|
|
|
|
2011-01-12 15:54:09 +00:00
|
|
|
// nifty code editor
|
|
|
|
$('code.html textarea').each(function() { addCodeMirrorEditor('liquid', $(this)); });
|
|
|
|
|
2010-07-23 20:20:09 +00:00
|
|
|
// save form in AJAX
|
|
|
|
$('form.save-with-shortcut').saveWithShortcut();
|
|
|
|
|
|
|
|
// 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);
|
2011-07-08 08:20:29 +00:00
|
|
|
try{guiders.next();}catch(ex){}
|
2010-07-23 20:20:09 +00:00
|
|
|
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');
|
2011-07-01 00:15:45 +00:00
|
|
|
content.slideDown('fast', function() { parent.trigger('refresh'); });
|
2010-07-23 20:20:09 +00:00
|
|
|
} else
|
|
|
|
content.slideUp('fast', function() { parent.addClass('folded'); });
|
|
|
|
});
|
|
|
|
|
|
|
|
// nifty checkboxes
|
|
|
|
$('.formtastic li.toggle input[type=checkbox]').checkToggle();
|
|
|
|
|
2011-07-05 16:30:12 +00:00
|
|
|
// sites picker
|
|
|
|
(function() {
|
|
|
|
var link = $('#sites-picker-link');
|
|
|
|
var picker = $('#sites-picker');
|
2011-07-05 18:33:21 +00:00
|
|
|
|
|
|
|
if (picker.empty()) return;
|
|
|
|
|
2011-07-05 16:30:12 +00:00
|
|
|
var left = link.position().left + link.parent().position().left - (picker.width() - link.width());
|
|
|
|
picker.css('left', left);
|
|
|
|
})();
|
|
|
|
$('#sites-picker-link').click(function(e) { $('#sites-picker').toggle(); e.stopPropagation(); e.preventDefault(); });
|
|
|
|
|
|
|
|
// separator between form fields
|
2011-07-01 00:15:45 +00:00
|
|
|
$('.formtastic fieldset.inputs').bind('refresh', function(e) { $(this).find('ol li:not(.item)').removeClass('last').filter(':visible').last().addClass('last'); })
|
|
|
|
.trigger('refresh');
|
|
|
|
|
2011-07-04 17:40:14 +00:00
|
|
|
$('.formtastic fieldset.inputs ol li:not(.item)').last().addClass('last');
|
2010-07-23 20:20:09 +00:00
|
|
|
});
|