@@ -18,7 +18,7 @@ IonPopup = {
18
18
if ( options . templateName ) {
19
19
innerTemplate = Template [ options . templateName ] . renderFunction ( ) . value ;
20
20
} else {
21
- innerTemplate = options . template ;
21
+ innerTemplate = '<span>' + options . template + '</span>' ;
22
22
}
23
23
24
24
var data = {
@@ -66,15 +66,52 @@ IonPopup = {
66
66
{
67
67
text : options . okText ? options . okText : 'Ok' ,
68
68
type : options . okType ? options . okType : 'button-positive' ,
69
- onTap : function ( ) {
69
+ onTap : function ( event ) {
70
70
if ( options . onOk ) options . onOk ( event ) ;
71
71
return true ;
72
72
}
73
73
} ,
74
74
{
75
75
text : options . cancelText ? options . cancelText : 'Cancel' ,
76
76
type : options . cancelType ? options . cancelType : 'button-default' ,
77
- onTap : function ( ) {
77
+ onTap : function ( event ) {
78
+ if ( options . onCancel ) options . onCancel ( event ) ;
79
+ return true ;
80
+ }
81
+ }
82
+ ]
83
+ } ) ;
84
+ } ,
85
+
86
+ prompt : function ( options ) {
87
+
88
+ if ( options . templateName ) {
89
+ template = Template [ options . templateName ] . renderFunction ( ) . value ;
90
+ } else {
91
+ template = '<span>' + options . template + '</span>' ;
92
+ }
93
+
94
+ template += '<input type="' + options . inputType + '" placeholder="' +
95
+ options . inputPlaceholder + '" name="prompt" >' ;
96
+
97
+ IonPopup . show ( {
98
+ title : options . title ,
99
+ subTitle : options . subtitle ,
100
+ template : template ,
101
+ buttons : [
102
+ {
103
+ text : options . okText ? options . okText : 'Ok' ,
104
+ type : options . okType ? options . okType : 'button-positive' ,
105
+ onTap : function ( event , template ) {
106
+ var inputVal = $ ( template . firstNode ) . find ( '[name=prompt]' ) . val ( ) ;
107
+ if ( options . onOk ) options . onOk ( event , inputVal ) ;
108
+ return true ;
109
+ }
110
+ } ,
111
+ {
112
+ text : options . cancelText ? options . cancelText : 'Cancel' ,
113
+ type : options . cancelType ? options . cancelType : 'button-default' ,
114
+ onTap : function ( event ) {
78
115
if ( options . onCancel ) options . onCancel ( event ) ;
79
116
return true ;
80
117
}
@@ -94,10 +131,10 @@ IonPopup = {
94
131
} . bind ( this ) , 100 ) ;
95
132
} ,
96
133
97
- buttonClicked : function ( index , event ) {
134
+ buttonClicked : function ( index , event , template ) {
98
135
var callback = this . buttons [ index ] . onTap ;
99
136
if ( callback ) {
100
- if ( callback ( event ) === true ) {
137
+ if ( callback ( event , template ) === true ) {
101
138
IonPopup . close ( ) ;
102
139
}
103
140
}
@@ -126,7 +163,7 @@ Template.ionPopup.events({
126
163
127
164
'click [data-index]' : function ( event , template ) {
128
165
var index = $ ( event . target ) . data ( 'index' ) ;
129
- IonPopup . buttonClicked ( index , event ) ;
166
+ IonPopup . buttonClicked ( index , event , template ) ;
130
167
}
131
168
132
169
} ) ;
0 commit comments