Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated builder script to use Blob ctor as its superseded BlobBuilder…

…, fixes #23
  • Loading branch information...
commit 938bdefd59f3e0080f097da0ed4f3b7d074b6cc3 1 parent 5404e5c
@ryanseddon ryanseddon authored
Showing with 24 additions and 6 deletions.
  1. +16 −6 i/js/builderapp.js
  2. +8 −0 i/js/modernizr.com-custom-2.6.1-01.js
View
22 i/js/builderapp.js
@@ -179,8 +179,11 @@ jQuery(function($){
// Client side file saving without flash!
window.URL = window.webkitURL || window.URL;
- window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||
- window.MozBlobBuilder;
+
+ if (Modernizr.blobbuilder) {
+ window.BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder ||
+ window.MozBlobBuilder;
+ }
var a = document.querySelector('.btn2'),
typer = document.querySelector('#generatedSource'),
@@ -189,12 +192,19 @@ jQuery(function($){
a.style.display = "none";
- if(Modernizr.download && Modernizr.bloburls && Modernizr.blobbuilder) {
- var bb = new BlobBuilder();
- bb.append(typer.value);
+ if(Modernizr.download && Modernizr.bloburls && (Modernizr.blobbuilder || Modernizr.blob)) {
+ var bb;
+
+ if (Modernizr.blob) {
+ bb = new Blob([typer.value], { type: "application/octet-stream" });
+ a.href = window.URL.createObjectURL(bb);
+ } else if(Modernizr.blobbuilder) {
+ bb = new BlobBuilder();
+ bb.append(typer.value);
+ a.href = window.URL.createObjectURL(bb.getBlob("application/octet-stream"));
+ }
a.download = fileName+".js";
- a.href = window.URL.createObjectURL(bb.getBlob("application/octet-stream"));
a.style.display = "inline-block";
a.onclick = function(e) {
View
8 i/js/modernizr.com-custom-2.6.1-01.js
@@ -31,6 +31,14 @@ Modernizr.addTest({
"blobbuilder": function() {
return !!(window.BlobBuilder || window.MozBlobBuilder || window.WebKitBlobBuilder);
},
+ // Blob ctor supersedes BlobBuilder
+ "blob": function() {
+ try {
+ return !!new Blob();
+ } catch (e) {
+ return false;
+ }
+ },
// Blob URL support
"bloburls": function() {
return !!(window.URL && window.URL.createObjectURL || window.webkitURL && window.webkitURL.createObjectURL);;
Please sign in to comment.
Something went wrong with that request. Please try again.