PluginProbe
MyBookTable Bookstore by Stormhill Media / trunk
MyBookTable Bookstore by Stormhill Media vtrunk
3.6.5 trunk
mybooktable / js / frontend.js

frontend.js in MyBookTable Bookstore by Stormhill Media trunk, at js/frontend.js

90 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function() {
2
3 /*---------------------------------------------------------*/
4 /* Shadow Boxes */
5 /*---------------------------------------------------------*/
6
7 jQuery('.mbt-shadowbox-inline').each(function(i, e) { jQuery(e).colorbox({inline:true, scrolling:false, transition:'none', href: jQuery(e).attr('data-href')}); });
8 jQuery('.mbt-shadowbox-iframe').each(function(i, e) { jQuery(e).colorbox({iframe:true, scrolling:true, transition:'none', width:"80%", height:"80%", href: jQuery(e).attr('data-href')}); });
9
10 /*---------------------------------------------------------*/
11 /* Find Bookstore Form */
12 /*---------------------------------------------------------*/
13
14 if(window.google) {
15 var geocoder = new google.maps.Geocoder();
16 var formtimer = null;
17
18 function mbt_update_bookstore_form(form) {
19 form.find('[type="submit"]').prop('disabled', true);
20 window.clearTimeout(formtimer);
21 formtimer = setTimeout(function() {
22 var city = form.find('.mbt-city').val();
23 var zip = form.find('.mbt-zip').val();
24
25 geocoder.geocode({ 'address': city + " " + zip }, function(results, status) {
26 if(status == google.maps.GeocoderStatus.OK) {
27 var lat = results[0].geometry.location.lat();
28 var lng = results[0].geometry.location.lng();
29 var url = "https://www.google.com/maps/search/bookstore/@"+lat+","+lng+",14z";
30 form.attr('action', url);
31 form.find('[type="submit"]').prop('disabled', false);
32 }
33 });
34 }, 1000);
35 }
36
37 jQuery('form.mbt-find-bookstore-form').each(function(i, e) {
38 var form = jQuery(e);
39
40 var updatefn = function() { mbt_update_bookstore_form(form); }
41 form.find('.mbt-city').on('input', updatefn);
42 form.find('.mbt-zip').on('input', updatefn);
43
44 form.submit(function() {
45 window.open(form.attr('action'), "", "");
46 return false;
47 });
48 });
49 }
50
51 /*---------------------------------------------------------*/
52 /* Social Media Buttons */
53 /*---------------------------------------------------------*/
54
55 jQuery('.mbt-book .mbt-book-share-buttons .mbt-book-share-button').click(function() {
56 window.open(jQuery(this).attr('href'), '_blank','height=500,width=500');
57 return false;
58 });
59
60 /*---------------------------------------------------------*/
61 /* Smooth Scroll to same id as url hash on click */
62 /*---------------------------------------------------------*/
63
64 // NOT Working MBT button scroll funtion
65 // jQuery('.mbt-book a').click(function() {
66 // var href = jQuery(this).attr("href");
67 // var hash = href.substr(href.indexOf("#"));
68 // jQuery('html, body').animate({ scrollTop: jQuery(".mbt-book-purchase-section").offset().top - 300}, 700);
69 // return false;
70 // });
71
72 // Working MBT button scroll funtion
73 /*
74 $(document).ready(function(){
75 jQuery( "a.mbt-book-purchase-button" ).click(function( event ) {
76 event.preventDefault();
77 jQuery("html, body").animate({ scrollTop: jQuery(jQuery(this).attr("#mbt-book-purchase-anchor")).offset().top - 300}, 500);
78 });
79 });
80 */
81 jQuery(document).ready(function($){
82 jQuery('a.mbt-book-purchase-button').attr("type","button");
83 $('a.mbt-book-purchase-button').click(function(e){
84 e.preventDefault();
85 $('html, body').animate({scrollTop: $('.mbt-book-purchase-section').offset().top - 100}, 500);
86 });
87 return false;
88 });
89 });
90