diff options
| author | Chris Rebert <[email protected]> | 2014-03-27 22:07:20 -0700 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2014-03-28 10:58:32 -0700 |
| commit | 5458134f5e02d377d50ca2fcabe80a75215273c3 (patch) | |
| tree | f4d5dab8bec6f5e06cecda2d29ee0ee134c4000a /docs | |
| parent | 440cedeed3e23960d0516153ef776c78f9efeabc (diff) | |
| download | bootstrap-5458134f5e02d377d50ca2fcabe80a75215273c3.tar.xz bootstrap-5458134f5e02d377d50ca2fcabe80a75215273c3.zip | |
Add Gist & Customizer URLs to customized files & config.json
Fixes #9951
Fixes #12865
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/assets/js/_src/customizer.js | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/docs/assets/js/_src/customizer.js b/docs/assets/js/_src/customizer.js index cee3c5766..ea7cf7f6f 100644 --- a/docs/assets/js/_src/customizer.js +++ b/docs/assets/js/_src/customizer.js @@ -43,7 +43,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 return match && decodeURIComponent(match[1].replace(/\+/g, ' ')) } - function createGist(configJson) { + function createGist(configJson, callback) { var data = { description: 'Bootstrap Customizer Config', 'public': true, @@ -61,10 +61,13 @@ window.onload = function () { // wait for load in a dumb way because B-0 }) .success(function (result) { var origin = window.location.protocol + '//' + window.location.host - history.replaceState(false, document.title, origin + window.location.pathname + '?id=' + result.id) + var newUrl = origin + window.location.pathname + '?id=' + result.id + history.replaceState(false, document.title, newUrl) + callback(result.html_url, newUrl) }) .error(function (err) { showError('<strong>Ruh roh!</strong> Could not save gist file, configuration not saved.', err) + callback('<none>', '<none>') }) } @@ -221,7 +224,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 }) } - function generateCSS() { + function generateCSS(preamble) { var oneChecked = false var lessFileIncludes = {} $('#less-section input').each(function() { @@ -242,8 +245,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 $(this).val() && (vars[$(this).prev().text()] = $(this).val()) }) - var bsLessSource = generateLESS('bootstrap.less', lessFileIncludes, vars) - var themeLessSource = generateLESS('theme.less', lessFileIncludes, vars) + var bsLessSource = preamble + generateLESS('bootstrap.less', lessFileIncludes, vars) + var themeLessSource = preamble + generateLESS('theme.less', lessFileIncludes, vars) try { compileLESS(bsLessSource, 'bootstrap', result) @@ -255,7 +258,7 @@ window.onload = function () { // wait for load in a dumb way because B-0 return result } - function generateJavascript() { + function generateJavascript(preamble) { var $checked = $('#plugin-section input:checked') if (!$checked.length) return false @@ -265,8 +268,8 @@ window.onload = function () { // wait for load in a dumb way because B-0 .join('\n') return { - 'bootstrap.js': js, - 'bootstrap.min.js': cw + uglify(js) + 'bootstrap.js': preamble + js, + 'bootstrap.min.js': preamble + cw + uglify(js) } } @@ -322,10 +325,19 @@ window.onload = function () { // wait for load in a dumb way because B-0 $compileBtn.attr('disabled', 'disabled') - generateZip(generateCSS(), generateJavascript(), generateFonts(), configJson, function (blob) { - $compileBtn.removeAttr('disabled') - saveAs(blob, 'bootstrap.zip') - createGist(configJson) + createGist(configJson, function (gistUrl, customizerUrl) { + configData.customizerUrl = customizerUrl + configJson = JSON.stringify(configData, null, 2) + + var preamble = '/*!\n' + + ' * Generated using the Bootstrap Customizer (' + customizerUrl + ')\n' + + ' * Config saved to config.json and ' + gistUrl + '\n' + + ' */\n' + + generateZip(generateCSS(preamble), generateJavascript(preamble), generateFonts(), configJson, function (blob) { + $compileBtn.removeAttr('disabled') + saveAs(blob, 'bootstrap.zip') + }) }) }); |
