comparison static/bootstrap/js/bootstrap-dropdown.js @ 88:a5a3d454eac9

Updated Bootstrap.
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 05 Apr 2013 08:08:12 -0700
parents 130eccd396d8
children
comparison
equal deleted inserted replaced
87:c0cf67362fb1 88:a5a3d454eac9
1 /* ============================================================ 1 /* ============================================================
2 * bootstrap-dropdown.js v2.2.2 2 * bootstrap-dropdown.js v2.3.1
3 * http://twitter.github.com/bootstrap/javascript.html#dropdowns 3 * http://twitter.github.com/bootstrap/javascript.html#dropdowns
4 * ============================================================ 4 * ============================================================
5 * Copyright 2012 Twitter, Inc. 5 * Copyright 2012 Twitter, Inc.
6 * 6 *
7 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * Licensed under the Apache License, Version 2.0 (the "License");
79 79
80 $parent = getParent($this) 80 $parent = getParent($this)
81 81
82 isActive = $parent.hasClass('open') 82 isActive = $parent.hasClass('open')
83 83
84 if (!isActive || (isActive && e.keyCode == 27)) return $this.click() 84 if (!isActive || (isActive && e.keyCode == 27)) {
85 if (e.which == 27) $parent.find(toggle).focus()
86 return $this.click()
87 }
85 88
86 $items = $('[role=menu] li:not(.divider):visible a', $parent) 89 $items = $('[role=menu] li:not(.divider):visible a', $parent)
87 90
88 if (!$items.length) return 91 if (!$items.length) return
89 92
113 if (!selector) { 116 if (!selector) {
114 selector = $this.attr('href') 117 selector = $this.attr('href')
115 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 118 selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
116 } 119 }
117 120
118 $parent = $(selector) 121 $parent = selector && $(selector)
119 $parent.length || ($parent = $this.parent()) 122
123 if (!$parent || !$parent.length) $parent = $this.parent()
120 124
121 return $parent 125 return $parent
122 } 126 }
123 127
124 128
150 154
151 /* APPLY TO STANDARD DROPDOWN ELEMENTS 155 /* APPLY TO STANDARD DROPDOWN ELEMENTS
152 * =================================== */ 156 * =================================== */
153 157
154 $(document) 158 $(document)
155 .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus) 159 .on('click.dropdown.data-api', clearMenus)
156 .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() }) 160 .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
157 .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() }) 161 .on('click.dropdown-menu', function (e) { e.stopPropagation() })
158 .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle) 162 .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
159 .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown) 163 .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
160 164
161 }(window.jQuery); 165 }(window.jQuery);