0
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-02-18 15:54:26 +01:00

Customizer: include config.json in bootstrap.zip

merges #10633; fixes part of #9951
This commit is contained in:
Stuart P. Bentley 2013-09-14 04:26:42 -04:00 committed by Chris Rebert
parent d820c6d225
commit 58a47b6bfd

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