RUSSEL86

Jquery Cheetsheet

Mar 9th, 2015
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 30.33 KB | None | 0 0
  1. ---------- jquery condition button if login show button and if loggedout then redirect login page --------------
  2. jQuery(document).ready(function( $ ){
  3.   if(jQuery('body').hasClass('logged-in'))
  4.   {
  5.   }else{
  6.     jQuery('.btn.show-code').attr('href','/login/');
  7.   }
  8. });
  9. ------or-------
  10. jQuery(document).ready(function( $ ){
  11.   if(jQuery('body').hasClass('logged-in'))
  12.   {
  13.   } else {
  14.    $(".btn.show-code").click(function(){
  15.   window.location.href='https://www.couponmii.com/login';
  16. });
  17.   }
  18.  
  19.  
  20.  
  21. });
  22. ------------ Bootstrap tab with select option list -------------
  23. <select class="select-tabs">
  24.     <option data-target="#home">Home</option>
  25.     <option data-target='#profile'>Profile</option>
  26.     <option data-target='#messages'>Messages</option>
  27.     <option data-target='#settings'>Settings</option>
  28. </select>
  29. <div class="tab-content">
  30.     <div class="tab-pane active" id="home">Home content</div>
  31.     <div class="tab-pane" id="profile">Profile content</div>
  32.     <div class="tab-pane" id="messages">Messages content</div>
  33.     <div class="tab-pane" id="settings">Settings content</div>
  34. </div>
  35.  
  36. jQuery('select.select-tabs').on('change', function () {
  37.     jQuery(':selected', this).tab('show');
  38. });
  39.  
  40. ------------ bxslider for custom pager slider -------------
  41. //slider
  42.  jQuery('.bxslider').bxSlider();
  43.   jQuery('.bxslider_single').bxSlider({
  44.   pagerCustom: '#bx-pager',
  45.    adaptiveHeight: true,
  46.    nextText:'<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>',
  47.    prevText:'<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>',
  48.   //controls:false
  49. });
  50. jQuery("#bx-pager").bxSlider({
  51.     slideWidth: 275,
  52.     minSlides: 3,
  53.     maxSlides: 3,
  54.     slideMargin: 0,
  55.     controls: true,
  56.     pager: false,
  57.     infiniteLoop: false,
  58.     nextText:'<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>',
  59.    prevText:'<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>',
  60. });
  61.  
  62.  
  63. Insert data from input to another input
  64. ---------------------------------------
  65. $("#kinginputgetid").keyup(function(){
  66.     var get_input_val = $("#kinginputgetid").val();
  67.     $("#kinginputpushid").val(get_input_val);
  68. });
  69. Ref:http://credshopping.com.br/formpage/
  70.  
  71. Insert data from select option to another select option
  72. -------------------------------------------------------
  73. $('#kingdropgetid').on('change', function() {
  74.     var get_select_val = $("#kingdropgetid").val();
  75.      $("#kingdroppushid").val(get_select_val);
  76. })
  77. Ref:http://credshopping.com.br/formpage/
  78.  
  79. Insert data from button to another input
  80. ---------------------------------------
  81. $('button.btn_select_kor').click(function(){
  82.     $(this).toggleClass('button_clicked');
  83.     var data_value = $(this).attr('data-btnvalue');
  84.     $(this).parent().next().find("#amount_dhorsi").val(data_value);
  85. });      
  86. Ref:http://credshopping.com.br/formpage-eight/
  87.  
  88. Insert data from button to another select option
  89. ------------------------------------------------
  90. $('button.btn_select_kortw').click(function() {
  91.     $(this).toggleClass('button_clickedtw');
  92.     var data_value = $(this).attr('data-btnvalue');
  93.     $(this).parent().next().find("#amount_seldhorsi").val(data_value);
  94. })
  95. Ref:http://credshopping.com.br/formpage-eight/
  96.  
  97.  
  98.  
  99. // Slider with custom pagination content
  100. ==================================
  101. // For Slider
  102.  jQuery('#banner-slider').slick({
  103.   arrows: false,
  104.   dots: false,
  105.   pauseOnHover: false,
  106.   fade: true,
  107.   adaptiveHeight: true,
  108.   slidesToShow: 1,
  109.   autoplay: false,
  110.   speed: 1000,
  111.  });
  112.  
  113.  // Slider Pagination
  114.  jQuery(".single-pagi").click( function() {
  115.   jQuery(this).addClass('active').siblings().removeClass('active');
  116.   var slidePos = jQuery(this).data('slide');
  117.   jQuery('#banner-slider').slick('slickGoTo', slidePos);
  118.  });
  119. ref : http://pitronot-ins.com/
  120. // Responsive Slicnav
  121. ==================================
  122. jQuery(document).ready(function(){
  123.  jQuery('#nav').slicknav({
  124.   duration: 1000,
  125.   label: 'Menu',
  126.   prependTo:"#mainmenu_area_mobile"
  127.  });
  128. });
  129. // Responsive meanmenu
  130. ==================================
  131.     jQuery('.menu_area').meanmenu({
  132.         meanMenuContainer:'#mobile_nav',
  133.         meanScreenWidth: "750"
  134.         });
  135. source : https://github.com/meanthemes/meanMenu
  136. // For Slider slicknav
  137. =========================================
  138. jQuery(document).ready(function(){
  139.    jQuery('#banner_slider').slick({
  140.    arrows: false,
  141.    dots: false,
  142.    pauseOnHover: false,
  143.    fade: true,
  144.    slidesToShow: 1,
  145.    slidesToScroll: 1,
  146.    autoplay: true,
  147.    speed: 1000,
  148.    autoplaySpeed: 2000,
  149.  });
  150. });
  151.  
  152.  
  153.  
  154. // Jquery nicescroll plugin activator
  155. ============================================
  156. jQuery(document).ready(function(){
  157. jQuery("html").niceScroll({
  158. cursorminheight: 80,
  159. hidecursordelay: 400,
  160. cursorcolor:"#000",
  161. cursorwidth: "8px",
  162. scrollspeed: 40,
  163. mousescrollstep: 60,
  164. });
  165. });
  166. plugin link: https://github.com/inuyaksa/jquery.nicescroll
  167.  
  168. // insert placeholder into input field by jquery
  169. ============================================
  170.  jQuery('input#es_txt_email').attr('placeholder', 'Enter Your Mail');
  171.  
  172. // addclass into li or some where you need  when hover by jquery
  173. ============================================
  174. jQuery(document).ready(function(){
  175.   jQuery("ul.new_navaright li.social").hover(
  176.   function () {
  177.     jQuery(this).addClass('active');
  178.   },
  179.   function () {
  180.     jQuery(this).removeClass('active');
  181.   }
  182. ); 
  183. });
  184.  
  185. // / addclass and removeClass into div or some where you need  when start scroll by jquery
  186. ============================================
  187. $(window).scroll(function(){
  188.     if($(this).scrollTop() > 1 ){
  189.         $('#targeted-div').addClass('head_color');
  190.     }else{
  191.         $('#targeted-div').removeClass('head_color');
  192.     }
  193. });
  194.  ---- or div hide/show smoothly where you need  when start scroll by jquery---
  195. $(window).scroll(function(){
  196.     if($(this).scrollTop() > 5){
  197.         $('.mobile_header_area').slideUp();
  198.     }else{
  199.         $('.mobile_header_area').slideDown();
  200.     }
  201. });
  202.  
  203. // Jquery auto Full Screen Height
  204. ============================================
  205. // fullheight banner
  206.  function fullheight(){
  207.     var mainheight = $(window).outerHeight();
  208.     $(".slider_item").height(mainheight);
  209.  };
  210.  fullheight();
  211.  $(window).resize(function(){
  212.  fullheight();
  213.  });
  214.  
  215. ------ or -------
  216.  
  217. jQuery(document).ready(function() {
  218.     var height = jQuery(window).height();
  219.     jQuery('div.full_width_banner').height(height);
  220. });
  221.  
  222. ---- or ---
  223.  
  224. jQuery(document).ready(function() {
  225.   function setHeight() {
  226.     windowHeight = jQuery(window).innerHeight();
  227.     jQuery('div.full_width_banner').css('height', windowHeight);
  228.   };
  229.   setHeight();
  230.   jQuery(window).resize(function() {
  231.     setHeight();
  232.   });
  233. });
  234.  
  235. ---- or ----
  236.  
  237. function thirty_pc() {
  238.     var height = jQuery(window).height();
  239.     var thirtypc = (100 * height) / 100;
  240.     thirtypc = parseInt(thirtypc) + 'px';
  241.     jQuery("div.full_width_banner").css('height',thirtypc);
  242. };
  243.  
  244. jQuery(document).ready(function() {
  245.     thirty_pc();
  246.     jQuery(window).bind('resize', thirty_pc);
  247. });
  248.  
  249. Window height plus minus Jquery
  250. =======================================
  251. var full_height = jQuery(window).height();
  252. var header_height = jQuery(".header_amin_area").height();
  253. var side_height = full_height - header_height;
  254. jQuery("div.full_width_banner").height(side_height);
  255. ------ or ---------------------
  256. var full_height = jQuery("body").height();
  257. var header_height = jQuery(".head_main_area").height();
  258. var side_height = full_height - header_height;
  259. jQuery(".sidebar_fixed_menu_area").height(side_height);
  260. ------ or ---------------------
  261. var height = jQuery(window).height();
  262. var header = jQuery(".header_main_area").outerHeight();
  263. jQuery('.home_banner_mainarea').height(height-header);
  264.  
  265. // margin top depend on header area
  266. ================================
  267. jQuery(document).ready(function() {
  268.     var head_height = jQuery("header#main-header").height();
  269.     jQuery('.areamenu_fro_ubermenu').css('margin-top', head_height);    
  270. });
  271.  
  272.  
  273. // Header fixed Js
  274. =======================================
  275. var stickyTop = $('#stickyBanner').offset().top;
  276. $(window).on( 'scroll', function(){
  277.         if ($(window).scrollTop() >= stickyTop) {
  278.             $('#stickyBanner').css({position: "fixed", top: "0px"});
  279.         } else {
  280.             $('#stickyBanner').css({position: "relative", top: "0px"});
  281.         }
  282.     });
  283.  
  284. // Footer fixed Js
  285. =======================================
  286. jQuery(document).scroll(function() {    
  287.     var scroll = jQuery(this).scrollTop();
  288.     if (scroll >= 200) {
  289.         jQuery("#sticky_footer, #pager").addClass("fixed");
  290.     } else{
  291.         jQuery("#sticky_footer, #pager").removeClass("fixed");
  292.     }
  293. });
  294.  
  295. // Dropdown-menu with toggle
  296. ---------------------------
  297.  $("li.widget_accordion_drop ul").hide();
  298. $("li.widget_accordion_drop a").click(function(event){
  299.     $(this).next("ul").slideToggle();
  300.     event.preventDefault();
  301.  
  302. });
  303.  
  304. // Scroll to Div
  305. ==================================
  306. jQuery(document).ready(function (){
  307.     jQuery("#goto_div_id").click(function (){
  308.         jQuery('html, body').animate({
  309.             scrollTop: jQuery("#target_div_id").offset().top
  310.         }, 2000);
  311.     });
  312. });
  313. -----------------  or  ----------------
  314. jQuery("#banner_arrow").click(function(event) {
  315.     event.preventDefault();
  316.     jQuery("html, body").animate({scrollTop: jQuery("#where_to_go").offset().top - jQuery(".head_main_area").height()},600);
  317. });
  318. // Scroll to Div when div reach top 220px
  319. ==================================
  320. var $window = $(window),
  321. $stickyEl = $('section.widget:last-child'),
  322.  elTop = $stickyEl.offset().top-220;
  323.    $window.scroll(function() {
  324.      $stickyEl.toggleClass('sticky', $window.scrollTop() > elTop);
  325. });
  326.  
  327. // Scroll to Top basic
  328. ========================================
  329. jQuery(document).ready(function(){
  330.  //Click event to scroll to top
  331.  jQuery('#backtotop').click(function(){
  332.   jQuery('html, body').animate({scrollTop : 0},800);
  333.   return false;
  334.  });
  335. });
  336.  
  337. <!-- Scroll To Top Html Here -->
  338.   <button type="button" id="backtotop">Scroll To Top</button>
  339.  
  340.  
  341. // Scroll to Top Advance
  342. ========================================
  343. jQuery(document).ready(function(){
  344.  //Check to see if the window is top if not then display button
  345.  jQuery(window).scroll(function(){
  346.   if (jQuery(this).scrollTop() > 200) {
  347.    jQuery('#backtotop').addClass('fixed');
  348.   } else {
  349.    jQuery('#backtotop').removeClass('fixed');
  350.   }
  351.  });
  352.  //Click event to scroll to top
  353.  jQuery('#backtotop').click(function(){
  354.   jQuery('html, body').animate({scrollTop : 0},800);
  355.   return false;
  356.  });
  357. });
  358.  
  359. <!-- Scroll To Top Start Here -->
  360.   <button type="button" id="backtotop">Scroll To Top</button>
  361. <!-- Scroll To Top End There -->
  362.  
  363. /*============== Scroll To Top style ===============*/
  364. button#backtotop {-moz-transition: all 0.5s;-o-transition: all 0.5s;-webkit-transition: all 0.5s;transition: all 0.5s;background: #760000;padding: 0;position: fixed;right: 40px;bottom: -150px;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter: alpha(opacity=0);opacity: 0;width: 40px;color: #fff;font-size: 30px;}
  365. button#backtotop:hover {-webkit-animation: scrolltotop 0.3s infinite linear;-moz-animation: scrolltotop 0.3s infinite linear;-ms-animation: scrolltotop 0.3s infinite linear;animation: scrolltotop 0.3s infinite linear;-moz-transition: 0.2s;-o-transition: 0.2s;-webkit-transition: 0.2s;transition: 0.2s}
  366. button#backtotop.fixed {bottom: 20px;-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter: alpha(opacity=100);opacity: 1;}
  367. button#backtotop:focus {-moz-box-shadow: 0 0 0 0 #fff;-webkit-box-shadow: 0 0 0 0 #fff;box-shadow: 0 0 0 0 #fff;}
  368. @-webkit-keyframes scrolltotop{
  369.         0% {
  370.         transform: translate(0, 0px);
  371.         } 50% {
  372.         transform: translate(0, 5px);
  373.         } 100% {
  374.         transform: translate(0, 0px);
  375.         }
  376. }
  377. @-moz-keyframes scrolltotop{
  378.         0% {
  379.         transform: translate(0, 0px);
  380.         } 50% {
  381.         transform: translate(0, 5px);
  382.         } 100% {
  383.         transform: translate(0, 0px);
  384.         }
  385. }
  386. @keyframes scrolltotop {
  387.     0% {
  388.         transform: translate(0, 0px);
  389.         } 50% {
  390.         transform: translate(0, 5px);
  391.         } 100% {
  392.         transform: translate(0, 0px);
  393.         }
  394.     }
  395.  
  396. // Scroll to section id from navigation
  397. ========================================
  398. reference = https://jsfiddle.net/cse_tushar/Dxtyu/141/
  399.  
  400. --------------------  or  -----------------------
  401. // handle links with @href started with '#' only
  402. $(document).on('click', 'a[href^="#"]', function(e) {
  403.     // target element id
  404.     var id = $(this).attr('href');
  405.     // target element
  406.     var $id = $(id);
  407.     if ($id.length === 0) {
  408.         return;
  409.     }
  410.     // prevent standard hash navigation (avoid blinking in IE)
  411.     e.preventDefault();
  412.     // top position relative to the document
  413.     var pos = $(id).offset().top -150;
  414.     // animated top scrolling
  415.     $('body, html').animate({scrollTop: pos});
  416. });
  417. reference = http://jsfiddle.net/dizel3d/1eamwt4e/
  418. ----------- or -------------------
  419.  
  420. $(function() {
  421.     $('a[href*=#]:not([href=#])').click(function() {
  422.         var target = $(this.hash);
  423.         target = target.length ? target : $('[name=' + this.hash.substr(1) +']');
  424.         if (target.length) {
  425.             $('html,body').animate({
  426.               scrollTop: target.offset().top - 150
  427.             }, 1000);
  428.             return false;
  429.         }
  430.     });
  431. });
  432. reference = http://stackoverflow.com/questions/19012495/smooth-scroll-to-div-id-jquery
  433. ------------ this is html markup ----------------
  434. <a href="#section1">Go Section 1</a>
  435. <div id="section1">
  436.     <!-- Content goes here -->
  437. </div>
  438.  
  439. // Jquery FancyBox
  440. -------------------------
  441. jQuery(document).ready(function() {
  442. jQuery('.video_play')
  443.   .attr('rel', 'media-gallery')
  444.   .fancybox({
  445.     openEffect : 'none',
  446.     closeEffect : 'none',
  447.     prevEffect : 'none',
  448.     nextEffect : 'none',
  449.    
  450.     arrows : false,
  451.     helpers : {
  452.       media : {},
  453.       buttons : {}
  454.     }
  455.   });
  456. });
  457.  
  458. // singlePageNav Activate  
  459. jQuery(document).ready(function(){
  460.     jQuery('#nav, .slicknav_nav').singlePageNav({
  461.         offset: jQuery('.mainmenu_main_area').outerHeight(),
  462.         filter: ':not(.external)',
  463.     speed : 2000,
  464.         updateHash: false,
  465.     });
  466. });
  467. // For Search hide show
  468. ======================================
  469. jQuery(document).ready(function(){
  470.     jQuery('#search_btn').on('click', function(){
  471.         jQuery(this).toggleClass('active').next('#search_form').toggleClass('active');
  472.     });
  473. });
  474.  
  475. <label id="search_btn" for="search_input"></label>
  476. <div id="search_form" class="fix">
  477.     <input type="text" placeholder="מה ברצונך לחפש?" class="search_input" id="search_input" />
  478.     <input type="submit" value="להגיש" class="search_submit" />
  479. </div>
  480.  
  481. #search_form {opacity: 0;visibility: hidden;}
  482. #search_form.active{opacity: 1;visibility: inherit;}
  483.  
  484.                
  485. // Video Background
  486.  
  487. jQuery(document).ready(function() {
  488.   jQuery('#my-video').backgroundVideo({
  489.     pauseVideoOnViewLoss: false,
  490.     $videoWrap: jQuery('#video-wrap'),
  491.     $outerWrap: jQuery('#outer-wrap'),
  492.     preventContextMenu: true,
  493.     parallaxOptions: {
  494.         offset: -200,
  495.         effect: 1.7
  496.     }
  497.   });
  498. });
  499.  
  500. // Contact Form Page
  501. jQuery(document).ready(function() {
  502.   // Add Captcha Wrapper Div
  503.     jQuery('img.captcha_image').wrap('<div class="captcha_code fix"></div>');
  504.   // Add Input Radio Wrapper Div
  505.     jQuery('input[type=radio]').wrap('<div class="radio_button fix"></div>');
  506.   // Radio Check to Add Remove Class
  507.   jQuery('input[type=radio]').on('click', function () {
  508.     jQuery(this).parents(".radio_button").addClass("checked");
  509.     jQuery('input[type=radio]').each(function () {
  510.       jQuery(this).is(':checked') ? jQuery(this).parents(".radio_button").addClass('checked') :             jQuery(this).parents(".radio_button").removeClass('checked');
  511.         });
  512.     });
  513. });
  514.  
  515.  
  516. // Volenteer Radio Button
  517. jQuery(document).ready(function() {
  518.   // Add Input Radio Wrapper Div
  519.     jQuery('#location_select input[type=radio], #agree_select input[type=checkbox]').wrap('<div class="radio_button fix"></div>');
  520.   jQuery('.radio_button').append('<span class="radio_check">[ ]</span>');
  521.   // Radio Check to Add Remove Class
  522.   jQuery('#location_select input[type=radio], #agree_select input[type=checkbox]').on('click', function () {
  523.     jQuery(this).parents(".radio_button").addClass("checked").children('span.radio_check').text('[✓]');
  524.     jQuery('#location_select input[type=radio], #agree_select input[type=checkbox]').each(function () {
  525.       jQuery(this).is(':checked') ? jQuery(this).parents(".radio_button").addClass('checked').children('span.radio_check').text('[✓]') :          jQuery(this).parents(".radio_button").removeClass('checked').children('span.radio_check').text('[ ]');
  526.         });
  527.     });
  528.   // Add Input Radio Wrapper Div
  529.     jQuery('.donation_form input[type=radio]').wrap('<div class="radio_button2 fix"></div>');
  530.   jQuery('.radio_button2').append('<span class="radio_check"></span>');
  531.   // Radio Check to Add Remove Class
  532.   jQuery('.donation_form input[type=radio]').on('click', function () {
  533.     jQuery(this).parents(".radio_button2").addClass("checked");
  534.     jQuery('.donation_form input[type=radio]').each(function () {
  535.       jQuery(this).is(':checked') ? jQuery(this).parents(".radio_button2").addClass('checked') :            jQuery(this).parents(".radio_button2").removeClass('checked');
  536.         });
  537.     });
  538. });
  539.  
  540. --------------------------------------------
  541. // Radio Button Wrrapper Funciton
  542. jQuery(function () {
  543.   jQuery('div.payment_form1 input[type=radio]').wrap('<span class="radio_wrrap"></span>').addClass('amount_radio');
  544. });
  545.  
  546. // Amount Select Option
  547. jQuery(function () {
  548.     jQuery('input.amount_radio').on('click', function () {
  549.         jQuery(this).parents("span.radio_wrrap").addClass("active");
  550.         jQuery('input.amount_radio').each(function () {
  551.             jQuery(this).is(':checked') ? jQuery(this).parents("span.radio_wrrap").addClass('active') : jQuery(this).parents("span.radio_wrrap").removeClass('active');
  552.         });
  553.     });
  554. });
  555. reference link https://www.ot-st.co.il/payment/
  556. --------------------------------------
  557. // Styled Select Option
  558. jQuery('select').each(function () {
  559.     // select variable
  560.     var $this = jQuery(this), numberOfOptions = jQuery(this).children('option').length;
  561.     // Hide select option
  562.     $this.addClass('select_hidden');
  563.     // Add Select Option Wrapper
  564.     $this.wrap('<div class="select fix"></div>');
  565.     // Add New select menu div
  566.     $this.after('<div class="select_styled fix"></div>');
  567.     // select menu Variable
  568.     var $styledSelect = $this.next('div.select_styled');
  569.     // Menu text variable
  570.     var menuText = $this.children('option').eq(0).text();
  571.     // add text to select menu
  572.     $styledSelect.text(menuText);
  573.     // Add New list
  574.     var $list = jQuery('<ul />',{
  575.         'class' : 'select_options fix'
  576.     }).insertAfter($styledSelect);
  577.     // Add list items
  578.     for (i = 0; i < numberOfOptions; i++) {
  579.         jQuery('<li />', {
  580.             text : $this.children('option').eq(i).text(),
  581.             rel : $this.children('option').eq(i).val(),
  582.         }).appendTo($list);
  583.     };
  584.     // List item variable
  585.     var $listItem = $list.children('li');
  586.     // select menu click to open/close list
  587.     $styledSelect.click(function(e) {
  588.         e.stopPropagation();
  589.         jQuery(this).toggleClass('active').next('ul.select_options').slideToggle();
  590.     });
  591.     // List item click to close menu
  592.     $listItem.click(function(e) {
  593.         e.stopPropagation();
  594.         // add Text in select menu and removeClass
  595.         $styledSelect.text(jQuery(this).text()).removeClass('active');
  596.         // update select option value
  597.         $this.val(jQuery(this).attr('rel'));
  598.         // and Close list
  599.         $list.slideUp();
  600.     });
  601.     // Document Click to styled select removeClass and list slideUp
  602.     jQuery(document).click(function () {
  603.         $styledSelect.removeClass('active');
  604.         $list.slideUp();
  605.     });
  606. });
  607.  
  608. // List Arrow Addd
  609. jQuery(document).ready(function() {
  610.   jQuery('.single_news_wedget ul li a').prepend('<i class="fa fa-caret-right"></i>');
  611.   jQuery(".single_focus_slid>a.learn_more, .news_exarpt_cont a.news_link").each(function(){
  612.       jQuery(this).appendTo(jQuery(this).prev('p'));
  613.   });
  614. });
  615.  
  616.  
  617. // Mobile Menu Bg Effect
  618. jQuery(document).ready(function() {
  619.     jQuery('a.slicknav_btn').click(function() {
  620.         parentsdiv = jQuery(this).parents('div.header_content_area');
  621.         if(parentsdiv.hasClass('fixed')) {
  622.             parentsdiv.find('div.head_bg').removeClass('mmenu');
  623.         } else {
  624.             parentsdiv.find('div.head_bg').addClass('mmenu');
  625.         }
  626.        
  627.     });
  628. });
  629.  
  630. ===============================================
  631. JQuery Basic code
  632. ===============================================
  633. $(document).ready(function(){
  634.     $('#nav').slicknav();
  635.    
  636.    
  637.   $(".slider_area").click(function(){
  638.     $(".header_area").addClass("main_header");
  639.   });
  640.    
  641.    
  642.   $(".cross_button").click(function(){
  643.     $(".fixed_advert").hide(50000);
  644.   });
  645.    
  646.     $(".testimonials-title h3").click(function(){
  647.     $(this).animate({fontSize:"50px"});
  648.   });
  649.  
  650.     jQuery(".tab-pane:first-child").addClass("active");
  651.     jQuery(".nav-tabs li:first-child").addClass("active");
  652.                      
  653. });
  654.  
  655. =========================
  656.  ajax page link
  657. =========================
  658. $(document).ready(function() {
  659.     $("header").find('a').on('click', function(e){
  660.      e.preventDefault();
  661.      ver linkloc = $(this).attr('href');
  662.      $('#content').load('template/'+linkloc);
  663.     });
  664.    });
  665. --------------------------------------------------------
  666. /**
  667.  * Javascript-Equal-Height-Responsive-Rows
  668.  * https://github.com/Sam152/Javascript-Equal-Height-Responsive-Rows
  669.  */
  670. (function($){'use strict';$.fn.equalHeight=function(){var heights=[];$.each(this,function(i,element){var $element=$(element);var elementHeight;var includePadding=($element.css('box-sizing')==='border-box')||($element.css('-moz-box-sizing')==='border-box');if(includePadding){elementHeight=$element.innerHeight();}else{elementHeight=$element.height();}
  671. heights.push(elementHeight);});this.css('height',Math.max.apply(window,heights)+'px');return this;};$.fn.equalHeightGrid=function(columns){var $tiles=this.filter(':visible');$tiles.css('height','auto');for(var i=0;i<$tiles.length;i++){if(i%columns===0){var row=$($tiles[i]);for(var n=1;n<columns;n++){row=row.add($tiles[i+n]);}
  672. row.equalHeight();}}
  673. return this;};$.fn.detectGridColumns=function(){var offset=0,cols=0,$tiles=this.filter(':visible');$tiles.each(function(i,elem){var elemOffset=$(elem).offset().top;if(offset===0||elemOffset===offset){cols++;offset=elemOffset;}else{return false;}});return cols;};var grids_event_uid=0;$.fn.responsiveEqualHeightGrid=function(){var _this=this;var event_namespace='.grids_'+grids_event_uid;_this.data('grids-event-namespace',event_namespace);function syncHeights(){var cols=_this.detectGridColumns();_this.equalHeightGrid(cols);}
  674. $(window).bind('resize'+event_namespace+' load'+event_namespace,syncHeights);syncHeights();grids_event_uid++;return this;};$.fn.responsiveEqualHeightGridDestroy=function(){var _this=this;_this.css('height','auto');$(window).unbind(_this.data('grids-event-namespace'));return this;};})(window.jQuery);
  675.  
  676. /*for activation*/
  677. <script type="text/javascript">
  678.     jQuery(function($) {
  679.         $('.element').responsiveEqualHeightGrid(); 
  680.     });
  681. </script>
  682.  
  683.    /* =========  or we can use  ================== */
  684.    
  685.    
  686. /* Simple jQuery Equal Heights */
  687. !function(a){a.fn.equalHeights=function(){var b=0,c=a(this);return c.each(function(){var c=a(this).innerHeight();c>b&&(b=c)}),c.css("height",b)},a("[data-equal]").each(function(){var b=a(this),c=b.data("equal");b.find(c).equalHeights()})}(jQuery);
  688.  
  689. /*for activation*/
  690. <script>
  691.     jQuery('#equalheight div').equalHeights();
  692. </script>
  693.  
  694. ---------------------------------------------------------
  695.  
  696. /* ========================================
  697.     Isotop portfolio dropdown category
  698. ========================================*/
  699.  
  700. jQuery( function () {
  701.     jQuery('.ui--custom-menu-bar').prepend('<ul class="filter_title"></ul>');
  702.     jQuery('ul.portfolio-filters').find('li.title-item').appendTo('.filter_title');
  703.     jQuery('ul.portfolio-filters').wrap('<div class="filters_dropdown"></div>');
  704.     var first_title = jQuery('.portfolio-filters').find('li:first-child>a').text();
  705.     jQuery('.filters_dropdown').prepend('<div class="dropdown_head"><div class="dropdown_title"></div><i class="ui--caret fontawesome-angle-down px18"></i></div>');
  706.     jQuery('.dropdown_title').text(first_title);
  707.     jQuery('ul.portfolio-filters>li>a').click(function() {
  708.         var livetext = jQuery(this).text();
  709.         jQuery('.dropdown_title').text(livetext);
  710.     });
  711. });
  712.  
  713. reference link http://sinus-dairy.dk.linux68.unoeuro-server.com/cases/
  714.  
  715.  
  716. /* ========================================
  717.    Video Area when click video thumb play specific area video with auto replace through thumb Video
  718. ========================================*/
  719.     jQuery('a.video_link').on('click', function(ev) {
  720.         var vidlink = jQuery(this).attr('href');
  721.         var videoid = vidlink.match(/(?:https?:\/{2})?(?:w{3}\.)?youtu(?:be)?\.(?:com|be)(?:\/watch\?v=|\/)([^\s&]+)/);
  722.         jQuery(this).parents('div.recent_lesson_content').find("#lesson_video")[0].src = "https://www.youtube.com/embed/"+ videoid[1] +"?rel=0&autoplay=1";
  723.         ev.preventDefault();
  724.     });
  725.    
  726. // and html markup is
  727. ------------------------------
  728. <div class="recent_lesson_content fix">
  729.     <div class="recent_lesson_big fix">
  730.         <iframe id="lesson_video" width="420" height="315" src="https://www.youtube.com/embed/NG37uE6rbWU" frameborder="0" allowfullscreen></iframe>
  731.     </div>
  732.     <div class="recent_lesson_smalls fix">
  733.         <div class="reles_small fix">
  734.             <a href="https://www.youtube.com/watch?v=Eq8SK5Ay5ZY" class="video_link fix">
  735.                 <img src="<?php echo get_template_directory_uri(); ?>/img/recent_lesson2.png" alt="" />
  736.             </a>
  737.         </div>
  738.         <div class="reles_small fix">
  739.             <a href="https://www.youtube.com/watch?v=Eq8SK5Ay5ZY" class="video_link fix">
  740.                 <img src="<?php echo get_template_directory_uri(); ?>/img/recent_lesson2.png" alt="" />
  741.             </a>
  742.         </div>
  743.     </div>
  744. </div>
  745.  
  746. // And css
  747. --------------
  748. .recent_lesson{}
  749. .recent_lesson .upcm_event_head h3{
  750.     color: #2DB673;
  751. }
  752. .recent_lesson_content{}
  753. .recent_lesson_big{
  754.     margin-bottom: 15px;
  755. }
  756. iframe#lesson_video{
  757.     width: 100%;
  758.     height: 250px;
  759. }
  760. .recent_lesson_big img{
  761.     display: block;
  762.     width: 100%;
  763. }
  764. .recent_lesson_smalls{}
  765. .reles_small{
  766.     float: left;
  767.     width: 48%;
  768.     margin-bottom: 15px;
  769.     margin-right: 4%;
  770. }
  771. .reles_small:nth-child(2n+2){
  772.     margin-right: 0px;
  773. }
  774. .reles_small img{
  775.     display: block;
  776. }
  777.  
  778.  
  779. reference link http://www.jew-tahana.co.il/
  780.  
  781. /*  insert one div to another dive */
  782. jQuery("span.ginput_total").prependTo(".prdpage_addcart_area"); /*  insert one div to another dive into first*/
  783. jQuery("span.ginput_total").appendTo(".prdpage_addcart_area"); /*  insert one div to another dive into last*/
  784.  
  785. jquery-detect-apple-touch-devices.js
  786. ===========================================
  787. jQuery(document).ready(function($){
  788.     var deviceAgent = navigator.userAgent.toLowerCase();
  789.     var agentID = deviceAgent.match(/(iphone|ipod|ipad)/);
  790.     if (agentID) {
  791.  
  792.         // mobile code here
  793.  
  794.     }
  795. });
  796.  
  797. /* Isotope Jquery */
  798. -----------------------
  799.  jQuery(window).load(function() {
  800.     var $container = jQuery('#container'),
  801.         filters = {};
  802.     $container.isotope({
  803.       itemSelector : '.isotope_item',
  804.       masonry: {
  805.         columnWidth: 0
  806.       }
  807.     });
  808.     // filter buttons
  809.     jQuery('.filter .filter_list').click(function(){
  810.       var $this = jQuery(this);
  811.       // don't proceed if already selected
  812.       if ( $this.hasClass('active') ) {
  813.         return;
  814.       }
  815.       var $optionSet = $this.parents('.option-set');
  816.       // change selected class
  817.       $optionSet.find('.active').removeClass('active');
  818.       $this.addClass('active');
  819.       // store filter value in object
  820.       // i.e. filters.color = 'red'
  821.       var group = $optionSet.attr('data-filter-group');
  822.       filters[ group ] = $this.attr('data-filter-value');
  823.       // convert object into array
  824.       var isoFilters = [];
  825.       for ( var prop in filters ) {
  826.         isoFilters.push( filters[ prop ] )
  827.       }
  828.       var selector = isoFilters.join('');
  829.       $container.isotope({ filter: selector });
  830.       return false;
  831.     });
  832.   });
  833.  
  834. /*--- Mixit up lightbox gallery for each Category  ---*/
  835. jQuery('#gallery_tabs li').click(function(){
  836.     var selector = jQuery(this).attr('data-filter-value');
  837.     if(selector == "*"){
  838.      jQuery(".gallery_light").attr("data-fancybox-group", "gallery");
  839.     } else{
  840.      jQuery(selector).find(".gallery_light").attr("data-fancybox-group", selector);
  841.     }
  842. });
  843.  
  844.  
  845. ==================================
  846. solve conflick slick slider into bootstrap tab content
  847. ------------------------------------------------------
  848. jQuery('[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  849.         jQuery('.tab_slider').slick('setPosition');
  850.     });
  851.  
  852. ==================================
  853. solve conflick slick slider into magnific popup content
  854. ------------------------------------------------------
  855. $('a.open-popup-post').magnificPopup({
  856.   type:'inline',
  857.   midClick: true,
  858.      callbacks: {
  859.  
  860.       open: function() {
  861.         $('#post_slider').slick('setPosition');
  862.         var slideIndex = this.index;
  863.         console.log(slideIndex);
  864.         setTimeout(function() {
  865.  
  866.           $('.slider-products').slick('slickGoTo', parseInt(slideIndex), true);
  867.         }, 100);
  868.  
  869.       },
  870.  
  871.       change: function() {
  872.         $('#post_slider').slick('setPosition');
  873.         var slideIndex = this.index;
  874.         console.log(slideIndex);
  875.         setTimeout(function() {
  876.  
  877.           $('#post_slider').slick('slickGoTo', parseInt(slideIndex), true);
  878.         }, 100);
  879.  
  880.  
  881.       }
  882.     }
  883. });
  884.  
  885.  
  886. // sidemenu auto full as document height
  887. =======================================
  888. jQuery('#rightmenu').css('height', jQuery(document).height());;
  889.  jQuery(document).resize(function(){
  890.     jQuery('#rightmenu').css('height', jQuery(document).height());
  891. });
  892.  
  893. // bx slider carousel responsive
  894. =============================
  895.     var maxSlides,
  896.     width = jQuery(window).width();
  897.  
  898. if (width < 430) {
  899.     maxSlides = 1;
  900. } else {
  901.     maxSlides = 3;
  902. }
  903.  
  904. var myslider = jQuery('.bxslider-inside').bxSlider({
  905.     slideWidth: 250,
  906.     minSlides: 1,
  907.     maxSlides: maxSlides,
  908.     pager:false
  909. });
  910.  
  911. // event handlers for captions  for slick slider.
  912.    // On before slide change
  913.     $('#kingcarosel_slider').on('beforeChange', function(event, slick, currentSlide, nextSlide){
  914.         $( '.show_item_text' ).hide();
  915.         $( '[data-slick-index = ' + nextSlide + '] .show_item_text' ).show('slow');
  916.     });
  917.     $('#kingcarosel_slider').on('afterChange', function(event, slick, currentSlide, nextSlide){
  918.  
  919.     });
  920.     // show 1st caption on page load
  921.   $( '.show_item_text' ).css('width','290px');
  922.   $( this ).children().find( '.slick-current .show_item_text' ).show();
Advertisement
Add Comment
Please, Sign In to add comment