Skip to content

Instantly share code, notes, and snippets.

@andrellima
Created April 5, 2011 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrellima/902973 to your computer and use it in GitHub Desktop.
Save andrellima/902973 to your computer and use it in GitHub Desktop.
var aTimer;
var bTimer;
var current_page;
// JavaScript Document
/*
Monta o layout
*/
function maximize() {
window.moveTo(1,1);
if (screen.availWidth >= 1920 && screen.availHeight >= 900) {
window.resizeTo(screen.availWidth, screen.availHeight);
} else {
window.resizeTo(1920, 900);
}
}
maximize();
function dontMaximize() {
if (screen.availWidth >= 1920 && screen.availHeight >= 900) {
window.resizeTo(1920, 900);
}
}
function load_new_screen() {
$('barra_azul_topo').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_topo').style.left = '0px';
$('barra_azul_topo').style.height = '34px';
$('barra_azul_topo').style.top = '34px';
$('barra_azul_topo_sub_navegacao').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_topo_sub_navegacao').style.left = '0px';
$('barra_azul_topo_sub_navegacao').style.height = '22px';
$('barra_azul_topo_sub_navegacao').style.top = '70px';
$('barra_azul_topo_link').style.width = (document.viewport.getWidth() - 125) + 'px';
$('barra_azul_topo_link').style.left = '28px';
$('barra_azul_topo_link').style.top = '40px';
$('player_musica').style.right = '43px';
$('player_musica').style.bottom = '33px';
$('barra_azul_rodape').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_rodape').style.left = '0px';
$('barra_azul_rodape').style.bottom = '0px';
$('texto_rodape').style.width = '265px';
$('texto_rodape').style.left = '43px';
$('texto_rodape').style.bottom = '10px';
}
function draw_layout() {
$('barra_azul_topo').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_topo').style.left = '0px';
$('barra_azul_topo').style.height = '34px';
$('barra_azul_topo').style.top = '34px';
$('barra_azul_topo_sub_navegacao').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_topo_sub_navegacao').style.left = '0px';
$('barra_azul_topo_sub_navegacao').style.height = '22px';
$('barra_azul_topo_sub_navegacao').style.top = '70px';
$('barra_azul_topo_link').style.width = (document.viewport.getWidth() - 125) + 'px';
$('barra_azul_topo_link').style.left = '28px';
$('barra_azul_topo_link').style.top = '40px';
$('player_musica').style.right = '43px';
$('player_musica').style.bottom = '33px';
$('barra_azul_rodape').style.width = document.viewport.getWidth() + 'px';
$('barra_azul_rodape').style.left = '0px';
$('barra_azul_rodape').style.bottom = '0px';
$('texto_rodape').style.width = '265px';
$('texto_rodape').style.left = '43px';
$('texto_rodape').style.bottom = '10px';
links = $$('.sub_menu_produtos');
links.each(function(s) {
s.style.left = '120px';
s.style.display = 'none';
});
links = $$('.sub_menu_produtos_fem');
links.each(function(s) {
s.style.left = '120px';
s.style.display = 'none';
});
links = $$('.sub_menu_catalogo');
links.each(function(s) {
s.style.left = '120px';
s.style.display = 'none';
});
links = $$('.sub_menu_catalogo_fem');
links.each(function(s) {
s.style.left = '120px';
s.style.display = 'none';
});
$('home').style.width = document.viewport.getWidth() + 'px';
$('home').style.height = document.viewport.getHeight() + 'px';
}
function drawn_content_width() {
$('produto_container').style.width = (document.viewport.getWidth()-250) + 'px';
$('produtos').style.width = document.viewport.getWidth() + 'px';
$('produtos_barra').style.width = document.viewport.getWidth() + 'px';
$('catalogo_container').style.width = (document.viewport.getWidth()-250) + 'px';
$('catalogo').style.width = document.viewport.getWidth() + 'px';
$('catalogo_barra').style.width = document.viewport.getWidth() + 'px';
$('load_produtos').style.left = ((document.viewport.getWidth()/2)-300) + 'px';
$('load_colecao').style.left = ((document.viewport.getWidth()/2)-300) + 'px';
franquias_largura('franquias_expansao');
franquias_largura('franquias_cadastro');
franquias_largura('franquias_historico');
franquias_largura('franquias_perguntas');
franquias_largura('franquias_lei');
franquias_largura('colecao_riviera');
franquias_largura('colecao_ficha_tecnica');
franquias_largura('franquias_lojas');
franquias_largura('franquias_contato');
franquias_largura('franquias_empresa');
campanha_largura('campanha_');
campanha_largura('campanha_making_of_');
campanha_largura('campanha_papeis_de_parede_');
campanha_largura('campanha_video_');
$$('#produto_detalhe').each(function(p) {
p.style.width = (document.viewport.getWidth()-780) + 'px';
});
$$('#produto_detalhe_table').each(function(p) {
p.style.width = '500px';
});
$$('#produto_detalhe_barra').each(function(p) {
p.style.width = (document.viewport.getWidth()-700) + 'px';
});
$$('#catalogo_detalhe').each(function(p) {
p.style.width = (document.viewport.getWidth()-780) + 'px';
});
$$('#catalogo_detalhe_table').each(function(p) {
p.style.width = '500px';
});
$$('#catalogo_detalhe_barra').each(function(p) {
p.style.width = (document.viewport.getWidth()-700) + 'px';
});
var aThumb1 = document.getElementById("thumb1");
var scrolldiv1 = document.getElementById("text_lojas");
Drag.init(aThumb1, null, 0, 0, 10, 305);
aThumb1.onDrag = function(x, y) {
scrolldiv1.style.top=y * 2 * (-1) + "px";
}
var aThumb2 = document.getElementById("thumb2");
var scrolldiv2 = document.getElementById("ajax_form_franquia");
Drag.init(aThumb2, null, 0, 0, 10, 305);
aThumb2.onDrag = function(x, y) {
scrolldiv2.style.top=y * (-1) +"px";
}
var aThumb_pergunta = document.getElementById("thumb_pegunta");
var scrolldiv_pergunta = document.getElementById("text_pergunta");
Drag.init(aThumb_pergunta, null, 0, 0, 10, 305);
aThumb_pergunta.onDrag = function(x, y) {
scrolldiv_pergunta.style.top=y * 5.5 * (-1) +"px";
}
var aThumb_plano = document.getElementById("thumb_plano");
var scrolldiv_plano = document.getElementById("text_plano");
Drag.init(aThumb_plano, null, 0, 0, 10, 305);
aThumb_plano.onDrag = function(x, y) {
scrolldiv_plano.style.top=y * (-1) +"px";
}
var aThumb_sobre = document.getElementById("thumb_sobre");
var scrolldiv_sobre = document.getElementById("text_sobre");
Drag.init(aThumb_sobre, null, 0, 0, 10, 305);
aThumb_sobre.onDrag = function(x, y) {
scrolldiv_sobre.style.top=y * 3 * (-1) +"px";
}
var aThumb_riviera = document.getElementById("thumb_riviera");
var scrolldiv_riviera = document.getElementById("text_riviera");
Drag.init(aThumb_riviera, null, 0, 0, 10, 305);
aThumb_riviera.onDrag = function(x, y) {
scrolldiv_riviera.style.top=y * (-1) +"px";
}
var aThumb_empresa = document.getElementById("thumb_empresa");
var scrolldiv_empresa= document.getElementById("text_empresa");
Drag.init(aThumb_empresa, null, 0, 0, 10, 305);
aThumb_empresa.onDrag = function(x, y) {
scrolldiv_empresa.style.top=y * (-1) +"px";
}
}
function draw_content() {
$('load_produtos').style.top = ((document.viewport.getHeight()/2)-40) + 'px';
$('load_colecao').style.top = ((document.viewport.getHeight()/2)-40) + 'px';
$('produtos').style.height = document.viewport.getHeight() + 'px';
$('catalogo').style.height = document.viewport.getHeight() + 'px';
$('produto_container').style.height = '350px';
$('produtos_barra').style.top = (document.viewport.getHeight()/2-175) + 'px';
$('produtos_barra').style.height = '350px';
$('catalogo_container').style.height = '350px';
$('catalogo_barra').style.top = (document.viewport.getHeight()/2-175) + 'px';
$('catalogo_barra').style.height = '350px';
$$('#produto_detalhe').each(function(p) {
p.style.height = '350px';
});
$$('produto_detalhe_table').each(function(p) {
p.style.height = '350px';
});
$$('#catalogo_detalhe').each(function(p) {
p.style.height = '350px';
});
$$('catalogo_detalhe_table').each(function(p) {
p.style.height = '350px';
});
franquia_altura('franquias_expansao');
franquia_altura('franquias_cadastro');
franquia_altura('franquias_historico');
franquia_altura('franquias_perguntas');
franquia_altura('franquias_lei');
franquia_altura('colecao_riviera');
franquia_altura('colecao_ficha_tecnica');
franquia_altura('franquias_lojas');
franquia_altura('franquias_contato');
franquia_altura('franquias_empresa');
campanha_altura('campanha_');
campanha_altura('campanha_making_of_');
campanha_altura('campanha_papeis_de_parede_');
campanha_altura('campanha_video_');
}
function go_home() {
go_to_destiny('home', 'home_barra');
}
function goto_campanha_video() {
hide_others('campanha_video_fotos_barra');
if (current_page == 'campanha_fotos' || current_page == 'ficha_tecnica' || current_page == 'papeis_de_parede') {
new Effect.Appear('campanha_video_fotos_barra', { duration: 1 });
} else {
new Effect.ScrollTo('campanha_fotos', { duration: 1, afterFinish: function() {
new Effect.Appear('campanha_video_fotos_barra', { duration: 1 }); }
});
}
current_page = 'campanha_video';
}
function goto_campanha_papeis_de_parede() {
hide_others('campanha_papeis_de_parede_fotos_barra');
if (current_page == 'campanha_fotos' || current_page == 'ficha_tecnica' || current_page == 'campanha_video') {
new Effect.Appear('campanha_papeis_de_parede_fotos_barra', { duration: 1 });
} else {
new Effect.ScrollTo('campanha_fotos', { duration: 1, afterFinish: function() {
new Effect.Appear('campanha_papeis_de_parede_fotos_barra', { duration: 1 }); }
});
}
current_page = 'papeis_de_parede';
}
function goto_colecao_ficha_tecnica() {
hide_others('colecao_ficha_tecnica_barra');
if (current_page == 'campanha_fotos' || current_page == 'papeis_de_parede' || current_page == 'campanha_video') {
new Effect.Appear('colecao_ficha_tecnica_barra', { duration: 1 });
} else {
new Effect.ScrollTo('campanha_fotos', { duration: 1, afterFinish: function() {
new Effect.Appear('colecao_ficha_tecnica_barra', { duration: 1 }); }
});
}
current_page = 'ficha_tecnica';
}
function goto_campanha_fotos() {
hide_others('campanha_fotos_barra');
if (current_page == 'ficha_tecnica' || current_page == 'papeis_de_parede' || current_page == 'campanha_video') {
new Effect.Appear('campanha_fotos_barra', { duration: 1 });
} else {
new Effect.ScrollTo('campanha_fotos', { duration: 1, afterFinish: function() {
new Effect.Appear('campanha_fotos_barra', { duration: 1 }); }
});
}
current_page = 'campanha_fotos';
}
function goto_franquia_loja() {
current_page = 'franquia_loja';
go_to_destiny('franquias_lojas', 'franquias_lojas_barra');
}
function goto_campanha_making_of_fotos() {
current_page = 'making_of_fotos';
go_to_destiny('campanha_making_of_fotos', 'campanha_making_of_fotos_barra');
}
function goto_colecao_riviera() {
current_page = 'colecao_riviera';
go_to_destiny('colecao_riviera', 'colecao_riviera_barra');
}
function goto_empresa() {
current_page = 'empresa';
go_to_destiny('franquias_empresa', 'franquias_empresa_barra');
}
function goto_contato() {
hide_others('franquias_contato_barra');
if (current_page == 'cadastro') {
new Ajax.Updater('ajax_form_contato', '/public/contact');
new Effect.Appear('franquias_contato_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_contato', { duration: 1, afterFinish: function() {
new Ajax.Updater('ajax_form_contato', '/public/contact');
new Effect.Appear('franquias_contato_barra', { duration: 1 }); }
});
}
current_page = 'contato';
}
function goto_cadastro() {
hide_others('franquias_cadastro_barra');
if (current_page == 'contato') {
new Ajax.Updater('ajax_form_franquia', '/public/cadastro_franquia');
new Effect.Appear('franquias_cadastro_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_contato', { duration: 1, afterFinish: function() {
new Ajax.Updater('ajax_form_franquia', '/public/cadastro_franquia');
new Effect.Appear('franquias_cadastro_barra', { duration: 1 }); }
});
}
current_page = 'cadastro';
}
function goto_expansao() {
hide_others('franquias_expansao_barra');
if (current_page == 'franquias_perguntas' || current_page == 'franquias_lei' || current_page == 'franquias_historico') {
new Effect.Appear('franquias_expansao_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_historico', { duration: 1, afterFinish: function() {
new Effect.Appear('franquias_expansao_barra', { duration: 1 }); }
});
}
current_page = 'expansao';
}
function goto_franquias_historico() {
hide_others('franquias_historico_barra');
if (current_page == 'franquias_perguntas' || current_page == 'franquias_lei' || current_page == 'expansao') {
new Effect.Appear('franquias_historico_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_historico', { duration: 1, afterFinish: function() {
new Effect.Appear('franquias_historico_barra', { duration: 1 }); }
});
}
current_page = 'franquias_historico';
}
function goto_franquias_perguntas() {
hide_others('franquias_perguntas_barra');
if (current_page == 'franquias_historico' || current_page == 'franquias_lei' || current_page == 'expansao') {
new Effect.Appear('franquias_perguntas_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_historico', { duration: 1, afterFinish: function() {
new Effect.Appear('franquias_perguntas_barra', { duration: 1 }); }
});
}
current_page = 'franquias_perguntas';
}
function goto_franquias_lei() {
hide_others('franquias_lei_barra');
if (current_page == 'franquias_historico' || current_page == 'franquias_perguntas' || current_page == 'expansao') {
new Effect.Appear('franquias_lei_barra', { duration: 1 });
} else {
new Effect.ScrollTo('franquias_historico', { duration: 1, afterFinish: function() {
new Effect.Appear('franquias_lei_barra', { duration: 1 }); }
});
}
current_page = 'franquias_lei';
}
function goto_franquias_cadastro() {
current_page = 'franquias_cadastro';
go_to_destiny('franquias_cadastro', 'franquias_cadastro_barra');
}
function goto_produtos(first_menu_item) {
show_submenu_lateral(first_menu_item);
new Effect.ScrollTo('produtos', { duration: 1, afterFinish: function() {
new Effect.Appear('produtos_barra', { duration: 1.0, afterFinish: function() {
hide_others('produtos_barra');
} }); }
});
current_page = 'produtos';
}
function goto_catalogo(first_menu_item) {
show_submenu_lateral_catalogo(first_menu_item);
new Effect.ScrollTo('catalogo', { duration: 1, afterFinish: function() {
new Effect.Appear('catalogo_barra', { duration: 1.0, afterFinish: function() {
hide_others('catalogo_barra');
} }); }
});
}
function show_submenu(sub_menu) {
$('barra_azul_topo_sub_navegacao').show();
if (sub_menu == 'menu_campanha') {
$(sub_menu).show();
$('menu_colecao').hide();
$('menu_franquias').hide();
$('menu_contato').hide();
} else {
if (sub_menu == 'menu_colecao') {
$(sub_menu).show();
$('menu_campanha').hide();
F $('menu_franquias').hide();
$('menu_contato').hide();
} else {
if (sub_menu == 'menu_franquias') {
$(sub_menu).show();
$('menu_colecao').hide();
$('menu_campanha').hide();
$('menu_contato').hide();
} else {
$(sub_menu).show();
$('menu_colecao').hide();
$('menu_campanha').hide();
$('menu_franquias').hide();
}
}
}
window.clearTimeout(aTimer);
window.clearTimeout(bTimer);
}
function hide_submenu(sub_menu) {
aTimer = window.setTimeout("$('barra_azul_topo_sub_navegacao').hide()", 1000);
bTimer = window.setTimeout("$('"+sub_menu+"').hide()", 1000);
}
function show_submenu_lateral(id) {
obj = $(id);
new Effect.Appear(id, { duration: 1.0});
links = $$('.sub_menu_produtos');
links.each(function(s) {
s.hide();
s.style.left = '120px';
});
links = $$('.sub_menu_produtos_fem');
links.each(function(s) {
s.hide();
s.style.left = '120px';
});
}
function show_submenu_lateral_catalogo(id) {
obj = $(id);
if (obj.style.left == '120px') {
new Effect.Appear(id, { duration: 1.0});
new Effect.Morph(id, {
style: 'left: 70px;',
duration: 0.3
});
links = $$('.sub_menu_catalogo');
links.each(function(s) {
s.hide();
s.style.left = '120px';
});
links = $$('.sub_menu_fem_catalogo');
links.each(function(s) {
s.hide();
s.style.left = '120px';
});
} else {
links = $$('.sub_menu_catalogo');
links.each(function(s) {
if (s.style.left == '70px' && s.style.display == 'none') {
s.style.left = '120px';
}
});
links = $$('.sub_menu_fem_catalogo');
links.each(function(s) {
if (s.style.left == '70px' && s.style.display == 'none') {
s.style.left = '120px';
}
});
}
}
function goto_nex_photo(index, total) {
pw = $('photo_wrapper');
pw_width = parseInt(pw.style.width)/(total+1);
new Effect.Move('photo_wrapper', { x: -(index*pw_width), y: 0, mode: 'absolute' });
}
function goto_nex_catalogo(index, total) {
pw = $('catalogo_wrapper');
pw_width = parseInt(pw.style.width)/(total+1);
new Effect.Move('catalogo_wrapper', { x: -(index*pw_width), y: 0, mode: 'absolute' });
}
function open_product(total) {
$('produto_wrapper').style.width = ((parseInt($('produto_container').style.width)) * (total+1)) + 'px';
$('produto_wrapper').style.left = '0px';
$('all_products').style.width = (document.viewport.getWidth()-270) + 'px';
$$('#produto_detalhe').each(function(p) {
p.style.width = (document.viewport.getWidth()-790) + 'px';
});
$$('#produto_detalhe_table').each(function(p) {
p.style.width = '450px';
});
$$('#produto_detalhe_barra').each(function(p) {
p.style.width = (document.viewport.getWidth()-700) + 'px';
});
new Effect.Appear('produto_wrapper', { duration: 0.4 });
$$(".tooltip_galery").each( function(link) {
new Tooltip(link, {mouseFollow: true});
});
}
function open_catalogo(total) {
$('catalogo_wrapper').style.width = ((parseInt($('catalogo_container').style.width)) * (total+1)) + 'px';
$('catalogo_wrapper').style.left = '0px';
$('all_catalogo').style.width = (document.viewport.getWidth()-270) + 'px';
$$('#catalogo_detalhe').each(function(p) {
p.style.width = (document.viewport.getWidth()-790) + 'px';
});
$$('#catalogo_detalhe_table').each(function(p) {
p.style.width = '450px';
});
$$('#catalogo_detalhe_barra').each(function(p) {
p.style.width = (document.viewport.getWidth()-700) + 'px';
});
new Effect.Appear('catalogo_wrapper', { duration: 0.4 });
$$(".tooltip_galery").each( function(link) {
new Tooltip(link, {mouseFollow: true});
});
}
function franquia_altura(id) {
$(id + '').style.height = document.viewport.getHeight() + 'px';
$(id + '_barra').style.top = (document.viewport.getHeight()/2-183) + 'px';
}
function campanha_altura(id) {
$(id +'fotos').style.height = document.viewport.getHeight() + 'px';
$(id + 'fotos_barra').style.top = (document.viewport.getHeight()/2-183) + 'px';
}
function hide_others(id) {
var all_barras = ['home_barra', 'colecao_ficha_tecnica_barra','campanha_papeis_de_parede_fotos_barra','franquias_contato_barra', 'produtos_barra', 'produto_wrapper', 'catalogo_barra', 'catalogo_wrapper', 'franquias_empresa_barra', 'campanha_fotos_barra', 'campanha_making_of_fotos_barra', 'campanha_video_fotos_barra', 'franquias_expansao_barra', 'franquias_historico_barra', 'franquias_perguntas_barra', 'franquias_lei_barra', 'franquias_cadastro_barra', 'franquias_lojas_barra']
for (i=0; i < all_barras.size(); i++) {
if (all_barras[i] != id) {
$(all_barras[i]).fade();
}
}
}
function go_to_destiny(dest, dest_barra) {
hide_others(dest_barra);
new Effect.ScrollTo(dest, { duration: 1, afterFinish: function() {
new Effect.Appear(dest_barra, { duration: 1 }); }
});
}
function franquias_largura(id) {
$(id + '').style.width = document.viewport.getWidth() + 'px';
$(id + '_barra').style.width = document.viewport.getWidth() + 'px';
$(id + '_content').style.width = (document.viewport.getWidth()-250) + 'px';
$(id + '_content').style.left = '250px';
$(id + '_content_text').style.width = (document.viewport.getWidth()-250) + 'px';
$(id + '_content_text').style.left = '250px';
}
function campanha_largura(id) {
$(id + 'fotos').style.width = document.viewport.getWidth() + 'px';
$(id + 'fotos_barra').style.width = document.viewport.getWidth() + 'px';
$(id + 'fotos_content').style.width = (document.viewport.getWidth()-250) + 'px';
$(id + 'fotos_content').style.left = '250px';
$(id + 'fotos_content_text').style.width = (document.viewport.getWidth()-250) + 'px';
$(id + 'fotos_content_text').style.left = '250px';
}
var Preloader = {
load: function() {
var args = $A(arguments);
var callback = Object.isFunction(args.last()) ? args.pop() : Prototype.emptyFunction;
var urls = Object.isArray(args[0]) ? $A(args[0]) : args;
var loaded = 0;
var images = $A();
var onload = function() {
if (++loaded == urls.length) {
callback();
// cleanup
images.each(function(i) { delete i });
images = callback = urls = null;
}
};
urls.each(function(url) {
var image = new Image();
image.onload = image.onerror = onload;
image.src = url;
images.push(image);
});
}
};
<html>
<head>
<%= javascript_include_tag "rotator", "jquery-rails", "jquery", "application", "photo" %>
<%= stylesheet_link_tag "rotator", "s1", "s2", "some", "scriptaculous" %>
</head>
<body>
<div id = "seta_mais">
<a href="javascript:goto_nex_photo(2, 5);"><img border="0" width="32" height="350" src="images/seta_produto_anterior.gif"></a>
</div>
<div class="main_image">
<% if @gallery_photos.first.geometry == 'vertical' %>
<img src="<%= @gallery_photos.first.photo.url("large") %>" style="height:420px;" />
<% else %>
<img src="<%= @gallery_photos.first.photo.url("large") %>" style="width:500px;" />
</div>
<div id = "seta_mais">
<a href="javascript:goto_nex_photo(4, 5);"><img border="0" width="32" height="350" src="images/seta_outro_produto.gif"></a>
</div>
<% end %>
<div class="desc">
<a href="#" class="collapse">Close Me!</a>
<div class="block">
<a href="http://twitter.com/share" class="twitter-share-button" data-text="Foto de divulgação." data-count="none" data-via="andre_llima_">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</div>
</div>
<div class="image_thumb">
<ul>
<% @gallery_photos.each do |g| %>
<% if g.geometry == 'vertical' %>
<li> <a href = "0" id = "thumb" > <img src = "<%= g.photo.url("small") %>" style="height:65px;"/></a>
<% else %>
<img src="<%= g.photo.url("small") %>" style="height:65px; width:80px;"/></li></a>
<% end %>
<% end %>
</li>
</ul>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment