From: Fabii Date: Sat, 30 Jan 2016 13:03:44 +0000 (+0100) Subject: Consistently using shorthand functions for DOM operations X-Git-Tag: 3.0.0_Beta_1~2030^2~62^2~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f5336f4f2059e569ad31bc5e147878e2ac70c169;p=GitHub%2FWoltLab%2FWCF.git Consistently using shorthand functions for DOM operations --- diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Editor.js b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Editor.js index c12349efde..08b42edda5 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Editor.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Editor.js @@ -206,7 +206,7 @@ define(['Ajax', 'Dictionary', 'Dom/Util', 'EventHandler'], function(Ajax, Dictio // apply CSS rules - var style = document.createElement('style'); + var style = elCreate('style'); style.appendChild(document.createTextNode('')); elData(style, 'created-by', 'WoltLab/Acp/Ui/Style/Editor'); document.head.appendChild(style); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Image/Upload.js b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Image/Upload.js index 71a85e917d..cefd66435f 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Image/Upload.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Image/Upload.js @@ -47,7 +47,7 @@ define(['Core', 'Dom/Traverse', 'Language', 'Ui/Notification', 'Upload'], functi elAttr(this._target, 'src', data.returnValues.url + '?timestamp=' + Date.now()); if (error) { - error.parentNode.removeChild(error); + elRemove(error); } UiNotification.show(); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js index aa8efafe03..627cac6d53 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js @@ -181,7 +181,7 @@ define(['Core', 'Language', 'Dom/ChangeListener', 'Dom/Util', 'Ui/Dialog', 'Wolt * @return {(*|null)} option value or null */ getOption: function(key) { - if (this._options.hasOwnProperty(key)) { + if (objOwns(this._options, key)) { return this._options[key]; } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js b/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js index a9c68f9225..ffba3f7011 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js @@ -34,7 +34,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa this._insertAllButton.className = 'button jsButtonAttachmentInsertAll'; this._insertAllButton.textContent = Language.get('wcf.attachment.insertAll'); if (DomTraverse.childBySel(this._target, 'li:not(.uploadFailed)')) { - this._insertAllButton.style.setProperty('display', 'none'); + elHide(this._insertAllButton); } this._insertAllButton.addEventListener('click', this._insertAll.bind(this)); this._button.appendChild(this._insertAllButton); @@ -56,7 +56,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa listItem.className = 'box64'; elData(listItem, 'filename', filename); this._target.appendChild(listItem); - this._target.style.removeProperty('display'); + elShow(this._target); var span = elCreate('span'); if (this._options.maxSize >= file.size) { @@ -129,7 +129,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa var listItem = this._fileElements[uploadId][i]; var progress = elByTag(listItem, 'PROGRESS'); - progress.parentNode.removeChild(progress); + elRemove(progress); var filename = elData(listItem, 'filename'); var internalFileId = elData(listItem, 'internal-file-id'); @@ -259,10 +259,10 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa // TODO: this._makeSortable(); if (DomTraverse.childrenBySel(this._target, 'li:not(.uploadFailed)').length) { - this._insertAllButton.style.removeProperty('display'); + elShow(this._insertAllButton); } else { - this._insertAllButton.style.setProperty('display', 'none'); + elHide(this._insertAllButton); } DomChangeListener.trigger(); @@ -301,7 +301,7 @@ define(['Core', 'Dom/ChangeListener', 'Dom/Traverse', 'Language', 'List', 'Uploa } if (innerError) { - innerError.parentNode.removeChild(innerError); + elRemove(innerError); } return true; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js index bc162b4eae..21f866ca4b 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js @@ -141,7 +141,7 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St _sourceConverter[i].callback(placeholder.previousElementSibling); - placeholder.parentNode.removeChild(placeholder); + elRemove(placeholder); } } }, @@ -529,7 +529,7 @@ define(['EventHandler', 'StringUtil', 'Dom/Traverse'], function(EventHandler, St var highlighter = elData(element, 'highlighter'); window.dtdesign = element; var list = DomTraverse.childByTag(element.children[0], 'OL'); - var lineNumber = ~~list.getAttribute('start') || 1; + var lineNumber = ~~elAttr(list, 'start') || 1; var content = ''; for (var i = 0, length = list.childElementCount; i < length; i++) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/ToHtml.js b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/ToHtml.js index caafe12256..0327a85790 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/ToHtml.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Bbcode/ToHtml.js @@ -245,7 +245,7 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/Bbcode/Pa } else if (length > 0) { attachmentId = ~~attributes[0]; - if (!_options.attachments.images.hasOwnProperty(attachmentId)) { + if (!objOwns(_options.attachments.images, attachmentId)) { length = 0; } } @@ -265,7 +265,7 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/Bbcode/Pa } } - var baseUrl = _options.attachments.thumbnailUrl; + var width, baseUrl = _options.attachments.thumbnailUrl; if (length > 2) { width = ~~attributes[2] || 0; if (width) { @@ -569,7 +569,7 @@ define(['Core', 'EventHandler', 'Language', 'StringUtil', 'WoltLab/WCF/Bbcode/Pa if (typeof item === 'string') { for (var smileyCode in __REDACTOR_SMILIES) { - if (__REDACTOR_SMILIES.hasOwnProperty(smileyCode)) { + if (objOwns(__REDACTOR_SMILIES, smileyCode)) { altValue = smileyCode.replace(//g, '>'); regexp = new RegExp('(\\s|^)' + StringUtil.escapeRegExp(smileyCode) + '(?=\\s|$)', 'gi'); item = item.replace(regexp, '$1' + altValue + ''); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js index 4f45012af0..e46aa409cd 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js @@ -140,11 +140,11 @@ define( var containerId = elData(checkbox, 'container-id'); var data = _containers.get(containerId); - var type = elAttr(data.element, 'data-type'); + var type = elData(data.element, 'type'); for (var i = 0, length = data.checkboxes.length; i < length; i++) { var item = data.checkboxes[i]; - var objectId = ~~item.getAttribute('data-object-id'); + var objectId = ~~elData(item, 'object-id'); if (isMarked) { if (!item.checked) { @@ -179,11 +179,11 @@ define( */ _mark: function(event) { var checkbox = event.currentTarget; - var objectId = ~~checkbox.getAttribute('data-object-id'); + var objectId = ~~elData(checkbox, 'object-id'); var isMarked = checkbox.checked; var containerId = elData(checkbox, 'container-id'); var data = _containers.get(containerId); - var type = elAttr(data.element, 'data-type'); + var type = elData(data.element, 'type'); var clipboardObject = DomTraverse.parentByClass(checkbox, 'jsClipboardObject'); data.markedObjectIds[(isMarked ? 'add' : 'delete')](objectId); @@ -261,7 +261,7 @@ define( var formData = {}; if (template.length) { - var items = UiConfirmation.getContentElement().querySelectorAll('input, select, textarea'); + var items = elBySel('input, select, textarea', UiConfirmation.getContentElement()); for (var i = 0, length = items.length; i < length; i++) { var item = items[i]; var name = elAttr(item, 'name'); @@ -324,7 +324,7 @@ define( if (typeof data.internalData.parameters === 'object') { for (var key in data.internalData.parameters) { - if (data.internalData.parameters.hasOwnProperty(key)) { + if (objOwns(data.internalData.parameters, key)) { parameters[key] = data.internalData.parameters[key]; } } @@ -356,7 +356,7 @@ define( * @param {object} event event object */ _unmarkAll: function(event) { - var type = elAttr(event.currentTarget, 'data-type'); + var type = elData(event.currentTarget, 'type'); Ajax.api(this, { actionName: 'unmarkAll', @@ -387,7 +387,7 @@ define( _ajaxSuccess: function(data) { if (data.actionName === 'unmarkAll') { _containers.forEach((function(containerData) { - if (elAttr(containerData.element, 'data-type') === data.returnValues.objectType) { + if (elData(containerData.element, 'type') === data.returnValues.objectType) { var clipboardObjects = elByClass('jsMarked', containerData.element); while (clipboardObjects.length) { clipboardObjects[0].classList.remove('jsMarked'); @@ -409,7 +409,7 @@ define( // rebuild markings _containers.forEach((function(containerData) { - var typeName = elAttr(containerData.element, 'data-type'); + var typeName = elData(containerData.element, 'type'); var objectIds = (data.returnValues.markedItems && objOwns(data.returnValues.markedItems, typeName)) ? data.returnValues.markedItems[typeName] : []; this._rebuildMarkings(containerData, objectIds); @@ -418,7 +418,7 @@ define( var keepEditors = [], typeName; if (data.returnValues && data.returnValues.items) { for (typeName in data.returnValues.items) { - if (data.returnValues.items.hasOwnProperty(typeName)) { + if (objOwns(data.returnValues.items, typeName)) { keepEditors.push(typeName); } } @@ -442,7 +442,7 @@ define( var created, dropdown, editor, typeData; var divider, item, itemData, itemIndex, label, unmarkAll; for (typeName in data.returnValues.items) { - if (!data.returnValues.items.hasOwnProperty(typeName)) { + if (!objOwns(data.returnValues.items, typeName)) { continue; } @@ -471,7 +471,7 @@ define( // create editor items for (itemIndex in typeData.items) { - if (!typeData.items.hasOwnProperty(itemIndex)) continue; + if (!objOwns(typeData.items, itemIndex)) continue; itemData = typeData.items[itemIndex]; @@ -525,7 +525,7 @@ define( var checkbox = data.checkboxes[i]; var clipboardObject = DomTraverse.parentByClass(checkbox, 'jsClipboardObject'); - var isMarked = (objectIds.indexOf(~~checkbox.getAttribute('data-object-id')) !== -1); + var isMarked = (objectIds.indexOf(~~elData(checkbox, 'object-id')) !== -1); if (!isMarked) markAll = false; checkbox.checked = isMarked; 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 8a08603be7..f238e72908 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js @@ -43,7 +43,7 @@ define(['Ajax'], function(Ajax) { var parent = button.parentNode; parent.addEventListener('transitionend', function() { - parent.parentNode.removeChild(parent); + elRemove(parent); }); parent.classList.remove('active'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js index 6839801b38..18a12101c5 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js @@ -311,7 +311,7 @@ define(['Ajax', 'Dictionary', 'Environment', 'Dom/ChangeListener', 'Dom/Util', ' _activeId = _hoverId; var elData = _elements.get(_activeId); - var data = _cache.get(elAttr(elData.element, 'data-cache-id')); + var data = _cache.get(elData(elData.element, 'cache-id')); if (data.state === STATE_READY) { _popoverContent.appendChild(data.content); @@ -342,7 +342,7 @@ define(['Ajax', 'Dictionary', 'Environment', 'Dom/ChangeListener', 'Dom/Util', ' */ _clearContent: function() { if (_activeId && _popoverContent.childElementCount && !_popover.classList.contains('active')) { - var activeElData = _cache.get(_elements.get(_activeId).element.getAttribute('data-cache-id')); + var activeElData = _cache.get(_elements.get(_activeId).elData(element, 'cache-id')); while (_popoverContent.childNodes.length) { activeElData.content.appendChild(_popoverContent.childNodes[0]); } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js index 8da9ead3b5..ff82cd4e0c 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js @@ -82,7 +82,7 @@ define(['Ajax', 'Language', 'Ui/Dialog'], function(Ajax, Language, UiDialog) { data: { actionName: 'changeStyle', className: 'wcf\\data\\style\\StyleAction', - objectIDs: [ elAttr(event.currentTarget, 'data-style-id') ] + objectIDs: [ elData(event.currentTarget, 'style-id') ] }, success: function() { window.location.reload(); } }); 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 9d39431d31..f45fff7eeb 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 @@ -45,7 +45,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function * @param {Element} mailSetting mail settings element */ _initGroup: function(group, mailSetting) { - var groupId = ~~group.getAttribute('data-object-id'); + var groupId = ~~elData(group, 'object-id'); var disabledNotification = elById('settings_' + groupId + '_disabled'); disabledNotification.addEventListener('click', function() { mailSetting.classList.remove('active'); }); @@ -75,7 +75,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function event.preventDefault(); var button = event.currentTarget; - var objectId = ~~button.getAttribute('data-object-id'); + var objectId = ~~elData(button, 'object-id'); var data = _data.get(objectId); if (data.dropdownMenu === null) { data.dropdownMenu = this._createDropdown(objectId, data.mailValue.value); @@ -88,7 +88,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function else { var items = DomTraverse.childrenByTag(data.dropdownMenu, 'LI'), value = data.mailValue.value; for (var i = 0; i < 4; i++) { - items[i].classList[(items[i].getAttribute('data-value') === value) ? 'add' : 'remove']('active'); + items[i].classList[(elData(items[i], 'value') === value) ? 'add' : 'remove']('active'); } } }, @@ -137,8 +137,8 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Ui/SimpleDropdown'], function * @param {Object} event event object */ _selectType: function(event) { - var value = elAttr(event.currentTarget, 'data-value'); - var groupId = ~~event.currentTarget.parentNode.getAttribute('data-object-id'); + var value = elData(event.currentTarget, 'value'); + var groupId = ~~elData(event.currentTarget.parentNode, 'object-id'); var data = _data.get(groupId); data.mailValue.value = value; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Core.js b/wcfsetup/install/files/js/WoltLab/WCF/Core.js index 9ecf991c3b..294bcfa535 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Core.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Core.js @@ -28,7 +28,7 @@ define([], function() { var newObj = {}; for (var key in obj) { - if (obj.hasOwnProperty(key) && typeof obj[key] !== 'undefined') { + if (objOwns(obj, key) && typeof obj[key] !== 'undefined') { newObj[key] = _clone(obj[key]); } } @@ -93,7 +93,7 @@ define([], function() { if (!obj) continue; for (var key in obj) { - if (obj.hasOwnProperty(key)) { + if (objOwns(obj, key)) { if (!Array.isArray(obj[key]) && typeof obj[key] === 'object') { if (this.isPlainObject(obj[key])) { // object literals have the prototype of Object which in return has no parent prototype @@ -192,7 +192,7 @@ define([], function() { var parameters = []; for (var key in obj) { - if (obj.hasOwnProperty(key)) { + if (objOwns(obj, key)) { var parameterKey = (prefix) ? prefix + '[' + key + ']' : key; var value = obj[key]; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js b/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js index 2760a61327..27e93c0275 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js @@ -208,7 +208,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment } _input = input; - var data = _data.get(_input), date, value = elAttr(_input, 'data-value'); + var data = _data.get(_input), date, value = elData(_input, 'value'); if (value) { date = new Date(+value); @@ -221,12 +221,12 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment } // set min/max date - _minDate = elAttr(_input, 'data-min-date'); - if (_minDate.match(/^datePicker-(.+)$/)) _minDate = elById(RegExp.$1).getAttribute('data-value'); + _minDate = elData(_input, 'min-date'); + if (_minDate.match(/^datePicker-(.+)$/)) _minDate = elData(elById(RegExp.$1), 'value'); _minDate = new Date(+_minDate); - _maxDate = elAttr(_input, 'data-max-date'); - if (_maxDate.match(/^datePicker-(.+)$/)) _maxDate = elById(RegExp.$1).getAttribute('data-value'); + _maxDate = elData(_input, 'max-date'); + if (_maxDate.match(/^datePicker-(.+)$/)) _maxDate = elData(elById(RegExp.$1), 'value'); _maxDate = new Date(+_maxDate); if (data.isDateTime) { @@ -290,7 +290,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment _renderGrid: function(day, month, year) { var cell, hasDay = (day !== undefined), hasMonth = (month !== undefined); - day = ~~day || ~~_dateGrid.getAttribute('data-day'); + day = ~~day || ~~elData(_dateGrid, 'day'); month = ~~month; year = ~~year; @@ -302,8 +302,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment var fragment = document.createDocumentFragment(); fragment.appendChild(_dateGrid); - if (!hasMonth) month = ~~_dateGrid.getAttribute('data-month'); - year = year || ~~_dateGrid.getAttribute('data-year'); + if (!hasMonth) month = ~~elData(_dateGrid, 'month'); + year = year || ~~elData(_dateGrid, 'year'); // check if current selection exceeds min/max date var date = new Date(year + '-' + ('0' + (month + 1).toString()).slice(-2) + '-' + ('0' + day.toString()).slice(-2)); @@ -350,8 +350,8 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment date.setDate(date.getDate() + 1); } - elAttr(_dateGrid, 'data-month', month); - elAttr(_dateGrid, 'data-year', year); + elData(_dateGrid, 'month', month); + elData(_dateGrid, 'year', year); _datePicker.insertBefore(fragment, _dateTime); @@ -394,7 +394,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment cell.classList[(!cell.classList.contains('otherMonth') && ~~cell.textContent === day) ? 'add' : 'remove']('active'); } - elAttr(_dateGrid, 'data-day', day); + elData(_dateGrid, 'day', day); } this._formatValue(); @@ -406,15 +406,15 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment _formatValue: function() { var data = _data.get(_input), date, value, shadowValue; - if (elAttr(_input, 'data-empty') === 'true') { + if (elData(_input, 'empty') === 'true') { return; } if (data.isDateTime) { date = new Date( - elAttr(_dateGrid, 'data-year'), - elAttr(_dateGrid, 'data-month'), - elAttr(_dateGrid, 'data-day'), + elData(_dateGrid, 'year'), + elData(_dateGrid, 'month'), + elData(_dateGrid, 'day'), _dateHour.value, _dateMinute.value ); @@ -424,9 +424,9 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment } else { date = new Date( - elAttr(_dateGrid, 'data-year'), - elAttr(_dateGrid, 'data-month'), - elAttr(_dateGrid, 'data-day') + elData(_dateGrid, 'year'), + elData(_dateGrid, 'month'), + elData(_dateGrid, 'day') ); value = DateUtil.formatDate(date); @@ -434,7 +434,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment } _input.value = value; - elAttr(_input, 'data-value', date.getTime()); + elData(_input, 'value', date.getTime()); data.shadow.value = shadowValue; }, @@ -620,7 +620,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment return; } - elAttr(_input, 'data-empty', false); + elData(_input, 'empty', false); this._renderGrid(event.currentTarget.textContent); @@ -637,7 +637,7 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment element = this._getElement(element); if (element.hasAttribute('data-value')) { - return new Date(+element.getAttribute('data-value')); + return new Date(+elData(element, 'value')); } return null; @@ -686,14 +686,14 @@ define(['DateUtil', 'Language', 'ObjectMap', 'Dom/ChangeListener', 'Ui/Alignment var container = element.parentNode; container.parentNode.insertBefore(element, container); - container.parentNode.removeChild(container); + elRemove(container); elAttr(element, 'type', 'date' + (data.isDateTime ? 'time' : '')); element.value = data.shadow.value; element.removeAttribute('data-value'); element.removeEventListener('click', _callbackOpen); - data.shadow.parentNode.removeChild(data.shadow); + elRemove(data); element.classList.remove('inputDatePicker'); element.readOnly = false; 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 eb64c2b952..08cf3a79bd 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js @@ -37,12 +37,12 @@ define(['Dom/ChangeListener', 'Language', 'WoltLab/WCF/Date/Util', 'WoltLab/WCF/ if (!element.classList.contains('datetime') || elData(element, 'is-future-date')) continue; - var elTimestamp = ~~element.getAttribute('data-timestamp') + _offset; + var elTimestamp = ~~elData(element, 'timestamp') + _offset; var elDate = elData(element, 'date'); var elTime = elData(element, 'time'); var elOffset = elData(element, 'offset'); - if (!element.getAttribute('title')) { + if (!elAttr(element, 'title')) { elAttr(element, 'title', Language.get('wcf.date.dateTimeFormat').replace(/%date%/, elDate).replace(/%time%/, elTime)); } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js b/wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js index e9b5d9c7b8..98f805d6c7 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js @@ -60,7 +60,7 @@ define(['Core'], function(Core) { if (_hasMap) return this._dictionary.has(key); else { - return (this._dictionary.hasOwnProperty(key) && typeof this._dictionary[key] !== "undefined"); + return (objOwns(this._dictionary, key) && typeof this._dictionary[key] !== "undefined"); } }, @@ -150,7 +150,7 @@ define(['Core'], function(Core) { var result = new Dictionary(); for (var key in object) { - if (object.hasOwnProperty(key)) { + if (objOwns(object, key)) { result.set(key, object[key]); } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js b/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js index 5186e87057..a230a6c289 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js @@ -198,7 +198,7 @@ define(['StringUtil'], function(StringUtil) { setStyles: function(el, styles) { var important = false; for (var property in styles) { - if (styles.hasOwnProperty(property)) { + if (objOwns(styles, property)) { if (/ !important$/.test(styles[property])) { important = true; @@ -254,7 +254,7 @@ define(['StringUtil'], function(StringUtil) { } element.appendChild(newScript); - script.parentNode.removeChild(script); + elRemove(script); } }, diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Language/Chooser.js b/wcfsetup/install/files/js/WoltLab/WCF/Language/Chooser.js index c4bb3d71b8..2a6a7b440e 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Language/Chooser.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Language/Chooser.js @@ -98,7 +98,7 @@ define(['Dictionary', 'Language', 'Dom/Traverse', 'Dom/Util', 'ObjectMap', 'Ui/S // add language dropdown items var a, div, h3, img, listItem; for (var availableLanguageId in languages) { - if (languages.hasOwnProperty(availableLanguageId)) { + if (objOwns(languages, availableLanguageId)) { var language = languages[availableLanguageId]; listItem = elCreate('li'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js b/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js index 6c01ad896e..cfa5526ab0 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js @@ -44,7 +44,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver // unescape values var unescapedValues = new Dictionary(); for (var key in values) { - if (values.hasOwnProperty(key)) { + if (objOwns(values, key)) { unescapedValues.set(~~key, StringUtil.unescapeHTML(values[key])); } } @@ -100,7 +100,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver DomUtil.insertAfter(dropdownMenu, button); var callbackClick = (function(event, isInit) { - var languageId = ~~event.currentTarget.getAttribute('data-language-id'); + var languageId = ~~elData(event.currentTarget, 'language-id'); var activeItem = DomTraverse.childByClass(dropdownMenu, 'active'); if (activeItem !== null) activeItem.classList.remove('active'); @@ -112,7 +112,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver // build language dropdown for (var languageId in availableLanguages) { - if (availableLanguages.hasOwnProperty(languageId)) { + if (objOwns(availableLanguages, languageId)) { var listItem = elCreate('li'); elData(listItem, 'language-id', languageId); @@ -142,7 +142,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver var activeItem = null; if (forceSelection === true || values.size) { for (var i = 0, length = dropdownMenu.childElementCount; i < length; i++) { - if (~~dropdownMenu.children[i].getAttribute('data-language-id') === LANGUAGE_ID) { + if (~~dropdownMenu.elData(children[i], 'language-id') === LANGUAGE_ID) { activeItem = dropdownMenu.children[i]; break; } @@ -238,13 +238,13 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver } var dropdownMenu = UiSimpleDropdown.getDropdownMenu(containerId); - var elementId = elById(containerId).getAttribute('data-input-id'); + var elementId = elData(elById(containerId), 'input-id'); var values = _values.get(elementId); var item, languageId; for (var i = 0, length = dropdownMenu.childElementCount; i < length; i++) { item = dropdownMenu.children[i]; - languageId = ~~item.getAttribute('data-language-id'); + languageId = ~~elData(item, 'language-id'); if (languageId) { item.classList[(values.has(languageId) || !values.size ? 'remove' : 'add')]('missingValue'); @@ -354,7 +354,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver element.isEnabled = false; // hide language dropdown - element.buttonLabel.parentNode.style.setProperty('display', 'none'); + elHide(element.buttonLabel.parentNode); var dropdownContainer = element.buttonLabel.parentNode.parentNode; dropdownContainer.classList.remove('inputAddon'); dropdownContainer.classList.remove('dropdown'); @@ -376,7 +376,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver element.isEnabled = true; // show language dropdown - element.buttonLabel.parentNode.style.removeProperty('display'); + elShow(element.buttonLabel.parentNode); var dropdownContainer = element.buttonLabel.parentNode.parentNode; dropdownContainer.classList.add('inputAddon'); dropdownContainer.classList.add('dropdown'); @@ -426,7 +426,7 @@ define(['Core', 'Dictionary', 'Language', 'ObjectMap', 'StringUtil', 'Dom/Traver var hasEmptyValue = false, hasNonEmptyValue = false; for (var i = 0, length = dropdownMenu.childElementCount; i < length; i++) { item = dropdownMenu.children[i]; - languageId = ~~item.getAttribute('data-language-id'); + languageId = ~~elData(item, 'language-id'); if (languageId) { if (!values.has(languageId) || values.get(languageId).length === 0) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js b/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js index c979895b35..b4988e69fb 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js @@ -176,7 +176,7 @@ define( // store media data locally var media = data.returnValues.media || { }; for (var mediaId in media) { - if (media.hasOwnProperty(mediaId)) { + if (objOwns(media, mediaId)) { this._mediaData.set(~~mediaId, media[mediaId]); } } @@ -345,7 +345,7 @@ define( var hasMedia = false; for (var mediaId in media) { - if (media.hasOwnProperty(mediaId)) { + if (objOwns(media, mediaId)) { hasMedia = true; } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Permission.js b/wcfsetup/install/files/js/WoltLab/WCF/Permission.js index 7ac22271f3..a4834a82ec 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Permission.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Permission.js @@ -36,7 +36,7 @@ define(['Dictionary'], function(Dictionary) { */ addObject: function(object) { for (var key in object) { - if (object.hasOwnProperty(key)) { + if (objOwns(object, key)) { this.addPermission(key, object[key]); } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js index 12ef5d1435..344d3199e4 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js @@ -159,12 +159,12 @@ define(['Core', 'Language', 'Dom/Traverse', 'Dom/Util'], function(Core, Language top: top + (top !== 'auto' ? 'px' : '') }); - el.style.removeProperty('display'); + elShow(el); el.style.removeProperty('visibility'); }, /** - * Calculates left/right position and verifys if the element would be still within the page's boundaries. + * Calculates left/right position and verifies if the element would be still within the page's boundaries. * * @param {string} align align to this side of the reference element * @param {Object} elDimensions element dimensions diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js index 012413d6f2..f5a652cf19 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js @@ -79,7 +79,7 @@ define( if (id && (container = elById(id))) { ((function(button, container) { container.classList.remove('jsStaticDialogContent'); - container.style.setProperty('display', 'none'); + elHide(container); button.addEventListener('click', this.openStatic.bind(this, container.id, null, { title: elData(container, 'title') })); }).bind(this))(button, container); } @@ -314,7 +314,7 @@ define( contentContainer.appendChild(content); if (content.style.getPropertyValue('display') === 'none') { - content.style.removeProperty('display'); + elShow(content); } _dialogs.set(id, { @@ -363,7 +363,7 @@ define( newScript.innerHTML = script.innerHTML; content.appendChild(newScript); - script.parentNode.removeChild(script); + elRemove(script); } data.content.appendChild(content); @@ -376,7 +376,7 @@ define( elAttr(data.dialog, 'aria-hidden', 'false'); elAttr(_container, 'aria-hidden', 'false'); - elAttr(_container, 'data-close-on-click', (data.backdropCloseOnClick ? 'true' : 'false')); + elData(_container, 'close-on-click', (data.backdropCloseOnClick ? 'true' : 'false')); _activeDialog = id; this.rebuild(id); @@ -465,7 +465,7 @@ define( return true; } - if (elAttr(_container, 'data-close-on-click') === 'true') { + if (elData(_container, 'close-on-click') === 'true') { this._close(event); } else { @@ -509,13 +509,13 @@ define( if (_activeDialog === null) { elAttr(_container, 'aria-hidden', 'true'); - elAttr(_container, 'data-close-on-click', 'false'); + elData(_container, 'close-on-click', 'false'); window.removeEventListener('keyup', _keyupListener); } else { data = _dialogs.get(_activeDialog); - elAttr(_container, 'data-close-on-click', (data.backdropCloseOnClick ? 'true' : 'false')); + elData(_container, 'close-on-click', (data.backdropCloseOnClick ? 'true' : 'false')); } }, diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/FlexibleMenu.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/FlexibleMenu.js index 726c790ca4..617b163202 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/FlexibleMenu.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/FlexibleMenu.js @@ -110,7 +110,7 @@ define(['Core', 'Dictionary', 'Dom/ChangeListener', 'Dom/Traverse', 'Dom/Util', continue; } - item.style.removeProperty('display'); + elShow(item); } if (dropdown.parentNode !== null) { @@ -131,7 +131,7 @@ define(['Core', 'Dictionary', 'Dom/ChangeListener', 'Dom/Traverse', 'Dom/Util', } hiddenItems.push(item); - item.style.setProperty('display', 'none'); + elHide(item); if (list.scrollWidth < availableWidth) { break; @@ -176,7 +176,7 @@ define(['Core', 'Dictionary', 'Dom/ChangeListener', 'Dom/Traverse', 'Dom/Util', item.addEventListener('click', (function(event) { event.preventDefault(); - Core.triggerEvent(hiddenItem.querySelector('a'), 'click'); + Core.triggerEvent(elBySel('a', hiddenItem), 'click'); // force a rebuild to guarantee the active item being visible setTimeout(function() { @@ -191,7 +191,7 @@ define(['Core', 'Dictionary', 'Dom/ChangeListener', 'Dom/Traverse', 'Dom/Util', dropdownMenu.appendChild(fragment); } else if (dropdown !== undefined && dropdown.parentNode !== null) { - dropdown.parentNode.removeChild(dropdown); + elRemove(dropdown); } } }; diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js index 0ad283ba10..8acd1af504 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js @@ -222,7 +222,7 @@ define(['Core', 'Dictionary', 'Language', 'Dom/Traverse', 'WoltLab/WCF/Ui/Sugges element.parentNode.insertBefore(inputElement, element); inputElement.id = element.id; - element.parentNode.removeChild(element); + elRemove(element); element = inputElement; } } 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 029d26fd82..fa5736a094 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js @@ -205,7 +205,7 @@ define( button.title = title; button.innerHTML = ' '; button.addEventListener('click', this._like.bind(this, element)); - button.setAttribute('data-type', (isLike ? 'like' : 'dislike')); + elData(button, 'type', (isLike ? 'like' : 'dislike')); listItem.appendChild(button); @@ -345,7 +345,7 @@ define( _isBusy = true; Ajax.api(this, { - actionName: elAttr(event.currentTarget, 'data-type'), + actionName: elData(event.currentTarget, 'type'), parameters: { data: { containerID: DomUtil.identify(element), diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js index 26fdb158ad..a738227dd0 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js @@ -244,7 +244,7 @@ define( } } else { - if (visibility.hasOwnProperty(item) && visibility[item] === false) { + if (objOwns(visibility, item) && visibility[item] === false) { elHide(listItem); } else { @@ -328,7 +328,7 @@ define( this._activeElement.classList.add('jsInvalidQuoteTarget'); var icon = DomTraverse.childByClass(elementData.messageBodyEditor, 'icon'); - icon.parentNode.removeChild(icon); + elRemove(icon); var messageBody = elementData.messageBodyEditor; var editor = elCreate('div'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Manager.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Manager.js index 1799e39cb1..9550d53cd6 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Manager.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Manager.js @@ -116,7 +116,7 @@ define(['Ajax', 'Core', 'Dictionary'], function(Ajax, Core, Dictionary) { } for (var key in data) { - if (data.hasOwnProperty(key)) { + if (objOwns(data, key)) { this._update(element, key, data[key]); } } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Mobile.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Mobile.js index 1c63da83ff..cac27c3cbf 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Mobile.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Mobile.js @@ -97,7 +97,7 @@ define( return; } - // use icons if language item is empty/non-existant + // use icons if language item is empty/non-existent var languageShowSidebar = 'wcf.global.sidebar.show' + sidebarPosition + 'Sidebar'; if (languageShowSidebar === Language.get(languageShowSidebar) || Language.get(languageShowSidebar) === '') { languageShowSidebar = elCreate('span'); diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Pagination.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Pagination.js index 11550e96c9..f060b302fb 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Pagination.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Pagination.js @@ -174,7 +174,7 @@ define(['Core', 'Language', 'ObjectMap', 'StringUtil', 'WoltLab/WCF/Ui/Page/Jump } if (hasHiddenPages) { - list.setAttribute('data-pages', this._options.maxPage); + elData(list, 'pages', this._options.maxPage); UiPageJumpTo.init(list, this.switchPage.bind(this)); } diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js index 65094dee94..17ba838124 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js @@ -154,7 +154,7 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd item = item.currentTarget.parentNode; } - this._options.callbackSelect(this._element.id, { objectId: item.children[0].getAttribute('data-object-id'), value: item.textContent }); + this._options.callbackSelect(this._element.id, { objectId: elData(item.children[0], 'object-id'), value: item.textContent }); if (isEvent) { this._element.focus(); @@ -162,7 +162,7 @@ define(['Ajax', 'Core', 'Ui/SimpleDropdown'], function(Ajax, Core, UiSimpleDropd }, /** - * Performs a search for the input value unless it is below the treshold. + * Performs a search for the input value unless it is below the threshold. * * @param {object} event event object */ 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 6bb237ce4a..f06cb884d2 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js @@ -100,7 +100,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict } if (this._isLegacy) { - elAttr(this._container, 'data-is-legacy', true); + elData(this._container, 'is-legacy', true); this._tabs.forEach(function(tab, name) { elAttr(tab, 'aria-controls', name); @@ -142,7 +142,7 @@ define(['Dictionary', 'Dom/Traverse', 'Dom/Util', 'EventHandler'], function(Dict } if (!selectTab) { - var preselect = elAttr(this._container, 'data-preselect'); + var preselect = elData(this._container, 'preselect'); if (preselect === "true" || !preselect) preselect = true; if (preselect === true) { diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Upload.js b/wcfsetup/install/files/js/WoltLab/WCF/Upload.js index 6322421c47..2ae6fe9feb 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Upload.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Upload.js @@ -190,7 +190,7 @@ define(['AjaxRequest', 'Core', 'Dom/ChangeListener', 'Language', 'Dom/Util', 'Do * Removes the button to upload files. */ _removeButton: function() { - this._button.parentNode.removeChild(this._button); + elRemove(this._button); DomChangeListener.trigger(); }, @@ -291,7 +291,7 @@ define(['AjaxRequest', 'Core', 'Dom/ChangeListener', 'Language', 'Dom/Util', 'Do var formData = new FormData(); for (var i = 0, length = files.length; i < length; i++) { if (this._fileElements[uploadId][i]) { - var internalFileId = elAttr(this._fileElements[uploadId][i], 'data-internal-file-id'); + var internalFileId = elData(this._fileElements[uploadId][i], 'internal-file-id'); if (blob) { formData.append('__files[' + internalFileId + ']', blob, files[i].name);