From: Alexander Ebert Date: Sun, 21 Aug 2016 21:16:59 +0000 (+0200) Subject: Removed some outdated js X-Git-Tag: 3.0.0_Beta_1~606 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1456241d2f36d7951c6da92ee6922353a0b4bfbe;p=GitHub%2FWoltLab%2FWCF.git Removed some outdated js --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabParagraphize.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabParagraphize.js deleted file mode 100644 index ce9ceeb670..0000000000 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabParagraphize.js +++ /dev/null @@ -1,31 +0,0 @@ -$.Redactor.prototype.WoltLabParagraphize = function() { - "use strict"; - - return { - init: function () { - this.paragraphize.getSafes = (function (html) { - var $div = $('
').append(html); - - // WoltLab modification: do not remove

inside quotes - // remove paragraphs in blockquotes - /*$div.find('blockquote p').replaceWith(function() - { - return $(this).append('
').contents(); - });*/ - - $div.find(this.opts.paragraphizeBlocks.join(', ')).each($.proxy(function(i,s) - { - this.paragraphize.z++; - this.paragraphize.safes[this.paragraphize.z] = s.outerHTML; - - return $(s).replaceWith('\n#####replace' + this.paragraphize.z + '#####\n\n'); - - - }, this)); - - - return $div.html(); - }).bind(this) - } - }; -}; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/FromHtml.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/FromHtml.js deleted file mode 100644 index e3386aa9a8..0000000000 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Bbcode/FromHtml.js +++ /dev/null @@ -1,547 +0,0 @@ -/** - * Converts a message containing HTML tags into BBCodes. - * - * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLabSuite/Core/Bbcode/FromHtml - */ -define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, StringUtil, DomTraverse) { - "use strict"; - - var _converter = []; - var _inlineConverter = {}; - var _sourceConverter = []; - - /** - * Returns true if a whitespace should be inserted before or after the smiley. - * - * @param {Element} element image element - * @param {boolean} before evaluate previous node - * @return {boolean} true if a whitespace should be inserted - */ - function addSmileyPadding(element, before) { - var target = element[(before ? 'previousSibling' : 'nextSibling')]; - if (target === null || target.nodeType !== Node.TEXT_NODE || !/\s$/.test(target.textContent)) { - return true; - } - - return false; - } - - /** - * @module WoltLabSuite/Core/Bbcode/FromHtml - */ - var BbcodeFromHtml = { - /** - * Converts a message containing HTML elements into BBCodes. - * - * @param {string} message message containing HTML elements - * @return {string} message containing BBCodes - */ - convert: function(message) { - if (message.length) this._setup(); - - var container = elCreate('div'); - container.innerHTML = message; - - // convert line breaks - var elements = elByTag('P', container); - while (elements.length) elements[0].outerHTML = elements[0].innerHTML; - - elements = elByTag('BR', container); - while (elements.length) elements[0].outerHTML = "\n"; - - // prevent conversion taking place inside source bbcodes - var sourceElements = this._preserveSourceElements(container); - - EventHandler.fire('com.woltlab.wcf.bbcode.fromHtml', 'beforeConvert', { container: container }); - - for (var i = 0, length = _converter.length; i < length; i++) { - this._convert(container, _converter[i]); - } - - EventHandler.fire('com.woltlab.wcf.bbcode.fromHtml', 'afterConvert', { container: container }); - - this._restoreSourceElements(container, sourceElements); - - // remove remaining HTML elements - elements = elByTag('*', container); - while (elements.length) elements[0].outerHTML = elements[0].innerHTML; - - message = this._convertSpecials(container.innerHTML); - - return message; - }, - - /** - * Replaces HTML elements mapping to source BBCodes to avoid - * them being handled by other converters. - * - * @param {Element} container container element - * @return {array} list of source elements and their placeholder - */ - _preserveSourceElements: function(container) { - var elements, sourceElements = [], tmp; - - for (var i = 0, length = _sourceConverter.length; i < length; i++) { - elements = elBySelAll(_sourceConverter[i].selector, container); - - tmp = []; - for (var j = 0, innerLength = elements.length; j < innerLength; j++) { - this._preserveSourceElement(elements[j], tmp); - } - - sourceElements.push(tmp); - } - - return sourceElements; - }, - - /** - * Replaces an element with a placeholder. - * - * @param {Element} element target element - * @param {array} list of removed elements and their placeholders - */ - _preserveSourceElement: function(element, sourceElements) { - var placeholder = elCreate('var'); - elData(placeholder, 'source', 'wcf'); - element.parentNode.insertBefore(placeholder, element); - - var fragment = document.createDocumentFragment(); - fragment.appendChild(element); - - sourceElements.push({ - fragment: fragment, - placeholder: placeholder - }); - }, - - /** - * Reinserts source elements for parsing. - * - * @param {Element} container container element - * @param {array} sourceElements list of removed elements and their placeholders - */ - _restoreSourceElements: function(container, sourceElements) { - var element, elements, placeholder; - for (var i = 0, length = sourceElements.length; i < length; i++) { - elements = sourceElements[i]; - - if (elements.length === 0) { - continue; - } - - for (var j = 0, innerLength = elements.length; j < innerLength; j++) { - element = elements[j]; - placeholder = element.placeholder; - - placeholder.parentNode.insertBefore(element.fragment, placeholder); - - _sourceConverter[i].callback(placeholder.previousElementSibling); - - elRemove(placeholder); - } - } - }, - - /** - * Converts special entities. - * - * @param {string} message HTML message - * @return {string} HTML message - */ - _convertSpecials: function(message) { - message = message.replace(/&/g, '&'); - message = message.replace(/</g, '<'); - message = message.replace(/>/g, '>'); - - return message; - }, - - /** - * Sets up converters applied to elements in linear order. - */ - _setup: function() { - if (_converter.length) { - return; - } - - _converter = [ - // simple replacement - { tagName: 'STRONG', bbcode: 'b' }, - { tagName: 'DEL', bbcode: 's' }, - { tagName: 'EM', bbcode: 'i' }, - { tagName: 'SUB', bbcode: 'sub' }, - { tagName: 'SUP', bbcode: 'sup' }, - { tagName: 'U', bbcode: 'u' }, - { tagName: 'KBD', bbcode: 'tt' }, - - // callback replacement - { tagName: 'A', callback: this._convertUrl.bind(this) }, - { tagName: 'IMG', callback: this._convertImage.bind(this) }, - { tagName: 'LI', callback: this._convertListItem.bind(this) }, - { tagName: 'OL', callback: this._convertList.bind(this) }, - { tagName: 'TABLE', callback: this._convertTable.bind(this) }, - { tagName: 'UL', callback: this._convertList.bind(this) }, - { tagName: 'BLOCKQUOTE', callback: this._convertBlockquote.bind(this) }, - - // convert these last - { tagName: 'SPAN', callback: this._convertSpan.bind(this) }, - { tagName: 'DIV', callback: this._convertDiv.bind(this) } - ]; - - _inlineConverter = { - span: [ - { style: 'color', callback: this._convertInlineColor.bind(this) }, - { style: 'font-size', callback: this._convertInlineFontSize.bind(this) }, - { style: 'font-family', callback: this._convertInlineFontFamily.bind(this) } - ], - div: [ - { style: 'text-align', callback: this._convertInlineTextAlign.bind(this) } - ] - }; - - _sourceConverter = [ - { selector: 'div.codeBox', callback: this._convertSourceCodeBox.bind(this) } - ]; - - EventHandler.fire('com.woltlab.wcf.bbcode.fromHtml', 'init', { - converter: _converter, - inlineConverter: _inlineConverter, - sourceConverter: _sourceConverter - }); - }, - - /** - * Converts an element into a raw string. - * - * @param {Element} container container element - * @param {object} converter converter object - */ - _convert: function(container, converter) { - if (typeof converter === 'function') { - converter(container); - return; - } - - var element, elements = elByTag(converter.tagName, container); - while (elements.length) { - element = elements[0]; - - if (converter.bbcode) { - element.outerHTML = '[' + converter.bbcode + ']' + element.innerHTML + '[/' + converter.bbcode + ']'; - } - else { - converter.callback(element); - } - } - }, - - /** - * Converts
into [quote]. - * - * @param {Element} element target element - */ - _convertBlockquote: function(element) { - var author = elData(element, 'author'); - var link = elAttr(element, 'cite'); - - var open = '[quote]'; - if (author) { - author = StringUtil.escapeHTML(author).replace(/(\\)?'/g, function(match, isEscaped) { return isEscaped ? match : "\\'"; }); - if (link) { - open = "[quote='" + author + "','" + StringUtil.escapeHTML(link) + "']"; - } - else { - open = "[quote='" + author + "']"; - } - } - - var header = DomTraverse.childByTag(element, 'HEADER'); - if (header !== null) element.removeChild(header); - - var divs = DomTraverse.childrenByTag(element, 'DIV'); - for (var i = 0, length = divs.length; i < length; i++) { - divs[i].outerHTML = divs[i].innerHTML + '\n'; - } - - element.outerHTML = open + element.innerHTML.replace(/^\n*/, '').replace(/\n*$/, '') + '[/quote]\n'; - }, - - /** - * Converts into smilies, [attach] or [img]. - * - * @param {Element} element target element - */ - _convertImage: function(element) { - if (element.classList.contains('smiley')) { - // smiley - element.outerHTML = (addSmileyPadding(element, true) ? ' ' : '') + elAttr(element, 'alt') + (addSmileyPadding(element, false) ? ' ' : ''); - return; - } - - var float = element.style.getPropertyValue('float') || 'none'; - var width = element.style.getPropertyValue('width'); - width = (typeof width === 'string') ? ~~width.replace(/px$/, '') : 0; - - if (element.classList.contains('redactorEmbeddedAttachment')) { - var attachmentId = elData(element, 'attachment-id'); - - if (width > 0) { - element.outerHTML = "[attach=" + attachmentId + "," + float + "," + width + "][/attach]"; - } - else if (float !== 'none') { - element.outerHTML = "[attach=" + attachmentId + "," + float + "][/attach]"; - } - else { - element.outerHTML = "[attach=" + attachmentId + "][/attach]"; - } - } - else { - // regular image - var source = element.src.trim(); - - if (width > 0) { - element.outerHTML = "[img='" + source + "'," + float + "," + width + "][/img]"; - } - else if (float !== 'none') { - element.outerHTML = "[img='" + source + "'," + float + "][/img]"; - } - else { - element.outerHTML = "[img]" + source + "[/img]"; - } - } - }, - - /** - * Converts
    and