engine/app/assets/javascripts/locomotive/inline_editor.js

68 lines
2.0 KiB
JavaScript
Raw Normal View History

2010-09-03 23:47:28 +00:00
if (typeof GENTICS != 'undefined') {
GENTICS.Aloha.settings = {
errorhandling : false,
ribbon: false,
"plugins": {
// "com.gentics.aloha.plugins.GCN": {
// "enabled": false
// },
"com.gentics.aloha.plugins.Format": {
config : [ 'b', 'i', 'u','del','sub','sup', 'p', 'title', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'pre', 'removeFormat'],
editables : {
'.editable-short-text' : [ 'b', 'i', 'u' ]
}
},
"com.gentics.aloha.plugins.Link": {
// all elements with no specific configuration may insert links
config : [ 'a' ],
editables : {
'.editable-short-text' : [ ]
}
},
"com.gentics.aloha.plugins.List": {
config : [ 'ul' ],
editables : {
'.editable-short-text' : [ ]
}
}
2011-02-12 17:13:06 +00:00
},
i18n: {
available: ['en', 'fr', 'pt-BR']
}
2010-09-03 23:47:28 +00:00
};
2010-09-04 23:50:11 +00:00
GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha, 'editableDeactivated', InlineEditorToolbar.updateForm);
2010-09-03 23:47:28 +00:00
}
2010-09-03 23:47:28 +00:00
jQuery(document).ready(function($) {
InlineEditorToolbar.initialize();
if (InlineEditorToolbar.editingMode) {
2011-02-12 17:13:06 +00:00
GENTICS.Aloha.settings.i18n['current'] = InlineEditorToolbar.locale;
2010-09-04 23:50:11 +00:00
2010-09-03 23:47:28 +00:00
// add 'edit' at the end of each url of the page
$('a').each(function() {
var url = $(this).attr('href');
2010-09-04 23:50:11 +00:00
if (url != '#' && /^(www|http)/.exec(url) == null && /(\/edit)$/.exec(url) == null) {
2010-09-03 23:47:28 +00:00
if (url == '/') url = '/index';
$(this).attr('href', url + '/edit');
}
});
// handle editable long text
$('.editable-long-text').aloha();
2010-09-03 23:47:28 +00:00
// handle editable short text
$('.editable-short-text').each(function() {
var link = $(this).parents('a').eq(0);
if (link.size() == 1) { // disable click event and replace it by double click instead
2010-09-03 23:47:28 +00:00
link.click(function(e) { e.stopPropagation(); e.preventDefault(); });
link.dblclick(function(e) { window.location.href = link.attr('href'); });
}
$(this).aloha();
2010-09-03 23:47:28 +00:00
});
}
});