1jQuery(function($) { 2 3 "use strict"; 4 5 /* SHOW MORE FOR (NEWS, ARTICLES AND SHARES) */ 6 $(".showMoreButton").on("click", function(event){ 7 event.preventDefault(); 8 9 var $pageNews = $(".pageNews"), 10 $showMore = $(this); 11 12 $.ajax({ 13 url: site_dir + "dev/moreNews.php", 14 type: "post", 15 dataType: "html", 16 data: $pageNews[0].dataset, 17 beforeSend: function(){ 18 $showMore.addClass("fade"); 19 $(".moreAnimation").css({"display": "block"}); 20 }, 21 success: function(data){ 22 $pageNews.attr("data-page", Number($pageNews.attr("data-page")) + 1); 23 24 if(Number($pageNews.attr("data-page")) >= Number($pageNews.attr("data-pageEnd"))) 25 $showMore.parent().fadeOut(); 26 27 $(".allNews").append(data); 28 $showMore.removeClass("fade"); 29 $(".moreAnimation").css({"display": "none"}); 30 }, 31 error: function(textStatus){ 32 console.log(textStatus); 33 } 34 }); 35 }); 36 37 /* OPEN / CLOSE BUTTONS SHARE */ 38 var flip = 0; 39 $(".leftShareButton", ".leftShare").on("click", function(){ 40 $(".modalShare").toggle(flip++ % 2 === 0); 41 }); 42 43 /* OPENING / CLOSING CONTACTS ON THE CARD */ 44 $(".mapContacts", ".map").on("click", function(){ 45 var $this = $(this); 46 47 ($this.hasClass("open") ? $this.removeClass("open") : $this.addClass("open")); 48 }); 49 50 /* ON / OFF CHECKED PERSONAL INFO */ 51 $(".personalInfo").on("click", "label", function(event){ 52 if(event.target.nodeName != "A") 53 { 54 var $this = $(this); 55 56 if($this.hasClass("ckecked")) 57 $this.removeClass("ckecked"); 58 else 59 { 60 $this.addClass("ckecked"); 61 $(".checkboxError").css({"display": "none"}); 62 } 63 } 64 }); 65 66 67/*------------------------ 68--- MODAL WINDOWS --- 69------------------------*/ 70 71 /* Adding classes (styles) if INPUT or DIV.MESSAGEFIELD is not empty */ 72 $(".inputField, .messageField").on("focus", function(){ 73 var $parent = $(this).parent(); 74 75 if(!$parent.hasClass("changeInput")) 76 $parent.addClass("changeInput").css({"margin-bottom": "-=" + 1}); 77 }); 78 79 $(".inputField, .messageField").on("focusout", function(){ 80 var $this = $(this), 81 $parent = $this.parent(); 82 83 if($this.val() != "" || $this.text() != "") 84 $parent.addClass("changeInput"); 85 else 86 { 87 $parent.removeClass("changeInput").css({"margin-bottom": "+=" + 1}); 88 $("span", $parent).html(""); 89 } 90 }); 91 92 93 var $header = $("header"), 94 $blackBack = $("#blackBack"), 95 $body = $("body"); 96 97 98 /* CLOSING MODAL BLOCKS */ 99 $(".modalClose").on("click", function(){ 100 var $this = $(this); 101 102 setTimeout(function() 103 { 104 $header.css({"right": ""}); 105 $blackBack.css({"display": "none"}); 106 $this.parents(".sendForm").css({"right": "", "display": "none"}); 107 $body.removeClass("modalOpen").attr("style", ""); 108 }, 150); 109 }); 110 111 112 /* OPENING MODAL BLOCKS */ 113 $(".modalButton").on("click", function(){ 114 var $this = $(this), 115 $modalBlock = $("form[data-form="+ $this.attr("data-id") +"]"); 116 117 if($this.attr("data-name") != "") 118 $("input[name='nameElement']", $modalBlock).val($this.attr("data-name")); 119 120 setTimeout(function() 121 { 122 $header.css({"right": "17px"}); 123 $blackBack.css({"display": "block"}); 124 $modalBlock.css({"display": "block"}); 125 $body.addClass("modalOpen"); 126 127 if($(window).height() >= $modalBlock.children().outerHeight(true)) 128 $modalBlock.css({"right": "17px"}); 129 130 if($(window).height() < $body.height()) 131 $body.css({"paddingRight": "17px"}); 132 }, 150); 133 }); 134 135 136 /* SITE FOLDER */ 137 var site_dir = $("#siteDir").attr("data-dir"); 138 139 140 /* SEND ALL TYPES OF MESSAGES */ 141 $(".sendForm").on("submit", function(event) 142 { 143 event.preventDefault(); 144 145 var error = false, 146 $modalName = $(this), 147 $submit = $(".modalSend", $modalName), 148 urlForForm = "dev/"+ $modalName.attr("data-form") +".php", 149 objectInput = {"fileID": Number($(".fileID").text()), "userText": $(".messageField", $modalName).html()}, 150 modalInput = $modalName.find(":input"), 151 ymGoal = $modalName.find("input[name=ym_goal]").val(); 152 153 if($(".logo").length) 154 objectInput["urlImg"] = $(".logo img").attr("src"); 155 else 156 objectInput["urlImg"] = $(".logo_detail img").attr("src"); 157 158 modalInput.each(function(){ 159 var $input = $(this), 160 inputParent = $input.parent(); 161 162 if($input.prop("required")) 163 { 164 if(!$input.val()) 165 { 166 inputParent.addClass("errorInput"); 167 error = true; 168 } 169 if($input.attr("name") == "userEmail") 170 { 171 var pattern = /^([a-z0-9_\.-])+@[a-z0-9-]+\.([a-z]{2,4}\.)?[a-z]{2,4}$/i; 172 if(!pattern.test($input.val())) 173 { 174 inputParent.addClass("errorInput"); 175 error = true; 176 } 177 } 178 } 179 if($input.attr("type") == "checkbox") 180 { 181 if(!$input.is(":checked")) 182 { 183 $(".checkboxError").css({"display": "block"}); 184 error = true; 185 } 186 } 187 188 objectInput[$input.attr("name")] = $input.val(); 189 }); 190 191 if(!error) 192 { 193 $.ajax({ 194 url: site_dir + urlForForm, 195 type: "post", 196 dataType: "html", 197 data: objectInput, 198 beforeSend: function(){ 199 $(".buttonAnimation", $modalName).addClass("active"); 200 }, 201 success: function() 202 { 203 if (ymGoal) { 204 try { 205 ym(11335477,'reachGoal', ymGoal); 206 } catch(e) { 207 console.error('Ðе ÑдалоÑÑ Ð¾ÑпÑавиÑÑ ÑÐµÐ»Ñ '+ymGoal+' в Я.ÐеÑÑикÑ'); 208 } 209 } 210 setTimeout(function(){ 211 $(".buttonAnimation", $modalName).removeClass("active").addClass("send"); 212 $modalName.find(".personalInfo").after('<div class="send__success">ÐаÑе ÑообÑение ÑÑпеÑно оÑпÑавлено!</div>'); 213 }, 1500); 214 setTimeout(function(){ 215 if($modalName.attr("data-form") === "sendSummary") 216 $submit.addClass("disabled").attr("disabled", true).val($submit.attr("data-file")); 217 else 218 $submit.val($submit.attr("data-text")); 219 220 $(".buttonAnimation", $modalName).removeClass("send"); 221 }, 3500); 222 223 $("input:not([type='hidden'])", $modalName).val("").removeAttr("checked"); 224 $(".personalInfo label", $modalName).removeClass("ckecked"); 225 $(".fileForm span, .messageField", $modalName).text(""); 226 $modalName.find(".changeInput").removeClass("changeInput").css({"borderBottomWidth": "1px", "margin-bottom": "+=" + 1}); 227 setTimeout(function(){ 228 $modalName.find(".send__success").remove(); 229 }, 6000); 230 }, 231 error: function(textStatus) 232 { 233 console.log(textStatus); 234 } 235 }); 236 } 237 238 }); 239 240 241 /* SAVING FILE */ 242 $(".sendForm").on("change", "input[type='file']", function() 243 { 244 var maxFileSize = 4 * 1024 * 1024, // THE MAXIMUM FILE SIZE IS - 4Mb 245 file = this.files[0], 246 $modalName = $(this).parents(".sendForm"), 247 $inputParent = $(this).parent(), 248 $submit = $(".modalSend", $modalName); 249 250 if(typeof file === "undefined" || file.size > maxFileSize) 251 { 252 $inputParent.addClass("changeInput"); 253 $(".fileForm span", $modalName).text("Max file size 4Mb"); 254 $submit.addClass("disabled").attr("disabled", true).val($submit.attr("data-file")); 255 return false;
256 } 257 258 var fileArray = this.files; 259 var data = new FormData(); 260 $.each(fileArray, function(key, value){ 261 data.append(key, value); 262 }); 263 264 $.ajax({ 265 url: site_dir + "dev/saveFile.php", 266 type: "post", 267 dataType: "json", 268 processData: false, 269 contentType: false, 270 data: data, 271 beforeSend: function(){ 272 $(".buttonAnimation", $modalName).addClass("active"); 273 }, 274 success: function(data) 275 { 276 $(".fileID").html(data[0]); 277 $submit.removeClass("disabled").attr("disabled", false).val($submit.attr("data-text")); 278 $(".buttonAnimation", $modalName).removeClass("active"); 279 $(".fileForm span", $modalName).text(data[1]); 280 $inputParent.addClass("changeInput"); 281 }, 282 error: function(textStatus) 283 { 284 console.log(textStatus); 285 } 286 }); 287 }); 288 289/*------------------------ 290--- MODAL WINDOWS --- 291------------------------*/ 292 293 294/*------------------------ 295--- DIFFERENT SETTINGS --- 296------------------------*/ 297 298 var headerMenu = document.querySelector(".headerMenu"), 299 topSearch = document.getElementById("topSearch"); 300 301 if(typeof headerMenu !== "undefined" && headerMenu !== null) 302 { 303 var parentHeaderMenu = headerMenu.parentNode; 304 if(!parentHeaderMenu.hasAttribute("class")) 305 { 306 parentHeaderMenu.style.float = "right"; 307 $("#topSearch").parent().css({"float": "right"}); 308 } 309 } 310 311 if(typeof topSearch !== "undefined" && topSearch !== null) 312 { 313 var parentTopSearch = topSearch.parentNode; 314 if(!parentTopSearch.hasAttribute("class")) 315 { 316 parentTopSearch.style.float = "right"; 317 } 318 } 319 320 321 /* SCROLL TO THE TOP */ 322 var buttonTop = document.querySelector(".buttonPosition"), 323 duration = 600; 324 325 buttonTop.addEventListener("click", function() { 326 327 var start = performance.now(), 328 from = window.pageYOffset || document.documentElement.scrollTop, 329 to = document.querySelector("body").getBoundingClientRect().top; 330 331 requestAnimationFrame(function animate(time){ 332 var timePassed = time - start; 333 334 if (timePassed > duration) 335 timePassed = duration; 336 337 window.scrollTo(0, from + to * timePassed / duration); 338 339 if (timePassed < duration) 340 requestAnimationFrame(animate); 341 }); 342 }); 343 344 addEventListener("scroll", function(){ 345 var scrollTop = window.pageYOffset || document.documentElement.scrollTop; 346 347 if(scrollTop > 400) 348 { 349 buttonTop.style.bottom = "31px"; 350 /* 351 if(scrollTop > 600) 352 { 353 $buttonMenu.css({"bottom": "100px"}); 354 if(scrollTop > 850) 355 $buttonSearch.css({"bottom": "159px"}); 356 else 357 $buttonSearch.css({"bottom": "-61px"}); 358 } 359 else 360 $buttonMenu.css({"bottom": "-61px"}); 361 */ 362 } 363 else 364 { 365 buttonTop.style.bottom = "-61px"; 366 //$buttonMenu.css({"bottom": "-61px"}); 367 //$buttonSearch.css({"bottom": "-61px"}); 368 } 369 }); 370 371/*------------------------ 372--- DIFFERENT SETTINGS --- 373------------------------*/ 374 375});
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.