//jQuery Ready $(function(){ /* ***** Config ***** */ var debug = false; //Debug mode is on? var screenr = false; //Screenr effect is on? var sPath = window.location.pathname; //Site URL var sPage = sPath.substring(sPath.lastIndexOf('/') + 1).replace(window.location.hash,''); //Current Page if(window.location.hash == '') var sHash = '#home'; else var sHash = window.location.hash; //Get Hash var $navChildren = $('nav li'); //Navigation childrens var $desk = $('#desk'); //Desk var $deck = $desk.find('.deck'); //Decks $deck.removeAttr('id'); /* ***** Loading Status ***** */ loadingStatus = function(module, status){ if(typeof $loadingModules == 'undefined') $loadingModules = [ {name:'images', msg:'Carregando imagens...'}, {name:'facebook', msg:'Conectando ao Facebook...'}, {name:'twitter', msg:'Conectando ao Twitter...'}, {name:'blog', msg:'Conectando ao Blog...'} ]; var $totalModules = $loadingModules.length; var animation = function(msg){ var $height = $('#blackout .status p:first-child').outerHeight(); $('
').appendTo('#blackout .status').fadeIn(600).prev().prev().animate({'margin-top':-$height, 'opacity':'0'}, 600, function(){ $(this).remove(); }); } if(typeof $loadingCount == 'undefined') $loadingCount = 0; if(status == 0) { if(module != 'complete') for(i=0; i < $totalModules; i++) { if(module == $loadingModules[i].name) { var $msg = $loadingModules[i].msg; break; } } animation($msg); } else { $loadingCount++; } if($loadingCount == $totalModules - 1) { $().goPage(sHash); window.scrollTo(0,0); setTimeout(function(){ animation('Ok! Carregado.'); }, 1200); setTimeout(function(){ $('#blackout').fadeOut(600, function(){ $(this).remove(); }); }, 2500); } } if(debug) { $('#blackout').fadeOut(600, function(){ $(this).remove(); }); } /* ***** Read and set cookies ***** */ jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + (options.path) : ''; var domain = options.domain ? '; domain=' + (options.domain) : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; /* ***** Save and load variables ***** */ storage = { set: function(bar, foo){ if(typeof(localStorage) != 'undefined') localStorage.setItem(bar, foo); //else $.cookie(bar, foo, {expires: 365}); }, get: function(bar){ if(typeof(localStorage) != 'undefined') if(localStorage.getItem(bar) != null) return localStorage.getItem(bar); else return $.cookie(bar); else return $.cookie(bar); } }; /* ***** Theme switcher ***** */ $('link[rel="alternate stylesheet"]').remove(); $('#themes ul li a').bind('click', function(event){ $(this).parent().addClass('current').siblings().removeClass('current'); $('link[rel="stylesheet"]').eq(1).attr('href','_css/'+$(this).attr('class')+'.css'); storage.set('theme',$(this).attr('class')); if(screenr) { setTimeout(function(){ $('body').fullscreenr({width: 1600, height: 1200}); }, 300); } event.preventDefault(); }); /* ***** Navigation ***** */ $.fn.calcPos = function(){ var $position = $(this).position(); var $position = $position.top+$(this).height()/2; return $position; }; $.fn.returnMark = function(options){ options = $.extend({ duration: 300, easing:'easeOutBack' }, options); var $element = $(this); var $position = $element.calcPos(); var $animating = false; $element.siblings('.selectedMark').stop().animate({'top':$position}, {duration: options.duration, easing:options.easing, step:function(now, fx){ $percent = parseInt((now/$position)*100); if(($percent >= '90' && $percent <= '120') || ($percent > '-2000' && $percent < '-1000') && $animating == false) { $element.addClass('selected'); $animating = true; } $element.siblings().removeClass('selected'); }}); $(this).siblings().removeClass('selected'); }; $.fn.goPage = function(hash){ $navChildren .find('a[href="'+hash+'"]') .parent() .addClass('selected current') .siblings() .removeClass('selected current') .end() .returnMark(); var $myHash = hash.replace('#',''); var $deckCount = $deck.length; var $deskPos = 0; for($c = 0; $c <= $deckCount; $c++) { $deskPos += parseInt($deck.eq($c).outerWidth()); if($deck.eq($c).attr('hash') == $myHash) { $deskPos -= parseInt($deck.eq(0).outerWidth()); break; } } $desk.stop().animate({'margin-left':-$deskPos}, 'slow'); }; $navChildren.not(".selectedMark").children('a') //On mouse over .bind('mouseover', function(){ $(this).parent().returnMark(); }) //On click .bind('click', function(){ $().goPage($(this).attr('href')); }) //On focus in .bind('focusin', function(){ $(this).parent().returnMark(); }) //On focus out .eq($navChildren.not(".selectedMark").length-1).bind('focusout', function(){ $(this).parent().parent().find('.current').returnMark(); }); //On mouse out $navChildren.parent().bind('mouseleave', function(){ $(this).find('.current').returnMark(); }); /* ***** Decks ***** */ //Reorder /*$deck.find('.card').each(function(i){ if(storage.get($(this).attr('id')) != null) { $(this).appendTo($deck.find('[colnum="'+storage.get($(this).attr('id'))+'"]')); } });*/ //Turn card sortable $(".column").sortable({ connectWith:'.column', handle:'.cardHeader', revert:300, tolerance:'pointer', placeholder:"ui-state-highlight", cursorAt:{'top':23, 'left':50}, start: function(event, ui) { ui.placeholder.css({'height':ui.item.outerHeight()}); }, change: function(event, ui) { ui.helper.stop().animate({'width':ui.placeholder.outerWidth()}, 300, function(){ if(ui.helper.attr('id') == 'portfolioCard' || ui.helper.attr('id') == 'myWorksFlow') ui.helper.find('.content ul').contentFlow(); }); }, stop: function(event, ui) { storage.set(ui.item.attr('id'),ui.item.parent().attr('colnum')); } }); /* ***** Resizable ***** */ $(".gripperV").each(function(){ $percentCalculate = ($(this).prev().width()/$(this).parent().outerWidth())*100; $(this).slider({ value:$percentCalculate+5, max:100, start: function(event, ui){ $('body').css('cursor','w-resize'); }, slide: function(event, ui){ if(ui.value > 30 && ui.value < 70) $(this).prev().css({width:ui.value-5+'%'}).end().next().css({width:100-(ui.value+5)+'%'}); else return false; }, stop: function(event, ui){ $('body').css('cursor','default'); } }); }); /* ***** Tooltips ***** */ $('a[title]:not(".noTooltip")').bind('mouseover', function(){ if(!$(this).find('.tooltip').length && $(this).attr('title') != '') $(this).append('').attr('title',''); $(this).find('.tooltip').fadeIn(70); }).bind('mouseleave', function(){ $(this).find('.tooltip').fadeOut(70); }); /* ***** Content Flow ***** */ $.fn.contentFlow = function(options){ options = $.extend({ size:60, duration:500, easing:'easeOutBack', desc:false }, options); this.each(function(){ //Sets var $exists = false; var $childrens = $(this).children(); var $childrensCount = $childrens.length; if($childrensCount%2 != 0) var $middleEq = (($childrensCount+1)/2)-1; else var $middleEq = (($childrensCount)/2)-1; var $middleChildren = $childrens.eq($middleEq); var $leftArrow; var $rightArrow; //Verify if($middleChildren.parent().is('.wraped')) { $middleChildren = $('.current', $middleChildren.parent()); $middleChildren.parent().removeClass('wraped').css('width','auto').unwrap(); $exists = true; $childrens.width($('.current', $middleChildren.parent()).width()); $leftArrow = $middleChildren.parent().parent().find('.cf-left-arrow'); $rightArrow = $middleChildren.parent().parent().find('.cf-right-arrow'); } var $maxWidth = $middleChildren.width(); var $maxOuterWidth = $middleChildren.outerWidth(); var $diff = 0; var $middleLeft = 0; var $verticalMargin = 0; $middleChildren.addClass('current').siblings().removeClass('current'); //Total Size var $initialSize = $middleChildren.parent().width(); var $totalSize = 0; $childrens.each(function(i){ $totalSize += $(this).outerWidth(); }); $middleChildren.parent().addClass('wraped').width($totalSize).wrap(''); $childrens.not('.current').each(function(i){ $(this).width(($maxWidth/100)*options.size); }); $diff = ($childrens.eq(0).outerWidth()-(($maxWidth/100)*options.size)); //Add left/right arrow if($exists == false) { $rightArrow = $('').prependTo($middleChildren.parent().parent()); $leftArrow = $('').appendTo($middleChildren.parent().parent()); } //Vertical margin $verticalMargin = ($middleChildren.outerHeight()/2)-($middleChildren.siblings().eq(0).outerHeight()/2); $middleChildren.siblings().css('margin-top',$verticalMargin); //Middle Animation var $fnMiddleCalc = function(elem){ //Math Math.middleLeft = function(){ $middleLeft = 0; $middleLeft += ($middleChildren.prevAll().length)*(($maxWidth/100)*options.size); $middleLeft += ($middleChildren.prevAll().length)*$diff; $middleLeft += $maxOuterWidth/2; $middleLeft -= $initialSize/2; return $middleLeft; }; $middleChildren = elem; elem.addClass('current').siblings().removeClass('current'); $middleLeft = Math.middleLeft(); $('.current', $middleChildren.parent()).siblings().stop().animate({'width':($maxWidth/100)*options.size, 'margin-top':$verticalMargin}, options.duration, options.easing); $('.current', $middleChildren.parent()).stop().animate({'width':$maxWidth, 'margin-top':'0'}, options.duration, options.easing); $middleChildren.parent().stop().animate({'left': -$middleLeft}, options.duration, options.easing); //Show Desc if(options.desc == true) { elem.parent().parent().parent().find('.desc h5').text(elem.find('h5').text()); elem.parent().parent().parent().find('.desc p').html(elem.find('p').html()); } else if(options.desc) { if(elem.attr('data-attr')) { $('#workAttributes .content ul').html(''); var attr = elem.attr('data-attr'); attr = attr.split(','); $.each(attr, function(i, value){ $('#workAttributes .content ul').append('