Created
April 10, 2011 20:01
-
-
Save walterdavis/912677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rightpanel = $('rightpanel'); | |
var leftpanel = $('leftpanel'); | |
var stories = rightpanel.select('h3').each(function(elm){ | |
elm['link'] = elm.down('a').href; | |
elm['description'] = elm.next('p').insert( | |
' <a href="' + this.link + '">read more</a>' | |
).remove(); | |
elm.update(elm.down('a').innerHTML).setStyle('cursor:pointer');; | |
elm.remove(); | |
}); | |
stories.each(function(story){ | |
leftpanel.insert(story); | |
story.observe('click',function(evt){ | |
rightpanel.update(this.clone(true)).insert( | |
this.description | |
); | |
stories.invoke('removeClassName','active'); | |
story.addClassName('active'); | |
}); | |
}); | |
//choose random story to feature first | |
var story = stories[Math.floor(Math.random() * stories.length)]; | |
rightpanel.update(story.clone(true)).insert( | |
story.description | |
); | |
story.addClassName('active'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment