mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
76 lines
2.0 KiB
JavaScript
76 lines
2.0 KiB
JavaScript
(function(document, ionic) {
|
|
'use strict';
|
|
|
|
// Ionic CSS polyfills
|
|
ionic.CSS = {};
|
|
|
|
(function() {
|
|
|
|
// transform
|
|
var i, keys = ['webkitTransform', 'transform', '-webkit-transform', 'webkit-transform',
|
|
'-moz-transform', 'moz-transform', 'MozTransform', 'mozTransform', 'msTransform'];
|
|
|
|
for(i = 0; i < keys.length; i++) {
|
|
if(document.documentElement.style[keys[i]] !== undefined) {
|
|
ionic.CSS.TRANSFORM = keys[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
// transition
|
|
keys = ['webkitTransition', 'mozTransition', 'msTransition', 'transition'];
|
|
for(i = 0; i < keys.length; i++) {
|
|
if(document.documentElement.style[keys[i]] !== undefined) {
|
|
ionic.CSS.TRANSITION = keys[i];
|
|
break;
|
|
}
|
|
}
|
|
|
|
})();
|
|
|
|
// classList polyfill for them older Androids
|
|
// https://gist.github.com/devongovett/1381839
|
|
if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') {
|
|
Object.defineProperty(HTMLElement.prototype, 'classList', {
|
|
get: function() {
|
|
var self = this;
|
|
function update(fn) {
|
|
return function() {
|
|
var x, classes = self.className.split(/\s+/);
|
|
|
|
for(x=0; x<arguments.length; x++) {
|
|
fn(classes, classes.indexOf(arguments[x]), arguments[x]);
|
|
}
|
|
|
|
self.className = classes.join(" ");
|
|
};
|
|
}
|
|
|
|
return {
|
|
add: update(function(classes, index, value) {
|
|
~index || classes.push(value);
|
|
}),
|
|
|
|
remove: update(function(classes, index) {
|
|
~index && classes.splice(index, 1);
|
|
}),
|
|
|
|
toggle: update(function(classes, index, value) {
|
|
~index ? classes.splice(index, 1) : classes.push(value);
|
|
}),
|
|
|
|
contains: function(value) {
|
|
return !!~self.className.split(/\s+/).indexOf(value);
|
|
},
|
|
|
|
item: function(i) {
|
|
return self.className.split(/\s+/)[i] || null;
|
|
}
|
|
};
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
})(document, ionic);
|