_createFileElement: function(file) {
var listItem = elCreate('li');
listItem.className = 'box64';
- elAttr(listItem, 'data-filename', filename);
+ elData(listItem, 'filename', filename);
this._target.appendChild(listItem);
this._target.style.removeProperty('display');
var progress = elByTag(listItem, 'PROGRESS');
progress.parentNode.removeChild(progress);
- var filename = elAttr(listItem, 'data-filename');
- var internalFileId = elAttr(listItem, 'data-internal-file-id');
+ var filename = elData(listItem, 'filename');
+ var internalFileId = elData(listItem, 'internal-file-id');
var icon = DomTraverse.childByClass(listItem, 'fa-spinner');
elAttr(img, 'src', attachment.tinyURL);
elAttr(img, 'alt', '');
icon.parentNode.replaceChild(icon, img);
-
- elAttr(listItem, 'data-height', attachment.height);
- elAttr(listItem, 'data-width', attachment.width);
+
+ elData(listItem, 'height', attachment.height);
+ elData(listItem, 'width', attachment.width);
}
else {
// TODO: Use FileUtil.getIconClassByMimeType()?
var span = elCreate('span');
span.className = 'button small jsDeleteButton';
span.textContent = Language.get('wcf.global.button.delete');
- elAttr(span, 'data-object-id', attachment.attachmentID);
- elAttr(span, 'data-confirm-message', Language.get('wcf.attachment.delete.sure'));
+ elData(span, 'object-id', attachment.attachmentID);
+ elData(span, 'confirm-message', Language.get('wcf.attachment.delete.sure'));
if (this._wysiwygContainerId) {
- elAttr(span, 'data-event-name', 'attachment_' + this._wysiwygContainerId);
+ elData(span, 'event-name', 'attachment_' + this._wysiwygContainerId);
}
deleteButton.appendChild(span);
- elAttr(span, 'data-object-id', attachment.attachmentID);
+ elData(span, 'object-id', attachment.attachmentID);
if (this._wysiwygContainerId) {
if (attachment.tinyURL) {
span = elCreate('span');
span.className = 'button small jsButtonAttachmentInsertThumbnail';
span.textContent = Language.get('wcf.global.button.insertThumbnail');
- elAttr(span, 'data-object-id', attachment.attachmentID);
+ elData(span, 'object-id', attachment.attachmentID);
span.addEventListener('click', this._insert.bind(this));
insertThumbnailButton.appendChild(span);
span = elCreate('span');
span.className = 'button small jsButtonAttachmentInsertFull';
span.textContent = Language.get('wcf.global.button.insertFull');
- elAttr(span, 'data-object-id', attachment.attachmentID);
+ elData(span, 'object-id', attachment.attachmentID);
span.addEventListener('click', this._insert.bind(this));
insertOriginalButton.appendChild(span);
}
else {
- var insertPlainButton elCreate('li');
+ var insertPlainButton = elCreate('li');
ul.appendChild(insertPlainButton);
span = elCreate('span');
span.className = 'button small jsButtonAttachmentInsertPlain';
span.textContent = Language.get('wcf.global.button.insert');
- elAttr(span, 'data-object-id', attachment.attachmentID);
+ elData(span, 'object-id', attachment.attachmentID);
span.addEventListener('click', this._insert.bind(this));
insertPlainButton.appendChild(span);
}
var toggle = function() {
var expand = container.classList.contains('collapsed');
container.classList[expand ? 'remove' : 'add']('collapsed');
- toggleButton.textContent = elAttr(toggleButton, 'data-title-' + (expand ? 'collapse' : 'expand'));
+ toggleButton.textContent = elData(toggleButton, 'title-' + (expand ? 'collapse' : 'expand'));
};
toggleButton.addEventListener('click', toggle);
*/
_preserveSourceElement: function(element, sourceElements) {
var placeholder = elCreate('var');
- elAttr(placeholder, 'data-source', 'wcf');
+ elData(placeholder, 'source', 'wcf');
element.parentNode.insertBefore(placeholder, element);
var fragment = document.createDocumentFragment();
* @param {Element} element target element
*/
_convertBlockquote: function(element) {
- var author = elAttr(element, 'data-author');
+ var author = elData(element, 'author');
var link = elAttr(element, 'cite');
var open = '[quote]';
width = (typeof width === 'string') ? ~~width.replace(/px$/, '') : 0;
if (element.classList.contains('redactorEmbeddedAttachment')) {
- var attachmentId = elAttr(element, 'data-attachment-id');
+ var attachmentId = elData(element, 'attachment-id');
if (width > 0) {
element.outerHTML = "[attach=" + attachmentId + "," + float + "," + width + "][/attach]";
* @param {Element} element target element
*/
_convertSourceCodeBox: function(element) {
- var filename = elAttr(element, 'data-filename').trim() || '';
- var highlighter = elAttr(element, 'data-highlighter');
+ var filename = elData(element, 'filename').trim() || '';
+ var highlighter = elData(element, 'highlighter');
window.dtdesign = element;
var list = DomTraverse.childByTag(element.children[0], 'OL');
var lineNumber = ~~list.getAttribute('start') || 1;
if (containerData === undefined) {
var markAll = elBySel('.jsClipboardMarkAll', container);
if (markAll !== null) {
- elAttr(markAll, 'data-container-id', containerId);
+ elData(markAll, 'container-id', containerId);
markAll.addEventListener('click', this._markAll.bind(this));
}
var checkbox = containerData.checkboxes[j];
if (!_knownCheckboxes.has(checkbox)) {
- elAttr(checkbox, 'data-container-id', containerId);
+ elData(checkbox, 'container-id', containerId);
checkbox.addEventListener('click', _callbackCheckbox);
_knownCheckboxes.add(checkbox);
_initEditors: function() {
var getTypes = function(editor) {
try {
- var types = elAttr(editor, 'data-types');
+ var types = elData(editor, 'types');
if (typeof types === 'string') {
return JSON.parse('{ "types": ' + types.replace(/'/g, '"') + '}').types;
}
var isMarked = (checkbox.nodeName !== 'INPUT' || checkbox.checked);
var objectIds = [];
- var containerId = elAttr(checkbox, 'data-container-id');
+ var containerId = elData(checkbox, 'container-id');
var data = _containers.get(containerId);
var type = elAttr(data.element, 'data-type');
var checkbox = event.currentTarget;
var objectId = ~~checkbox.getAttribute('data-object-id');
var isMarked = checkbox.checked;
- var containerId = elAttr(checkbox, 'data-container-id');
+ var containerId = elData(checkbox, 'container-id');
var data = _containers.get(containerId);
var type = elAttr(data.element, 'data-type');
}
var triggerEvent = function() {
- var type = elAttr(listItem, 'data-type');
+ var type = elData(listItem, 'type');
EventHandler.fire('com.woltlab.wcf.clipboard', type, {
data: data,
parameters: parameters
}, (function(responseData) {
if (data.actionName !== 'unmarkAll') {
- var type = elAttr(listItem, 'data-type');
+ var type = elData(listItem, 'type');
EventHandler.fire('com.woltlab.wcf.clipboard', type, {
data: data,
label.textContent = itemData.label;
item.appendChild(label);
itemList.appendChild(item);
-
- elAttr(item, 'data-type', typeName);
+
+ elData(item, 'type', typeName);
item.addEventListener('click', _callbackItem);
_itemData.set(item, itemData);
// add 'unmark all'
var unmarkAll = elCreate('li');
- elAttr(unmarkAll, 'data-type', typeName);
+ elData(unmarkAll, 'type', typeName);
var label = elCreate('span');
label.textContent = Language.get('wcf.clipboard.item.unmarkAll');
unmarkAll.appendChild(label);
data: {
actionName: 'dismiss',
className: 'wcf\\data\\notice\\NoticeAction',
- objectIDs: [ elAttr(button, 'data-object-id') ]
+ objectIDs: [ elData(button, 'object-id') ]
},
success: function() {
var parent = button.parentNode;
}
var cacheId = identifier + "-" + objectId;
- elAttr(element, 'data-cache-id', cacheId);
+ elData(element, 'cache-id', cacheId);
_elements.set(id, {
element: element,
if (_activeId) {
var activeElement = _elements.get(_activeId).element;
- if (elAttr(activeElement, 'data-cache-id') === cacheId) {
+ if (elData(activeElement, 'cache-id') === cacheId) {
this._show();
}
}
var mailValue = DomTraverse.childByTag(mailSetting, 'INPUT');
var button = DomTraverse.childByTag(mailSetting, 'A');
- elAttr(button, 'data-object-id', groupId);
+ elData(button, 'object-id', groupId);
button.addEventListener('click', _callbackClick);
_data.set(groupId, {
_createDropdown: function(objectId, initialValue) {
var dropdownMenu = elCreate('ul');
dropdownMenu.className = 'dropdownMenu';
- elAttr(dropdownMenu, 'data-object-id', objectId);
+ elData(dropdownMenu, 'object-id', objectId);
var link, listItem, value, items = ['instant', 'daily', 'divider', 'none'];
for (var i = 0; i < 4; i++) {
link = elCreate('a');
link.textContent = Language.get('wcf.user.notification.mailNotificationType.' + value);
listItem.appendChild(link);
- elAttr(listItem, 'data-value', value);
+ elData(listItem, 'value', value);
listItem.addEventListener('click', _callbackSelectType);
if (initialValue === value) {
element.readOnly = true;
var isDateTime = (elAttr(element, 'type') === 'datetime');
-
- elAttr(element, 'data-is-date-time', isDateTime);
+
+ elData(element, 'is-date-time', isDateTime);
// convert value
var date = null, value = elAttr(element, 'value');
if (elAttr(element, 'value')) {
date = new Date(value);
- elAttr(element, 'data-value', date.getTime());
+ elData(element, 'value', date.getTime());
value = DateUtil['formatDate' + (isDateTime ? 'Time' : '')](date);
}
// handle birthday input
if (element.classList.contains('birthday')) {
- elAttr(element, 'data-min-date', '100');
- elAttr(element, 'data-max-date', 'now');
+ elData(element, 'min-date', '100');
+ elData(element, 'max-date', 'now');
}
this._initDateRange(element, now, true);
this._initDateRange(element, now, false);
- if (elAttr(element, 'data-min-date') === elAttr(element, 'data-max-date')) {
+ if (elData(element, 'min-date') === elData(element, 'max-date')) {
throw new Error("Minimum and maximum date cannot be the same (element id '" + element.id + "').");
}
// change type to prevent browser's datepicker to trigger
element.type = 'text';
element.value = value;
- elAttr(element, 'data-empty', isEmpty);
+ elData(element, 'empty', isEmpty);
- if (elAttr(element, 'data-placeholder')) {
- elAttr(element, 'placeholder', elAttr(element, 'data-placeholder'));
+ if (elData(element, 'placeholder')) {
+ elAttr(element, 'placeholder', elData(element, 'placeholder'));
}
// add a hidden element to hold the actual date
setDate: function(element, date) {
element = this._getElement(element);
var data = _data.get(element);
-
- elAttr(element, 'data-value', date.getTime());
+
+ elData(element, 'value', date.getTime());
element.value = DateUtil['formatDate' + (data.isDateTime ? 'Time' : '')](date);
data.shadow.value = DateUtil.format(date, (data.isDateTime ? 'c' : 'Y-m-d'));
for (var i = 0, length = _elements.length; i < length; i++) {
var element = _elements[i];
- if (!element.classList.contains('datetime') || elAttr(element, 'data-is-future-date')) continue;
+ if (!element.classList.contains('datetime') || elData(element, 'is-future-date')) continue;
if (!element.getAttribute('title')) elAttr(element, 'title', element.textContent.trim());
var elTimestamp = ~~element.getAttribute('data-timestamp') + _offset;
- var elDate = elAttr(element, 'data-date');
- var elTime = elAttr(element, 'data-time');
- var elOffset = elAttr(element, 'data-offset');
+ var elDate = elData(element, 'date');
+ var elTime = elData(element, 'time');
+ var elOffset = elData(element, 'offset');
// timestamp is less than 60 seconds ago
if (elTimestamp >= timestamp || timestamp < (elTimestamp + 60)) {
if (!container.classList.contains('inputAddon')) {
container = elCreate('div');
container.className = 'inputAddon' + (element.nodeName === 'TEXTAREA' ? ' inputAddonTextarea' : '');
- elAttr(container, 'data-input-id', elementId);
+ elData(container, 'input-id', elementId);
element.parentNode.insertBefore(container, element);
container.appendChild(element);
for (var languageId in availableLanguages) {
if (availableLanguages.hasOwnProperty(languageId)) {
var listItem = elCreate('li');
- elAttr(listItem, 'data-language-id', languageId);
+ elData(listItem, 'language-id', languageId);
span = elCreate('span');
span.textContent = availableLanguages[languageId];
dropdownMenu.appendChild(listItem);
listItem = elCreate('li');
- elAttr(listItem, 'data-language-id', 0);
+ elData(listItem, 'language-id', 0);
span = elCreate('span');
span.textContent = Language.get('wcf.global.button.disabledI18n');
listItem.appendChild(span);
for (var i = 0, length = dropdownMenu.childElementCount; i < length; i++) {
item = dropdownMenu.children[i];
- var itemLanguageId = elAttr(item, 'data-language-id');
+ var itemLanguageId = elData(item, 'language-id');
if (itemLanguageId.length && languageId === ~~itemLanguageId) {
label = item.children[0].textContent;
}
return;
}
- _isOpen = (elAttr(sidebar, 'data-is-open') === 'true');
+ _isOpen = (elData(sidebar, 'is-open') === 'true');
_main = elById('main');
- _name = elAttr(sidebar, 'data-sidebar-name');
+ _name = elData(sidebar, 'sidebar-name');
this._createUI(sidebar);
button = _staticDialogs[0];
button.classList.remove('jsStaticDialog');
- id = elAttr(button, 'data-dialog-id');
+ id = elData(button, 'dialog-id');
if (id && (container = elById(id))) {
((function(button, container) {
container.classList.remove('jsStaticDialogContent');
container.style.setProperty('display', 'none');
- button.addEventListener('click', this.openStatic.bind(this, container.id, null, { title: elAttr(container, 'data-title') }));
+ button.addEventListener('click', this.openStatic.bind(this, container.id, null, { title: elData(container, 'title') }));
}).bind(this))(button, container);
}
}
dialog.classList.add('dialogContainer');
elAttr(dialog, 'aria-hidden', 'true');
elAttr(dialog, 'role', 'dialog');
- elAttr(dialog, 'data-id', id);
+ elData(dialog, 'id', id);
if (options.disposeOnClose) {
- elAttr(dialog, 'data-dispose-on-close', true);
+ elData(dialog, 'dispose-on-close', true);
}
var header = elCreate('header');
for (var i = 0; i < _container.childElementCount; i++) {
var child = _container.children[i];
if (elAttr(child, 'aria-hidden') === 'false') {
- _activeDialog = elAttr(child, 'data-id');
+ _activeDialog = elData(child, 'id');
break;
}
}
for (var i = 0, length = items.length; i < length; i++) {
item = items[i];
value = {
- objectId: elAttr(item, 'data-object-id'),
+ objectId: elData(item, 'object-id'),
value: DomTraverse.childByTag(item, 'SPAN').textContent
};
_createUI: function(element, options) {
var list = elCreate('ol');
list.className = 'inputItemList';
- elAttr(list, 'data-element-id', element.id);
+ elData(list, 'element-id', element.id);
list.addEventListener('click', function(event) {
if (event.target === list) element.focus();
});
var content = elCreate('span');
content.className = 'content';
- elAttr(content, 'data-object-id', value.objectId);
+ elData(content, 'object-id', value.objectId);
content.textContent = value.value;
var button = elCreate('a');
item = (event === null) ? item : event.currentTarget.parentNode;
var parent = item.parentNode;
- var elementId = elAttr(parent, 'data-element-id');
+ var elementId = elData(parent, 'element-id');
var data = _data.get(elementId);
data.suggestion.removeExcludedValue(item.children[0].textContent);
likeButton: null,
summary: null,
- dislikes: ~~elAttr(element, 'data-like-dislikes'),
- liked: ~~elAttr(element, 'data-like-liked'),
- likes: ~~elAttr(element, 'data-like-likes'),
- objectId: ~~elAttr(element, 'data-object-id'),
- users: JSON.parse(elAttr(element, 'data-like-users'))
+ dislikes: ~~elData(element, 'like-dislikes'),
+ liked: ~~elData(element, 'like-liked'),
+ likes: ~~elData(element, 'like-likes'),
+ objectId: ~~elData(element, 'object-id'),
+ users: JSON.parse(elData(element, 'like-users'))
};
this._containers.set(element, elementData);
this._updateBadge(element);
}
- var insertPosition, userId = elAttr(element, 'data-user-id');
+ var insertPosition, userId = elData(element, 'user-id');
if (this._options.canLikeOwnContent || WCF.User.userID === userId) {
insertPosition = elBySel(this._options.buttonBeforeSelector, element);
if (insertPosition !== null) {
init: function(element, callback) {
callback = callback || null;
if (callback === null) {
- var redirectUrl = elAttr(element, 'data-link');
+ var redirectUrl = elData(element, 'link');
if (redirectUrl) {
callback = function(pageNo) {
window.location = redirectUrl.replace(/pageNo=%d/, 'pageNo=' + pageNo);
UiDialog.open(this);
- var pages = elAttr(element, 'data-pages');
+ var pages = elData(element, 'pages');
_input.value = pages;
_input.setAttribute('max', pages);
anchor = elCreate('a');
anchor.textContent = item.label;
- elAttr(anchor, 'data-object-id', item.objectID);
+ elData(anchor, 'object-id', item.objectID);
anchor.addEventListener('click', this._select.bind(this));
listItem = elCreate('li');
var container, containers = DomTraverse.childrenByTag(this._container, 'DIV'), name;
for (var i = 0, length = containers.length; i < length; i++) {
container = containers[i];
- name = elAttr(container, 'data-name');
+ name = elData(container, 'name');
if (!name) {
name = DomUtil.identify(container);
}
-
- elAttr(container, 'data-name', name);
+
+ elData(container, 'name', name);
this._containers.set(name, container);
}
// bind listeners
this._tabs.forEach((function(tab) {
- if (!oldTabs || oldTabs.get(elAttr(tab, 'data-name')) !== tab) {
+ if (!oldTabs || oldTabs.get(elData(tab, 'name')) !== tab) {
tab.children[0].addEventListener('click', this._onClick.bind(this));
}
}).bind(this));
}
}
- name = name || elAttr(tab, 'data-name');
+ name = name || elData(tab, 'name');
// unmark active tab
var oldTab = elBySel('#' + this._container.id + ' > nav > ul > li.active');
var oldContent = null;
if (oldTab) {
- if (elAttr(oldTab, 'data-name') === name) {
+ if (elData(oldTab, 'name') === name) {
// same tab
return;
}
oldTab.classList.remove('active');
- oldContent = this._containers.get(elAttr(oldTab, 'data-name'));
+ oldContent = this._containers.get(elData(oldTab, 'name'));
oldContent.classList.remove('active');
oldContent.classList.add('hidden');
active: tab,
activeName: name,
previous: oldTab,
- previousName: oldTab ? elAttr(oldTab, 'data-name') : null
+ previousName: oldTab ? elData(oldTab, 'name') : null
});
var jQuery = (this._isLegacy && typeof window.jQuery === 'function') ? window.jQuery : null;
* @return {string} tab name
*/
_getTabName: function(tab) {
- var name = elAttr(tab, 'data-name');
+ var name = elData(tab, 'name');
// handle legacy tab menus
if (!name) {
}
else {
this._isLegacy = true;
- elAttr(tab, 'data-name', name);
+ elData(tab, 'name', name);
}
}
}
title = (typeof title === 'string') ? title.trim() : '';
if (title.length) {
- elAttr(element, 'data-tooltip', title);
+ elData(element, 'tooltip', title);
element.removeAttribute('title');
element.addEventListener('mouseenter', this._mouseEnter.bind(this));
title = (typeof title === 'string') ? title.trim() : '';
if (title !== '') {
- elAttr(element, 'data-tooltip', title);
+ elData(element, 'tooltip', title);
element.removeAttribute('title');
}
- title = elAttr(element, 'data-tooltip');
+ title = elData(element, 'tooltip');
// reset tooltip position
_tooltip.style.removeProperty('top');