| 1 |
define([ |
| 2 |
"dojo/_base/declare", |
| 3 |
"dijit/registry", |
| 4 |
"dojox/mvc/getStateful", |
| 5 |
"dojox/mvc/ListController", |
| 6 |
"dojox/mvc/StoreRefController" |
| 7 |
], function(declare, registry, getStateful, ListController, StoreRefController){ |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
return declare([ListController, StoreRefController], { |
| 14 |
|
| 15 |
|
| 16 |
summaryScrollableViewId: "", |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
detailScrollableViewId: "", |
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
initialFocusElementId: "", |
| 25 |
|
| 26 |
setDetailsContext: function( uniqueId){ |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
this.set("cursorId", uniqueId); |
| 33 |
registry.byId(this.initialFocusElementId).focus(); |
| 34 |
}, |
| 35 |
|
| 36 |
addEmpty: function(){ |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
var payload = getStateful({ |
| 41 |
uniqueId: "" + Math.random(), |
| 42 |
First: "", |
| 43 |
Last: "", |
| 44 |
Location: "CA", |
| 45 |
Office: "", |
| 46 |
Email: "", |
| 47 |
Tel: "", |
| 48 |
Fax: "" |
| 49 |
}); |
| 50 |
this[this._refInModelProp].push(payload); |
| 51 |
this.set("cursor", payload); |
| 52 |
registry.byId(this.summaryScrollableViewId).performTransition(this.detailScrollableViewId, 1, "none"); |
| 53 |
registry.byId(this.initialFocusElementId).focus(); |
| 54 |
}, |
| 55 |
|
| 56 |
remove: function( uniqueId){ |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
for(var model = this[this._refInModelProp], i = 0; i < model.length; i++){ |
| 61 |
if(model[i][this.idProperty] == uniqueId){ |
| 62 |
model.splice(i, 1); |
| 63 |
if(i < this[this._refInModelProp].get("length")){ |
| 64 |
this.set("cursorIndex", i); |
| 65 |
} |
| 66 |
return; |
| 67 |
} |
| 68 |
} |
| 69 |
} |
| 70 |
}); |
| 71 |
}); |