From cf7ed2625456a5e619f68408f8ebfe78f443a672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Tue, 10 Jul 2012 19:51:16 +0000 Subject: upgrade to bootstrap 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- web/pub/bootstrap/js/README.md | 106 + web/pub/bootstrap/js/application.js | 184 + web/pub/bootstrap/js/bootstrap-alert.js | 90 + web/pub/bootstrap/js/bootstrap-button.js | 96 + web/pub/bootstrap/js/bootstrap-carousel.js | 169 + web/pub/bootstrap/js/bootstrap-collapse.js | 157 + web/pub/bootstrap/js/bootstrap-dropdown.js | 100 + web/pub/bootstrap/js/bootstrap-modal.js | 218 + web/pub/bootstrap/js/bootstrap-popover.js | 98 + web/pub/bootstrap/js/bootstrap-scrollspy.js | 151 + web/pub/bootstrap/js/bootstrap-tab.js | 135 + web/pub/bootstrap/js/bootstrap-tooltip.js | 275 + web/pub/bootstrap/js/bootstrap-transition.js | 61 + web/pub/bootstrap/js/bootstrap-typeahead.js | 285 + web/pub/bootstrap/js/bootstrap.js | 1825 ++++ web/pub/bootstrap/js/bootstrap.min.js | 6 + .../bootstrap/js/google-code-prettify/prettify.css | 30 + .../bootstrap/js/google-code-prettify/prettify.js | 28 + web/pub/bootstrap/js/jquery.js | 9252 ++++++++++++++++++++ 19 files changed, 13266 insertions(+) create mode 100644 web/pub/bootstrap/js/README.md create mode 100644 web/pub/bootstrap/js/application.js create mode 100644 web/pub/bootstrap/js/bootstrap-alert.js create mode 100644 web/pub/bootstrap/js/bootstrap-button.js create mode 100644 web/pub/bootstrap/js/bootstrap-carousel.js create mode 100644 web/pub/bootstrap/js/bootstrap-collapse.js create mode 100644 web/pub/bootstrap/js/bootstrap-dropdown.js create mode 100644 web/pub/bootstrap/js/bootstrap-modal.js create mode 100644 web/pub/bootstrap/js/bootstrap-popover.js create mode 100644 web/pub/bootstrap/js/bootstrap-scrollspy.js create mode 100644 web/pub/bootstrap/js/bootstrap-tab.js create mode 100644 web/pub/bootstrap/js/bootstrap-tooltip.js create mode 100644 web/pub/bootstrap/js/bootstrap-transition.js create mode 100644 web/pub/bootstrap/js/bootstrap-typeahead.js create mode 100644 web/pub/bootstrap/js/bootstrap.js create mode 100644 web/pub/bootstrap/js/bootstrap.min.js create mode 100644 web/pub/bootstrap/js/google-code-prettify/prettify.css create mode 100644 web/pub/bootstrap/js/google-code-prettify/prettify.js create mode 100644 web/pub/bootstrap/js/jquery.js (limited to 'web/pub/bootstrap/js') diff --git a/web/pub/bootstrap/js/README.md b/web/pub/bootstrap/js/README.md new file mode 100644 index 0000000..b58fa1d --- /dev/null +++ b/web/pub/bootstrap/js/README.md @@ -0,0 +1,106 @@ +## 2.0 BOOTSTRAP JS PHILOSOPHY +These are the high-level design rules which guide the development of Bootstrap's plugin apis. + +--- + +### DATA-ATTRIBUTE API + +We believe you should be able to use all plugins provided by Bootstrap purely through the markup API without writing a single line of javascript. + +We acknowledge that this isn't always the most performant and sometimes it may be desirable to turn this functionality off altogether. Therefore, as of 2.0 we provide the ability to disable the data attribute API by unbinding all events on the body namespaced with `'data-api'`. This looks like this: + + $('body').off('.data-api') + +To target a specific plugin, just include the plugins name as a namespace along with the data-api namespace like this: + + $('body').off('.alert.data-api') + +--- + +### PROGRAMATIC API + +We also believe you should be able to use all plugins provided by Bootstrap purely through the JS API. + +All public APIs should be single, chainable methods, and return the collection acted upon. + + $(".btn.danger").button("toggle").addClass("fat") + +All methods should accept an optional options object, a string which targets a particular method, or null which initiates the default behavior: + + $("#myModal").modal() // initialized with defaults + $("#myModal").modal({ keyboard: false }) // initialized with now keyboard + $("#myModal").modal('show') // initializes and invokes show immediately afterqwe2 + +--- + +### OPTIONS + +Options should be sparse and add universal value. We should pick the right defaults. + +All plugins should have a default object which can be modified to effect all instance's default options. The defaults object should be available via `$.fn.plugin.defaults`. + + $.fn.modal.defaults = { … } + +An options definition should take the following form: + + *noun*: *adjective* - describes or modifies a quality of an instance + +examples: + + backdrop: true + keyboard: false + placement: 'top' + +--- + +### EVENTS + +All events should have an infinitive and past participle form. The infinitive is fired just before an action takes place, the past participle on completion of the action. + + show | shown + hide | hidden + +--- + +### CONSTRUCTORS + +Each plugin should expose it's raw constructor on a `Constructor` property -- accessed in the following way: + + + $.fn.popover.Constructor + +--- + +### DATA ACCESSOR + +Each plugin stores a copy of the invoked class on an object. This class instance can be accessed directly through jQuery's data API like this: + + $('[rel=popover]').data('popover') instanceof $.fn.popover.Constructor + +--- + +### DATA ATTRIBUTES + +Data attributes should take the following form: + +- data-{{verb}}={{plugin}} - defines main interaction +- data-target || href^=# - defined on "control" element (if element controls an element other than self) +- data-{{noun}} - defines class instance options + +examples: + + // control other targets + data-toggle="modal" data-target="#foo" + data-toggle="collapse" data-target="#foo" data-parent="#bar" + + // defined on element they control + data-spy="scroll" + + data-dismiss="modal" + data-dismiss="alert" + + data-toggle="dropdown" + + data-toggle="button" + data-toggle="buttons-checkbox" + data-toggle="buttons-radio" \ No newline at end of file diff --git a/web/pub/bootstrap/js/application.js b/web/pub/bootstrap/js/application.js new file mode 100644 index 0000000..6463b90 --- /dev/null +++ b/web/pub/bootstrap/js/application.js @@ -0,0 +1,184 @@ +// NOTICE!! DO NOT USE ANY OF THIS JAVASCRIPT +// IT'S ALL JUST JUNK FOR OUR DOCS! +// ++++++++++++++++++++++++++++++++++++++++++ + +!function ($) { + + $(function(){ + + // Disable certain links in docs + $('section [href^=#]').click(function (e) { + e.preventDefault() + }) + + // make code pretty + window.prettyPrint && prettyPrint() + + // add-ons + $('.add-on :checkbox').on('click', function () { + var $this = $(this) + , method = $this.attr('checked') ? 'addClass' : 'removeClass' + $(this).parents('.add-on')[method]('active') + }) + + // position static twipsies for components page + if ($(".twipsies a").length) { + $(window).on('load resize', function () { + $(".twipsies a").each(function () { + $(this) + .tooltip({ + placement: $(this).attr('title') + , trigger: 'manual' + }) + .tooltip('show') + }) + }) + } + + // add tipsies to grid for scaffolding + if ($('#grid-system').length) { + $('#grid-system').tooltip({ + selector: '.show-grid > div' + , title: function () { return $(this).width() + 'px' } + }) + } + + // fix sub nav on scroll + var $win = $(window) + , $nav = $('.subnav') + , navTop = $('.subnav').length && $('.subnav').offset().top - 40 + , isFixed = 0 + + processScroll() + + // hack sad times - holdover until rewrite for 2.1 + $nav.on('click', function () { + if (!isFixed) setTimeout(function () { $win.scrollTop($win.scrollTop() - 47) }, 10) + }) + + $win.on('scroll', processScroll) + + function processScroll() { + var i, scrollTop = $win.scrollTop() + if (scrollTop >= navTop && !isFixed) { + isFixed = 1 + $nav.addClass('subnav-fixed') + } else if (scrollTop <= navTop && isFixed) { + isFixed = 0 + $nav.removeClass('subnav-fixed') + } + } + + // tooltip demo + $('.tooltip-demo.well').tooltip({ + selector: "a[rel=tooltip]" + }) + + $('.tooltip-test').tooltip() + $('.popover-test').popover() + + // popover demo + $("a[rel=popover]") + .popover() + .click(function(e) { + e.preventDefault() + }) + + // button state demo + $('#fat-btn') + .click(function () { + var btn = $(this) + btn.button('loading') + setTimeout(function () { + btn.button('reset') + }, 3000) + }) + + // carousel demo + $('#myCarousel').carousel() + + // javascript build logic + var inputsComponent = $("#components.download input") + , inputsPlugin = $("#plugins.download input") + , inputsVariables = $("#variables.download input") + + // toggle all plugin checkboxes + $('#components.download .toggle-all').on('click', function (e) { + e.preventDefault() + inputsComponent.attr('checked', !inputsComponent.is(':checked')) + }) + + $('#plugins.download .toggle-all').on('click', function (e) { + e.preventDefault() + inputsPlugin.attr('checked', !inputsPlugin.is(':checked')) + }) + + $('#variables.download .toggle-all').on('click', function (e) { + e.preventDefault() + inputsVariables.val('') + }) + + // request built javascript + $('.download-btn').on('click', function () { + + var css = $("#components.download input:checked") + .map(function () { return this.value }) + .toArray() + , js = $("#plugins.download input:checked") + .map(function () { return this.value }) + .toArray() + , vars = {} + , img = ['glyphicons-halflings.png', 'glyphicons-halflings-white.png'] + + $("#variables.download input") + .each(function () { + $(this).val() && (vars[ $(this).prev().text() ] = $(this).val()) + }) + + $.ajax({ + type: 'POST' + , url: /\?dev/.test(window.location) ? 'http://localhost:3000' : 'http://bootstrap.herokuapp.com' + , dataType: 'jsonpi' + , params: { + js: js + , css: css + , vars: vars + , img: img + } + }) + }) + }) + +// Modified from the original jsonpi https://github.com/benvinegar/jquery-jsonpi +$.ajaxTransport('jsonpi', function(opts, originalOptions, jqXHR) { + var url = opts.url; + + return { + send: function(_, completeCallback) { + var name = 'jQuery_iframe_' + jQuery.now() + , iframe, form + + iframe = $('