Advertisement
bondcemil

js

Jun 17th, 2013
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function() {  
  2.  
  3.     $('.tooltip').tipsy({gravity: 's' });
  4.     $('.recommendedTooltip').tipsy({html: true, gravity: 'w' });
  5.  
  6.  
  7.     /// AJAX LOGIN \\\
  8.     $('.login-form').submit(function(){
  9.        
  10.         var thisform = this;
  11.         var fields = $('p.inputs', thisform);
  12.        
  13.         $(fields).block({ message: null, overlayCSS: {
  14.             backgroundColor: '#fff',
  15.             opacity:         0.6
  16.         } });
  17.        
  18.         var data = {
  19.             action:         'woca_ajax_login_process',
  20.             security:       $('input[name=\"login_nonce\"]', thisform).val(),
  21.             log:            $('input[name=\"log\"]', thisform).val(),
  22.             pwd:            $('input[name=\"pwd\"]', thisform).val(),
  23.             redirect_to:    $('input[name=\"redirect_to\"]', thisform).val()
  24.         };
  25.    
  26.         // Ajax action
  27.         $.post( $('input[name=\"ajax_url\"]', thisform).val(), data, function(response) {
  28.            
  29.             $('span.error').remove();
  30.             $('input.input-error').removeClass('error');
  31.            
  32.             result = $.parseJSON( response );
  33.            
  34.             if (result.success==1) {
  35.                 window.location = result.redirect;
  36.             } else if (result.error) {
  37.                 $(thisform).append('<span class="error">' + result.error + '</span>');
  38.                 $('.input-text', fields).addClass('input-error');
  39.                 $(fields).unblock();
  40.             } else {
  41.                 return true;
  42.             }
  43.         });
  44.        
  45.         return false;
  46.     });
  47.  
  48.  
  49.     /// AJAX LOGIN POPUP \\\
  50.     $(".btnPopup").toggle(
  51.         function(){
  52.             $(this).next(".popup").stop().css({display: "block"}).animate({top:33, opacity:1}, {duration: 250});
  53.         },
  54.         function() {
  55.             $(this).next(".popup").animate({top:23, opacity:0}, {duration: 250});
  56.             $(this).next(".popup").queue (function ()  {
  57.                 $(this).css({display: "none"});
  58.                 $(this).dequeue();
  59.             });
  60.  
  61.         });
  62.  
  63.     $(".popup-close").click(function() {
  64.         $(this).parent(".popup").animate({top:23, opacity:0}, {duration: 250});
  65.         $(this).parent(".popup").queue (function ()  {
  66.             $(this).css({display: "none"});
  67.             $(this).dequeue();
  68.         });
  69.     });
  70.  
  71.  
  72.     /// BG SWTICHER \\\
  73.     $(".custom_backgrounds a").click( function(e) {
  74.         e.preventDefault()
  75.         var ajax_url = bg_switcher.ajaxurl;
  76.         var bg_url = $(this).attr('data-bg-url');
  77.  
  78.         $.ajax({
  79.             url: ajax_url,
  80.             type:   'get',
  81.             dataType:   'json',
  82.             // cache:  'false',
  83.             data: { 'action' : 'bg_cookie', 'bg_url' : bg_url},
  84.             success: function(data) {
  85.  
  86.                 if (bg_url == 'default')
  87.                     $('body').removeAttr("style");
  88.                 else
  89.                     $('body').css('backgroundImage', 'url(' + bg_url + ')');
  90.  
  91.             },
  92.             error: function() {
  93.                 console.error('fail')
  94.             }
  95.         });
  96.  
  97.     });
  98.  
  99.     /// PAGE CENTER FUNCTION \\\
  100.     $.fn.center = function () {
  101.         this.css("position","fixed");
  102.         this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
  103.         this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
  104.         return this;
  105.     }
  106.  
  107.     // ADVERTISE
  108.     $('.ad-hide.right').toggle( function() {
  109.         $(this).next().animate({right:-120});
  110.         $(this).animate({right:0});
  111.     }, function() {
  112.         $(this).next().animate({right:0});
  113.         $(this).animate({right:120});
  114.     });
  115.  
  116.     $('.ad-hide.left').toggle( function() {
  117.         $(this).next().animate({left:-120});
  118.         $(this).animate({left:0});
  119.     }, function() {
  120.         $(this).next().animate({left:0});
  121.         $(this).animate({left:120});
  122.     });
  123.  
  124.      //HIDE AD ON LOW RESOLUTION
  125.     $(window).resize(function() {
  126.         var windowW = $(window).width();
  127.         if (windowW < 1205) {
  128.             $('#sag-sabit-reklam, #sol-sabit-reklam, .ad-hide').hide();
  129.         } else {
  130.             $('#sag-sabit-reklam, #sol-sabit-reklam, .ad-hide').show();
  131.         }
  132.     });
  133.     $(window).trigger('resize');
  134.  
  135.  
  136.     //CREATE PLACEHOLDER FUNCTIONALITY IN IE
  137.  
  138.      jQuery(function() {
  139.         jQuery.support.placeholder = false;
  140.         test = document.createElement('input');
  141.         if('placeholder' in test) jQuery.support.placeholder = true;
  142.     });
  143.  
  144.     if(!$.support.placeholder) {
  145.         var active = document.activeElement;
  146.         $(':text').focus(function () {
  147.             if ($(this).attr('placeholder') != '' && $(this).val() == $(this).attr('placeholder')) {
  148.                 $(this).val('').removeClass('hasPlaceholder');
  149.             }
  150.         }).blur(function () {
  151.             if ($(this).attr('placeholder') != '' && ($(this).val() == '' || $(this).val() == $(this).attr('placeholder'))) {
  152.                 $(this).val($(this).attr('placeholder')).addClass('hasPlaceholder');
  153.             }
  154.         });
  155.         $(':text').blur();
  156.         $(active).focus();
  157.         $('form').submit(function () {
  158.             $(this).find('.hasPlaceholder').each(function() { $(this).val(''); });
  159.         });
  160.     }
  161.  
  162.  
  163. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement