From 1ff6d33aa87aea3e9bd028839e32fa2b9eb99ba3 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Tue, 18 Feb 2014 01:45:58 -0800 Subject: [PATCH] use @ssorallen's blob support test in customizer; fixes #12617 --- docs/assets/js/src/customizer.js | 48 +++++++++++++++++++++++--------- docs/customize.html | 2 +- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/docs/assets/js/src/customizer.js b/docs/assets/js/src/customizer.js index 4ce304f1a1..cee3c5766d 100644 --- a/docs/assets/js/src/customizer.js +++ b/docs/assets/js/src/customizer.js @@ -327,20 +327,42 @@ window.onload = function () { // wait for load in a dumb way because B-0 saveAs(blob, 'bootstrap.zip') createGist(configJson) }) - }) + }); - // browser support alerts - if (!window.URL && navigator.userAgent.toLowerCase().indexOf('safari') != -1) { - showCallout('Looks like you\'re using safari, which sadly doesn\'t have the best support' + - 'for HTML5 blobs. Because of this your file will be downloaded with the name "untitled".' + - 'However, if you check your downloads folder, just rename this "untitled" file' + - 'to "bootstrap.zip" and you should be good to go!') - } else if (!window.URL && !window.webkitURL) { - $('.bs-docs-section, .bs-docs-sidebar').css('display', 'none') - - showCallout('Looks like your current browser doesn\'t support the Bootstrap Customizer. Please take a second' + - 'to upgrade to a more modern browser.', true) - } + // browser support alert + (function () { + function failback() { + $('.bs-docs-section, .bs-docs-sidebar').css('display', 'none') + showCallout('Looks like your current browser doesn\'t support the Bootstrap Customizer. Please take a second ' + + 'to upgrade to a more modern browser (other than Safari).', true) + } + /** + * Based on: + * Blob Feature Check v1.1.0 + * https://github.com/ssorallen/blob-feature-check/ + * License: Public domain (http://unlicense.org) + */ + var url = window.webkitURL || window.URL // Safari 6 uses "webkitURL". + var svg = new Blob( + [''], + {type: 'image/svg+xml;charset=utf-8'} + ) + var objectUrl = url.createObjectURL(svg); + if (/^blob:/.exec(objectUrl) === null) { + // `URL.createObjectURL` created a URL that started with something other + // than "blob:", which means it has been polyfilled and is not supported by + // this browser. + failback() + } + else { + $('') + .on('load', function () { + $compileBtn.prop('disabled', false) + }) + .on('error', failback) + .attr('src', objectUrl) + } + })(); parseUrl() } diff --git a/docs/customize.html b/docs/customize.html index 3e29227bb5..a36cbdf32d 100644 --- a/docs/customize.html +++ b/docs/customize.html @@ -356,7 +356,7 @@ lead: Customize Bootstrap's components, Less variables, and jQuery plugins to ge

Hooray! Your custom version of Bootstrap is now ready to be compiled. Just click the button below to finish the process.

- +