diff options
| author | Mark Otto <[email protected]> | 2012-04-14 23:07:51 -0700 |
|---|---|---|
| committer | Mark Otto <[email protected]> | 2012-04-14 23:07:51 -0700 |
| commit | 2dbce887df8ffec477929c92085745af9b93feaa (patch) | |
| tree | 09fbf6161b08eef8e66a5089b3b1f6886324164f | |
| parent | a6f27ebed440919aac6f62e73e6748bfecd00ab9 (diff) | |
| parent | c7dc4cc573c61306ae849d316f432160b16a2099 (diff) | |
| download | bootstrap-2dbce887df8ffec477929c92085745af9b93feaa.tar.xz bootstrap-2dbce887df8ffec477929c92085745af9b93feaa.zip | |
Merge branch '2.0.3-wip' of github.com:twitter/bootstrap into 2.0.3-wip
Conflicts:
docs/assets/bootstrap.zip
| -rw-r--r-- | Makefile | 2 | ||||
| -rw-r--r-- | docs/assets/bootstrap.zip | bin | 71446 -> 71484 bytes | |||
| -rw-r--r-- | docs/assets/js/bootstrap-dropdown.js | 6 | ||||
| -rw-r--r-- | js/bootstrap-dropdown.js | 6 | ||||
| -rw-r--r-- | js/tests/unit/bootstrap-dropdown.js | 34 |
5 files changed, 44 insertions, 4 deletions
@@ -2,8 +2,6 @@ BOOTSTRAP = ./docs/assets/css/bootstrap.css BOOTSTRAP_LESS = ./less/bootstrap.less BOOTSTRAP_RESPONSIVE = ./docs/assets/css/bootstrap-responsive.css BOOTSTRAP_RESPONSIVE_LESS = ./less/responsive.less -LESS_COMPRESSOR ?= `which lessc` -WATCHR ?= `which watchr` # # BUILD DOCS diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip Binary files differindex 4aae825c5..4e3217a76 100644 --- a/docs/assets/bootstrap.zip +++ b/docs/assets/bootstrap.zip diff --git a/docs/assets/js/bootstrap-dropdown.js b/docs/assets/js/bootstrap-dropdown.js index f27f4d2f4..d856ba6ec 100644 --- a/docs/assets/js/bootstrap-dropdown.js +++ b/docs/assets/js/bootstrap-dropdown.js @@ -40,10 +40,14 @@ , toggle: function (e) { var $this = $(this) - , selector = $this.attr('data-target') , $parent + , selector , isActive + if ($this.is('.disabled, :disabled')) return + + selector = $this.attr('data-target') + if (!selector) { selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 diff --git a/js/bootstrap-dropdown.js b/js/bootstrap-dropdown.js index f27f4d2f4..d856ba6ec 100644 --- a/js/bootstrap-dropdown.js +++ b/js/bootstrap-dropdown.js @@ -40,10 +40,14 @@ , toggle: function (e) { var $this = $(this) - , selector = $this.attr('data-target') , $parent + , selector , isActive + if ($this.is('.disabled, :disabled')) return + + selector = $this.attr('data-target') + if (!selector) { selector = $this.attr('href') selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 diff --git a/js/tests/unit/bootstrap-dropdown.js b/js/tests/unit/bootstrap-dropdown.js index 368ced2a5..4e52c8485 100644 --- a/js/tests/unit/bootstrap-dropdown.js +++ b/js/tests/unit/bootstrap-dropdown.js @@ -10,6 +10,40 @@ $(function () { ok($(document.body).dropdown()[0] == document.body, 'document.body returned') }) + test("should not open dropdown if target is disabled", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<button disabled href="#" class="btn dropdown-toggle" data-toggle="dropdown">Dropdown</button>' + + '<ul class="dropdown-menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"></li>' + + '<li><a href="#">Another link</a></li>' + + '</ul>' + + '</li>' + + '</ul>' + , dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + + ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') + }) + + test("should not open dropdown if target is disabled", function () { + var dropdownHTML = '<ul class="tabs">' + + '<li class="dropdown">' + + '<button href="#" class="btn dropdown-toggle disabled" data-toggle="dropdown">Dropdown</button>' + + '<ul class="dropdown-menu">' + + '<li><a href="#">Secondary link</a></li>' + + '<li><a href="#">Something else here</a></li>' + + '<li class="divider"></li>' + + '<li><a href="#">Another link</a></li>' + + '</ul>' + + '</li>' + + '</ul>' + , dropdown = $(dropdownHTML).find('[data-toggle="dropdown"]').dropdown().click() + + ok(!dropdown.parent('.dropdown').hasClass('open'), 'open class added on click') + }) + test("should add class open to menu if clicked", function () { var dropdownHTML = '<ul class="tabs">' + '<li class="dropdown">' |
