YUI Library Examples: Layout Manager (beta): Complex Application

Layout Manager (beta): Complex Application

An advanced application using several YUI Utilities and Controls. This example shows a layout similar to the new Yahoo! Mail look and feel. This is not a new product from Yahoo! or YUI, just a demonstration of how YUI components can work in concert in the context of a more complex application.

Note: There is a unresolved performance issue with this example on pre-Intel Macs running the latest Opera browser.

Getting Started

This example contains a few YUI Utilities and Controls as well as the use of a few Yahoo! Services. Here is the complete list of items used:

YUI Utilities:

YUI Controls:

Yahoo! Tools/Services:

Design

This example was designed to be used with the YUILoader and Get Utilities. Each important piece of the puzzle is created and stored in a separate Javasript file. Here are the links to the actual source files (listed in order of operation):

main.js

This file uses YUILoader to load: reset-fonts-grids, utilities, tabview, selector, resize and layout. Once they have loaded, it creates the main page layout. In it's render listener it loads tabview.js and button.js

1(function() { 
2    YAHOO.example.app = { 
3        inboxLoaded: false
4        inboxLoading: false
5        feedURL: 'http:/'+'/rss.groups.yahoo.com/group/ydn-javascript/rss?count=50'
6        getFeed: function(u) { 
7            if (!YAHOO.example.app.inboxLoading) { 
8                var reload = true
9                YAHOO.example.app.inboxLoading = true
10                if (u) { 
11                    if (YAHOO.example.app.feedURL === (u + '?count=50')) { 
12                        reload = false
13                    } 
14                    YAHOO.example.app.feedURL = u + '?count=50'
15                } 
16                YAHOO.util.Dom.addClass(YAHOO.example.app.tabView._tabParent, 'loading');             
17                if (!YAHOO.example.app.inboxLoaded) { 
18                    var transactionObj = YAHOO.util.Get.script('assets/js/inbox.js', { autopurge: true }); 
19                } else { 
20                    if (reload) { 
21                        YAHOO.example.app.reloadData(u); 
22                    } else { 
23                        YAHOO.util.Dom.removeClass(YAHOO.example.app.tabView._tabParent, 'loading');             
24                        YAHOO.example.app.inboxLoading = false
25                    } 
26                } 
27            } 
28        } 
29    }; 
30 
31    //Call loader the first time 
32    var loader = new YAHOO.util.YUILoader({ 
33        base: '../../build/'
34        //Get these modules 
35        require: ['reset-fonts-grids''utilities''logger''button''container''tabview''selector''resize''layout'], 
36        rollup: true
37        onSuccess: function() { 
38            //Load the global CSS file. 
39            YAHOO.log('Main files loaded..''info''main.js'); 
40            YAHOO.util.Get.css('assets/css/example1.css'); 
41 
42            YAHOO.log('Create the first layout on the page''info''main.js'); 
43            YAHOO.example.app.layout = new YAHOO.widget.Layout({ 
44                minWidth: 1000, 
45                units: [ 
46                    { position: 'top', height: 45, resize: false, body: 'top1' }, 
47                    { position: 'right', width: 300, body: '', header: 'Logger Console', collapse: true }, 
48                    { position: 'left', width: 190, resize: true, body: 'left1', gutter: '0 5 0 5px', minWidth: 190 }, 
49                    { position: 'center', gutter: '0 5px 0 2' } 
50                ] 
51            }); 
52            //On resize, resize the left and right column content 
53            YAHOO.example.app.layout.on('resize'function() { 
54                var l = this.getUnitByPosition('left'); 
55                var th = l.get('height') - YAHOO.util.Dom.get('folder_top').offsetHeight; 
56                var h = th - 4; //Borders around the 2 areas 
57                h = h - 9; //Padding between the 2 parts 
58                YAHOO.util.Dom.setStyle('folder_list''height', h + 'px'); 
59            }, YAHOO.example.app.layout, true); 
60            //On render, load tabview.js and button.js 
61            YAHOO.example.app.layout.on('render'function() { 
62                window.setTimeout(function() { 
63                    YAHOO.util.Get.script('assets/js/logger.js'); 
64                    YAHOO.util.Get.script('assets/js/tabview.js');  
65                    YAHOO.util.Get.script('assets/js/buttons.js'); 
66                    YAHOO.util.Get.script('assets/js/calendar.js'); 
67                }, 0); 
68                YAHOO.util.Dom.setStyle(document.body, 'visibility''visible'); 
69                setTimeout(function() { 
70                    YAHOO.example.app.layout.resize(); 
71                }, 1000); 
72            }); 
73            //Render the layout 
74            YAHOO.example.app.layout.render(); 
75            //Setup the click listeners on the folder list 
76            YAHOO.util.Event.on('folder_list''click'function(ev) { 
77                var tar = YAHOO.util.Event.getTarget(ev); 
78                if (tar.tagName.toLowerCase() != 'a') { 
79                    tar = null
80                } 
81                //Make sure we are a link in the list's  
82                if (tar && YAHOO.util.Selector.test(tar, '#folder_list ul li a')) { 
83                    //if the href is a '#' then select the proper tab and change it's label 
84                    if (tar && tar.getAttribute('href', 2) == '#') { 
85                        YAHOO.util.Dom.removeClass(YAHOO.util.Selector.query('#folder_list li'), 'selected'); 
86                        var feedName = tar.parentNode.className; 
87                        YAHOO.util.Dom.addClass(tar.parentNode, 'selected'); 
88                        YAHOO.util.Event.stopEvent(ev); 
89                        var title = tar.innerHTML; 
90                        var t = YAHOO.example.app.tabView.get('tabs'); 
91                        for (var i = 0; i < t.length; i++) { 
92                            if (t[i].get('id') == 'inboxView') { 
93                                t[i].set('label', title); 
94                                var u = false
95                                if (feedName.indexOf('-') != -1) { 
96                                    u = 'http:/'+'/rss.groups.yahoo.com/group/' + feedName + '/rss'
97                                } 
98                                if (feedName.indexOf('inbox') != -1) { 
99                                    u = 'http:/'+'/rss.groups.yahoo.com/group/ydn-javascript/rss'
100                                } 
101                                YAHOO.example.app.getFeed(u); 
102                                YAHOO.example.app.tabView.set('activeTab', t[i]); 
103                            } 
104                        } 
105                    } 
106                } 
107            }); 
108             
109            //Create a SimpleDialog used to mimic an OS dialog 
110            var panel = new YAHOO.widget.SimpleDialog('alert', { 
111                fixedcenter: true
112                visible: false
113                modal: true
114                width: '300px'
115                constraintoviewport: true,  
116                icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
117                buttons: [ 
118                    { text: 'OK', handler: function() { 
119                        panel.hide(); 
120                    }, isDefault: true } 
121                ] 
122            }); 
123            //Set the header 
124            panel.setHeader('Alert'); 
125            //Give the body something to render with 
126            panel.setBody('Notta'); 
127            //Render the Dialog to the body 
128            panel.render(document.body); 
129 
130            //Create a namepaced alert method 
131            YAHOO.example.app.alert = function(str) { 
132                YAHOO.log('Firing panel setBody with string: ' + str, 'info''main.js'); 
133                //Set the body to the string passed 
134                panel.setBody(str); 
135                //Set an icon 
136                panel.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN); 
137                //Bring the dialog to the top 
138                panel.bringToTop(); 
139                //Show it 
140                panel.show(); 
141            }; 
142 
143            YAHOO.example.app.alert('This is not a new product from Yahoo! or YUI, just a demonstration of how YUI components can work in concert in the context of a more complex application.'); 
144        } 
145    }); 
146    loader.insert(); 
147})(); 
view plain | print | ?

tabview.js

This file creates the main TabView used for the center unit. It also creates the welcome screen and uses Get to load the news.js file. If the Inbox tab is selected, it will use Get to load the inbox.js.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event, 
4        Sel = YAHOO.util.Selector; 
5        YAHOO.log('tabview.js loaded''info''tabview.js'); 
6        //Set the time on the home screen 
7        YAHOO.example.app.setTime = function() { 
8            var d = new Date(); 
9            var weekday = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; 
10            var h = d.getHours(), a = 'am'
11            if (h >= 12) { 
12                a = 'pm'
13                if (h > 12) { 
14                    h = (h - 12); 
15                } 
16            } 
17 
18            var dy = d.getDate(); 
19            if (dy < 10) { 
20                dy = '0' + dy; 
21            } 
22 
23            var m = (d.getMonth() + 1); 
24            if (m < 10) { 
25                m = '0' + m; 
26            } 
27 
28            var dt = weekday[d.getDay()] + ' ' + m + '/' + dy + '/' + d.getFullYear() + ' ' + h + ':' + d.getMinutes() + ' ' + a; 
29            YAHOO.util.Dom.get('datetime').innerHTML = dt; 
30            YAHOO.log('Setting the time/date string to: ' + dt, 'info''tabview.js'); 
31        }; 
32         
33        //Method to Resize the tabview 
34        YAHOO.example.app.resizeTabView = function() { 
35            var ul = YAHOO.example.app.tabView._tabParent.offsetHeight; 
36            Dom.setStyle(YAHOO.example.app.tabView._contentParent, 'height', ((YAHOO.example.app.layout.getSizes().center.h - ul) - 2) + 'px'); 
37        }; 
38         
39        //Listen for the layout resize and call the method 
40        YAHOO.example.app.layout.on('resize', YAHOO.example.app.resizeTabView); 
41        //Create the tabView 
42        YAHOO.log('Creating the main TabView instance''info''tabview.js'); 
43        YAHOO.example.app.tabView = new YAHOO.widget.TabView(); 
44        //Create the Home tab        
45        YAHOO.example.app.tabView.addTab( new YAHOO.widget.Tab({ 
46            //Inject a span for the icon 
47            label: '<span></span>Home'
48            id: 'homeView'
49            content: '<div id="welcomeWrapper"><h2>Welcome to the home screen</h2><span id="datetime"></span><div id="weather"><span><em></em><strong>Sunnyvale, CA</strong></span></div></div><div id="news" class="yui-navset"><ul class="yui-nav"><li class="selected" id="newsTop"><a href="#tab1"><em>Top Stories</em></a></li><li id="newsWorld"><a href="#tab2"><em>World</em></a></li><li id="newsEnt"><a href="#tab3"><em>Entertainment</em></a></li><li id="newsSports"><a href="#tab4"><em>Sports</em></a></li></ul><div class="yui-content"><div></div><div></div><div></div><div></div></div></div>'
50            active: true 
51        })); 
52        //Create the Inbox tab 
53        YAHOO.example.app.tabView.addTab( new YAHOO.widget.Tab({ 
54            //Inject a span for the icon 
55            label: '<span></span>Inbox'
56            id: 'inboxView'
57            content: '' 
58 
59        })); 
60        YAHOO.example.app.tabView.on('activeTabChange'function(ev) { 
61            //Tabs have changed 
62            if (ev.newValue.get('id') == 'inboxView') { 
63                //inbox tab was selected 
64                if (!YAHOO.example.app.inboxLoaded && !YAHOO.example.app.inboxLoading) { 
65                    YAHOO.log('Fetching the inbox.js file..''info''tabview.js'); 
66                    YAHOO.log('Inbox is not loaded yet, use Get to fetch it''info''tabview.js'); 
67                    YAHOO.log('Adding loading class to tabview''info''tabview.js'); 
68                    YAHOO.example.app.getFeed(); 
69                } 
70            } 
71            //Is an editor present? 
72            if (YAHOO.example.app.editor) { 
73                if (ev.newValue.get('id') == 'composeView') { 
74                    YAHOO.log('Showing the ediitor''info''tabview.js'); 
75                    YAHOO.example.app.editor.show(); 
76                    YAHOO.example.app.editor.set('disabled'false); 
77                } else { 
78                    YAHOO.log('Hiding the editor''info''tabview.js'); 
79                    YAHOO.example.app.editor.hide(); 
80                    YAHOO.example.app.editor.set('disabled'true); 
81                } 
82            } 
83            //Resize to fit the new content 
84            YAHOO.example.app.layout.resize(); 
85        }); 
86        //Add the tabview to the center unit of the main layout 
87        var el = YAHOO.example.app.layout.getUnitByPosition('center').get('wrap'); 
88        YAHOO.example.app.tabView.appendTo(el); 
89 
90        //resize the TabView 
91        YAHOO.example.app.resizeTabView(); 
92        //Set the time on the home screen 
93        YAHOO.example.app.setTime(); 
94        //Setup the interval to update the time 
95        setInterval(YAHOO.example.app.setTime, 60000); 
96 
97         
98        YAHOO.log('Fetch the news feed''info''tabview.js'); 
99        YAHOO.util.Get.script('assets/js/news.js');  
100 
101 
102        //When inboxView is available, update the height.. 
103        Event.onAvailable('inboxView'function() { 
104            var t = YAHOO.example.app.tabView.get('tabs'); 
105            for (var i = 0; i < t.length; i++) { 
106                if (t[i].get('id') == 'inboxView') { 
107                    var el = t[i].get('contentEl'); 
108                    el.id = 'inboxHolder'
109                    YAHOO.log('Setting the height of the TabViews content parent''info''tabview.js'); 
110                    Dom.setStyle(el, 'height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
111                     
112                } 
113            } 
114 
115        }); 
116 
117})(); 
view plain | print | ?

news.js

This file makes several calls to Yahoo! Pipes with the Get utility in order to fetch the 4 news feeds for the home screen.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event, 
4        Sel = YAHOO.util.Selector, 
5        tt = null
6        pdata = {}; 
7        YAHOO.log('news.js file loaded..''info''news.js'); 
8        //Callback from the Pipes data call 
9        YAHOO.example.app.getWeather = function(r) { 
10            //Sometimes pipes fails.. 
11            if (r && r.value && r.value.items && r.value.items.length) { 
12                YAHOO.log('Inside weather callback from Pipes data''info''news.js'); 
13                var data = r.value.items[1].content; 
14                var img = data[0].content.substring(10); 
15                img = img.substring(0, (img.length - 3)); 
16                Sel.query('#weather em'''true).innerHTML = data[2].content; //Tempurature 
17                Dom.setStyle('weather''background-image''url( ' + img + ' )'); 
18                var url = data[8].content; 
19                url = url.substring(url.indexOf('http')); 
20                url = url.substring(0, url.indexOf('">')); 
21                YAHOO.log('Creating the Weather tooltip''info''news.js'); 
22                var tt = new YAHOO.widget.Tooltip('weatherTooltip', {  
23                    context: 'weather',  
24                    text: r.value.items[0].content + '<br><strong>Forecast:</strong><br>' + data[5].content + '<br>' + data[6].content 
25                }); 
26                 
27                Event.on('weather''click'function() { 
28                    window.open(url); 
29                }); 
30            } else { 
31                //Attempt to fetch it again 
32                window.setTimeout(function() { 
33                    YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=cnZFI_rR3BGvnn8h8ivLAg&_render=json&_callback=YAHOO.example.app.getWeather'); 
34                }, 5000); 
35            } 
36        }; 
37        YAHOO.log('Get the weather data from Pipes..''info''news.js'); 
38        YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=cnZFI_rR3BGvnn8h8ivLAg&_render=json&_callback=YAHOO.example.app.getWeather'); 
39        //Generic Filter Method 
40        var _filter = function(r, type) { 
41            pdata[type] = []; 
42            var data = r.value.items, 
43                str = ''
44                pdata[type][0] = data[0]; 
45                for (var i = 1; i < data.length; i++) { 
46                    pdata[type][i] = data[i]; 
47                    if (i <= 8) { 
48                        str += '<li><a href="' + data[i].link + '" target="_blank" class="' + type + '_' + i + '">' + data[i].title + '</a></li>'
49                    } 
50                } 
51                str = '<ul>' + str + '</ul>'
52                var d = data[0].description.replace('</a>''<h3><a href="' + data[0].link + '">' + data[0].title + '</a></h3>'); 
53                str =  d + str; 
54                str += '<p><a href="#' + type + '" class="moreNews">Click here for more news...</a></p>'
55            return str; 
56        }; 
57        YAHOO.example.app.getWorldNews = function(r) { 
58            YAHOO.log('Fetch the World News''info''news.js'); 
59            var str = _filter(r, 'world'); 
60            YAHOO.example.app.homeTabView.get('tabs')[1].set('content', str); 
61        }; 
62        YAHOO.example.app.getEntNews = function(r) { 
63            YAHOO.log('Fetch the Entertainment News''info''news.js'); 
64            var str = _filter(r, 'ent'); 
65            YAHOO.example.app.homeTabView.get('tabs')[2].set('content', str); 
66        }; 
67        YAHOO.example.app.getSportsNews = function(r) { 
68            YAHOO.log('Fetch the Sports News''info''news.js'); 
69            var str = _filter(r, 'sports'); 
70            YAHOO.example.app.homeTabView.get('tabs')[3].set('content', str); 
71        }; 
72        YAHOO.example.app.getTopNews = function(r) { 
73            YAHOO.log('Fetch the Top News''info''news.js'); 
74            var str = _filter(r, 'top'); 
75            YAHOO.example.app.homeTabView.get('tabs')[0].set('content', str); 
76            //Now that the Top news is loaded, load the other news in a timeout.. 
77            window.setTimeout(function() { 
78                YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=VE3fZVjT3BG0lA1gjtzu1g&newsfeed=world&_render=json&_callback=YAHOO.example.app.getWorldNews');  
79                YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=VE3fZVjT3BG0lA1gjtzu1g&newsfeed=entertainment&_render=json&_callback=YAHOO.example.app.getEntNews');  
80                YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=VE3fZVjT3BG0lA1gjtzu1g&newsfeed=sports&_render=json&_callback=YAHOO.example.app.getSportsNews');  
81            }, 0); 
82            YAHOO.log('Create a dynamic tooltip on the news articles''info''news.js'); 
83            tt = new YAHOO.widget.Tooltip('newsTip', { 
84                context: Sel.query('#news .yui-content'), 
85                text: 'Test'
86                width: '300px'
87                showDelay: 500, 
88                hideDelay: 500 
89            }); 
90            //Listen for the contextMouseOverEvent 
91            tt.contextMouseOverEvent.subscribe(function(cev, ev) { 
92                //Get the target of the mouseover event 
93                var tar = Event.getTarget(ev[1]); 
94                //It needs to be an A tag 
95                if (tar && tar.tagName && (tar.tagName.toLowerCase() == 'a')) { 
96                    //Does it have a className 
97                    if (tar.className) { 
98                        //Split the className on the _ (data placed above) 
99                        var tmp = tar.className.split('_'); 
100                        //Get the data from the pdata object 
101                        if (tmp.length != 2) { 
102                            return false
103                        } 
104                        var d = pdata[tmp[0]][tmp[1]]; 
105                        if (d) { 
106                            //It exists, parse it and set the Tooltip's text property with the descrition of the news article 
107                            var data = d.description.replace('</a>''</a><h3>' + d.title + '</h3>'); 
108                            tt.cfg.setProperty('text', data); 
109                        } else { 
110                            //Failed don't show the TT 
111                            return false
112                        } 
113                    } else { 
114                        //Failed don't show the TT 
115                        return false
116                    } 
117                } else { 
118                    //Failed don't show the TT 
119                    return false
120                } 
121            }); 
122            Event.on('news''click'function(ev) { 
123                var tar = Event.getTarget(ev); 
124                //Did we click on an a inside #news with the className of moreNews 
125                if (Sel.test(tar, '#news a.moreNews')) { 
126                    YAHOO.log('You clicked on a More News link''info''news.js'); 
127                    Event.stopEvent(ev); 
128                    //Get the news type 
129                    var type = tar.getAttribute('href', 2).split('#')[1]; 
130                    //get all of the tabs 
131                    var t = YAHOO.example.app.tabView.get('tabs'); 
132                    var tab = null
133                    for (var i = 0; i < t.length; i++) { 
134                        if (t[i].get('id') == 'newsView') { 
135                            YAHOO.log('We found an existing newsView tab''info''news.js'); 
136                            //setup a reference and change it to the active tab 
137                            tab = t[i]; 
138                            YAHOO.example.app.tabView.set('activeTab', tab); 
139                        } 
140                    } 
141                    //get the data from the pdata array (above) 
142                    var data = pdata[type], news = ''
143                    //Loop through it and create the news string 
144                    for (var n = 0; n < data.length; n++) { 
145                        news += '<div class="feedData">' + data[n].description.replace('</a>''<h3><a href="' + data[n].link + '">' + data[n].title + '</a></h3>') + '</div>'
146                    } 
147                    if (!tab) { 
148                        YAHOO.log('News Tab doesn\'t exist, create it', 'info', 'news.js'); 
149                        var nt = document.createElement('div'); 
150                        nt.id = 'newsEl'
151                        YAHOO.example.app.tabView._contentParent.appendChild(nt); 
152                        tab = new YAHOO.widget.Tab({ 
153                            label: '<span class="close"></span>News Reader'
154                            id: 'newsView'
155                            content: ''
156                            contentEl: nt, 
157                            active: true 
158                        }); 
159                        Dom.setStyle(nt, 'height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
160                        YAHOO.example.app.layout.on('resize'function() { 
161                            Dom.setStyle(nt, 'height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
162                        }); 
163                        YAHOO.log('Use YUILoader to fetch slider''info''news.js'); 
164                        var loader = new YAHOO.util.YUILoader({ 
165                                base: '../../build/'
166                                require: ['slider'], 
167                                onSuccess: function() { 
168                                    //Setup our default article size and font size 
169                                    var s = 500, f = 93; 
170                                    //Create the slider wrapper 
171                                    var d = document.createElement('div'); 
172                                    d.id = 'newsSlider'
173                                    //Inject the Slider HTML 
174                                    d.innerHTML = '<h3>Adjust font and article size</h3><div id="slider-bg" tabindex="-1" title="Adjust font and article size"><div id="slider-thumb"><img src="assets/css/thumb-n.gif"></div></div>'
175                                    //Give the Slider a little UI update when mousing over it.. 
176                                    Event.on(d, 'mouseover'function() { 
177                                        Dom.addClass(this'over'); 
178                                    }); 
179                                    Event.on(d, 'mouseout'function() { 
180                                        Dom.removeClass(this'over'); 
181                                    }); 
182                                    //Append the wrapper to the TabView's content parent 
183                                    YAHOO.example.app.tabView._contentParent.appendChild(d); 
184                                    YAHOO.log('Create the slider''info''news.js'); 
185                                    var slider = YAHOO.widget.Slider.getHorizSlider('slider-bg''slider-thumb', 0, 200); 
186                                    slider.subscribe('change'function(o) { 
187                                        //On change we will change the width and the font-size of the newsFeed div 
188                                        Dom.setStyle(Sel.query('.newsFeeds'), 'font-size', (f + (o / 3)) + '%'); 
189                                        Dom.setStyle(Sel.query('.newsFeeds'), 'width', (s + (o * 2)) + 'px'); 
190                                    }); 
191                                    //Hook into the tabView activeTabChange event to hide the slider when it is not being used. 
192                                    YAHOO.example.app.tabView.on('activeTabChange'function(ev) { 
193                                        //Tabs have changed 
194                                        if (ev.newValue.get('id') == 'newsView') { 
195                                            YAHOO.log('Show slider''info''news.js'); 
196                                            Dom.setStyle(d, 'display''block'); 
197                                        } else { 
198                                            YAHOO.log('Hide Slider''info''news.js'); 
199                                            Dom.setStyle(d, 'display''none'); 
200                                        } 
201                                    }); 
202                                     
203                                } 
204                            }); 
205                            //Inject the scripts 
206                            loader.insert({}, 'js'); 
207 
208                         
209                        YAHOO.log('Add the close button to the tab''info''news.js'); 
210                        Event.on(tab.get('labelEl').getElementsByTagName('span')[0], 'click'function(ev) { 
211                            Event.stopEvent(ev); 
212                            YAHOO.log('Close the news tab''info''news.js'); 
213                            YAHOO.example.app.tabView.set('activeTab', YAHOO.example.app.tabView.get('tabs')[0]); 
214                            YAHOO.example.app.tabView.removeTab(tab); 
215                            Dom.get('newsSlider').parentNode.removeChild(Dom.get('newsSlider')); 
216                        }); 
217                        YAHOO.log('Add the tab to the tabView''info''news.js'); 
218                        YAHOO.example.app.tabView.addTab(tab); 
219                    } 
220                    YAHOO.log('Set the content of the tab to the string news''info''news.js'); 
221                    tab.set('content''<div class="newsFeeds">' + news + '</div>'); 
222                } 
223            }); 
224        }; 
225         
226 
227        YAHOO.log('Create the tabview for the home screen''info''news.js'); 
228        YAHOO.example.app.homeTabView = new YAHOO.widget.TabView('news'); 
229        window.setTimeout(function() { 
230            YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=VE3fZVjT3BG0lA1gjtzu1g&newsfeed=topstories&_render=json&_callback=YAHOO.example.app.getTopNews');  
231        }, 0); 
232 
233})(); 
view plain | print | ?

