Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
66
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.             $.getJSON('../json/urls.json', function(data) {
  98.                 result.basePath = data.urls[0].basePath;
  99.                 result.login = data.urls[0].login;
  100.             });
  101.  
  102.             $.ajax({
  103.                 url: '../json/urls.json',
  104.                 async: false,
  105.                 dataType: 'json',
  106.                 success: function(data) {
  107.                     result.basePath = data.urls[0].basePath;
  108.                     result.login = data.urls[0].login;
  109.                 }
  110.             });
  111.  
  112.             return result;
  113.         },
  114.         //modal window
  115.         modalWindow: function(selector, href) {
  116.             $.colorbox(href);
  117.         },
  118.         //deal with services
  119.         serviceLogged: function(data) {
  120.             var result = {
  121.                 logged: false,
  122.                 success: false
  123.             };
  124.  
  125.             if (data.status.errors[1].code === 'Auth' && data.status.errors[1].desc !== 'Invalid Credentials') {
  126.                 result.logged = true;
  127.                 result.success = data.status.success;
  128.             }
  129.  
  130.             return result;
  131.         }
  132.     };
  133.  
  134.     //call all the urls to user when needed    
  135.     window.GlobalFn.URLData = window.GlobalFn.URLs();
  136.  
  137.     //Accessing the window.GlobalFn.URLData Object:
  138.     //basePath GET: window.GlobalFn.URLData.basePath
  139.     //login GET: window.GlobalFn.URLData.login
  140.  
  141.     //init modal window
  142.     $('body').delegate('[rel=modal]', 'click', function(e) {
  143.         e.preventDefault();
  144.         $this = $(this);
  145.         window.GlobalFn.modalWindow($this);
  146.         //$(this).blur();
  147.     });
  148.  
  149.     //menu
  150.     var mainMenu = $('#menu');
  151.     var mainSubMenu = mainMenu.find('ul');
  152.     mainSubMenu.hide();
  153.     $(mainMenu).children('li').hover(
  154.  
  155.     function() {
  156.         $(this).children('a').addClass('active');
  157.         $(this).children('ul').animate({
  158.             'opacity': '1',
  159.             'height': 'toggle'
  160.         });
  161.     }, function() {
  162.         $(this).children('a').removeClass('active');
  163.         $(this).children('ul').animate({
  164.             'opacity': '0',
  165.             'height': 'toggle'
  166.         });
  167.         Cufon.refresh();
  168.     });
  169.  
  170. /*
  171. //inputs type support
  172. if(!Modernizr.inputtypes.search){
  173.   $('input[type="search"]').each(function(){
  174.     var $this = $(this);
  175.     marker = $('<span />').insertBefore($this);
  176.     $this.detach().attr('type', 'text').insertAfter(marker);
  177.     marker.remove();
  178.   });
  179. }
  180. */
  181.  
  182.     //inputs placeholders support
  183.     if (!Modernizr.input.placeholder) {
  184.         $('input[placeholder]').each(function() {
  185.             var $this = $(this);
  186.             if ($.trim($this.val()) == '' && $this.attr('placeholder') != '') {
  187.                 $this.val($this.attr('placeholder'));
  188.                 $this.focus(function() {
  189.                     if ($this.val() == $this.attr('placeholder')) $this.val('');
  190.                 });
  191.                 $this.blur(function() {
  192.                     if ($.trim($this.val()) == '') $this.val($this.attr('placeholder'));
  193.                 });
  194.             }
  195.         });
  196.     }
  197.  
  198. /*
  199.     //votes
  200.     var $rating = $('#rating').find('.vote');
  201.     if ($rating.length) {
  202.         $.ajax({
  203.             url: window.GlobalFn.URLs.basePath + '/assets/scripts/jquery.rating.pack.js',
  204.             dataType: 'script',
  205.             complete: function() {
  206.                 $rating.find('input').rating({
  207.                     callback: function(value, link) {
  208.                         $(this).parents('.vote').find('label').html('Obrigado pelo seu voto!').addClass('applied');
  209.                     }
  210.                 });
  211.             }
  212.         });
  213.     }
  214. */
  215.  
  216.     //IE6 users
  217.     if ($('body').hasClass('ie6')) {
  218.         alert('este browser não é suportado');
  219.     }
  220. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement