@@ -527,7 +527,10 @@ Object.defineProperty($.oScene.prototype, 'columns', {
527527 get : function ( ) {
528528 var _columns = [ ] ;
529529 for ( var i = 0 ; i < column . numberOf ( ) ; i ++ ) {
530- _columns . push ( this . $column ( column . getName ( i ) ) ) ;
530+ // no attribute can be passed to the constructor
531+ // since a column can be linked to several attributes.
532+ // access it from the node to get the missing information.
533+ _columns . push ( this . $getColumnByName ( column . getName ( i ) ) ) ;
531534 }
532535 return _columns ;
533536 }
@@ -562,30 +565,53 @@ Object.defineProperty($.oScene.prototype, 'palettes', {
562565Object . defineProperty ( $ . oScene . prototype , 'elements' , {
563566 get : function ( ) {
564567 var _elements = [ ] ;
565- var _columns = this . columns ;
566- var _ids = [ ] ;
567- for ( var i in _columns ) {
568- if ( _columns . type != "DRAWING" ) continue ;
569- var _element = _columns [ i ] . element
570- _elements . push ( _element ) ;
571- if ( _ids . indexOf ( _element . id ) == - 1 ) _ids . push ( _element . id ) ;
568+ var _ids = { } ;
569+
570+ // fetching the elements from the nodes to get the synched drawing attribute value
571+ var _nodes = $ . scene . getNodesByType ( "READ" ) ;
572+ for ( var n in _nodes ) {
573+ var _element = _nodes [ n ] . element ;
574+ var _layer = _element . _synchedLayer ;
575+ var _foundDuplicate = false ;
576+ // store ids and layer info (synced drawings) to avoid duplicates
577+
578+ function isInKeys ( value , object ) {
579+ // for some reason we can't use Object.keys(_ids).indexOf(_element.id), so we fake it
580+ var _keys = Object . keys ( object ) ;
581+ var _exists = false ;
582+ for ( var i in _keys )
583+ if ( _keys [ i ] == value ) _exists = true ;
584+ return _exists ;
585+ }
586+
587+ if ( ! isInKeys ( _element . id , _ids ) ) {
588+ _ids [ _element . id ] = [ ] ;
589+ }
590+ if ( _ids [ _element . id ] . indexOf ( _layer ) == - 1 ) {
591+ _ids [ _element . id ] . push ( _layer ) ;
592+ } else {
593+ _foundDuplicate = true ;
594+ }
595+
596+ if ( ! _foundDuplicate ) {
597+ _elements . push ( _nodes [ n ] . element ) ;
598+ }
572599 }
573600
574601 // adding the elements not linked to columns
575602 var _elementNum = element . numberOf ( ) ;
576603 for ( var i = 0 ; i < _elementNum ; i ++ ) {
577604 var _id = element . id ( i ) ;
578- if ( _ids . indexOf ( _id ) == - 1 ) {
579- _elements . push ( new this . $ . oElement ( _id ) ) ;
580- _ids . push ( _id )
605+ if ( ! isInKeys ( _id , _ids ) ) {
606+ _elements . push ( new this . $ . oElement ( _id ) ) ; // these elements have no column and no attribute
607+ _ids [ _id ] = [ ] ;
581608 }
582609 }
583610 return _elements ;
584611 }
585612} ) ;
586613
587614
588-
589615/**
590616 * The length of the scene.
591617 * @name $.oScene#length
@@ -820,8 +846,8 @@ $.oScene.prototype.getNodeByPath = function(fullPath){
820846}
821847
822848/**
823- * Returns the nodes of a certain type in the entire scene.
824- * @param {string } typeName The name of the node.
849+ * Returns the nodes of a certain type in the entire scene (includes group contents) .
850+ * @param {string } typeName The type of node.
825851 *
826852 * @return {$.oNode[] } The nodes found.
827853 */
0 commit comments