mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-17 07:10:48 +03:00
Компонент editor
This commit is contained in:
parent
692b0d8b06
commit
c5646d7514
|
@ -518,7 +518,6 @@ $config['head']['default']['js'] = array(
|
|||
"___path.application.web___/frontend/common/js/userfeed.js",
|
||||
"___path.application.web___/frontend/common/js/activity.js",
|
||||
"___path.application.web___/frontend/common/js/toolbar.js",
|
||||
"___path.application.web___/frontend/common/js/settings.js",
|
||||
"___path.application.web___/frontend/common/js/topic.js",
|
||||
"___path.application.web___/frontend/common/js/admin.js",
|
||||
"___path.application.web___/frontend/common/js/userfield.js",
|
||||
|
|
|
@ -13,119 +13,19 @@ var ls = ls || {};
|
|||
ls.editor = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
// Селекторы
|
||||
selectors: {
|
||||
insertImageButton: '.js-insert-image-button',
|
||||
uploadImageButton: '.js-upload-image-button',
|
||||
previewImageLoader: '.js-topic-preview-loader'
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
* @param {Object} options Опции
|
||||
*/
|
||||
this.init = function(options) {
|
||||
var self = this;
|
||||
this.init = function(selector) {
|
||||
var _this = this;
|
||||
|
||||
this.options = $.extend({}, defaults, options);
|
||||
$(selector).each(function () {
|
||||
var editor = $(this),
|
||||
type = editor.data('editor-type'),
|
||||
set = editor.data('editor-set') || 'default';
|
||||
|
||||
// Вставка ссылки
|
||||
$(this.options.selectors.insertImageButton).on('click', function (e) {
|
||||
var sUrl = $('#img_url').val(),
|
||||
sAlign = $('#form-image-url-align').val(),
|
||||
sTitle = $('#form-image-url-title').val();
|
||||
|
||||
self.insertImageUrlToEditor(sUrl, sAlign, sTitle);
|
||||
});
|
||||
|
||||
// Вставка ссылки
|
||||
$(this.options.selectors.uploadImageButton).on('click', function (e) {
|
||||
var sFormId = $(this).data('form-id');
|
||||
|
||||
self.ajaxUploadImg('#' + sFormId);
|
||||
});
|
||||
|
||||
// Справка по разметке редактора
|
||||
$('.js-editor-help').each(function () {
|
||||
var oEditorHelp = $(this),
|
||||
oTargetForm = $('#' + oEditorHelp.data('form-id'));
|
||||
|
||||
oEditorHelp.find('.js-tags-help-link').on('click', function (e) {
|
||||
if ($(this).data('insert')) {
|
||||
var sTag = $(this).data('insert');
|
||||
} else {
|
||||
var sTag = $(this).text();
|
||||
}
|
||||
|
||||
$.markItUp({
|
||||
target: oTargetForm,
|
||||
replaceWith: sTag
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставка ссылки загруженного изображения в редактор
|
||||
*
|
||||
* @param {String} sUrl Ссылка
|
||||
* @param {String} sAlign Выравнивание
|
||||
* @param {String} sTitle Описание
|
||||
*/
|
||||
this.insertImageUrlToEditor = function(sUrl, sAlign, sTitle) {
|
||||
sAlign = sAlign == 'center' ? 'class="image-center"' : 'align="' + sAlign + '"';
|
||||
|
||||
$.markItUp({
|
||||
replaceWith: '<img src="' + sUrl + '" title="' + sTitle + '" ' + sAlign + ' />'
|
||||
});
|
||||
|
||||
this.hideUploadImageModal();
|
||||
};
|
||||
|
||||
/**
|
||||
* Загрузка изображения
|
||||
*
|
||||
* @param {String} sFormId ID формы
|
||||
*/
|
||||
this.ajaxUploadImg = function(sFormId) {
|
||||
var self = this;
|
||||
|
||||
ls.hook.marker('ajaxUploadImgBefore');
|
||||
|
||||
ls.ajax.submit('upload/image/', sFormId, function (data){
|
||||
if (data.bStateError) {
|
||||
ls.msg.error(data.sMsgTitle,data.sMsg);
|
||||
} else {
|
||||
$.markItUp({
|
||||
replaceWith: data.sText
|
||||
});
|
||||
|
||||
self.hideUploadImageModal();
|
||||
|
||||
ls.hook.marker('ajaxUploadImgAfter');
|
||||
}
|
||||
}, {
|
||||
// TODO: Fix validation
|
||||
validate: false
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Закрытие окна загрузки изображения
|
||||
*/
|
||||
this.hideUploadImageModal = function() {
|
||||
var oModal = $('#modal-image-upload');
|
||||
|
||||
oModal.find('input[type="text"], input[type="file"]').val('');
|
||||
oModal.modal('hide');
|
||||
ls.editor[type].init(editor, set);
|
||||
})
|
||||
};
|
||||
|
||||
return this;
|
||||
|
|
126
application/frontend/common/js/editor.markup.js
Normal file
126
application/frontend/common/js/editor.markup.js
Normal file
|
@ -0,0 +1,126 @@
|
|||
/**
|
||||
* Markup редактор
|
||||
*
|
||||
* @module ls/editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
ls.editor = ls.editor || {};
|
||||
|
||||
ls.editor.markup = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
sets: {
|
||||
default: {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name:'H4', className:'editor-h4', openWith:'<h4>', closeWith:'</h4>' },
|
||||
{name:'H5', className:'editor-h5', openWith:'<h5>', closeWith:'</h5>' },
|
||||
{name:'H6', className:'editor-h6', openWith:'<h6>', closeWith:'</h6>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ul', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ol', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>' },
|
||||
{name: ls.lang.get('panel_list_li'), className:'editor-li', openWith:'<li>', closeWith:'</li>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_video'), className:'editor-video', replaceWith:'<video>[!['+ls.lang.get('panel_video_promt')+':!:http://]!]</video>' },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
|
||||
{name: ls.lang.get('panel_cut'), className:'editor-cut', replaceWith: function(markitup) { if (markitup.selection) return '<cut name="'+markitup.selection+'">'; else return '<cut>' }}
|
||||
]
|
||||
},
|
||||
light: {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*
|
||||
*/
|
||||
this.init = function(element, set) {
|
||||
var self = this;
|
||||
|
||||
this.options = $.extend({}, defaults);
|
||||
|
||||
element.markItUp(this.options.sets[set]);
|
||||
|
||||
// Справка по разметке редактора
|
||||
$('.js-editor-help-toggle').on('click', function (e) {
|
||||
$(this).parent().next().toggle();
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
$('.js-editor-help').each(function () {
|
||||
var oEditorHelp = $(this),
|
||||
oTargetForm = $('#' + oEditorHelp.data('form-id'));
|
||||
|
||||
oEditorHelp.find('.js-tags-help-link').on('click', function (e) {
|
||||
if ($(this).data('insert')) {
|
||||
var sTag = $(this).data('insert');
|
||||
} else {
|
||||
var sTag = $(this).text();
|
||||
}
|
||||
|
||||
$.markItUp({
|
||||
target: oTargetForm,
|
||||
replaceWith: sTag
|
||||
});
|
||||
|
||||
e.preventDefault();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Вставка ссылки загруженного изображения в редактор
|
||||
*
|
||||
* @param {String} sUrl Ссылка
|
||||
* @param {String} sAlign Выравнивание
|
||||
* @param {String} sTitle Описание
|
||||
*/
|
||||
this.insertImageUrlToEditor = function(sUrl, sAlign, sTitle) {
|
||||
sAlign = sAlign == 'center' ? 'class="image-center"' : 'align="' + sAlign + '"';
|
||||
|
||||
$.markItUp({
|
||||
replaceWith: '<img src="' + sUrl + '" title="' + sTitle + '" ' + sAlign + ' />'
|
||||
});
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.editor.markup || {},jQuery);
|
113
application/frontend/common/js/editor.visual.js
Normal file
113
application/frontend/common/js/editor.visual.js
Normal file
|
@ -0,0 +1,113 @@
|
|||
/**
|
||||
* Визуальный редактор
|
||||
*
|
||||
* @module ls/editor
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
ls.editor = ls.editor || {};
|
||||
|
||||
ls.editor.visual = (function($) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Дефолтные опции
|
||||
*/
|
||||
var defaults = {
|
||||
sets: {
|
||||
default: {
|
||||
mode : "specific_textareas",
|
||||
editor_selector : "js-editor",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "lshselect,bold,italic,underline,strikethrough,|,bullist,numlist,|,undo,redo,|,lslink,unlink,lsvideo,lsimage,pagebreak,code",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : LANGUAGE,
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
}
|
||||
},
|
||||
light: {
|
||||
mode : "textareas",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,lslink,lsquote",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : 'ru',
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
},
|
||||
setup : function(ed) {
|
||||
// Display an alert onclick
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
key = e.keyCode || e.which;
|
||||
if(e.ctrlKey && (key == 13)) {
|
||||
$('#comment-button-submit').click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Инициализация
|
||||
*/
|
||||
this.init = function(element, set) {
|
||||
this.options = $.extend({}, defaults);
|
||||
|
||||
// Т.к. тини не принимает jquery элементы в качестве селектора
|
||||
// пишем небольшой костыль который генерит рандомный класс и используем его как селектор
|
||||
var selector = 'tinymce' + Math.floor(Math.random() * 10e10);
|
||||
|
||||
element.addClass(selector);
|
||||
|
||||
this.options.sets[set].editor_selector = selector;
|
||||
tinyMCE.init(this.options.sets[set]);
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.editor.visual || {},jQuery);
|
|
@ -1,142 +0,0 @@
|
|||
/**
|
||||
* Различные настройки
|
||||
*
|
||||
* @module ls/settings
|
||||
*
|
||||
* @license GNU General Public License, version 2
|
||||
* @copyright 2013 OOO "ЛС-СОФТ" {@link http://livestreetcms.com}
|
||||
* @author Denis Shakhov <denis.shakhov@gmail.com>
|
||||
*/
|
||||
|
||||
var ls = ls || {};
|
||||
|
||||
ls.settings = (function ($) {
|
||||
|
||||
this.get = function (sSettingsName) {
|
||||
return this[sSettingsName];
|
||||
};
|
||||
|
||||
this.markitup = {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name:'H4', className:'editor-h4', openWith:'<h4>', closeWith:'</h4>' },
|
||||
{name:'H5', className:'editor-h5', openWith:'<h5>', closeWith:'</h5>' },
|
||||
{name:'H6', className:'editor-h6', openWith:'<h6>', closeWith:'</h6>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ul', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>' },
|
||||
{name: ls.lang.get('panel_list'), className:'editor-ol', openWith:' <li>', closeWith:'</li>', multiline: true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>' },
|
||||
{name: ls.lang.get('panel_list_li'), className:'editor-li', openWith:'<li>', closeWith:'</li>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_video'), className:'editor-video', replaceWith:'<video>[!['+ls.lang.get('panel_video_promt')+':!:http://]!]</video>' },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
|
||||
{name: ls.lang.get('panel_cut'), className:'editor-cut', replaceWith: function(markitup) { if (markitup.selection) return '<cut name="'+markitup.selection+'">'; else return '<cut>' }}
|
||||
]
|
||||
};
|
||||
|
||||
this.markitupComment = {
|
||||
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||
onTab: {keepDefault:false, replaceWith:' '},
|
||||
markupSet: [
|
||||
{name: ls.lang.get('panel_b'), className:'editor-bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||
{name: ls.lang.get('panel_i'), className:'editor-italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||
{name: ls.lang.get('panel_s'), className:'editor-stroke', key:'S', openWith:'<s>', closeWith:'</s>' },
|
||||
{name: ls.lang.get('panel_u'), className:'editor-underline', key:'U', openWith:'<u>', closeWith:'</u>' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_quote'), className:'editor-quote', key:'Q', replaceWith: function(m) { if (m.selectionOuter) return '<blockquote>'+m.selectionOuter+'</blockquote>'; else if (m.selection) return '<blockquote>'+m.selection+'</blockquote>'; else return '<blockquote></blockquote>' } },
|
||||
{name: ls.lang.get('panel_code'), className:'editor-code', openWith:'<(!(code|!|codeline)!)>', closeWith:'</(!(code|!|codeline)!)>' },
|
||||
{name: ls.lang.get('panel_image'), className:'editor-picture', key:'P', beforeInsert: function(h) { jQuery('#modal-image-upload').modal('show'); } },
|
||||
{name: ls.lang.get('panel_url'), className:'editor-link', key:'L', openWith:'<a href="[!['+ls.lang.get('panel_url_promt')+':!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||
{name: ls.lang.get('panel_user'), className:'editor-user', replaceWith:'<ls user="[!['+ls.lang.get('panel_user_promt')+']!]" />' },
|
||||
{separator:'---------------' },
|
||||
{name: ls.lang.get('panel_clear_tags'), className:'editor-clean', replaceWith: function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }
|
||||
]
|
||||
};
|
||||
|
||||
this.tinymce = {
|
||||
mode : "specific_textareas",
|
||||
editor_selector : "mce-editor",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "lshselect,bold,italic,underline,strikethrough,|,bullist,numlist,|,undo,redo,|,lslink,unlink,lsvideo,lsimage,pagebreak,code",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : 'ru',
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
}
|
||||
};
|
||||
|
||||
this.tinymceComment = {
|
||||
mode : "textareas",
|
||||
theme : "advanced",
|
||||
skin : "livestreet",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,lslink,lsquote",
|
||||
theme_advanced_buttons2 : "",
|
||||
theme_advanced_buttons3 : "",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
theme_advanced_resize_horizontal : 0,
|
||||
theme_advanced_resizing_use_cookie : 0,
|
||||
theme_advanced_path : false,
|
||||
object_resizing : true,
|
||||
force_br_newlines : true,
|
||||
forced_root_block : '', // Needed for 3.x
|
||||
force_p_newlines : false,
|
||||
plugins : "lseditor,safari,inlinepopups,media,pagebreak,autoresize",
|
||||
convert_urls : false,
|
||||
extended_valid_elements : "embed[src|type|allowscriptaccess|allowfullscreen|width|height]",
|
||||
pagebreak_separator : "<cut>",
|
||||
media_strict : false,
|
||||
language : 'ru',
|
||||
inline_styles: false,
|
||||
formats : {
|
||||
underline : {inline : 'u', exact : true},
|
||||
strikethrough : {inline : 's', exact : true}
|
||||
},
|
||||
setup : function(ed) {
|
||||
// Display an alert onclick
|
||||
ed.onKeyPress.add(function(ed, e) {
|
||||
key = e.keyCode || e.which;
|
||||
if(e.ctrlKey && (key == 13)) {
|
||||
$('#comment-button-submit').click();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return this;
|
||||
}).call(ls.settings || {},jQuery);
|
|
@ -22,10 +22,6 @@
|
|||
{/block}
|
||||
|
||||
{block 'layout_content'}
|
||||
{* Подключение редактора *}
|
||||
{include 'forms/editor.init.tpl' sEditorType='comment' sMediaTargetType='blog'}
|
||||
|
||||
|
||||
<form method="post" enctype="multipart/form-data" class="js-form-validate">
|
||||
{hook run='form_add_blog_begin'}
|
||||
|
||||
|
@ -83,16 +79,12 @@
|
|||
|
||||
|
||||
{* Описание блога *}
|
||||
{include 'components/field/field.textarea.tpl'
|
||||
sName = 'blog_description'
|
||||
aRules = [ 'required' => true, 'rangelength' => '[10,3000]' ]
|
||||
sLabel = $aLang.blog.add.fields.description.label
|
||||
sInputClasses = 'js-editor'}
|
||||
|
||||
{* Если визуальный редактор отключен выводим справку по разметке для обычного редактора *}
|
||||
{if ! $oConfig->GetValue('view.wysiwyg')}
|
||||
{include 'forms/editor.help.tpl' sTagsTargetId='blog_description'}
|
||||
{/if}
|
||||
{include 'components/editor/editor.tpl'
|
||||
sSet = 'light'
|
||||
sMediaTargetType = 'blog'
|
||||
sName = 'blog_description'
|
||||
aRules = [ 'required' => true, 'rangelength' => '[10,3000]' ]
|
||||
sLabel = $aLang.blog.add.fields.description.label}
|
||||
|
||||
|
||||
{* Ограничение по рейтингу *}
|
||||
|
|
|
@ -5,8 +5,6 @@
|
|||
{extends 'layouts/layout.user.messages.tpl'}
|
||||
|
||||
{block 'layout_content'}
|
||||
{include 'forms/editor.init.tpl' sEditorType='comment' sMediaTargetType='talk'}
|
||||
|
||||
{hook run='talk_add_begin'}
|
||||
|
||||
<form action="" method="POST" enctype="multipart/form-data" class="js-form-validate">
|
||||
|
@ -29,11 +27,13 @@
|
|||
sLabel = $aLang.talk_create_title}
|
||||
|
||||
{* Текст сообщения *}
|
||||
{include 'components/field/field.textarea.tpl'
|
||||
sName = 'talk_text'
|
||||
aRules = [ 'required' => true, 'rangelength' => '[2,3000]' ]
|
||||
sLabel = $aLang.topic_create_text
|
||||
sInputClasses = 'js-editor'}
|
||||
{include 'components/editor/editor.tpl'
|
||||
sSet = 'light'
|
||||
sMediaTargetType = 'talk'
|
||||
sName = 'talk_text'
|
||||
aRules = [ 'required' => true, 'rangelength' => '[2,3000]' ]
|
||||
sLabel = $aLang.topic_create_text
|
||||
sInputClasses = 'js-editor'}
|
||||
|
||||
{* Preview *}
|
||||
<div class="text mb-20" id="text_preview" style="display: none;"></div>
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Справка по разметке редактора
|
||||
*
|
||||
* @template editor.markup.help.tpl
|
||||
*/
|
||||
.editor-help header { margin-bottom: 20px; }
|
||||
|
||||
.editor-help-body {
|
||||
display: none;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
background: #f7f7f7;
|
||||
color: #333;
|
||||
}
|
||||
.editor-help-body h3 { font-size: 18px; font-weight: bold; margin-bottom: 10px; }
|
||||
|
||||
.editor-help-col { float: left; width: 47%; margin-left: 6%; }
|
||||
.editor-help-col:first-child { margin-left: 0; }
|
||||
|
||||
.editor-help-item { margin-bottom: 20px; }
|
||||
.editor-help-item:last-child { margin-bottom: 0; }
|
||||
.editor-help-item h4 { font-family: monospace; font-weight: bold; margin-bottom: 3px; }
|
|
@ -17,30 +17,6 @@
|
|||
.avatar-edit label { margin-top: 10px; }
|
||||
|
||||
|
||||
/**
|
||||
* Справка по разметке редактора
|
||||
*
|
||||
* @template editor_help.tpl
|
||||
*/
|
||||
.editor-help header { margin-bottom: 20px; }
|
||||
|
||||
.editor-help-body {
|
||||
display: none;
|
||||
padding: 20px;
|
||||
margin-bottom: 20px;
|
||||
background: #f7f7f7;
|
||||
color: #333;
|
||||
}
|
||||
.editor-help-body h3 { font-size: 18px; font-weight: bold; margin-bottom: 10px; }
|
||||
|
||||
.editor-help-col { float: left; width: 47%; margin-left: 6%; }
|
||||
.editor-help-col:first-child { margin-left: 0; }
|
||||
|
||||
.editor-help-item { margin-bottom: 20px; }
|
||||
.editor-help-item:last-child { margin-bottom: 0; }
|
||||
.editor-help-item h4 { font-family: monospace; font-weight: bold; margin-bottom: 3px; }
|
||||
|
||||
|
||||
/**
|
||||
* Форма авторизации
|
||||
*
|
||||
|
|
|
@ -1,83 +0,0 @@
|
|||
/* TinyMCE Content
|
||||
---------------------------------------------------- */
|
||||
|
||||
body, td, pre { color: #000; font-family: Arial, Helvetica, sans-serif; margin: 8px; font-size: 15px; line-height: 1.6em; overflow: hidden; zoom: 1; }
|
||||
body {background:#FFF;}
|
||||
body.mceForceColors {background:#FFF; color:#000;}
|
||||
body.mceBrowserDefaults {background:transparent; color:inherit; font-size:inherit; font-family:inherit;}
|
||||
|
||||
.mceItemTable, .mceItemTable td, .mceItemTable th, .mceItemTable caption, .mceItemVisualAid {border: 1px dashed #BBB;}
|
||||
a.mceItemAnchor {display:inline-block; -webkit-user-select:all; -webkit-user-modify:read-only; -moz-user-select:all; -moz-user-modify:read-only; width:11px !important; height:11px !important; background:url(img/items.gif) no-repeat center center}
|
||||
span.mceItemNbsp {background: #DDD}
|
||||
td.mceSelected, th.mceSelected {background-color:#3399ff !important}
|
||||
img {border:0;}
|
||||
table, img, hr, .mceItemAnchor {cursor:default}
|
||||
table td, table th {cursor:text}
|
||||
ins {border-bottom:1px solid green; text-decoration: none; color:green}
|
||||
del {color:red; text-decoration:line-through}
|
||||
cite {border-bottom:1px dashed blue}
|
||||
acronym {border-bottom:1px dotted #CCC; cursor:help}
|
||||
abbr {border-bottom:1px dashed #CCC; cursor:help}
|
||||
|
||||
h4 { font-size: 24px; margin-bottom: 7px; font-weight: bold; }
|
||||
h5 { font-size: 20px; margin-bottom: 7px; font-weight: bold; }
|
||||
h6 { font-size: 18px; margin-bottom: 7px; font-weight: bold; }
|
||||
|
||||
p { margin-bottom: 1em; }
|
||||
abbr[title] { border-bottom: 1px dotted; }
|
||||
b, strong { font-weight: bold; }
|
||||
blockquote { margin: 0; background: #fafafa; color: #555; padding: 15px 20px; clear: both; border-left: 5px solid #eee; }
|
||||
dfn { font-style: italic; }
|
||||
hr { display: block; height: 1px; border: 0; border-top: 1px solid #ccc; margin: 1em 0; padding: 0; }
|
||||
ins { background: #ff9; color: #000; text-decoration: none; }
|
||||
mark { background: #ff0; color: #000; font-style: italic; font-weight: bold; }
|
||||
|
||||
pre { margin: 0; padding: 10px 15px; border: none; background: #fafafa; font-size: 12px; line-height: 18px; overflow: auto; width: 100%; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; clear: both; }
|
||||
q { quotes: none; clear: both; }
|
||||
q:before, q:after { content: ""; content: none; }
|
||||
small { font-size: 85%; }
|
||||
|
||||
sub, sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; }
|
||||
sup { top: -0.5em; }
|
||||
sub { bottom: -0.25em; }
|
||||
|
||||
ul, ol { margin: 0; padding: 0 0 0 40px; }
|
||||
ul { list-style-type: disc; }
|
||||
ol { list-style-type: decimal; }
|
||||
dd { margin: 0 0 0 40px; }
|
||||
|
||||
img[align="right"] { margin: 4px 0 5px 15px; }
|
||||
img[align="left"] { margin: 4px 15px 10px 0; }
|
||||
img.image-center { display: block; margin: 0 auto; }
|
||||
|
||||
object,
|
||||
img { max-width: 100%; }
|
||||
|
||||
|
||||
/* IE */
|
||||
* html body {
|
||||
scrollbar-3dlight-color:#F0F0EE;
|
||||
scrollbar-arrow-color:#676662;
|
||||
scrollbar-base-color:#F0F0EE;
|
||||
scrollbar-darkshadow-color:#DDD;
|
||||
scrollbar-face-color:#E0E0DD;
|
||||
scrollbar-highlight-color:#F0F0EE;
|
||||
scrollbar-shadow-color:#F0F0EE;
|
||||
scrollbar-track-color:#F5F5F5;
|
||||
}
|
||||
|
||||
img:-moz-broken {-moz-force-broken-image-icon:1; width:24px; height:24px}
|
||||
font[face=mceinline] {font-family:inherit !important}
|
||||
*[contentEditable]:focus {outline:0}
|
||||
|
||||
.mceItemMedia {border:1px dotted #cc0000; background-position:center; background-repeat:no-repeat; background-color:#ffffcc}
|
||||
.mceItemShockWave {background-image:url(../../img/shockwave.gif)}
|
||||
.mceItemFlash {background-image:url(../../img/flash.gif)}
|
||||
.mceItemQuickTime {background-image:url(../../img/quicktime.gif)}
|
||||
.mceItemWindowsMedia {background-image:url(../../img/windowsmedia.gif)}
|
||||
.mceItemRealMedia {background-image:url(../../img/realmedia.gif)}
|
||||
.mceItemVideo {background-image:url(../../img/video.gif)}
|
||||
.mceItemAudio {background-image:url(../../img/video.gif)}
|
||||
.mceItemEmbeddedAudio {background-image:url(../../img/video.gif)}
|
||||
.mceItemIframe {background-image:url(../../img/iframe.gif)}
|
||||
.mcePageBreak {display:block;border:0;width:100%;height:12px;border-top:1px dotted #ccc;margin-top:15px;background:#fff url(../../img/pagebreak.gif) no-repeat center top;}
|
|
@ -174,7 +174,7 @@ jQuery(document).ready(function($){
|
|||
/**
|
||||
* Editor
|
||||
*/
|
||||
ls.editor.init();
|
||||
ls.editor.init('.js-editor');
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,14 +8,14 @@
|
|||
*}
|
||||
|
||||
{* Подключение редактора *}
|
||||
{include 'forms/editor.init.tpl' sEditorType='comment' sMediaTargetType='comment' }
|
||||
|
||||
|
||||
{* Форма *}
|
||||
<form method="post" class="comment-form js-comment-form" enctype="multipart/form-data" data-target-id="{$iTargetId}" data-target-type="{$sTargetType}">
|
||||
{hook run='form_add_comment_begin'}
|
||||
|
||||
{* Текст комментария *}
|
||||
{include 'components/field/field.textarea.tpl' sName='comment_text' sId='form_comment_text' sInputClasses='js-editor'}
|
||||
{include 'components/editor/editor.tpl' sSet='light' sName='comment_text' sId='form_comment_text' bShowHelp=false sMediaTargetType='comment'}
|
||||
|
||||
{hook run='form_add_comment_end'}
|
||||
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
{**
|
||||
* Справка по разметке редактора
|
||||
*}
|
||||
|
||||
{function editor_help_item}
|
||||
{strip}
|
||||
{foreach $aItems as $aItem}
|
||||
<dl class="editor-help-item">
|
||||
{foreach $aItem['tags'] as $aTag}
|
||||
<dt>
|
||||
<a href="#" class="link-dotted js-tags-help-link" {if $aTag['insert']}data-insert="{$aTag['insert']}"{/if}>
|
||||
{$aTag['text']}
|
||||
</a>
|
||||
</dt>
|
||||
{/foreach}
|
||||
|
||||
<dd>{$aItem['def']}</dd>
|
||||
</dl>
|
||||
{/foreach}
|
||||
{/strip}
|
||||
{/function}
|
||||
|
||||
|
||||
<div class="editor-help js-editor-help" data-form-id="{$smarty.local.sTargetId}">
|
||||
<header class="editor-help-header clearfix">
|
||||
<a href="#" class="link-dotted help-link js-editor-help-toggle">{$aLang.tags_help_link_show}</a>
|
||||
</header>
|
||||
|
||||
<div class="editor-help-body">
|
||||
<h3 class="h3">{$aLang.tags_help_special}</h3>
|
||||
|
||||
<div class="mb-30">
|
||||
{editor_help_item aItems=[
|
||||
[ 'tags' => [ [ 'text' => '<cut>' ] ], 'def' => $aLang.tags_help_special_cut ],
|
||||
[ 'tags' => [ [ 'text' => "<cut name=\"{$aLang.tags_help_special_cut_name_example_name}\">" ] ], 'def' => $aLang.tags_help_special_cut_name ],
|
||||
[ 'tags' => [ [ 'text' => "<video>http://...</video>", 'insert' => '<video></video>' ] ], 'def' => $aLang.tags_help_special_video ],
|
||||
[ 'tags' => [ [ 'text' => "<ls user=\"{$aLang.tags_help_special_ls_user_example_user}\" />", 'insert' => '<ls user="" />' ] ], 'def' => $aLang.tags_help_special_ls_user ]
|
||||
]}
|
||||
</div>
|
||||
|
||||
<h3 class="h3">{$aLang.tags_help_standart}</h3>
|
||||
|
||||
<div class="clearfix">
|
||||
<ul class="editor-help-col">
|
||||
{editor_help_item aItems=[
|
||||
[ 'tags' => [
|
||||
[ 'text' => '<h4></h4>' ],
|
||||
[ 'text' => '<h5></h5>' ],
|
||||
[ 'text' => '<h6></h6>' ]
|
||||
], 'def' => $aLang.tags_help_standart_h ],
|
||||
[ 'tags' => [ [ 'text' => "<img src=\"\" />" ] ], 'def' => $aLang.tags_help_standart_img ],
|
||||
[ 'tags' => [
|
||||
[ 'text' => "<a href=\"http://...\">{$aLang.tags_help_standart_a_example_href}</a>", 'insert' => '<a href=""></a>"' ]
|
||||
], 'def' => $aLang.tags_help_standart_a ],
|
||||
[ 'tags' => [ [ 'text' => "<b></b>" ] ], 'def' => $aLang.tags_help_standart_b ],
|
||||
[ 'tags' => [ [ 'text' => "<i></i>" ] ], 'def' => $aLang.tags_help_standart_i ],
|
||||
[ 'tags' => [ [ 'text' => "<s></s>" ] ], 'def' => $aLang.tags_help_standart_s ],
|
||||
[ 'tags' => [ [ 'text' => "<u></u>" ] ], 'def' => $aLang.tags_help_standart_u ]
|
||||
]}
|
||||
</ul>
|
||||
|
||||
<ul class="editor-help-col">
|
||||
{editor_help_item aItems=[
|
||||
[ 'tags' => [ [ 'text' => "<hr />" ] ], 'def' => $aLang.tags_help_standart_hr ],
|
||||
[ 'tags' => [ [ 'text' => "<blockquote></blockquote>" ] ], 'def' => $aLang.tags_help_standart_blockquote ],
|
||||
[ 'tags' => [
|
||||
[ 'text' => '<table></table>' ],
|
||||
[ 'text' => '<th></th>' ],
|
||||
[ 'text' => '<td></td>' ],
|
||||
[ 'text' => '<tr></tr>' ]
|
||||
], 'def' => $aLang.tags_help_standart_table ],
|
||||
[ 'tags' => [
|
||||
[ 'text' => '<ul></ul>' ],
|
||||
[ 'text' => '<li></li>' ]
|
||||
], 'def' => $aLang.tags_help_standart_ul ],
|
||||
[ 'tags' => [
|
||||
[ 'text' => '<ol></ol>' ],
|
||||
[ 'text' => '<li></li>' ]
|
||||
], 'def' => $aLang.tags_help_standart_ol ]
|
||||
]}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,57 @@
|
|||
{**
|
||||
* Редактор
|
||||
*}
|
||||
|
||||
{* Название компонента *}
|
||||
{$_sComponentName = 'editor'}
|
||||
|
||||
{* Получаем тип редактора *}
|
||||
{$_sType = ( Config::Get('view.wysiwyg') ) ? 'visual' : 'markup'}
|
||||
{$_sSet = $smarty.local.sSet|default:'default'}
|
||||
|
||||
{* Уникальный ID *}
|
||||
{$_uid = $smarty.local.sId|default:($_sComponentName|cat:rand(0, 10e10))}
|
||||
|
||||
{* Класс на который вешается обработчик редактора *}
|
||||
{$_sBindClass = $smarty.local.sBindClass|default:"js-{$_sComponentName}"}
|
||||
|
||||
{**
|
||||
* Textarea
|
||||
*}
|
||||
{function editor_textarea}
|
||||
{include 'components/field/field.textarea.tpl'
|
||||
sName = $smarty.local.sName
|
||||
sLabel = $smarty.local.sLabel
|
||||
sMods = $smarty.local.sMods
|
||||
sClasses = $smarty.local.sClasses
|
||||
sId = $_uid
|
||||
sAttributes = $smarty.local.sAttributes
|
||||
aRules = $smarty.local.aRules
|
||||
sInputClasses = "$_sBindClass {$smarty.local.sInputClasses}"
|
||||
sInputAttributes = "{$smarty.local.sAttributes} data-editor-type=\"{$_sType}\" data-editor-set=\"{$_sSet}\""
|
||||
sNote = $smarty.local.sNote
|
||||
iRows = $smarty.local.iRows|default:10}
|
||||
{/function}
|
||||
|
||||
{* Визуальный редактор *}
|
||||
{if Config::Get('view.wysiwyg')}
|
||||
{hookb run='editor_visual'}
|
||||
{editor_textarea}
|
||||
{/hookb}
|
||||
|
||||
{* Markup редактор *}
|
||||
{else}
|
||||
{hookb run='editor_markup'}
|
||||
{editor_textarea}
|
||||
|
||||
{if $smarty.local.bShowHelp|default:true}
|
||||
{include './editor.markup.help.tpl' sTargetId=$_uid}
|
||||
{/if}
|
||||
{/hookb}
|
||||
{/if}
|
||||
|
||||
{* TODO: Исправить повторный инклуд при подключении нескольких редакторов *}
|
||||
{include 'modals/modal.upload_image.tpl' sMediaTargetType=$smarty.local.sMediaTargetType sMediaTargetId=$smarty.local.sMediaTargetId assign='sMediaModal'}
|
||||
|
||||
{* Добавляем модальное окно в конец лэйаута чтобы избежать вложенных форм *}
|
||||
{$sLayoutAfter = "$sLayoutAfter $sMediaModal" scope='root'}
|
|
@ -0,0 +1,35 @@
|
|||
{**
|
||||
* Тестирование компонента editor
|
||||
*}
|
||||
|
||||
{extends 'layouts/layout.base.tpl'}
|
||||
|
||||
{block 'layout_options'}
|
||||
{$bNoSidebar = true}
|
||||
{/block}
|
||||
|
||||
{block 'layout_page_title'}
|
||||
Component <span>editor</span>
|
||||
{/block}
|
||||
|
||||
{block 'layout_content'}
|
||||
{function test_heading}
|
||||
<br><h3>{$sText}</h3>
|
||||
{/function}
|
||||
|
||||
<script>
|
||||
jQuery(document).ready(function($) {
|
||||
ls.editor.init('.js-editor-test');
|
||||
});
|
||||
</script>
|
||||
|
||||
{* Полная версия *}
|
||||
{test_heading sText='Default'}
|
||||
|
||||
{include 'components/editor/editor.tpl' sBindClass='js-editor-test' sName='text'}
|
||||
|
||||
{* Облегченная версия *}
|
||||
{test_heading sText='Light'}
|
||||
|
||||
{include 'components/editor/editor.tpl' sBindClass='js-editor-test' sSet='light' sName='text'}
|
||||
{/block}
|
|
@ -11,7 +11,7 @@
|
|||
{$_sComponentName = 'field'}
|
||||
|
||||
{* Уникальный ID *}
|
||||
{$_uid = ( $smarty.local.sId ) ? $smarty.local.sId : $_sComponentName|cat:rand(0, 10e10)}
|
||||
{$_uid = $smarty.local.sId|default:($_sComponentName|cat:rand(0, 10e10))}
|
||||
|
||||
{* Переменные *}
|
||||
{$_sMods = $smarty.local.sMods}
|
||||
|
|
|
@ -110,5 +110,7 @@
|
|||
|
||||
<body class="{$sBodyClasses} layout-{cfg name='view.grid.type'} {block name='layout_body_classes'}{/block}">
|
||||
{block name='layout_body'}{/block}
|
||||
|
||||
{$sLayoutAfter}
|
||||
</body>
|
||||
</html>
|
|
@ -1,111 +0,0 @@
|
|||
{**
|
||||
* Справка по разметке редактора
|
||||
*}
|
||||
|
||||
<div class="editor-help js-editor-help" data-form-id="{$sTagsTargetId}">
|
||||
<header class="editor-help-header clearfix">
|
||||
<a href="#" class="link-dotted help-link" onclick="jQuery('#js-editor-help').toggle(); return false;">{$aLang.tags_help_link_show}</a>
|
||||
</header>
|
||||
|
||||
<div class="editor-help-body" id="js-editor-help">
|
||||
<h3>{$aLang.tags_help_special}</h3>
|
||||
|
||||
<ul class="mb-30">
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><cut></a></h4>
|
||||
{$aLang.tags_help_special_cut}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><cut name="{$aLang.tags_help_special_cut_name_example_name}"></a></h4>
|
||||
{$aLang.tags_help_special_cut_name}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link" data-insert="<video></video>"><video>http://...</video></a></h4>
|
||||
{$aLang.tags_help_special_video}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link" data-insert="<ls user="" />"><ls user="{$aLang.tags_help_special_ls_user_example_user}" /></a></h4>
|
||||
{$aLang.tags_help_special_ls_user}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h3>{$aLang.tags_help_standart}</h3>
|
||||
|
||||
<div class="clearfix">
|
||||
<ul class="editor-help-col">
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><h4></h4></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><h5></h5></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><h6></h6></a></h4>
|
||||
{$aLang.tags_help_standart_h}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><img src="" /></a></h4>
|
||||
{$aLang.tags_help_standart_img}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link" data-insert="<a href=""></a>"><a href="http://...">{$aLang.tags_help_standart_a_example_href}</a></a></h4>
|
||||
{$aLang.tags_help_standart_a}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><b></b></a></h4>
|
||||
{$aLang.tags_help_standart_b}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><i></i></a></h4>
|
||||
{$aLang.tags_help_standart_i}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><s></s></a></h4>
|
||||
{$aLang.tags_help_standart_s}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><u></u></a></h4>
|
||||
{$aLang.tags_help_standart_u}
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="editor-help-col">
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><hr /></a></h4>
|
||||
{$aLang.tags_help_standart_hr}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><blockquote></blockquote></a></h4>
|
||||
{$aLang.tags_help_standart_blockquote}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><table></table></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><th></th></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><td></td></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><tr></tr></a></h4>
|
||||
{$aLang.tags_help_standart_table}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><ul></ul></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><li></li></a></h4>
|
||||
{$aLang.tags_help_standart_ul}
|
||||
</li>
|
||||
|
||||
<li class="editor-help-item">
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><ol></ol></a></h4>
|
||||
<h4><a href="#" class="link-dotted js-tags-help-link"><li></li></a></h4>
|
||||
{$aLang.tags_help_standart_ol}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,75 +0,0 @@
|
|||
{**
|
||||
* Инициализация редактора
|
||||
*
|
||||
* sEditorType - тип
|
||||
* sEditorSelector - селектор textarea с редактором
|
||||
*
|
||||
* Настройки редакторов храняться в файле templates/framework/js/core/settings.js
|
||||
*
|
||||
* TODO: Исправить повторное подключение скрипта
|
||||
* TODO: Локализация TinyMCE
|
||||
*}
|
||||
|
||||
{* Дефолтный тип редактора *}
|
||||
{if ! $sEditorType}
|
||||
{$sEditorType = 'default'}
|
||||
{/if}
|
||||
|
||||
{* Дефолтный селектор редактора *}
|
||||
{if ! $sEditorSelector}
|
||||
{$sEditorSelector = 'js-editor'}
|
||||
{/if}
|
||||
|
||||
{* Инициализация *}
|
||||
{if $oConfig->GetValue('view.wysiwyg')}
|
||||
{* WYSIWYG редактор *}
|
||||
|
||||
{hookb run='editor_init_wysiwyg' sEditorType=$sEditorType sEditorSelector=$sEditorSelector}
|
||||
{if $sEditorType == 'comment'}
|
||||
{$sSettings = 'ls.settings.get("tinymceComment")'}
|
||||
{else}
|
||||
{hook run='editor_init_wysiwyg_settings' sEditorType=$sEditorType assign='sSettings'}
|
||||
|
||||
{if ! $sSettings}
|
||||
{$sSettings = 'ls.settings.get("tinymce")'}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<script src="{cfg name='path.framework.frontend.web'}/js/vendor/tinymce/tiny_mce.js"></script>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
tinyMCE.init($.extend({ }, {$sSettings}, {
|
||||
editor_selector : '{$sEditorSelector}',
|
||||
language : {$oConfig->GetValue('lang.current')}
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
{/hookb}
|
||||
{else}
|
||||
{* Markup редактор *}
|
||||
|
||||
{hookb run='editor_init_markup' sEditorType=$sEditorType sEditorSelector=$sEditorSelector}
|
||||
{include file='modals/modal.upload_image.tpl'}
|
||||
|
||||
{if $sEditorType == 'comment'}
|
||||
{$sSettings = 'ls.settings.get("markitupComment")'}
|
||||
{else}
|
||||
{hook run='editor_init_markup_settings' sEditorType=$sEditorType assign='sSettings'}
|
||||
|
||||
{if ! $sSettings}
|
||||
{$sSettings = 'ls.settings.get("markitup")'}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
<script src="{cfg name='path.framework.frontend.web'}/js/vendor/markitup/jquery.markitup.js"></script>
|
||||
|
||||
<script>
|
||||
jQuery(function($) {
|
||||
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li,panel_image_promt,panel_user,panel_user_promt"});
|
||||
|
||||
$('.{$sEditorSelector}').markItUp({$sSettings});
|
||||
});
|
||||
</script>
|
||||
{/hookb}
|
||||
{/if}
|
|
@ -23,14 +23,6 @@
|
|||
{block name='layout_content'}
|
||||
{block name='add_topic_options'}{/block}
|
||||
|
||||
{* Подключение редактора *}
|
||||
{$sMediaTargetId=''}
|
||||
{if $oTopicEdit}
|
||||
{$sMediaTargetId=$oTopicEdit->getId()}
|
||||
{/if}
|
||||
{include file='forms/editor.init.tpl' sMediaTargetType='topic' sMediaTargetId=$sMediaTargetId}
|
||||
|
||||
|
||||
{hook run="add_topic_begin"}
|
||||
{block name='add_topic_header_after'}{/block}
|
||||
|
||||
|
@ -78,17 +70,13 @@
|
|||
|
||||
{* Текст топика *}
|
||||
{if $oTopicType->getParam('allow_text')}
|
||||
{include file='components/field/field.textarea.tpl'
|
||||
sName = 'topic[topic_text_source]'
|
||||
sValue = {(($oTopicEdit) ? $oTopicEdit->getTextSource() : '')|escape:'html' }
|
||||
aRules = [ 'required' => true, 'rangelength' => "[2,{$oConfig->Get('module.topic.max_length')}]" ]
|
||||
sLabel = $aLang.topic_create_text
|
||||
sInputClasses = 'js-editor'}
|
||||
|
||||
{* Если визуальный редактор отключен выводим справку по разметке для обычного редактора *}
|
||||
{if ! $oConfig->GetValue('view.wysiwyg')}
|
||||
{include file='forms/editor.help.tpl' sTagsTargetId='topic_text'}
|
||||
{/if}
|
||||
{include 'components/editor/editor.tpl'
|
||||
sName = 'topic[topic_text_source]'
|
||||
sValue = (($oTopicEdit) ? $oTopicEdit->getTextSource() : '')|escape
|
||||
sLabel = $aLang.topic_create_text
|
||||
aRules = [ 'required' => true, 'rangelength' => "[2,{Config::Get('module.topic.max_length')}]" ]
|
||||
sMediaTargetType = 'topic'
|
||||
sMediaTargetId = ($oTopicEdit) ? $oTopicEdit->getId() : ''}
|
||||
{/if}
|
||||
|
||||
|
||||
|
@ -119,8 +107,7 @@
|
|||
{if $oTopicType->getParam('allow_poll')}
|
||||
{include file='polls/poll.form.inject.tpl'
|
||||
sTargetType = 'topic'
|
||||
sTargetId = {($oTopicEdit) ? $oTopicEdit->getId() : '' }
|
||||
}
|
||||
sTargetId = ($oTopicEdit) ? $oTopicEdit->getId() : ''}
|
||||
{/if}
|
||||
|
||||
{* Запретить комментарии *}
|
||||
|
@ -167,12 +154,11 @@
|
|||
sText = $sSubmitInputText}
|
||||
{include file='components/button/button.tpl' sType='button' sClasses='js-topic-preview-text-button' sText=$aLang.topic_create_submit_preview}
|
||||
{include file='components/button/button.tpl' sId={($oTopicEdit) ? 'submit-edit-topic-save' : 'submit-add-topic-save' } sText=$aLang.topic_create_submit_save}
|
||||
</form>
|
||||
</form>
|
||||
|
||||
|
||||
{* Блок с превью текста *}
|
||||
<div class="topic-preview" style="display: none;" id="topic-text-preview"></div>
|
||||
|
||||
{* Блок с превью текста *}
|
||||
<div class="topic-preview" style="display: none;" id="topic-text-preview"></div>
|
||||
|
||||
{block name='add_topic_end'}{/block}
|
||||
{hook run="add_topic_end"}
|
||||
|
|
|
@ -25,8 +25,6 @@ $aCss = array(
|
|||
// Base styles
|
||||
"___path.skin.assets.web___/css/base.css",
|
||||
"___path.framework.frontend.web___/js/vendor/jquery-ui/css/smoothness/jquery-ui-1.10.2.custom.css",
|
||||
"___path.framework.frontend.web___/js/vendor/markitup/skins/synio/style.css",
|
||||
"___path.framework.frontend.web___/js/vendor/markitup/sets/synio/style.css",
|
||||
"___path.framework.frontend.web___/js/vendor/jcrop/jquery.Jcrop.css",
|
||||
"___path.framework.frontend.web___/js/vendor/prettify/prettify.css",
|
||||
"___path.framework.frontend.web___/js/vendor/notifier/jquery.notifier.css",
|
||||
|
@ -83,6 +81,24 @@ if ( Config::Get('view.rtl') ) {
|
|||
$aCss[] = "___path.skin.assets.web___/css/components/vote-rtl.css";
|
||||
}
|
||||
|
||||
// Подключение редакторов
|
||||
if ( Config::Get('view.wysiwyg') ) {
|
||||
$config['head']['default']['js'] = array_merge($config['head']['default']['js'], array(
|
||||
"___path.framework.frontend.web___/js/vendor/tinymce/tiny_mce.js",
|
||||
"___path.application.web___/frontend/common/js/editor.visual.js"
|
||||
));
|
||||
} else {
|
||||
$config['head']['default']['js'] = array_merge($config['head']['default']['js'], array(
|
||||
"___path.framework.frontend.web___/js/vendor/markitup/jquery.markitup.js",
|
||||
"___path.application.web___/frontend/common/js/editor.markup.js"
|
||||
));
|
||||
$aCss = array_merge($aCss, array(
|
||||
"___path.framework.frontend.web___/js/vendor/markitup/skins/synio/style.css",
|
||||
"___path.framework.frontend.web___/js/vendor/markitup/sets/synio/style.css",
|
||||
"___path.skin.assets.web___/css/components/editor.css"
|
||||
));
|
||||
}
|
||||
|
||||
// Подключение фронтенд фреймворка
|
||||
$config['head']['default']['css'] = array_merge(Config::Get('head.default.css'), $aCss);
|
||||
|
||||
|
|
Loading…
Reference in a new issue