9 * @class Roo.bootstrap.PhoneInput
10 * @extends Roo.bootstrap.TriggerField
11 * Bootstrap PhoneInput class
14 * Create a new PhoneInput
15 * @param {Object} config The config object
18 Roo.bootstrap.PhoneInput = function(config){
19 Roo.bootstrap.PhoneInput.superclass.constructor.call(this, config);
28 this.selectedIndex = -1;
29 if(this.mode == 'local'){
30 if(config.queryDelay === undefined){
33 if(config.minChars === undefined){
39 Roo.extend(Roo.bootstrap.PhoneInput, Roo.bootstrap.TriggerField, {
41 //setting properties..
43 getAutoCreate : function()
48 * Render classic select for iso
51 if(Roo.isIOS && this.useNativeIOS){
52 cfg = this.getAutoCreateNativeIOS();
60 if(Roo.isTouch && this.mobileTouchView){
61 cfg = this.getAutoCreateTouchView();
69 cfg = Roo.bootstrap.PhoneInput.superclass.getAutoCreate.call(this);
74 * PhoneInput with tickable selections
77 var align = this.labelAlign || this.parentLabelAlign();
80 cls : 'form-group roo-PhoneInput-tickable' //input-group
83 var btn_text_select = '';
84 var btn_text_done = '';
85 var btn_text_cancel = '';
87 if (this.btn_text_show) {
88 btn_text_select = 'Select';
89 btn_text_done = 'Done';
90 btn_text_cancel = 'Cancel';
95 cls : 'tickable-buttons',
100 cls : 'btn btn-link btn-edit pull-' + this.btnPosition,
101 //html : this.triggerText
102 html: btn_text_select
108 cls : 'btn btn-link btn-ok pull-' + this.btnPosition,
116 cls : 'btn btn-link btn-cancel pull-' + this.btnPosition,
118 html: btn_text_cancel
126 cls: 'roo-select2-search-field-input'
132 Roo.each(buttons.cn, function(c){
134 c.cls += ' btn-' + _this.size;
137 if (_this.disabled) {
148 cls: 'form-hidden-field'
152 cls: 'roo-select2-choices',
156 cls: 'roo-select2-search-field',
167 cls: 'roo-select2-container input-group roo-select2-container-multi',
172 // cls: 'typeahead typeahead-long dropdown-menu',
173 // style: 'display:none; max-height:' + this.maxHeight + 'px;'
178 if(this.hasFeedback && !this.allowBlank){
182 cls: 'glyphicon form-control-feedback'
185 PhoneInput.cn.push(feedback);
189 if (align ==='left' && this.fieldLabel.length) {
191 cfg.cls += ' roo-form-group-label-left';
196 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
197 tooltip : 'This field is required'
202 cls : 'control-label',
203 html : this.fieldLabel
215 var labelCfg = cfg.cn[1];
216 var contentCfg = cfg.cn[2];
219 if(this.indicatorpos == 'right'){
225 cls : 'control-label',
229 html : this.fieldLabel
233 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
234 tooltip : 'This field is required'
249 labelCfg = cfg.cn[0];
250 contentCfg = cfg.cn[1];
254 if(this.labelWidth > 12){
255 labelCfg.style = "width: " + this.labelWidth + 'px';
258 if(this.labelWidth < 13 && this.labelmd == 0){
259 this.labelmd = this.labelWidth;
262 if(this.labellg > 0){
263 labelCfg.cls += ' col-lg-' + this.labellg;
264 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
267 if(this.labelmd > 0){
268 labelCfg.cls += ' col-md-' + this.labelmd;
269 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
272 if(this.labelsm > 0){
273 labelCfg.cls += ' col-sm-' + this.labelsm;
274 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
277 if(this.labelxs > 0){
278 labelCfg.cls += ' col-xs-' + this.labelxs;
279 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
283 } else if ( this.fieldLabel.length) {
287 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
288 tooltip : 'This field is required'
292 //cls : 'input-group-addon',
293 html : this.fieldLabel
298 if(this.indicatorpos == 'right'){
302 //cls : 'input-group-addon',
303 html : this.fieldLabel
307 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
308 tooltip : 'This field is required'
323 ['xs','sm','md','lg'].map(function(size){
324 if (settings[size]) {
325 cfg.cls += ' col-' + size + '-' + settings[size];
333 _initEventsCalled : false,
336 initEvents: function()
338 if (this._initEventsCalled) { // as we call render... prevent looping...
341 this._initEventsCalled = true;
344 throw "can not find store for combo";
347 this.store = Roo.factory(this.store, Roo.data);
348 this.store.parent = this;
350 // if we are building from html. then this element is so complex, that we can not really
351 // use the rendered HTML.
352 // so we have to trash and replace the previous code.
353 if (Roo.XComponent.build_from_html) {
355 // remove this element....
356 var e = this.el.dom, k=0;
357 while (e ) { e = e.previousSibling; ++k;}
362 this.rendered = false;
364 this.render(this.parent().getChildContainer(true), k);
370 if(Roo.isIOS && this.useNativeIOS){
379 if(Roo.isTouch && this.mobileTouchView){
380 this.initTouchView();
385 this.initTickableEvents();
389 Roo.bootstrap.PhoneInput.superclass.initEvents.call(this);
393 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
395 this.hiddenField.dom.value =
396 this.hiddenValue !== undefined ? this.hiddenValue :
397 this.value !== undefined ? this.value : '';
399 // prevent input submission
400 this.el.dom.removeAttribute('name');
401 this.hiddenField.dom.setAttribute('name', this.hiddenName);
406 // this.el.dom.setAttribute('autocomplete', 'off');
409 var cls = 'x-combo-list';
411 //this.list = new Roo.Layer({
412 // shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
418 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
419 _this.list.setWidth(lw);
422 this.list.on('mouseover', this.onViewOver, this);
423 this.list.on('mousemove', this.onViewMove, this);
425 this.list.on('scroll', this.onViewScroll, this);
428 this.list.swallowEvent('mousewheel');
429 this.assetHeight = 0;
432 this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
433 this.assetHeight += this.header.getHeight();
436 this.innerList = this.list.createChild({cls:cls+'-inner'});
437 this.innerList.on('mouseover', this.onViewOver, this);
438 this.innerList.on('mousemove', this.onViewMove, this);
439 this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
441 if(this.allowBlank && !this.pageSize && !this.disableClear){
442 this.footer = this.list.createChild({cls:cls+'-ft'});
443 this.pageTb = new Roo.Toolbar(this.footer);
447 this.footer = this.list.createChild({cls:cls+'-ft'});
448 this.pageTb = new Roo.PagingToolbar(this.footer, this.store,
449 {pageSize: this.pageSize});
453 if (this.pageTb && this.allowBlank && !this.disableClear) {
455 this.pageTb.add(new Roo.Toolbar.Fill(), {
456 cls: 'x-btn-icon x-btn-clear',
462 _this.onSelect(false, -1);
467 this.assetHeight += this.footer.getHeight();
472 this.tpl = '<li><a href="#">{' + this.displayField + '}</a></li>';
475 this.view = new Roo.View(this.list, this.tpl, {
476 singleSelect:true, store: this.store, selectedClass: this.selectedClass
478 //this.view.wrapEl.setDisplayed(false);
479 this.view.on('click', this.onViewClick, this);
482 this.store.on('beforeload', this.onBeforeLoad, this);
483 this.store.on('load', this.onLoad, this);
484 this.store.on('loadexception', this.onLoadException, this);
487 this.resizer = new Roo.Resizable(this.list, {
488 pinned:true, handles:'se'
490 this.resizer.on('resize', function(r, w, h){
491 this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
493 this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
494 this.restrictHeight();
496 this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
500 this.editable = true;
501 this.setEditable(false);
506 if (typeof(this.events.add.listeners) != 'undefined') {
508 this.addicon = this.wrap.createChild(
509 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-add' });
511 this.addicon.on('click', function(e) {
512 this.fireEvent('add', this);
515 if (typeof(this.events.edit.listeners) != 'undefined') {
517 this.editicon = this.wrap.createChild(
518 {tag: 'img', src: Roo.BLANK_IMAGE_URL, cls: 'x-form-combo-edit' });
520 this.editicon.setStyle('margin-left', '40px');
522 this.editicon.on('click', function(e) {
524 // we fire even if inothing is selected..
525 this.fireEvent('edit', this, this.lastData );
531 this.keyNav = new Roo.KeyNav(this.inputEl(), {
533 this.inKeyMode = true;
537 "down" : function(e){
538 if(!this.isExpanded()){
539 this.onTriggerClick();
541 this.inKeyMode = true;
546 "enter" : function(e){
547 // this.onViewClick();
551 if(this.fireEvent("specialkey", this, e)){
552 this.onViewClick(false);
565 if(this.fireEvent("specialkey", this, e)){
566 this.onViewClick(false);
574 doRelay : function(foo, bar, hname){
575 if(hname == 'down' || this.scope.isExpanded()){
576 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
585 this.queryDelay = Math.max(this.queryDelay || 10,
586 this.mode == 'local' ? 10 : 250);
589 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
592 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
594 if(this.editable !== false){
595 this.inputEl().on("keyup", this.onKeyUp, this);
597 if(this.forceSelection){
598 this.inputEl().on('blur', this.doForce, this);
602 this.choices = this.el.select('ul.roo-select2-choices', true).first();
603 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
607 initTickableEvents: function()
613 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
615 this.hiddenField.dom.value =
616 this.hiddenValue !== undefined ? this.hiddenValue :
617 this.value !== undefined ? this.value : '';
619 // prevent input submission
620 this.el.dom.removeAttribute('name');
621 this.hiddenField.dom.setAttribute('name', this.hiddenName);
626 // this.list = this.el.select('ul.dropdown-menu',true).first();
628 this.choices = this.el.select('ul.roo-select2-choices', true).first();
629 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
630 if(this.triggerList){
631 this.searchField.on("click", this.onSearchFieldClick, this, {preventDefault:true});
634 this.trigger = this.el.select('.tickable-buttons > .btn-edit', true).first();
635 this.trigger.on("click", this.onTickableTriggerClick, this, {preventDefault:true});
637 this.okBtn = this.el.select('.tickable-buttons > .btn-ok', true).first();
638 this.cancelBtn = this.el.select('.tickable-buttons > .btn-cancel', true).first();
640 this.okBtn.on('click', this.onTickableFooterButtonClick, this, this.okBtn);
641 this.cancelBtn.on('click', this.onTickableFooterButtonClick, this, this.cancelBtn);
643 this.trigger.setVisibilityMode(Roo.Element.DISPLAY);
644 this.okBtn.setVisibilityMode(Roo.Element.DISPLAY);
645 this.cancelBtn.setVisibilityMode(Roo.Element.DISPLAY);
648 this.cancelBtn.hide();
653 var lw = _this.listWidth || Math.max(_this.inputEl().getWidth(), _this.minListWidth);
654 _this.list.setWidth(lw);
657 this.list.on('mouseover', this.onViewOver, this);
658 this.list.on('mousemove', this.onViewMove, this);
660 this.list.on('scroll', this.onViewScroll, this);
663 this.tpl = '<li class="roo-select2-result"><div class="checkbox"><input id="{roo-id}" type="checkbox" {roo-data-checked}><label for="{roo-id}"><b>{' + this.displayField + '}</b></label></div></li>';
666 this.view = new Roo.View(this.list, this.tpl, {
667 singleSelect:true, tickable:true, parent:this, store: this.store, selectedClass: this.selectedClass
670 //this.view.wrapEl.setDisplayed(false);
671 this.view.on('click', this.onViewClick, this);
675 this.store.on('beforeload', this.onBeforeLoad, this);
676 this.store.on('load', this.onLoad, this);
677 this.store.on('loadexception', this.onLoadException, this);
680 this.keyNav = new Roo.KeyNav(this.tickableInputEl(), {
682 this.inKeyMode = true;
686 "down" : function(e){
687 this.inKeyMode = true;
691 "enter" : function(e){
692 if(this.fireEvent("specialkey", this, e)){
693 this.onViewClick(false);
700 this.onTickableFooterButtonClick(e, false, false);
704 this.fireEvent("specialkey", this, e);
706 this.onTickableFooterButtonClick(e, false, false);
713 doRelay : function(e, fn, key){
714 if(this.scope.isExpanded()){
715 return Roo.KeyNav.prototype.doRelay.apply(this, arguments);
724 this.queryDelay = Math.max(this.queryDelay || 10,
725 this.mode == 'local' ? 10 : 250);
728 this.dqTask = new Roo.util.DelayedTask(this.initQuery, this);
731 this.taTask = new Roo.util.DelayedTask(this.onTypeAhead, this);
734 if(this.editable !== false){
735 this.tickableInputEl().on("keyup", this.onKeyUp, this);
738 this.indicator = this.indicatorEl();
741 this.indicator.setVisibilityMode(Roo.Element.DISPLAY);
742 this.indicator.hide();
747 onDestroy : function(){
749 this.view.setStore(null);
750 this.view.el.removeAllListeners();
751 this.view.el.remove();
752 this.view.purgeListeners();
755 this.list.dom.innerHTML = '';
759 this.store.un('beforeload', this.onBeforeLoad, this);
760 this.store.un('load', this.onLoad, this);
761 this.store.un('loadexception', this.onLoadException, this);
763 Roo.bootstrap.PhoneInput.superclass.onDestroy.call(this);
767 fireKey : function(e){
768 if(e.isNavKeyPress() && !this.list.isVisible()){
769 this.fireEvent("specialkey", this, e);
774 onResize: function(w, h){
775 // Roo.bootstrap.PhoneInput.superclass.onResize.apply(this, arguments);
777 // if(typeof w != 'number'){
778 // // we do not handle it!?!?
781 // var tw = this.trigger.getWidth();
782 // // tw += this.addicon ? this.addicon.getWidth() : 0;
783 // // tw += this.editicon ? this.editicon.getWidth() : 0;
785 // this.inputEl().setWidth( this.adjustWidth('input', x));
787 // //this.trigger.setStyle('left', x+'px');
789 // if(this.list && this.listWidth === undefined){
790 // var lw = Math.max(x + this.trigger.getWidth(), this.minListWidth);
791 // this.list.setWidth(lw);
792 // this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
800 * Allow or prevent the user from directly editing the field text. If false is passed,
801 * the user will only be able to select from the items defined in the dropdown list. This method
802 * is the runtime equivalent of setting the 'editable' config option at config time.
803 * @param {Boolean} value True to allow the user to directly edit the field text
805 setEditable : function(value){
806 if(value == this.editable){
809 this.editable = value;
811 this.inputEl().dom.setAttribute('readOnly', true);
812 this.inputEl().on('mousedown', this.onTriggerClick, this);
813 this.inputEl().addClass('x-combo-noedit');
815 this.inputEl().dom.setAttribute('readOnly', false);
816 this.inputEl().un('mousedown', this.onTriggerClick, this);
817 this.inputEl().removeClass('x-combo-noedit');
823 onBeforeLoad : function(combo,opts){
828 this.list.dom.innerHTML = '<li class="loading-indicator">'+(this.loadingText||'loading')+'</li>' ;
830 this.restrictHeight();
831 this.selectedIndex = -1;
837 this.hasQuery = false;
843 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
847 if(this.store.getCount() > 0){
850 this.restrictHeight();
851 if(this.lastQuery == this.allQuery){
852 if(this.editable && !this.tickable){
853 this.inputEl().dom.select();
857 !this.selectByValue(this.value, true) &&
860 !this.store.lastOptions ||
861 typeof(this.store.lastOptions.add) == 'undefined' ||
862 this.store.lastOptions.add != true
865 this.select(0, true);
871 if(this.typeAhead && this.lastKey != Roo.EventObject.BACKSPACE && this.lastKey != Roo.EventObject.DELETE){
872 this.taTask.delay(this.typeAheadDelay);
876 this.onEmptyResults();
882 onLoadException : function()
884 this.hasQuery = false;
886 if(typeof(this.loading) !== 'undefined' && this.loading !== null){
890 if(this.tickable && this.editable){
895 // only causes errors at present
896 //Roo.log(this.store.reader.jsonData);
897 //if (this.store && typeof(this.store.reader.jsonData.errorMsg) != 'undefined') {
899 //Roo.MessageBox.alert("Error loading",this.store.reader.jsonData.errorMsg);
905 onTypeAhead : function(){
906 if(this.store.getCount() > 0){
907 var r = this.store.getAt(0);
908 var newValue = r.data[this.displayField];
909 var len = newValue.length;
910 var selStart = this.getRawValue().length;
913 this.setRawValue(newValue);
914 this.selectText(selStart, newValue.length);
920 onSelect : function(record, index){
922 if(this.fireEvent('beforeselect', this, record, index) !== false){
924 this.setFromData(index > -1 ? record.data : false);
927 this.fireEvent('select', this, record, index);
932 * Returns the currently selected field value or empty string if no value is set.
933 * @return {String} value The selected value
935 getValue : function()
937 if(Roo.isIOS && this.useNativeIOS){
938 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.valueField];
942 return (this.hiddenField) ? this.hiddenField.dom.value : this.value;
946 return typeof this.value != 'undefined' ? this.value : '';
948 return Roo.bootstrap.PhoneInput.superclass.getValue.call(this);
952 getRawValue : function()
954 if(Roo.isIOS && this.useNativeIOS){
955 return this.ios_options[this.inputEl().dom.selectedIndex].data[this.displayField];
958 var v = this.inputEl().getValue();
964 * Clears any text/value currently set in the field
966 clearValue : function(){
968 if(this.hiddenField){
969 this.hiddenField.dom.value = '';
972 this.setRawValue('');
973 this.lastSelectionText = '';
974 this.lastData = false;
976 var close = this.closeTriggerEl();
987 * Sets the specified value into the field. If the value finds a match, the corresponding record text
988 * will be displayed in the field. If the value does not match the data value of an existing item,
989 * and the valueNotFoundText config option is defined, it will be displayed as the default field text.
990 * Otherwise the field will be blank (although the value will still be set).
991 * @param {String} value The value to match
993 setValue : function(v)
995 if(Roo.isIOS && this.useNativeIOS){
1006 if(this.valueField){
1007 var r = this.findRecord(this.valueField, v);
1009 text = r.data[this.displayField];
1010 }else if(this.valueNotFoundText !== undefined){
1011 text = this.valueNotFoundText;
1014 this.lastSelectionText = text;
1015 if(this.hiddenField){
1016 this.hiddenField.dom.value = v;
1018 Roo.bootstrap.PhoneInput.superclass.setValue.call(this, text);
1021 var close = this.closeTriggerEl();
1024 (v && (v.length || v * 1 > 0)) ? close.show() : close.hide();
1030 * @property {Object} the last set data for the element
1035 * Sets the value of the field based on a object which is related to the record format for the store.
1036 * @param {Object} value the value to set as. or false on reset?
1038 setFromData : function(o){
1045 var dv = ''; // display value
1046 var vv = ''; // value value..
1048 if (this.displayField) {
1049 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1051 // this is an error condition!!!
1052 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1055 if(this.valueField){
1056 vv = !o || typeof(o[this.valueField]) == 'undefined' ? dv : o[this.valueField];
1059 var close = this.closeTriggerEl();
1062 (vv.length || vv * 1 > 0) ? close.show() : close.hide();
1065 if(this.hiddenField){
1066 this.hiddenField.dom.value = vv;
1068 this.lastSelectionText = dv;
1069 Roo.bootstrap.PhoneInput.superclass.setValue.call(this, dv);
1073 // no hidden field.. - we store the value in 'value', but still display
1074 // display field!!!!
1075 this.lastSelectionText = dv;
1076 Roo.bootstrap.PhoneInput.superclass.setValue.call(this, dv);
1084 // overridden so that last data is reset..
1091 this.setValue(this.originalValue);
1092 //this.clearInvalid();
1093 this.lastData = false;
1095 this.view.clearSelections();
1101 findRecord : function(prop, value){
1103 if(this.store.getCount() > 0){
1104 this.store.each(function(r){
1105 if(r.data[prop] == value){
1117 // returns hidden if it's set..
1118 if (!this.rendered) {return ''};
1119 return !this.hiddenName && this.inputEl().dom.name ? this.inputEl().dom.name : (this.hiddenName || '');
1123 onViewMove : function(e, t){
1124 this.inKeyMode = false;
1128 onViewOver : function(e, t){
1129 if(this.inKeyMode){ // prevent key nav and mouse over conflicts
1132 var item = this.view.findItemFromChild(t);
1135 var index = this.view.indexOf(item);
1136 this.select(index, false);
1141 onViewClick : function(view, doFocus, el, e)
1143 var index = this.view.getSelectedIndexes()[0];
1145 var r = this.store.getAt(index);
1149 if(typeof(e) != 'undefined' && e.getTarget().nodeName.toLowerCase() != 'input'){
1156 Roo.each(this.tickItems, function(v,k){
1158 if(typeof(v) != 'undefined' && v[_this.valueField] == r.data[_this.valueField]){
1159 _this.tickItems.splice(k, 1);
1161 if(typeof(e) == 'undefined' && view == false){
1162 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = false;
1174 if(this.fireEvent('tick', this, r, index, Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked) !== false){
1175 this.tickItems.push(r.data);
1178 if(typeof(e) == 'undefined' && view == false){
1179 Roo.get(_this.view.getNodes(index, index)[0]).select('input', true).first().dom.checked = true;
1186 this.onSelect(r, index);
1188 if(doFocus !== false && !this.blockFocus){
1189 this.inputEl().focus();
1194 restrictHeight : function(){
1195 //this.innerList.dom.style.height = '';
1196 //var inner = this.innerList.dom;
1197 //var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
1198 //this.innerList.setHeight(h < this.maxHeight ? 'auto' : this.maxHeight);
1199 //this.list.beginUpdate();
1200 //this.list.setHeight(this.innerList.getHeight()+this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight);
1201 this.list.alignTo(this.inputEl(), this.listAlign);
1202 this.list.alignTo(this.inputEl(), this.listAlign);
1203 //this.list.endUpdate();
1207 onEmptyResults : function(){
1209 if(this.tickable && this.editable){
1210 this.restrictHeight();
1218 * Returns true if the dropdown list is expanded, else false.
1220 isExpanded : function(){
1221 return this.list.isVisible();
1225 * Select an item in the dropdown list by its data value. This function does NOT cause the select event to fire.
1226 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1227 * @param {String} value The data value of the item to select
1228 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1229 * selected item if it is not currently in view (defaults to true)
1230 * @return {Boolean} True if the value matched an item in the list, else false
1232 selectByValue : function(v, scrollIntoView){
1233 if(v !== undefined && v !== null){
1234 var r = this.findRecord(this.valueField || this.displayField, v);
1236 this.select(this.store.indexOf(r), scrollIntoView);
1244 * Select an item in the dropdown list by its numeric index in the list. This function does NOT cause the select event to fire.
1245 * The store must be loaded and the list expanded for this function to work, otherwise use setValue.
1246 * @param {Number} index The zero-based index of the list item to select
1247 * @param {Boolean} scrollIntoView False to prevent the dropdown list from autoscrolling to display the
1248 * selected item if it is not currently in view (defaults to true)
1250 select : function(index, scrollIntoView){
1251 this.selectedIndex = index;
1252 this.view.select(index);
1253 if(scrollIntoView !== false){
1254 var el = this.view.getNode(index);
1256 * el && !this.multiple && !this.tickable // not sure why we disable multiple before..
1259 this.list.scrollChildIntoView(el, false);
1265 selectNext : function(){
1266 var ct = this.store.getCount();
1268 if(this.selectedIndex == -1){
1270 }else if(this.selectedIndex < ct-1){
1271 this.select(this.selectedIndex+1);
1277 selectPrev : function(){
1278 var ct = this.store.getCount();
1280 if(this.selectedIndex == -1){
1282 }else if(this.selectedIndex != 0){
1283 this.select(this.selectedIndex-1);
1289 onKeyUp : function(e){
1290 if(this.editable !== false && !e.isSpecialKey()){
1291 this.lastKey = e.getKey();
1292 this.dqTask.delay(this.queryDelay);
1297 validateBlur : function(){
1298 return !this.list || !this.list.isVisible();
1302 initQuery : function(){
1304 var v = this.getRawValue();
1306 if(this.tickable && this.editable){
1307 v = this.tickableInputEl().getValue();
1314 doForce : function(){
1315 if(this.inputEl().dom.value.length > 0){
1316 this.inputEl().dom.value =
1317 this.lastSelectionText === undefined ? '' : this.lastSelectionText;
1323 * Execute a query to filter the dropdown list. Fires the beforequery event prior to performing the
1324 * query allowing the query action to be canceled if needed.
1325 * @param {String} query The SQL query to execute
1326 * @param {Boolean} forceAll True to force the query to execute even if there are currently fewer characters
1327 * in the field than the minimum specified by the minChars config option. It also clears any filter previously
1328 * saved in the current store (defaults to false)
1330 doQuery : function(q, forceAll){
1332 if(q === undefined || q === null){
1341 if(this.fireEvent('beforequery', qe)===false || qe.cancel){
1346 forceAll = qe.forceAll;
1347 if(forceAll === true || (q.length >= this.minChars)){
1349 this.hasQuery = true;
1351 if(this.lastQuery != q || this.alwaysQuery){
1353 if(this.mode == 'local'){
1354 this.selectedIndex = -1;
1356 this.store.clearFilter();
1359 if(this.specialFilter){
1360 this.fireEvent('specialfilter', this);
1365 this.store.filter(this.displayField, q);
1368 this.store.fireEvent("datachanged", this.store);
1375 this.store.baseParams[this.queryParam] = q;
1377 var options = {params : this.getParams(q)};
1381 options.params.start = this.page * this.pageSize;
1384 this.store.load(options);
1387 * this code will make the page width larger, at the beginning, the list not align correctly,
1388 * we should expand the list on onLoad
1394 this.selectedIndex = -1;
1399 this.loadNext = false;
1403 getParams : function(q){
1405 //p[this.queryParam] = q;
1409 p.limit = this.pageSize;
1415 * Hides the dropdown list if it is currently expanded. Fires the 'collapse' event on completion.
1417 collapse : function(){
1418 if(!this.isExpanded()){
1424 this.hasFocus = false;
1428 this.cancelBtn.hide();
1429 this.trigger.show();
1432 this.tickableInputEl().dom.value = '';
1433 this.tickableInputEl().blur();
1438 Roo.get(document).un('mousedown', this.collapseIf, this);
1439 Roo.get(document).un('mousewheel', this.collapseIf, this);
1440 if (!this.editable) {
1441 Roo.get(document).un('keydown', this.listKeyPress, this);
1443 this.fireEvent('collapse', this);
1449 collapseIf : function(e){
1450 var in_combo = e.within(this.el);
1451 var in_list = e.within(this.list);
1452 var is_list = (Roo.get(e.getTarget()).id == this.list.id) ? true : false;
1454 if (in_combo || in_list || is_list) {
1455 //e.stopPropagation();
1460 this.onTickableFooterButtonClick(e, false, false);
1468 * Expands the dropdown list if it is currently hidden. Fires the 'expand' event on completion.
1470 expand : function(){
1472 if(this.isExpanded() || !this.hasFocus){
1476 var lw = this.listWidth || Math.max(this.inputEl().getWidth(), this.minListWidth);
1477 this.list.setWidth(lw);
1483 this.restrictHeight();
1487 this.tickItems = Roo.apply([], this.item);
1490 this.cancelBtn.show();
1491 this.trigger.hide();
1494 this.tickableInputEl().focus();
1499 Roo.get(document).on('mousedown', this.collapseIf, this);
1500 Roo.get(document).on('mousewheel', this.collapseIf, this);
1501 if (!this.editable) {
1502 Roo.get(document).on('keydown', this.listKeyPress, this);
1505 this.fireEvent('expand', this);
1509 // Implements the default empty TriggerField.onTriggerClick function
1510 onTriggerClick : function(e)
1512 Roo.log('trigger click');
1514 if(this.disabled || !this.triggerList){
1519 this.loadNext = false;
1521 if(this.isExpanded()){
1523 if (!this.blockFocus) {
1524 this.inputEl().focus();
1528 this.hasFocus = true;
1529 if(this.triggerAction == 'all') {
1530 this.doQuery(this.allQuery, true);
1532 this.doQuery(this.getRawValue());
1534 if (!this.blockFocus) {
1535 this.inputEl().focus();
1540 onTickableTriggerClick : function(e)
1547 this.loadNext = false;
1548 this.hasFocus = true;
1550 if(this.triggerAction == 'all') {
1551 this.doQuery(this.allQuery, true);
1553 this.doQuery(this.getRawValue());
1557 onSearchFieldClick : function(e)
1559 if(this.hasFocus && !this.disabled && e.getTarget().nodeName.toLowerCase() != 'button'){
1560 this.onTickableFooterButtonClick(e, false, false);
1564 if(this.hasFocus || this.disabled || e.getTarget().nodeName.toLowerCase() == 'button'){
1569 this.loadNext = false;
1570 this.hasFocus = true;
1572 if(this.triggerAction == 'all') {
1573 this.doQuery(this.allQuery, true);
1575 this.doQuery(this.getRawValue());
1579 listKeyPress : function(e)
1581 //Roo.log('listkeypress');
1582 // scroll to first matching element based on key pres..
1583 if (e.isSpecialKey()) {
1586 var k = String.fromCharCode(e.getKey()).toUpperCase();
1589 var csel = this.view.getSelectedNodes();
1590 var cselitem = false;
1592 var ix = this.view.indexOf(csel[0]);
1593 cselitem = this.store.getAt(ix);
1594 if (!cselitem.get(this.displayField) || cselitem.get(this.displayField).substring(0,1).toUpperCase() != k) {
1600 this.store.each(function(v) {
1602 // start at existing selection.
1603 if (cselitem.id == v.id) {
1609 if (v.get(this.displayField) && v.get(this.displayField).substring(0,1).toUpperCase() == k) {
1610 match = this.store.indexOf(v);
1616 if (match === false) {
1617 return true; // no more action?
1620 this.view.select(match);
1621 var sn = Roo.get(this.view.getSelectedNodes()[0]);
1622 sn.scrollIntoView(sn.dom.parentNode, false);
1625 onViewScroll : function(e, t){
1627 if(this.view.el.getScroll().top == 0 ||this.view.el.getScroll().top < this.view.el.dom.scrollHeight - this.view.el.dom.clientHeight || !this.hasFocus || !this.append || this.hasQuery){
1631 this.hasQuery = true;
1633 this.loading = this.list.select('.loading', true).first();
1635 if(this.loading === null){
1636 this.list.createChild({
1638 cls: 'loading roo-select2-more-results roo-select2-active',
1639 html: 'Loading more results...'
1642 this.loading = this.list.select('.loading', true).first();
1644 this.loading.setVisibilityMode(Roo.Element.DISPLAY);
1646 this.loading.hide();
1649 this.loading.show();
1654 this.loadNext = true;
1656 (function() { _combo.doQuery(_combo.allQuery, true); }).defer(500);
1661 addItem : function(o)
1663 var dv = ''; // display value
1665 if (this.displayField) {
1666 dv = !o || typeof(o[this.displayField]) == 'undefined' ? '' : o[this.displayField];
1668 // this is an error condition!!!
1669 Roo.log('no displayField value set for '+ (this.name ? this.name : this.id));
1676 var choice = this.choices.createChild({
1678 cls: 'roo-select2-search-choice',
1687 cls: 'roo-select2-search-choice-close fa fa-times',
1692 }, this.searchField);
1694 var close = choice.select('a.roo-select2-search-choice-close', true).first();
1696 close.on('click', this.onRemoveItem, this, { item : choice, data : o} );
1704 this.inputEl().dom.value = '';
1709 onRemoveItem : function(e, _self, o)
1713 this.lastItem = Roo.apply([], this.item);
1715 var index = this.item.indexOf(o.data) * 1;
1718 Roo.log('not this item?!');
1722 this.item.splice(index, 1);
1727 this.fireEvent('remove', this, e);
1733 syncValue : function()
1735 if(!this.item.length){
1742 Roo.each(this.item, function(i){
1743 if(_this.valueField){
1744 value.push(i[_this.valueField]);
1751 this.value = value.join(',');
1753 if(this.hiddenField){
1754 this.hiddenField.dom.value = this.value;
1757 this.store.fireEvent("datachanged", this.store);
1762 clearItem : function()
1770 Roo.each(this.choices.select('>li.roo-select2-search-choice', true).elements, function(c){
1778 if(this.tickable && !Roo.isTouch){
1779 this.view.refresh();
1783 inputEl: function ()
1785 if(Roo.isIOS && this.useNativeIOS){
1786 return this.el.select('select.roo-ios-select', true).first();
1789 if(Roo.isTouch && this.mobileTouchView){
1790 return this.el.select('input.form-control',true).first();
1794 return this.searchField;
1797 return this.el.select('input.form-control',true).first();
1800 onTickableFooterButtonClick : function(e, btn, el)
1804 this.lastItem = Roo.apply([], this.item);
1806 if(btn && btn.name == 'cancel'){
1807 this.tickItems = Roo.apply([], this.item);
1816 Roo.each(this.tickItems, function(o){
1824 validate : function()
1826 var v = this.getRawValue();
1829 v = this.getValue();
1832 if(this.disabled || this.allowBlank || v.length){
1841 tickableInputEl : function()
1843 if(!this.tickable || !this.editable){
1844 return this.inputEl();
1847 return this.inputEl().select('.roo-select2-search-field-input', true).first();
1851 getAutoCreateTouchView : function()
1856 cls: 'form-group' //input-group
1862 type : this.inputType,
1863 cls : 'form-control x-combo-noedit',
1864 autocomplete: 'new-password',
1865 placeholder : this.placeholder || '',
1870 input.name = this.name;
1874 input.cls += ' input-' + this.size;
1877 if (this.disabled) {
1878 input.disabled = true;
1889 inputblock.cls += ' input-group';
1891 inputblock.cn.unshift({
1893 cls : 'input-group-addon',
1898 if(this.removable && !this.multiple){
1899 inputblock.cls += ' roo-removable';
1901 inputblock.cn.push({
1904 cls : 'roo-combo-removable-btn close'
1908 if(this.hasFeedback && !this.allowBlank){
1910 inputblock.cls += ' has-feedback';
1912 inputblock.cn.push({
1914 cls: 'glyphicon form-control-feedback'
1921 inputblock.cls += (this.before) ? '' : ' input-group';
1923 inputblock.cn.push({
1925 cls : 'input-group-addon',
1936 cls: 'form-hidden-field'
1950 cls: 'form-hidden-field'
1954 cls: 'roo-select2-choices',
1958 cls: 'roo-select2-search-field',
1971 cls: 'roo-select2-container input-group roo-touchview-PhoneInput ',
1977 if(!this.multiple && this.showToggleBtn){
1984 if (this.caret != false) {
1987 cls: 'fa fa-' + this.caret
1992 PhoneInput.cn.push({
1994 cls : 'input-group-addon btn dropdown-toggle',
1999 cls: 'PhoneInput-clear',
2013 PhoneInput.cls += ' roo-select2-container-multi';
2016 var align = this.labelAlign || this.parentLabelAlign();
2018 if (align ==='left' && this.fieldLabel.length) {
2023 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
2024 tooltip : 'This field is required'
2028 cls : 'control-label',
2029 html : this.fieldLabel
2040 var labelCfg = cfg.cn[1];
2041 var contentCfg = cfg.cn[2];
2044 if(this.indicatorpos == 'right'){
2048 cls : 'control-label',
2049 html : this.fieldLabel,
2053 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
2054 tooltip : 'This field is required'
2067 labelCfg = cfg.cn[0];
2068 contentCfg = cfg.cn[2];
2070 if(this.labelWidth > 12){
2071 labelCfg.style = "width: " + this.labelWidth + 'px';
2074 if(this.labelWidth < 13 && this.labelmd == 0){
2075 this.labelmd = this.labelWidth;
2078 if(this.labellg > 0){
2079 labelCfg.cls += ' col-lg-' + this.labellg;
2080 contentCfg.cls += ' col-lg-' + (12 - this.labellg);
2083 if(this.labelmd > 0){
2084 labelCfg.cls += ' col-md-' + this.labelmd;
2085 contentCfg.cls += ' col-md-' + (12 - this.labelmd);
2088 if(this.labelsm > 0){
2089 labelCfg.cls += ' col-sm-' + this.labelsm;
2090 contentCfg.cls += ' col-sm-' + (12 - this.labelsm);
2093 if(this.labelxs > 0){
2094 labelCfg.cls += ' col-xs-' + this.labelxs;
2095 contentCfg.cls += ' col-xs-' + (12 - this.labelxs);
2099 } else if ( this.fieldLabel.length) {
2103 cls : 'roo-required-indicator left-indicator text-danger fa fa-lg fa-star',
2104 tooltip : 'This field is required'
2108 cls : 'control-label',
2109 html : this.fieldLabel
2120 if(this.indicatorpos == 'right'){
2124 cls : 'control-label',
2125 html : this.fieldLabel,
2129 cls : 'roo-required-indicator right-indicator text-danger fa fa-lg fa-star',
2130 tooltip : 'This field is required'
2143 cfg.cn = PhoneInput;
2147 var settings = this;
2149 ['xs','sm','md','lg'].map(function(size){
2150 if (settings[size]) {
2151 cfg.cls += ' col-' + size + '-' + settings[size];
2158 initTouchView : function()
2160 this.renderTouchView();
2162 this.touchViewEl.on('scroll', function(){
2163 this.el.dom.scrollTop = 0;
2166 this.originalValue = this.getValue();
2168 this.triggerEl = this.el.select('span.dropdown-toggle',true).first();
2170 this.inputEl().on("click", this.showTouchView, this);
2171 if (this.triggerEl) {
2172 this.triggerEl.on("click", this.showTouchView, this);
2176 this.touchViewFooterEl.select('.roo-touch-view-cancel', true).first().on('click', this.hideTouchView, this);
2177 this.touchViewFooterEl.select('.roo-touch-view-ok', true).first().on('click', this.setTouchViewValue, this);
2179 this.maskEl = new Roo.LoadMask(this.touchViewEl, { store : this.store, msgCls: 'roo-el-mask-msg' });
2181 this.store.on('beforeload', this.onTouchViewBeforeLoad, this);
2182 this.store.on('load', this.onTouchViewLoad, this);
2183 this.store.on('loadexception', this.onTouchViewLoadException, this);
2185 if(this.hiddenName){
2187 this.hiddenField = this.el.select('input.form-hidden-field',true).first();
2189 this.hiddenField.dom.value =
2190 this.hiddenValue !== undefined ? this.hiddenValue :
2191 this.value !== undefined ? this.value : '';
2193 this.el.dom.removeAttribute('name');
2194 this.hiddenField.dom.setAttribute('name', this.hiddenName);
2198 this.choices = this.el.select('ul.roo-select2-choices', true).first();
2199 this.searchField = this.el.select('ul li.roo-select2-search-field', true).first();
2202 if(this.removable && !this.multiple){
2203 var close = this.closeTriggerEl();
2205 close.setVisibilityMode(Roo.Element.DISPLAY).hide();
2206 close.on('click', this.removeBtnClick, this, close);
2210 * fix the bug in Safari iOS8
2212 this.inputEl().on("focus", function(e){
2213 document.activeElement.blur();
2221 renderTouchView : function()
2223 this.touchViewEl = Roo.get(document.body).createChild(Roo.bootstrap.PhoneInput.touchViewTemplate);
2224 this.touchViewEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2226 this.touchViewHeaderEl = this.touchViewEl.select('.modal-header', true).first();
2227 this.touchViewHeaderEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2229 this.touchViewBodyEl = this.touchViewEl.select('.modal-body', true).first();
2230 this.touchViewBodyEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2231 this.touchViewBodyEl.setStyle('overflow', 'auto');
2233 this.touchViewListGroup = this.touchViewBodyEl.select('.list-group', true).first();
2234 this.touchViewListGroup.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2236 this.touchViewFooterEl = this.touchViewEl.select('.modal-footer', true).first();
2237 this.touchViewFooterEl.setVisibilityMode(Roo.Element.DISPLAY).originalDisplay = 'block';
2241 showTouchView : function()
2247 this.touchViewHeaderEl.hide();
2249 if(this.modalTitle.length){
2250 this.touchViewHeaderEl.dom.innerHTML = this.modalTitle;
2251 this.touchViewHeaderEl.show();
2254 this.touchViewEl.setStyle('z-index', Roo.bootstrap.Modal.zIndex++);
2255 this.touchViewEl.show();
2257 this.touchViewEl.select('.modal-dialog', true).first().setStyle('margin', '0px');
2258 this.touchViewEl.select('.modal-dialog > .modal-content', true).first().setSize(
2259 Roo.lib.Dom.getViewWidth(true), Roo.lib.Dom.getViewHeight(true));
2261 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2263 if(this.modalTitle.length){
2264 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2267 this.touchViewBodyEl.setHeight(bodyHeight);
2271 (function(){ _this.touchViewEl.addClass('in'); }).defer(50);
2273 this.touchViewEl.addClass('in');
2276 this.doTouchViewQuery();
2280 hideTouchView : function()
2282 this.touchViewEl.removeClass('in');
2286 (function(){ _this.touchViewEl.setStyle('display', 'none'); }).defer(150);
2288 this.touchViewEl.setStyle('display', 'none');
2293 setTouchViewValue : function()
2300 Roo.each(this.tickItems, function(o){
2305 this.hideTouchView();
2308 doTouchViewQuery : function()
2317 if(this.fireEvent('beforequery', qe) ===false || qe.cancel){
2321 if(!this.alwaysQuery || this.mode == 'local'){
2322 this.onTouchViewLoad();
2329 onTouchViewBeforeLoad : function(combo,opts)
2335 onTouchViewLoad : function()
2337 if(this.store.getCount() < 1){
2338 this.onTouchViewEmptyResults();
2342 this.clearTouchView();
2344 var rawValue = this.getRawValue();
2346 var template = (this.multiple) ? Roo.bootstrap.PhoneInput.listItemCheckbox : Roo.bootstrap.PhoneInput.listItemRadio;
2348 this.tickItems = [];
2350 this.store.data.each(function(d, rowIndex){
2351 var row = this.touchViewListGroup.createChild(template);
2353 if(typeof(d.data.cls) != 'undefined' && d.data.cls.length){
2354 row.addClass(d.data.cls);
2357 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
2360 html : d.data[this.displayField]
2363 if(this.fireEvent('touchviewdisplay', this, cfg) !== false){
2364 row.select('.roo-PhoneInput-list-group-item-value', true).first().dom.innerHTML = cfg.html;
2367 row.removeClass('selected');
2368 if(!this.multiple && this.valueField &&
2369 typeof(d.data[this.valueField]) != 'undefined' && d.data[this.valueField] == this.getValue())
2372 row.select('.roo-PhoneInput-list-group-item-box > input', true).first().attr('checked', true);
2373 row.addClass('selected');
2376 if(this.multiple && this.valueField &&
2377 typeof(d.data[this.valueField]) != 'undefined' && this.getValue().indexOf(d.data[this.valueField]) != -1)
2381 row.select('.roo-PhoneInput-list-group-item-box > input', true).first().attr('checked', true);
2382 this.tickItems.push(d.data);
2385 row.on('click', this.onTouchViewClick, this, {row : row, rowIndex : rowIndex});
2389 var firstChecked = this.touchViewListGroup.select('.list-group-item > .roo-PhoneInput-list-group-item-box > input:checked', true).first();
2391 var bodyHeight = Roo.lib.Dom.getViewHeight() - this.touchViewFooterEl.getHeight() + this.touchViewBodyEl.getPadding('tb');
2393 if(this.modalTitle.length){
2394 bodyHeight = bodyHeight - this.touchViewHeaderEl.getHeight();
2397 var listHeight = this.touchViewListGroup.getHeight();
2401 if(firstChecked && listHeight > bodyHeight){
2402 (function() { firstChecked.findParent('li').scrollIntoView(_this.touchViewListGroup.dom); }).defer(500);
2407 onTouchViewLoadException : function()
2409 this.hideTouchView();
2412 onTouchViewEmptyResults : function()
2414 this.clearTouchView();
2416 this.touchViewListGroup.createChild(Roo.bootstrap.PhoneInput.emptyResult);
2418 this.touchViewListGroup.select('.roo-PhoneInput-touch-view-empty-result', true).first().dom.innerHTML = this.emptyResultText;
2422 clearTouchView : function()
2424 this.touchViewListGroup.dom.innerHTML = '';
2427 onTouchViewClick : function(e, el, o)
2432 var rowIndex = o.rowIndex;
2434 var r = this.store.getAt(rowIndex);
2436 if(this.fireEvent('beforeselect', this, r, rowIndex) !== false){
2439 Roo.each(this.touchViewListGroup.select('.list-group-item > .roo-PhoneInput-list-group-item-box > input:checked', true).elements, function(c){
2440 c.dom.removeAttribute('checked');
2443 row.select('.roo-PhoneInput-list-group-item-box > input', true).first().attr('checked', true);
2445 this.setFromData(r.data);
2447 var close = this.closeTriggerEl();
2453 this.hideTouchView();
2455 this.fireEvent('select', this, r, rowIndex);
2460 if(this.valueField && typeof(r.data[this.valueField]) != 'undefined' && this.getValue().indexOf(r.data[this.valueField]) != -1){
2461 row.select('.roo-PhoneInput-list-group-item-box > input', true).first().dom.removeAttribute('checked');
2462 this.tickItems.splice(this.tickItems.indexOf(r.data), 1);
2466 row.select('.roo-PhoneInput-list-group-item-box > input', true).first().attr('checked', true);
2467 this.addItem(r.data);
2468 this.tickItems.push(r.data);
2472 getAutoCreateNativeIOS : function()
2475 cls: 'form-group' //input-group,
2480 cls : 'roo-ios-select'
2484 PhoneInput.name = this.name;
2487 if (this.disabled) {
2488 PhoneInput.disabled = true;
2491 var settings = this;
2493 ['xs','sm','md','lg'].map(function(size){
2494 if (settings[size]) {
2495 cfg.cls += ' col-' + size + '-' + settings[size];
2499 cfg.cn = PhoneInput;
2505 initIOSView : function()
2507 this.store.on('load', this.onIOSViewLoad, this);
2512 onIOSViewLoad : function()
2514 if(this.store.getCount() < 1){
2518 this.clearIOSView();
2520 if(this.allowBlank) {
2522 var default_text = '-- SELECT --';
2524 var opt = this.inputEl().createChild({
2531 o[this.valueField] = 0;
2532 o[this.displayField] = default_text;
2534 this.ios_options.push({
2541 this.store.data.each(function(d, rowIndex){
2545 if(this.displayField && typeof(d.data[this.displayField]) != 'undefined'){
2546 html = d.data[this.displayField];
2551 if(this.valueField && typeof(d.data[this.valueField]) != 'undefined'){
2552 value = d.data[this.valueField];
2561 if(this.value == d.data[this.valueField]){
2562 option['selected'] = true;
2565 var opt = this.inputEl().createChild(option);
2567 this.ios_options.push({
2574 this.inputEl().on('change', function(){
2575 this.fireEvent('select', this);
2580 clearIOSView: function()
2582 this.inputEl().dom.innerHTML = '';
2584 this.ios_options = [];
2587 setIOSValue: function(v)
2591 if(!this.ios_options){
2595 Roo.each(this.ios_options, function(opts){
2597 opts.el.dom.removeAttribute('selected');
2599 if(opts.data[this.valueField] != v){
2603 opts.el.dom.setAttribute('selected', true);
2609 * @cfg {Boolean} grow
2613 * @cfg {Number} growMin
2617 * @cfg {Number} growMax
2626 Roo.apply(Roo.bootstrap.PhoneInput, {
2630 cls: 'modal-header',
2652 cls: 'list-group-item',
2656 cls: 'roo-PhoneInput-list-group-item-value'
2660 cls: 'roo-PhoneInput-list-group-item-box pull-xs-right radio-inline radio radio-info',
2674 listItemCheckbox : {
2676 cls: 'list-group-item',
2680 cls: 'roo-PhoneInput-list-group-item-value'
2684 cls: 'roo-PhoneInput-list-group-item-box pull-xs-right checkbox-inline checkbox checkbox-info',
2700 cls: 'alert alert-danger roo-PhoneInput-touch-view-empty-result'
2705 cls: 'modal-footer',
2713 cls: 'col-xs-6 text-left',
2716 cls: 'btn btn-danger roo-touch-view-cancel',
2722 cls: 'col-xs-6 text-right',
2725 cls: 'btn btn-success roo-touch-view-ok',