1
+ < link rel ="import " href ="../polymer/polymer.html " />
2
+ < link rel ="import " href ="../paper-input/paper-input.html " />
3
+ <!--
4
+ @group Xenon Elements
5
+ @element xenon-fullname-input
6
+ @demo demo/index.html
7
+ -->
8
+ < dom-module id ="xenon-fullname-input ">
9
+ < template >
10
+ < paper-input-container id ="container " invalid ="{{invalid}} ">
11
+ < label style ="left:40px; " hidden$ ="[[!label]] "> [[label]]</ label >
12
+ < div class ="horizontal layout ">
13
+ < input is ="iron-input "
14
+ id ="input "
15
+ class ="flex "
16
+ aria-labelledby$ ="[[_ariaLabelledBy]] "
17
+ aria-describedby$ ="[[_ariaDescribedBy]] "
18
+ required$ ="[[required]] "
19
+ bind-value ="{{value}} "
20
+ name$ ="[[name]] "
21
+ disabled$ ="[[disabled]] "
22
+ invalid ="{{invalid}} "
23
+ autofocus$ ="[[autofocus]] "
24
+ inputmode$ ="[[inputmode]] "
25
+ placeholder$ ="[[placeholder]] "
26
+ readonly$ ="[[readonly]] "
27
+ pattern$ ="[[pattern]] "
28
+ maxlength$ ="[[length]] "
29
+ prevent-invalid-input ="[[preventInvalidInput]] "
30
+ allowed-pattern ="[[allowedPattern]] ">
31
+ </ div >
32
+ < template is ="dom-if " if ="[[errorMessage]] ">
33
+ < paper-input-error id ="error "> [[errorMessage]]</ paper-input-error >
34
+ </ template >
35
+ </ paper-input-container >
36
+ </ template >
37
+ < script >
38
+ Polymer ( {
39
+ is : "xenon-fullname-input" ,
40
+ properties : {
41
+ value : { type : String , notify : true , value : "" } ,
42
+ firstname : { type : String , notify : true , value : "" } ,
43
+ middlename : { type : String , notify : true , value : "" } ,
44
+ lastname : { type : String , notify : true , value : "" } ,
45
+ } ,
46
+ behaviors : [
47
+ Polymer . PaperInputBehavior ,
48
+ Polymer . IronValidatableBehavior ,
49
+ Polymer . IronFormElementBehavior
50
+ ] ,
51
+ fullnamesplit : function ( ) {
52
+ var fullname = this . value . trim ( ) ;
53
+ var temp = fullname . split ( " " ) ;
54
+
55
+ var firstName = "" ;
56
+ var middleName = "" ;
57
+ var lastName = "" ;
58
+
59
+ if ( temp . length < 3 ) {
60
+ firstName = temp [ 0 ] ;
61
+ lastName = temp [ 1 ] ;
62
+ }
63
+ else {
64
+ firstName = temp [ 0 ] ;
65
+ middleName = temp [ 1 ] ;
66
+ lastName = temp [ 2 ] ;
67
+ }
68
+
69
+ this . set ( "firstname" , firstName ) ;
70
+ this . set ( "middlename" , middleName ) ;
71
+ this . set ( "lastname" , lastName ) ;
72
+
73
+ console . log ( "fistname: " + this . firstname ) ;
74
+ console . log ( "middlename: " + this . middlename ) ;
75
+ console . log ( "lastname: " + this . lastname ) ;
76
+ } ,
77
+ validate : function ( ) {
78
+ if ( this . value . split ( " " ) . length < 2 ) {
79
+ this . set ( "invalid" , true ) ;
80
+ return false ;
81
+ }
82
+ this . fullnamesplit ( ) ;
83
+ console . log ( this . $ . input . validate ( ) ) ;
84
+ return this . $ . input . validate ( ) ;
85
+ }
86
+ } )
87
+ </ script >
88
+ </ dom-module >
0 commit comments