Skip to content

Commit

Permalink
Merge branch '3.0.0-wip' into bs3_homepage
Browse files Browse the repository at this point in the history
Conflicts:
	dist/css/bootstrap.min.css
  • Loading branch information
mdo committed Aug 18, 2013
2 parents 5e31478 + 04a73eb commit 18766db
Show file tree
Hide file tree
Showing 63 changed files with 3,107 additions and 3,157 deletions.
13 changes: 12 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,17 @@ module.exports = function(grunt) {
},
src: ['less/bootstrap.less'],
dest: 'dist/css/<%= pkg.name %>.min.css'
},
theme: {
src: ['less/theme.less'],
dest: 'dist/css/<%= pkg.name %>-theme.css'
},
theme_min: {
options: {
compress: true
},
src: ['less/theme.less'],
dest: 'dist/css/<%= pkg.name %>-theme.min.css'
}
},

Expand Down Expand Up @@ -169,7 +180,7 @@ module.exports = function(grunt) {
grunt.registerTask('dist', ['clean', 'dist-css', 'dist-js']);

// Default task.
grunt.registerTask('default', ['test', 'dist']);
grunt.registerTask('default', ['test', 'dist', 'build-customizer']);

// task for building customizer
grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Read the [Getting Started page](http://getbootstrap.com/getting-started/) for in

Have a bug or a feature request? [Please open a new issue](https://github.com/twbs/bootstrap/issues). Before opening any issue, please search for existing issues and read the [Issue Guidelines](https://github.com/necolas/issue-guidelines), written by [Nicolas Gallagher](https://github.com/necolas/).

You may use [this JS Bin](http://jsbin.com/aFacAf/1/edit) as a template for your bug reports.



## Documentation
Expand Down
1 change: 0 additions & 1 deletion _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
<script src="{{ page.base_url }}assets/js/less.js"></script>
<script src="{{ page.base_url }}assets/js/jszip.js"></script>
<script src="{{ page.base_url }}assets/js/uglify.js"></script>
<script src="{{ page.base_url }}assets/js/jquery.bbq.min.js"></script>
<script src="{{ page.base_url }}assets/js/customizer.js"></script>
{% endif %}

Expand Down
52 changes: 0 additions & 52 deletions _layouts/customize.html

This file was deleted.

21 changes: 21 additions & 0 deletions assets/css/docs.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

133 changes: 100 additions & 33 deletions assets/js/customizer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
window.onload = function () { // wait for load in a dumb way because B-0
var cw = '/*!\n * Bootstrap v3.0.0-rc.2\n *\n * Copyright 2013 Twitter, Inc\n * Licensed under the Apache License v2.0\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Designed and built with all the love in the world @twitter by @mdo and @fat.\n */\n\n'

function showError (msg, err) {
$('<div id="bsCustomizerAlert" class="bs-customizer-alert">\
<div class="container">\
<a href="#bsCustomizerAlert" data-dismiss="alert" class="close pull-right">&times;</a>\
<p class="bs-customizer-alert-text">' + msg + '</p>' +
(err.extract ? '<pre class="bs-customizer-alert-extract">' + err.extract.join('\n') + '</pre>' : '') + '\
</div>\
</div>').appendTo('body').alert()
throw err
}

function getQueryParam(key) {
key = key.replace(/[*+?^$.\[\]{}()|\\\/]/g, "\\$&"); // escape RegEx meta chars
var match = location.search.match(new RegExp("[?&]"+key+"=([^&]+)(&|$)"));
return match && decodeURIComponent(match[1].replace(/\+/g, " "));
}

function createGist (configData) {
var data = {
"description": "Bootstrap Customizer Config",
"public": true,
"files": {
"config.json": {
"content": JSON.stringify(configData)
}
}
}
$.ajax({
url: 'https://api.github.com/gists',
type: 'POST',
dataType: 'json',
data: JSON.stringify(data)
})
.success(function(result) {
history.replaceState(false, document.title, window.location.origin + window.location.pathname + '?id=' + result.id)
})
.error(function(err) {
showError('<strong>Error</strong> Could not save gist file, configuration not saved.', err)
})
}

function generateUrl() {
var vars = {}

Expand All @@ -11,39 +52,50 @@ window.onload = function () { // wait for load in a dumb way because B-0

var data = {
vars: vars,
css: $('#less-section input:not(:checked)').map(function () { return this.value }).toArray(),
js: $('#plugin-section input:not(:checked)').map(function () { return this.value }).toArray()
css: $('#less-section input:checked') .map(function () { return this.value }).toArray(),
js: $('#plugin-section input:checked').map(function () { return this.value }).toArray()
}

if ($.isEmptyObject(data.vars) && !data.css.length && !data.js.length) return

window.location = jQuery.param.querystring('/customize/', data)
createGist(data)
}

function parseUrl() {
var data = jQuery.deparam.querystring()
var id = getQueryParam('id')

if (data.js) {
for (var i = 0; i < data.js.length; i++) {
var input = $('input[value="'+data.js[i]+'"]')
input && input.prop('checked', false)
}
}
if (!id) return

if (data.css) {
for (var i = 0; i < data.css.length; i++) {
var input = $('input[value="'+data.css[i]+'"]')
input && input.prop('checked', false)
$.ajax({
url: 'https://api.github.com/gists/' + id,
type: 'GET',
dataType: 'json'
})
.success(function(result) {
var data = JSON.parse(result.files['config.json'].content)
if (data.js) {
$('#plugin-section input').each(function () {
$(this).prop('checked', ~$.inArray(this.value, data.js))
})
}
}

if (data.vars) {
// todo (fat): vars
}
if (data.css) {
$('#less-section input').each(function () {
$(this).prop('checked', ~$.inArray(this.value, data.css))
})
}
if (data.vars) {
for (var i in data.vars) {
$('input[data-var="' + i + '"]').val(data.vars[i])
}
}
})
.error(function(err) {
showError('Error fetching bootstrap config file', err)
})
}

function generateZip(css, js, complete) {
if (!css && !js) return alert('you want to build nothing… o_O')
if (!css && !js) return showError('<strong>Error</strong> No Bootstrap files selected.', new Error('no Bootstrap'))

var zip = new JSZip()

Expand All @@ -62,9 +114,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
}

var content = zip.generate()

location.href = 'data:application/zip;base64,' + content

complete()
}

Expand Down Expand Up @@ -108,15 +158,16 @@ window.onload = function () { // wait for load in a dumb way because B-0
, optimization: 0
, filename: 'bootstrap.css'
}).parse(css, function (err, tree) {
if (err) return alert(err)

if (err) {
return showError('<strong>Error</strong> Could not parse less files.', err)
}
result = {
'bootstrap.css' : cw + tree.toCSS(),
'bootstrap.min.css' : cw + tree.toCSS({ compress: true })
}
})
} catch (err) {
return alert(err)
return showError('<strong>Error</strong> Could not parse less files.', err)
}

return result
Expand All @@ -142,9 +193,7 @@ window.onload = function () { // wait for load in a dumb way because B-0
$downloadBtn.addClass('loading')
generateZip(generateCSS(), generateJavascript(), function () {
$downloadBtn.removeClass('loading')
setTimeout(function () {
generateUrl()
}, 1)
setTimeout(generateUrl, 500)
})
})

Expand All @@ -167,9 +216,27 @@ window.onload = function () { // wait for load in a dumb way because B-0
inputsVariables.val('')
})

try {
parseUrl()
} catch (e) {
// maybe alert user that we can't parse their url
}
$('[data-dependencies]').on('click', function () {
if (!$(this).is(':checked')) return
var dependencies = this.getAttribute('data-dependencies')
if (!dependencies) return
dependencies = dependencies.split(',')
for (var i = 0; i < dependencies.length; i++) {
var dependency = $('[value="' + dependencies[i] + '"]')
dependency && dependency.prop('checked', true)
}
})

$('[data-dependents]').on('click', function () {
if ($(this).is(':checked')) return
var dependents = this.getAttribute('data-dependents')
if (!dependents) return
dependents = dependents.split(',')
for (var i = 0; i < dependents.length; i++) {
var dependent = $('[value="' + dependents[i] + '"]')
dependent && dependent.prop('checked', false)
}
})

parseUrl()
}
Loading

0 comments on commit 18766db

Please sign in to comment.