]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Customizer: include config.json in bootstrap.zip
authorStuart P. Bentley <stuart@testtrack4.com>
Sat, 14 Sep 2013 08:26:42 +0000 (04:26 -0400)
committerChris Rebert <code@rebertia.com>
Thu, 10 Oct 2013 00:35:26 +0000 (17:35 -0700)
merges #10633; fixes part of #9951

docs-assets/js/customizer.js

index 5abfe422800cbd88f1286b24682918852e82d430..cc772d222cdb04bf19ba2ba6a42f40f713703842 100644 (file)
@@ -31,13 +31,13 @@ window.onload = function () { // wait for load in a dumb way because B-0
     return match && decodeURIComponent(match[1].replace(/\+/g, " "));
   }
 
-  function createGist(configData) {
+  function createGist(configJson) {
     var data = {
       "description": "Bootstrap Customizer Config",
       "public": true,
       "files": {
         "config.json": {
-          "content": JSON.stringify(configData, null, 2)
+          "content": configJson
         }
       }
     }
@@ -107,7 +107,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
     })
   }
 
-  function generateZip(css, js, fonts, complete) {
+  function generateZip(css, js, fonts, config, complete) {
     if (!css && !js) return showError('<strong>Ruh roh!</strong> No Bootstrap files selected.', new Error('no Bootstrap'))
 
     var zip = new JSZip()
@@ -133,6 +133,10 @@ window.onload = function () { // wait for load in a dumb way because B-0
       }
     }
 
+    if (config) {
+      zip.file('config.json', config)
+    }
+
     var content = zip.generate({type:"blob"})
 
     complete(content)
@@ -262,14 +266,17 @@ window.onload = function () { // wait for load in a dumb way because B-0
   var $downloadBtn = $('#btn-download')
 
   $compileBtn.on('click', function (e) {
+    var configData = getCustomizerData()
+    var configJson = JSON.stringify(configData, null, 2)
+
     e.preventDefault()
 
     $compileBtn.attr('disabled', 'disabled')
 
-    generateZip(generateCSS(), generateJavascript(), generateFonts(), function (blob) {
+    generateZip(generateCSS(), generateJavascript(), generateFonts(), configJson, function (blob) {
       $compileBtn.removeAttr('disabled')
       saveAs(blob, "bootstrap.zip")
-      createGist(getCustomizerData())
+      createGist(configJson)
     })
   })