aboutsummaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/README.md4
-rw-r--r--js/bootstrap-collapse.js4
-rw-r--r--js/bootstrap-modal.js2
-rw-r--r--js/bootstrap-scrollspy.js4
-rw-r--r--js/bootstrap-tab.js102
-rw-r--r--js/bootstrap-tabs.js80
-rw-r--r--js/bootstrap-transition.js (renamed from js/bootstrap-transitions.js)0
7 files changed, 110 insertions, 86 deletions
diff --git a/js/README.md b/js/README.md
index 98be75421..5224d65b7 100644
--- a/js/README.md
+++ b/js/README.md
@@ -67,14 +67,14 @@ All events should have an infinitive and past participle form. The infinitive is
Data attributes should take the following form:
data-*(verb)* - defines main interaction
-data-target - defined on controller element (if element interacts with an element other than self)
+data-target || href^=# - defined on controller element (if element interacts with an element other than self)
data-*(noun)* - defines options for element invocation
examples:
// control other targets
data-toggle="modal" data-target="#foo"
- data-toggle="view" data-target="#foo"
+ data-toggle="collapse" data-target="#foo" data-parent="#foo"
// defined on element they control
data-spy="scroll"
diff --git a/js/bootstrap-collapse.js b/js/bootstrap-collapse.js
index 6de3d971a..629d9b589 100644
--- a/js/bootstrap-collapse.js
+++ b/js/bootstrap-collapse.js
@@ -117,9 +117,9 @@
$(function () {
$('body').delegate('[data-toggle=collapse]', 'click.collapse.data-api', function ( e ) {
var $this = $(this)
- , target = $this.attr('data-target')
+ , target = $this.attr('data-target') || $this.attr('href')
, option = $(target).data('collapse') ? 'toggle' : $this.data()
- e.preventDefault()
+ e.preventDefault()
$(target).collapse(option)
})
})
diff --git a/js/bootstrap-modal.js b/js/bootstrap-modal.js
index dab67d1b2..5f543c553 100644
--- a/js/bootstrap-modal.js
+++ b/js/bootstrap-modal.js
@@ -192,7 +192,7 @@
$(document).ready(function () {
$('body').delegate('[data-toggle="modal"]', 'click.modal.data-api', function ( e ) {
var $this = $(this)
- , target = $this.attr('data-target')
+ , target = $this.attr('data-target') || $this.attr('href')
, option = $(target).data('modal') ? 'toggle' : $this.data()
e.preventDefault()
$(target).modal(option)
diff --git a/js/bootstrap-scrollspy.js b/js/bootstrap-scrollspy.js
index e4bfea483..fe34019ff 100644
--- a/js/bootstrap-scrollspy.js
+++ b/js/bootstrap-scrollspy.js
@@ -28,7 +28,9 @@
var process = $.proxy(this.process, this)
this.$scrollElement = $(element).bind('scroll.scroll.data-api', process)
- this.selector = (this.$scrollElement.attr('data-target') || '') + ' .nav li > a'
+ this.selector = (this.$scrollElement.attr('data-target')
+ || this.$scrollElement.attr('href')
+ || '') + ' .nav li > a'
this.$body = $('body').delegate(this.selector, 'click.scroll.data-api', process)
this.refresh()
diff --git a/js/bootstrap-tab.js b/js/bootstrap-tab.js
new file mode 100644
index 000000000..ba956cbe8
--- /dev/null
+++ b/js/bootstrap-tab.js
@@ -0,0 +1,102 @@
+/* ========================================================
+ * bootstrap-tabs.js v2.0.0
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
+ * ========================================================
+ * Copyright 2011 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"
+
+ /* TAB CLASS DEFINITION
+ * ==================== */
+
+ var Tab = function ( element ) {
+ this.element = $(element)
+ }
+
+ Tab.prototype = {
+
+ show: function () {
+ var $this = this.element
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
+ , href = $this.attr('data-target') || $this.attr('href')
+ , previous
+ , $href
+
+ if ( $this.parent('li').hasClass('active') ) return
+
+ previous = $ul.find('.active a').last()[0]
+
+ $this.trigger({
+ type: 'show'
+ , relatedTarget: previous
+ })
+
+ $href = $(href)
+
+ this.activate($this.parent('li'), $ul)
+ this.activate($href, $href.parent())
+
+ $this.trigger({
+ type: 'shown'
+ , relatedTarget: previous
+ })
+ }
+
+ , activate: function ( element, container ) {
+ container
+ .find('> .active')
+ .removeClass('active')
+ .find('> .dropdown-menu > .active')
+ .removeClass('active')
+
+ element.addClass('active')
+
+ if ( element.parent('.dropdown-menu') ) {
+ element.closest('li.dropdown').addClass('active')
+ }
+ }
+ }
+
+
+ /* TAB PLUGIN DEFINITION
+ * ===================== */
+
+ $.fn.tab = function (option) {
+ return this.each(function () {
+ var $this = $(this)
+ , data = $this.data('tab')
+ if (!data) $this.data('tab', (data = new Tab(this)))
+ if (typeof option == 'string') data[option]()
+ })
+ }
+
+ $.fn.tab.Tab = Tab
+
+
+ /* TAB DATA-API
+ * ============ */
+
+ $(document).ready(function () {
+ $('body').delegate('[data-toggle="tab"], [data-toggle="pill"]', 'click.tab.data-api', function (e) {
+ e.preventDefault()
+ $(this).tab('show')
+ })
+ })
+
+}( window.jQuery || window.ender ) \ No newline at end of file
diff --git a/js/bootstrap-tabs.js b/js/bootstrap-tabs.js
deleted file mode 100644
index bd49e130f..000000000
--- a/js/bootstrap-tabs.js
+++ /dev/null
@@ -1,80 +0,0 @@
-/* ========================================================
- * bootstrap-tabs.js v2.0.0
- * http://twitter.github.com/bootstrap/javascript.html#tabs
- * ========================================================
- * Copyright 2011 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"
-
- function activate ( element, container ) {
- container
- .find('> .active')
- .removeClass('active')
- .find('> .dropdown-menu > .active')
- .removeClass('active')
-
- element.addClass('active')
-
- if ( element.parent('.dropdown-menu') ) {
- element.closest('li.dropdown').addClass('active')
- }
- }
-
- function tab( e ) {
- var $this = $(this)
- , $ul = $this.closest('ul:not(.dropdown-menu)')
- , href = $this.attr('href')
- , previous
- , $href
-
- if ( /^#\w+/.test(href) ) {
- e.preventDefault()
-
- if ( $this.parent('li').hasClass('active') ) {
- return
- }
-
- previous = $ul.find('.active a').last()[0]
- $href = $(href)
-
- activate($this.parent('li'), $ul)
- activate($href, $href.parent())
-
- $this.trigger({
- type: 'change'
- , relatedTarget: previous
- })
- }
- }
-
-
- /* TABS/PILLS PLUGIN DEFINITION
- * ============================ */
-
- $.fn.tabs = $.fn.pills = function ( selector ) {
- return this.each(function () {
- $(this).delegate(selector || '.tabs li > a, .pills > li > a', 'click', tab)
- })
- }
-
- $(document).ready(function () {
- $('body').tabs('ul[data-tabs] li > a, ul[data-pills] > li > a')
- })
-
-}( window.jQuery || window.ender ) \ No newline at end of file
diff --git a/js/bootstrap-transitions.js b/js/bootstrap-transition.js
index 25f8b111f..25f8b111f 100644
--- a/js/bootstrap-transitions.js
+++ b/js/bootstrap-transition.js