diff options
author | isteven <isteven@server.fake> | 2014-04-17 12:23:48 +0800 |
---|---|---|
committer | isteven <isteven@server.fake> | 2014-04-17 12:23:48 +0800 |
commit | 914a0985b4e7f1509a4dbdae7c6b13228c44ab1f (patch) | |
tree | ed4e50b8332535faa3787d205f0dfc92ad2f4c00 /angular-multi-select.js | |
parent | b2e677e245d0197ccdc39559daf339bf4e4eefda (diff) | |
download | angular-multi-select-914a0985b4e7f1509a4dbdae7c6b13228c44ab1f.zip angular-multi-select-914a0985b4e7f1509a4dbdae7c6b13228c44ab1f.tar.gz angular-multi-select-914a0985b4e7f1509a4dbdae7c6b13228c44ab1f.tar.bz2 |
bug fix: single selection mode toggle
Diffstat (limited to 'angular-multi-select.js')
-rw-r--r-- | angular-multi-select.js | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/angular-multi-select.js b/angular-multi-select.js index ce1b3b4..a2e8eef 100644 --- a/angular-multi-select.js +++ b/angular-multi-select.js @@ -197,16 +197,25 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', fu } // UI operations to show/hide checkboxes - $scope.toggleCheckboxes = function( e ) { + $scope.toggleCheckboxes = function( e ) { if ( e.target ) { if ( e.target.tagName.toUpperCase() !== 'BUTTON' && e.target.className.indexOf( 'multiSelectButton' ) < 0 ) { - e = $scope.findUpTag( e.target, 'button', 'multiSelectButton' ); + if ( attrs.selectionMode && $scope.selectionMode.toUpperCase() === 'SINGLE' ) { + if ( e.target.tagName.toUpperCase() === 'INPUT' ) + { + e = $scope.findUpTag( e.target, 'div', 'checkboxLayer' ); + e = e.previousSibling; + } + } + else { + e = $scope.findUpTag( e.target, 'button', 'multiSelectButton' ); + } } else { e = e.target; } - } + } $scope.labelFilter = ''; @@ -221,16 +230,7 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', fu break; } } - - if ( attrs.selectionMode && $scope.selectionMode.toUpperCase() === 'SINGLE' ) { - for( i=0; i < multiSelectButtons.length; i++ ) { - if ( e.target.parentNode.parentNode.parentNode.parentNode.previousSibling === multiSelectButtons[ i ] ) { - multiSelectIndex = i; - break; - } - } - } - + if ( multiSelectIndex > -1 ) { for( i=0; i < checkboxes.length; i++ ) { if ( i != multiSelectIndex ) { @@ -252,9 +252,12 @@ angular.module( 'multi-select', ['ng'] ).directive( 'multiSelect' , [ '$sce', fu $scope.findUpTag = function ( el, tag, className ) { while ( el.parentNode ) { - el = el.parentNode; - if ( el.tagName.toUpperCase() === tag.toUpperCase() && el.className.indexOf( 'multiSelectButton' ) > -1 ) - return el; + el = el.parentNode; + if ( typeof el.tagName !== 'undefined' ) { + if ( el.tagName.toUpperCase() === tag.toUpperCase() && el.className.indexOf( className ) > -1 ) { + return el; + } + } } return null; } |