Advertisement
Guest User

Untitled

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