From a72c635c7669933204c17bf85cfe3d4fc350c73a Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 11 Nov 2013 19:03:37 +0100 Subject: [PATCH 0001/1647] fix(collapse): remove element height watching For unclear reasons the directive was watching DOM element's height which incurs performance penalty. Normally this watching shouldn't be necessery as collapsible elements should get height: auto; Closes #1222 --- src/collapse/collapse.js | 18 +----------------- src/collapse/test/collapse.spec.js | 16 ---------------- 2 files changed, 1 insertion(+), 33 deletions(-) diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index d0a33b454f..d36c9a438f 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -22,23 +22,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition']) var isCollapsed; var initialAnimSkip = true; - scope.$watch(function (){ return element[0].scrollHeight; }, function (value) { - //The listener is called when scollHeight changes - //It actually does on 2 scenarios: - // 1. Parent is set to display none - // 2. angular bindings inside are resolved - //When we have a change of scrollHeight we are setting again the correct height if the group is opened - if (element[0].scrollHeight !== 0) { - if (!isCollapsed) { - if (initialAnimSkip) { - fixUpHeight(scope, element, element[0].scrollHeight + 'px'); - } else { - fixUpHeight(scope, element, 'auto'); - } - } - } - }); - + scope.$watch(attrs.collapse, function(value) { if (value) { collapse(); diff --git a/src/collapse/test/collapse.spec.js b/src/collapse/test/collapse.spec.js index d04a8b3c90..d3784ad4c6 100644 --- a/src/collapse/test/collapse.spec.js +++ b/src/collapse/test/collapse.spec.js @@ -86,21 +86,5 @@ describe('collapse directive', function () { expect(element.height()).toBeLessThan(collapseHeight); }); - it('should shrink accordingly when content size inside collapse decreases on subsequent use', function() { - scope.isCollapsed = false; - scope.exp = false; - scope.$digest(); - scope.isCollapsed = true; - scope.$digest(); - scope.isCollapsed = false; - scope.$digest(); - $timeout.flush(); - scope.exp = true; - scope.$digest(); - var collapseHeight = element.height(); - scope.exp = false; - scope.$digest(); - expect(element.height()).toBeLessThan(collapseHeight); - }); }); }); \ No newline at end of file From 9eca35a8de12287b0ec70b01fac4b243936c8d08 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Mon, 11 Nov 2013 19:10:37 +0100 Subject: [PATCH 0002/1647] fix(collapse): add the "in" class for expanded panels Closes #1192 --- src/collapse/collapse.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/collapse/collapse.js b/src/collapse/collapse.js index d36c9a438f..3469d6ad37 100644 --- a/src/collapse/collapse.js +++ b/src/collapse/collapse.js @@ -50,6 +50,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition']) initialAnimSkip = false; if ( !isCollapsed ) { fixUpHeight(scope, element, 'auto'); + element.addClass('in'); } } else { doTransition({ height : element[0].scrollHeight + 'px' }) @@ -58,6 +59,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition']) // the group while the animation was still running if ( !isCollapsed ) { fixUpHeight(scope, element, 'auto'); + element.addClass('in'); } }); } @@ -66,6 +68,7 @@ angular.module('ui.bootstrap.collapse',['ui.bootstrap.transition']) var collapse = function() { isCollapsed = true; + element.removeClass('in'); if (initialAnimSkip) { initialAnimSkip = false; fixUpHeight(scope, element, 0); From a7bd3169a911df6794a5a8786bf40848658bd988 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Tue, 12 Nov 2013 18:03:57 +0100 Subject: [PATCH 0003/1647] chore(readme): add a note in readme about custom build --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 2c0c908c17..48a93b5a29 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,10 @@ All the directives in this repository should have their markup externalized as t Each directive has its own AngularJS module without any dependencies on other modules or third-pary JavaScript code. In practice it means that you can **just grab the code for the directives you need** and you are not obliged to drag the whole repository. +You can also make a custom build with the grunt command line. e.g: + + grunt build:modal:tabs:alert:popover:dropdownToggle:buttons:progressbar + ### Quality and stability Directives should work. All the time and in all browsers. This is why all the directives have a comprehensive suite of unit tests. All the automated tests are executed on each checkin in several browsers: Chrome, ChromeCanary, Firefox, Opera, Safari, IE9. From b3b2a9845b678eb949f9a3ce695718806a381317 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Wed, 13 Nov 2013 19:30:59 +0100 Subject: [PATCH 0004/1647] docs(README): info on building a subset of modules --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 48a93b5a29..761d1c007b 100644 --- a/README.md +++ b/README.md @@ -61,10 +61,6 @@ All the directives in this repository should have their markup externalized as t Each directive has its own AngularJS module without any dependencies on other modules or third-pary JavaScript code. In practice it means that you can **just grab the code for the directives you need** and you are not obliged to drag the whole repository. -You can also make a custom build with the grunt command line. e.g: - - grunt build:modal:tabs:alert:popover:dropdownToggle:buttons:progressbar - ### Quality and stability Directives should work. All the time and in all browsers. This is why all the directives have a comprehensive suite of unit tests. All the automated tests are executed on each checkin in several browsers: Chrome, ChromeCanary, Firefox, Opera, Safari, IE9. @@ -84,6 +80,13 @@ We are always looking for the quality contributions! Please check the [CONTRIBUT * Build the whole project: `grunt` - this will run `lint`, `test`, and `concat` targets * To build modules, first run `grunt html2js` then `grunt build:module1:module2...:moduleN` +You can generate a custom build, containing only needed modules, from the project's homepage. +Alternativelly you can run local Grunt build from the command line and list needed modules as shown below: + +``` +grunt build:modal:tabs:alert:popover:dropdownToggle:buttons:progressbar +``` + Check the Grunt build file for other tasks that are defined for this project. #### TDD From d290fd2b54276c74327d99d68d851fcde7c988c0 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Wed, 13 Nov 2013 21:06:59 +0100 Subject: [PATCH 0005/1647] refactor(modal): remove unused templates --- template/dialog/message.html | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 template/dialog/message.html diff --git a/template/dialog/message.html b/template/dialog/message.html deleted file mode 100644 index c2c1db5882..0000000000 --- a/template/dialog/message.html +++ /dev/null @@ -1,9 +0,0 @@ - - - From 127ab70dc3e2b3c096b01e5071d35da6186ea2dc Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sun, 17 Nov 2013 12:42:01 +0100 Subject: [PATCH 0006/1647] style(all): rename test files to keep extensions consistent --- src/accordion/test/{accordionSpec.js => accordion.spec.js} | 0 .../test/{dropdownToggleSpec.js => dropdownToggle.spec.js} | 0 src/popover/test/{popoverSpec.js => popover.spec.js} | 0 src/tabs/test/{tabsSpec.js => tabs.spec.js} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename src/accordion/test/{accordionSpec.js => accordion.spec.js} (100%) rename src/dropdownToggle/test/{dropdownToggleSpec.js => dropdownToggle.spec.js} (100%) rename src/popover/test/{popoverSpec.js => popover.spec.js} (100%) rename src/tabs/test/{tabsSpec.js => tabs.spec.js} (100%) diff --git a/src/accordion/test/accordionSpec.js b/src/accordion/test/accordion.spec.js similarity index 100% rename from src/accordion/test/accordionSpec.js rename to src/accordion/test/accordion.spec.js diff --git a/src/dropdownToggle/test/dropdownToggleSpec.js b/src/dropdownToggle/test/dropdownToggle.spec.js similarity index 100% rename from src/dropdownToggle/test/dropdownToggleSpec.js rename to src/dropdownToggle/test/dropdownToggle.spec.js diff --git a/src/popover/test/popoverSpec.js b/src/popover/test/popover.spec.js similarity index 100% rename from src/popover/test/popoverSpec.js rename to src/popover/test/popover.spec.js diff --git a/src/tabs/test/tabsSpec.js b/src/tabs/test/tabs.spec.js similarity index 100% rename from src/tabs/test/tabsSpec.js rename to src/tabs/test/tabs.spec.js From 0d810acdb9f075245aaece032283f706c4baaf3f Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Sun, 17 Nov 2013 14:08:01 +0100 Subject: [PATCH 0007/1647] fix(tooltip): tackle DOM node and event handlers leak Closes #1133 --- src/tooltip/test/tooltip.spec.js | 1 - src/tooltip/tooltip.js | 25 +++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/tooltip/test/tooltip.spec.js b/src/tooltip/test/tooltip.spec.js index d2b7d7a2b9..cac92712f2 100644 --- a/src/tooltip/test/tooltip.spec.js +++ b/src/tooltip/test/tooltip.spec.js @@ -332,7 +332,6 @@ describe('tooltip', function() { expect( inCache() ).toBeTruthy(); elm.trigger('fooTrigger'); elmScope.$destroy(); - $timeout.flush(); expect( inCache() ).toBeFalsy(); })); }); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index cf6256c7e3..987cb410dc 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -100,7 +100,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap 'title="'+startSym+'tt_title'+endSym+'" '+ 'content="'+startSym+'tt_content'+endSym+'" '+ 'placement="'+startSym+'tt_placement'+endSym+'" '+ - 'animation="tt_animation()" '+ + 'animation="tt_animation" '+ 'is-open="tt_isOpen"'+ '>'+ ''; @@ -112,7 +112,7 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap var tooltip = $compile( template )( scope ); var transitionTimeout; var popupTimeout; - var $body; + var $body = $document.find( 'body' ); var appendToBody = angular.isDefined( options.appendToBody ) ? options.appendToBody : false; var triggers = getTriggers( undefined ); var hasRegisteredTriggers = false; @@ -172,7 +172,6 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap // Now we add it to the DOM because need some info about it. But it's not // visible yet anyway. if ( appendToBody ) { - $body = $body || $document.find( 'body' ); $body.append( tooltip ); } else { element.after( tooltip ); @@ -235,8 +234,10 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap // And now we remove it from the DOM. However, if we have animation, we // need to wait for it to expire beforehand. // FIXME: this is a placeholder for a port of the transitions library. - if ( angular.isDefined( scope.tt_animation ) && scope.tt_animation() ) { - transitionTimeout = $timeout( function () { tooltip.remove(); }, 500 ); + if ( scope.tt_animation ) { + transitionTimeout = $timeout(function () { + tooltip.remove(); + }, 500); } else { tooltip.remove(); } @@ -263,8 +264,8 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap scope.tt_placement = angular.isDefined( val ) ? val : options.placement; }); - attrs.$observe( prefix+'Animation', function ( val ) { - scope.tt_animation = angular.isDefined( val ) ? $parse( val ) : function(){ return options.animation; }; + attrs.$observe(prefix + 'Animation', function (val) { + scope.tt_animation = angular.isDefined(val) ? !!val : options.animation; }); attrs.$observe( prefix+'PopupDelay', function ( val ) { @@ -308,11 +309,11 @@ angular.module( 'ui.bootstrap.tooltip', [ 'ui.bootstrap.position', 'ui.bootstrap // Make sure tooltip is destroyed and removed. scope.$on('$destroy', function onDestroyTooltip() { - if ( scope.tt_isOpen ) { - hide(); - } else { - tooltip.remove(); - } + $timeout.cancel( popupTimeout ); + tooltip.remove(); + tooltip.unbind(); + tooltip = null; + $body = null; }); } }; From 0e9f9980ed7cf3c8f5fe6871ad83e8f3104460b7 Mon Sep 17 00:00:00 2001 From: Sean Kenny Date: Sat, 16 Nov 2013 08:18:47 +0000 Subject: [PATCH 0008/1647] fix(typeahead): support IE8 --- src/typeahead/typeahead.js | 6 +++--- template/typeahead/typeahead-popup.html | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/typeahead/typeahead.js b/src/typeahead/typeahead.js index d886886165..b1eecff95f 100644 --- a/src/typeahead/typeahead.js +++ b/src/typeahead/typeahead.js @@ -68,7 +68,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap var hasFocus; //pop-up element used to display matches - var popUpEl = angular.element(''); + var popUpEl = angular.element('
'); popUpEl.attr({ matches: 'matches', active: 'activeIdx', @@ -283,7 +283,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap .directive('typeaheadPopup', function () { return { - restrict:'E', + restrict:'EA', scope:{ matches:'=', query:'=', @@ -318,7 +318,7 @@ angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap .directive('typeaheadMatch', ['$http', '$templateCache', '$compile', '$parse', function ($http, $templateCache, $compile, $parse) { return { - restrict:'E', + restrict:'EA', scope:{ index:'=', match:'=', diff --git a/template/typeahead/typeahead-popup.html b/template/typeahead/typeahead-popup.html index 69707cefe5..32ec197185 100644 --- a/template/typeahead/typeahead-popup.html +++ b/template/typeahead/typeahead-popup.html @@ -1,5 +1,5 @@ \ No newline at end of file From 6efd6745b2890d3c0518812e352902544126c949 Mon Sep 17 00:00:00 2001 From: Murray Smith Date: Thu, 21 Nov 2013 10:31:36 -0700 Subject: [PATCH 0009/1647] docs(modal): fix typo --- src/modal/docs/readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modal/docs/readme.md b/src/modal/docs/readme.md index d5daeb22f9..2e69a34a8f 100644 --- a/src/modal/docs/readme.md +++ b/src/modal/docs/readme.md @@ -1,4 +1,4 @@ -`$modal` is a s service to quickly create AngularJS-powered modal windows. +`$modal` is a service to quickly create AngularJS-powered modal windows. Creating custom modals is straightforward: create a partial view, its controller and reference them when using the service. The `$modal` service has only one method: `open(options)` where available options are like follows: From c7b097b5ab87c4a1c30b6f8523b80c663c1ca8f0 Mon Sep 17 00:00:00 2001 From: Tasos Bekos Date: Fri, 22 Nov 2013 17:22:25 +0100 Subject: [PATCH 0010/1647] test(alert): fix wrong assertion test for close button --- src/alert/test/alert.spec.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/alert/test/alert.spec.js b/src/alert/test/alert.spec.js index 29d9225716..7a5feb42cf 100644 --- a/src/alert/test/alert.spec.js +++ b/src/alert/test/alert.spec.js @@ -32,7 +32,7 @@ describe("alert", function () { } function findCloseButton(index) { - return element.find('.alert button').eq(index); + return element.find('.close').eq(index); } it("should generate alerts using ng-repeat", function () { @@ -64,9 +64,9 @@ describe("alert", function () { }); it('should not show close buttons if no close callback specified', function () { - var element = $compile('No close')(scope); + element = $compile('No close')(scope); scope.$digest(); - expect(findCloseButton(0).length).toEqual(0); + expect(findCloseButton(0).css('display')).toBe('none'); }); it('it should be possible to add additional classes for alert', function () { From 9dbc2390f2d4521589093393e87ef6ac8baa7e2a Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Fri, 22 Nov 2013 20:33:52 +0100 Subject: [PATCH 0011/1647] chore(release): v0.7.0 --- CHANGELOG.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bf43cbfec..74afde4fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,51 @@ +# 0.7.0 (2013-11-22) + +## Features + +- **datepicker:** + - add i18n support for bar buttons in popup ([c6ba8d7f](http://github.com/angular-ui/bootstrap/commit/c6ba8d7f)) + - dynamic date format for popup ([aa3eaa91](http://github.com/angular-ui/bootstrap/commit/aa3eaa91)) + - datepicker-append-to-body attribute ([0cdc4609](http://github.com/angular-ui/bootstrap/commit/0cdc4609)) +- **dropdownToggle:** + - disable dropdown when it has the disabled class ([104bdd1b](http://github.com/angular-ui/bootstrap/commit/104bdd1b)) +- **tooltip:** + - add ability to enable / disable tooltip ([5d9bd058](http://github.com/angular-ui/bootstrap/commit/5d9bd058)) + +## Bug Fixes + +- **accordion:** + - assign `is-open` to correct scope ([157f614a](http://github.com/angular-ui/bootstrap/commit/157f614a)) +- **collapse:** + - remove element height watching ([a72c635c](http://github.com/angular-ui/bootstrap/commit/a72c635c)) + - add the "in" class for expanded panels ([9eca35a8](http://github.com/angular-ui/bootstrap/commit/9eca35a8)) +- **datepicker:** + - some IE8 compatibility improvements ([4540476f](http://github.com/angular-ui/bootstrap/commit/4540476f)) + - set popup initial position in append-to-body case ([78a1e9d7](http://github.com/angular-ui/bootstrap/commit/78a1e9d7)) + - properly handle showWeeks config option ([570dba90](http://github.com/angular-ui/bootstrap/commit/570dba90)) +- **modal:** + - correctly close modals with no backdrop ([e55c2de3](http://github.com/angular-ui/bootstrap/commit/e55c2de3)) +- **pagination:** + - fix altering of current page caused by totals change ([81164dae](http://github.com/angular-ui/bootstrap/commit/81164dae)) + - handle extreme values for `total-items` ([8ecf93ed](http://github.com/angular-ui/bootstrap/commit/8ecf93ed)) +- **position:** + - correct positioning for SVG elements ([968e5407](http://github.com/angular-ui/bootstrap/commit/968e5407)) +- **tabs:** + - initial tab selection ([a08173ec](http://github.com/angular-ui/bootstrap/commit/a08173ec)) +- **timepicker:** + - use html5 for input elements ([53709f0f](http://github.com/angular-ui/bootstrap/commit/53709f0f)) +- **tooltip:** + - restore html-unsafe compatibility with AngularJS 1.2 ([08d8b21d](http://github.com/angular-ui/bootstrap/commit/08d8b21d)) + - hide tooltips when content becomes empty ([cf5c27ae](http://github.com/angular-ui/bootstrap/commit/cf5c27ae)) + - tackle DOM node and event handlers leak ([0d810acd](http://github.com/angular-ui/bootstrap/commit/0d810acd)) +- **typeahead:** + - do not set editable error when input is empty ([006986db](http://github.com/angular-ui/bootstrap/commit/006986db)) + - remove popup flickering ([dde804b6](http://github.com/angular-ui/bootstrap/commit/dde804b6)) + - don't show matches if an element is not focused ([d1f94530](http://github.com/angular-ui/bootstrap/commit/d1f94530)) + - fix loading callback when deleting characters ([0149eff6](http://github.com/angular-ui/bootstrap/commit/0149eff6)) + - prevent accidental form submission on ENTER ([253c49ff](http://github.com/angular-ui/bootstrap/commit/253c49ff)) + - evaluate matches source against a correct scope ([fd21214d](http://github.com/angular-ui/bootstrap/commit/fd21214d)) + - support IE8 ([0e9f9980](http://github.com/angular-ui/bootstrap/commit/0e9f9980)) + # 0.6.0 (2013-09-08) ## Features diff --git a/package.json b/package.json index 6b883eeaa5..c8af370ca3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "https://github.com/angular-ui/bootstrap/graphs/contributors", "name": "angular-ui-bootstrap", - "version": "0.7.0-SNAPSHOT", + "version": "0.7.0", "dependencies": {}, "devDependencies": { "grunt": "~0.4.1", From 2abadcad2cc537fae8c00a48549abce4efbffdf4 Mon Sep 17 00:00:00 2001 From: Pawel Kozlowski Date: Tue, 26 Nov 2013 20:08:49 +0100 Subject: [PATCH 0012/1647] chore(release): Starting v0.8.0-SNAPSHOT --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c8af370ca3..459732703b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "https://github.com/angular-ui/bootstrap/graphs/contributors", "name": "angular-ui-bootstrap", - "version": "0.7.0", + "version": "0.8.0-SNAPSHOT", "dependencies": {}, "devDependencies": { "grunt": "~0.4.1", From 9ec21286ea227f9901a9ef6fe036cf6727c769ca Mon Sep 17 00:00:00 2001 From: Tasos Bekos Date: Tue, 26 Nov 2013 10:34:12 +0100 Subject: [PATCH 0013/1647] fix(accordion): correct `is-open` handling for dynamic groups Closes #1297 --- src/accordion/accordion.js | 7 ++-- src/accordion/test/accordion.spec.js | 51 +++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/src/accordion/accordion.js b/src/accordion/accordion.js index e18e2d04d7..594c156329 100644 --- a/src/accordion/accordion.js +++ b/src/accordion/accordion.js @@ -9,9 +9,6 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) // This array keeps track of the accordion groups this.groups = []; - // Keep reference to user's scope to properly assign `is-open` - this.scope = $scope; - // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to this.closeOthers = function(openGroup) { var closeOthers = angular.isDefined($attrs.closeOthers) ? $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers; @@ -81,7 +78,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) getIsOpen = $parse(attrs.isOpen); setIsOpen = getIsOpen.assign; - accordionCtrl.scope.$watch(getIsOpen, function(value) { + scope.$parent.$watch(getIsOpen, function(value) { scope.isOpen = !!value; }); } @@ -91,7 +88,7 @@ angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) accordionCtrl.closeOthers(scope); } if ( setIsOpen ) { - setIsOpen(accordionCtrl.scope, value); + setIsOpen(scope.$parent, value); } }); } diff --git a/src/accordion/test/accordion.spec.js b/src/accordion/test/accordion.spec.js index 143ca73270..d0c9645d0b 100644 --- a/src/accordion/test/accordion.spec.js +++ b/src/accordion/test/accordion.spec.js @@ -217,13 +217,12 @@ describe('accordion', function () { describe('is-open attribute', function() { beforeEach(function () { var tpl = - "" + - "Content 1" + - "Content 2" + - ""; + '' + + 'Content 1' + + 'Content 2' + + ''; element = angular.element(tpl); - scope.open1 = false; - scope.open2 = true; + scope.open = { first: false, second: true }; $compile(element)(scope); scope.$digest(); groups = element.find('.accordion-group'); @@ -237,11 +236,11 @@ describe('accordion', function () { it('should toggle variable on element click', function() { findGroupLink(0).click(); scope.$digest(); - expect(scope.open1).toBe(true); + expect(scope.open.first).toBe(true); findGroupLink(0).click(); scope.$digest(); - expect(scope.open1).toBe(false); + expect(scope.open.second).toBe(false); }); }); @@ -272,6 +271,42 @@ describe('accordion', function () { }); }); + describe('is-open attribute with dynamic groups', function () { + var model; + beforeEach(function () { + var tpl = + '' + + '{{group.content}}' + + ''; + element = angular.element(tpl); + scope.groups = [ + {name: 'title 1', content: 'Content 1', open: false}, + {name: 'title 2', content: 'Content 2', open: true} + ]; + $compile(element)(scope); + scope.$digest(); + + groups = element.find('.accordion-group'); + }); + + it('should have visible group body when the group with isOpen set to true', function () { + expect(findGroupBody(0).scope().isOpen).toBe(false); + expect(findGroupBody(1).scope().isOpen).toBe(true); + }); + + it('should toggle element on click', function() { + findGroupLink(0).click(); + scope.$digest(); + expect(findGroupBody(0).scope().isOpen).toBe(true); + expect(scope.groups[0].open).toBe(true); + + findGroupLink(0).click(); + scope.$digest(); + expect(findGroupBody(0).scope().isOpen).toBe(false); + expect(scope.groups[0].open).toBe(false); + }); + }); + describe('accordion-heading element', function() { beforeEach(function() { var tpl = From 4d158e0dd972242345a18fd6824a50a2629b35bd Mon Sep 17 00:00:00 2001 From: Tasos Bekos Date: Sun, 6 Oct 2013 00:37:47 +0300 Subject: [PATCH 0014/1647] feat(datepicker): option whether to display button bar in popup --- src/datepicker/datepicker.js | 15 ++++++++------- src/datepicker/docs/readme.md | 11 ++++++++--- src/datepicker/test/datepicker.spec.js | 22 ++++++++++++++++------ template/datepicker/popup.html | 3 +-- 4 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index a4579873c5..c75e22917b 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -258,7 +258,8 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.position']) clearText: 'Clear', closeText: 'Done', closeOnDateSelection: true, - appendToBody: false + appendToBody: false, + showButtonBar: true }) .directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'datepickerPopupConfig', 'datepickerConfig', @@ -267,17 +268,17 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon restrict: 'EA', require: 'ngModel', link: function(originalScope, element, attrs, ngModel) { - var dateFormat; + var scope = originalScope.$new(), // create a child scope so we are not polluting original one + dateFormat, + closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? originalScope.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection, + appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? originalScope.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody; + attrs.$observe('datepickerPopup', function(value) { dateFormat = value || datepickerPopupConfig.dateFormat; ngModel.$render(); }); - var closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? originalScope.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection; - var appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? originalScope.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody; - - // create a child scope for the datepicker directive so we are not polluting original scope - var scope = originalScope.$new(); + scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? originalScope.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar; originalScope.$on('$destroy', function() { scope.$destroy(); diff --git a/src/datepicker/docs/readme.md b/src/datepicker/docs/readme.md index 1e4bdfa52d..bb00aeb818 100644 --- a/src/datepicker/docs/readme.md +++ b/src/datepicker/docs/readme.md @@ -7,7 +7,8 @@ Everything is formatted using the [date filter](http://docs.angularjs.org/api/ng ### Datepicker Settings ### -All settings can be provided as attributes in the `` or globally configured through the `datepickerConfig`. `datepicker-popup` options may be provided as attributes in the `datepicker-popup`'s element, or globally configured through the `datepickerPopupConfig`. +All settings can be provided as attributes in the `` or globally configured through the `datepickerConfig`. + * `ng-model` : The date object. @@ -64,12 +65,16 @@ All settings can be provided as attributes in the `` or globally con ### Popup Settings ### Options for datepicker can be passed as JSON using the `datepicker-options` attribute. -Specific settings for the `datepicker-popup` are: +Specific settings for the `datepicker-popup`, that can globally configured through the `datepickerPopupConfig`, are: * `datepicker-popup` _(Default: 'yyyy-MM-dd')_ : The format for displayed dates. + * `show-button-bar` + _(Default: true)_ : + Whether to display a button bar underneath the datepicker. + * `current-text` _(Default: 'Today')_ : The text to display for the current day button. @@ -89,7 +94,7 @@ Specific settings for the `datepicker-popup` are: * `close-on-date-selection` _(Default: true)_ : Whether to close calendar when a date is chosen. - + * `datepicker-append-to-body` _(Default: false)_: Append the datepicker popup element to `body`, rather than inserting after `datepicker-popup`. For global configuration, use `datepickerPopupConfig.appendToBody`. diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index af69093103..6ed390b9d4 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -1137,15 +1137,20 @@ describe('datepicker directive', function () { }); describe('button bar', function() { - var buttons; + var buttons, buttonBarElement; beforeEach(inject(function() { - assignButtons(); + assignButtonBar(); })); - function assignButtons() { - buttons = dropdownEl.find('li').eq(2).find('button'); + function assignButtonBar() { + buttonBarElement = dropdownEl.find('li').eq(-1); + buttons = buttonBarElement.find('button'); } + it('should be visible', function() { + expect(buttonBarElement.css('display')).not.toBe('none'); + }); + it('should have four buttons', function() { expect(buttons.length).toBe(4); @@ -1170,12 +1175,13 @@ describe('datepicker directive', function () { describe('customization', function() { beforeEach(inject(function() { + $rootScope.showBar = false; $rootScope.clearText = 'Null it!'; $rootScope.close = 'Close'; - var wrapElement = $compile('
')($rootScope); + var wrapElement = $compile('
')($rootScope); $rootScope.$digest(); assignElements(wrapElement); - assignButtons(); + assignButtonBar(); })); it('should change text from attributes', function() { @@ -1184,6 +1190,10 @@ describe('datepicker directive', function () { expect(buttons.eq(2).text()).toBe('Null it!'); expect(buttons.eq(3).text()).toBe('CloseME'); }); + + it('should hide bar', function() { + expect(buttonBarElement.css('display')).toBe('none'); + }); }); }); diff --git a/template/datepicker/popup.html b/template/datepicker/popup.html index 7da51a9098..7c7ab7b2e3 100644 --- a/template/datepicker/popup.html +++ b/template/datepicker/popup.html @@ -1,7 +1,6 @@
Color (null not allowed): -
+
Color (null allowed): -
Color grouped by shade: -
- Select bogus.
+ Select bogus.

- Currently selected: {{ {selected_color:color} }} + Currently selected: {{ {selected_color:myColor} }}
+ ng-style="{'background-color':myColor.name}">
it('should check ng-options', function() { - expect(element(by.binding('{selected_color:color}')).getText()).toMatch('red'); - element.all(by.select('color')).first().click(); - element.all(by.css('select[ng-model="color"] option')).first().click(); - expect(element(by.binding('{selected_color:color}')).getText()).toMatch('black'); - element(by.css('.nullable select[ng-model="color"]')).click(); - element.all(by.css('.nullable select[ng-model="color"] option')).first().click(); - expect(element(by.binding('{selected_color:color}')).getText()).toMatch('null'); + expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('red'); + element.all(by.model('myColor')).first().click(); + element.all(by.css('select[ng-model="myColor"] option')).first().click(); + expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('black'); + element(by.css('.nullable select[ng-model="myColor"]')).click(); + element.all(by.css('.nullable select[ng-model="myColor"] option')).first().click(); + expect(element(by.binding('{selected_color:myColor}')).getText()).toMatch('null'); }); */ -var ngOptionsDirective = valueFn({ terminal: true }); +var ngOptionsDirective = valueFn({ + restrict: 'A', + terminal: true +}); + // jshint maxlen: false var selectDirective = ['$compile', '$parse', function($compile, $parse) { //000011111111110000000000022222222220000000000000000000003333333333000000000000004444444444444440000000005555555555555550000000666666666666666000000000000000777777777700000000000000000008888888888 @@ -20965,7 +25457,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { }; - self.addOption = function(value) { + self.addOption = function(value, element) { assertNotHasOwnProperty(value, '"option value"'); optionsMap[value] = true; @@ -20973,13 +25465,19 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { $element.val(value); if (unknownOption.parent()) unknownOption.remove(); } + // Workaround for https://code.google.com/p/chromium/issues/detail?id=381459 + // Adding an