]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
greatly simply js plugins - remove js api where reasonable
authorJacob Thornton <jacobthornton@gmail.com>
Thu, 20 Oct 2011 04:56:06 +0000 (21:56 -0700)
committerJacob Thornton <jacobthornton@gmail.com>
Thu, 20 Oct 2011 04:56:06 +0000 (21:56 -0700)
docs/assets/js/application.js
js/bootstrap-accordion.js [new file with mode: 0644]
js/bootstrap-alerts.js
js/bootstrap-dropdown.js
js/bootstrap-modal.js
js/bootstrap-popover.js
js/bootstrap-scrollspy.js
js/bootstrap-tabs.js
js/bootstrap-transitions.js [new file with mode: 0644]
js/bootstrap-twipsy.js

index 16a20e068e235f8fc7bfa94e9f8403687b68418a..74024caa1d8fab6e8fd06c8540af44023b2d049c 100644 (file)
@@ -1,4 +1,4 @@
-$(document).ready(function(){
+$(function(){
 
   // table sort example
   // ==================
diff --git a/js/bootstrap-accordion.js b/js/bootstrap-accordion.js
new file mode 100644 (file)
index 0000000..b880576
--- /dev/null
@@ -0,0 +1,41 @@
+/* =============================================================
+ * bootstrap-accordion.js v1.3.0
+ * http://twitter.github.com/bootstrap/javascript.html#accordion
+ * =============================================================
+ * 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( $ ){
+
+  var Accordion = function ( element, options ) {}
+
+  Accordion.prototype = {}
+
+  /* ALERT PLUGIN DEFINITION
+   * ======================= */
+
+  $.fn.accordion = function ( options ) {
+
+    if ( options === true ) {
+     return this.data('accordion')
+    }
+
+    return this.each(function () {
+      new Accordion(this, options)
+    })
+  }
+
+
+})( window.jQuery || window.ender )
\ No newline at end of file
index 4498270cb9eb0b23512756a56009a3de3800c9c5..bac92deb8aa4e3a114d5647a6eca55280f10d991 100644 (file)
  * limitations under the License.
  * ========================================================== */
 
-
 (function( $ ){
 
-  /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
-   * ======================================================= */
-
-   var transitionEnd
-
-   $(document).ready(function () {
-
-     $.support.transition = (function () {
-       var thisBody = document.body || document.documentElement
-         , thisStyle = thisBody.style
-         , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
-       return support
-     })()
-
-     // set CSS transition event type
-     if ( $.support.transition ) {
-       transitionEnd = "TransitionEnd"
-       if ( $.browser.webkit ) {
-               transitionEnd = "webkitTransitionEnd"
-       } else if ( $.browser.mozilla ) {
-               transitionEnd = "transitionend"
-       } else if ( $.browser.opera ) {
-               transitionEnd = "oTransitionEnd"
-       }
-     }
-
-   })
-
  /* ALERT CLASS DEFINITION
   * ====================== */
 
-  var Alert = function ( content, selector ) {
-    this.$element = $(content)
-      .delegate('[data-alert-dismiss]', 'click', this.close)
-  }
-
-  Alert.prototype = {
-
-    close: function (e) {
-      var $element = $(this).parent('.alert-message')
+  function close(e) {
+    var $element = $(this).parent('.alert-message')
 
-      e && e.preventDefault()
-      e && e.stopPropagation()
+    e && e.preventDefault()
+    $element.removeClass('in')
 
-      $element.removeClass('in')
-
-      function removeElement () {
-        $element.remove()
-      }
-
-      $.support.transition && $element.hasClass('fade') ?
-        $element.bind(transitionEnd, removeElement) :
-        removeElement()
+    function removeElement () {
+      $element.remove()
     }
 
+    $.support.transition && $element.hasClass('fade') ?
+      $element.bind($.support.transition.end, removeElement) :
+      removeElement()
   }
 
 
  /* ALERT PLUGIN DEFINITION
   * ======================= */
 
-  $.fn.alert = function ( options ) {
-
-    if ( options === true ) {
-      return this.data('alert')
-    }
-
-    return this.each(function () {
-      var $this = $(this)
-
-      if ( typeof options == 'string' ) {
-        return $this.data('alert')[options]()
-      }
-
-      $(this).data('alert', new Alert( this ))
-
-    })
-  }
-
-  $(document).ready(function () {
-    new Alert($('body'))
+  $(function () {
+    $('body').delegate('[data-alert-dismiss]', 'click', close)
   })
 
 })( window.jQuery || window.ender )
\ No newline at end of file
index 6379653c56aeaa53241ab8e37a962acc15545aa9..6d9430b391704b0ff928f315152464600f8c072f 100644 (file)
 
 (function( $ ){
 
-  var d = '[data-dropdown]'
-
-  /* DROPDOWN PLUGIN DEFINITION
-   * ========================== */
-
-  $.fn.dropdown = function () {
-    return this.each(function () {
-      $(this).delegate(d, 'click', function (e) {
-        var li = $(this).parent('li')
-          , isActive = li.hasClass('open')
-
-        clearMenus()
-        !isActive && li.toggleClass('open')
-        return false
-      })
-    })
-  }
-
   /* APPLY TO STANDARD DROPDOWN ELEMENTS
    * =================================== */
 
   function clearMenus() {
-    $(d).parent('li').removeClass('open')
+    $(selector).parent('li').removeClass('open')
   }
 
   $(function () {
     $('html').bind("click", clearMenus)
-    $('body').dropdown()
+    $('body').delegate('[data-dropdown]', 'click', function (e) {
+      var li = $(this).parent('li')
+        , isActive = li.hasClass('open')
+      clearMenus()
+      !isActive && li.toggleClass('open')
+      return false
+    })
   })
 
 })( window.jQuery || window.ender )
\ No newline at end of file
index 60b83d58fd15de80da2ec6881980984fb83b8a91..02f8b2382799fc6098e3ad15c8959bf09f7e1460 100644 (file)
 
 !function( $ ){
 
- /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
-  * ======================================================= */
-
-  var transitionEnd
-
-  $(document).ready(function () {
-
-    $.support.transition = (function () {
-      var thisBody = document.body || document.documentElement
-        , thisStyle = thisBody.style
-        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
-      return support
-    })()
-
-    // set CSS transition event type
-    if ( $.support.transition ) {
-      transitionEnd = "TransitionEnd"
-      if ( $.browser.webkit ) {
-       transitionEnd = "webkitTransitionEnd"
-      } else if ( $.browser.mozilla ) {
-       transitionEnd = "transitionend"
-      } else if ( $.browser.opera ) {
-       transitionEnd = "oTransitionEnd"
-      }
-    }
-
-  })
-
-
  /* MODAL PUBLIC CLASS DEFINITION
   * ============================= */
 
         this.$element.trigger('show')
 
         escape.call(this)
-        backdrop.call(this, function () {
-          var transition = $.support.transition && that.$element.hasClass('fade')
-
-          that.$element
-            .appendTo(document.body)
-            .show()
-
-          if (transition) {
-            that.$element[0].offsetWidth // force reflow
-          }
-
-          that.$element
-            .addClass('in')
-
-          transition ?
-            that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
-            that.$element.trigger('shown')
-
-        })
+        backdrop.call(this)
 
         return this
       }
         }
 
         $.support.transition && this.$element.hasClass('fade') ?
-          this.$element.one(transitionEnd, removeElement) :
+          this.$element.one($.support.transition.end, removeElement) :
           removeElement()
 
         return this
  /* MODAL PRIVATE METHODS
   * ===================== */
 
-  function backdrop ( callback ) {
+  function backdrop () {
     var that = this
       , animate = this.$element.hasClass('fade') ? 'fade' : ''
+      , callback = $.proxy(show, this)
+
     if ( this.isShown && this.settings.backdrop ) {
       var doAnimate = $.support.transition && animate
 
       this.$backdrop.addClass('in')
 
       doAnimate ?
-        this.$backdrop.one(transitionEnd, callback) :
+        this.$backdrop.one($.support.transition.end, callback) :
         callback()
 
     } else if ( !this.isShown && this.$backdrop ) {
       }
 
       $.support.transition && this.$element.hasClass('fade')?
-        this.$backdrop.one(transitionEnd, removeElement) :
+        this.$backdrop.one($.support.transition.end, removeElement) :
         removeElement()
     } else if ( callback ) {
        callback()
     }
   }
 
+  function show() {
+    var transition = $.support.transition && that.$element.hasClass('fade')
+      , that = this
+
+    this.$element
+      .appendTo(document.body)
+      .show()
+
+    if (transition) {
+      this.$element[0].offsetWidth // force reflow
+    }
+
+    this.$element
+      .addClass('in')
+
+    transition ?
+      this.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
+      this.$element.trigger('shown')
+  }
+
   function escape() {
     var that = this
     if ( this.isShown && this.settings.keyboard ) {
  /* MODAL DATA-IMPLEMENTATION
   * ========================= */
 
-  $(document).ready(function () {
+  $(function () {
     $('body').delegate('[data-controls-modal]', 'click', function (e) {
       e.preventDefault()
       var $this = $(this).data('show', true)
index 1cf4b8917ad35c1256ef9676ff1f372e80b2264e..22db98fd9b882f666ae40148b19acb7e1b95303b 100644 (file)
@@ -62,7 +62,6 @@
 
   })
 
-
  /* POPOVER PLUGIN DEFINITION
   * ======================= */
 
index 4b146e58093666ab7eac3330b9c289e7887165dc..23bdf59e9c84cdb65ffdfccf253c221718a5949b 100644 (file)
 
   }
 
-  /* SCROLLSPY PLUGIN DEFINITION
-   * =========================== */
-
-  $.fn.scrollSpy = function( options ) {
-    var scrollspy = this.data('scrollspy')
-
-    if (!scrollspy) {
-      return this.each(function () {
-        $(this).data('scrollspy', new ScrollSpy( this, options ))
-      })
-    }
-
-    if ( options === true ) {
-      return scrollspy
-    }
-
-    if ( typeof options == 'string' ) {
-      scrollspy[options]()
-    }
-
-    return this
-  }
-
-  $(document).ready(function () {
+  $(function () {
     $('body').scrollSpy('[data-scrollspy] li > a')
   })
 
index b94adfc25dea86c3ca25c78e1292b1c3fd3de25a..6ee80429c784d635e731241f0a71ed11b25d3b5b 100644 (file)
  /* 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')
+  $(function () {
+    $('body').delegate('ul[data-tabs] > li > a, ul[data-pills] > li > a', 'click', tab)
   })
 
 }( window.jQuery || window.ender );
\ No newline at end of file
diff --git a/js/bootstrap-transitions.js b/js/bootstrap-transitions.js
new file mode 100644 (file)
index 0000000..49b5338
--- /dev/null
@@ -0,0 +1,45 @@
+/* ===================================================
+ * bootstrap-transitions.js v2.0.0
+ * http://twitter.github.com/bootstrap/javascript.html
+ * ===================================================
+ * 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 () {
+
+  /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
+   * ======================================================= */
+
+  $.support.transition = (function () {
+    var thisBody = document.body || document.documentElement
+      , thisStyle = thisBody.style
+      , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
+
+    return support && {
+      end: (function () {
+        var transitionEnd = "TransitionEnd"
+        if ( $.browser.webkit ) {
+               transitionEnd = "webkitTransitionEnd"
+        } else if ( $.browser.mozilla ) {
+               transitionEnd = "transitionend"
+        } else if ( $.browser.opera ) {
+               transitionEnd = "oTransitionEnd"
+        }
+        return transitionEnd
+      })()
+    }
+  })()
+
+})
\ No newline at end of file
index 0144c48158ae764c837e93f333bbed46601856b2..c44395e08ec00114ac15c88a75f9ea8a5504e739 100644 (file)
 
 !function( $ ) {
 
- /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
-  * ======================================================= */
-
-  var transitionEnd
-
-  $(document).ready(function () {
-
-    $.support.transition = (function () {
-      var thisBody = document.body || document.documentElement
-        , thisStyle = thisBody.style
-        , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
-      return support
-    })()
-
-    // set CSS transition event type
-    if ( $.support.transition ) {
-      transitionEnd = "TransitionEnd"
-      if ( $.browser.webkit ) {
-       transitionEnd = "webkitTransitionEnd"
-      } else if ( $.browser.mozilla ) {
-       transitionEnd = "transitionend"
-      } else if ( $.browser.opera ) {
-       transitionEnd = "oTransitionEnd"
-      }
-    }
-
-  })
-
-
  /* TWIPSY PUBLIC CLASS DEFINITION
   * ============================== */
 
       }
 
       $.support.transition && this.$tip.hasClass('fade') ?
-        $tip.bind(transitionEnd, removeElement) :
+        $tip.bind($.support.transition.end, removeElement) :
         removeElement()
     }