1jQuery(function($) { 2 //Start of popup form onload 3 $(document).ready(function() { 4 if (($("body.page-node-1").length > 0)) { //page-node-1 = HomePage 5 if (($("#home_special_announcement").length == 0)) { //Disable this Announcement if the [Custom Block: (Home) Special Announcement] shown 6 var html2 = ''; 7 var title = ''; 8 var content = ''; 9 var webform_id = ''; 10 var url = ''; 11 var url_title = ''; 12 var show_popup = true; 13 //var spec = '_blank'; 14 //var replace = 'width=1024, height=768'; 15 16 $.ajax({ 17 type: "GET", 18 url: "/announcement_listing?_format=json", 19 cache: false, 20 beforeSend: function() {}, 21 success: function(data) { 22 if (data.length > 0) { 23 title = data[0]["title"]; 24 content = data[0]["field_description"]; 25 webform_id = data[0]["field_webform_id"]; 26 url = data[0]["field_url"]; 27 url_title = data[0]["field_url_title"]; 28 29 html2 += '<div id="home_special_announcement" style="overflow:auto;" class="lity-hide">'; 30 html2 += '<h2>' + title + '</h2>'; 31 html2 += content; 32 33 //Start of Link Proc 34 if (url != '') { 35 //If this is webform 36 if (webform_id != '') { 37 //If Login 38 if (drupalSettings.user.uid > 0) { 39 $.ajax({
40 type: "GET", 41 url: "/check_my_webform_submit?_format=json&webform_id=" + webform_id, 42 cache: false, 43 beforeSend: function() {}, 44 success: function(data1) { 45 //if (webform complate) 46 if (data1.length > 0) { 47 ///hide the popup 48 show_popup = false; 49 } else { 50 //show the [Login hint msg] & link 51 show_popup = true; 52 html2 += '<div class="hint_msg_in_announcement">'; 53 html2 += 'ç±æ¼é£ä¸å·²ç»è¨æå¡, 宿åå·èª¿æ¥å¾æç²å¾ç©å'; 54 html2 += '</div>'; 55 56 html2 += '<div class="link_in_announcement">'; 57 //html2 += '<a onclick="window.open(\'' + url + '\', \'' + spec + '\', \'' + replace + '\')">' + url_title + '</a>'; 58 html2 += '<button class="windows-popup" popup-url="' + url + '">' + url_title + '</button>' 59 html2 += '</div>'; 60 } 61 62 html2 += '</div>'; 63 if ((html2 != '') && (show_popup)) { 64 html2 += '<a class="btn open_home_special_announcement" href="#home_special_announcement" data-lity>Open home_special_announcement</a>'; 65 $(".page-node-1").append(html2); 66 setTimeout( 67 function() { 68 //alert("open .open_home_special_announcement (1)"); 69 $( ".open_home_special_announcement" ).trigger( "click" ); 70 }, 71 2000); 72 } 73 }, 74 error: function(data1) {}, 75 complete: function() {} 76 }) 77 } else { 78 //show the [Non-login hint msg] & link 79 show_popup = true; 80 html2 += '<div class="hint_msg_in_announcement">'; 81 html2 += 'ç±æ¼é£ä¸æªç»è¨æå¡, å䏿ç²å¾ç©å'; 82 html2 += '</div>'; 83 84 html2 += '<div class="link_in_announcement">'; 85 //html2 += '<a onclick="window.open(\'' + url + '\', \'' + spec + '\', \'' + replace + '\')">' + url_title + '</a>'; 86 html2 += '<button class="windows-popup" popup-url="' + url + '">' + url_title + '</button>' 87 html2 += '</div>'; 88 89 html2 += '</div>'; 90 if ((html2 != '') && (show_popup)) { 91 html2 += '<a class="btn open_home_special_announcement" href="#home_special_announcement" data-lity>Open home_special_announcement</a>'; 92 $(".page-node-1").append(html2); 93 setTimeout( 94 function() { 95 //alert("open .open_home_special_announcement (2)"); 96 $( ".open_home_special_announcement" ).trigger( "click" ); 97 }, 98 2000); 99 } 100 } 101 102 } else { 103 //Link only 104 html2 += '<div class="link_in_announcement"><a href="' + url + '">' + url_title + '</a></div>'; 105 106 html2 += '</div>'; 107 if ((html2 != '') && (show_popup)) { 108 html2 += '<a class="btn open_home_special_announcement" href="#home_special_announcement" data-lity>Open home_special_announcement</a>'; 109 $(".page-node-1").append(html2); 110 setTimeout( 111 function() { 112 //alert("open .open_home_special_announcement (3)"); 113 $( ".open_home_special_announcement" ).trigger( "click" ); 114 }, 115 2000); 116 } 117 } 118 } else { 119 120 html2 += '</div>'; 121 if ((html2 != '') && (show_popup)) { 122 html2 += '<a class="btn open_home_special_announcement" href="#home_special_announcement" data-lity>Open home_special_announcement</a>'; 123 $(".page-node-1").append(html2); 124 setTimeout( 125 function() { 126 //alert("open .open_home_special_announcement (4)"); 127 $( ".open_home_special_announcement" ).trigger( "click" ); 128 }, 129 2000); 130 } 131 } 132 //End of Link Proc 133 } 134 }, 135 error: function(data) {}, 136 complete: function() {} 137 }); 138 } 139 } 140 });
141 142 //End of popup form onload 143 144 145 //Start of popup windows handling 146 //REF: https://www.jnorton.co.uk/check-if-popup-window-closed 147 148 var win; 149 $(document).ready(function () { 150 $('body').on('click', '.link_in_announcement .windows-popup', function() { 151 var popup_url = $(this).attr("popup-url"); 152 if (popup_url != "") { 153 _open_popup(popup_url); 154 } 155 }); 156 }); 157 158 159 160 function _open_popup(url) { 161 var left = (screen.width / 2); 162 var top = (screen.height / 2); 163 var popWidth = 1024; 164 var popHeight = 768; 165 var popTop = top - popHeight / 2; 166 var popLeft = left - popWidth / 2; 167 if (win && !win.closed) { //checks to see if window is open 168 win.focus(); 169 } else { 170 win = window.open(url, 'e123_popup_windows', 'height=' + popHeight + ',width=' + popWidth + ',resizeable=0, top=' + popTop + ', left=' + popLeft); 171 win.focus(); 172 } 173 } 174 175 function _waiting_for_close() { 176 if (win && win.closed) { 177 clearInterval(timer); 178 /////alert('popup window is closed.'); 179 $( ".lity-close" ).trigger( "click" ); 180 } 181 } 182 var timer = setInterval(_waiting_for_close, 2000); 183 184 185 /** 186 * This javascript file checks for the brower/browser tab action. 187 * It is based on the file menstioned by Daniel Melo. 188 * Reference: http://stackoverflow.com/questions/1921941/close-kill-the-session-when-t... 189 */ 190 var validNavigation = false; 191 192 function _end_session() { 193 // Browser or broswer tab is closed 194 // Do sth here ... 195 if (win !== undefined) { 196 win.close(); 197 } 198 /////alert("Browser window closed"); 199 } 200 201 // Wire up the events as soon as the DOM tree is ready 202 $(document).ready(function() { 203 _wire_up_events(); 204 }); 205 206 207 function _wire_up_events() { 208 /* 209 * For a list of events that triggers onbeforeunload on IE 210 * check http://msdn.microsoft.com/en-us/library/ms536907(VS.85).aspx 211 */ 212 window.onbeforeunload = function() { 213 if (!validNavigation) { 214 _end_session(); 215 } 216 } 217 218 // Attach the event keypress to exclude the F5 refresh 219 $('html').bind('keypress', function(e) { 220 if (e.keyCode == 116) { 221 validNavigation = true; 222 } 223 }); 224 225 // Attach the event click for all links in the page 226 $("a").bind("click", function() { 227 validNavigation = true; 228 }); 229 230 // Attach the event submit for all forms in the page 231 $("form").bind("submit", function() { 232 validNavigation = true; 233 }); 234 235 // Attach the event click for all inputs in the page 236 $("input[type=submit]").bind("click", function() { 237 validNavigation = true; 238 }); 239 } 240 241 //End of popup windows handling 242});
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.