Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature add for issue #1589 and issue #4704 #4705

Merged
merged 6 commits into from
Dec 6, 2015
15 changes: 12 additions & 3 deletions js/angular/service/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,10 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
* cssClass: '', // String, The custom CSS class name
* subTitle: '', // String (optional). The sub-title of the popup.
* template: '', // String (optional). The html template to place in the popup body.
* templateUrl: '', // String (optional). The URL of an html template to place in the popup body.
* templateUrl: '', // String (optional). The URL of an html template to place in the popup body.
* inputType: // String (default: 'text'). The type of input to use
* defaultText: // String (default: ''). The initial value placed into the input.
* maxLength: // Integer (default: null). Specify a maxlength attribute for the input.
* inputPlaceholder: // String (default: ''). A placeholder to use for the input.
* cancelText: // String (default: 'Cancel'. The text of the Cancel button.
* cancelType: // String (default: 'button-default'). The type of the Cancel button.
Expand Down Expand Up @@ -464,14 +466,21 @@ function($ionicTemplateLoader, $ionicBackdrop, $q, $timeout, $rootScope, $ionicB
function showPrompt(opts) {
var scope = $rootScope.$new(true);
scope.data = {};
scope.data.fieldtype = opts.inputType ? opts.inputType : 'text';
scope.data.response = opts.defaultText ? opts.defaultText : '';
scope.data.placeholder = opts.inputPlaceholder ? opts.inputPlaceholder : '';
scope.data.maxlength = opts.maxLength ? parseInt(opts.maxLength) : '';
var text = '';
if (opts.template && /<[a-z][\s\S]*>/i.test(opts.template) === false) {
text = '<span>' + opts.template + '</span>';
delete opts.template;
}
return showPopup(extend({
template: text + '<input ng-model="data.response" type="' + (opts.inputType || 'text') +
'" placeholder="' + (opts.inputPlaceholder || '') + '">',
template: text + '<input ng-model="data.response" '
+ 'type="{{ data.fieldtype }}"'
+ 'maxlength="{{ data.maxlength }}"'
+ 'placeholder="{{ data.placeholder }}"'
+ '>',
scope: scope,
buttons: [{
text: opts.cancelText || 'Cancel',
Expand Down