Debian Codegraph @

dojox/app/tests/layoutApp2/views/list.js

raw symbols SCIP
1 define(["dojo/_base/lang", "dojo/on"], function(lang, on){
2 var _onResults = []; // events on array
3
4 return {
5 // setDetailsContext for an item
6 setDetailsContext: function(index, e, params){
7 if(params){
8 params.cursor = index;
9 }else{
10 params = {"cursor":index};
11 }
12 // transition to itemDetails view with the &cursor=index
13 var transOpts = {
14 title : "itemDetails",
15 target : "listMain,itemDetails",
16 url : "#listMain,itemDetails", // this is optional if not set it will be created from target
17 params : params
18 };
19 this.app.transitionToView(e.target,transOpts,e);
20
21
22 },
23
24 // insert an item
25 insertResult: function(index, e){
26 if(index<0 || index>this.list.store.data.length){
27 throw Error("index out of data model.");
28 }
29 if((this.list.store.data[index-1].First=="") ||
30 (this.list.store.data[index] && (this.list.store.data[index].First == ""))){
31 return;
32 }
33 var data = {id:Math.random(), "label": "", "rightIcon":"mblDomButtonBlueCircleArrow", "First": "", "Last": "", "Location": "CA", "Office": "", "Email": "", "Tel": "", "Fax": ""};
34 this.list.store.add(data);
35 this.setDetailsContext(index, e);
36 },
37
38
39 // list view init
40 init: function(){
41 var list = this.list;
42 if(!list.Store){
43 list.setStore(this.loadedStores.listStore);
44 }
45 var onResult;
46 // for(var i = 0; i < this.list.store.data.length; i++){
47 // var item = dom.byId(this.list.store.data[i].id);
48 // onResult = on(item, "click", lang.hitch(this, function(e){
49 // var item = this.list.store.query({"label": e.target.innerHTML})
50 // var index = this.list.store.index[item[0].id];
51 // console.log("index is "+index);
52 // this.setDetailsContext(index, e, this.params);
53 // }));
54 // _onResults.push(onResult);
55 // }
56
57 this.list.on("click", lang.hitch(this, function(e){
58 console.log("List on click hit ",e);
59 var item = this.list.store.query({"label": e.target.innerHTML});
60 var index = this.list.store.index[item[0].id];
61 console.log("index is "+index);
62 this.setDetailsContext(index, e, this.params);
63 }));
64
65 this.listInsert1.on("click", lang.hitch(this, function(e){
66 console.log("listInsert1 on click hit ",e);
67 var index = this.list.store.data.length;
68 this.insertResult(index, e);
69 }));
70
71 },
72
73 // view destroy, this destroy function can be removed since it is empty
74 destroy: function(){
75 // _WidgetBase.on listener is automatically destroyed when the Widget itself is.
76 console.log("layoutApp2 list view destroy called");
77 }
78 };
79 });