YUI Library Home

YUI Library Examples: Layout Manager: Complex Application

Layout Manager: 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            //Use the DD shim on all DD objects 
39            YAHOO.util.DDM.useShim = true
40            //Load the global CSS file. 
41            YAHOO.log('Main files loaded..''info''main.js'); 
42            YAHOO.util.Get.css('assets/css/example1.css'); 
43 
44            YAHOO.log('Create the first layout on the page''info''main.js'); 
45            YAHOO.example.app.layout = new YAHOO.widget.Layout({ 
46                minWidth: 1000, 
47                units: [ 
48                    { position: 'top', height: 45, resize: false, body: 'top1' }, 
49                    { position: 'right', width: 300, body: '', header: 'Logger Console', collapse: true }, 
50                    { position: 'left', width: 190, resize: true, body: 'left1', gutter: '0 5 0 5px', minWidth: 190 }, 
51                    { position: 'center', gutter: '0 5px 0 2' } 
52                ] 
53            }); 
54            //On resize, resize the left and right column content 
55            YAHOO.example.app.layout.on('resize'function() { 
56                var l = this.getUnitByPosition('left'); 
57                var th = l.get('height') - YAHOO.util.Dom.get('folder_top').offsetHeight; 
58                var h = th - 4; //Borders around the 2 areas 
59                h = h - 9; //Padding between the 2 parts 
60                YAHOO.util.Dom.setStyle('folder_list''height', h + 'px'); 
61            }, YAHOO.example.app.layout, true); 
62            //On render, load tabview.js and button.js 
63            YAHOO.example.app.layout.on('render'function() { 
64                window.setTimeout(function() { 
65                    YAHOO.util.Get.script('assets/js/logger.js'); 
66                    YAHOO.util.Get.script('assets/js/tabview.js');  
67                    YAHOO.util.Get.script('assets/js/buttons.js'); 
68                    YAHOO.util.Get.script('assets/js/calendar.js'); 
69                }, 0); 
70                YAHOO.example.app.layout.getUnitByPosition('right').collapse(); 
71                setTimeout(function() { 
72                    YAHOO.util.Dom.setStyle(document.body, 'visibility''visible'); 
73                    YAHOO.example.app.layout.resize(); 
74                }, 1000); 
75            }); 
76            //Render the layout 
77            YAHOO.example.app.layout.render(); 
78            //Setup the click listeners on the folder list 
79            YAHOO.util.Event.on('folder_list''click'function(ev) { 
80                var tar = YAHOO.util.Event.getTarget(ev); 
81                if (tar.tagName.toLowerCase() != 'a') { 
82                    tar = null
83                } 
84                //Make sure we are a link in the list's  
85                if (tar && YAHOO.util.Selector.test(tar, '#folder_list ul li a')) { 
86                    //if the href is a '#' then select the proper tab and change it's label 
87                    if (tar && tar.getAttribute('href', 2) == '#') { 
88                        YAHOO.util.Dom.removeClass(YAHOO.util.Selector.query('#folder_list li'), 'selected'); 
89                        var feedName = tar.parentNode.className; 
90                        YAHOO.util.Dom.addClass(tar.parentNode, 'selected'); 
91                        YAHOO.util.Event.stopEvent(ev); 
92                        var title = tar.innerHTML; 
93                        var t = YAHOO.example.app.tabView.get('tabs'); 
94                        for (var i = 0; i < t.length; i++) { 
95                            if (t[i].get('id') == 'inboxView') { 
96                                t[i].set('label', title); 
97                                var u = false
98                                if (feedName.indexOf('-') != -1) { 
99                                    u = 'http:/'+'/rss.groups.yahoo.com/group/' + feedName + '/rss'
100                                } 
101                                if (feedName.indexOf('inbox') != -1) { 
102                                    u = 'http:/'+'/rss.groups.yahoo.com/group/ydn-javascript/rss'
103                                } 
104                                YAHOO.example.app.getFeed(u); 
105                                YAHOO.example.app.tabView.set('activeTab', t[i]); 
106                            } 
107                        } 
108                    } 
109                } 
110            }); 
111             
112            //Create a SimpleDialog used to mimic an OS dialog 
113            var panel = new YAHOO.widget.SimpleDialog('alert', { 
114                fixedcenter: true
115                visible: false
116                modal: true
117                width: '300px'
118                constraintoviewport: true,  
119                icon: YAHOO.widget.SimpleDialog.ICON_WARN, 
120                buttons: [ 
121                    { text: 'OK', handler: function() { 
122                        panel.hide(); 
123                    }, isDefault: true } 
124                ] 
125            }); 
126            //Set the header 
127            panel.setHeader('Alert'); 
128            //Give the body something to render with 
129            panel.setBody('Notta'); 
130            //Render the Dialog to the body 
131            panel.render(document.body); 
132 
133            //Create a namepaced alert method 
134            YAHOO.example.app.alert = function(str) { 
135                YAHOO.log('Firing panel setBody with string: ' + str, 'info''main.js'); 
136                //Set the body to the string passed 
137                panel.setBody(str); 
138                //Set an icon 
139                panel.cfg.setProperty('icon', YAHOO.widget.SimpleDialog.ICON_WARN); 
140                //Bring the dialog to the top 
141                panel.bringToTop(); 
142                //Show it 
143                panel.show(); 
144            }; 
145 
146            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.'); 
147        } 
148    }); 
149    loader.insert(); 
150})(); 
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.util.Dom.get('calDateStr').innerHTML = m + '/' + dy + '/' + d.getFullYear(); 
31            YAHOO.log('Setting the time/date string to: ' + dt, 'info''tabview.js'); 
32        }; 
33         
34        //Method to Resize the tabview 
35        YAHOO.example.app.resizeTabView = function() { 
36            var ul = YAHOO.example.app.tabView._tabParent.offsetHeight; 
37            Dom.setStyle(YAHOO.example.app.tabView._contentParent, 'height', ((YAHOO.example.app.layout.getSizes().center.h - ul) - 2) + 'px'); 
38        }; 
39         
40        //Listen for the layout resize and call the method 
41        YAHOO.example.app.layout.on('resize', YAHOO.example.app.resizeTabView); 
42        //Create the tabView 
43        YAHOO.log('Creating the main TabView instance''info''tabview.js'); 
44        YAHOO.example.app.tabView = new YAHOO.widget.TabView(); 
45        //Create the Home tab        
46        YAHOO.example.app.tabView.addTab( new YAHOO.widget.Tab({ 
47            //Inject a span for the icon 
48            label: '<span></span>Home'
49            id: 'homeView'
50            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>'
51            active: true 
52        })); 
53        //Create the Inbox tab 
54        YAHOO.example.app.tabView.addTab( new YAHOO.widget.Tab({ 
55            //Inject a span for the icon 
56            label: '<span></span>Inbox'
57            id: 'inboxView'
58            content: '' 
59 
60        })); 
61        YAHOO.example.app.tabView.on('activeTabChange'function(ev) { 
62            //Tabs have changed 
63            if (ev.newValue.get('id') == 'inboxView') { 
64                //inbox tab was selected 
65                if (!YAHOO.example.app.inboxLoaded && !YAHOO.example.app.inboxLoading) { 
66                    YAHOO.log('Fetching the inbox.js file..''info''tabview.js'); 
67                    YAHOO.log('Inbox is not loaded yet, use Get to fetch it''info''tabview.js'); 
68                    YAHOO.log('Adding loading class to tabview''info''tabview.js'); 
69                    YAHOO.example.app.getFeed(); 
70                } 
71            } 
72            //Is an editor present? 
73            if (YAHOO.example.app.editor) { 
74                if (ev.newValue.get('id') == 'composeView') { 
75                    YAHOO.log('Showing the ediitor''info''tabview.js'); 
76                    YAHOO.example.app.editor.show(); 
77                    YAHOO.example.app.editor.set('disabled'false); 
78                } else { 
79                    YAHOO.log('Hiding the editor''info''tabview.js'); 
80                    YAHOO.example.app.editor.hide(); 
81                    YAHOO.example.app.editor.set('disabled'true); 
82                } 
83            } 
84            //Resize to fit the new content 
85            YAHOO.example.app.layout.resize(); 
86        }); 
87        //Add the tabview to the center unit of the main layout 
88        var el = YAHOO.example.app.layout.getUnitByPosition('center').get('wrap'); 
89        YAHOO.example.app.tabView.appendTo(el); 
90 
91        //resize the TabView 
92        YAHOO.example.app.resizeTabView(); 
93        //Set the time on the home screen 
94        YAHOO.example.app.setTime(); 
95        //Setup the interval to update the time 
96        setInterval(YAHOO.example.app.setTime, 60000); 
97 
98         
99        YAHOO.log('Fetch the news feed''info''tabview.js'); 
100        YAHOO.util.Get.script('assets/js/news.js');  
101 
102 
103        //When inboxView is available, update the height.. 
104        Event.onAvailable('inboxView'function() { 
105            var t = YAHOO.example.app.tabView.get('tabs'); 
106            for (var i = 0; i < t.length; i++) { 
107                if (t[i].get('id') == 'inboxView') { 
108                    var el = t[i].get('contentEl'); 
109                    el.id = 'inboxHolder'
110                    YAHOO.log('Setting the height of the TabViews content parent''info''tabview.js'); 
111                    Dom.setStyle(el, 'height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
112                     
113                } 
114            } 
115 
116        }); 
117 
118})(); 
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 
52            //Create the DT, setting scrollable to true and setting the height 
53            YAHOO.widget.DataTable.MSG_EMPTY = 'This folder contains no messages'
54 
55            dataTable = new YAHOO.widget.DataTable("standard"
56                    myColumnDefs, myDataSource, { scrollable: true, height: dtH + 'px', width: w + 'px' }); 
57             
58             
59            // Subscribe to events for row selection 
60            dataTable.subscribe("rowMouseoverEvent", dataTable.onEventHighlightRow); 
61            dataTable.subscribe("rowMouseoutEvent", dataTable.onEventUnhighlightRow); 
62            dataTable.subscribe("rowClickEvent", dataTable.onEventSelectRow); 
63            dataTable.subscribe("rowSelectEvent"function() { 
64                YAHOO.log('A row is selected, lets update the preview pane below the the data from the recordset''info''inbox.js'); 
65                var data = this.getRecordSet().getRecord(this.getSelectedRows()[0])._oData; 
66                var unit = YAHOO.widget.LayoutUnit.getLayoutUnitById('center2'); 
67                unit.set('header''Subject: ' + data.Subject + '<br>From: ' + data.From + '<br>To: ' + data.To); 
68                unit.set('body''<p>' + data.Body + '<p><p><a href="' + data.Link + '" target="_blank">See the full thread here.</a></p>'); 
69            }, dataTable, true); 
70 
71            YAHOO.example.app.dt = dataTable; 
72            YAHOO.example.app.inboxLoaded = true
73        }; 
74         
75        YAHOO.example.app.reloadData = function(empty) { 
76            if (empty === false) { 
77                var d = { 
78                    value: { 
79                        items: [] 
80                    } 
81                }; 
82                YAHOO.example.app.inboxDataReady(d); 
83            } else { 
84                YAHOO.log('Getting data from: ' + YAHOO.example.app.feedURL, 'info''inbox.js'); 
85                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); 
86            } 
87        }; 
88 
89        //Pipes callback 
90        YAHOO.example.app.inboxDataReady = function(d) { 
91            YAHOO.log('Data returned from the Yahoo! Pipes callback''info''inbox.js'); 
92            var items = d.value.items; 
93            emails.messages = []; 
94            //Create the JS Array that we will feed to the DT  
95            for (var i = 0; i < items.length; i++) { 
96                emails.messages[emails.messages.length] = { 
97                    To: 'YUI User'
98                    From: items[i]['dc:creator'], 
99                    Subject: items[i]['y:title'], 
100                    Date: new Date(items[i]['y:published'].year, (parseInt(items[i]['y:published'].month, 10) - 1),items[i]['y:published'].day), 
101                    Body: items[i].description, 
102                    Link: items[i].link, 
103                    Size: prettySize((items[i].description.length * 1024)) 
104                }; 
105            } 
106            setTimeout(function() { 
107                //init the datatable 
108                if (!YAHOO.example.app.inboxLoaded) { 
109                    initDataTable(layout2.getSizes().top.h, layout2.getSizes().top.w); 
110                } else { 
111                    dataTable.getRecordSet().replaceRecords(emails.messages); 
112                    dataTable.render(); 
113                } 
114                //Setup some sizes 
115                layout2.getUnitByPosition('top')._setWidth(Dom.get('standard'), layout2.getSizes().top.w); 
116                layout2.getUnitByPosition('top')._setHeight(Dom.get('standard'), layout2.getSizes().top.h); 
117                YAHOO.log('Remove the loading class (icon) from the tabview..''info''inbox.js'); 
118                YAHOO.util.Dom.removeClass(YAHOO.example.app.tabView._tabParent, 'loading'); 
119                YAHOO.example.app.inboxLoading = false
120            }, 1000); 
121        }; 
122 
123        YAHOO.log('Using loader to fetch datatable and editor (for the toolbar)''info''inbox.js'); 
124        var loader = new YAHOO.util.YUILoader({ 
125            base: '../../build/'
126            require: ['datatable''editor'], 
127            ignore: ['containercore'], 
128            onSuccess: function() { 
129                YAHOO.log('Inject some HTML for the content of this layout.''info''inbox.js'); 
130                var d = document.createElement('div'); 
131                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>'
132                document.body.appendChild(d); 
133                YAHOO.log('Creating a second Layout for the inbox and preview pane''info''inbox.js'); 
134                layout2 = new YAHOO.widget.Layout('inboxHolder', { 
135                    parent: YAHOO.example.app.layout, 
136                    units: [ 
137                        { position: 'top', height: '300px', maxHeight: 700, resize: true, id: 'top2', gutter: '0 0 15 0' }, 
138                        { position: 'center', id: 'center2', gutter: '0 0 1 0', scroll: true } 
139                    ] 
140                }); 
141                //before the resize, update the parent with the proper height 
142                layout2.on('beforeResize'function() { 
143                    Dom.setStyle('inboxHolder''height', Dom.getStyle(YAHOO.example.app.tabView._contentParent, 'height')); 
144                }); 
145                //On resize, resize the table and set the custom width on the Subject Column 
146                layout2.on('resize'function() { 
147                    if (dataTable) { 
148                        this.getUnitByPosition('top')._setWidth(Dom.get('standard'), this.getSizes().top.w); 
149                        this.getUnitByPosition('top')._setWidth(Dom.get('yui-dt0-table'), this.getSizes().top.w); 
150                        dataTable.set('height', (this.getSizes().top.h - 27 - YAHOO.example.app.inboxToolbarHeight) + 'px'); 
151                        dataTable.set('width', (this.getSizes().top.w) + 'px'); 
152                        dataTable.setColumnWidth(dataTable.getColumn('Subject'), (this.getSizes().top.w - magicNum)); 
153                        dataTable._syncColWidths(); 
154                    } 
155                }, layout2, true); 
156                layout2.on('render'function() { 
157                    YAHOO.log('On render create the inbox Toolbar''info''inbox.js'); 
158                    YAHOO.example.app.inboxToolbar = new YAHOO.widget.Toolbar('inboxToolbar', { 
159                        buttons: [ 
160                            { id: 'tb_delete', type: 'push', label: 'Delete', value: 'delete'}, 
161                            { type: 'separator' }, 
162                            { id: 'tb_reply', type: 'push', label: 'Reply', value: 'reply' }, 
163                            { id: 'tb_forward', type: 'push', label: 'Forward', value: 'forward' }, 
164                            { type: 'separator' }, 
165                            { id: 'tb_spam', type: 'push', label: 'Spam', value: 'spam' }, 
166                            { type: 'separator' }, 
167                            { id: 'tb_move', type: 'push', label: 'Move', value: 'move' }, 
168                            { id: 'tb_print', type: 'push', label: 'Print', value: 'print' } 
169                        ] 
170                    }); 
171                    //Show an alert message with the button they clicked 
172                    YAHOO.example.app.inboxToolbar.on('buttonClick'function(ev) { 
173                        var data = dataTable.getRecordSet().getRecord(dataTable.getSelectedRows()[0])._oData; 
174                        YAHOO.example.app.alert(ev.button.label + ': ' + data.Subject); 
175                    }); 
176                    //Grab it's height for later use 
177                    YAHOO.example.app.inboxToolbarHeight = Dom.get('inboxToolbar').clientHeight + 3; 
178                     
179                    window.setTimeout(function() { 
180                        YAHOO.log('Using get to call the Yahoo! Pipe for the inbox feed''info''inbox.js'); 
181                        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); 
182                    }, 0); 
183                }, layout2, true); 
184                layout2.render(); 
185                YAHOO.example.app.layout2 = layout2; 
186            } 
187        }); 
188        //Have loader insert only the JS files. 
189        loader.insert({}, 'js'); 
190})(); 
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            //Custom editor resize method 
27            var editorResize = function() { 
28                var h = YAHOO.util.Dom.get('composeViewEl').parentNode.clientHeight - (YAHOO.util.Dom.get('composeBarWrap').clientHeight); 
29                var th = YAHOO.example.app.editor.toolbar.get('element').clientHeight; 
30                var newH = (h - th); 
31                YAHOO.example.app.editor.set('height', newH + 'px'); 
32                YAHOO.example.app.editor.set('width', YAHOO.example.app.layout.getSizes().center.w + 'px'); 
33            }; 
34            YAHOO.log('Create the Editor''info''editor.js'); 
35            var editor = new YAHOO.widget.Editor('compose', { 
36                width: (YAHOO.example.app.layout.getUnitByPosition('center').getSizes().body.w - 2) + 'px' 
37            }); 
38            editor.on('afterRender'function() { 
39                YAHOO.log('The editor is loaded, resize the editor to fit the layout''info''editor.js'); 
40                var h = YAHOO.util.Dom.get('composeViewEl').parentNode.clientHeight - (YAHOO.util.Dom.get('composeBarWrap').clientHeight); 
41                var th = this.toolbar.get('element').clientHeight; 
42                var newH = (h - th); 
43                this.set('height', newH + 'px'); 
44            }, editor, true); 
45            //Turn off the titlebar 
46            editor._defaultToolbar.titlebar = false
47            YAHOO.log('Render the editor''info''editor.js'); 
48            editor.render(); 
49            YAHOO.example.app.editor = editor; 
50 
51            //On resize and start resize handlers 
52            YAHOO.example.app.layout.on('resize', editorResize); 
53            //Method to destroy the editor. 
54            YAHOO.example.app.destroyEditor = function() { 
55                YAHOO.log('Destroying the Editor instance and HTML''info''editor.js'); 
56                YAHOO.example.app.layout.unsubscribe('resize', editorResize); 
57                YAHOO.example.app.editor = null
58            }; 
59 
60            YAHOO.log('Setup the AutoComplete for the To Field''info''editor.js'); 
61            //Build some fake data.. 
62            var team = [ 
63                'Dav'
64                'Thomas'
65                'Eric'
66                'Matt'
67                'Adam'
68                'Lucas'
69                'Nate'
70                'Jenny'
71                'Satyen'
72                'Todd'
73                'George' 
74            ], data = []; 
75 
76            for (var i = 0; i < team.length; i++) { 
77                for (var s = 0; s < 5; s++) { 
78                    data[data.length] = team[i] + ' (' + s + ') [' + team[i].toLowerCase() + '@yui.com]'
79                } 
80            } 
81            // Instantiate JS Array DataSource 
82            var oACDS2 = new YAHOO.widget.DS_JSArray(data); 
83            YAHOO.log('Instantiate AutoComplete''info''editor.js'); 
84            var oAutoComp = new YAHOO.widget.AutoComplete('composeTo','autoTo', oACDS2); 
85            oAutoComp.prehighlightClassName = "yui-ac-prehighlight"
86            oAutoComp.typeAhead = true
87            oAutoComp.useIFrame = true
88        } 
89    }); 
90    //Have loader only insert the js files.. 
91    loader.insert({}, 'js'); 
92})(); 
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 
14            var logger = new YAHOO.widget.LogReader(r.body, { 
15                logReaderEnabled: true
16                draggable: false
17                newestOnTop: true
18                height: h + 'px'
19                width: w + 'px' 
20            }); 
21 
22             
23            r.on('collapse'function() { 
24                logger.pause(); 
25            }); 
26            r.on('expand'function() { 
27                logger.resume(); 
28            }); 
29 
30            YAHOO.example.app.layout.on('resize'function() { 
31                var r = YAHOO.example.app.layout.getUnitByPosition('right'), 
32                w = r.getSizes().body.w, 
33                h = r.getSizes().body.h; 
34                Dom.setStyle(YAHOO.util.Selector.query('div.yui-log-bd', r.body), 'height', h + 'px'); 
35            }); 
36        } 
37    }); 
38    //Call insert, only choosing the JS files, so the skin doesn't over write my custom css 
39    loader.insert({}, 'js'); 
40})(); 
view plain | print | ?

Configuration for This Example

You can load the necessary JavaScript and CSS for this example from Yahoo's servers. Click here to load the YUI Dependency Configurator with all of this example's dependencies preconfigured.

Copyright © 2011 Yahoo! Inc. All rights reserved.

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