inbox.js

This file uses YUILoader to fetch the DataTable and SimpleEditor (for the toolbar) modules to display the inbox. It also makes a call to a Yahoo! Pipe to gather the data to be populated by the DataTable.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event, 
4        layout2 = null
5        dataTable = null
6        emails = { 
7            account:"jenny@yahoo.com"
8            currStorage: 10, 
9            maxStorage: 200, 
10            messages: [] 
11        }, 
12        magicNum = 345; 
13         
14 
15        YAHOO.log('inbox.js file is loaded..''info''inbox.js'); 
16        var prettySize = function(size) { 
17            var gb = 1024 * 1024 * 1024, mb = 1024 * 1024, mysize; 
18            if (size > gb) { 
19                mysize = Math.round(size / gb) + " GB"
20            } else if (size > mb) { 
21                mysize = Math.round(size / mb) + " MB"
22            } else if ( size >= 1024 ) { 
23                mysize = Math.round(size / 1024) + " Kb"
24            } else { 
25                mysize = size + " b"
26            } 
27            return mysize; 
28        }; 
29         
30 
31        var initDataTable = function(h, w) { 
32            YAHOO.log('Creating the DataTable''info''inbox.js'); 
33            //Create the Column Definitions 
34            var myColumnDefs = [ 
35                {key:'', formatter:YAHOO.widget.DataTable.formatCheckbox, width: 10 }, // use the built-in checkbox formatter  
36                {key:"From", sortable:true, width: 125 }, 
37                {key:"Subject", sortable:true, width: (w - magicNum) }, 
38                {key:"Date",formatter:YAHOO.widget.DataTable.formatDate, sortable:true, width: 50 }, 
39                {key:"Size", sortable: false, width: 35 } 
40            ]; 
41            //Create the datasource 
42             
43            var myDataSource = new YAHOO.util.DataSource(emails); 
44            myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; 
45            myDataSource.responseSchema = { 
46                resultsList: 'messages'
47                fields: ["Date","To","From","Subject",'Size''Link''Body'
48            }; 
49            //Give the DT a custom Height 
50            var dtH = (h - 27 - YAHOO.example.app.inboxToolbarHeight); 
51            //Create the DT, setting scrollable to true and setting the height 
52            YAHOO.widget.DataTable.MSG_EMPTY = 'This folder contains no messages'
53            dataTable = new YAHOO.widget.DataTable("standard"
54                    myColumnDefs, myDataSource, { scrollable: true, height: dtH + 'px' }); 
55             
56            // Subscribe to events for row selection 
57            dataTable.subscribe("rowMouseoverEvent", dataTable.onEventHighlightRow); 
58            dataTable.subscribe("rowMouseoutEvent", dataTable.onEventUnhighlightRow); 
59            dataTable.subscribe("rowClickEvent", dataTable.onEventSelectRow); 
60            dataTable.subscribe("rowSelectEvent"function() { 
61                YAHOO.log('A row is selected, lets update the preview pane below the the data from the recordset''info''inbox.js'); 
62                var data = this.getRecordSet().getRecord(this.getSelectedRows()[0])._oData; 
63                var unit = YAHOO.widget.LayoutUnit.getLayoutUnitById('center2'); 
64                unit.set('header''Subject: ' + data.Subject + '<br>From: ' + data.From + '<br>To: ' + data.To); 
65                unit.set('body''<p>' + data.Body + '<p><p><a href="' + data.Link + '" target="_blank">See the full thread here.</a></p>'); 
66            }, dataTable, true); 
67 
68            YAHOO.example.app.dt = dataTable; 
69            YAHOO.example.app.inboxLoaded = true
70        }; 
71         
72        YAHOO.example.app.reloadData = function(empty) { 
73            if (empty === false) { 
74                var d = { 
75                    value: { 
76                        items: [] 
77                    } 
78                }; 
79                YAHOO.example.app.inboxDataReady(d); 
80            } else { 
81                YAHOO.log('Getting data from: ' + YAHOO.example.app.feedURL, 'info''inbox.js'); 
82                YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=kFM9h0vT3BGxGXVs8ivLAg&_render=json&_callback=YAHOO.example.app.inboxDataReady&feed=' + YAHOO.example.app.feedURL); 
83            } 
84        }; 
85 
86        //Pipes callback 
87        YAHOO.example.app.inboxDataReady = function(d) { 
88            YAHOO.log('Data returned from the Yahoo! Pipes callback''info''inbox.js'); 
89            var items = d.value.items; 
90            emails.messages = []; 
91            //Create the JS Array that we will feed to the DT  
92            for (var i = 0; i < items.length; i++) { 
93                emails.messages[emails.messages.length] = { 
94                    To: 'YUI User'
95                    From: items[i]['dc:creator'], 
96                    Subject: items[i]['y:title'], 
97                    Date: new Date(items[i]['y:published'].year, (parseInt(items[i]['y:published'].month, 10) - 1),items[i]['y:published'].day), 
98                    Body: items[i].description, 
99                    Link: items[i].link, 
100                    Size: prettySize((items[i].description.length * 1024)) 
101                }; 
102            } 
103            setTimeout(function() { 
104                //init the datatable 
105                if (!YAHOO.example.app.inboxLoaded) { 
106                    initDataTable(layout2.getSizes().top.h, layout2.getSizes().top.w); 
107                } else { 
108                    dataTable.getRecordSet().replaceRecords(emails.messages); 
109                    dataTable.render(); 
110                } 
111                //Setup some sizes 
112                layout2.getUnitByPosition('top')._setWidth(Dom.get('standard'), layout2.getSizes().top.w); 
113                layout2.getUnitByPosition('top')._setHeight(Dom.get('standard'), layout2.getSizes().top.h); 
114                YAHOO.log('Remove the loading class (icon) from the tabview..''info''inbox.js'); 
115                YAHOO.util.Dom.removeClass(YAHOO.example.app.tabView._tabParent, 'loading'); 
116                YAHOO.example.app.inboxLoading = false
117            }, 0); 
118        }; 
119 
120        YAHOO.log('Using loader to fetch datatable and editor (for the toolbar)''info''inbox.js'); 
121        var loader = new YAHOO.util.YUILoader({ 
122            base: '../../build/'
123            require: ['datatable''editor'], 
124            ignore: ['containercore'], 
125            onSuccess: function() { 
126                YAHOO.log('Inject some HTML for the content of this layout.''info''inbox.js'); 
127                var d = document.createElement('div'); 
128                d.innerHTML = '<div id="top2"><div id="inboxToolbar"></div><div id="standard"></div></div><div id="center2"><div class="yui-layout-bd"><div id="preview"><p><strong>Got your eye on one of those messages up there?</strong></p><p>To view your message down here in this handy Reading pane, just click on it.</p></div></div></div>'
129                document.body.appendChild(d); 
130                YAHOO.log('Creating a second Layout for the inbox and preview pane''info''inbox.js'); 
131                layout2 = new YAHOO.widget.Layout('inboxHolder', { 
132                    parent: YAHOO.example.app.layout, 
133                    units: [ 
134                        { position: 'top', height: '300px', maxHeight: 700, resize: true, id: 'top2', gutter: '0 0 15 0' }, 
135                        { position: 'center', id: 'center2', gutter: '0 0 1 0', scroll: true } 
136                    ] 
137                }); 
138                //before the resize, update the parent with the proper height 
139                layout2.on('beforeResize'function() { 
140                    Dom.setStyle('inboxHolder''height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
141                }); 
142                //On resize, resize the table and set the custom width on the Subject Column 
143                layout2.on('resize'function() { 
144                    if (dataTable) { 
145                        this.getUnitByPosition('top')._setWidth(Dom.get('standard'), this.getSizes().top.w); 
146                        this.getUnitByPosition('top')._setWidth(Dom.get('yui-dt0-table'), this.getSizes().top.w); 
147                        dataTable.set('height', (this.getSizes().top.h - 27 - YAHOO.example.app.inboxToolbarHeight) + 'px'); 
148                        dataTable.set('width', (this.getSizes().top.w) + 'px'); 
149                        dataTable.setColumnWidth(dataTable.getColumn('Subject'), (this.getSizes().top.w - magicNum)); 
150                        dataTable._syncColWidths(); 
151                        dataTable._syncScrollPadding(); 
152                    } 
153                }, layout2, true); 
154                layout2.on('render'function() { 
155                    YAHOO.log('On render create the inbox Toolbar''info''inbox.js'); 
156                    YAHOO.example.app.inboxToolbar = new YAHOO.widget.Toolbar('inboxToolbar', { 
157                        buttons: [ 
158                            { id: 'tb_delete', type: 'push', label: 'Delete', value: 'delete'}, 
159                            { type: 'separator' }, 
160                            { id: 'tb_reply', type: 'push', label: 'Reply', value: 'reply' }, 
161                            { id: 'tb_forward', type: 'push', label: 'Forward', value: 'forward' }, 
162                            { type: 'separator' }, 
163                            { id: 'tb_spam', type: 'push', label: 'Spam', value: 'spam' }, 
164                            { type: 'separator' }, 
165                            { id: 'tb_move', type: 'push', label: 'Move', value: 'move' }, 
166                            { id: 'tb_print', type: 'push', label: 'Print', value: 'print' } 
167                        ] 
168                    }); 
169                    //Show an alert message with the button they clicked 
170                    YAHOO.example.app.inboxToolbar.on('buttonClick'function(ev) { 
171                        var data = dataTable.getRecordSet().getRecord(dataTable.getSelectedRows()[0])._oData; 
172                        YAHOO.example.app.alert(ev.button.label + ': ' + data.Subject); 
173                    }); 
174                    //Grab it's height for later use 
175                    YAHOO.example.app.inboxToolbarHeight = Dom.get('inboxToolbar').clientHeight + 3; 
176                     
177                    window.setTimeout(function() { 
178                        YAHOO.log('Using get to call the Yahoo! Pipe for the inbox feed''info''inbox.js'); 
179                        YAHOO.util.Get.script('http:/'+'/pipes.yahoo.com/pipes/pipe.run?_id=kFM9h0vT3BGxGXVs8ivLAg&_render=json&_callback=YAHOO.example.app.inboxDataReady&feed=' + YAHOO.example.app.feedURL); 
180                    }, 0); 
181                }, layout2, true); 
182                layout2.render(); 
183                YAHOO.example.app.layout2 = layout2; 
184            } 
185        }); 
186        //Have loader insert only the JS files. 
187        loader.insert({}, 'js'); 
188})(); 
view plain | print | ?

