Skip to content

Commit

Permalink
fix IE bug
Browse files Browse the repository at this point in the history
  • Loading branch information
o.istomin committed Sep 4, 2015
1 parent ec3fd50 commit 0dfef25
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 21 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
#### Features

- **oi-select-options:**
- cleanModel: changed behavior (clean model by click)
- cleanModel: changed behavior (clean model by click). It affected `newItem: 'prompt'`

#### Bug Fixes

- **dropdown** fixed dropdown opening in IE, open dropdown by pushing on letter keys (for single select)
- **oi-select-options:**
- closeList: fixed

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#oi.select — AngularJS directive of select element

**[Download 0.2.11](https://github.com/tamtakoe/oi.select/tree/master/dist)**
**[Download 0.2.12](https://github.com/tamtakoe/oi.select/tree/master/dist)**

## Features

Expand Down Expand Up @@ -91,7 +91,7 @@ Use `oi-select` directive:
* `listFilter` — filter name for items order in dropdown. Use `none` to disable filtering
* `editItem` — function which get `lastQuery`, `removedItem` and `getLabel(item)` and return string for input after element was removed (default: ''). `editItem = true` allows you to edit a deleted item. `editItem = 'correct'` same as `true` but does not edit the first time
* `saveTrigger` — Trigger on which element is stored in the model. May be `enter`, `blur` (default: `enter`)
* `cleanModel` [deprecated] — Clean model on blur for single select.
* `cleanModel` — Clean model on click for single select.
* `closeList` — close dropdown list by default after choosing or removing item (default: true)
* `newItem` — Mode of adding new items from query (default: false). May be `autocomplete` (priority save matches), `prompt` (priority save new item)
* `newItemModel` — New items model (default: model = query). `$query` value from model will be changed to query string.
Expand Down
14 changes: 11 additions & 3 deletions dist/select-tpls.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ angular.module('oi.select')
element[0].addEventListener('blur', blurHandler, true);
inputElement.on('focus', focusHandler);

function blurHandler() {
function blurHandler(event) {
if (event.target.nodeName !== 'INPUT') return; //for IE

isBlur = false;

if (isMousedown) {
Expand Down Expand Up @@ -414,7 +416,7 @@ angular.module('oi.select')
};
}

if (options.cleanModel) {
if (options.cleanModel && (!editItem || editItemCorrect)) {
element.addClass('cleanMode');
}

Expand Down Expand Up @@ -584,7 +586,10 @@ angular.module('oi.select')
scope.query = editItemFn(removedItem, lastQuery, getLabel);
}

editItemCorrect = false;
if (editItem) {
editItemCorrect = false;
element.removeClass('cleanMode');
}

if (multiple && options.closeList) {
resetMatches({query: true});
Expand Down Expand Up @@ -669,6 +674,9 @@ angular.module('oi.select')
break;
}
default: /* any key */
if (scope.inputHide) {
cleanInput();
}
scope.backspaceFocus = false;
return false; //preventDefaults
}
Expand Down
2 changes: 1 addition & 1 deletion dist/select-tpls.min.js

Large diffs are not rendered by default.

14 changes: 11 additions & 3 deletions dist/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ angular.module('oi.select')
element[0].addEventListener('blur', blurHandler, true);
inputElement.on('focus', focusHandler);

function blurHandler() {
function blurHandler(event) {
if (event.target.nodeName !== 'INPUT') return; //for IE

isBlur = false;

if (isMousedown) {
Expand Down Expand Up @@ -414,7 +416,7 @@ angular.module('oi.select')
};
}

if (options.cleanModel) {
if (options.cleanModel && (!editItem || editItemCorrect)) {
element.addClass('cleanMode');
}

Expand Down Expand Up @@ -584,7 +586,10 @@ angular.module('oi.select')
scope.query = editItemFn(removedItem, lastQuery, getLabel);
}

editItemCorrect = false;
if (editItem) {
editItemCorrect = false;
element.removeClass('cleanMode');
}

if (multiple && options.closeList) {
resetMatches({query: true});
Expand Down Expand Up @@ -669,6 +674,9 @@ angular.module('oi.select')
break;
}
default: /* any key */
if (scope.inputHide) {
cleanInput();
}
scope.backspaceFocus = false;
return false; //preventDefaults
}
Expand Down
2 changes: 1 addition & 1 deletion dist/select.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/examples/autocomplete/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ angular.module('selectDemo')
$scope.shopObj = ShopObj.get();

$scope.shopObj.$promise.then(function(data) {
$scope.bundle = [data[5]];
$scope.bundle = data[5];
});
});
2 changes: 0 additions & 2 deletions docs/examples/autocomplete/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ <h2>Autocomplete</h2>
<oi-select
oi-options="item.name for (key, item) in shopObj"
ng-model="bundle"
multiple
oi-select-options="{
newItem: 'autocomplete',
newItemModel: {id: null, name: $query, category: 'shoes'},
Expand All @@ -21,7 +20,6 @@ <h2>Autocomplete</h2>
<div hljs class="col-md-8">
oi-options="item.name for (key, item) in shopObj"
ng-model="bundle"
multiple
oi-select-options="{
newItem: 'autocomplete',
newItemModel: {id: null, name: $query, category: 'shoes'},
Expand Down
2 changes: 1 addition & 1 deletion docs/examples/prompt/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ angular.module('selectDemo')
$scope.shopObj = ShopObj.get();

$scope.shopObj.$promise.then(function(data) {
$scope.bundle = [data[5]];
$scope.bundle = data[5];
});
});
2 changes: 0 additions & 2 deletions docs/examples/prompt/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ <h2>Prompt</h2>
<oi-select
oi-options="item.name for (key, item) in shopObj"
ng-model="bundle"
multiple
oi-select-options="{
newItem: 'prompt',
newItemModel: {id: null, name: $query, category: 'shoes'},
Expand All @@ -20,7 +19,6 @@ <h2>Prompt</h2>
<div hljs class="col-md-8">
oi-options="item.name for (key, item) in shopObj"
ng-model="bundle"
multiple
oi-select-options="{
newItem: 'prompt',
newItemModel: {id: null, name: $query, category: 'shoes'},
Expand Down
10 changes: 8 additions & 2 deletions src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ angular.module('oi.select')
};
}

if (options.cleanModel) {
if (options.cleanModel && (!editItem || editItemCorrect)) {
element.addClass('cleanMode');
}

Expand Down Expand Up @@ -250,7 +250,10 @@ angular.module('oi.select')
scope.query = editItemFn(removedItem, lastQuery, getLabel);
}

editItemCorrect = false;
if (editItem) {
editItemCorrect = false;
element.removeClass('cleanMode');
}

if (multiple && options.closeList) {
resetMatches({query: true});
Expand Down Expand Up @@ -335,6 +338,9 @@ angular.module('oi.select')
break;
}
default: /* any key */
if (scope.inputHide) {
cleanInput();
}
scope.backspaceFocus = false;
return false; //preventDefaults
}
Expand Down
4 changes: 3 additions & 1 deletion src/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ angular.module('oi.select')
element[0].addEventListener('blur', blurHandler, true);
inputElement.on('focus', focusHandler);

function blurHandler() {
function blurHandler(event) {
if (event.target.nodeName !== 'INPUT') return; //for IE

isBlur = false;

if (isMousedown) {
Expand Down

0 comments on commit 0dfef25

Please sign in to comment.