1/* Add Custom Code Jquery 2 ========================================================*/ 3 4jQuery(document).ready(function($) { 5 var $demosPreview = $('.so-demos-preview'), 6 $demoTabs = $('.so-demo-tabs'), 7 demosLoad = false, 8 demosShown = false, 9 htmlResponse = ''; 10 $(document).on('click', '.so-show-demos', function(e) { 11 e.preventDefault(); 12 $('body').addClass('so-demos-open'); 13 14 15 if (demosLoad && demosShown) { 16 $demosPreview.addClass('so-preview-open'); 17 //so_init_nanoScroller(); 18 return; 19 } else if (demosLoad && !demosShown) { 20 $demosPreview.addClass('so-preview-open'); 21 $demoTabs.html(htmlResponse); 22 tabs(); 23 lazyload('.so-demo-tab-item.active .so-lazy'); 24 //so_init_nanoScroller(); 25 demosShown = true; 26 return; 27 } else if (!demosLoad && !demosShown) { 28 $demosPreview.addClass('so-preview-open'); 29 so_get_demos(showDemos = true); 30 } 31 }); 32 33 $(document).on('click', '.so-close-demos-preview', function() { 34 $demosPreview.removeClass('so-preview-open'); 35 $('body').removeClass('so-demos-open'); 36 }); 37 $(document).keyup(function(e) { 38 if (e.keyCode === 27) $('.so-close-demos-preview').click(); 39 }); 40 $(document).on('mouseenter mouseleave mousemove', '.so-hover-open', function(e) { 41 lazyload('.so-demos-dropdown-wrapper .so-lazy'); 42 }); 43 44 $(document).on('click', '.so-category-list .so-category-item', function() { 45 var categoryTabId = $(this).attr('id'), 46 tab = $('.so-demo-tab-item[data-tab-id="' + categoryTabId + '"]'); 47 $(this).siblings().removeClass('active'); 48 $(this).addClass('active'); 49 tab.siblings().removeClass('active'); 50 tab.addClass('active'); 51 //so_init_nanoScroller(); 52 lazyload('.so-demo-tab-item.active .so-lazy'); 53 }); 54 var getUrlParameter = function getUrlParameter(sParam) { 55 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 56 sURLVariables = sPageURL.split('&'), 57 sParameterName, i; 58 for (i = 0; i < sURLVariables.length; i++) { 59 sParameterName = sURLVariables[i].split('='); 60 if (sParameterName[0] === sParam) { 61 return sParameterName[1] === undefined ? true : sParameterName[1]; 62 } 63 } 64 }; 65 66 function so_get_demos(showDemos) { 67 $demosPreview.addClass('so-demos-loading'); 68 $.ajax({
69 url: plugin_obj.ajax_url, 70 data: { 71 action: 'get_demos' 72 }, 73 method: "POST", 74 dataType: "html", 75 success: function(response) { 76 htmlResponse = response; 77 demosLoad = true; 78 if (showDemos) { 79 $demoTabs.html(htmlResponse); 80 tabs(); 81 lazyload('.so-demo-tab-item.active .so-lazy'); 82 demosShown = true; 83 } 84 setTimeout(function() { 85 //so_init_nanoScroller(); 86 }, 150); 87 $demosPreview.removeClass('so-demos-loading'); 88 $demosPreview.addClass('so-demos-loaded'); 89 }, 90 error: function() { 91 console.log('ajax error'); 92 } 93 }); 94 } 95 96 function so_init_nanoScroller() { 97 if ($(window).width() < 1024) return; 98 $('.so-scroll').nanoScroller({ 99 paneClass: 'so-scroll-pane', 100 sliderClass: 'so-scroll-slider', 101 contentClass: 'so-scroll-content', 102 preventPageScrolling: false 103 }); 104 } 105 106 function tabs() { 107 var $firstTabEl = $('.so-category-list .so-category-item').first(), 108 firstTabEl_id = $firstTabEl.attr('id'); 109 $firstTabEl.addClass('active'); 110 $('.so-demo-tab-item[data-tab-id="' + firstTabEl_id + '"]').addClass('active'); 111 } 112 113 function lazyload($selector) { 114 var lazy = $($selector); 115 lazy.each(function() { 116 if (!$(this).parent().hasClass('so-image-loaded')) { 117 var ImageSrc = $(this).data('lazy-original'); 118 $(this).attr('src', ImageSrc); 119 $(this).parent().addClass('so-image-loading'); 120 $(this).on('load', function() { 121 $(this).parent().removeClass('so-image-loading'); 122 $(this).parent().addClass('so-image-loaded'); 123 }) 124 } 125 }) 126 } 127 $('body').addClass('so-demos-ready'); 128});;
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.