2
2
angular-input-hints v1.0.0
3
3
https://github.com/williamboman/angular-input-hints
4
4
5
- Copyright (c) 2014 William Boman <[email protected] >
5
+ Copyright (c) 2017 William Boman <[email protected] >
6
6
7
7
License: MIT (https://github.com/williamboman/angular-input-hints/blob/master/LICENSE)
8
8
*/
@@ -18,17 +18,16 @@ angular.module('wb.inputHints', [
18
18
angular
19
19
. module ( 'wb.inputHints.directive' , [ ] )
20
20
21
- . directive ( 'inputHints' , [ 'inputHints ' ,
22
- function ( inputHints ) {
21
+ . directive ( 'inputHints' , [ 'InputHints' , '$parse ',
22
+ function ( InputHints , $parse ) {
23
23
return {
24
24
restrict : 'A' ,
25
25
link : function ( scope , element , attr ) {
26
26
var userConfig = {
27
27
waitBeforeDeleteMs : attr . waitBeforeDeleting || attr . waitBeforeDelete ,
28
28
waitInBetweenMs : attr . waitInBetween ,
29
29
writeSpeedMs : attr . writeSpeed ,
30
- deleteSpeedMs : attr . deleteSpeed ,
31
- delimiter : attr . delimiter
30
+ deleteSpeedMs : attr . deleteSpeed
32
31
} ;
33
32
34
33
// Unset non-existing config values.
@@ -38,9 +37,8 @@ angular
38
37
}
39
38
} ) ;
40
39
41
- var ticker = new inputHints ( userConfig ) ;
42
-
43
- ticker . placeholders = attr . inputHints ;
40
+ var placeholders = $parse ( attr . inputHints ) ( scope ) ;
41
+ var ticker = new InputHints ( userConfig , placeholders ) ;
44
42
45
43
ticker . onTick = function ( newPlaceholderText ) {
46
44
element . attr ( 'placeholder' , newPlaceholderText ) ;
@@ -55,25 +53,26 @@ angular
55
53
angular
56
54
. module ( 'wb.inputHints.service' , [ ] )
57
55
58
- . provider ( 'inputHints ' , function ( ) {
56
+ . provider ( 'InputHints ' , function ( ) {
59
57
var config = this . config = {
60
58
waitBeforeDeleteMs : 2000 ,
61
59
waitInBetweenMs : 300 ,
62
60
writeSpeedMs : 100 ,
63
- deleteSpeedMs : 60 ,
64
- delimiter : '|'
61
+ deleteSpeedMs : 60
65
62
} ;
66
63
67
64
this . $get = [ '$timeout' ,
68
65
function ( $timeout ) {
69
66
70
- function Ticker ( userConfig ) {
67
+ function Ticker ( userConfig , placeholders ) {
71
68
userConfig = userConfig || { } ;
72
69
this . currentPlaceholderText = '' ;
73
70
this . currentPlaceholdersIndex = 0 ;
74
71
this . currentPlaceholderIndex = 0 ;
75
72
this . isDeleting = false ;
76
73
this . timeout = undefined ;
74
+ this . placeholders = placeholders ;
75
+ debugger
77
76
78
77
this . config = angular . copy ( config ) ;
79
78
angular . extend ( this . config , userConfig ) ;
@@ -84,11 +83,6 @@ angular
84
83
if ( ! this . placeholders ) {
85
84
throw new TypeError ( '[wb.inputHints] This instance of Ticker is missing Ticker.placeholders property.' ) ;
86
85
}
87
- this . placeholders = this . placeholders . split ( this . config . delimiter ) ;
88
-
89
- if ( this . userConfig ) {
90
- angular . extend ( this . config , this . userConfig ) ;
91
- }
92
86
93
87
if ( ! this . onTick || typeof this . onTick !== 'function' ) {
94
88
throw new TypeError ( '[wb.inputHints] This instance of Ticker is missing a valid Ticker.onTick callback function.' ) ;
0 commit comments