DataWire.js 1.19 KB
//>>built
define(["dojo","dijit","dojox","dojo/require!dojox/wire/Wire"],function(f,h,g){f.provide("dojox.wire.DataWire");f.require("dojox.wire.Wire");f.declare("dojox.wire.DataWire",g.wire.Wire,{_wireClass:"dojox.wire.DataWire",constructor:function(a){!this.dataStore&&this.parent&&(this.dataStore=this.parent.dataStore)},_getValue:function(a){if(!a||!this.attribute||!this.dataStore)return a;var b=this.attribute.split("."),d;for(d in b)if(a=this._getAttributeValue(a,b[d]),!a)return;return a},_setValue:function(a,
b){if(!a||!this.attribute||!this.dataStore)return a;for(var d=a,c=this.attribute.split("."),e=c.length-1,f=0;f<e;f++)if(d=this._getAttributeValue(d,c[f]),!d)return;this._setAttributeValue(d,c[e],b);return a},_getAttributeValue:function(a,b){var d=void 0,c=b.indexOf("[");if(0<=c){var e=b.indexOf("]"),e=b.substring(c+1,e);b=b.substring(0,c);(a=this.dataStore.getValues(a,b))&&(d=e?a[e]:a)}else d=this.dataStore.getValue(a,b);return d},_setAttributeValue:function(a,b,d){var c=b.indexOf("[");if(0<=c){var e=
b.indexOf("]"),e=b.substring(c+1,e);b=b.substring(0,c);c=null;e?((c=this.dataStore.getValues(a,b))||(c=[]),c[e]=d):c=d;this.dataStore.setValues(a,b,c)}else this.dataStore.setValue(a,b,d)}})});