Permalink
Browse files

Bootstrap in libraries

  • Loading branch information...
1 parent f9c72f9 commit 9245e2edc2c550d8572c177a0cf6032f3ad1e7c1 @remy remy committed Apr 16, 2012
Showing with 22 additions and 14 deletions.
  1. +14 −5 js/editors/libraries.js
  2. +8 −9 js/editors/library.js
View
@@ -16,6 +16,14 @@ var Libraries = function () {
Libraries.prototype.init = function () {
var libs = {
+ bootstrap: {
+ text: 'Bootstrap',
+ style: ['http://twitter.github.com/bootstrap/assets/css/bootstrap.css',
+ 'http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css'],
+ scripts: [
+ { text: 'Bootstrap latest', url: 'http://twitter.github.com/bootstrap/assets/js/bootstrap.js'}
+ ]
+ },
yui: {
text: 'YUI',
scripts: [
@@ -59,10 +67,11 @@ Libraries.prototype.init = function () {
jquerymobile : {
text: 'jQuery Mobile',
requires: 'http://code.jquery.com/jquery-1.6.4.min.js',
- style: 'http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0.min.css',
+ style: 'http://code.jquery.com/mobile/latest/jquery.mobile.css',
scripts: [
- { text: 'jQuery Mobile 1.0', url: 'http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js' },
- { text: 'jQuery Mobile 1.0b3', url: 'http://code.jquery.com/mobile/1.0b3/jquery.mobile-1.0b3.min.js' }
+ { text: 'jQuery Mobile Latest', url: 'http://code.jquery.com/mobile/latest/jquery.mobile.js' },
+ { text: 'jQuery Mobile 1.0.1', url: 'http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.1.min.js' },
+ { text: 'jQuery Mobile 1.1.0rc1', url: 'http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.js' }
]
},
others: {
@@ -99,7 +108,7 @@ Libraries.prototype.init = function () {
// }
},
// NOTE if a new library category is added, you need to add it here
- order = 'jquery jqueryui jquerymobile prototype yui mootools dojo others'.split(' '),
+ order = 'jquery jqueryui jquerymobile bootstrap prototype yui mootools dojo others'.split(' '),
i = 0;
this.length = 0; // triggers support for length prop
@@ -127,4 +136,4 @@ Libraries.prototype.clear = function () {
// OO based to all me to fiddle the object to resemble an array
var libraries = new Libraries();
-window.libraries = libraries; // expose a command line API
+window.libraries = libraries; // expose a command line API
View
@@ -1,4 +1,5 @@
//= require "libraries"
+var state = {};
$('#library').bind('init', function () {
var $select = $(this),
html = ['<option value="none">None</option>'],
@@ -14,15 +15,10 @@ $('#library').bind('init', function () {
}
$select.html( html.join('') ).val(selected);
-}).trigger('init');
-
-var state = {};
-
-$('#library').bind('change', function () {
+}).trigger('init').change(function () {
var libIndex = [],
lib = {},
thislib = {},
- re,
i,
code = editors.html.getCode();
@@ -57,8 +53,11 @@ $('#library').bind('change', function () {
}
if (lib.style) {
- state.add++;
- code = code.replace('<head', "<head>\n<" + 'link class="jsbin" href="' + lib.style + '" rel="stylesheet" type="text/css" /');
+ if (typeof lib.style === 'string') lib.style = [lib.style];
+ for (i = 0; i < lib.style.length; i++) {
+ state.add++;
+ code = code.replace('<head', "<head>\n<" + 'link class="jsbin" href="' + lib.style[i] + '" rel="stylesheet" type="text/css" /');
+ }
}
} else { // add to the start of the doc
code = "<" + 'script class="jsbin" src="' + lib.scripts[libIndex[1]].url + '"><' + '/script>\n' + code;
@@ -81,4 +80,4 @@ $('#library').bind('change', function () {
editors.html.setCode(code);
editors.html.focus();
editors.html.setCursor({ line: state.line, ch: state.character });
-});
+});

0 comments on commit 9245e2e

Please sign in to comment.