Created
March 2, 2012 03:59
-
-
Save hongymagic/1955524 to your computer and use it in GitHub Desktop.
Extension to `Pre` client-side JavaScript library to fix vendor prefixes, with usable API to plugin to jQuery, zepto and other libraries.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.logger = (function (window) { | |
var document = window.document, | |
textarea = document.getElementById('log'), | |
counter = 1; | |
const DELIMETER = ''; | |
function log () { | |
var messages = [].slice.call(arguments); | |
messages.forEach(function (message, index) { | |
if (typeof message == 'object') { | |
message = JSON.stringify(message); | |
} | |
textarea.value += [counter++, ': ', message, '\n'].join(DELIMETER); | |
}); | |
} | |
function clear() { | |
textarea.value = ''; | |
} | |
return { | |
log: log, | |
clear: clear | |
}; | |
}(window)); | |
window.Pre = {}; | |
// | |
// Pre.fix | |
// | |
// @usage: Pre.fix({ 'transition': 'all .4s ease-in-out' }); | |
(function (window, Pre) { | |
var document = window.document, | |
computedStyle = window.getComputedStyle(document.documentElement, null), | |
keys = Object.keys(computedStyle), | |
counter = {}, | |
index, key, value, prefix, parts; | |
for (index in keys) { | |
key = keys[index]; | |
value = computedStyle[key]; | |
if (value && typeof value.split === 'function') { | |
parts = value.split('-'); | |
prefix = parts[1]; | |
if (prefix) { | |
counter[prefix] = ++counter[prefix] || 1; | |
} | |
} | |
} | |
logger.log(counter); | |
Pre.fix = function () { | |
}; | |
}(window, Pre)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment