From 3c2b7e9bad4cfd0afde29c6f4a15fd77cbeb1837 Mon Sep 17 00:00:00 2001 From: Fabii Date: Fri, 22 Jan 2016 18:52:07 +0100 Subject: [PATCH] Use 'elData()' instead of 'elAttr()' wherever possible --- .../files/js/WoltLab/WCF/Attachment/Upload.js | 28 +++++++++---------- .../js/WoltLab/WCF/Bbcode/Collapsible.js | 2 +- .../files/js/WoltLab/WCF/Bbcode/FromHtml.js | 10 +++---- .../js/WoltLab/WCF/Controller/Clipboard.js | 20 ++++++------- .../WoltLab/WCF/Controller/Notice/Dismiss.js | 2 +- .../js/WoltLab/WCF/Controller/Popover.js | 4 +-- .../Controller/User/Notification/Settings.js | 6 ++-- .../files/js/WoltLab/WCF/Date/Picker.js | 22 +++++++-------- .../js/WoltLab/WCF/Date/Time/Relative.js | 8 +++--- .../files/js/WoltLab/WCF/Language/Input.js | 8 +++--- .../js/WoltLab/WCF/Ui/Collapsible/Sidebar.js | 4 +-- .../install/files/js/WoltLab/WCF/Ui/Dialog.js | 10 +++---- .../files/js/WoltLab/WCF/Ui/ItemList.js | 8 +++--- .../files/js/WoltLab/WCF/Ui/Like/Handler.js | 12 ++++---- .../files/js/WoltLab/WCF/Ui/Page/JumpTo.js | 4 +-- .../files/js/WoltLab/WCF/Ui/Suggestion.js | 2 +- .../files/js/WoltLab/WCF/Ui/TabMenu/Simple.js | 20 ++++++------- .../files/js/WoltLab/WCF/Ui/Tooltip.js | 6 ++-- 18 files changed, 88 insertions(+), 88 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js b/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js index 403545884c..33c2ab5892 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js @@ -54,7 +54,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa _createFileElement: function(file) { var listItem = elCreate('li'); listItem.className = 'box64'; - elAttr(listItem, 'data-filename', filename); + elData(listItem, 'filename', filename); this._target.appendChild(listItem); this._target.style.removeProperty('display'); @@ -131,8 +131,8 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa var progress = elByTag(listItem, 'PROGRESS'); progress.parentNode.removeChild(progress); - var filename = elAttr(listItem, 'data-filename'); - var internalFileId = elAttr(listItem, 'data-internal-file-id'); + var filename = elData(listItem, 'filename'); + var internalFileId = elData(listItem, 'internal-file-id'); var icon = DomTraverse.childByClass(listItem, 'fa-spinner'); @@ -144,9 +144,9 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa elAttr(img, 'src', attachment.tinyURL); elAttr(img, 'alt', ''); icon.parentNode.replaceChild(icon, img); - - elAttr(listItem, 'data-height', attachment.height); - elAttr(listItem, 'data-width', attachment.width); + + elData(listItem, 'height', attachment.height); + elData(listItem, 'width', attachment.width); } else { // TODO: Use FileUtil.getIconClassByMimeType()? @@ -179,14 +179,14 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa var span = elCreate('span'); span.className = 'button small jsDeleteButton'; span.textContent = Language.get('wcf.global.button.delete'); - elAttr(span, 'data-object-id', attachment.attachmentID); - elAttr(span, 'data-confirm-message', Language.get('wcf.attachment.delete.sure')); + elData(span, 'object-id', attachment.attachmentID); + elData(span, 'confirm-message', Language.get('wcf.attachment.delete.sure')); if (this._wysiwygContainerId) { - elAttr(span, 'data-event-name', 'attachment_' + this._wysiwygContainerId); + elData(span, 'event-name', 'attachment_' + this._wysiwygContainerId); } deleteButton.appendChild(span); - elAttr(span, 'data-object-id', attachment.attachmentID); + elData(span, 'object-id', attachment.attachmentID); if (this._wysiwygContainerId) { if (attachment.tinyURL) { @@ -196,7 +196,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa span = elCreate('span'); span.className = 'button small jsButtonAttachmentInsertThumbnail'; span.textContent = Language.get('wcf.global.button.insertThumbnail'); - elAttr(span, 'data-object-id', attachment.attachmentID); + elData(span, 'object-id', attachment.attachmentID); span.addEventListener('click', this._insert.bind(this)); insertThumbnailButton.appendChild(span); @@ -206,18 +206,18 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa span = elCreate('span'); span.className = 'button small jsButtonAttachmentInsertFull'; span.textContent = Language.get('wcf.global.button.insertFull'); - elAttr(span, 'data-object-id', attachment.attachmentID); + elData(span, 'object-id', attachment.attachmentID); span.addEventListener('click', this._insert.bind(this)); insertOriginalButton.appendChild(span); } else { - var insertPlainButton elCreate('li'); + var insertPlainButton = elCreate('li'); ul.appendChild(insertPlainButton); span = elCreate('span'); span.className = 'button small jsButtonAttachmentInsertPlain'; span.textContent = Language.get('wcf.global.button.insert'); - elAttr(span, 'data-object-id', attachment.attachmentID); + elData(span, 'object-id', attachment.attachmentID); span.addEventListener('click', this._insert.bind(this)); insertPlainButton.appendChild(span); } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/Collapsible.js b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/Collapsible.js index bb44fb95ba..ccfed639fe 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/Collapsible.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/Collapsible.js @@ -30,7 +30,7 @@ define([], function() { var toggle = function() { var expand = container.classList.contains('collapsed'); container.classList[expand ? 'remove' : 'add']('collapsed'); - toggleButton.textContent = elAttr(toggleButton, 'data-title-' + (expand ? 'collapse' : 'expand')); + toggleButton.textContent = elData(toggleButton, 'title-' + (expand ? 'collapse' : 'expand')); }; toggleButton.addEventListener('click', toggle); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js index 97c302a2e4..bc162b4eae 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js @@ -106,7 +106,7 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St */ _preserveSourceElement: function(element, sourceElements) { var placeholder = elCreate('var'); - elAttr(placeholder, 'data-source', 'wcf'); + elData(placeholder, 'source', 'wcf'); element.parentNode.insertBefore(placeholder, element); var fragment = document.createDocumentFragment(); @@ -245,7 +245,7 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St * @param {Element} element target element */ _convertBlockquote: function(element) { - var author = elAttr(element, 'data-author'); + var author = elData(element, 'author'); var link = elAttr(element, 'cite'); var open = '[quote]'; @@ -287,7 +287,7 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St width = (typeof width === 'string') ? ~~width.replace(/px$/, '') : 0; if (element.classList.contains('redactorEmbeddedAttachment')) { - var attachmentId = elAttr(element, 'data-attachment-id'); + var attachmentId = elData(element, 'attachment-id'); if (width > 0) { element.outerHTML = "[attach=" + attachmentId + "," + float + "," + width + "][/attach]"; @@ -525,8 +525,8 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St * @param {Element} element target element */ _convertSourceCodeBox: function(element) { - var filename = elAttr(element, 'data-filename').trim() || ''; - var highlighter = elAttr(element, 'data-highlighter'); + var filename = elData(element, 'filename').trim() || ''; + var highlighter = elData(element, 'highlighter'); window.dtdesign = element; var list = DomTraverse.childByTag(element.children[0], 'OL'); var lineNumber = ~~list.getAttribute('start') || 1; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js index 300932e56f..0c3a3b8dc7 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js @@ -88,7 +88,7 @@ define( if (containerData === undefined) { var markAll = elBySel('.jsClipboardMarkAll', container); if (markAll !== null) { - elAttr(markAll, 'data-container-id', containerId); + elData(markAll, 'container-id', containerId); markAll.addEventListener('click', this._markAll.bind(this)); } @@ -105,7 +105,7 @@ define( var checkbox = containerData.checkboxes[j]; if (!_knownCheckboxes.has(checkbox)) { - elAttr(checkbox, 'data-container-id', containerId); + elData(checkbox, 'container-id', containerId); checkbox.addEventListener('click', _callbackCheckbox); _knownCheckboxes.add(checkbox); @@ -120,7 +120,7 @@ define( _initEditors: function() { var getTypes = function(editor) { try { - var types = elAttr(editor, 'data-types'); + var types = elData(editor, 'types'); if (typeof types === 'string') { return JSON.parse('{ "types": ' + types.replace(/'/g, '"') + '}').types; } @@ -166,7 +166,7 @@ define( var isMarked = (checkbox.nodeName !== 'INPUT' || checkbox.checked); var objectIds = []; - var containerId = elAttr(checkbox, 'data-container-id'); + var containerId = elData(checkbox, 'container-id'); var data = _containers.get(containerId); var type = elAttr(data.element, 'data-type'); @@ -209,7 +209,7 @@ define( var checkbox = event.currentTarget; var objectId = ~~checkbox.getAttribute('data-object-id'); var isMarked = checkbox.checked; - var containerId = elAttr(checkbox, 'data-container-id'); + var containerId = elData(checkbox, 'container-id'); var data = _containers.get(containerId); var type = elAttr(data.element, 'data-type'); @@ -267,7 +267,7 @@ define( } var triggerEvent = function() { - var type = elAttr(listItem, 'data-type'); + var type = elData(listItem, 'type'); EventHandler.fire('com.woltlab.wcf.clipboard', type, { data: data, @@ -369,7 +369,7 @@ define( parameters: parameters }, (function(responseData) { if (data.actionName !== 'unmarkAll') { - var type = elAttr(listItem, 'data-type'); + var type = elData(listItem, 'type'); EventHandler.fire('com.woltlab.wcf.clipboard', type, { data: data, @@ -501,8 +501,8 @@ define( label.textContent = itemData.label; item.appendChild(label); itemList.appendChild(item); - - elAttr(item, 'data-type', typeName); + + elData(item, 'type', typeName); item.addEventListener('click', _callbackItem); _itemData.set(item, itemData); @@ -514,7 +514,7 @@ define( // add 'unmark all' var unmarkAll = elCreate('li'); - elAttr(unmarkAll, 'data-type', typeName); + elData(unmarkAll, 'type', typeName); var label = elCreate('span'); label.textContent = Language.get('wcf.clipboard.item.unmarkAll'); unmarkAll.appendChild(label); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js index ec19886ee3..8a08603be7 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js @@ -37,7 +37,7 @@ define(['Ajax'], function(Ajax) { data: { actionName: 'dismiss', className: 'wcf\\data\\notice\\NoticeAction', - objectIDs: [ elAttr(button, 'data-object-id') ] + objectIDs: [ elData(button, 'object-id') ] }, success: function() { var parent = button.parentNode; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js index f8a220ae25..06ab96ff0d 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js @@ -180,7 +180,7 @@ define(['Ajax', 'Dictionary', 'Environment', 'Dom/ChangeListener', 'Dom/Util', ' } var cacheId = identifier + "-" + objectId; - elAttr(element, 'data-cache-id', cacheId); + elData(element, 'cache-id', cacheId); _elements.set(id, { element: element, @@ -217,7 +217,7 @@ define(['Ajax', 'Dictionary', 'Environment', 'Dom/ChangeListener', 'Dom/Util', ' if (_activeId) { var activeElement = _elements.get(_activeId).element; - if (elAttr(activeElement, 'data-cache-id') === cacheId) { + if (elData(activeElement, 'cache-id') === cacheId) { this._show(); } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/User/Notification/Settings.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/User/Notification/Settings.js index 44b6a34853..9d39431d31 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/User/Notification/Settings.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/User/Notification/Settings.js @@ -55,7 +55,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function var mailValue = DomTraverse.childByTag(mailSetting, 'INPUT'); var button = DomTraverse.childByTag(mailSetting, 'A'); - elAttr(button, 'data-object-id', groupId); + elData(button, 'object-id', groupId); button.addEventListener('click', _callbackClick); _data.set(groupId, { @@ -103,7 +103,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function _createDropdown: function(objectId, initialValue) { var dropdownMenu = elCreate('ul'); dropdownMenu.className = 'dropdownMenu'; - elAttr(dropdownMenu, 'data-object-id', objectId); + elData(dropdownMenu, 'object-id', objectId); var link, listItem, value, items = ['instant', 'daily', 'divider', 'none']; for (var i = 0; i < 4; i++) { @@ -117,7 +117,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function link = elCreate('a'); link.textContent = Language.get('wcf.user.notification.mailNotificationType.' + value); listItem.appendChild(link); - elAttr(listItem, 'data-value', value); + elData(listItem, 'value', value); listItem.addEventListener('click', _callbackSelectType); if (initialValue === value) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js b/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js index 60989b9675..976ba33f76 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js @@ -48,14 +48,14 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment element.readOnly = true; var isDateTime = (elAttr(element, 'type') === 'datetime'); - - elAttr(element, 'data-is-date-time', isDateTime); + + elData(element, 'is-date-time', isDateTime); // convert value var date = null, value = elAttr(element, 'value'); if (elAttr(element, 'value')) { date = new Date(value); - elAttr(element, 'data-value', date.getTime()); + elData(element, 'value', date.getTime()); value = DateUtil['formatDate' + (isDateTime ? 'Time' : '')](date); } @@ -63,24 +63,24 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment // handle birthday input if (element.classList.contains('birthday')) { - elAttr(element, 'data-min-date', '100'); - elAttr(element, 'data-max-date', 'now'); + elData(element, 'min-date', '100'); + elData(element, 'max-date', 'now'); } this._initDateRange(element, now, true); this._initDateRange(element, now, false); - if (elAttr(element, 'data-min-date') === elAttr(element, 'data-max-date')) { + if (elData(element, 'min-date') === elData(element, 'max-date')) { throw new Error("Minimum and maximum date cannot be the same (element id '" + element.id + "')."); } // change type to prevent browser's datepicker to trigger element.type = 'text'; element.value = value; - elAttr(element, 'data-empty', isEmpty); + elData(element, 'empty', isEmpty); - if (elAttr(element, 'data-placeholder')) { - elAttr(element, 'placeholder', elAttr(element, 'data-placeholder')); + if (elData(element, 'placeholder')) { + elAttr(element, 'placeholder', elData(element, 'placeholder')); } // add a hidden element to hold the actual date @@ -652,8 +652,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment setDate: function(element, date) { element = this._getElement(element); var data = _data.get(element); - - elAttr(element, 'data-value', date.getTime()); + + elData(element, 'value', date.getTime()); element.value = DateUtil['formatDate' + (data.isDateTime ? 'Time' : '')](date); data.shadow.value = DateUtil.format(date, (data.isDateTime ? 'c' : 'Y-m-d')); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js index 6e4c36a47f..58a4b0a507 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js @@ -35,14 +35,14 @@ define(['Dom/ChangeListener', 'Language', 'WoltLab/WCF/Date/Util', 'WoltLab/WCF/ for (var i = 0, length = _elements.length; i < length; i++) { var element = _elements[i]; - if (!element.classList.contains('datetime') || elAttr(element, 'data-is-future-date')) continue; + if (!element.classList.contains('datetime') || elData(element, 'is-future-date')) continue; if (!element.getAttribute('title')) elAttr(element, 'title', element.textContent.trim()); var elTimestamp = ~~element.getAttribute('data-timestamp') + _offset; - var elDate = elAttr(element, 'data-date'); - var elTime = elAttr(element, 'data-time'); - var elOffset = elAttr(element, 'data-offset'); + var elDate = elData(element, 'date'); + var elTime = elData(element, 'time'); + var elOffset = elData(element, 'offset'); // timestamp is less than 60 seconds ago if (elTimestamp >= timestamp || timestamp < (elTimestamp + 60)) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js b/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js index c7a8798c42..6c01ad896e 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js @@ -79,7 +79,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver if (!container.classList.contains('inputAddon')) { container = elCreate('div'); container.className = 'inputAddon' + (element.nodeName === 'TEXTAREA' ? ' inputAddonTextarea' : ''); - elAttr(container, 'data-input-id', elementId); + elData(container, 'input-id', elementId); element.parentNode.insertBefore(container, element); container.appendChild(element); @@ -114,7 +114,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver for (var languageId in availableLanguages) { if (availableLanguages.hasOwnProperty(languageId)) { var listItem = elCreate('li'); - elAttr(listItem, 'data-language-id', languageId); + elData(listItem, 'language-id', languageId); span = elCreate('span'); span.textContent = availableLanguages[languageId]; @@ -131,7 +131,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver dropdownMenu.appendChild(listItem); listItem = elCreate('li'); - elAttr(listItem, 'data-language-id', 0); + elData(listItem, 'language-id', 0); span = elCreate('span'); span.textContent = Language.get('wcf.global.button.disabledI18n'); listItem.appendChild(span); @@ -194,7 +194,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver for (var i = 0, length = dropdownMenu.childElementCount; i < length; i++) { item = dropdownMenu.children[i]; - var itemLanguageId = elAttr(item, 'data-language-id'); + var itemLanguageId = elData(item, 'language-id'); if (itemLanguageId.length && languageId === ~~itemLanguageId) { label = item.children[0].textContent; } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Collapsible/Sidebar.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Collapsible/Sidebar.js index bbb67995ac..9729bd8999 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Collapsible/Sidebar.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Collapsible/Sidebar.js @@ -26,9 +26,9 @@ define(['Ajax', 'Language', 'Dom/Util'], function(Ajax, Language, DomUtil) { return; } - _isOpen = (elAttr(sidebar, 'data-is-open') === 'true'); + _isOpen = (elData(sidebar, 'is-open') === 'true'); _main = elById('main'); - _name = elAttr(sidebar, 'data-sidebar-name'); + _name = elData(sidebar, 'sidebar-name'); this._createUI(sidebar); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js index 6916667bcf..966e02b86c 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js @@ -75,12 +75,12 @@ define( button = _staticDialogs[0]; button.classList.remove('jsStaticDialog'); - id = elAttr(button, 'data-dialog-id'); + id = elData(button, 'dialog-id'); if (id && (container = elById(id))) { ((function(button, container) { container.classList.remove('jsStaticDialogContent'); container.style.setProperty('display', 'none'); - button.addEventListener('click', this.openStatic.bind(this, container.id, null, { title: elAttr(container, 'data-title') })); + button.addEventListener('click', this.openStatic.bind(this, container.id, null, { title: elData(container, 'title') })); }).bind(this))(button, container); } } @@ -258,10 +258,10 @@ define( dialog.classList.add('dialogContainer'); elAttr(dialog, 'aria-hidden', 'true'); elAttr(dialog, 'role', 'dialog'); - elAttr(dialog, 'data-id', id); + elData(dialog, 'id', id); if (options.disposeOnClose) { - elAttr(dialog, 'data-dispose-on-close', true); + elData(dialog, 'dispose-on-close', true); } var header = elCreate('header'); @@ -517,7 +517,7 @@ define( for (var i = 0; i < _container.childElementCount; i++) { var child = _container.children[i]; if (elAttr(child, 'aria-hidden') === 'false') { - _activeDialog = elAttr(child, 'data-id'); + _activeDialog = elData(child, 'id'); break; } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js index f2d8a1f0eb..0ad283ba10 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js @@ -143,7 +143,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges for (var i = 0, length = items.length; i < length; i++) { item = items[i]; value = { - objectId: elAttr(item, 'data-object-id'), + objectId: elData(item, 'object-id'), value: DomTraverse.childByTag(item, 'SPAN').textContent }; @@ -179,7 +179,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges _createUI: function(element, options) { var list = elCreate('ol'); list.className = 'inputItemList'; - elAttr(list, 'data-element-id', element.id); + elData(list, 'element-id', element.id); list.addEventListener('click', function(event) { if (event.target === list) element.focus(); }); @@ -342,7 +342,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges var content = elCreate('span'); content.className = 'content'; - elAttr(content, 'data-object-id', value.objectId); + elData(content, 'object-id', value.objectId); content.textContent = value.value; var button = elCreate('a'); @@ -374,7 +374,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges item = (event === null) ? item : event.currentTarget.parentNode; var parent = item.parentNode; - var elementId = elAttr(parent, 'data-element-id'); + var elementId = elData(parent, 'element-id'); var data = _data.get(elementId); data.suggestion.removeExcludedValue(item.children[0].textContent); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js index 311ba61a77..cae130f0b7 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js @@ -77,11 +77,11 @@ define( likeButton: null, summary: null, - dislikes: ~~elAttr(element, 'data-like-dislikes'), - liked: ~~elAttr(element, 'data-like-liked'), - likes: ~~elAttr(element, 'data-like-likes'), - objectId: ~~elAttr(element, 'data-object-id'), - users: JSON.parse(elAttr(element, 'data-like-users')) + dislikes: ~~elData(element, 'like-dislikes'), + liked: ~~elData(element, 'like-liked'), + likes: ~~elData(element, 'like-likes'), + objectId: ~~elData(element, 'object-id'), + users: JSON.parse(elData(element, 'like-users')) }; this._containers.set(element, elementData); @@ -134,7 +134,7 @@ define( this._updateBadge(element); } - var insertPosition, userId = elAttr(element, 'data-user-id'); + var insertPosition, userId = elData(element, 'user-id'); if (this._options.canLikeOwnContent || WCF.User.userID === userId) { insertPosition = elBySel(this._options.buttonBeforeSelector, element); if (insertPosition !== null) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpTo.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpTo.js index 3e1c6d5a64..f922e4214b 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpTo.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Page/JumpTo.js @@ -28,7 +28,7 @@ define(['Language', 'ObjectMap', 'Ui/Dialog'], function(Language, ObjectMap, UiD init: function(element, callback) { callback = callback || null; if (callback === null) { - var redirectUrl = elAttr(element, 'data-link'); + var redirectUrl = elData(element, 'link'); if (redirectUrl) { callback = function(pageNo) { window.location = redirectUrl.replace(/pageNo=%d/, 'pageNo=' + pageNo); @@ -68,7 +68,7 @@ define(['Language', 'ObjectMap', 'Ui/Dialog'], function(Language, ObjectMap, UiD UiDialog.open(this); - var pages = elAttr(element, 'data-pages'); + var pages = elData(element, 'pages'); _input.value = pages; _input.setAttribute('max', pages); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js index fa72f04c6f..65094dee94 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js @@ -223,7 +223,7 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd anchor = elCreate('a'); anchor.textContent = item.label; - elAttr(anchor, 'data-object-id', item.objectID); + elData(anchor, 'object-id', item.objectID); anchor.addEventListener('click', this._select.bind(this)); listItem = elCreate('li'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js index c06d17cb2d..4e1d322fe2 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js @@ -56,13 +56,13 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict var container, containers = DomTraverse.childrenByTag(this._container, 'DIV'), name; for (var i = 0, length = containers.length; i < length; i++) { container = containers[i]; - name = elAttr(container, 'data-name'); + name = elData(container, 'name'); if (!name) { name = DomUtil.identify(container); } - - elAttr(container, 'data-name', name); + + elData(container, 'name', name); this._containers.set(name, container); } @@ -124,7 +124,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict // bind listeners this._tabs.forEach((function(tab) { - if (!oldTabs || oldTabs.get(elAttr(tab, 'data-name')) !== tab) { + if (!oldTabs || oldTabs.get(elData(tab, 'name')) !== tab) { tab.children[0].addEventListener('click', this._onClick.bind(this)); } }).bind(this)); @@ -199,19 +199,19 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict } } - name = name || elAttr(tab, 'data-name'); + name = name || elData(tab, 'name'); // unmark active tab var oldTab = elBySel('#' + this._container.id + ' > nav > ul > li.active'); var oldContent = null; if (oldTab) { - if (elAttr(oldTab, 'data-name') === name) { + if (elData(oldTab, 'name') === name) { // same tab return; } oldTab.classList.remove('active'); - oldContent = this._containers.get(elAttr(oldTab, 'data-name')); + oldContent = this._containers.get(elData(oldTab, 'name')); oldContent.classList.remove('active'); oldContent.classList.add('hidden'); @@ -257,7 +257,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict active: tab, activeName: name, previous: oldTab, - previousName: oldTab ? elAttr(oldTab, 'data-name') : null + previousName: oldTab ? elData(oldTab, 'name') : null }); var jQuery = (this._isLegacy && typeof window.jQuery === 'function') ? window.jQuery : null; @@ -312,7 +312,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict * @return {string} tab name */ _getTabName: function(tab) { - var name = elAttr(tab, 'data-name'); + var name = elData(tab, 'name'); // handle legacy tab menus if (!name) { @@ -325,7 +325,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict } else { this._isLegacy = true; - elAttr(tab, 'data-name', name); + elData(tab, 'name', name); } } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js index 172f95bf47..cf4d87a3f8 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Tooltip.js @@ -58,7 +58,7 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme title = (typeof title === 'string') ? title.trim() : ''; if (title.length) { - elAttr(element, 'data-tooltip', title); + elData(element, 'tooltip', title); element.removeAttribute('title'); element.addEventListener('mouseenter', this._mouseEnter.bind(this)); @@ -79,11 +79,11 @@ define(['Environment', 'Dom/ChangeListener', 'Ui/Alignment'], function(Environme title = (typeof title === 'string') ? title.trim() : ''; if (title !== '') { - elAttr(element, 'data-tooltip', title); + elData(element, 'tooltip', title); element.removeAttribute('title'); } - title = elAttr(element, 'data-tooltip'); + title = elData(element, 'tooltip'); // reset tooltip position _tooltip.style.removeProperty('top'); -- 2.20.1