Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $(function() {
- //search
- var search = $('#search');
- var searchInput = search.find('.string');
- var searchSubmit = search.find('.submitBtn');
- if (!$('#header').hasClass('homepage')) {
- var searchTip = $('#search').find('.tip');
- var advancedFields = $('#advancedFields');
- var headerHeight = $('#header').height();
- var advancedSearchGrowHeight = advancedFields.height() - searchTip.height();
- search.delegate('#advancedSearch', 'click keypress', function(e, first) {
- e.preventDefault();
- var advancedSearchLabel = $(this);
- if (advancedSearchLabel.hasClass('opened') && first != true) {
- searchTip.slideDown(300);
- $('#header, #headerContainer').animate({
- 'height': headerHeight
- }, function() {
- advancedSearchLabel.text('Pesquisa Avançada').removeClass('opened');
- searchInput.select();
- });
- } else {
- searchTip.slideUp(600);
- $('#header, #headerContainer').animate({
- 'height': headerHeight + advancedSearchGrowHeight
- }, function() {
- advancedSearchLabel.text('Pesquisa Simples').addClass('opened');
- searchInput.select();
- });
- }
- });
- if ($('#advancedSearch').hasClass('opened')) {
- $('#advancedSearch').trigger('click', [true]);
- }
- }
- searchSubmit.bind('click keypress', function(e) {
- var $this = $(this);
- $this.blur();
- if ($.trim(searchInput.val()) == '' || searchInput.val() == searchInput.attr('placeholder')) {
- e.preventDefault();
- searchInput.focus();
- }
- });
- });
- //testimonies
- $.fn.showTestimonies = function(url) {
- var testimonyContainer = $('#testimony');
- $.ajax({
- url: url,
- dataType: 'json',
- success: function(data) {
- var html = '';
- for (i = 0; i < data.testimonies.length; i++) {
- if (data.testimonies[i].image != undefined) html += '<article class="content" style="background:transparent url(' + data.testimonies[i].image + ') right top no-repeat;">';
- if (data.testimonies[i].story1 != undefined) html += '<p class="story1">' + data.testimonies[i].story1 + '</p>';
- if (data.testimonies[i].story2 != undefined) html += '<p class="story2">' + data.testimonies[i].story2 + '</p>';
- if (data.testimonies[i].name != undefined) html += '<p class="name">' + data.testimonies[i].name + '</p>';
- if (data.testimonies[i].jobAge != undefined) html += '<p class="jobAge">' + data.testimonies[i].jobAge + '</p>';
- if (data.testimonies[i].image != undefined) html += '</article>';
- }
- testimonyContainer.html(html);
- var testimonyList = testimonyContainer.find('article');
- testimonyList.first().addClass('active');
- testimonyList.not('.active').hide();
- (function testimonySlideShow() {
- setTimeout(function() {
- var $current = testimonyList.filter('.active');
- var $next = testimonyList.eq($current.index() + 1);
- if (!$next.length) $next = testimonyList.eq(0);
- $current.removeClass('active').fadeOut(500, function() {
- $next.addClass('active').fadeIn(500);
- });
- }, 7000);
- })();
- }
- });
- };
- $(function() {
- Cufon.replace('#menu li a', {
- forceHitArea: true,
- hover: true
- });
- Cufon.replace('.convertFont', {});
- Cufon.replace('.convertFontLink', {
- hover: true
- });
- });
- window.GlobalFn = {
- //get urls
- URLs: function() {
- var result = {
- basePath: '',
- login: ''
- };
- $.ajax({
- url: '../json/urls.json',
- async: false,
- dataType: 'json',
- success: function(data) {
- result.basePath = data.urls[0].basePath;
- result.login = data.urls[0].login;
- }
- });
- return result;
- },
- //modal window
- modalWindow: function(selector, href) {
- $.colorbox(href);
- },
- //deal with services
- serviceLogged: function(data) {
- var result = {
- logged: false,
- success: false
- };
- if (data.status.errors[1].code === 'Auth' && data.status.errors[1].desc !== 'Invalid Credentials') {
- result.logged = true;
- result.success = data.status.success;
- }
- return result;
- }
- };
- //instatiate the urls
- window.GlobalFn.URLData = window.GlobalFn.URLs();
- //Accessing the window.GlobalFn.URLData Object:
- //basePath GET: window.GlobalFn.URLData.basePath
- //login GET: window.GlobalFn.URLData.login
- $(function() {
- //init modal window
- $('body').delegate('[rel=modal]', 'click', function(e) {
- e.preventDefault();
- $this = $(this);
- window.GlobalFn.modalWindow($this);
- //$(this).blur();
- });
- //menu
- var mainMenu = $('#menu');
- var mainSubMenu = mainMenu.find('ul');
- mainSubMenu.hide();
- $(mainMenu).children('li').hover(function() {
- $(this).children('a').addClass('active');
- $(this).children('ul').animate({
- 'opacity': '1',
- 'height': 'toggle'
- });
- }, function() {
- $(this).children('a').removeClass('active');
- $(this).children('ul').animate({
- 'opacity': '0',
- 'height': 'toggle'
- });
- Cufon.refresh();
- });
- /*
- //inputs type support
- if(!Modernizr.inputtypes.search){
- $('input[type="search"]').each(function(){
- var $this = $(this);
- marker = $('<span />').insertBefore($this);
- $this.detach().attr('type', 'text').insertAfter(marker);
- marker.remove();
- });
- }
- */
- //inputs placeholders support
- if (!Modernizr.input.placeholder) {
- $('input[placeholder]').each(function() {
- var $this = $(this);
- if ($.trim($this.val()) == '' && $this.attr('placeholder') != '') {
- $this.val($this.attr('placeholder'));
- $this.focus(function() {
- if ($this.val() == $this.attr('placeholder')) $this.val('');
- });
- $this.blur(function() {
- if ($.trim($this.val()) == '') $this.val($this.attr('placeholder'));
- });
- }
- });
- }
- //votes
- var $rating = $('#rating').find('.vote');
- if ($rating.length) {
- $.ajax({
- url: window.GlobalFn.URLs.basePath + '/assets/scripts/jquery.rating.pack.js',
- dataType: 'script',
- complete: function() {
- $rating.find('input').rating({
- callback: function(value, link) {
- $(this).parents('.vote').find('label').html('Obrigado pelo seu voto!').addClass('applied');
- }
- });
- }
- });
- }
- //IE6 users
- if ($('body').hasClass('ie6')) {
- alert('este browser não é suportado');
- }
- });
- })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement