Consistently using shorthand functions for DOM operations
authorFabii <fabiangossner@gmail.com>
Sat, 30 Jan 2016 13:03:44 +0000 (14:03 +0100)
committerFabii <fabiangossner@gmail.com>
Thu, 3 Mar 2016 18:45:41 +0000 (19:45 +0100)
32 files changed:
wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Editor.js
wcfsetup/install/files/js/WoltLab/WCF/Acp/Ui/Style/Image/Upload.js
wcfsetup/install/files/js/WoltLab/WCF/Ajax/Request.js
wcfsetup/install/files/js/WoltLab/WCF/Attachment/Upload.js
wcfsetup/install/files/js/WoltLab/WCF/Bbcode/FromHtml.js
wcfsetup/install/files/js/WoltLab/WCF/Bbcode/ToHtml.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Clipboard.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Notice/Dismiss.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Popover.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/Style/Changer.js
wcfsetup/install/files/js/WoltLab/WCF/Controller/User/Notification/Settings.js
wcfsetup/install/files/js/WoltLab/WCF/Core.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Picker.js
wcfsetup/install/files/js/WoltLab/WCF/Date/Time/Relative.js
wcfsetup/install/files/js/WoltLab/WCF/Dictionary.js
wcfsetup/install/files/js/WoltLab/WCF/Dom/Util.js
wcfsetup/install/files/js/WoltLab/WCF/Language/Chooser.js
wcfsetup/install/files/js/WoltLab/WCF/Language/Input.js
wcfsetup/install/files/js/WoltLab/WCF/Media/Manager/Base.js
wcfsetup/install/files/js/WoltLab/WCF/Permission.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Alignment.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Dialog.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/FlexibleMenu.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/ItemList.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Like/Handler.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/InlineEditor.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Manager.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Mobile.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Pagination.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/Suggestion.js
wcfsetup/install/files/js/WoltLab/WCF/Ui/TabMenu/Simple.js
wcfsetup/install/files/js/WoltLab/WCF/Upload.js

index c12349efdecb09b880df9d77b9fcfdb9d0209e9f..08b42edda5693cc5b94bc450e9c903cdedc9c245 100644 (file)
@@ -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);
index 71a85e917d8bac78789070450d965f4d7375759e..cefd66435fede81379ffd03fcb81b7b10489dbf7 100644 (file)
@@ -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();
index aa8efafe037dea48faf18a59d1a9946a468b5806..627cac6d5365b1c184716549ffd02b281a80a64e 100644 (file)
@@ -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];
                        }
                        
index a9c68f9225b8d1c3e2c8d9f2bc3ce9e0bf972fdd..ffba3f7011d4d7c84884123ee845c7eb28e3bcda 100644 (file)
@@ -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;
index bc162b4eaef42b1a9b2ae5e86a6d8f8eac0c3886..21f866ca4bb41063425caa7660db9f3fb7342406 100644 (file)
@@ -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++) {
index caafe12256e3aa268320b44599e614750f929202..0327a857902e324b5083746caf5c31b25192b754 100644 (file)
@@ -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, '&lt;').replace(/>/g, '&gt;');
                                                        regexp = new RegExp('(\\s|^)' + StringUtil.escapeRegExp(smileyCode) + '(?=\\s|$)', 'gi');
                                                        item = item.replace(regexp, '$1<img src="' + __REDACTOR_SMILIES[smileyCode] + '" class="smiley" alt="' + altValue + '">');
index 4f45012af0b6f4200a67f8ef85a6895928952d7b..e46aa409cd657f7ca15665246f5a24fd4f696a1d 100644 (file)
@@ -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;
index 8a08603be75a54cb8ecacef23ebcf08887eca2e5..f238e72908f73c79411a0a98f54b67b81099b0da 100644 (file)
@@ -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');
index 6839801b380e37bd6492ccaac7a77007c155f399..18a12101c5bc757961baaec9eec43ff4efb23783 100644 (file)
@@ -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]);
                                }
index 8da9ead3b5cd1994798d5f9115a3c4d3d6c955dd..ff82cd4e0c72f8fadffcc47d88e434ee0c4ac9f0 100644 (file)
@@ -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(); }
                        });
index 9d39431d3158871d93701417636040a5d16f2400..f45fff7eebbec1b43c82e72513f8a7da7e484b97 100644 (file)
@@ -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;
index 9ecf991c3b95f6d6d5ae6d59feaf502290956130..294bcfa5352e56d8063bc77624550991567c9354 100644 (file)
@@ -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];
                                        
index 2760a6132738f17ff5bb7ff1bac3c914892e76b3..27e93c02750fe8e70776b5052a20c74ecd0cc12a 100644 (file)
@@ -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;
index eb64c2b952c738960760895d8b6d2bb4573c691a..08cf3a79bd395e178ab01338256b62675fe2b77d 100644 (file)
@@ -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));
                                }
                                
index e9b5d9c7b85ad5469177ac3e38833c4a64333f41..98f805d6c7989a694fe18433233c41e9927a2bbe 100644 (file)
@@ -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]);
                        }
                }
index 5186e870570b873f0149df1ccfd01045150a6421..a230a6c289d4afd501afa4e30069fdb5a967fb3b 100644 (file)
@@ -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);
                        }
                },
                
index c4bb3d71b8a7f8f9804b118d19ee652e39af20f2..2a6a7b440ec0f4e5c34abd73aca69f7af7f1cdae 100644 (file)
@@ -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');
index 6c01ad896e7c173d4e4db0a3ac1a2065031298bb..cfa5526ab009147fc33a005aad6e60c70cd0aed5 100644 (file)
@@ -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) {
index c979895b35ef666eca5673e5aad69982f4d9029a..b4988e69fb1124f94033b50f9784fc84cbbcc81f 100644 (file)
@@ -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;
                                }
                        }
index 7ac22271f33c449dd2bd4fa2859e19423a18b0ba..a4834a82ec91880bc61680982046a5145c86e14a 100644 (file)
@@ -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]);
                                }
                        }
index 12ef5d1435b988abee219dacebc066075fc6dc94..344d3199e4fda1c2029c38ff49799f3cbde27efa 100644 (file)
@@ -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<string, int>}   elDimensions    element dimensions
index 012413d6f2e5adcbf256261dd641c4a3944ec9d1..f5a652cf19953219a4f9d5fe76e73b684056c00b 100644 (file)
@@ -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'));
                        }
                },
                
index 726c790ca4c73fdc9f76b5215f5d030900dcb1f4..617b163202b286d4824fe48097164e3960e27c30 100644 (file)
@@ -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);
                        }
                }
        };
index 0ad283ba101b25024ee6ae7a660758b6768d574f..8acd1af504c28e6f3992d63158b5d473d5d80f33 100644 (file)
@@ -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;
                                }
                        }
index 029d26fd82d5ba38ef18f33831d51b9f0bd8cd92..fa5736a094b85147ed18b79a4bde014f3f87ae82 100644 (file)
@@ -205,7 +205,7 @@ define(
                        button.title = title;
                        button.innerHTML = '<span class="icon icon16 fa-thumbs-o-' + (isLike ? 'up' : 'down') + '" /> <span class="invisible">' + title + '</span>';
                        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),
index 26fdb158ad7a260059a4fd495bcbf38d2a8e2245..a738227dd099102f78c1287c1ad3a3708ef26a60 100644 (file)
@@ -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');
index 1799e39cb1dd0443d4d5689e27e48aa055d05afe..9550d53cd66c8234948edbb4002f8306a528763d 100644 (file)
@@ -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]);
                                        }
                                }
index 1c63da83ff852e4ef4b7a5aff3a2cbe5b76b488a..cac27c3cbf59815031c1d471391cc2486b8acdb3 100644 (file)
@@ -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');
index 11550e96c9e4775a7002bf245ff8a75c64db7729..f060b302fbc6cf720043db76545238eda06f9d02 100644 (file)
@@ -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));
                        }
index 65094dee94d96d7815d9208e2570b7e5947d5f47..17ba838124d8e09a891c09ddb25c560eb6baa38a 100644 (file)
@@ -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
                 */
index 6bb237ce4a533c2406dfcd04413a3ff618328a36..f06cb884d2d308ff15a47687ec95cf3570257472 100644 (file)
@@ -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) {
index 6322421c47b891848b6b169876656c46a9a92c81..2ae6fe9feb0f6ea9a2608c67353d44e2809e00d9 100644 (file)
@@ -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);