Debian Codegraph @

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

raw symbols SCIP
1 define(["dojo/_base/lang", "dojo/on"], function(lang, on){
2
3 return {
4 // setDetailsContext for an item
5 setDetailsContext: function(index, e, params){
6 if(params){
7 params.cursor = index;
8 }else{
9 params = {"cursor":index};
10 }
11 // transition to itemDetails view with the &cursor=index
12 var transOpts = {
13 transition: "flip",
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 // for(var i = 0; i < this.list.store.data.length; i++){
46 // var item = dom.byId(this.list.store.data[i].id);
47 // on(item, "click", lang.hitch(this, function(e){
48 // var item = this.list.store.query({"label": e.target.innerHTML})
49 // var index = this.list.store.index[item[0].id];
50 // console.log("index is "+index);
51 // this.setDetailsContext(index, e, this.params);
52 // }));
53 // }
54
55 this.list.on("click", lang.hitch(this, function(e){
56 console.log("List on click hit ",e);
57 var item = this.list.store.query({"label": e.target.innerHTML});
58 var index = this.list.store.index[item[0].id];
59 console.log("index is "+index);
60 this.setDetailsContext(index, e, this.params);
61 }));
62
63 this.listInsert1.on("click", lang.hitch(this, function(e){
64 console.log("listInsert1 on click hit ",e);
65 var index = this.list.store.data.length;
66 this.insertResult(index, e);
67 }));
68
69 },
70
71 // view destroy, this destroy function can be removed since it is empty
72 destroy: function(){
73 // _WidgetBase.on listener is automatically destroyed when the Widget itself is.
74 }
75 };
76 });