~argilsoft/+junk/pexego-addons-7.0

« back to all changes in this revision

Viewing changes to pexego-runbot/js/dropdown.js

  • Committer: Israel CA
  • Date: 2013-10-22 21:54:35 UTC
  • Revision ID: israel.cruz@hesatecnica.com-20131022215435-jo9l2iq7di64bqjn
Importación inicial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ============================================================
 
2
 * bootstrap-dropdown.js v2.0.2
 
3
 * http://twitter.github.com/bootstrap/javascript.html#dropdowns
 
4
 * ============================================================
 
5
 * Copyright 2012 Twitter, Inc.
 
6
 *
 
7
 * Licensed under the Apache License, Version 2.0 (the "License");
 
8
 * you may not use this file except in compliance with the License.
 
9
 * You may obtain a copy of the License at
 
10
 *
 
11
 * http://www.apache.org/licenses/LICENSE-2.0
 
12
 *
 
13
 * Unless required by applicable law or agreed to in writing, software
 
14
 * distributed under the License is distributed on an "AS IS" BASIS,
 
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
16
 * See the License for the specific language governing permissions and
 
17
 * limitations under the License.
 
18
 * ============================================================ */
 
19
 
 
20
 
 
21
!function( $ ){
 
22
 
 
23
  "use strict"
 
24
 
 
25
 /* DROPDOWN CLASS DEFINITION
 
26
  * ========================= */
 
27
 
 
28
  var toggle = '[data-toggle="dropdown"]'
 
29
    , Dropdown = function ( element ) {
 
30
        var $el = $(element).on('click.dropdown.data-api', this.toggle)
 
31
        $('html').on('click.dropdown.data-api', function () {
 
32
          $el.parent().removeClass('open')
 
33
        })
 
34
      }
 
35
 
 
36
  Dropdown.prototype = {
 
37
 
 
38
    constructor: Dropdown
 
39
 
 
40
  , toggle: function ( e ) {
 
41
      var $this = $(this)
 
42
        , selector = $this.attr('data-target')
 
43
        , $parent
 
44
        , isActive
 
45
 
 
46
      if (!selector) {
 
47
        selector = $this.attr('href')
 
48
        selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
 
49
      }
 
50
 
 
51
      $parent = $(selector)
 
52
      $parent.length || ($parent = $this.parent())
 
53
 
 
54
      isActive = $parent.hasClass('open')
 
55
 
 
56
      clearMenus()
 
57
      !isActive && $parent.toggleClass('open')
 
58
 
 
59
      return false
 
60
    }
 
61
 
 
62
  }
 
63
 
 
64
  function clearMenus() {
 
65
    $(toggle).parent().removeClass('open')
 
66
  }
 
67
 
 
68
 
 
69
  /* DROPDOWN PLUGIN DEFINITION
 
70
   * ========================== */
 
71
 
 
72
  $.fn.dropdown = function ( option ) {
 
73
    return this.each(function () {
 
74
      var $this = $(this)
 
75
        , data = $this.data('dropdown')
 
76
      if (!data) $this.data('dropdown', (data = new Dropdown(this)))
 
77
      if (typeof option == 'string') data[option].call($this)
 
78
    })
 
79
  }
 
80
 
 
81
  $.fn.dropdown.Constructor = Dropdown
 
82
 
 
83
 
 
84
  /* APPLY TO STANDARD DROPDOWN ELEMENTS
 
85
   * =================================== */
 
86
 
 
87
  $(function () {
 
88
    $('html').on('click.dropdown.data-api', clearMenus)
 
89
    $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
 
90
  })
 
91
 
 
92
}( window.jQuery );
 
 
b'\\ No newline at end of file'