Skip to content

Commit

Permalink
add commonjs support by export angular module name.
Browse files Browse the repository at this point in the history
add main section in package.json. fix #152
update version to 2.1.10
  • Loading branch information
lordfriend committed Nov 16, 2016
1 parent ad350ee commit d8d5d9c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nya-bootstrap-select",
"version": "2.1.9",
"version": "2.1.10",
"main": [
"dist/js/nya-bs-select.js",
"dist/css/nya-bs-select.css"
Expand Down
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 @@
/**
* @lordfriend/nya-bootstrap-select v2.1.9
* @lordfriend/nya-bootstrap-select v2.1.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.

31 changes: 26 additions & 5 deletions dist/js/nya-bs-select.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @lordfriend/nya-bootstrap-select v2.1.9
* @lordfriend/nya-bootstrap-select v2.1.10
* Copyright 2014 Nyasoft
* Licensed under MIT license
*/
Expand Down Expand Up @@ -1073,6 +1073,19 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
}
}
}

function supportsSelector(selector) {
var el = document.createElement('div');
el.innerHTML = ['&shy;', '<style>', selector, '{}', '</style>'].join('');
el = document.body.appendChild(el);
var style = el.getElementsByTagName('style')[0];
if (style && style.sheet && style.sheet.rules && style.sheet.cssRules) {
var ret = !!(style.sheet.rules || style.sheet.cssRules)[0];
document.body.removeChild(el);
return ret;
}
return false;
}

function findFocus(fromFirst) {
var firstLiElement;
Expand All @@ -1083,10 +1096,18 @@ nyaBsSelect.directive('nyaBsSelect', ['$parse', '$document', '$timeout', '$compi
}

// focus on selected element
for(var i = 0; i < dropdownMenu.children().length; i++) {
var childElement = dropdownMenu.children().eq(i);
if (!childElement.hasClass('not-match') && childElement.hasClass('selected')) {
return dropdownMenu.children().eq(i)[0];
if (supportsSelector(".selected:not(.not-match)")) {
var match = dropdownMenu[0].querySelector('.selected:not(.not-match)');
if (match)
return match;
}
else {
// Fallback for IE8 users
for(var i = 0; i < dropdownMenu.children().length; i++) {
var childElement = dropdownMenu.children().eq(i);
if (!childElement.hasClass('not-match') && childElement.hasClass('selected')) {
return dropdownMenu.children().eq(i)[0];
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions dist/js/nya-bs-select.min.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('./dist/js/nya-bs-select');

module.exports = 'nya.bootstrap.select';
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"name": "@lordfriend/nya-bootstrap-select",
"version": "2.1.9",
"version": "2.1.10",
"description": "An angular directive wraps bootstrap-select",
"main": "index.js",
"repository": {
"type": "git",
"url": "git://github.com/lordfriend/nya-bootstrap-select.git"
Expand Down

0 comments on commit d8d5d9c

Please sign in to comment.