var config = {
buttons: buttons,
minHeight: 200,
- plugins: ['alignment', 'source', 'table', 'WoltLabColor', 'WoltLabDropdown', 'WoltLabEvent', 'WoltLabLink', 'WoltLabQuote', 'WoltLabSize'],
+ plugins: ['alignment', 'source', 'table', 'WoltLabColor', 'WoltLabDropdown', 'WoltLabEvent', 'WoltLabLink', 'WoltLabQuote', 'WoltLabSize', 'WoltLabSmiley'],
toolbarFixed: false,
woltlab: {
autosave: autosave,
{if $__wcf->session->getPermission('admin.content.cms.canUseMedia')}'{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMedia.js?v={@LAST_UPDATE_TIME}',{/if}
'{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabMention.js?v={@LAST_UPDATE_TIME}',
'{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabQuote.js?v={@LAST_UPDATE_TIME}',
- '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}'
+ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSize.js?v={@LAST_UPDATE_TIME}',
+ '{@$__wcf->getPath()}js/3rdParty/redactor2/plugins/WoltLabSmiley.js?v={@LAST_UPDATE_TIME}'
], function() {
WCF.System.Dependency.Manager.invoke(callbackIdentifier);
// set icon
this.button.setIcon(button, '<span class="icon icon16 ' + buttonData.icon + '"></span>');
-
+ if (!button[0]) {
+ console.debug(buttonName);
+ }
// set title
//noinspection JSUnresolvedVariable
elAttr(button[0], 'title', buttonData.title);
--- /dev/null
+$.Redactor.prototype.WoltLabSmiley = function() {
+ "use strict";
+
+ return {
+ init: function() {
+ require(['EventHandler'], (function(EventHandler) {
+ EventHandler.add('com.woltlab.wcf.redactor2', 'insertSmiley_' + this.$element[0].id, this.WoltLabSmiley._insertSmiley.bind(this))
+ }).bind(this));
+ },
+
+ _insertSmiley: function(data) {
+ this.insert.html('<img src="' + data.path + '" class="smiley" alt="' + data.code + '">');
+ }
+ }
+};
*/
WCF.Message.Smilies = Class.extend({
/**
- * redactor element
- * @var $.Redactor
- */
- _redactor: null,
-
- /**
- * wysiwyg container id
+ * wysiwyg editor id
* @var string
*/
- _wysiwygSelector: '',
+ _editorId: '',
/**
* Initializes the smiley handler.
*
- * @param {string} wysiwygSelector
+ * @param {string} editorId
*/
- init: function(wysiwygSelector) {
- this._wysiwygSelector = wysiwygSelector;
+ init: function(editorId) {
+ this._editorId = editorId;
- WCF.System.Dependency.Manager.register('Redactor_' + this._wysiwygSelector, $.proxy(function() {
- this._redactor = $('#' + this._wysiwygSelector).redactor('core.getObject');
-
- $('.messageTabMenu[data-wysiwyg-container-id=' + this._wysiwygSelector + ']').on('click', '.jsSmiley', $.proxy(this._smileyClick, this));
- }, this));
+ $('.messageTabMenu[data-wysiwyg-container-id=' + this._editorId + ']').on('click', '.jsSmiley', this._smileyClick.bind(this));
},
/**
_smileyClick: function(event) {
event.preventDefault();
- var $target = $(event.currentTarget);
- var $smileyCode = $target.data('smileyCode');
- var $smileyPath = $target.data('smileyPath');
-
- // register smiley
- this._redactor.wbbcode.insertSmiley($smileyCode, $smileyPath, true);
+ require(['EventHandler'], (function(EventHandler) {
+ EventHandler.fire('com.woltlab.wcf.redactor2', 'insertSmiley_' + this._editorId, {
+ code: elData(event.currentTarget, 'smiley-code'),
+ path: elData(event.currentTarget, 'smiley-path')
+ });
+ }).bind(this));
}
});