Created
April 20, 2012 07:26
-
-
Save jmlweb/2426836 to your computer and use it in GitHub Desktop.
Coffeescript + jQuery basic use
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
BITOKE = { | |
external_links: -> | |
$('a[rel=external]', '.main_content').click -> | |
window.open($(this).attr('href')) | |
return false | |
lava_lamp: -> | |
#move($('a.current', '.main_menu'), 0) | |
_a_list = $('a', '.main_menu') | |
lava_lamp_utils = { | |
assign_events: -> | |
#assign events | |
_old_a = null | |
_a_list | |
.mouseover -> | |
_a = $(this) | |
if(_a != _old_a) | |
lava_lamp_utils.move(_a, 400) | |
_old_a = _a | |
return false | |
.mouseout -> | |
lava_lamp_utils.move($('a.current', '.main_menu'), 400) | |
return false | |
move: (_a, _duration)-> | |
if(_a.hasClass('logo')) | |
_child = _a.children('img') | |
else | |
_child = _a.children('span') | |
_position = _child.position() | |
_width = _child.width() | |
$('span', '.lava_lamp').stop().animate({ | |
left: _position.left - 49, | |
width: _width | |
}, 400) | |
} | |
lava_lamp_utils.assign_events() | |
lava_lamp_utils.move($('a.current', '.main_menu'), 0) | |
$('span', '.lava_lamp').fadeIn(200) | |
examples_popup: -> | |
BITOKE.lang = $('html').attr('lang') | |
if BITOKE.lang is 'en' | |
BITOKE.pag_current = 'image {current} of {total}' | |
else if BITOKE.lang is 'ca' | |
BITOKE.pag_current = 'imatge {current} de {total}' | |
else | |
BITOKE.pag_current = 'imagen {current} de {total}' | |
$('article', '#examples').each -> | |
_this = $(this) | |
$('a[rel!=view_more]', _this).colorbox({ | |
opacity: 0.7, | |
rel: $('a[rel!=view_more]', _this).attr('rel'), | |
current: BITOKE.pag_current | |
}) | |
$('a[rel=view_more]', _this).click -> | |
$('a[rel!=view_more]', _this).eq(0).click() | |
return false | |
} | |
$ -> | |
BITOKE.external_links() | |
BITOKE.lava_lamp() | |
if $('article', '#examples').length | |
BITOKE.examples_popup() | |
return false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment