Skip to content

Commit

Permalink
fix #45 by revert getOptionValue function(src/nya-bs-select.js) to th…
Browse files Browse the repository at this point in the history
…e previous version.
  • Loading branch information
lordfriend committed Mar 5, 2015
1 parent 35958dd commit 0febf1b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion dist/css/nya-bs-select.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* nya-bootstrap-select v2.0.9
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/css/nya-bs-select.min.css

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

12 changes: 6 additions & 6 deletions dist/js/nya-bs-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* nya-bootstrap-select v2.0.9
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down Expand Up @@ -1095,14 +1095,14 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC
* @param nyaBsOption a jqLite wrapped `nya-bs-option` element
*/
function getOptionValue(nyaBsOption) {
var scopeOfOption = nyaBsOption.scope();
var scopeOfOption;
if(valueExpFn) {
scopeOfOption = nyaBsOption.scope();
return valueExpFn(scopeOfOption);
} else {
if(typeof nyaBsSelectCtrl.valueIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier];
} else if(typeof nyaBsSelectCtrl.keyIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
if(nyaBsSelectCtrl.valueIdentifier || nyaBsSelectCtrl.keyIdentifier) {
scopeOfOption = nyaBsOption.scope();
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier] || scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
} else {
return nyaBsOption.attr('value');
}
Expand Down
4 changes: 2 additions & 2 deletions dist/js/nya-bs-select.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dist/css/main.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* nya-bootstrap-select v2.0.9
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down
2 changes: 1 addition & 1 deletion docs/dist/css/nya-bs-select.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* nya-bootstrap-select v2.0.9
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down
29 changes: 23 additions & 6 deletions docs/dist/js/nya-bs-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* nya-bootstrap-select v2.0.9
* nya-bootstrap-select v2.0.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down Expand Up @@ -664,10 +664,19 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC
// if click the outside of dropdown menu, close the dropdown menu
$document.on('click', function(event) {
if(filterTarget(event.target, $element.parent()[0], $element[0]) === null) {
if($element.hasClass('open')) {
$element.triggerHandler('blur');
}
$element.removeClass('open');
}
});


dropdownToggle.on('blur', function() {
if(!$element.hasClass('open')) {
$element.triggerHandler('blur');
}
});
dropdownToggle.on('click', function() {
var nyaBsOptionNode;
$element.toggleClass('open');
Expand Down Expand Up @@ -853,6 +862,9 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC
if(keyCode === 27) {
// escape pressed
dropdownToggle[0].focus();
if($element.hasClass('open')) {
$element.triggerHandler('blur');
}
$element.removeClass('open');
event.stopPropagation();

Expand Down Expand Up @@ -1067,6 +1079,9 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC

if(!isMultiple) {
// in single selection mode. close the dropdown menu
if($element.hasClass('open')) {
$element.triggerHandler('blur');
}
$element.removeClass('open');
}
updateButtonContent();
Expand All @@ -1080,14 +1095,14 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC
* @param nyaBsOption a jqLite wrapped `nya-bs-option` element
*/
function getOptionValue(nyaBsOption) {
var scopeOfOption = nyaBsOption.scope();
var scopeOfOption;
if(valueExpFn) {
scopeOfOption = nyaBsOption.scope();
return valueExpFn(scopeOfOption);
} else {
if(typeof nyaBsSelectCtrl.valueIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier];
} else if(typeof nyaBsSelectCtrl.keyIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
if(nyaBsSelectCtrl.valueIdentifier || nyaBsSelectCtrl.keyIdentifier) {
scopeOfOption = nyaBsOption.scope();
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier] || scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
} else {
return nyaBsOption.attr('value');
}
Expand All @@ -1108,6 +1123,8 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC

function updateButtonContent() {
var modelValue = ngCtrl.$modelValue;
$element.triggerHandler('change');

var filterOption = dropdownToggle.children().eq(0);
if(typeof modelValue === 'undefined') {
/**
Expand Down
10 changes: 5 additions & 5 deletions src/nya-bs-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,14 +692,14 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsC
* @param nyaBsOption a jqLite wrapped `nya-bs-option` element
*/
function getOptionValue(nyaBsOption) {
var scopeOfOption = nyaBsOption.scope();
var scopeOfOption;
if(valueExpFn) {
scopeOfOption = nyaBsOption.scope();
return valueExpFn(scopeOfOption);
} else {
if(typeof nyaBsSelectCtrl.valueIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier];
} else if(typeof nyaBsSelectCtrl.keyIdentifier !== 'undefined') {
return scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
if(nyaBsSelectCtrl.valueIdentifier || nyaBsSelectCtrl.keyIdentifier) {
scopeOfOption = nyaBsOption.scope();
return scopeOfOption[nyaBsSelectCtrl.valueIdentifier] || scopeOfOption[nyaBsSelectCtrl.keyIdentifier];
} else {
return nyaBsOption.attr('value');
}
Expand Down

0 comments on commit 0febf1b

Please sign in to comment.