buttons.js

This file handles the 3 main buttons on the screen: Check Mail, New Message and Search Web. It also handles the click for the New Message button which calls Get to load the editor.js file.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event; 
4 
5    YAHOO.log('buttons.js loaded''info''button.js'); 
6    //Create this loader instance and ask for the Button module 
7    var loader = new YAHOO.util.YUILoader({ 
8        base: '../../build/'
9        require: ['button'], 
10        ignore: ['containercore'], 
11        onSuccess: function() { 
12            YAHOO.log('Create the search button''info''button.js'); 
13            var searchButton = new YAHOO.widget.Button('search'); 
14            searchButton.on('click'function() { 
15                var q = Dom.get('query').value; 
16                if (q !== 'Search the Web..') { 
17                    window.open('http:/'+'/search.yahoo.com/search?p=' + q); 
18                } 
19            }); 
20            YAHOO.log('Create the Check Mail button''info''button.js'); 
21            var b1 = new YAHOO.widget.Button({ 
22                label: 'Check Mail'
23                id: 'checkButton'
24                container: Dom.get('check_buttons'
25            }); 
26            //inject a span for the icon 
27            var icon = document.createElement('span'); 
28            icon.className = 'icon'
29            b1.appendChild(icon); 
30            b1.on('click'function() { 
31                var t = YAHOO.example.app.tabView.get('tabs'); 
32                for (var i = 0; i < t.length; i++) { 
33                    if (t[i].get('id') == 'inboxView') { 
34                        YAHOO.example.app.tabView.set('activeTab', t[i]); 
35                    } 
36                } 
37            }); 
38            YAHOO.log('Create the New Message button''info''button.js'); 
39            var b2 = new YAHOO.widget.Button({ 
40                label: 'New'
41                id: 'newButton'
42                title: 'New Message'
43                container: Dom.get('check_buttons'
44            }); 
45            //inject a span for the icon 
46            var icon2 = document.createElement('span'); 
47            icon2.className = 'icon'
48            b2.appendChild(icon2); 
49            //Setup the click listener for the new message button 
50            b2.on('click'function() { 
51                if (!YAHOO.example.app.editor) { 
52                    YAHOO.log('No editor present, add the tab''info''button.js'); 
53                    var cTab = new YAHOO.widget.Tab({ 
54                        label: '<span class="close"></span><span class="icon"></span>New Message'
55                        id: 'composeView'
56                        active: true
57                        contentEl: Dom.get('composeViewEl'
58                    }); 
59                    //Add the close button to the tab 
60                    Event.on(cTab.get('labelEl').getElementsByTagName('span')[0], 'click'function(ev) { 
61                        YAHOO.log('Closing the Editor tab and destroying the Editor instance''info''button.js'); 
62                        Event.stopEvent(ev); 
63                        YAHOO.example.app.tabView.set('activeTab', YAHOO.example.app.tabView.get('tabs')[0]); 
64                        var cel = Dom.get('composeViewEl'); 
65                        YAHOO.example.app.destroyEditor(); 
66                        YAHOO.example.app.tabView.removeTab(cTab); 
67                        document.body.appendChild(cel); 
68 
69                    }); 
70                    YAHOO.example.app.tabView.addTab(cTab); 
71                    YAHOO.log('Load the Editor''info''button.js'); 
72                    window.setTimeout(function() { 
73                        var transactionObj = YAHOO.util.Get.script('assets/js/editor.js', { autopurge: true }); 
74                    }, 0); 
75                } else { 
76                    YAHOO.log('If there is an editor, then activate the proper tab''info''button.js'); 
77                    var t = YAHOO.example.app.tabView.get('tabs'); 
78                    for (var i = 0; i < t.length; i++) { 
79                        if (t[i].get('id') == 'composeView') { 
80                            YAHOO.example.app.tabView.set('activeTab', t[i]); 
81                        } 
82                    } 
83                } 
84            }); 
85            YAHOO.log('Add some functionality to the search box''info''button.js'); 
86            Event.on('query''click'function() { 
87                this.value = ''
88            }); 
89            Event.on('query''blur'function() { 
90                if (this.value === '') { 
91                    this.value = 'Search the Web..'
92                } 
93            }); 
94        } 
95    }); 
96    //Call insert, only choosing the JS files, so the skin doesn't over write my custom css 
97    loader.insert({}, 'js'); 
98})(); 
view plain | print | ?

editor.js

This file loads an Editor instance for use in the New Message tab.

1(function() { 
2    YAHOO.log('editor.js file loaded''info''editor.js'); 
3    YAHOO.log('Inject some HTML for the Compose Window''info''editor.js'); 
4    YAHOO.util.Dom.get('composeViewEl').innerHTML = '<div id="composeBarWrap"><div id="composeBar"></div><div id="composeAddr"><span><label>To:</label><input type="text" id="composeTo"></span><span><label>Subject:</label><input type="text"></span></div></div><text'+'area id="compose"></text'+'area><div id="autoTo"></div>'
5    //Use loader to load the Editor 
6    var loader = new YAHOO.util.YUILoader({ 
7        base: '../../build/'
8        require: ['autocomplete''editor'], 
9        ignore: ['containercore'], 
10        onSuccess: function() { 
11            YAHOO.log('Create a Toolbar above the To/From Fields''info''editor.js'); 
12            YAHOO.example.app.composeToolbar = new YAHOO.widget.Toolbar('composeBar', { 
13                buttons: [ 
14                    { id: 'tb_delete', type: 'push', label: 'Send', value: 'send'}, 
15                    { id: 'tb_reply', type: 'push', label: 'Attach', value: 'attach' }, 
16                    { id: 'tb_forward', type: 'push', label: 'Save Draft', value: 'savedraft' }, 
17                    { id: 'tb_forward', type: 'push', label: 'Spelling', value: 'spelling' }, 
18                    { id: 'tb_forward', type: 'push', label: 'Cancel', value: 'cancel' } 
19                ] 
20            }); 
21            //Show an alert message with the button they clicked             
22            YAHOO.example.app.composeToolbar.on('buttonClick'function(ev) { 
23                YAHOO.example.app.alert('You clicked: ' + ev.button.label); 
24            }); 
25             
26            //Editor startResize method - Disables the editor so we can drga over it. 
27            var editorStartResize = function() { 
28                YAHOO.example.app.editor.set('disabled'true); 
29            }; 
30            //Custom editor resize method 
31            var editorResize = function() { 
32                var h = YAHOO.util.Dom.get('composeViewEl').parentNode.clientHeight - (YAHOO.util.Dom.get('composeBarWrap').clientHeight); 
33                var th = YAHOO.example.app.editor.toolbar.get('element').clientHeight; 
34                var newH = (h - th); 
35                YAHOO.example.app.editor.set('height', newH + 'px'); 
36                YAHOO.example.app.editor.set('width', YAHOO.example.app.layout.getSizes().center.w + 'px'); 
37                YAHOO.example.app.editor.set('disabled'false); 
38            }; 
39            YAHOO.log('Create the Editor''info''editor.js'); 
40            var editor = new YAHOO.widget.Editor('compose', { 
41                width: (YAHOO.example.app.layout.getUnitByPosition('center').getSizes().body.w - 2) + 'px' 
42            }); 
43            editor.on('afterRender'function() { 
44                YAHOO.log('The editor is loaded, resize the editor to fit the layout''info''editor.js'); 
45                var h = YAHOO.util.Dom.get('composeViewEl').parentNode.clientHeight - (YAHOO.util.Dom.get('composeBarWrap').clientHeight); 
46                var th = this.toolbar.get('element').clientHeight; 
47                var newH = (h - th); 
48                this.set('height', newH + 'px'); 
49            }, editor, true); 
50            //Turn off the titlebar 
51            editor._defaultToolbar.titlebar = false
52            YAHOO.log('Render the editor''info''editor.js'); 
53            editor.render(); 
54            YAHOO.example.app.editor = editor; 
55 
56            //On resize and start resize handlers 
57            YAHOO.example.app.layout.on('startResize', editorStartResize); 
58            YAHOO.example.app.layout.on('resize', editorResize); 
59            //Method to destroy the editor. 
60            YAHOO.example.app.destroyEditor = function() { 
61                YAHOO.log('Destroying the Editor instance and HTML''info''editor.js'); 
62                YAHOO.example.app.layout.unsubscribe('startResize', editorStartResize); 
63                YAHOO.example.app.layout.unsubscribe('resize', editorResize); 
64                YAHOO.example.app.editor = null
65            }; 
66 
67            YAHOO.log('Setup the AutoComplete for the To Field''info''editor.js'); 
68            //Build some fake data.. 
69            var team = [ 
70                'Dav'
71                'Thomas'
72                'Eric'
73                'Matt'
74                'Adam'
75                'Lucas'
76                'Nate'
77                'Jenny'
78                'Satyen'
79                'Todd'
80                'George' 
81            ], data = []; 
82 
83            for (var i = 0; i < team.length; i++) { 
84                for (var s = 0; s < 5; s++) { 
85                    data[data.length] = team[i] + ' (' + s + ') [' + team[i].toLowerCase() + '@yui.com]'
86                } 
87            } 
88            // Instantiate JS Array DataSource 
89            var oACDS2 = new YAHOO.widget.DS_JSArray(data); 
90            YAHOO.log('Instantiate AutoComplete''info''editor.js'); 
91            var oAutoComp = new YAHOO.widget.AutoComplete('composeTo','autoTo', oACDS2); 
92            oAutoComp.prehighlightClassName = "yui-ac-prehighlight"
93            oAutoComp.typeAhead = true
94            oAutoComp.useIFrame = true
95        } 
96    }); 
97    //Have loader only insert the js files.. 
98    loader.insert({}, 'js'); 
99})(); 
view plain | print | ?

calendar.js

This file loads a Calendar instance and sets up the animation for showing and hiding via the calendar box in the lower left corner.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event; 
4     
5    YAHOO.log('calendar.js file loaded..''info''calendar.js'); 
6    //Create this loader instance and ask for the Calendar module 
7    var loader = new YAHOO.util.YUILoader({ 
8        base: '../../build/'
9        require: ['calendar'], 
10        onSuccess: function() { 
11            //Set a flag to show if the calendar is open or not 
12            YAHOO.example.app.calOpen = false
13            YAHOO.log('Create the new calendar''info''calendar.js'); 
14            YAHOO.example.app.calendar = new YAHOO.widget.Calendar('cal'); 
15            YAHOO.example.app.calendar.selectEvent.subscribe(function(ev, args) { 
16                var d = args[0][0]; 
17                YAHOO.example.app.alert('You selected this date: ' + d[1] + '/' + d[2] + '/' + d[0]); 
18            }); 
19             
20            YAHOO.example.app.calendar.render(); 
21             
22            //Method to toggle the animation of the calendar on and off 
23            YAHOO.example.app.toggleCal = function() { 
24                YAHOO.log('Toggle the calendar popup window''info''calendar.js'); 
25                //set the initial height to the offsetHeight of the calendar element 
26                var attr = { 
27                        height: { 
28                            to: Dom.get('cal').offsetHeight 
29                        } 
30                    }; 
31                //If it's open, set the height to 0 
32                if (YAHOO.example.app.calOpen) { 
33                    attr.height.to = 0; 
34                } 
35                //setup the animation instance 
36                var anim = new YAHOO.util.Anim('calContainer', attr); 
37                anim.animate(); 
38                //Toggle the flag 
39                YAHOO.example.app.calOpen = !YAHOO.example.app.calOpen; 
40            }; 
41            //Handle the click event on the cal box at the bottom 
42            Event.on('calBox''click'function(ev) { 
43                Event.stopEvent(ev); 
44                YAHOO.example.app.toggleCal(); 
45            }); 
46            YAHOO.log('Hijack the calendar link and make it toggle the calendar''info''calendar.js'); 
47            var c = YAHOO.util.Selector.query('#folder_list li.calendar a')[0]; 
48            if (c) { 
49                Event.on(c, 'click'function(ev) { 
50                    Event.stopEvent(ev); 
51                    YAHOO.example.app.toggleCal(); 
52                }); 
53            } 
54        } 
55    }); 
56    //Call insert, only choosing the JS files, so the skin doesn't over write my custom css 
57    loader.insert({}, 'js'); 
58})(); 
view plain | print | ?

