|
@@ -12,13 +12,13 @@ define [
|
|
|
ctrl.showHint = false
|
|
ctrl.showHint = false
|
|
|
ctrl.hasFocus = false
|
|
ctrl.hasFocus = false
|
|
|
ctrl.suggestion = null
|
|
ctrl.suggestion = null
|
|
|
|
|
+ ctrl.onBlur()
|
|
|
ctrl.handleKeyDown = ($event) ->
|
|
ctrl.handleKeyDown = ($event) ->
|
|
|
if ($event.which == 9 or $event.which == 13) and ctrl.suggestion? and ctrl.suggestion != ""
|
|
if ($event.which == 9 or $event.which == 13) and ctrl.suggestion? and ctrl.suggestion != ""
|
|
|
$event.preventDefault()
|
|
$event.preventDefault()
|
|
|
ctrl.localNgModel += ctrl.suggestion
|
|
ctrl.localNgModel += ctrl.suggestion
|
|
|
- ctrl.suggestion = null
|
|
|
|
|
- ctrl.showHint = false
|
|
|
|
|
-
|
|
|
|
|
|
|
+ ctrl.suggestion = null
|
|
|
|
|
+ ctrl.showHint = false
|
|
|
$scope.$watch "$ctrl.localNgModel", (newVal, oldVal) ->
|
|
$scope.$watch "$ctrl.localNgModel", (newVal, oldVal) ->
|
|
|
if ctrl.hasFocus and newVal != oldVal
|
|
if ctrl.hasFocus and newVal != oldVal
|
|
|
ctrl.suggestion = null
|
|
ctrl.suggestion = null
|
|
@@ -34,16 +34,21 @@ define [
|
|
|
App.component "inputSuggestions", {
|
|
App.component "inputSuggestions", {
|
|
|
bindings:
|
|
bindings:
|
|
|
localNgModel: "=ngModel"
|
|
localNgModel: "=ngModel"
|
|
|
|
|
+ localNgModelOptions: "=?ngModelOptions"
|
|
|
getSuggestion: "&"
|
|
getSuggestion: "&"
|
|
|
- inputId: "@"
|
|
|
|
|
- inputPlaceholder: "@"
|
|
|
|
|
|
|
+ onBlur: "&?"
|
|
|
|
|
+ inputId: "@?"
|
|
|
|
|
+ inputName: "@?"
|
|
|
|
|
+ inputPlaceholder: "@?"
|
|
|
|
|
+ inputType: "@?"
|
|
|
|
|
+ inputRequired: "=?"
|
|
|
controller: inputSuggestionsController
|
|
controller: inputSuggestionsController
|
|
|
template: """
|
|
template: """
|
|
|
<div class="input-suggestions">
|
|
<div class="input-suggestions">
|
|
|
<div type="text" + $ctrl.suggestion" class="form-control input-suggestions-shadow" ng-show="$ctrl.showHint">
|
|
<div type="text" + $ctrl.suggestion" class="form-control input-suggestions-shadow" ng-show="$ctrl.showHint">
|
|
|
<span ng-bind="$ctrl.localNgModel" class="input-suggestions-shadow-existing"></span><span ng-bind="$ctrl.suggestion" class="input-suggestions-shadow-suggested"></span>
|
|
<span ng-bind="$ctrl.localNgModel" class="input-suggestions-shadow-existing"></span><span ng-bind="$ctrl.suggestion" class="input-suggestions-shadow-suggested"></span>
|
|
|
</div>
|
|
</div>
|
|
|
- <input type="text" ng-focus="$ctrl.handleFocus()" ng-keyDown="$ctrl.handleKeyDown($event)" ng-blur="$ctrl.handleBlur()" ng-model="$ctrl.localNgModel" ng-model-options="{ debounce: 50 }" class="form-control input-suggestions-main" ng-attr-id="{{ ::$ctrl.inputId }}" ng-attr-placeholder="{{ ::$ctrl.inputPlaceholder }}">
|
|
|
|
|
|
|
+ <input type="text" ng-focus="$ctrl.handleFocus()" ng-keyDown="$ctrl.handleKeyDown($event)" ng-blur="$ctrl.handleBlur()" ng-model="$ctrl.localNgModel" ng-model-options="$ctrl.localNgModelOptions" ng-model-options="{ debounce: 50 }" class="form-control input-suggestions-main" ng-attr-id="{{ ::$ctrl.inputId }}" ng-attr-placeholder="{{ ::$ctrl.inputPlaceholder }}" ng-attr-type="{{ ::$ctrl.inputType }}" ng-attr-name="{{ ::$ctrl.inputName }}" ng-required="::$ctrl.inputRequired">
|
|
|
</div>
|
|
</div>
|
|
|
"""
|
|
"""
|
|
|
}
|
|
}
|