Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function($) {
  2.     $(function() {
  3.         //search
  4.         var search = $('#search');
  5.         var searchInput = search.find('.string');
  6.         var searchSubmit = search.find('.submitBtn');
  7.         if (!$('#header').hasClass('homepage')) {
  8.             var searchTip = $('#search').find('.tip');
  9.             var advancedFields = $('#advancedFields');
  10.             var headerHeight = $('#header').height();
  11.             var advancedSearchGrowHeight = advancedFields.height() - searchTip.height();
  12.             search.delegate('#advancedSearch', 'click keypress', function(e, first) {
  13.                 e.preventDefault();
  14.                 var advancedSearchLabel = $(this);
  15.                 if (advancedSearchLabel.hasClass('opened') && first != true) {
  16.                     searchTip.slideDown(300);
  17.                     $('#header, #headerContainer').animate({
  18.                         'height': headerHeight
  19.                     }, function() {
  20.                         advancedSearchLabel.text('Pesquisa Avançada').removeClass('opened');
  21.                         searchInput.select();
  22.                     });
  23.                 } else {
  24.                     searchTip.slideUp(600);
  25.                     $('#header, #headerContainer').animate({
  26.                         'height': headerHeight + advancedSearchGrowHeight
  27.                     }, function() {
  28.                         advancedSearchLabel.text('Pesquisa Simples').addClass('opened');
  29.                         searchInput.select();
  30.                     });
  31.                 }
  32.             });
  33.  
  34.             if ($('#advancedSearch').hasClass('opened')) {
  35.                 $('#advancedSearch').trigger('click', [true]);
  36.             }
  37.         }
  38.  
  39.         searchSubmit.bind('click keypress', function(e) {
  40.             var $this = $(this);
  41.             $this.blur();
  42.             if ($.trim(searchInput.val()) == '' || searchInput.val() == searchInput.attr('placeholder')) {
  43.                 e.preventDefault();
  44.                 searchInput.focus();
  45.             }
  46.         });
  47.     });
  48.  
  49.     //testimonies
  50.     $.fn.showTestimonies = function(url) {
  51.         var testimonyContainer = $('#testimony');
  52.         $.ajax({
  53.             url: url,
  54.             dataType: 'json',
  55.             success: function(data) {
  56.                 var html = '';
  57.                 for (i = 0; i < data.testimonies.length; i++) {
  58.                     if (data.testimonies[i].image != undefined) html += '<article class="content" style="background:transparent url(' + data.testimonies[i].image + ') right top no-repeat;">';
  59.                     if (data.testimonies[i].story1 != undefined) html += '<p class="story1">' + data.testimonies[i].story1 + '</p>';
  60.                     if (data.testimonies[i].story2 != undefined) html += '<p class="story2">' + data.testimonies[i].story2 + '</p>';
  61.                     if (data.testimonies[i].name != undefined) html += '<p class="name">' + data.testimonies[i].name + '</p>';
  62.                     if (data.testimonies[i].jobAge != undefined) html += '<p class="jobAge">' + data.testimonies[i].jobAge + '</p>';
  63.                     if (data.testimonies[i].image != undefined) html += '</article>';
  64.                 }
  65.                 testimonyContainer.html(html);
  66.                 var testimonyList = testimonyContainer.find('article');
  67.                 testimonyList.first().addClass('active');
  68.                 testimonyList.not('.active').hide();
  69.                 (function testimonySlideShow() {
  70.                     setTimeout(function() {
  71.                         var $current = testimonyList.filter('.active');
  72.                         var $next = testimonyList.eq($current.index() + 1);
  73.                         if (!$next.length) $next = testimonyList.eq(0);
  74.                         $current.removeClass('active').fadeOut(500, function() {
  75.                             $next.addClass('active').fadeIn(500);
  76.                         });
  77.                     }, 7000);
  78.                 })();
  79.             }
  80.         });
  81.     };
  82.  
  83.     $(function() {
  84.         Cufon.replace('#menu li a', {
  85.             forceHitArea: true,
  86.             hover: true
  87.         });
  88.  
  89.         Cufon.replace('.convertFont', {});
  90.         Cufon.replace('.convertFontLink', {
  91.             hover: true
  92.         });
  93.     });
  94.  
  95.     window.GlobalFn = {
  96.         //get urls
  97.         URLs: function() {
  98.             var result = {
  99.                 basePath: '',
  100.                 login: ''
  101.             };
  102.  
  103.             $.ajax({
  104.                 url: '../json/urls.json',
  105.                 async: false,
  106.                 dataType: 'json',
  107.                 success: function(data) {
  108.                     result.basePath = data.urls[0].basePath;
  109.                     result.login = data.urls[0].login;
  110.                 }
  111.             });
  112.  
  113.             return result;
  114.         },
  115.         //modal window
  116.         modalWindow: function(selector, href) {
  117.             $.colorbox(href);
  118.         },
  119.         //deal with services
  120.         serviceLogged: function(data) {
  121.             var result = {
  122.                 logged: false,
  123.                 success: false
  124.             };
  125.  
  126.             if (data.status.errors[1].code === 'Auth' && data.status.errors[1].desc !== 'Invalid Credentials') {
  127.                 result.logged = true;
  128.                 result.success = data.status.success;
  129.             }
  130.  
  131.             return result;
  132.         }
  133.     };
  134.  
  135.     //instatiate the urls    
  136.     window.GlobalFn.URLData = window.GlobalFn.URLs();
  137.  
  138.     //Accessing the window.GlobalFn.URLData Object:
  139.     //basePath GET: window.GlobalFn.URLData.basePath
  140.     //login GET: window.GlobalFn.URLData.login
  141.     $(function() {
  142.         //init modal window
  143.         $('body').delegate('[rel=modal]', 'click', function(e) {
  144.             e.preventDefault();
  145.             $this = $(this);
  146.             window.GlobalFn.modalWindow($this);
  147.             //$(this).blur();
  148.         });
  149.  
  150.         //menu
  151.         var mainMenu = $('#menu');
  152.         var mainSubMenu = mainMenu.find('ul');
  153.         mainSubMenu.hide();
  154.         $(mainMenu).children('li').hover(function() {
  155.             $(this).children('a').addClass('active');
  156.             $(this).children('ul').animate({
  157.                 'opacity': '1',
  158.                 'height': 'toggle'
  159.             });
  160.         }, function() {
  161.             $(this).children('a').removeClass('active');
  162.             $(this).children('ul').animate({
  163.                 'opacity': '0',
  164.                 'height': 'toggle'
  165.             });
  166.             Cufon.refresh();
  167.         });
  168.  
  169.         /*
  170.         //inputs type support
  171.         if(!Modernizr.inputtypes.search){
  172.           $('input[type="search"]').each(function(){
  173.             var $this = $(this);
  174.             marker = $('<span />').insertBefore($this);
  175.             $this.detach().attr('type', 'text').insertAfter(marker);
  176.             marker.remove();
  177.           });
  178.         }
  179.         */
  180.  
  181.         //inputs placeholders support
  182.         if (!Modernizr.input.placeholder) {
  183.             $('input[placeholder]').each(function() {
  184.                 var $this = $(this);
  185.                 if ($.trim($this.val()) == '' && $this.attr('placeholder') != '') {
  186.                     $this.val($this.attr('placeholder'));
  187.                     $this.focus(function() {
  188.                         if ($this.val() == $this.attr('placeholder')) $this.val('');
  189.                     });
  190.                     $this.blur(function() {
  191.                         if ($.trim($this.val()) == '') $this.val($this.attr('placeholder'));
  192.                     });
  193.                 }
  194.             });
  195.         }
  196.  
  197.         //votes
  198.         var $rating = $('#rating').find('.vote');
  199.         if ($rating.length) {
  200.             $.ajax({
  201.                 url: window.GlobalFn.URLs.basePath + '/assets/scripts/jquery.rating.pack.js',
  202.                 dataType: 'script',
  203.                 complete: function() {
  204.                     $rating.find('input').rating({
  205.                         callback: function(value, link) {
  206.                             $(this).parents('.vote').find('label').html('Obrigado pelo seu voto!').addClass('applied');
  207.                         }
  208.                     });
  209.                 }
  210.             });
  211.         }
  212.  
  213.         //IE6 users
  214.         if ($('body').hasClass('ie6')) {
  215.             alert('este browser não é suportado');
  216.         }
  217.     });
  218. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement