//>>built
define("dojox/widget/RollingList",["dijit","dojo","dojox","dojo/i18n!dijit/nls/common","dojo/require!dojo/window,dijit/layout/ContentPane,dijit/_Templated,dijit/_Contained,dijit/layout/_LayoutWidget,dijit/Menu,dijit/form/Button,dijit/focus,dijit/_base/focus,dojox/html/metrics,dojo/i18n"],function(p,c,u){c.provide("dojox.widget.RollingList");c.experimental("dojox.widget.RollingList");c.require("dojo.window");c.require("dijit.layout.ContentPane");c.require("dijit._Templated");c.require("dijit._Contained");
c.require("dijit.layout._LayoutWidget");c.require("dijit.Menu");c.require("dijit.form.Button");c.require("dijit.focus");c.require("dijit._base.focus");c.require("dojox.html.metrics");c.require("dojo.i18n");c.requireLocalization("dijit","common");c.declare("dojox.widget._RollingListPane",[p.layout.ContentPane,p._Templated,p._Contained],{templateString:'\x3cdiv class\x3d"dojoxRollingListPane"\x3e\x3ctable\x3e\x3ctbody\x3e\x3ctr\x3e\x3ctd dojoAttachPoint\x3d"containerNode"\x3e\x3c/td\x3e\x3c/tr\x3e\x3c/tbody\x3e\x3c/div\x3e',
parentWidget:null,parentPane:null,store:null,items:null,query:null,queryOptions:null,_focusByNode:!0,minWidth:0,_setContentAndScroll:function(a,b){this._setContent(a,b);this.parentWidget.scrollIntoView(this)},_updateNodeWidth:function(a,b){a.style.width="";c.marginBox(a).w<b&&c.marginBox(a,{w:b})},_onMinWidthChange:function(a){this._updateNodeWidth(this.domNode,a)},_setMinWidthAttr:function(a){a!==this.minWidth&&(this.minWidth=a,this._onMinWidthChange(a))},startup:function(){this._started||(this.store&&
this.store.getFeatures()["dojo.data.api.Notification"]&&window.setTimeout(c.hitch(this,function(){this.connect(this.store,"onSet","_onSetItem");this.connect(this.store,"onNew","_onNewItem");this.connect(this.store,"onDelete","_onDeleteItem")}),1),this.connect(this.focusNode||this.domNode,"onkeypress","_focusKey"),this.parentWidget._updateClass(this.domNode,"Pane"),this.inherited(arguments),this._onMinWidthChange(this.minWidth))},_focusKey:function(a){a.charOrCode==c.keys.BACKSPACE?c.stopEvent(a):
a.charOrCode==c.keys.LEFT_ARROW&&this.parentPane?(this.parentPane.focus(),this.parentWidget.scrollIntoView(this.parentPane)):a.charOrCode==c.keys.ENTER&&this.parentWidget._onExecute()},focus:function(a){if(this.parentWidget._focusedPane!=this&&(this.parentWidget._focusedPane=this,this.parentWidget.scrollIntoView(this),this._focusByNode&&(!this.parentWidget._savedFocus||a)))try{(this.focusNode||this.domNode).focus()}catch(b){}},_onShow:function(){this.inherited(arguments);(this.store||this.items)&&
(this.refreshOnShow&&this.domNode||!this.isLoaded&&this.domNode)&&this.refresh()},_load:function(){this.isLoaded=!1;this.items?(this._setContentAndScroll(this.onLoadStart(),!0),window.setTimeout(c.hitch(this,"_doQuery"),1)):this._doQuery()},_doLoadItems:function(a,b){var d=0,e=this.store;c.forEach(a,function(l){e.isItemLoaded(l)||d++});if(0===d)b();else{var f=function(l){d--;0===d&&b()};c.forEach(a,function(l){e.isItemLoaded(l)||e.loadItem({item:l,onItem:f})})}},_doQuery:function(){if(this.domNode){var a=
this.parentWidget.preloadItems;a=!0===a||this.items&&this.items.length<=Number(a);if(this.items&&a)this._doLoadItems(this.items,c.hitch(this,"onItems"));else if(this.items)this.onItems();else this._setContentAndScroll(this.onFetchStart(),!0),this.store.fetch({query:this.query,onComplete:function(b){this.items=b;this.onItems()},onError:function(b){this._onError("Fetch",b)},scope:this})}},_hasItem:function(a){for(var b=this.items||[],d=0,e;e=b[d];d++)if(this.parentWidget._itemsMatch(e,a))return!0;return!1},
_onSetItem:function(a,b,d,e){this._hasItem(a)&&this.refresh()},_onNewItem:function(a,b){var d;!b&&!this.parentPane||b&&this.parentPane&&this.parentPane._hasItem(b.item)&&(d=this.parentPane._getSelected())&&this.parentWidget._itemsMatch(d.item,b.item)?(this.items.push(a),this.refresh()):b&&this.parentPane&&this._hasItem(b.item)&&this.refresh()},_onDeleteItem:function(a){this._hasItem(a)&&(this.items=c.filter(this.items,function(b){return b!=a}),this.refresh())},onFetchStart:function(){return this.loadingMessage},
onFetchError:function(a){return this.errorMessage},onLoadStart:function(){return this.loadingMessage},onLoadError:function(a){return this.errorMessage},onItems:function(){this.onLoadDeferred||(this.cancel(),this.onLoadDeferred=new c.Deferred(c.hitch(this,"cancel")));this._onLoadHandler()}});c.declare("dojox.widget._RollingListGroupPane",[u.widget._RollingListPane],{templateString:'\x3cdiv\x3e\x3cdiv dojoAttachPoint\x3d"containerNode"\x3e\x3c/div\x3e\x3cdiv dojoAttachPoint\x3d"menuContainer"\x3e\x3cdiv dojoAttachPoint\x3d"menuNode"\x3e\x3c/div\x3e\x3c/div\x3e\x3c/div\x3e',
_menu:null,_setContent:function(a){this._menu||this.inherited(arguments)},_onMinWidthChange:function(a){if(this._menu){var b=c.marginBox(this.domNode).w,d=c.marginBox(this._menu.domNode).w;this._updateNodeWidth(this._menu.domNode,a-(b-d))}},onItems:function(){if(this._menu){var a=this._getSelected();this._menu.destroyRecursive()}this._menu=this._getMenu();var b,d;this.items.length?c.forEach(this.items,function(f){if(b=this.parentWidget._getMenuItemForItem(f,this))a&&this.parentWidget._itemsMatch(b.item,
a.item)&&(d=b),this._menu.addChild(b)},this):(b=this.parentWidget._getMenuItemForItem(null,this))&&this._menu.addChild(b);if(d){if(this._setSelected(d),a&&!a.children&&d.children||a&&a.children&&!d.children){var e=this.parentWidget._getPaneForItem(d.item,this,d.children);e?this.parentWidget.addChild(e,this.getIndexInParent()+1):(this.parentWidget._removeAfter(this),this.parentWidget._onItemClick(null,this,d.item,d.children))}}else a&&this.parentWidget._removeAfter(this);this.containerNode.innerHTML=
"";this.containerNode.appendChild(this._menu.domNode);this.parentWidget.scrollIntoView(this);this._checkScrollConnection(!0);this.inherited(arguments);this._onMinWidthChange(this.minWidth)},_checkScrollConnection:function(a){var b=this.store;this._scrollConn&&this.disconnect(this._scrollConn);delete this._scrollConn;c.every(this.items,function(d){return b.isItemLoaded(d)})||(a&&this._loadVisibleItems(),this._scrollConn=this.connect(this.domNode,"onscroll","_onScrollPane"))},startup:function(){this.inherited(arguments);
this.parentWidget._updateClass(this.domNode,"GroupPane")},focus:function(a){if(this._menu){this._pendingFocus&&this.disconnect(this._pendingFocus);delete this._pendingFocus;var b=this._menu.focusedChild;if(!b){var d=c.query(".dojoxRollingListItemSelected",this.domNode)[0];d&&(b=p.byNode(d))}b||(b=this._menu.getChildren()[0]||this._menu);this._focusByNode=!1;if(b.focusNode){if(!this.parentWidget._savedFocus||a)try{b.focusNode.focus()}catch(e){}window.setTimeout(function(){try{c.window.scrollIntoView(b.focusNode)}catch(e){}},
1)}else b.focus?(!this.parentWidget._savedFocus||a)&&b.focus():this._focusByNode=!0;this.inherited(arguments)}else this._pendingFocus||(this._pendingFocus=this.connect(this,"onItems","focus"))},_getMenu:function(){var a=this,b=new p.Menu({parentMenu:this.parentPane?this.parentPane._menu:null,onCancel:function(d){a.parentPane&&a.parentPane.focus(!0)},_moveToPopup:function(d){if(this.focusedChild&&!this.focusedChild.disabled)this.onItemClick(this.focusedChild,d)}},this.menuNode);this.connect(b,"onItemClick",
function(d,e){if(!d.disabled)if(e.alreadySelected=c.hasClass(d.domNode,"dojoxRollingListItemSelected"),e.alreadySelected&&("keypress"==e.type&&e.charOrCode!=c.keys.ENTER||"internal"==e.type)){var f=this.parentWidget.getChildren()[this.getIndexInParent()+1];f&&(f.focus(!0),this.parentWidget.scrollIntoView(f))}else this._setSelected(d,b),this.parentWidget._onItemClick(e,this,d.item,d.children),"keypress"==e.type&&e.charOrCode==c.keys.ENTER&&this.parentWidget._onExecute()});b._started||b.startup();return b},
_onScrollPane:function(){this._visibleLoadPending&&window.clearTimeout(this._visibleLoadPending);this._visibleLoadPending=window.setTimeout(c.hitch(this,"_loadVisibleItems"),500)},_loadVisibleItems:function(){delete this._visibleLoadPending;var a=this._menu;if(a){var b=a.getChildren();if(b&&b.length){var d=function(g,k,q){var r=c.getComputedStyle(g),m=0;k&&(m+=c._getMarginExtents(g,r).t);q&&(m+=c._getPadBorderExtents(g,r).t);return m};d=d(this.domNode,!1,!0)+d(this.containerNode,!0,!0)+d(a.domNode,
!0,!0)+d(b[0].domNode,!0,!1);var e=c.contentBox(this.domNode).h,f=this.domNode.scrollTop-d-e/2,l=f+3*e/2,h=c.filter(b,function(g){var k=g.domNode.offsetTop,q=g.store;g=g.item;return k>=f&&k<=l&&!q.isItemLoaded(g)}),n=c.map(h,function(g){return g.item});b=c.hitch(this,function(){var g=this._getSelected();c.forEach(n,function(k,q){var r=this.parentWidget._getMenuItemForItem(k,this),m=h[q],t=m.getIndexInParent();a.removeChild(m);r&&(g&&this.parentWidget._itemsMatch(r.item,g.item),a.addChild(r,t),a.focusedChild==
m&&a.focusChild(r));m.destroy()},this);this._checkScrollConnection(!1)});this._doLoadItems(n,b)}}},_getSelected:function(a){a||(a=this._menu);if(a){a=this._menu.getChildren();for(var b=0,d;d=a[b];b++)if(c.hasClass(d.domNode,"dojoxRollingListItemSelected"))return d}return null},_setSelected:function(a,b){b||(b=this._menu);b&&c.forEach(b.getChildren(),function(d){this.parentWidget._updateClass(d.domNode,"Item",{Selected:a&&d==a&&!d.disabled})},this)}});c.declare("dojox.widget.RollingList",[p._Widget,
p._Templated,p._Container],{templateString:c.cache("dojox.widget","RollingList/RollingList.html",'\x3cdiv class\x3d"dojoxRollingList ${className}"\n\t\x3e\x3cdiv class\x3d"dojoxRollingListContainer" dojoAttachPoint\x3d"containerNode" dojoAttachEvent\x3d"onkeypress:_onKey"\n\t\x3e\x3c/div\n\t\x3e\x3cdiv class\x3d"dojoxRollingListButtons" dojoAttachPoint\x3d"buttonsNode"\n        \x3e\x3cbutton dojoType\x3d"dijit.form.Button" dojoAttachPoint\x3d"okButton"\n\t\t\t\tdojoAttachEvent\x3d"onClick:_onExecute"\x3e${okButtonLabel}\x3c/button\n        \x3e\x3cbutton dojoType\x3d"dijit.form.Button" dojoAttachPoint\x3d"cancelButton"\n\t\t\t\tdojoAttachEvent\x3d"onClick:_onCancel"\x3e${cancelButtonLabel}\x3c/button\n\t\x3e\x3c/div\n\x3e\x3c/div\x3e\n'),
widgetsInTemplate:!0,className:"",store:null,query:null,queryOptions:null,childrenAttrs:["children"],parentAttr:"",value:null,executeOnDblClick:!0,preloadItems:!1,showButtons:!1,okButtonLabel:"",cancelButtonLabel:"",minPaneWidth:0,postMixInProperties:function(){this.inherited(arguments);var a=c.i18n.getLocalization("dijit","common");this.okButtonLabel=this.okButtonLabel||a.buttonOk;this.cancelButtonLabel=this.cancelButtonLabel||a.buttonCancel},_setShowButtonsAttr:function(a){var b=!1;if(this.showButtons!=
a&&this._started||this.showButtons==a&&!this.started)b=!0;c.toggleClass(this.domNode,"dojoxRollingListButtonsHidden",!a);this.showButtons=a;b&&(this._started?this.layout():window.setTimeout(c.hitch(this,"layout"),0))},_itemsMatch:function(a,b){return a||b?a&&b?a==b||this._isIdentity&&this.store.getIdentity(a)==this.store.getIdentity(b):!1:!0},_removeAfter:function(a){"number"!=typeof a&&(a=this.getIndexOfChild(a));0<=a&&c.forEach(this.getChildren(),function(f,l){l>a&&(this.removeChild(f),f.destroyRecursive())},
this);var b=this.getChildren();b=b[b.length-1];for(var d=null;b&&!d;){var e=b._getSelected?b._getSelected():null;e&&(d=e.item);b=b.parentPane}this._setInProgress||this._setValue(d)},addChild:function(a,b){0<b&&this._removeAfter(b-1);this.inherited(arguments);a._started||a.startup();a.attr("minWidth",this.minPaneWidth);this.layout();this._savedFocus||a.focus()},_setMinPaneWidthAttr:function(a){a!==this.minPaneWidth&&(this.minPaneWidth=a,c.forEach(this.getChildren(),function(b){b.attr("minWidth",a)}))},
_updateClass:function(a,b,d){this._declaredClasses||(this._declaredClasses=("dojoxRollingList "+this.className).split(" "));c.forEach(this._declaredClasses,function(e){if(e){c.addClass(a,e+b);for(var f in d||{})c.toggleClass(a,e+b+f,d[f]);c.toggleClass(a,e+b+"FocusSelected",c.hasClass(a,e+b+"Focus")&&c.hasClass(a,e+b+"Selected"));c.toggleClass(a,e+b+"HoverSelected",c.hasClass(a,e+b+"Hover")&&c.hasClass(a,e+b+"Selected"))}})},scrollIntoView:function(a){this._scrollingTimeout&&window.clearTimeout(this._scrollingTimeout);
delete this._scrollingTimeout;this._scrollingTimeout=window.setTimeout(c.hitch(this,function(){a.domNode&&c.window.scrollIntoView(a.domNode);delete this._scrollingTimeout}),1)},resize:function(a){p.layout._LayoutWidget.prototype.resize.call(this,a)},layout:function(){var a=this.getChildren();if(this._contentBox){var b=this._contentBox.h-c.marginBox(this.buttonsNode).h-u.html.metrics.getScrollbar().h;c.forEach(a,function(d){c.marginBox(d.domNode,{h:b})})}this._focusedPane?(a=this._focusedPane,delete this._focusedPane,
this._savedFocus||a.focus()):a&&a.length&&(this._savedFocus||a[0].focus())},_onChange:function(a){this.onChange(a)},_setValue:function(a){delete this._setInProgress;this._itemsMatch(this.value,a)||(this.value=a,this._onChange(a))},_setValueAttr:function(a){if(!this._itemsMatch(this.value,a)||a)if(!this._setInProgress||this._setInProgress!==a)if((this._setInProgress=a)&&this.store.isItem(a)){var b=c.hitch(this,function(h,n){var g=this.store,k;if(this.parentAttr&&g.getFeatures()["dojo.data.api.Identity"]&&
((k=this.store.getValue(h,this.parentAttr))||""===k)){var q=function(t){g.getIdentity(t)==g.getIdentity(h)?n(null):n([t])};""===k?n(null):"string"==typeof k?g.fetchItemByIdentity({identity:k,onItem:q}):g.isItem(k)&&q(k)}else{var r=this.childrenAttrs.length,m=[];c.forEach(this.childrenAttrs,function(t){var v={};v[t]=h;g.fetch({query:v,scope:this,onComplete:function(w){this._setInProgress===a&&(m=m.concat(w),r--,0===r&&n(m))}})},this)}}),d=c.hitch(this,function(h,n){var g=h[n],k=this.getChildren()[n],
q;if(g&&k){var r=c.hitch(this,function(){q&&this.disconnect(q);delete q;if(this._setInProgress===a){var m=c.filter(k._menu.getChildren(),function(t){return this._itemsMatch(t.item,g)},this)[0];m&&(n++,k._menu.onItemClick(m,{type:"internal",stopPropagation:function(){},preventDefault:function(){}}),h[n]?d(h,n):(this._setValue(g),this.onItemClick(g,k,this.getChildItems(g))))}});k.isLoaded?r():q=this.connect(k,"onLoad",r)}else 0===n&&this.set("value",null)}),e=[],f=c.hitch(this,function(h){h&&h.length?
(e.push(h[0]),b(h[0],f)):(h||e.pop(),e.reverse(),d(e,0))}),l=this.domNode.style;"none"==l.display||"hidden"==l.visibility?this._setValue(a):this._itemsMatch(a,this._visibleItem)||f([a])}else l=this.getChildren()[0],l._setSelected(null),this._onItemClick(null,l,null,null)},_onItemClick:function(a,b,d,e){if(a){var f=this._getPaneForItem(d,b,e);"click"==a.type&&a.alreadySelected&&f?(this._removeAfter(b.getIndexInParent()+1),(f=b.getNextSibling())&&f._setSelected&&f._setSelected(null),this.scrollIntoView(f)):
f?(this.addChild(f,b.getIndexInParent()+1),this._savedFocus&&f.focus(!0)):(this._removeAfter(b),this.scrollIntoView(b))}else b&&(this._removeAfter(b),this.scrollIntoView(b));a&&"internal"==a.type||(this._setValue(d),this.onItemClick(d,b,e));this._visibleItem=d},_getPaneForItem:function(a,b,d){var e=this.getPaneForItem(a,b,d);e.store=this.store;e.parentWidget=this;e.parentPane=b||null;a?e.items=d?d:[a]:(e.query=this.query,e.queryOptions=this.queryOptions);return e},_getMenuItemForItem:function(a,b){var d=
this.store;if(a&&d&&d.isItem(a)){var e=(d=d.isItemLoaded(a))?this.getChildItems(a):void 0;if(e){var f=this.getMenuItemForItem(a,b,e);f.children=e;this._updateClass(f.domNode,"Item",{Expanding:!0});if(f._started)c.style(f.arrowWrapper,"visibility","");else var l=f.connect(f,"startup",function(){this.disconnect(l);c.style(this.arrowWrapper,"visibility","")})}else f=this.getMenuItemForItem(a,b,null),d?this._updateClass(f.domNode,"Item",{Single:!0}):(this._updateClass(f.domNode,"Item",{Unloaded:!0}),
f.attr("disabled",!0));f.store=this.store;f.item=a;f.label||f.attr("label",this.store.getLabel(a).replace(/</g,"\x26lt;"));if(f.focusNode){var h=this;f.focus=function(){if(!this.disabled)try{this.focusNode.focus()}catch(n){}};f.connect(f.focusNode,"onmouseenter",function(){this.disabled||h._updateClass(this.domNode,"Item",{Hover:!0})});f.connect(f.focusNode,"onmouseleave",function(){this.disabled||h._updateClass(this.domNode,"Item",{Hover:!1})});f.connect(f.focusNode,"blur",function(){h._updateClass(this.domNode,
"Item",{Focus:!1,Hover:!1})});f.connect(f.focusNode,"focus",function(){h._updateClass(this.domNode,"Item",{Focus:!0});h._focusedPane=b});this.executeOnDblClick&&f.connect(f.focusNode,"ondblclick",function(){h._onExecute()})}return f}d=new p.MenuItem({label:"---",disabled:!0,iconClass:"dojoxEmpty",focus:function(){}});this._updateClass(d.domNode,"Item");return d},_setStore:function(a){a===this.store&&this._started||(this.store=a,this._isIdentity=a.getFeatures()["dojo.data.api.Identity"],a=this._getPaneForItem(),
this.addChild(a,0))},_onKey:function(a){if(a.charOrCode==c.keys.BACKSPACE)c.stopEvent(a);else if(a.charOrCode==c.keys.ESCAPE&&this._savedFocus){try{p.focus(this._savedFocus)}catch(b){}c.stopEvent(a)}else a.charOrCode!=c.keys.LEFT_ARROW&&a.charOrCode!=c.keys.RIGHT_ARROW||c.stopEvent(a)},_resetValue:function(){this.set("value",this._lastExecutedValue)},_onCancel:function(){this._resetValue();this.onCancel()},_onExecute:function(){this._lastExecutedValue=this.get("value");this.onExecute()},focus:function(){var a=
this._savedFocus;this._savedFocus=p.getFocus(this);this._savedFocus.node||delete this._savedFocus;if(this._focusedPane){this._savedFocus=p.getFocus(this);var b=this._focusedPane;delete this._focusedPane;a||b.focus(!0)}else(b=this.getChildren()[0])&&!a&&b.focus(!0)},handleKey:function(a){return a.keyCode==c.keys.DOWN_ARROW?(delete this._savedFocus,this.focus(),!1):a.keyCode==c.keys.ESCAPE?(this._onCancel(),!1):!0},_updateChildClasses:function(){var a=this.getChildren(),b=a.length;c.forEach(a,function(d,
e){c.toggleClass(d.domNode,"dojoxRollingListPaneCurrentChild",e==b-1);c.toggleClass(d.domNode,"dojoxRollingListPaneCurrentSelected",e==b-2)})},startup:function(){this._started||(this.getParent&&this.getParent()||(this.resize(),this.connect(c.global,"onresize","resize")),this.connect(this,"addChild","_updateChildClasses"),this.connect(this,"removeChild","_updateChildClasses"),this._setStore(this.store),this.set("showButtons",this.showButtons),this.inherited(arguments),this._lastExecutedValue=this.get("value"))},
getChildItems:function(a){var b,d=this.store;c.forEach(this.childrenAttrs,function(e){(e=d.getValues(a,e))&&e.length&&(b=(b||[]).concat(e))});return b},getMenuItemForItem:function(a,b,d){return new p.MenuItem({})},getPaneForItem:function(a,b,d){return!a||d?new u.widget._RollingListGroupPane({}):null},onItemClick:function(a,b,d){},onExecute:function(){},onCancel:function(){},onChange:function(a){}})});