Skip to content

Commit

Permalink
Merge pull request #1220 from sarken/issue_3604
Browse files Browse the repository at this point in the history
3604 Update dropdown plugin
  • Loading branch information
CristinaRO committed Jun 19, 2014
2 parents a43d2b5 + e2c6ec7 commit 53e34cb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/views/layouts/_javascripts.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</script>

<script type="text/javascript">$j = jQuery.noConflict();</script>
<%= javascript_include_tag "jquery.scrollTo.min.js", "jquery.livequery.min", "rails", "application", "bootstrap/bootstrap-dropdown.js", "jquery-shuffle", "jquery.tokeninput", "jquery.trap.min", "ao3modal.min", "jquery.cookie" %>
<%= javascript_include_tag "jquery.scrollTo.min.js", "jquery.livequery.min", "rails", "application", "bootstrap/bootstrap-dropdown.min.js", "jquery-shuffle", "jquery.tokeninput", "jquery.trap.min", "ao3modal.min", "jquery.cookie" %>
<% if allow_tinymce?(controller) %>
<%= yield :tinymce_init %>
Expand Down
8 changes: 4 additions & 4 deletions public/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,14 @@ jQuery.fn.preventDoubleSubmit = function() {

// add attributes that are only needed in the primary menus and when JavaScript is enabled
function setupDropdown(){
$j('#header .dropdown').attr("aria-haspopup", true);
$j('#header .dropdown > a, #header .dropdown .actions > a').attr({
$j('#header').find('.dropdown').attr("aria-haspopup", true);
$j('#header').find('.dropdown, .dropdown .actions').children('a').attr({
'class': 'dropdown-toggle',
'data-toggle': 'dropdown',
'data-target': '#'
});
$j('.dropdown .menu').addClass("dropdown-menu");
$j('.dropdown .menu li').attr("role", "menu-item");
$j('.dropdown').find('.menu').addClass("dropdown-menu");
$j('.dropdown').find('.menu').children('li').attr("role", "menu-item");
}

// Accordion-style collapsible widgets
Expand Down
29 changes: 17 additions & 12 deletions public/javascripts/bootstrap/bootstrap-dropdown.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ============================================================
* bootstrap-dropdown.js v2.2.2
* bootstrap-dropdown.js v2.3.1
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
* ============================================================
* Copyright 2012 Twitter, Inc.
Expand All @@ -15,15 +15,16 @@
* 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.
* ==========================================================
* OTWARCHVIE DEVS:
* ============================================================
* OTWARCHIVE DEVS:
*
* When updating to the newest version, make sure to include the
* customizations from LINES 60-68 AND 172-178 and UPDATE THIS
* customizations from LINES 61-69 AND 177-183 and UPDATE THIS
* MESSAGE with the new line numbers. These lines ensure proper
* behavior when both JS and CSS hover are used for menus
* ========================================================== */


!function ($) {

"use strict"; // jshint ;_;
Expand Down Expand Up @@ -93,7 +94,10 @@

isActive = $parent.hasClass('open')

if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).focus()
return $this.click()
}

$items = $('[role=menu] li:not(.divider):visible a', $parent)

Expand Down Expand Up @@ -127,8 +131,9 @@
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}

$parent = $(selector)
$parent.length || ($parent = $this.parent())
$parent = selector && $(selector)

if (!$parent || !$parent.length) $parent = $this.parent()

return $parent
}
Expand Down Expand Up @@ -164,11 +169,11 @@
* =================================== */

$(document)
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown-menu', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
.on('mouseenter', '.dropdown', function (e) {
var $parent = $(this)
if ($parent.siblings('.open').length) {
Expand Down
1 change: 1 addition & 0 deletions public/javascripts/bootstrap/bootstrap-dropdown.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53e34cb

Please sign in to comment.