From eb24404d3d55dd87444c24484e042ce64db3de07 Mon Sep 17 00:00:00 2001 From: Robin Date: Sat, 4 Feb 2012 18:37:36 +0100 Subject: [PATCH] automatic prefixfree.js dl --- bin/installDeps.sh | 15 ++ static/js/prefixfree.js | 419 ---------------------------------------- 2 files changed, 15 insertions(+), 419 deletions(-) delete mode 100644 static/js/prefixfree.js diff --git a/bin/installDeps.sh b/bin/installDeps.sh index 8580387db..ab976a66b 100755 --- a/bin/installDeps.sh +++ b/bin/installDeps.sh @@ -67,6 +67,21 @@ if [ $DOWNLOAD_JQUERY = "true" ]; then curl -lo static/js/jquery.js http://code.jquery.com/jquery-$NEEDED_VERSION.js || exit 1 fi +echo "Ensure prefixfree is downloaded and up to date..." +DOWNLOAD_PREFIXFREE="true" +NEEDED_VERSION="1.0.4" +if [ -f "static/js/prefixfree.js" ]; then + VERSION=$(cat static/js/prefixfree.js | grep "PrefixFree" | grep -o "[0-9].[0-9].[0-9]"); + + if [ ${VERSION#v} = $NEEDED_VERSION ]; then + DOWNLOAD_PREFIXFREE="false" + fi +fi + +if [ $DOWNLOAD_PREFIXFREE = "true" ]; then + curl -lo static/js/prefixfree.js https://raw.github.com/LeaVerou/prefixfree/master/prefixfree.min.js || exit 1 +fi + #Remove all minified data to force node creating it new echo "Clear minfified cache..." rm -f var/minified* diff --git a/static/js/prefixfree.js b/static/js/prefixfree.js deleted file mode 100644 index 1b0d52466..000000000 --- a/static/js/prefixfree.js +++ /dev/null @@ -1,419 +0,0 @@ -/** - * StyleFix 1.0.1 - * @author Lea Verou - * MIT license - */ - -(function(){ - -if(!window.addEventListener) { - return; -} - -var self = window.StyleFix = { - link: function(link) { - try { - // Ignore stylesheets with data-noprefix attribute as well as alternate stylesheets - if(link.rel !== 'stylesheet' || !link.sheet.cssRules || link.hasAttribute('data-noprefix')) { - return; - } - } - catch(e) { - return; - } - - var url = link.href || link.getAttribute('data-href'), - base = url.replace(/[^\/]+$/, ''), - parent = link.parentNode, - xhr = new XMLHttpRequest(); - - xhr.open('GET', url); - - xhr.onreadystatechange = function() { - if(xhr.readyState === 4) { - var css = xhr.responseText; - - if(css && link.parentNode) { - css = self.fix(css, true, link); - - // Convert relative URLs to absolute, if needed - if(base) { - css = css.replace(/url\((?:'|")?(.+?)(?:'|")?\)/gi, function($0, url) { - if(!/^([a-z]{3,10}:|\/|#)/i.test(url)) { // If url not absolute & not a hash - // May contain sequences like /../ and /./ but those DO work - return 'url("' + base + url + '")'; - } - - return $0; - }); - - // behavior URLs shoudn’t be converted (Issue #19) - css = css.replace(RegExp('\\b(behavior:\\s*?url\\(\'?"?)' + base, 'gi'), '$1'); - } - - var style = document.createElement('style'); - style.textContent = css; - style.media = link.media; - style.disabled = link.disabled; - style.setAttribute('data-href', link.getAttribute('href')); - - parent.insertBefore(style, link); - parent.removeChild(link); - } - } - }; - - xhr.send(null); - - link.setAttribute('data-inprogress', ''); - }, - - styleElement: function(style) { - var disabled = style.disabled; - - style.textContent = self.fix(style.textContent, true, style); - - style.disabled = disabled; - }, - - styleAttribute: function(element) { - var css = element.getAttribute('style'); - - css = self.fix(css, false, element); - - element.setAttribute('style', css); - }, - - process: function() { - // Linked stylesheets - $('link[rel="stylesheet"]:not([data-inprogress])').forEach(StyleFix.link); - - // Inline stylesheets - $('style').forEach(StyleFix.styleElement); - - // Inline styles - $('[style]').forEach(StyleFix.styleAttribute); - }, - - register: function(fixer, index) { - (self.fixers = self.fixers || []) - .splice(index === undefined? self.fixers.length : index, 0, fixer); - }, - - fix: function(css, raw) { - for(var i=0; i 3) { - parts.pop(); - - var shorthand = parts.join('-'); - - if(supported(shorthand) && properties.indexOf(shorthand) === -1) { - properties.push(shorthand); - } - } - } - }, - supported = function(property) { - return StyleFix.camelCase(property) in dummy; - } - - // Some browsers have numerical indices for the properties, some don't - if(style.length > 0) { - for(var i=0; i