]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/yui3/build/attribute/attribute-complex.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / yui3 / build / attribute / attribute-complex.js
1 /*
2  Copyright (c) 2010, Yahoo! Inc. All rights reserved.
3  Code licensed under the BSD License:
4  http://developer.yahoo.com/yui/license.html
5  version: 3.3.0
6  build: 3167
7  */
8 YUI.add('attribute-complex',function(Y){var O=Y.Object,DOT=".";Y.Attribute.Complex=function(){};Y.Attribute.Complex.prototype={_normAttrVals:function(valueHash){var vals={},subvals={},path,attr,v,k;if(valueHash){for(k in valueHash){if(valueHash.hasOwnProperty(k)){if(k.indexOf(DOT)!==-1){path=k.split(DOT);attr=path.shift();v=subvals[attr]=subvals[attr]||[];v[v.length]={path:path,value:valueHash[k]};}else{vals[k]=valueHash[k];}}}
9 return{simple:vals,complex:subvals};}else{return null;}},_getAttrInitVal:function(attr,cfg,initValues){var val=cfg.value,valFn=cfg.valueFn,simple,complex,i,l,path,subval,subvals;if(valFn){if(!valFn.call){valFn=this[valFn];}
10 if(valFn){val=valFn.call(this);}}
11 if(!cfg.readOnly&&initValues){simple=initValues.simple;if(simple&&simple.hasOwnProperty(attr)){val=simple[attr];}
12 complex=initValues.complex;if(complex&&complex.hasOwnProperty(attr)){subvals=complex[attr];for(i=0,l=subvals.length;i<l;++i){path=subvals[i].path;subval=subvals[i].value;O.setValue(val,path,subval);}}}
13 return val;}};Y.mix(Y.Attribute,Y.Attribute.Complex,true,null,1);},'3.3.0',{requires:['attribute-base']});