Skip to content

Commit

Permalink
update document
Browse files Browse the repository at this point in the history
  • Loading branch information
lordfriend committed Jan 17, 2015
1 parent 27b0fac commit 466aa5e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 29 deletions.
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.5
* nya-bootstrap-select v2.0.6
* 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.5
* nya-bootstrap-select v2.0.6
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down
77 changes: 50 additions & 27 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.5
* nya-bootstrap-select v2.0.6
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down Expand Up @@ -315,6 +315,8 @@ var deepEquals = angular.equals;

var deepCopy = angular.copy;

var extend = angular.extend;

var nyaBsSelect = angular.module('nya.bootstrap.select', []);


Expand All @@ -338,7 +340,7 @@ nyaBsSelect.controller('nyaBsSelectCtrl', function(){
};

});
nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', function ($parse, $document, $timeout) {
nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', 'nyaBsConfig', function ($parse, $document, $timeout, nyaBsConfig) {

var DEFAULT_NONE_SELECTION = 'Nothing selected';

Expand All @@ -364,8 +366,32 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio
controller: 'nyaBsSelectCtrl',
compile: function nyaBsSelectCompile (tElement, tAttrs){


tElement.addClass('btn-group');

var getDefaultNoneSelectionContent = function() {
// text node or jqLite element.
var content;

if(tAttrs.titleTpl) {
// use title-tpl attribute value.
content = jqLite(tAttrs.titleTpl);
} else if(tAttrs.title) {
// use title attribute value.
content = document.createTextNode(tAttrs.title);
} else if(localizedText.defaultNoneSelectionTpl){
// use localized text template.
content = jqLite(localizedText.defaultNoneSelectionTpl);
} else if(localizedText.defaultNoneSelection) {
// use localized text.
content = document.createTextNode(localizedText.defaultNoneSelection);
} else {
// use default.
content = document.createTextNode(DEFAULT_NONE_SELECTION);
}
return content;
};

var options = tElement.children(),
dropdownToggle = jqLite(DROPDOWN_TOGGLE),
dropdownContainer = jqLite(DROPDOWN_CONTAINER),
Expand All @@ -375,7 +401,8 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio
classList,
length,
index,
liElement;
liElement,
localizedText = nyaBsConfig;

classList = getClassList(tElement[0]);
classList.forEach(function(className) {
Expand Down Expand Up @@ -409,17 +436,21 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio

if(tAttrs.liveSearch === 'true') {
searchBox = jqLite(SEARCH_BOX);

// set localized text
if(localizedText.noSearchResultTpl) {
NO_SEARCH_RESULT = NO_SEARCH_RESULT.replace('NO SEARCH RESULT', localizedText.noSearchResultTpl);
} else if(localizedText.noSearchResult) {
NO_SEARCH_RESULT = NO_SEARCH_RESULT.replace('NO SEARCH RESULT', localizedText.noSearchResult);
}

noSearchResult = jqLite(NO_SEARCH_RESULT);
dropdownContainer.append(searchBox);
dropdownMenu.append(noSearchResult);
}

// set default none selection text
if(tAttrs.title) {
dropdownToggle.children().eq(0).text(tAttrs.title);
} else {
dropdownToggle.children().eq(0).text(DEFAULT_NONE_SELECTION);
}
dropdownToggle.children().eq(0).append(getDefaultNoneSelectionContent());

dropdownContainer.append(dropdownMenu);

Expand Down Expand Up @@ -1013,15 +1044,8 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio
return;
}
if(isMultiple && modelValue.length === 0) {
if($attrs.title) {
// use title attribute value.
filterOption.empty();
filterOption.append(document.createTextNode($attrs.title));
} else {
// use default text.
filterOption.empty();
filterOption.append(document.createTextNode(DEFAULT_NONE_SELECTION));
}
filterOption.empty();
filterOption.append(getDefaultNoneSelectionContent());
} else {
$timeout(function() {

Expand All @@ -1044,7 +1068,13 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio
// data-selected-text-format="count" or data-selected-text-format="count>x"
if((typeof count !== 'undefined') && modelValue.length > count) {
filterOption.empty();
filterOption.append(document.createTextNode(modelValue.length + ' items selected'));
if(localizedText.numberItemSelectedTpl) {
filterOption.append(jqLite(localizedText.numberItemSelectedTpl.replace('%d', modelValue.length)));
} else if(localizedText.numberItemSelected) {
filterOption.append(document.createTextNode(localizedText.numberItemSelected.replace('%d', modelValue.length)));
} else {
filterOption.append(document.createTextNode(modelValue.length + ' items selected'));
}
return;
}

Expand Down Expand Up @@ -1082,15 +1112,8 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', functio
}

if(selection.length === 0) {
if($attrs.title) {
// use title attribute value.
filterOption.empty();
filterOption.append(document.createTextNode($attrs.title));
} else {
// use default text.
filterOption.empty();
filterOption.append(document.createTextNode(DEFAULT_NONE_SELECTION));
}
filterOption.empty();
filterOption.append(getDefaultNoneSelectionContent());
} else if(selection.length === 1) {
// either single or multiple selection will show the only selected content.
filterOption.empty();
Expand Down

0 comments on commit 466aa5e

Please sign in to comment.