<ahref="http://todomvc.meteor.com"data-source="http://meteor.com"data-content="Meteor is an ultra-simple environment for building modern websites.A Meteor application is a mix of JavaScript that runs inside a client web browser, JavaScript that runs on the Meteor server inside a Node.js container, and all the supporting HTML fragments, CSS rules, and static assets. Meteor automates the packaging and transmission of these different components. And, it is quite flexible about how you choose to structure those components in your file tree.">Meteor</a>
</li>
<li>
<ahref="labs/architecture-examples/montage/"data-source="https://github.com/Motorola-Mobility/montage"data-content="Montage simplifies the development of rich HTML5 applications by providing modular components, real-time two-way data binding, CommonJS dependency management, and many more conveniences.">Montage</a>
</li>
<li>
<ahref="labs/architecture-examples/socketstream/README.md"data-source="http://www.socketstream.org"data-content="SocketStream is a fast, modular Node.js web framework dedicated to building realtime single-page apps">SocketStream + jQuery</a>
define("4763f06","ui/controller/array-controller",{dependencies:["montage","ui/controller/object-controller","core/change-notification","ui/controller/array-controller"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/controller/object-controller").ObjectController,f=a("core/change-notification").ChangeNotification,g=b.ArrayController=d.create(e,{didCreate:{value:function(){vara=this;this.addPropertyChangeListener("selections",function(){varb=[];a._selections.forEach(function(a,c){a&&b.push(c)}),a.selectedIndexes=b}),this.addPropertyChangeListener("content",function(){a.selectedObjects=null,a.automaticallyOrganizeObjects&&a.organizeObjects()})}},_content:{value:null},content:{get:function(){returnthis._content},set:function(a){if(this._content===a)return;this._content=a}},delegate:{value:null},_organizedObjects:{distinct:!0,value:[]},organizedObjects:{get:function(){returnthis._organizedObjects}},automaticallyOrganizeObjects:{value:!0},_sortFunction:{value:null},sortFunction:{get:function(){returnthis._sortFunction},set:function(a){if(this._sortFunction===a)return;this._sortFunction=a,this.automaticallyOrganizeObjects&&this.organizeObjects()}},_filterFunction:{value:null},filterFunction:{get:function(){returnthis._filterFunction},set:function(a){if(this._filterFunction===a)return;this._filterFunction=a,this.automaticallyOrganizeObjects&&this.organizeObjects()}},_startIndex:{value:null},startIndex:{get:function(){returnthis._startIndex},set:function(a){if(this._startIndex===a)return;this._startIndex=a,this.automaticallyOrganizeObjects&&this.organizeObjects()}},_endIndex:{enumerable:!1,value:null},endIndex:{get:function(){returnthis._endIndex},set:function(a){if(this._endIndex===a)return;this._endIndex=a,this.automaticallyOrganizeObjects&&this.organizeObjects()}},_organizedObjectsIndexes:{value:null},_rangedOrganizedObjectsIndexes:{value:null},_selectedIndexes:{value:null},selectedIndexes:{get:function(){returnthis._selectedIndexes?this._selectedIndexes:this.selectedContentIndexes?this._selectedIndexes=this._convertIndexesFromContentToOrganized(this.selectedContentIndexes):null},set:function(a){if(this.selectedIndexes!==a){varb=a?this._convertIndexesFromOrganizedToContent(a):null,c=null;if(this.delegate&&typeofthis.delegate.shouldChangeSelection=="function"){b&&(c=this.content.filter(function(a,c){returnb.indexOf(c)>=0},this));if(this.delegate.shouldChangeSelection(this,c,this._selectedObjects)===!1)return}this.dispatchPropertyChange("selections","selectedContentIndexes","selectedObjects",function(){this._selectedIndexes=a,this._selectedContentIndexes=b,this._selectedObjects=null,this._selections=null})}}},_convertIndexesFromOrganizedToContent:{value:function(a){varb,c=[],d,e=a.length,f,g;d=this._rangedOrganizedObjectsIndexes?this._rangedOrganizedObjectsIndexes:this._organizedObjectsIndexes;if(d){g=d.length;for(b=0;b<e;b++)f=a[b],f<g&&f>=0&&(c[c.length]=d[f])}elsefor(b=0;b<e;b++)c[c.length]=a[b]+this.startIndex;returnc.sort()}},_convertIndexesFromContentToOrganized:{value:function(a){varb,c=[],d,e=a.length,f;d=this._rangedOrganizedObjectsIndexes?this._rangedOrganizedObjectsIndexes:this._organizedObjectsIndexes;if(d)for(b=0;b<e;b++)f=a[b],f>=0&&(f=d.indexOf(f),f!==-1&&(c[c.length]=f));elsefor(b=0;b<e;b++)f=a[b]-this.startIndex,f>-1&&(this.endIndex==null||f<this.endIndex)&&(c[c.length]=f);returnc.sort()}},organizeObjects:{value:function(){vara=this.content,b=this.filterFunction,c=this.sortFunction,d=0,e=0,f,g,h,i;a&&typeofb=="function"&&(f=[],a=a.filter(function(a){varc=b.call(this,a);returnc&&(f[e]=d,e++),d++,c},this));if(typeofc=="function"){g=[],h=[],d=0;for(d=0;i=a[d];d++)i!==null&&typeofi=="object"?(i._montage_array_controller_index=d,h[d]=i):h[d]={_montage_array_controller_index:d,_montage_array_controller_value:i};h=h.sort(function(a,b){returna._montage_array_controller_value&&(a=a._montage_array_controller_value),b._montage_array_controller_value&&(b=b._montage_array_controller_value),c.call(this,a,b)}),a=[];for(d=0;i=h[d];d++)e=i._montage_array_controller_index,g[d]=f?f[e]:e,i._montage_array_controller_value?a[d]=i._montage_array_controller_value:(a[d]=i,deletei._montage_array_controller_index);this._organizedObjectsIndexes=g}elsethis._organizedObjectsIndexes=f;this._applyRangeIfNeeded(a)}},_applyRangeIfNeeded:{value:function(a){varb=this.startIndex,c=this.endIndex;a&&(typeofb=="number"||typeofc=="number")&&(b=typeofb=="number"&&b>=0?b:0,c=typeofc=="number"&&c<a.length?c:a.length,a=a.slice(b,c),this._organizedObjectsIndexes?this._rangedOrganizedObjectsIndexes=this._organizedObjectsIndexes.slice(b,c):this._rangedOrganizedObjectsIndexes=null),this.dispatchPropertyChange("organizedObjects",function(){this._organizedObjects=a?a:[]})}},_selectedObjects:{value:null},selectedObjects:{get:function(){returnthis._selectedObjects?this._selectedObjects:this._selectedContentIndexes?(this.content&&(this._selectedObjects=this.content.filter(function(a,b){returnthis._selectedContentIndexes.indexOf(b)>=0},this)),this._selectedObjects):null},set:function(a){a===null||typeofa=="undefined"?a=null:Array.isArray(a)||(a=[a]);if(this.selectedObjects===a)return;if(this.delegate&&typeofthis.delegate.shouldChangeSelection=="function"&&this.delegate.shouldChangeSelection(this,a,this._selectedObjects)===!1)return;this.dispatchPropertyChange("selections","selectedContentIndexes","selectedIndexes",function(){this._selectedObjects=a,this._selectedContentIndexes=null,this._selectedIndexes=null,this._selections=null})}},_selectedContentIndexes:{value:null},selectedContentIndexes:{get:function(){if(this._selectedContentIndexes)returnthis._selectedContentIndexes;if(!this._selectedObjects)returnnull;this._selectedContentIndexes=[];vara;returnthis._selectedObjects.forEach(function(b){(a=this.content.indexOf(b))!==-1&&this._selectedContentIndexes.push(a)},this),this._selectedContentIndexes},set:function(a){a===null||a===!1||typeofa=="undefined"?a=null:Array.isArray(a)||(a=[a]);if(this.selectedContentIndexes===a)return;if(this.delegate&&typeofthis.delegate.shouldChangeSelection=="function"){varb=a,c=null;b&&(c=this.content.filter(function(a,c){returnb.indexOf(c)>=0},this));if(this.delegate.shouldChangeSelection(this,c,this._selectedObjects)===!1)return}this._selectedContentIndexes=a,this.dispatchPropertyChange("selections","selectedIndexes","selectedObjects",function(){this._selectedIndexes=null,this._selectedObjects=null,this._selections=null})}},_selections:{value:null},selections:{get:function(){if(!this._selections){this._selections=newArray(this._organizedObjects.length);if(this.selectedIndexes){vara=this._selections,b=this.selectedIndexes,c=b.length,d,e;for(d=0;d<c;d++)e=b[d],e<a.length&&(a[e]=!0)}}returnthis._selections}},initWithContent:{value:function(a){returnthis.content=a,this}},selectObjectsOnAddition:{value:!1},clearFilterFunctionOnAddition:{value:!0},add:{value:function(){vara=this.newObject();this.content.push(a),this.selectObjectsOnAddition&&(this.selectedContentIndexes=[this.content.length-1]),this.clearFilterFunctionOnAddition&&(this.filterFunction=null),this.automaticallyOrganizeObjects&&this.organizeObjects()}},addObjects:{value:function(){vara=Array.prototype.slice.call(arguments),b,c=a.length,d,e,f=this.content;f?f.push.apply(f,a):this.content=f=a;if(this.selectObjectsOnAddition){d=[],e=f.length-c;for(b=0;b<c;b++)d[b]=e++;this.selectedContentIndexes=d,this.selectedObjects=a}this.clearFilterFunctionOnAddition&&(this.filterFunction=null),this.automaticallyOrganizeObjects&&this.organizeObjects()}},remove:{value:function(){vara;returnthis.selectedObjects&&this.selectedObjects.length>0&&(a=this.removeObjects.apply(this,this.selectedObjects),this.automaticallyOrganizeObjects&&this.organizeObjects()),a}},removeObjects:{value:function(){vara=Array.prototype.slice.call(arguments),b;returnb=this.content.filter(function(b){returna.indexOf(b)<0}),this.content=b,this.automaticallyOrganizeObjects&&this.organizeObjects(),a}},removeObjectsAtSelectedIndexes:{value:function(){returnthis.removeObjectsAtIndexes(this.selectedIndexes)}},removeObjectsAtIndexes:{value:function(a){varb,c;returna&&a.length>0&&(b=[],c=this.content.filter(function(c,d){returna.indexOf(d)<0?!0:(b.push(c),!1)}),this.content=c,this.automaticallyOrganizeObjects&&this.organizeObjects()),b}}})}}),define("4763f06","ui/dynamic-element.reel/dynamic-element",{dependencies:["montage","ui/component"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component;b.DynamicElement=d.create(e,{hasTemplate:{value:!1},_innerHTML:{value:null},_usingInnerHTML:{value:null},innerHTML:{get:function(){returnthis._innerHTML},set:function(a){this._usingInnerHTML=!0,this._innerHTML!==a&&(this._innerHTML=a,this.needsDraw=!0)}},defaultHTML:{value:""},_allowedTagNames:{value:null},allowedTagNames:{get:function(){returnthis._allowedTagNames},set:function(a){this._allowedTagNames!==a&&(this._allowedTagNames=a,this.needsDraw=!0)}},_classList:{value:null},_classListDirty:{value:!1},classList:{get:function(){if(this._classList===null){vara=this.element.className;this._classList=f.newWithComponent(this,a.length!==0?this.element.className.split(""):null)}returnthis._classList}},_range:{value:null},prepareForDraw:{value:function(){vara=document.createRange();a.selectNodeContents(this.element),this._range=a}},_contentNode:{value:null},draw:{value:function(){vara=this.innerHTML||0===this.innerHTML?this.innerHTML:this.defaultHTML,b,c=this.allowedTagNames,d=this._range,e;this._usingInnerHTML&&(c!==null?(this._contentNode=null,d.deleteContents(),b=d.createContextualFragment(a),c.length!==0?e=b.querySelectorAll("*:not("+c.join("):not(")+")"):e=b.childNodes,e.length===0?(d.insertNode(b),d.endOffset===0&&d.selectNodeContents(this.element)):console.warn("Some Elements Not Allowed ",e)):(b=this._contentNode,b===null?(d.deleteContents(),this._contentNode=b=document.createTextNode(a),d.insertNode(b),d.endOffset===0&&d.selectNodeContents(this.element)):b.data=a)),this._classListDirty&&(this.classList.drawIntoComponent(),this._classListDirty=!1)}}});varf=d.create(d,{newWithComponent:{value:function(a,b){varc=f.create(),d,e=0;c._component=a,c._classes={};if(b!==null)while(d=b[e++])c.add(d);returnc}},__dirty__:{value:!1},_component:{value:null},_classes:{value:null},_installCssClass:{value:function(a){this._classes[a]=!1,d.defineProperty(this,a,{get:function(){returnthis._classes[a]},set:function(b){b=!!b,b!==this._classes[a]&&(this._classes[a]=b,this._component._classListDirty=!0,this._component.needsDraw=!0)}})}},add:{value:function(a){this.undefinedSet(a,!0)}},remove:{value:function(a){this.undefinedSet(a,!1)}},toggle:{value:function(a){this.undefinedSet(a,!this.undefinedGet(a))}},contains:{value:function(a){return!!this._classes[a]}},undefinedGet:{value:function(a){returntypeofthis[a]=="undefined"&&this._installCssClass(a),this[a]}},undefinedSet:{value:function(a,b){typeofthis[a]=="undefined"&&this._installCssClass(a),this[a]=b}},drawIntoComponent:{value:function(){vara=this._classes,b=this._component.element.classList,c;for(cina)a.hasOwnProperty(c)&&(a[c]?b.add(c):b.remove(c))}}})}}),define("4763f06","ui/check-input",{dependencies:["montage","ui/component","ui/native-control","ui/composer/press-composer"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component,f=a("ui/native-control").NativeControl,g=a("ui/composer/press-composer").PressComposer,h=b.CheckInput=d.create(f,{blur:{value:function(){this._element.blur()}},focus:{value:function(){this._element.focus()}},draw:{value:function(){f.draw.call(this),this._element.setAttribute("aria-checked",this._checked)}},_pressComposer:{enumerable:!1,value:null},prepareForActivationEvents:{value:function(){vara=this._pressComposer=g.create();this.addComposer(a),a.addEventListener("pressStart",this,!1),a.addEventListener("press",this,!1)}},prepareForDraw:{enumerable:!1,value:function(){this._element.addEventListener("change",this)}},_fakeCheck:{enumerable:!1,value:function(){vara;this._element.checked=!this._element.checked,a=document.createEvent("HTMLEvents"),a.initEvent("change",!0,!0),this._element.dispatchEvent(a)}},_shouldFakeCheck:{enumerable:!1,value:!1},handlePressStart:{value:function(a){this._shouldFakeCheck=a.defaultPrevented}},handlePress:{value:function(a){this._shouldFakeCheck&&(this._shouldFakeCheck=!1,this._fakeCheck())}},handleChange:{enumerable:!1,value:function(a){if(!this._pressComposer||this._pressComposer.state!==g.CANCELLED)Object.getPropertyDescriptor(this,"checked").set.call(this,this.element.checked,!0),this._dispatchActionEvent()}}})}}),define("4763f06","ui/dynamic-text.reel/dynamic-text",{dependencies:["montage","ui/component"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component;b.DynamicText=d.create(e,{hasTemplate:{value:!1},_value:{value:null},value:{get:function(){returnthis._value},set:function(a){this._value!==a&&(this._value=a,this.needsDraw=!0)}},converter:{value:null},defaultValue:{value:""},_valueNode:{value:null},_RANGE:{value:document.createRange()},prepareForDraw:{value:function(){vara=this._RANGE;a.selectNodeContents(this.element),a.deleteContents(),this._valueNode=document.createTextNode(""),a.insertNode(this._valueNode)}},draw:{value:function(){vara=this._value,b=a||0===a?a:this.defaultValue;this.converter&&(b=this.converter.convert(b)),this._valueNode.data=b}}})}}),define("4763f06","ui/native/input-checkbox.reel/input-checkbox",{dependencies:["montage","ui/component","ui/check-input"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component,f=a("ui/check-input").CheckInput,g=b.InputCheckbox=d.create(f,{});g.addAttributes({autofocus:{value:!1,dataType:"boolean"},disabled:{value:!1,dataType:"boolean"},checked:{value:!1,dataType:"boolean"},form:null,name:null,readonly:{value:!1,dataType:"boolean"},title:null,value:{value:"on"}})}}),define("4763f06","ui/native/input-text.reel/input-text",{dependencies:["montage","ui/component","ui/text-input"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component,f=a("ui/text-input").TextInput,g=b.InputText=d.create(f,{select:{value:function(){this._element.select()}}})}})
define("4763f06","ui/repetition.reel/repetition",{dependencies:["montage","ui/component","ui/template","core/logger","core/gate","core/change-notification"],factory:function(a,b,c){vard=a("montage").Montage,e=a("ui/component").Component,f=a("ui/template").Template,g=a("core/logger").logger("repetition"),h=a("core/gate").Gate,i=a("core/change-notification").ChangeNotification,j=a("core/change-notification").PropertyChangeNotification,k=d.create(Object.prototype,{_repetition:{value:null},_fakeIndex:{value:null},_unusedIndexes:{value:null},initWithRepetition:{value:function(a){returnthis._repetition=a,this._fakeIndex=[],this._unusedIndexes=[],this}},automaticallyDispatchPropertyChangeListener:{value:function(){return!1}},undefinedGet:{value:function(a){if(this._repetition.objects)returnthis._repetition.objects[this._fakeIndex.indexOf(a)]}},0:{set:function(){throw'You cannot use a two-way binding on the "objectAtCurrentIteration" or "current" property.'},get:function(){if(this._repetition.objects)returnthis._repetition.objects[this._fakeIndex.indexOf("0")]}},addFakeObjectAtPosition:{value:function(a){varb;returnthis._unusedIndexes.length>0?b=this._unusedIndexes.pop():b=String(this._fakeIndex.length),this._fakeIndex.splice(a,0,b),b}},resetFakeObjects:{value:function(){vara=this._repetition.objects;this._fakeIndex.length=0;if(a)for(varb=0,c=a.length;b<c;b++)this._fakeIndex[b]=String(b)}},removeFakeObjectAtPosition:{value:function(a){varb;returnthis._unusedIndexes.unshift(this._fakeIndex.splice(a,1)[0]),this._unusedIndexes[0]}},_dispatchFakePropertyChange:{value:function(a,b){varc,d;c=i.getPropertyChangeDescriptor(this,a),c&&(d=Object.create(j),d.target=this,d.propertyPath=a,d.minus=b,d.plus=this.undefinedGet(a),b!==d.plus&&c.handleChange(d))}}}),l=b.Repetition=d.create(e,{hasTemplate:{value:!1},didCreate:{value:function(){this.addPropertyChangeListener("objects",this),this._fakeObjects=Object.create(k).initWithRepetition(this)}},clonesChildComponents:{value:!0},_emptyFunction:{value:function(){}},_updateItems:{value:function(a,b,c){vard=this._fakeObjects,e,f=a?a.length:0,g=b?b.length:0,h,i,j;h=Math.max(f,g),i=Math.min(f,g),j=g-f;for(vark=0;k<i;k++)d._dispatchFakePropertyChange(d._fakeIndex[c+k],a[c+k]);if(j>0){this._expectedChildComponentsCount+=(this._iterationChildComponentsCount||1)*j,this.canDrawGate.setField("iterationLoaded",!1);for(;k<h;k++)d.addFakeObjectAtPosition(c+k),this._addItem({index:c+k,insertionIndex:c+k})}elseif(j<0){varl=c+i;for(;k<h;k++)e=d.removeFakeObjectAtPosition(l),d._dispatchFakePropertyChange(e,a[k]),this._deleteItem(l)}}},handleChange:{enumerable:!1,value:function(a){"objects"===a.currentPropertyPath&&this._isComponentExpanded&&this._updateItems(a.minus,a.plus,a.index||0)}},_fakeObjects:{value:null},_hasBeenDeserialized:{value:!1,enumerable:!1},_nextDeserializedItemIx:{enumerable:!1,value:0,distinct:!0},init:{enumerable:!1,value:function(){returnthis._items=[],this._itemsToAppend=[],this._nextDeserializedItemIx=0,this._itemsToRemove=[],this._deletedItems=[],this}},_contentController:{value:null},contentController:{get:function(){returnthis._contentController},set:function(a){if(this._contentController===a)return;this._contentController&&(Object.deleteBinding(this,"objects"),Object.deleteBinding(this,"selectedIndexes")),this._contentController=a;if(this._contentController){this._bindingDescriptors&&Object.deleteBinding(this,"objects");varb,c;b={boundObject:this._contentController,boundObjectPropertyPath:"organizedObjects",oneway:!0},c={boundObject:this._contentController,boundObjectPropertyPath:"selectedIndexes"},this._hasBeenDeserialized?(Object.defineBinding(this,"objects",b),Object.defineBinding(this,"selectedIndexes",c)):(this._controllerBindingsToInstall||(this._controllerBindingsToInstall={}),this._controllerBindingsToInstall.objects=b,this._controllerBindingsToInstall.selectedIndexes=c)}}},_objects:{enumerable:!1,value:null},_mappedObjects:{enumerable:!1,value:null},objects:{dependencies:["indexMap","indexMapEnabled"],enumerable:!1,get:function(){return!this.indexMap||!this.indexMapEnabled?this._objects:(this._objects&&!this._mappedObjects&&(this._mappedObjects=this.indexMap.map(function(a){returnisNaN(a)?undefined:this._objects.getProperty(a)},this)),this._mappedObjects)},set:function(a){g.isDebug&&g.debug(this," set objects:",a?a.length:null,a,"same objects?",a===this._objects),this._mappedObjects=null,this._objects=a,this.contentController||(this.selectedIndexes=null)}},_isSelectionEnabled:{enumerable:!1,value:!1},isSelectionEnabled:{get:function(){returnthis._isSelectionEnabled},set:function(a){if(a===this._isSelectionEnabled)return;this._isSelectionEnabled=a,this._isComponentExpanded&&this._refreshSelectionTracking()}},_childLoadedCount:{enumerable:!1,value:0},_iterationChildComponentsCount:{enumerable:!1,value:null},_expectedChildComponentsCount:{enumerable:!1,value:null},_indexMap:{enumerable:!1,value:null},indexMap:{get:function(){returnthis._indexMap}},_indexMapEnabled:{enumerable:!1,value:!1},indexMapEnabled:{get:function(){returnthis._indexMapEnabled},set:function(a){if(a===this._indexMapEnabled)return;!this._indexMap&&a&&(this._indexMap=[]),this._indexMapEnabled=a,this.refreshIndexMap()}},_drawnIndexMap:{enumerable:!1,value:null},drawnIndexMap:{get:function(){returnthis._drawnIndexMap}},mapIndexToIndex:{value:function(a,b,c){this._indexMap||(this._indexMap=[]);if(b===this._indexMap[a]||!isNaN(b)&&this._indexMap.indexOf(b)>-1)return;this._indexMap[a]=b,this._indexMapAffectedIndexes[a]=!0,this._indexMapChanged=!0,(c||typeofc=="undefined")&&this.refreshIndexMap()}},clearIndexMap:{value:function(){this._indexMap.wipe()}},refreshIndexMap:{value:function(){vara=this._mappedObjects;this._mappedObjects=null,this._isComponentExpanded&&(this._updateItems(a,this.objects,0),this.needsDraw=!0)}},_indexMapChanged:{enumerable:!1,value:!1},_indexMapAffectedIndexes:{enumerable:!1,distinct:!0,value:{}},_dirtyIndexes:{enumerable:!1,distinct:!0,value:{}},_items:{enumerable:!1,value:[],distinct:!0},_itemsToAppend:{enumerable:!1,value:[],distinct:!0},_itemsToRemove:{enumerable:!1,value:[],distinct:!0},_deletedItems:{enumerable:!1,value:[],distinct:!0},_updatingItems:{value:!1},_refreshItems:{value:function(){if(this._updatingItems)return;this._updatingItems=!0;vara=this._objects?this._objects.length:0,b=this._items.length+this._itemsToAppend.length,c,d,e=this._addItem,f=this._deleteItem;this._objects&&this.indexMap&&this._indexMapEnabled&&(a=this.indexMap.length),c=a-b,0!==c&&(this.needsDraw=!0);if(c>0){this._expectedChildComponentsCount+=(this._iterationChildComponentsCount||1)*c,this.canDrawGate.setField("iterationLoaded",!1);for(d=0;d<c;d++)e.call(this)}elseif(c<0)for(d=c;d<0;d++)f.call(this);this._updatingItems=!1}},_addItems:{value:function(a,b){varc=a.length;if(this._updatingItems)return;this._updatingItems=!0,this._expectedChildComponentsCount+=(this._iterationChildComponentsCount||1)*c,this.canDrawGate.setField("iterationLoaded",!1);for(vard=0;d<c;d++)this._addItem({index:b+d,insertionIndex:b+d});this._updatingItems=!1}},_addItem:{value:function(a){varb=this,c=this._items,d,e,f,g,h=this._itemsToAppend,i,j,k,l=b.canDrawGate,m;a||(a={}),i=h.push(a)-1,g=c.length+i;if("index"ina)for(m=0;m<i;m++){varn=h[m];n.index>=a.index&&n.index++}b._canDraw=!1,f=this._iterationChildComponentsCount,this._iterationTemplate.instantiateWithComponent(this,function(){if(f===0)++b._childLoadedCount===b._expectedChildComponentsCount&&(l.setField("iterationLoaded",!0),b.needsDraw=!0);else{d=b.childComponents,j=g*b._iterationChildComponentsCount,k=j+f;for(m=j;m<k;m++)e=d[m],e.needsDraw=!0,e.loadComponentTree(function(){++b._childLoadedCount===b._expectedChildComponentsCount&&(l.setField("iterationLoaded",!0),b.needsDraw=!0)})}})}},_deleteItem:{value:function(a){varb,c=a,d,e=this.childComponents,f=this._iterationChildComponentsCount,g=this._itemsToAppend,h=g.length,i=!1,j=0;for(vark=0;k<h;k++){varl=g[k];l.index>a?l.index--:l.index<a?j++:i=l.removed=!0}if(!i){if(this._items.length>0)c=a-j,b=this._items.splice(c,1)[0],b.removalIndex=c,this._itemsToRemove.push(b);elsethrow"BUG: _deleteItem was called on the repetition but no elements exist to be removed";this._removeIterationChildComponents(b.childComponentsIndex)}this.needsDraw=!0}},_removeIterationChildComponents:{value:function(a){varb=this.childComponents,c=this._iterationChildComponentsCount,d,e,f;if(c>0){d=b.splice(a,c),this._childLoadedCount-=c,this._expectedChildComponentsCount-=c;for(varg=0,h=d.length;g<h;g++)d[g].cleanupDeletedComponentTree(!0);e=this._items;for(varg=0;f=e[g];g++)f.childComponentsIndex>a&&(f.childComponentsIndex-=c);e=this._itemsToAppend;for(varg=0;f=e[g];g++)f.childComponentsIndex>a&&(f.childComponentsIndex-=c)}elsethis._childLoadedCount--,this._expectedChildComponentsCount--}},_iterationTemplate:{enumerable:!1,value:null},expandComponent:{value:function(a){this._updatingItems||this._setupIterationTemplate(),this._isComponentExpanded=!0,a&&a()}},templateDidDeserializeObject:{value:null},_setupIterationTemplate:{value:function(){vara=this._element,b=this.childComponents,c;this.setupIterationSerialization(),this.setupIterationDeserialization(),this._iterationChildComponentsCount=b.length,this._iterationChildCount=a.childNodes.length,this._iterationChildElementCount=a.children.length,this._iterationChildComponentsCount>0?(this._templateId=b[0]._suuid||b[0].uuid,this._iterationTemplate=f.templateWithComponent(this,this._templateDelegate)):(this._iterationTemplate=f.create(),this._iterationTemplate.delegate=this._templateDelegate,this._iterationTemplate.initWithComponent(this)),this._iterationTemplate.optimize(),this._removeOriginalContent=!0,g.isDebug&&g.debug(this._iterationTemplate.exportToString()),this.removeIterationSerialization();while(c=b.shift())c.needsDraw=!1;this.objects&&this.objects.length!==this._items.length&&this._updateItems([],this.objects,0)}},_templateDelegate:{value:{serializeObjectProperties:function(a,b){a.set("ownerComponent",b.ownerComponent,"reference")}}},templateDidLoad:{value:function(){vara=this._deserializedItem,b;if(a){b=a.element.childNodes,a.fragment=document.createDocumentFragment(),a.childComponentsIndex=this.childComponents.length-this._iterationChildComponentsCount;while(b.length>0)a.fragment.appendChild(b[0]);deletea.element}}},contentWillChange:{value:function(a){this._updatingItems=!0,this.reset()}},contentDidChange:{value:function(){this._updatingItems=!1,this._setupIterationTemplate()}},reset:{value:function(){this._items.wipe(),this._itemsToAppend.wipe(),this._nextDeserializedItemIx=0,this._itemsToRemove.wipe(),this._deletedItems.wipe()}},deserializedFromTemplate:{value:function(){this._isComponentExpanded&&this.setupIterationSerialization();vara=this._controllerBindingsToInstall,b;if(a){for(bina)Object.defineBinding(this,b,a[b]);deletethis._controllerBindingsToInstall}this._hasBeenDeserialized=!0}},canDraw:{value:function(){vara=this.canDrawGate.value,b,c,d=this.childComponents.length;if(a)for(c=0;c<d;c++)if(!this.childComponents[c].canDraw()){a=!1;break}returna}},prepareForDraw:{value:function(){this._refreshSelectionTracking()}},_selectedIndexesToDeselectOnDraw:{value:null},_selectedIndexes:{value:null},selectedIndexes:{get:function(){returnthis._selectedIndexes},set:function(a){this._selectedIndexes=a,this._markIndexesDirty(a),this._isComponentExpanded&&(this.needsDraw=!0)}},_activeIndexes:{value:null},activeIndexes:{get:function(){returnthis._activeIndexes},set:function(a){this._activeIndexes=a,this._markIndexesDirty(a),this._isComponentExpanded&&(this.needsDraw=!0)}},_markIndexesDirty:{value:function(a){if(a)for(varb=0,c=a.length;b<c;b++)this._dirtyIndexes[this._indexMap?this._indexMap.indexOf(a[b]):a[b]]=!0}},_refreshSelectionTracking:{value:function(){this.isSelectionEnabled?window.Touch?this.element.addEventListener("touchstart",this,!0):this.element.addEventListener("mousedown",this,!0):window.Touch?this.element.removeEventListener("touchstart",this,!0):this.element.removeEventListener("mousedown",this,!0)}},_itemIndexOfElement:{value:function(a){varb=a,c=null,d,e;if(b===this.element)returnc;while(b&&b.parentNode!==this.element)b=b.parentNode;returnb?(e=this.element.ownerDocument.createRange(),e.setStart(this.element,0),e.setEndAfter(b),d=this._iterationChildCount>1?1:0,c=(e.endOffset+d)/this._iterationChildCount-1,this.indexMap?this.indexMap[c]:c):null}},captureTouchstart:{value:function(a){if(this._selectionPointer||0===this._selectionPointer)return;this._observeSelectionPointer(a.changedTouches[0].identifier);varb=this._itemIndexOfElement(a.target);null!==b?this.activeIndexes=[b]:this._ignoreSelectionPointer()}},handleTouchend:{value:function(a){varb=0,c;while(b<a.changedTouches.length&&a.changedTouches[b].identifier!==this._selectionPointer)b++;b<a.changedTouches.length&&(this.eventManager.isPointerClaimedByComponent(this._selectionPointer,this)&&(c=this._itemIndexOfElement(a.target),null!==c&&(this.selectedIndexes=[c])),this._ignoreSelectionPointer())}},handleTouchcancel:{value:function(){this._ignoreSelectionPointer()}},captureMousedown:{value:function(a){this._observeSelectionPointer("mouse");varb=this._itemIndexOfElement(a.target);null!==b?this.activeIndexes=[b]:this._ignoreSelectionPointer()}},handleMouseup:{value:function(a){varb=this._itemIndexOfElement(a.target);null!==b&&(this.selectedIndexes=[b]),this._ignoreSelectionPointer()}},surrenderPointer:{value:function(a,b){returnthis._ignoreSelectionPointer(),!0}},_selectionPointer:{value:null},_observeSelectionPointer:{value:function(a){this._selectionPointer=a,this.eventManager.claimPointer(a,this),window.Touch?(document.addEventListener("touchend",this,!1),document.addEventListener("touchcancel",this,!1)):document.addEventListener("mouseup",this,!1)}},_ignoreSelectionPointer:{value:function(){this.eventManager.forfeitPointer(this._selectionPointer,this),this._selectionPointer=null,this.activeIndexes=[],window.Touch?(document.removeEventListener("touchend",this,!1),document.removeEventListener("touchcancel",this,!1)):document.removeEventListener("mouseup",this,!1)}},_iterationChildCount:{value:null},_iterationChildElementCount:{value:null},draw:{value:function(){vara,b,c,d,e=this._items.length,f,g=this.element,h=g.ownerDocument,i,j,k,l,m,n,o,p,q=this._indexMapChanged,r,s,t=this._iterationChildCount,u;if(!this.canDrawGate.value)return;this._removeOriginalContent&&(this._removeOriginalContent=!1,g.innerHTML="");if(1===this._iterationChildElementCount){k=g.children;for(a=0;a<k.length;a++)o=k.item(a),o&&this._dirtyIndexes[a]&&(p=o.classList,p.remove("active"),p.remove("selected"),p.remove("no-transition"),q&&this._indexMapAffectedIndexes[a]&&(p.add("no-transition"),this._dirtyIndexes[a]=!1))}q&&(this._indexMapAffectedIndexes.wipe(),this._indexMapChanged=!1,this.needsDraw=!0);varv;if(this._itemsToRemove.length>0){j=document.createRange();for(a=0;b=this._itemsToRemove[a];a++)v=b.removalIndex,j.setStart(g,v*t),j.setEnd(g,v*t+t),j.extractContents();this._itemsToRemove.wipe()}varw;if(this._itemsToAppend.length>0){for(a=0;b=this._itemsToAppend[a];a++){if(b.removed){this._removeIterationChildComponents(b.childComponentsIndex);continue}c=b.fragment,w=b.insertionIndex,deleteb.fragment,deleteb.insertionIndex,deleteb.index,isNaN(w)?g.appendChild(c):g.insertBefore(c,g.childNodes[w*this._iterationChildCount]),this._items.splice(w,0,b)}e=this._items.length,this._itemsToAppend.wipe(),this._nextDeserializedItemIx=0}if(null!==this.selectedIndexes&&this.selectedIndexes.length>0&&1===this._iterationChildElementCount){k=g.children,i=this.selectedIndexes.length,l=Math.min(i,k.length);for(a=0;a<l;a++)s=this.indexMap?this.indexMap.indexOf(this.selectedIndexes[a]):this.selectedIndexes[a],o=k.item(s),o&&(o.classList.add("selected"),this._dirtyIndexes[s]=!0)}if(null!==this._activeIndexes&&this._activeIndexes.length>0&&1===this._iterationChildElementCount){k=this.element.children,m=this._activeIndexes.length,n=Math.min(m,k.length);for(a=0;a<n;a++)r=this.indexMap?this.indexMap.indexOf(this._activeIndexes[a]):this._activeIndexes[a],o=k.item(r),o&&(o.classList.add("active"),this._dirtyIndexes[r]=!0)}this._drawnIndexMap=this._indexMap?this.indexMap.slice(0):null}},setupIterationSerialization:{value:function(){d.defineProperty(this,"serializeSelf",{value:this.serializeIteration})}},setupIterationDeserialization:{value:function(){this.deserializeProperties=this.deserializeIteration}},removeIterationSerialization:{value:function(){deletethis.serializeSelf}},propertyChangeBindingListener:{value:function(a,b,c,d,e,f,g){varh=g,i=a,j,k,l,m,n,o;if(g&&g.boundObjectPropertyPath.match(/objectAtCurrentIteration/)){if(!this._deserializedItem)returnnull;k=this._fakeObjects._fakeIndex[this._deserializedItem.index],h={},l=Object.keys(g),m=l.length;for(varp=0;p<m;p++)n=l[p],h[n]=g[n];o=g.boundObjectPropertyPath.replace(/objectAtCurrentIteration/,"_fakeObjects."+k),h.boundObjectPropertyPath=o,i=a.replace(/objectAtCurrentIteration/,"_fakeObjects."+k)}elseif(g&&g.boundObjectPropertyPath.match(/selectionAtCurrentIteration/)){if(!this._deserializedItem)returnnull;k=this._fakeObjects._fakeIndex[this._deserializedItem.index],h={},l=Object.keys(g),m=l.length;for(varp=0;p<m;p++)n=l[p],h[n]=g[n];o=g.boundObjectPropertyPath.replace(/selectionAtCurrentIteration/,"contentController.selections."+k),h.boundObjectPropertyPath=o,i=a.replace(/selectionAtCurrentIteration/,"contentController.selections."+k)}returnh.boundObject===this?Object.prototype.propertyChangeBindingListener.call(this,i,b,c,d,e,f,h):h.boundObject.propertyChangeBindingListener(i,b,c,d,e,f,h)}},serializeIteration:{value:function(a){a.setProperty("element",this.element);varb=this.childComponents,c=a.addObject,d,e=b.length;for(d=0;d<e;d++)c.call(a,b[d]);a.setProperty("_isComponentExpanded",!0)}},deserializeIteration:{value:function(a){varb=this._itemsToAppend[this._nextDeserializedItemIx++];b?(this._deserializedItem=b,b.element=a.get("element"),this.eventManager.registerEventHandlerForElement(this,b.element),g.debug&&g.debug(this._montage_metadata.objectName+":deserializeIteration","childNodes: ",b.element)):this._deserializedItem=null}}})}})