//>>built
define("dojox/form/ListInput","dojo/_base/kernel,dojo/_base/lang,dojo/_base/array,dojo/_base/json,dojo/_base/fx,dojo/_base/window,dojo/_base/connect,dojo/dom-class,dojo/dom-style,dojo/dom-construct,dojo/dom-geometry,dojo/keys,dijit/_Widget,dijit/_TemplatedMixin,dijit/form/_FormValueWidget,dijit/form/ValidationTextBox,dijit/InlineEditBox,dojo/i18n!dijit/nls/common,dojo/_base/declare".split(","),function(h,c,j,o,k,l,m,e,p,f,n,g,q,r,s,t,u,v,i){h.experimental("dojox.form.ListInput");var h=i("dojox.form.ListInput",
[s],{constructor:function(){this._items=[];if(!c.isArray(this.delimiter))this.delimiter=[this.delimiter];this.regExp="^"+this.regExp+("("+this.delimiter.join("|")+")?")+"$"},inputClass:"dojox.form._ListInputInputBox",inputHandler:"onChange",inputProperties:{minWidth:50},submitOnlyValidValue:!0,useOnBlur:!0,readOnlyInput:!1,maxItems:null,showCloseButtonWhenValid:!0,showCloseButtonWhenInvalid:!0,regExp:".*",delimiter:",",constraints:{},baseClass:"dojoxListInput",type:"select",value:"",templateString:'<div dojoAttachPoint="focusNode" class="dijit dijitReset dijitLeft dojoxListInput"><select dojoAttachpoint="_selectNode" multiple="multiple" class="dijitHidden" ${!nameAttrSetting}></select><ul dojoAttachPoint="_listInput"><li dojoAttachEvent="onclick: _onClick" class="dijitInputField dojoxListInputNode dijitHidden" dojoAttachPoint="_inputNode"></li></ul></div>',
useAnim:!0,duration:500,easingIn:null,easingOut:null,readOnlyItem:!1,useArrowForEdit:!0,_items:null,_lastAddedItem:null,_currentItem:null,_input:null,_count:0,postCreate:function(){this.inherited(arguments);this._createInputBox()},_setReadOnlyInputAttr:function(a){if(!this._started)return this._createInputBox();this.readOnlyInput=a;this._createInputBox()},_setReadOnlyItemAttr:function(a){if(this._started)for(var b in this._items)this._items[b].set("readOnlyItem",a)},_createInputBox:function(){e.toggle(this._inputNode,
"dijitHidden",this.readOnlyInput);if(!this.readOnlyInput&&!this._input){if(null===this.inputHandler)return!1;if(c.isString(this.inputHandler))this.inputHandler=this.inputHandler.split(",");if(c.isString(this.inputProperties))this.inputProperties=o.fromJson(this.inputProperties);var a=c.getObject(this.inputClass,!1);this.inputProperties.regExp=this.regExpGen(this.constraints);this._input=new a(this.inputProperties);this._input.startup();this._inputNode.appendChild(this._input.domNode);j.forEach(this.inputHandler,
function(a){this.connect(this._input,c.trim(a),"_onHandler")},this);this.connect(this._input,"onKeyDown","_inputOnKeyDown");this.connect(this._input,"onBlur","_inputOnBlur")}},compare:function(a,b){a=a.join(",");b=b.join(",");return a>b?1:a<b?-1:0},add:function(a){if(!(this._count>=this.maxItems&&null!==this.maxItems)){this._lastValueReported=this._getValues();c.isArray(a)||(a=[a]);for(var b in a){var d=a[b];if(!(""===d||"string"!=typeof d)){this._count++;this.regExpGen(this.constraints);this._lastAddedItem=
new w({index:this._items.length,readOnlyItem:this.readOnlyItem,value:d,regExp:this.regExpGen(this.constraints)});this._lastAddedItem.startup();this._testItem(this._lastAddedItem,d);this._lastAddedItem.onClose=c.hitch(this,"_onItemClose",this._lastAddedItem);this._lastAddedItem.onChange=c.hitch(this,"_onItemChange",this._lastAddedItem);this._lastAddedItem.onEdit=c.hitch(this,"_onItemEdit",this._lastAddedItem);this._lastAddedItem.onKeyDown=c.hitch(this,"_onItemKeyDown",this._lastAddedItem);this.useAnim&&
p.set(this._lastAddedItem.domNode,{opacity:0,display:""});this._placeItem(this._lastAddedItem.domNode);this.useAnim&&k.fadeIn({node:this._lastAddedItem.domNode,duration:this.duration,easing:this.easingIn}).play();this._items[this._lastAddedItem.index]=this._lastAddedItem;if(this._onChangeActive&&this.intermediateChanges)this.onChange(d);if(this._count>=this.maxItems&&null!==this.maxItems)break}}this._updateValues();if(0==this._lastValueReported.length)this._lastValueReported=this.value;this.readOnlyInput||
this._input.set("value","");if(this._onChangeActive)this.onChange(this.value);this._setReadOnlyWhenMaxItemsReached()}},_setReadOnlyWhenMaxItemsReached:function(){this.set("readOnlyInput",this._count>=this.maxItems&&null!==this.maxItems)},_setSelectNode:function(){this._selectNode.options.length=0;var a=this.submitOnlyValidValue?this.get("MatchedValue"):this.value;c.isArray(a)&&j.forEach(a,function(a){this._selectNode.options[this._selectNode.options.length]=new Option(a,a,!0,!0)},this)},_placeItem:function(a){f.place(a,
this._inputNode,"before")},_getCursorPos:function(a){if("undefined"!=typeof a.selectionStart)return a.selectionStart;try{a.focus()}catch(b){}var d=a.createTextRange();d.moveToBookmark(l.doc.selection.createRange().getBookmark());d.moveEnd("character",a.value.length);return a.value.length-d.text.length},_onItemClose:function(a){this.disabled||(this.useAnim?k.fadeOut({node:a.domNode,duration:this.duration,easing:this.easingOut,onEnd:c.hitch(this,"_destroyItem",a)}).play():this._destroyItem(a))},_onItemKeyDown:function(a,
b){!this.readOnlyItem&&this.useArrowForEdit&&(b.keyCode==g.LEFT_ARROW&&0==this._getCursorPos(b.target)?this._editBefore(a):b.keyCode==g.RIGHT_ARROW&&this._getCursorPos(b.target)==b.target.value.length&&this._editAfter(a))},_editBefore:function(a){this._currentItem=this._getPreviousItem(a);null!==this._currentItem&&this._currentItem.edit()},_editAfter:function(a){this._currentItem=this._getNextItem(a);null!==this._currentItem&&this._currentItem.edit();this.readOnlyInput||null===this._currentItem&&
this._focusInput()},_onItemChange:function(a,b){b=b||a.get("value");this._testItem(a,b);this._updateValues()},_onItemEdit:function(a){e.remove(a.domNode,["dijitError",this.baseClass+"Match",this.baseClass+"Mismatch"])},_testItem:function(a,b){var d=RegExp(this.regExpGen(this.constraints)),d=(""+b).match(d);e.remove(a.domNode,this.baseClass+(!d?"Match":"Mismatch"));e.add(a.domNode,this.baseClass+(d?"Match":"Mismatch"));e.toggle(a.domNode,"dijitError",!d);this.showCloseButtonWhenValid&&d||this.showCloseButtonWhenInvalid&&
!d?e.add(a.domNode,this.baseClass+"Closable"):e.remove(a.domNode,this.baseClass+"Closable")},_getValueAttr:function(){return this.value},_setValueAttr:function(a){this._destroyAllItems();this.add(this._parseValue(a))},_parseValue:function(a){if("string"==typeof a){if(c.isString(this.delimiter))this.delimiter=[this.delimiter];var b=RegExp("^.*("+this.delimiter.join("|")+").*");if(a.match(b))return b=RegExp(this.delimiter.join("|")),a.split(b)}return a},regExpGen:function(){return this.regExp},_setDisabledAttr:function(a){if(!this.readOnlyItem)for(var b in this._items)this._items[b].set("disabled",
a);this.readOnlyInput||this._input.set("disabled",a);this.inherited(arguments)},_onHandler:function(a){a=this._parseValue(a);c.isArray(a)&&this.add(a)},_onClick:function(){this._focusInput()},_focusInput:function(){!this.readOnlyInput&&this._input.focus&&this._input.focus()},_inputOnKeyDown:function(a){this._currentItem=null;var b=this._input.get("value");a.keyCode==g.BACKSPACE&&""==b&&this.get("lastItem")?this._destroyItem(this.get("lastItem")):a.keyCode==g.ENTER&&""!=b?this.add(b):a.keyCode==g.LEFT_ARROW&&
0==this._getCursorPos(this._input.focusNode)&&!this.readOnlyItem&&this.useArrowForEdit&&this._editBefore()},_inputOnBlur:function(){var a=this._input.get("value");this.useOnBlur&&""!=a&&this.add(a)},_getMatchedValueAttr:function(){return this._getValues(c.hitch(this,this._matchValidator))},_getMismatchedValueAttr:function(){return this._getValues(c.hitch(this,this._mismatchValidator))},_getValues:function(a){var b=[],a=a||this._nullValidator,d;for(d in this._items){var c=this._items[d];null!==c&&
(c=c.get("value"),a(c)&&b.push(c))}return b},_nullValidator:function(){return!0},_matchValidator:function(a){var b=RegExp(this.regExpGen(this.constraints));return a.match(b)},_mismatchValidator:function(a){var b=RegExp(this.regExpGen(this.constraints));return!a.match(b)},_getLastItemAttr:function(){return this._getSomeItem()},_getSomeItem:function(a,b){var a=a||!1,b=b||"last",c=null,e=-1,f;for(f in this._items)if(null!==this._items[f]){if("before"==b&&this._items[f]===a)break;c=this._items[f];if("first"==
b||0==e){e=1;break}"after"==b&&this._items[f]===a&&(e=0)}"after"==b&&0==e&&(c=null);return c},_getPreviousItem:function(a){return this._getSomeItem(a,"before")},_getNextItem:function(a){return this._getSomeItem(a,"after")},_destroyItem:function(a,b){this._items[a.index]=null;a.destroy();this._count--;!1!==b&&(this._updateValues(),this._setReadOnlyWhenMaxItemsReached())},_updateValues:function(){this.value=this._getValues();this._setSelectNode()},_destroyAllItems:function(){for(var a in this._items)null!=
this._items[a]&&this._destroyItem(this._items[a],!1);this._items=[];this._count=0;this.value=null;this._setSelectNode();this._setReadOnlyWhenMaxItemsReached()},destroy:function(){this._destroyAllItems();this._lastAddedItem=null;this._input||this._input.destroy();this.inherited(arguments)}}),w=i("dojox.form._ListInputInputItem",[q,r],{templateString:'<li class="dijit dijitReset dijitLeft dojoxListInputItem" dojoAttachEvent="onclick: onClick" ><span dojoAttachPoint="labelNode"></span></li>',closeButtonNode:null,
readOnlyItem:!0,baseClass:"dojoxListInputItem",value:"",regExp:".*",_editBox:null,_handleKeyDown:null,attributeMap:{value:{node:"labelNode",type:"innerHTML"}},postMixInProperties:function(){c.mixin(this,v);this.inherited(arguments)},postCreate:function(){this.inherited(arguments);this.closeButtonNode=f.create("span",{"class":"dijitButtonNode dijitDialogCloseIcon",title:this.itemClose,onclick:c.hitch(this,"onClose"),onmouseenter:c.hitch(this,"_onCloseEnter"),onmouseleave:c.hitch(this,"_onCloseLeave")},
this.domNode);f.create("span",{"class":"closeText",title:this.itemClose,innerHTML:"x"},this.closeButtonNode)},startup:function(){this.inherited(arguments);this._createInlineEditBox()},_setReadOnlyItemAttr:function(a){(this.readOnlyItem=a)?this._editBox&&this._editBox.set("disabled",!0):this._createInlineEditBox()},_createInlineEditBox:function(){if(!this.readOnlyItem&&this._started)this._editBox?this._editBox.set("disabled",!1):(this._editBox=new u({value:this.value,editor:"dijit.form.ValidationTextBox",
editorParams:{regExp:this.regExp}},this.labelNode),this.connect(this._editBox,"edit","_onEdit"),this.connect(this._editBox,"onChange","_onCloseEdit"),this.connect(this._editBox,"onCancel","_onCloseEdit"))},edit:function(){this.readOnlyItem||this._editBox.edit()},_onCloseEdit:function(a){e.remove(this.closeButtonNode,this.baseClass+"Edited");m.disconnect(this._handleKeyDown);this.onChange(a)},_onEdit:function(){e.add(this.closeButtonNode,this.baseClass+"Edited");this._handleKeyDown=m.connect(this._editBox.editWidget,
"_onKeyPress",this,"onKeyDown");this.onEdit()},_setDisabledAttr:function(a){this.readOnlyItem||this._editBox.set("disabled",a)},_getValueAttr:function(){return!this.readOnlyItem&&this._started?this._editBox.get("value"):this.value},destroy:function(){this._editBox&&this._editBox.destroy();this.inherited(arguments)},_onCloseEnter:function(){e.add(this.closeButtonNode,"dijitDialogCloseIcon-hover")},_onCloseLeave:function(){e.remove(this.closeButtonNode,"dijitDialogCloseIcon-hover")},onClose:function(){},
onEdit:function(){},onClick:function(){},onChange:function(){},onKeyDown:function(){}});i("dojox.form._ListInputInputBox",[t],{minWidth:50,intermediateChanges:!0,regExp:".*",_sizer:null,onChange:function(a){this.inherited(arguments);if(null===this._sizer)this._sizer=f.create("div",{style:{position:"absolute",left:"-10000px",top:"-10000px"}},l.body());this._sizer.innerHTML=a;var b=n.getContentBox(this._sizer).w+this.minWidth;n.setContentSize(this.domNode,{w:b})},destroy:function(){f.destroy(this._sizer);
this.inherited(arguments)}});return h});