1 2 3// jQUERY READY 4jQuery(document).ready(function() 5{ 6 jQuery(document).delegate('.awesome-weather-form', 'submit', function(e) 7 { 8 var this_form = jQuery(this); 9 var js_slug = this_form.data('js-slug'); 10 var city_slug = this_form.data('slug'); 11 var user_location = this_form.children('input').val(); 12 13 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout .awesome-weather-blankout-error').hide(); 14 15 if( user_location ) 16 { 17 // SHOW LOADING 18 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout .awe-loading').show(); 19 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-form').hide(); 20 21 22 var widget_obj = awe['awe_weather_widget_json_' + js_slug]; 23 widget_obj.longlat_location = "0"; 24 widget_obj.user_location = user_location; 25 26 27 // PASS WEATHER OBJECT BACK THROUGH THE SYSTEM 28 jQuery.post(awe['ajaxurl'], widget_obj, function(response) 29 { 30 if( response == "false" ) 31 { 32 awesome_weather_show_form( city_slug ); 33 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout .awesome-weather-blankout-error').show(); 34 } 35 else 36 { 37 // SPIT BACK THE RESULTS IN THE CONTAINER 38 jQuery("#awesome-weather-" + city_slug ).replaceWith( response ); 39 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout .awesome-weather-blankout-error').hide(); 40 } 41 42 // SET COOKIE OF CITY ID 43 var new_city_id = jQuery(".awesome-weather-form[data-js-slug='" + js_slug + "']").data('city-id'); 44 Cookies.set('awe_city_id', new_city_id, { expires: 7 } ); 45 46 // STOP LOADING 47 awe_stop_loading(); 48 }); 49 } 50 51 e.preventDefault(); 52 }); 53 54 55 // WEATHER TRIGGER 56 jQuery(document).delegate('.awe-weather-trigger a', 'click', function(e) 57 { 58 59 console.log(awe); 60 61 var this_btn = jQuery(this); 62 this_btn.addClass('loading'); 63 64 var js_slug = this_btn.data('js-slug'); 65 var city_slug = this_btn.data('slug'); 66 67 jQuery('#awesome-weather-' + city_slug + ' .awe-weather-bubble').hide(); 68 69 70 // SHOW LOADING 71 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout').show(); 72 73 74 // CHECK IF HTML5 GEOLOCATION IS AVAILABLE 75 if (navigator.geolocation) 76 { 77 // GET POSITION 78 navigator.geolocation.getCurrentPosition(awesome_weather_set_location, awesome_weather_show_form_to_user); 79 } 80 else 81 { 82 // NO GEO LOCATION, SHOW FORM 83 awesome_weather_show_form( city_slug ); 84 } 85 86 function awesome_weather_show_form_to_user() 87 { 88 awesome_weather_show_form( city_slug ); 89 } 90 91 function awesome_weather_set_location(position) 92 { 93 // SAVE LOCATION AND REFRESH 94 var widget_obj = awe['awe_weather_widget_json_' + js_slug]; 95 96 97 // ADD IP LOCATION TO NEW WEATHER OBJECT 98 widget_obj.longlat_location = position.coords.latitude + "," + position.coords.longitude; 99 widget_obj.longlat_triggered = "1"; 100 101 // PASS WEATHER OBJECT BACK THROUGH THE SYSTEM 102 jQuery.post(awe['ajaxurl'], widget_obj, function(response) 103 { 104 // SPIT BACK THE RESULTS IN THE CONTAINER 105 jQuery("#awesome-weather-" + city_slug ).replaceWith( response ); 106 107 108 // SET COOKIE OF CITY ID 109 var new_city_id = jQuery(".awesome-weather-form[data-js-slug='" + js_slug + "']").data('city-id'); 110 Cookies.set('awe_city_id', new_city_id, { expires: 7 }); 111 112 113 // STOP LOADING 114 awe_stop_loading(); 115 }); 116 } 117 118 e.preventDefault(); 119 return false; 120 }); 121 122 function awesome_weather_show_form( city_slug ) 123 { 124 awe_stop_loading( city_slug ); 125 126 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-form').show(); 127 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-form input').focus(); 128 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout').show(); 129 130 jQuery(document).delegate('#awesome-weather-' + city_slug + ' .awesome-weather-blankout', 'click', function(e) 131 { 132 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-form').hide(); 133 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout').hide(); 134 }); 135 } 136 137 function awe_stop_loading( city_slug ) 138 { 139 jQuery('#awesome-weather-' + city_slug + ' .awesome-weather-blankout .awe-loading').hide(); 140 } 141 142 143});
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.