diff options
author | Thomas Park <thomas@thomaspark.me> | 2012-02-21 12:45:52 -0500 |
---|---|---|
committer | Thomas Park <thomas@thomaspark.me> | 2012-02-21 12:45:52 -0500 |
commit | b46358a73431aa4b5283139ec12ece59d9ccce28 (patch) | |
tree | 89a7ee6f4fcb9cb8b46735fc1b006581e0936392 /js | |
parent | b5b6ce16bf174de7e5427955b4a1eec7cecdaab6 (diff) |
changed path to top js folder
Diffstat (limited to 'js')
-rwxr-xr-x | js/application.js | 181 | ||||
-rwxr-xr-x | js/bootstrap-collapse.js | 136 |
2 files changed, 317 insertions, 0 deletions
diff --git a/js/application.js b/js/application.js new file mode 100755 index 00000000..675653a4 --- /dev/null +++ b/js/application.js @@ -0,0 +1,181 @@ +// 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') + , navHeight = $('.navbar').first().height() + , navTop = $('.subnav').length && $('.subnav').offset().top - navHeight + , isFixed = 0 + + processScroll() + + $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: '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 = $('<iframe>') +// .attr('name', name) +// .appendTo('head') +// +// form = $('<form>') +// .attr('method', opts.type) // GET or POST +// .attr('action', url) +// .attr('target', name) +// +// $.each(opts.params, function(k, v) { +// +// $('<input>') +// .attr('type', 'hidden') +// .attr('name', k) +// .attr('value', typeof v == 'string' ? v : JSON.stringify(v)) +// .appendTo(form) +// }) +// +// form.appendTo('body').submit() +// } +// } +}) + +}(window.jQuery)
\ No newline at end of file diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js new file mode 100755 index 00000000..8134cc42 --- /dev/null +++ b/js/bootstrap-collapse.js @@ -0,0 +1,136 @@ +/* ============================================================= + * bootstrap-collapse.js v2.0.0 + * http://twitter.github.com/bootstrap/javascript.html#collapse + * ============================================================= + * Copyright 2012 Twitter, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============================================================ */ + +!function( $ ){ + + "use strict" + + var Collapse = function ( element, options ) { + this.$element = $(element) + this.options = $.extend({}, $.fn.collapse.defaults, options) + + if (this.options["parent"]) { + this.$parent = $(this.options["parent"]) + } + + this.options.toggle && this.toggle() + } + + Collapse.prototype = { + + constructor: Collapse + + , dimension: function () { + var hasWidth = this.$element.hasClass('width') + return hasWidth ? 'width' : 'height' + } + + , show: function () { + var dimension = this.dimension() + , scroll = $.camelCase(['scroll', dimension].join('-')) + , actives = this.$parent && this.$parent.find('.in') + , hasData + + if (actives && actives.length) { + hasData = actives.data('collapse') + actives.collapse('hide') + hasData || actives.data('collapse', null) + } + + this.$element[dimension](0) + this.transition('addClass', 'show', 'shown') + this.$element[dimension](this.$element[0][scroll]) + + } + + , hide: function () { + var dimension = this.dimension() + this.reset(this.$element[dimension]()) + this.transition('removeClass', 'hide', 'hidden') + this.$element[dimension](0) + } + + , reset: function ( size ) { + var dimension = this.dimension() + + this.$element + .removeClass('collapse') + [dimension](size || 'auto') + [0].offsetWidth + + this.$element.addClass('collapse') + } + + , transition: function ( method, startEvent, completeEvent ) { + var that = this + , complete = function () { + if (startEvent == 'show') that.reset() + that.$element.trigger(completeEvent) + } + + this.$element + .trigger(startEvent) + [method]('in') + + $.support.transition && this.$element.hasClass('collapse') ? + this.$element.one($.support.transition.end, complete) : + complete() + } + + , toggle: function () { + this[this.$element.hasClass('in') ? 'hide' : 'show']() + } + + } + + /* COLLAPSIBLE PLUGIN DEFINITION + * ============================== */ + + $.fn.collapse = function ( option ) { + return this.each(function () { + var $this = $(this) + , data = $this.data('collapse') + , options = typeof option == 'object' && option + if (!data) $this.data('collapse', (data = new Collapse(this, options))) + if (typeof option == 'string') data[option]() + }) + } + + $.fn.collapse.defaults = { + toggle: true + } + + $.fn.collapse.Constructor = Collapse + + + /* COLLAPSIBLE DATA-API + * ==================== */ + + $(function () { + $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) { + var $this = $(this), href + , target = $this.attr('data-target') + || e.preventDefault() + || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7 + , option = $(target).data('collapse') ? 'toggle' : $this.data() + $(target).collapse(option) + }) + }) + +}( window.jQuery ) |