1(function ($, window) { 2 "use strict"; 3 4 // Responsive Navigation Menu 5 //--------------------------------------------// 6 function bpxl_responsive_menu() { 7 $(".st-menu ul li").has('ul').prepend("<span class='side-sub-menu'><i class='fa fa-angle-down'></i></span>"); 8 9 $('.st-menu ul li .side-sub-menu').on("click", function(){ 10 $(this).next().next().slideToggle(300); 11 if ($(this).children().hasClass('fa-angle-down')) { 12 $(this).children().removeClass('fa-angle-down').addClass('fa-angle-up'); 13 } else { 14 $(this).children().removeClass('fa-angle-up').addClass('fa-angle-down'); 15 } 16 }); 17 18 $(".menu-btn").click(function(e){ 19 e.preventDefault(); 20 e.stopPropagation(); 21 $("html").toggleClass("openNav"); 22 }); 23 24 $(document).on( 'click', function ( e ) { 25 var mouseclick = $(e.target); 26 //console.log(mouseclick); 27 if ( mouseclick.hasClass('st-menu') || mouseclick.parents().hasClass('st-menu') || mouseclick.parents().hasClass('side-sub-menu') ) { 28 return; 29 } 30 else { 31 $('html').removeClass("openNav"); 32 } 33 } ); 34 }; 35 36 // Tabs 37 //--------------------------------------------// 38 function bpxl_tabs() { 39 "use strict"; 40 $("#tabs li").click(function() { 41 $("#tabs li").removeClass('active'); 42 $(this).addClass("active"); 43 $(".tab-content").hide(); 44 var selected_tab = $(this).find("a").attr("href"); 45 $(selected_tab).fadeIn(); 46 return false; 47 }); 48 }; 49 50 // Back to Top Button 51 //--------------------------------------------// 52 function bpxl_scroll_top() { 53 var offset = 220; 54 var duration = 500; 55 $(window).scroll(function() { 56 if ($(this).scrollTop() > offset) { 57 $('.back-to-top').fadeIn(duration); 58 } else { 59 $('.back-to-top').fadeOut(duration); 60 } 61 }); 62 63 $('.back-to-top').on("click", function(event){ 64 event.preventDefault(); 65 $('html,body').animate({scrollTop: 0}, duration); 66 return false; 67 }) 68 }; 69 70 // Fitvids 71 //--------------------------------------------// 72 function bpxl_fitvids() { 73 $("body").fitVids( { 74 customSelector: [ 75 "iframe[src*='youtu.be']", 76 "iframe[src*='soundcloud.com']", 77 "iframe[src*='mixcloud.com']", 78 "iframe[src*='blip.tv']", 79 "iframe[src*='dailymotion.com']", 80 "iframe[src*='spotify.com']", 81 "iframe[src*='slideshare.net']", 82 ] 83 } ); 84 $( ".wp-video-shortcode, .wp-audio-shortcode" ).css( 'max-width', '100%' ); 85 }; 86 87 // Open Social Share Buttons in Popup Window 88 //--------------------------------------------// 89 function bpxl_social_window() { 90 $('.social-btn a').click(function(e) { 91 var className = $(this).attr('class'); 92 if ( className != 'fa fa-whatsapp' ) { 93 e.preventDefault(); 94 window.open($(this).attr('href'), '', 'height=450, width=550, top=' + ($(window).height() / 2 - 275) + ', left=' + ($(window).width() / 2 - 225) + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=1'); 95 return false; 96 } 97 }); 98 }; 99 100 // Header Slider 101 //--------------------------------------------// 102 function bpxl_header_slider() { 103 $('.header-slider').imagesLoaded(function () { 104 $('.header-slider').flexslider({ 105 animation: "fade", 106 pauseOnHover: true, 107 controlNav: true, 108 directionNav: false, 109 prevText: "", 110 nextText: "", 111 touch: true, 112 start: function(slider) { 113 $('.header-slider').removeClass('loading'); 114 } 115 }); 116 }); 117 }; 118 119 // Widget Slider 120 //--------------------------------------------// 121 function bpxl_widget_slider() { 122 $('.widgetslider').imagesLoaded(function () { 123 $('.widgetslider').flexslider({ 124 animation: "fade", 125 pauseOnHover: true, 126 controlNav: false, 127 prevText: "<i class='fa fa-angle-left'></i>", 128 nextText: "<i class='fa fa-angle-right'></i>", 129 touch: true, 130 start: function(slider) { 131 $('.widgetslider').removeClass('loading'); 132 } 133 }); 134 }); 135 }; 136 137 // Featured Slider 138 //--------------------------------------------// 139 function bpxl_featured_slider() { 140 $('.featuredslider').imagesLoaded(function () { 141 $('.featuredslider').flexslider({ 142 animation: "fade", 143 pauseOnHover: true, 144 controlNav: true, 145 prevText: "<i class='fa fa-angle-left'></i>", 146 nextText: "<i class='fa fa-angle-right'></i>", 147 touch: true, 148 initDelay: 5000, 149 start: function(slider) { 150 $('.featuredslider').removeClass('loading'); 151 } 152 }); 153 }); 154 }; 155 156 // Gallery Slider 157 //--------------------------------------------// 158 function bpxl_gallery_slider() { 159 $('.galleryslider').imagesLoaded(function () { 160 $('.galleryslider').flexslider({ 161 animation: "fade", 162 pauseOnHover: true, 163 directionNav: true, 164 controlNav: true, 165 prevText: "<i class='fa fa-angle-left'></i>", 166 nextText: "<i class='fa fa-angle-right'></i>", 167 touch: true, 168 start: function(slider) { 169 $('.galleryslider').removeClass('loading'); 170 } 171 }); 172 }); 173 } 174 175 // Masonry 176 //--------------------------------------------// 177 function bpxl_masonry_layout() { 178 if ( goblog_masonry.enabled == 1 ) { 179 var container = jQuery('.masonry').imagesLoaded(function() { 180 container.masonry({ 181 itemSelector : '.masonry article', 182 columnWidth : '.grid-sizer', 183 isAnimated : true, 184 gutter: '.gutter-sizer', 185 percentPosition: true 186 }); 187 }); 188 } 189 } 190 191 function bpxl_scripts() { 192 bpxl_responsive_menu(); 193 bpxl_tabs(); 194 bpxl_scroll_top(); 195 bpxl_fitvids(); 196 bpxl_social_window(); 197 bpxl_header_slider(); 198 bpxl_widget_slider(); 199 bpxl_featured_slider(); 200 bpxl_gallery_slider(); 201 bpxl_masonry_layout(); 202 } 203 204 $(document).ready(bpxl_scripts); 205})(jQuery, window); 206 207jQuery(document).ready(function($) { 208 ajaxMailChimpForm($("#mc-embedded-subscribe-form"), $(".subscribe-result")); 209 // Turn the given MailChimp form into an ajax version of it. 210 // If resultElement is given, the subscribe result is set as html to 211 // that element.
212 function ajaxMailChimpForm($form, $resultElement){ 213 // Hijack the submission. We'll submit the form manually. 214 $form.attr("action"); 215 $form.submit(function(e) { 216 e.preventDefault(); 217 if (!isValidEmail($form)) { 218 var error = "A valid email address must be provided."; 219 $resultElement.html(error); 220 $resultElement.css("color", "red"); 221 } else { 222 $resultElement.html("Subscribing..."); 223 var url=$form.attr('action'); 224 console.log(url); 225 if (url=='') { 226 $resultElement.css("color", "red"); 227 $resultElement.html("Please add mailchimp form URL for this widget"); 228 return false; 229 } else { 230 url=url.replace('subscribe/post', 'subscribe/post-json'); 231 } 232 submitSubscribeForm($form, $resultElement, url); 233 } 234 }); 235 } 236 // Validate the email address in the form 237 function isValidEmail($form) { 238 // If email is empty, show error message. 239 // contains just one @ 240 var email = $form.find("input[type='email']").val(); 241 if (!email || !email.length) { 242 return false; 243 } else if (email.indexOf("@") == -1) { 244 return false; 245 } 246 return true; 247 } 248 // Submit the form with an ajax/jsonp request. 249 // Based on http://stackoverflow.com/a/15120409/215821 250 function submitSubscribeForm($form, $resultElement, $url) { 251 $.ajax({
252 type: "GET", 253 url: $url, 254 data: $form.serialize(), 255 cache: false, 256 dataType: "jsonp", 257 jsonp: "c", // trigger MailChimp to return a JSONP response 258 contentType: "application/json; charset=utf-8", 259 error: function(error){ 260 // According to jquery docs, this is never called for cross-domain JSONP requests 261 }, 262 success: function(data){ 263 if (data.result != "success") { 264 var message = data.msg || "Sorry. Unable to subscribe. Please try again later."; 265 $resultElement.css("color", "green"); 266 if (data.msg && data.msg.indexOf("already subscribed") >= 0) { 267 message = "You're already subscribed. Thank you."; 268 } 269 $resultElement.html(message); 270 } else { 271 $resultElement.html("Thank you!<br>You must confirm the subscription in your inbox."); 272 } 273 } 274 }); 275 } 276});
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.