Skip to content

Instantly share code, notes, and snippets.

@benbonnet
Created April 18, 2009 14:41
Show Gist options
  • Save benbonnet/97631 to your computer and use it in GitHub Desktop.
Save benbonnet/97631 to your computer and use it in GitHub Desktop.
def stuff
current_site = Site.find params[:id]
session[:site] = current_site
Site.update current_site, :default => 1
back_sites = Site.find_by_sql("SELECT sites.* FROM sites WHERE id != #{current_site.id} AND user_id = #{@user.id}")
back_sites.each do |s|
Site.update s, :default => 0
end
render :nothing => :true
end
<script type="text/javascript">
function delayedRedirect(leader){
window.location = "/veeo/site/" + leader
}
function morphing(leader){
<% sites.each do |s| %>
if(<%= s.id %> == leader){
new Effect.Morph('cursor_<%= s.id %>', {style: {marginLeft: '55px'}, duration: 0.5});
$('cursor_zone_<%= s.id %>').setStyle({backgroundImage:'url(/images/veeo/cursor/bg_on.png)'});
} else {
new Effect.Morph('cursor_<%= s.id %>', {style: {marginLeft: '0px'}, duration: 0.5});
$('cursor_zone_<%= s.id %>').setStyle({backgroundImage:'url(/images/veeo/cursor/bg_off.png)'});
}
<% end %>
setTimeout('delayedRedirect(' + leader + ')', 2000);
}
</script>
<% sites.each do |s| %>
<li>
<%
if @site.id == s.id
bg_img = "bg_on"
cursor_style = "position: absolute; margin-left: 55px"
else
bg_img = "bg_off"
cursor_style = "position: absolute; margin-left: 0px"
end
%>
<span style="cursor: pointer; float: right; width: 94px; height: 27px; display: block; background: url(/images/veeo/cursor/<%= bg_img %>.png); margin-top: -5px" id="cursor_zone_<%= s.id %>" onclick="<%= remote_function :url => {:controller => "veeo", :action => "activate_site", :id => s.id}, :success => "morphing(#{s.id})" %>" class="temp_site">
<%= image_tag("/images/veeo/cursor/cursor.png", :style => "#{cursor_style}", :id => "cursor_#{s.id}") %>
</span>
<%= link_to s.nom, :action => "site", :id => s.id %>
</li>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment