Separate initialize, update and destroy functions.

This commit is contained in:
Hyunje Alex Jun
2015-02-11 15:53:41 +00:00
parent 7ab6c5e5ef
commit fa7e169b9f
9 changed files with 888 additions and 795 deletions
+8
View File
@@ -35,3 +35,11 @@ exports.remove = function (element, className) {
oldRemove(element, className);
}
};
exports.list = function (element) {
if (element.classList) {
return element.classList;
} else {
return element.className.split(' ');
}
};
+16
View File
@@ -0,0 +1,16 @@
/* Copyright (c) 2015 Hyunje Alex Jun and other contributors
* Licensed under the MIT License
*/
'use strict';
module.exports = (function() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return function() {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
};
})();
+12 -1
View File
@@ -3,7 +3,8 @@
*/
'use strict';
var d = require('./dom');
var cls = require('./class')
, d = require('./dom');
exports.toInt = function (x) {
if (typeof x === 'string') {
@@ -42,6 +43,16 @@ exports.isEditable = function (el) {
d.matches(el, "button,[contenteditable]");
};
exports.removePsClass = function (element) {
var clsList = cls.list(element);
for (var i = 0; i < clsList.length; i++) {
var className = clsList[i];
if (className.indexOf('ps-') === 0) {
cls.remove(className);
}
}
};
exports.env = {
isWebKit: 'WebkitAppearance' in document.documentElement.style,
supportsTouch: (('ontouchstart' in window) || window.DocumentTouch && document instanceof window.DocumentTouch),