logger.js

This file loads a Logger instance and places it in the right unit.

1(function() { 
2    var Dom = YAHOO.util.Dom, 
3        Event = YAHOO.util.Event; 
4 
5    //Create this loader instance and ask for the Button module 
6    var loader = new YAHOO.util.YUILoader({ 
7        base: '../../build/'
8        require: ['logger'], 
9        onSuccess: function() { 
10            var r = YAHOO.example.app.layout.getUnitByPosition('right'), 
11            w = r.getSizes().body.w, 
12            h = r.getSizes().body.h; 
13            var logger = new YAHOO.widget.LogReader(r.body, { 
14                logReaderEnabled: true
15                draggable: false
16                footerEnabled: false
17                newestOnTop: true
18                height: h + 'px'
19                width: w + 'px' 
20            }); 
21            YAHOO.example.app.layout.on('resize'function() { 
22                var r = YAHOO.example.app.layout.getUnitByPosition('right'), 
23                w = r.getSizes().body.w, 
24                h = r.getSizes().body.h; 
25                Dom.setStyle(YAHOO.util.Selector.query('div.yui-log-bd', r.body), 'height', h + 'px'); 
26            }); 
27        } 
28    }); 
29    //Call insert, only choosing the JS files, so the skin doesn't over write my custom css 
30    loader.insert({}, 'js'); 
31})(); 
view plain | print | ?

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings