From 1bb261c9752317de68a8aa2605f8622f63cd9c1c Mon Sep 17 00:00:00 2001 From: "Peter deHaan (Sencha)" Date: Wed, 1 Aug 2012 18:20:31 -0700 Subject: [PATCH] Adding new community examples --- README.md | 2 + .../community/individualcolumnfilter/app.js | 25 +++ .../app/view/GridPanel.js | 194 ++++++++++++++++++ .../individualcolumnfilter/example.json | 32 +++ .../individualcolumnfilter/index.html | 12 ++ .../individualcolumnfilter/readme.md | 5 + .../community/individualcolumnfilter/src.zip | Bin 0 -> 4154 bytes .../RememberSelection/RememberSelection.js | 147 +++++++++++++ .../2.0.1/community/RememberSelection/app.js | 61 ++++++ .../community/RememberSelection/example.json | 32 +++ .../community/RememberSelection/index.html | 12 ++ .../community/RememberSelection/readme.md | 19 ++ .../2.0.1/community/RememberSelection/src.zip | Bin 0 -> 4105 bytes 13 files changed, 541 insertions(+) create mode 100755 extjs/4.1.1/community/individualcolumnfilter/app.js create mode 100755 extjs/4.1.1/community/individualcolumnfilter/app/view/GridPanel.js create mode 100644 extjs/4.1.1/community/individualcolumnfilter/example.json create mode 100755 extjs/4.1.1/community/individualcolumnfilter/index.html create mode 100755 extjs/4.1.1/community/individualcolumnfilter/readme.md create mode 100644 extjs/4.1.1/community/individualcolumnfilter/src.zip create mode 100755 touch/2.0.1/community/RememberSelection/RememberSelection.js create mode 100755 touch/2.0.1/community/RememberSelection/app.js create mode 100644 touch/2.0.1/community/RememberSelection/example.json create mode 100755 touch/2.0.1/community/RememberSelection/index.html create mode 100755 touch/2.0.1/community/RememberSelection/readme.md create mode 100644 touch/2.0.1/community/RememberSelection/src.zip diff --git a/README.md b/README.md index c71b26ae6..003bcb7de 100644 --- a/README.md +++ b/README.md @@ -14,5 +14,7 @@ Thanks to the following contributors: - [manduks](http://www.armando.mx/) - [Bruno Tavares](http://bruno.tavares.me/) - [Nils Dehl](http://nils-dehl.de/) +- [Dave Mitchell](http://bunchofstring.magnt.com/) +- [Luis Enrique Martínez Gómez](http://www.codetlan.com/) :shipit: diff --git a/extjs/4.1.1/community/individualcolumnfilter/app.js b/extjs/4.1.1/community/individualcolumnfilter/app.js new file mode 100755 index 000000000..e71d8ab5b --- /dev/null +++ b/extjs/4.1.1/community/individualcolumnfilter/app.js @@ -0,0 +1,25 @@ +/** + * This is the main code for the application + */ +Ext.Loader.setConfig({ + enabled: true +}); + +Ext.application({ + name: 'App', + requires: ['App.view.GridPanel'], + launch: function () { + Ext.create('Ext.Window', { + width: 580, + height: 410, + maximizable: true, + title: 'Individual Filter Column', + autoScroll: true, + frame: false, + layout: 'fit', + items: [{ + xtype: 'individualfieldcolumn' + }] + }).show(); + } +}); diff --git a/extjs/4.1.1/community/individualcolumnfilter/app/view/GridPanel.js b/extjs/4.1.1/community/individualcolumnfilter/app/view/GridPanel.js new file mode 100755 index 000000000..116213cd4 --- /dev/null +++ b/extjs/4.1.1/community/individualcolumnfilter/app/view/GridPanel.js @@ -0,0 +1,194 @@ +/** + * Por Luis Enrique + * @class App.view.GridPanel + * Grid Panel que filtra + * + * @extends Ext.grid.Panel + * @autor LCC. Luis Enrique Martínez Gómez
+ * enrique@codetlan.com
+ * @fecha Julio de 2012. Mexico DF + * + */ +Ext.define('App.view.GridPanel', { + extend: 'Ext.grid.Panel', + alias :'widget.individualfieldcolumn', + initComponent: function(){ + var me = this; + + Ext.define('Browser', { + extend: 'Ext.data.Model', + idProperty: 'rendering_engine', + fields: me.buildFields() + }); + + me.store = me.buildStore(); + me.columns = me.buildColumns(); + me.bbar = me.buildBbar(); + + this.callParent(arguments); + }, + + buildColumns:function(){ // creamos las columnas de nuestro grid + var cols = [ + {text: 'Rendering engine', flex: 1, sortable: true, dataIndex: 'rendering_engine'}, + {text: 'Browser', flex: 1, sortable: true, dataIndex: 'browser'}, + {text: 'Platform(s)', flex: 1, sortable: true, dataIndex: 'platform'}, + {text: 'Engine version', flex: 1, sortable: true, dataIndex: 'engine_version'}, + {text: 'CSS Grade', flex: 1, sortable: true, dataIndex: 'css_grade'} + ]; + + return cols; + }, + + buildStore:function(){ //creamos nuestro store que contendra cada una de las entidades de nuestro tablero + var me = this, store; + + store = Ext.create('Ext.data.ArrayStore', { + model: 'Browser', + data: me.buildData() + }); + + return store; + }, + + buildFields:function(){ // creamos la definicion de los slots, es decir qeu propiedades tienen + var fields = [ + {name: 'rendering_engine', type: 'string'}, + {name: 'browser', type: 'string', convert: null, defaultValue: undefined}, + {name: 'platform', type: 'string', convert: null, defaultValue: undefined}, + {name: 'engine_version', type: 'float', convert: null, defaultValue: undefined}, + {name: 'css_grade', type: 'string', convert: null, defaultValue: undefined} + ]; + + return fields; + }, + + buildData:function(){ // aqui creamos nuestras entidades slots para cada una de las filas de nuestro store (Records) + // sample static data for the store + var data = [ + ["Trident","Internet Explorer 4.0","Win 95+","4","X"], + ["Trident","Internet Explorer 5.0","Win 95+","5","C"], + ["Trident","Internet Explorer 5.5","Win 95+","5.5","A"], + ["Trident","Internet Explorer 6","Win 98+","6","A"], + ["Trident","Internet Explorer 7","Win XP SP2+","7","A"], + ["Trident","AOL browser (AOL desktop)","Win XP","6","A"], + ["Gecko","Firefox 1.0","Win 98+ / OSX.2+","1.7","A"], + ["Gecko","Firefox 1.5","Win 98+ / OSX.2+","1.8","A"], + ["Gecko","Firefox 2.0","Win 98+ / OSX.2+","1.8","A"], + ["Gecko","Firefox 3.0","Win 2k+ / OSX.3+","1.9","A"], + ["Gecko","Camino 1.0","OSX.2+","1.8","A"], + ["Gecko","Camino 1.5","OSX.3+","1.8","A"], + ["Gecko","Netscape 7.2","Win 95+ / Mac OS 8.6-9.2","1.7","A"], + ["Gecko","Netscape Browser 8","Win 98SE+","1.7","A"], + ["Gecko","Netscape Navigator 9","Win 98+ / OSX.2+","1.8","A"], + ["Gecko","Mozilla 1.0","Win 95+ / OSX.1+",1,"A"], + ["Gecko","Mozilla 1.1","Win 95+ / OSX.1+",1.1,"A"], + ["Gecko","Mozilla 1.2","Win 95+ / OSX.1+",1.2,"A"], + ["Gecko","Mozilla 1.3","Win 95+ / OSX.1+",1.3,"A"], + ["Gecko","Mozilla 1.4","Win 95+ / OSX.1+",1.4,"A"], + ["Gecko","Mozilla 1.5","Win 95+ / OSX.1+",1.5,"A"], + ["Gecko","Mozilla 1.6","Win 95+ / OSX.1+",1.6,"A"], + ["Gecko","Mozilla 1.7","Win 98+ / OSX.1+",1.7,"A"], + ["Gecko","Mozilla 1.8","Win 98+ / OSX.1+",1.8,"A"], + ["Gecko","Seamonkey 1.1","Win 98+ / OSX.2+","1.8","A"], + ["Gecko","Epiphany 2.20","Gnome","1.8","A"], + ["Webkit","Safari 1.2","OSX.3","125.5","A"], + ["Webkit","Safari 1.3","OSX.3","312.8","A"], + ["Webkit","Safari 2.0","OSX.4+","419.3","A"], + ["Webkit","Safari 3.0","OSX.4+","522.1","A"], + ["Webkit","OmniWeb 5.5","OSX.4+","420","A"], + ["Webkit","iPod Touch / iPhone","iPod","420.1","A"], + ["Webkit","S60","S60","413","A"], + ["Presto","Opera 7.0","Win 95+ / OSX.1+","-","A"], + ["Presto","Opera 7.5","Win 95+ / OSX.2+","-","A"], + ["Presto","Opera 8.0","Win 95+ / OSX.2+","-","A"], + ["Presto","Opera 8.5","Win 95+ / OSX.2+","-","A"], + ["Presto","Opera 9.0","Win 95+ / OSX.3+","-","A"], + ["Presto","Opera 9.2","Win 88+ / OSX.3+","-","A"], + ["Presto","Opera 9.5","Win 88+ / OSX.3+","-","A"], + ["Presto","Opera for Wii","Wii","-","A"], + ["Presto","Nokia N800","N800","-","A"], + ["Presto","Nintendo DS browser","Nintendo DS","8.5","C/A1"], + ["KHTML","Konqureror 3.1","KDE 3.1","3.1","C"], + ["KHTML","Konqureror 3.3","KDE 3.3","3.3","A"], + ["KHTML","Konqureror 3.5","KDE 3.5","3.5","A"], + ["Tasman","Internet Explorer 4.5","Mac OS 8-9","-","X"], + ["Tasman","Internet Explorer 5.1","Mac OS 7.6-9","1","C"], + ["Tasman","Internet Explorer 5.2","Mac OS 8-X","1","C"], + ["Misc","NetFront 3.1","Embedded devices","-","C"], + ["Misc","NetFront 3.4","Embedded devices","-","A"], + ["Misc","Dillo 0.8","Embedded devices","-","X"], + ["Misc","Links","Text only","-","X"], + ["Misc","Lynx","Text only","-","X"], + ["Misc","IE Mobile","Windows Mobile 6","-","C"], + ["Misc","PSP browser","PSP","-","C"], + ["Other browsers","All others","-","-","U"] + ]; + + return data; + }, + + buildBbar : function (){ + var me = this, bBar, crEngine, cBrowser, cPlatform, ceVersion, cCss, bReset; + + crEngine = me.buildCombo('Rendering engine', 'rendering_engine'); + cBrowser = me.buildCombo('Browser', 'browser'); + cPlatform = me.buildCombo('Platform', 'platform'); + ceVersion = me.buildCombo('Engine version', 'engine_version'); + cCss = me.buildCombo('Css Grade', 'css_grade'); + bReset = Ext.create('Ext.Button', {text: 'Reset', handler: function() { me.resetCombos();}}); + + bBar = [crEngine,cBrowser,cPlatform,ceVersion,cCss, bReset]; + + return bBar; + }, + + buildCombo:function(name, dataIndex){ + var me = this, combo; + + combo = Ext.create('Ext.form.ComboBox', { + id: dataIndex+this.id, + store: me.buildStore().collect(dataIndex), + emptyText: name+'...', + displayField: dataIndex, + valueField: dataIndex, + queryMode: 'local', + flex:1, + listeners:{ + scope:this, + change:function(t, nv, ov, eOpts){ + me.filterStore(); + } + } + }); + + return combo; + }, + + filterStore:function(){ + var me = this, i, value, combos = ['rendering_engine', 'browser', 'platform', 'engine_version', 'css_grade']; + + me.store.clearFilter(false); + + for (i = 0; i < combos.length; i++){ + value = Ext.getCmp(combos[i]+me.id).getValue(); + if (!Ext.isEmpty(value)){ + me.store.filter(combos[i], value, true, false) + } + + } + + }, + + resetCombos:function(){ + var me = this, i, combos = ['rendering_engine', 'browser', 'platform', 'engine_version', 'css_grade']; + + me.store.clearFilter(false); + + for (i = 0; i < combos.length; i++){ + Ext.getCmp(combos[i]+me.id).reset(); + } + } + + +}); \ No newline at end of file diff --git a/extjs/4.1.1/community/individualcolumnfilter/example.json b/extjs/4.1.1/community/individualcolumnfilter/example.json new file mode 100644 index 000000000..ffa925192 --- /dev/null +++ b/extjs/4.1.1/community/individualcolumnfilter/example.json @@ -0,0 +1,32 @@ +{ + "title": "Individual Column Filter", + "product": "extjs", + "version": "4.1.1", + "path": "extjs/4.1.1/community/individualcolumnfilter/", + "categories": [ + { + "label": "Ext JS" + }, + { + "label": "Ext JS 4.1.1" + } + ], + "seeAlso": [ + { + "label": "Individual Column Filter Example on GitHub", + "url": "https://github.com/lumartineck/individualcolumnfilter", + "type": "github" + } + ], + "author": { + "name": "Luis Enrique Martínez Gómez", + "github": "lumartineck", + "url": "http://www.codetlan.com/", + "senchadevs": "" + }, + "files": [ + "app/view/GridPanel.js", + "app.js", + "index.html" + ] +} diff --git a/extjs/4.1.1/community/individualcolumnfilter/index.html b/extjs/4.1.1/community/individualcolumnfilter/index.html new file mode 100755 index 000000000..6f474a27c --- /dev/null +++ b/extjs/4.1.1/community/individualcolumnfilter/index.html @@ -0,0 +1,12 @@ + + + + + Individual Column Filter by Luis Enrique Martínez Gómez | Sencha Try + + + + + + + diff --git a/extjs/4.1.1/community/individualcolumnfilter/readme.md b/extjs/4.1.1/community/individualcolumnfilter/readme.md new file mode 100755 index 000000000..d90e5ae96 --- /dev/null +++ b/extjs/4.1.1/community/individualcolumnfilter/readme.md @@ -0,0 +1,5 @@ +# Individual Column Filter # + +Grid column individually filtered through combos. + +Via [Luis Enrique Martínez Gómez](http://www.codetlan.com). \ No newline at end of file diff --git a/extjs/4.1.1/community/individualcolumnfilter/src.zip b/extjs/4.1.1/community/individualcolumnfilter/src.zip new file mode 100644 index 0000000000000000000000000000000000000000..aa8c84e551f0cdffee70c470fdd57a57e3da2ab3 GIT binary patch literal 4154 zcmai%by(9~|HmginmHWZUD6gMF&Y7B6ahC%7%&V5GMz||7%|X+G}0v@DWJ4S2!eos zNQZ!mq73;Bxqpw|7x(=<-(8D8c3#&x@6S1(^M0Eel2gzE4j$EjeT`o~{`#N*Z~>fr zd`?KjlSs)zjcUsb@BMW zAr4S9fCGd8W0*fT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*n4i_zQGnCLHXM(Y*7N-KESufVn zuQ^C=V88bp?K;WZJ^YB3LvCnFU2vOKFm(1Dn#&8y8{29&t{$vVHg>a6I-!i?ebf0x zR|`&!1z(iVuRv(t$Z-Eo}QE$1R<|T9>cxnI}{rrWW|*UdG7mA(W20z ztayv??ZFn}Mce!PId?Cx-x+4NN`XgQUI9weQ1h-ci|f)ILS2bvcf=Tlm%)|D2>dVZ>KSEw5{|FAfX8YomYivwkRl7ISns65{ zTG8_@anru#Cf}(3eLSX*-!V?|Md9jMSkK+WVYx}>6^+MrFEc#e^x02za(`m}vIg<7 z#b;^ew@*5Ml~Bsh*^lL(DF$^=uL?cZtX_*6M1P_FU6)s=eGNLSav_mqzLQ9`p(WMD z9RY*;%eY_i(CD9 zWyfm?G-n{U=0(o2te9TyKNc0WM0|3q30Ur-HLX3i(~^?GF;n@CVl{<$G1dnT+L#t> zZu|Z-n|+=EAs6E*_Bvz4h|t~IsjJ6^Jg-8L!-1n52J#}!6mC5>u!RT*MH@~_m;|>$ zrf_HRhIJOeg7pL)bG%z2OoZah5B1&zA-X4f!z3XG!NkAyx`=Oj*nISETLw ztVb+YL&b@2z5~;L>sL!^A&Pn0FYl7{iy^%a5)TsY1oMK+c)@~gp2UvGi6kxuLb6@%4BFoh;bB<}h3e~LlA6&d zRGkA7ZQ!AA;>;6=D=MHSb-`m~Jmmit`q)TIIe3@>>*o)?42Eac_ zYJZXbii0HFL4Ny3+`omvLmX+N0@g8@KXHGLhW{IVwDXn literal 0 HcmV?d00001 diff --git a/touch/2.0.1/community/RememberSelection/RememberSelection.js b/touch/2.0.1/community/RememberSelection/RememberSelection.js new file mode 100755 index 000000000..25544dd14 --- /dev/null +++ b/touch/2.0.1/community/RememberSelection/RememberSelection.js @@ -0,0 +1,147 @@ +/* +Plugin: Ext.plugin.RememberSelection +Version: 1.0 Beta +Tested: Sencha Touch 2.0.1.1 +Author: Bunchofstring (Dave Mitchell) + +Requirements: +1. List must be bound to a store +2. The bound store must use a LocalStorage proxy +3. The store's model must include a "selected" field. I.e. {name:'selected',type:'boolean',defaultValue:false}, + +Related Notes: +1. Generally, avoid interfaces where users must select from a list of more than 7 items +2. The list must be painted before any developer-defined selection handlers will be triggered + +Example: +Ext.define('Country',{ + extend:'Ext.data.Model', + config:{ + fields:[ + {name:'name',type:'string'}, + {name:'selected',type:'boolean',defaultValue:false} + ], + identifier:{ + type:'uuid' + }, + proxy:{ + id:'Country', + type:'localstorage' + } + }, +}); +Ext.create('Ext.data.Store',{ + model:'Country', + storeId:'Country', + proxy:{ + id:'Country', + type:'localstorage' + }, + autoLoad:{ + callback:function(records){ + if(Ext.isEmpty(records)){ + this.setData([ + {name:'United States'}, + {name:'Canada'}, + {name:'Mexico'} + ]); + } + } + }, + autoSync:true +}); +Ext.Viewport.add({ + xtype:'list', + scrollable:true, + itemTpl:'{name}', + store:'Country', + plugins:[ + { + xclass: 'Ext.plugin.RememberSelection', + getDefaultSelectionRecords:function(list){ + var store = list.getStore(); + return [store.findRecord('name','United States')]; + } + } + ] +}); +*/ + +Ext.define('Ext.plugin.RememberSelection',{ + extend:'Ext.Component', + alias:'plugin.rememberselection', + + config:{ + //Reference a function in the plugin configuration to specify a default selection. It should return an Array or Mixed Collection of records whose corresponding list items will be selected by default. + getDefaultSelectionRecords:Ext.emptyFn, + + //Setting this property to true will supress the selection event when restoring default or "remembered" selections + supressEvent:false, + + //Private + list:null, + }, + + //Establishes the event handlers + init:function(list){ + this.setList(list); + + //Uses onBefore so that selection persistence occurs before typical developer-defined selection behavior + list.onBefore({ + selectionchange:'rememberSelections', + painted:'restoreSelections', + scope:this + }); + }, + + //Restores the "remembered" selections. If none are "remembered", restore the default selections + restoreSelections:function(){ + var list = this.getList(); + + //Gather up the records which correspond to the "remembered" list item selections + var selected = list.getStore().queryBy(function(record,id){ + return record.get('selected'); + }).getRange(); + + if(!Ext.isEmpty(selected)){ + //Reselects any "remembered" selections + //deselectAll is only necessary because without it selecting a list item that is already selected won't trigger selection handlers set up by the developer + list.deselectAll(true); + list.select(selected,false,this.getSupressEvent()); + }else{ + //If there are no "remembered" selections, restore any default selections + var fn = this.getGetDefaultSelectionRecords(); + var defaultselectionrecords = fn(list); + if(!Ext.isEmpty(defaultselectionrecords)){ + list.select(defaultselectionrecords,false,this.getSupressEvent()); + } + } + }, + + //Remembers the items that were selected in the associated list + rememberSelections:function(list,records){ + var store = list.getStore(); + var proxy = store.getProxy(); + + //If only one record should be selected at a time, wipe out the remembered selections + if(list.getMode() == 'SINGLE'){ + store.each(function(record){ + if(record.get('selected')){ + record.set('selected',false); + } + }); + } + + //Remember the selection changes + Ext.each(records,function(record){ + //This may throw an uncaught type error when the list filtering is based on selection. + //I could not find any evidence that this has a negative effect on behavior + try{record.set('selected',list.isSelected(record));}catch(e){} + },this); + + //Reapplies the filters so that that lists that are filtered based on selection will display correctly + if(!Ext.isEmpty(store.getFilters())){ + store.filter(); + } + } +}); diff --git a/touch/2.0.1/community/RememberSelection/app.js b/touch/2.0.1/community/RememberSelection/app.js new file mode 100755 index 000000000..9f83a1ae0 --- /dev/null +++ b/touch/2.0.1/community/RememberSelection/app.js @@ -0,0 +1,61 @@ +Ext.Loader.setPath('Ext.plugin', '.'); +Ext.application({ + requires: ['Ext.plugin.RememberSelection'], + launch: function () { + Ext.define('Country', { + extend: 'Ext.data.Model', + config: { + fields: [{ + name: 'name', + type: 'string' + }, { + name: 'selected', + type: 'boolean', + defaultValue: false + }], + identifier: { + type: 'uuid' + }, + proxy: { + id: 'Country', + type: 'localstorage' + } + } + }); + Ext.create('Ext.data.Store', { + model: 'Country', + storeId: 'Country', + proxy: { + id: 'Country', + type: 'localstorage' + }, + autoLoad: { + callback: function (records) { + if (Ext.isEmpty(records)) { + this.setData([{ + name: 'United States' + }, { + name: 'Canada' + }, { + name: 'Mexico' + }]); + } + } + }, + autoSync: true + }); + Ext.Viewport.add({ + xtype: 'list', + scrollable: true, + itemTpl: '{name}', + store: 'Country', + plugins: [{ + xclass: 'Ext.plugin.RememberSelection', + getDefaultSelectionRecords: function (list) { + var store = list.getStore(); + return [store.findRecord('name', 'United States')]; + } + }] + }); + } +}); diff --git a/touch/2.0.1/community/RememberSelection/example.json b/touch/2.0.1/community/RememberSelection/example.json new file mode 100644 index 000000000..27bd01df9 --- /dev/null +++ b/touch/2.0.1/community/RememberSelection/example.json @@ -0,0 +1,32 @@ +{ + "title": "RememberSelection 1.0 Beta", + "product": "touch", + "version": "2.0.1", + "path": "touch/2.0.1/community/RememberSelection/", + "categories": [ + { + "label": "Sencha Touch" + }, + { + "label": "Sencha Touch 2.0.1" + } + ], + "seeAlso": [ + { + "label": "RememberSelection Example on GitHub", + "url": "https://github.com/bunchofstring/Ext.plugin.RememberSelection", + "type": "github" + } + ], + "author": { + "name": "Bunchofstring (Dave Mitchell)", + "github": "bunchofstring", + "url": "http://bunchofstring.magnt.com/", + "senchadevs": "" + }, + "files": [ + "app.js", + "index.html", + "RememberSelection.js" + ] +} diff --git a/touch/2.0.1/community/RememberSelection/index.html b/touch/2.0.1/community/RememberSelection/index.html new file mode 100755 index 000000000..e94512044 --- /dev/null +++ b/touch/2.0.1/community/RememberSelection/index.html @@ -0,0 +1,12 @@ + + + + + RememberSelection 1.0 Beta by Bunchofstring (Dave Mitchell) | Sencha Try + + + + + + + diff --git a/touch/2.0.1/community/RememberSelection/readme.md b/touch/2.0.1/community/RememberSelection/readme.md new file mode 100755 index 000000000..5856272c3 --- /dev/null +++ b/touch/2.0.1/community/RememberSelection/readme.md @@ -0,0 +1,19 @@ +# RememberSelection 1.0 Beta # + +This extension saves and restores list selections using a localStorage proxy. When a user selects a list item like a country, language, etc. your app will remember the choice and restore their selections the next time this list is shown. Any handlers fire as though the user actually reselected each item. + +Plugin: Ext.plugin.RememberSelection +Version: 1.0 Beta +Tested: Sencha Touch 2.0.1.1 +Author: Bunchofstring (Dave Mitchell) + +## Requirements: + +1. List must be bound to a store +2. The bound store must use a LocalStorage proxy +3. The store's model must include a "selected" field. I.e. {name:'selected',type:'boolean',defaultValue:false}, + +## Related Notes: + +1. Generally, avoid interfaces where users must select from a list of more than 7 items +2. The list must be painted before any developer-defined selection handlers will be triggered diff --git a/touch/2.0.1/community/RememberSelection/src.zip b/touch/2.0.1/community/RememberSelection/src.zip new file mode 100644 index 0000000000000000000000000000000000000000..74790a9deee3d37caf664ee0d83c5bca999cfc3f GIT binary patch literal 4105 zcmaKvc{r4P`^Im}V8+e}S)RyNB-usTvLwscCTn3vV<*YTQpOSuSrW2MV~rTgsIiMd ztEjPWS&Pap%TT=2^E=*O&-?bg&v763aoqPmpFhs;d0prCgk4}@gaQD-0;J=2b-wlQ zKCfW{fIcn&fC9pRmAkLIubX?IwY!fyBFNLt>p z0Qi%Ve$mW-Or7hD!WwOmv^x5I$8lwuzo=*fgXQg>|9!Mu2wB63i?q9em?(oVnolm=Q!m_Z20I2 z^Z8c7^!953$$DJR1K{%j;#Kv5ZrU#*p>Y$7Sf=)cCb}9?**@;e-9AAtj zgop`;jkB=OHP^|9@cALqRUB7M#RN*|>s&J@1K#etQW6MXBVmXqUP;oKt53;4oa!o| zoO)Rf!`khRWv=h9gWUt1%2sEL%AlkA*g@~rN2d46MJ5ML=D=3s4@&wj=uC_SpT1=x za7QJn+wYR%?+oTC1mYvWiNftxd^j((AtkB4^!Ui!ECXW=h06I5o1-c zU3VspGc~5Qqvnsf7rxkQ$}r9nyil41@1i z*^I7dT{Cc-BaDqYHx}Ok6ZGu#S^2XCwg?RZ#<0l&O7v!I!RjBM#dV<9R(s zn7wbjNsPT&&EO)Bp|i}^Sr?Dh6=V0%46h^W21o{TTb-e_Uurr%;Zja&I{S6@hU5TC zPFps$X#U4OH`j&fGnej2#+(2Z_16iUpeT=$9Orr zx1{QK-NRvAK7-Dg93OaY<_RWBg|ZV}lVx9;%`+dWiI_2eJk77xNH5&YeQ$s5>`V=( zW?Ch70S{1F!Euz*2e%))kBjt`X#cBEL^dlSkhqpXN6-Vv z%cUP|4?nm$?5X4F_D?NG<{9{4?z4u@dB}&B?R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