From: Tim Düsterhus Date: Fri, 10 Jul 2015 21:56:28 +0000 (+0200) Subject: Rename JavaScript modules into proper camel case X-Git-Tag: 3.0.0_Beta_1~2191 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fd73966e16a2a281dfb8aae6252b98ead08b58fb;p=GitHub%2FWoltLab%2FWCF.git Rename JavaScript modules into proper camel case --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/ACP/Bootstrap.js b/wcfsetup/install/files/js/WoltLab/WCF/ACP/Bootstrap.js deleted file mode 100644 index 1243c441e8..0000000000 --- a/wcfsetup/install/files/js/WoltLab/WCF/ACP/Bootstrap.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Bootstraps WCF's JavaScript with additions for the ACP usage. - * - * @author Alexander Ebert - * @copyright 2001-2015 WoltLab GmbH - * @license GNU Lesser General Public License - * @module WoltLab/WCF/ACP/Bootstrap - */ -define(['WoltLab/WCF/Bootstrap'], function(Bootstrap) { - "use strict"; - - /** - * ACP Boostrapper. - * - * @exports WoltLab/WCF/ACP/Bootstrap - */ - var ACPBootstrap = { - /** - * Bootstraps general modules and frontend exclusive ones. - * - * @param {object} options bootstrap options - */ - setup: function(options) { - Bootstrap.setup(); - } - }; - - return ACPBootstrap; -}); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Bootstrap.js b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Bootstrap.js new file mode 100644 index 0000000000..1243c441e8 --- /dev/null +++ b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Bootstrap.js @@ -0,0 +1,29 @@ +/** + * Bootstraps WCF's JavaScript with additions for the ACP usage. + * + * @author Alexander Ebert + * @copyright 2001-2015 WoltLab GmbH + * @license GNU Lesser General Public License + * @module WoltLab/WCF/ACP/Bootstrap + */ +define(['WoltLab/WCF/Bootstrap'], function(Bootstrap) { + "use strict"; + + /** + * ACP Boostrapper. + * + * @exports WoltLab/WCF/ACP/Bootstrap + */ + var ACPBootstrap = { + /** + * Bootstraps general modules and frontend exclusive ones. + * + * @param {object} options bootstrap options + */ + setup: function(options) { + Bootstrap.setup(); + } + }; + + return ACPBootstrap; +}); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/BBCode/FromHtml.js deleted file mode 100644 index 9745f1862e..0000000000 --- a/wcfsetup/install/files/js/WoltLab/WCF/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 WoltLab/WCF/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 WoltLab/WCF/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 = document.createElement('div'); - container.innerHTML = message; - - // convert line breaks - var elements = container.getElementsByTagName('P'); - while (elements.length) elements[0].outerHTML = elements[0].innerHTML; - - elements = container.getElementsByTagName('BR'); - 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 = container.getElementsByTagName('*'); - 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 = container.querySelectorAll(_sourceConverter[i].selector); - - 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 = document.createElement('var'); - placeholder.setAttribute('data-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); - - placeholder.parentNode.removeChild(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 = container.getElementsByTagName(converter.tagName); - 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 = element.getAttribute('data-author') || ''; - var link = element.getAttribute('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) ? ' ' : '') + element.getAttribute('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 = element.getAttribute('data-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