Skip to content

Commit

Permalink
Merge pull request #4705 from gregallensworth/master
Browse files Browse the repository at this point in the history
Feature add for issue #1589 and issue #4704
  • Loading branch information
mlynch committed Dec 6, 2015
2 parents 7aec81f + afd0efe commit 240cd30
Showing 1 changed file with 12 additions and 3 deletions.
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

0 comments on commit 240cd30

Please sign in to comment.