1(function( $ ) { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 */ 8 $(document).ready(function($) { 9 10 var weblink_connect = { 11 12 prev_next: '', 13 nonce: '', 14 pid: '', 15 16 /** 17 * Initialize 18 * Which API are we working with? 19 */ 20 init:function(){ 21 22 var self = this; 23 if($('.weblink-events').length){ 24 this.calendar(); 25 } 26 else{ 27 //this.ajax_links(); 28 //this.keyword_search(); 29 //this.pager(); 30 31 /*$('.allcat').click(function(){ 32 console.log('allcat'); 33 $('#business-directory .cats').css({'display':'grid'}); 34 $('#business-directory .listings').remove(); 35 return false; 36 });*/ 37 38 $('.directory-listing .wlc_more a.more-open').click(function(){ 39 $(this).parent().find('.wlc_descr').toggle(); 40 return false; 41 }); 42 43 $('.wlc_contact_form').click(function(e){ 44 e.preventDefault(); 45 var postid = $(this).parent().parent().parent().data('postid'); 46 self.openEmailForm(postid); 47 }); 48 49 //referrals 50 $('.directory-listing').each(function(){ 51 var profile_id = $(this).data('profile-id'); 52 var listing_id = $(this).data('listing-id'); 53 54 if(profile_id == 1){ 55 // console.log('pid: '+profile_id); 56 // console.log('lid: '+listing_id); 57 self.referral('Directory',profile_id,listing_id); 58 } 59 }); 60 /* $('.directory-listing .more-open').click(function(){ 61 var profile_id = $(this).parent().parent().data('profile-id'); 62 console.log(profile_id); 63 if(profile_id == 1){ 64 self.referral('LD',profile_id); 65 } 66 });*/ 67 68 69 //dupe search results fix 70 if($('section#content').length==2){ 71 $('section#content').each(function(i,elem){ 72 //console.log(i); 73 if(i==1){ 74 $(elem).remove(); 75 } 76 }); 77 } 78 //console.log($('#sidebar').length); 79 if($('#sidebar').length==2){ 80 $('#sidebar').each(function(i,elem){ 81 //console.log(i); 82 if(i==1){ 83 $(elem).remove(); 84 } 85 }); 86 } 87 if($('#sidebar-2').length==2){ 88 $('#sidebar-2').each(function(i,elem){ 89 //console.log(i); 90 if(i==1){ 91 $(elem).remove(); 92 } 93 }); 94 } 95 if($('main#site-content').length==2){ 96 $('main#site-content').each(function(i,elem){ 97 //console.log(i); 98 if(i==1){ 99 $(elem).remove(); 100 } 101 }); 102 } 103 } 104 105 }, 106 107 /** 108 * HANDLE AJAX CALLS 109 * @param params 110 */ 111 ajax:function(params,callback){ 112 var self = this; 113 //params.action = 'weblink_connect_do_ajax_request'; 114 115 var options = { 116 url : weblink_connect_params.ajaxurl, 117 method: "POST", 118 //async: false, 119 data: params, 120 }; 121 122 $.ajax(options).success(function(success) { 123 //console.log(success); 124 }).error(function(err) { 125 console.log('err: '+JSON.stringify(err)); 126 console.log(options); 127 console.log(arguments); 128 }).complete(function(data){ 129 var response = data.responseXML; 130 console.log(response); 131 response = $( response ).find( 'response_data' ).text(); 132 //console.log(response); 133 callback(response); 134 135 //callback(data); 136 }); 137 138 }, 139 140 /*** 141 * Referrals 142 */ 143 referral:function(referralType,pid,lid){ 144 console.log(weblink_connect_params); 145 var self = this; 146 var post_id = $('.directory-listing').parent().attr('id').split("-")[1]; 147 var params = { 148 action: 'wlc_referral', 149 ReferralType: referralType, 150 ProfileID: pid, 151 ListingID: lid, 152 post_id: post_id, 153 nonce: weblink_connect_params.nonce, 154 }; 155 156 self.ajax(params,self['referralHandler']); 157 }, 158 159 referralHandler:function(response){ 160 console.log(response); 161 }, 162 163 /*** 164 * Full Calendar 165 */ 166 calendar:function(){ 167 $('#calendar').fullCalendar({ 168 events: $.parseJSON($('#scheduleSource').val()), 169 header: { 170 left: 'prev,next today', 171 center: 'title', 172 right: 'month,agendaWeek,list' 173 }, 174 defaultView: 'month', 175 views: { 176 list: { 177 type: 'agenda', 178 duration: { days: 30 }, 179 }, 180 agendaDay: { 181 182 } 183 }, 184 /* viewRender: function(view,element) { 185 var d = new Date(); // for now 186 var h = d.getHours(); 187 if(h>=12){h = h - 12;} 188 if(h<10){ h = '0'+h; } 189 var nowTR = $('tr [data-time="'+h+':00:00"]'); 190 var new_position = $(nowTR).offset(); 191 $(view.scroller.scrollEl).stop().animate({ scrollTop: new_position.top }, 500); 192 },*/ 193 displayEventEnd:true, 194 eventRender: function(event, element) { 195 //console.log(event); 196 //console.log(element); 197 element.attr('title', event.title); 198 $(element).css({'background-color':event.color,'color':'#fff'}); 199 $(element).find('.fc-time').html(event.startTime); 200 201 return ($("input[type=checkbox][id=et-null]").is(":checked") && null == event.eventtype) 202 || 203 ($("input[type=checkbox][id=et-1Berkshire]").is(":checked") && 204 null != event.eventtype && 205 event.eventtype.indexOf("1Berkshire") >= 0) 206 || 207 ($("input[type=checkbox][id=et-Community]").is(":checked") && 208 null != event.eventtype && 209 event.eventtype.indexOf("Community") >= 0); 210 211 /*|| 212 ( $("input[type=checkbox][id=ct-Org]").is(":checked") && 213 null != event.eventtype && 214 (event.eventtype.indexOf("1Berkshire") >= 0 215 || null == event.eventtype) 216 ) 217 || 218 ( $("input[type=checkbox][id=ct-Community]").is(":checked") && 219 null != event.eventtype && 220 event.eventtype.indexOf("Community") >= 0 221 ); 222 */ 223 224 }, 225 //event info on click 226 eventClick: function(info) { 227 console.log(info); 228 if($('#evt_dialog').length){ 229 $('#evt_dialog').remove(); 230 } 231 var dialog = $('<div/>',{'id':'evt_dialog','title':info.title}) 232 .append($('<div/>').html(info.descr)); 233 $('body').append($(dialog)); 234 $('#evt_dialog').dialog({ 235 minWidth: $(window).width() / 2 236 }); 237 238 } 239 }); 240 241 $('#gotodate').change(function(){ 242 var date = $(this).val(); 243 if(''==date){ 244 $('.fc-today-button').click(); 245 } 246 else{ 247 $('#calendar').fullCalendar('changeView', 'agendaDay', date); 248 } 249 }); 250 251 $('#eventtype input[type="checkbox"]').change(function(){ 252 $('#calendar').fullCalendar('rerenderEvents'); 253 }); 254 }, 255 256 /*** 257 * Email Submission to Business Listing 258 */ 259 openEmailForm:function(postid){ 260 var self = this; 261 if($('#email_dialog').length){ 262 $('#email_dialog').remove(); 263 } 264 265 var org = $('div[data-postid="'+postid+'"] h2').html(); 266 $('body').append($('<div/>',{'id':'email_dialog', 'title':'Send a Message'})); 267 $('#email_dialog') 268 /*** 269 * DEV 270 */ 271 .append($('<span/>',{'id':'d_wlc_org'}).html('To: '+org+'<br/><span style="color:red">In Development Mode - Emails only sent to [email protected]')) 272 /***DEV */ 273 //.append($('<span/>',{'id':'d_wlc_org'}).html('To: '+org)) 274 .append($('<label/>',{'for':'wlc_name'}).html('Name <span style="color:red">*</span>')) 275 .append($('<input/>',{'id':'wlc_name','type':'text','required':'required'})) 276 .append($('<label/>',{'for':'wlc_email'}).html('Email <span style="color:red">*</span>')) 277 .append($('<input/>',{'id':'wlc_email','type':'email','required':'required'})) 278 .append($('<label/>',{'for':'wlc_msg'}).html('Message')) 279 .append($('<textarea/>',{'id':'wlc_msg'})) 280 .append($('<div/>',{'id':'wlc_mail_status'}).css({'color':'red'})); 281 282 var art_post_id = $('article.business-directory').attr('id').split("-")[1]; 283 $( "#email_dialog" ).dialog({ 284 width: 500, 285 buttons: [ 286 { 287 text: "Submit", 288 icon: "ui-icon-email", 289 click: function() { 290 var params = { 291 action: 'wlc_send_email', 292 name: $('#wlc_name').val(), 293 email: $('#wlc_email').val(), 294 message: $('#wlc_msg').val(), 295 postid: postid, 296 post_id: art_post_id, 297 nonce: weblink_connect_params.nonce, 298 }; 299 300 if(params.name=='' || params.email==''){ 301 $('#wlc_mail_status').html('Missing Required Field(s)'); 302 } 303 else{ 304 305 $('#email_dialog') 306 .empty() 307 .append($('<div/>').html('Sending...')); 308 $('.ui-dialog-buttonset button').remove(); 309 310 self.ajax(params,self['emailSubmitHandler']); 311 } 312 } 313 } 314 ] 315 }); 316 }, 317 318 emailSubmitHandler:function(response){ 319 console.log(response); 320 $('#email_dialog') 321 .empty() 322 .append($('<div/>').html(response)); 323 setTimeout(function(){ 324 $( "#email_dialog" ).dialog( "close" ); 325 },3000); 326 /* $('body').append($('<div/>',{'id':'email_dialog', 'title':'Message Status'})); 327 $('#email_dialog').append($('<div/>').html(response)); 328 $( "#email_dialog" ).dialog({ 329 width: 500, 330 buttons: [ 331 { 332 text: "Close", 333 icon: "ui-icon-email", 334 click: function() { 335 $( this ).dialog( "close" ); 336 $('#email_dialog').remove(); 337 } 338 } 339 ] 340 }); 341 */ 342 } 343 344 345 }; 346 347 weblink_connect.init(); 348 }); 349 350})( jQuery );
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.