Skip to content

Commit 240cd30

Browse files
committed
Merge pull request #4705 from gregallensworth/master
Feature add for issue #1589 and issue #4704
2 parents 7aec81f + afd0efe commit 240cd30

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Diff for: js/angular/service/popup.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,10 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
251251
* cssClass: '', // String, The custom CSS class name
252252
* subTitle: '', // String (optional). The sub-title of the popup.
253253
* template: '', // String (optional). The html template to place in the popup body.
254-
* templateUrl: '', // String (optional). The URL of an html template to place in the popup body.
254+
* templateUrl: '', // String (optional). The URL of an html template to place in the popup body.
255255
* inputType: // String (default: 'text'). The type of input to use
256+
* defaultText: // String (default: ''). The initial value placed into the input.
257+
* maxLength: // Integer (default: null). Specify a maxlength attribute for the input.
256258
* inputPlaceholder: // String (default: ''). A placeholder to use for the input.
257259
* cancelText: // String (default: 'Cancel'. The text of the Cancel button.
258260
* cancelType: // String (default: 'button-default'). The type of the Cancel button.
@@ -464,14 +466,21 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
464466
function showPrompt(opts) {
465467
var scope = $rootScope.$new(true);
466468
scope.data = {};
469+
scope.data.fieldtype = opts.inputType ? opts.inputType : 'text';
470+
scope.data.response = opts.defaultText ? opts.defaultText : '';
471+
scope.data.placeholder = opts.inputPlaceholder ? opts.inputPlaceholder : '';
472+
scope.data.maxlength = opts.maxLength ? parseInt(opts.maxLength) : '';
467473
var text = '';
468474
if (opts.template && /<[a-z][\s\S]*>/i.test(opts.template) === false) {
469475
text = '<span>' + opts.template + '</span>';
470476
delete opts.template;
471477
}
472478
return showPopup(extend({
473-
template: text + '<input ng-model="data.response" type="' + (opts.inputType || 'text') +
474-
'" placeholder="' + (opts.inputPlaceholder || '') + '">',
479+
template: text + '<input ng-model="data.response" '
480+
+ 'type="{{ data.fieldtype }}"'
481+
+ 'maxlength="{{ data.maxlength }}"'
482+
+ 'placeholder="{{ data.placeholder }}"'
483+
+ '>',
475484
scope: scope,
476485
buttons: [{
477486
text: opts.cancelText || 'Cancel',

0 commit comments

Comments
 (0)