diff --git a/app/views/layouts/_javascripts.html.erb b/app/views/layouts/_javascripts.html.erb index 5ff356a54a2..ec89ef3469a 100644 --- a/app/views/layouts/_javascripts.html.erb +++ b/app/views/layouts/_javascripts.html.erb @@ -13,7 +13,7 @@ -<%= 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 %> diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 8feebccd30d..59a6de5f193 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -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 diff --git a/public/javascripts/bootstrap/bootstrap-dropdown.js b/public/javascripts/bootstrap/bootstrap-dropdown.js index 7754b539c7e..716b39924d6 100644 --- a/public/javascripts/bootstrap/bootstrap-dropdown.js +++ b/public/javascripts/bootstrap/bootstrap-dropdown.js @@ -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. @@ -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 ;_; @@ -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) @@ -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 } @@ -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) { diff --git a/public/javascripts/bootstrap/bootstrap-dropdown.min.js b/public/javascripts/bootstrap/bootstrap-dropdown.min.js new file mode 100644 index 00000000000..45ab63130c2 --- /dev/null +++ b/public/javascripts/bootstrap/bootstrap-dropdown.min.js @@ -0,0 +1 @@ +!function(e){"use strict";function r(){e(t).each(function(){i(e(this)).removeClass("open")})}function i(t){var n=t.attr("data-target"),r;if(!n){n=t.attr("href");n=n&&/#/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,"")}r=n&&e(n);if(!r||!r.length)r=t.parent();return r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;s=i(n);o=s.hasClass("open");r();if(o){s.children("ul").hide();n.blur()}else{s.toggleClass("open").children("ul").removeAttr("style");n.focus()}n.focus();return false},keydown:function(n){var r,s,o,u,a,f;if(!/(38|40|27)/.test(n.keyCode))return;r=e(this);n.preventDefault();n.stopPropagation();if(r.is(".disabled, :disabled"))return;u=i(r);a=u.hasClass("open");if(!a||a&&n.keyCode==27){if(n.which==27)u.find(t).focus();return r.click()}s=e("[role=menu] li:not(.divider):visible a",u);if(!s.length)return;f=s.index(s.filter(":focus"));if(n.keyCode==38&&f>0)f--;if(n.keyCode==40&&f