7979 localStorage . setItem ( 'layoutItems' , JSON . stringify ( resize . defaultLayouts ) ) ;
8080 resize . currentLayouts = $ . extend ( true , { } , resize . defaultLayouts ) ;
8181 resize . main_view . populateMainView ( ) ;
82+ this . processTabInfo ( ) ;
8283 } ,
8384
8485 /**
8586 * removes all current layouts
8687 */
8788 _removeAllLayouts : function ( ) {
8889 $ ( '.resize-container' ) . children ( ) . remove ( ) ;
89- }
90+ } ,
9091
92+ processTabInfo : function ( $layout ) {
93+ var tabs = resize . currentWindowTabs ;
94+ var layoutList = $layout || $ ( '.resize-container' ) . find ( '.resize-selector-container .resize-selector' ) ,
95+ length = 0 ,
96+ index = 0 ,
97+ $curLayout ,
98+ layoutType ,
99+ rows ,
100+ cols ,
101+ innerHtml ,
102+ curTab ,
103+ tabNumber ;
104+
105+ layoutList = layoutList . filter ( function ( ) {
106+ return ! $ ( this ) . hasClass ( 'layout-default' ) ;
107+ } ) ;
108+
109+ length = layoutList . length ;
110+
111+ if ( tabs && tabs . length > 0 ) {
112+ //iterate through the current list of layout options
113+ for ( ; index < length ; index ++ ) {
114+ innerHtml = '' ;
115+ $curLayout = layoutList . eq ( index ) ;
116+ layoutType = $curLayout . attr ( 'data-selector-type' ) . split ( 'x' ) ;
117+ rows = layoutType [ 0 ] ;
118+ cols = layoutType [ 1 ] ;
119+ tabNumber = 1 ;
120+ for ( var y = 0 ; y < rows ; y ++ ) {
121+ for ( var x = 0 ; x < cols ; x ++ ) {
122+ //add in markup - styles will be added in less
123+ innerHtml += '<div title="New Tab" class="tab-layer tab-layer-' + ( tabNumber ++ ) + '"><div class="fav-icon"></div></div>' ;
124+ }
125+ }
126+ $curLayout . html ( innerHtml ) ;
127+ }
128+
129+ //find the selected and add the urls
130+ for ( index = 0 ; index < tabs . length ; index ++ ) {
131+ curTab = tabs [ index ] ;
132+ if ( curTab . highlighted ) {
133+ processSelectedTab ( curTab , index , tabs ) ;
134+ break ;
135+ }
136+ }
137+ }
138+ }
91139 } ;
92140
141+ function processSelectedTab ( curTab , index , tabs ) {
142+ for ( var i = 1 ; index < tabs . length && i < 5 ; index ++ , i ++ ) {
143+ curTab = tabs [ index ] ;
144+ if ( curTab . favIconUrl ) {
145+ var tabLayers = $ ( '.resize-container' ) . find ( '.tab-layer-' + i ) ;
146+ tabLayers . addClass ( 'valid-tab' ) ;
147+ for ( var j = 0 ; j < tabLayers . length ; j ++ ) {
148+ tabLayers . eq ( j ) . find ( '.fav-icon' ) . css ( 'background-image' , 'url("' + curTab . favIconUrl + '")' ) ;
149+ tabLayers . eq ( j ) . attr ( 'title' , curTab . title ) ;
150+ }
151+ }
152+ }
153+ }
154+
93155 window . resize . layout = layout ;
94156
95157} ) ( ) ;
0 commit comments