1// set language to localStorage base on URL - case when user changes the language in the URL 2var lang = GetURLParameter('lang'); 3if (lang === 'en') { 4 localStorage.setItem('language', '?lang=en') 5} else { 6 localStorage.setItem('language', '') 7} 8 9 10function keyboardSearch(e) { 11 if (e.which == 13 || e.keyCode == 13 || e.key === "Enter") { 12 if (event.target.value) { 13 localStorage.setItem('searchKeyword', event.target.value); 14 window.location.href = '/search/' + localStorage.getItem('language'); 15 } 16 } 17} 18 19function clickSearch() { 20 var inputValue = $('#mobile-search-input').val(); 21 if (inputValue) { 22 localStorage.setItem('searchKeyword', inputValue); 23 window.location.href = '/search/' + localStorage.getItem('language'); 24 } 25} 26 27// $(document).ready(function () { 28// var container = $('#cookie-message'); 29// var cookie_cookie = Cookies.get('CookieMessage'); 30// if (cookie_cookie !== 'agreed') { 31// container.fadeIn(); 32// } 33// 34// $('.cookie-agree').on('click', function () { 35// Cookies.set('CookieMessage', 'agreed', {expires: 365}); 36// container.fadeOut(); 37// }); 38// }); 39 40$(function () { 41 var box = $('.left-side-menu'); 42 var button = $('.burger-wrap'); 43 button.on('click', function () { 44 if (!box.hasClass('active')) { 45 box.addClass('active'); 46 button.addClass('open'); 47 } else { 48 box.removeClass('active'); 49 button.removeClass('open'); 50 } 51 }); 52 $('.menu-arrow-left').on('click', function () { 53 $(this).hide(); 54 if ($('body').hasClass('lang1')) { 55 $('.right-side-menu ul.vertical-menu-en').show(); 56 $('.right-side-menu ul.vertical-menu-en').animate({left: 1}, 200, function () { 57 $('.menu-arrow-right').show(); 58 }); 59 } else if ($('body').hasClass('lang2')) { 60 $('.right-side-menu ul.vertical-menu-ro').show(); 61 $('.right-side-menu ul.vertical-menu-ro').animate({left: 1}, 200, function () { 62 $('.menu-arrow-right').show(); 63 }); 64 } 65 }); 66 67 $('.menu-arrow-right').on('click', function () { 68 $(this).hide(); 69 $('.right-side-menu ul').animate({left: 300}, 200, function () { 70 $('.menu-arrow-left').show(); 71 $('.right-side-menu ul').hide(); 72 }); 73 }); 74}); 75 76$(document).mouseup(function (e) { 77 var container = $(".left-side-menu, .burger-wrap, .meta-person-name"); 78 // if the target of the click isn't the container nor a descendant of the container 79 if (!container.is(e.target) && container.has(e.target).length === 0) { 80 container.removeClass('active'); 81 // $('.hovering-box').removeClass('active'); 82 // $('.hovering-box-general').addClass('active'); 83 // $('.year-box').removeClass('active'); 84 $('.mini-popup').removeClass('active'); 85 $('.burger-wrap').removeClass('open'); 86 } 87}); 88 89$(document).mouseup(function (e) { 90 var container = $(".timeline-container, .hovering-box"); 91 // if the target of the click isn't the container nor a descendant of the container 92 if (!container.is(e.target) && container.has(e.target).length === 0) { 93 container.removeClass('active'); 94 $('.hovering-box').removeClass('active'); 95 // $('.hovering-box-general').addClass('active'); 96 $('.year-box').removeClass('active'); 97 } 98}); 99 100// generic GET request function 101function getReq(url, callback) { 102 showLoader(); 103 $.get(url, null, function (res) { 104 var result = $.parseJSON(res); 105 callback(result); 106 hideLoader(); 107 }, 'html'); 108} 109 110$(document).ready(function () { 111 $.ajaxSetup({ 112 error: AjaxError 113 }); 114 115}); 116 117function AjaxError(x, e) { 118 hideLoader(); 119 if (x.status === 0) { 120 alert(' Check Your Network.'); 121 } else if (x.status === 404) { 122 alert('Requested URL not found.'); 123 } else if (x.status === 500) { 124 alert('Internel Server Error.'); 125 } else { 126 alert('Unknow Error.\n' + x.responseText); 127 } 128} 129 130function showLoader() {
131 $('.custom-loader').addClass('show-custom-loader') 132} 133 134function hideLoader() { 135 $('.custom-loader').removeClass('show-custom-loader') 136} 137 138 139/** 140 * @return {string} 141 */ 142function GetURLParameter(sParam) { 143 var sPageURL = window.location.search.substring(1); 144 var sURLVariables = sPageURL.split(/[?&]+/); 145 146 for (var i = 0; i < sURLVariables.length; i++) { 147 var sParameterName = sURLVariables[i].split('='); 148 149 if (sParameterName[0] === sParam) { 150 return sParameterName[1]; 151 } 152 } 153} 154 155function setLanguage(lang) { 156 if (lang === 'en') { 157 localStorage.setItem('language', '?lang=en') 158 } else { 159 localStorage.setItem('language', '') 160 } 161} 162 163function setLocalStorage(key, value) { 164 localStorage.setItem(key, value) 165} 166 167function openVideoModal(movie) { 168 (close || movie) && $('.film-page-wrapper').remove(); 169 170 var lang = localStorage.getItem('language') ? localStorage.getItem('language') : ''; 171 172 // get all movie-information and add each to a 'p' 173 var movieInformation = '<p>No information at the moment.</p>'; 174 if (movie.acf.descriere) { 175 movieInformation = `<p>${movie.acf.descriere}</p>` 176 } 177 // get all movie-tags and add each to a 'a' 178 var movieTags = '<p>N/A</p>'; 179 if (movie.acf.taguri) { 180 movieTags = movie.acf.taguri.map(function (tag) { 181 return `<a href=${"/keywords/" + lang} class="txt-color" onclick="setLocalStorage('keyword',${tag.ID})">${tag.post_title}</a>` 182 }).join(', ') 183 } 184 var locations = '<p>N/A</p>'; 185 var locationPlaceholder = lang === '?lang=en' ? 'Place' : 'Loc'; 186 if (movie.acf.localitati.length > 0) { 187 locations = movie.acf.localitati.map(function (loc) { 188 return `<a href=${"/locations/" + lang} class="txt-color" onclick="setLocalStorage('location',${loc.ID})">${loc.post_title}</a>` 189 }).join(', '); 190 } 191 // get all dvd-collections and add each to a 'a' 192 var colectii = '<p>N/A</p>'; 193 if (movie.acf.colectii) { 194 colectii = movie.acf.colectii.map(function (colectie) { 195 return `<a class="txt-color href="#">${colectie.colectia}</a>` 196 }).join(', ') 197 } 198 199 var peopleAndPossitions = ''; 200 var placeholderPersonPhoto = '/wp-content/themes/sahiavintage/assets_19/portrait.jpg'; 201 var regizor_name = movie.acf.regizor ? movie.acf.regizor.post_title : 'unknown'; 202 203 if (movie.acf.oameni_si_functii) { 204 205 var groupByFunctie = {}; 206 var functieAndPersoaneList = []; 207 movie.acf.oameni_si_functii.forEach(function (om_si_functie) { 208 if (groupByFunctie[om_si_functie.functie.post_title]) { 209 groupByFunctie[om_si_functie.functie.post_title].persoane.push(om_si_functie.persoana) 210 } else { 211 groupByFunctie[om_si_functie.functie.post_title] = { 212 functie: [om_si_functie.functie.post_title], 213 persoane: [om_si_functie.persoana] 214 }; 215 } 216 }); 217 218 for (var functie in groupByFunctie) { 219 functieAndPersoaneList.push(groupByFunctie[functie]) 220 } 221 222 peopleAndPossitions = functieAndPersoaneList.map(function (functieSiPersoane) { 223 224 var oameni = functieSiPersoane.persoane.map(function (persoana) { 225 var personPhoto = (persoana.acf && persoana.acf.poza && persoana.acf.poza.sizes) 226 ? persoana.acf.poza.sizes.medium : placeholderPersonPhoto; 227 228 return `<span class="meta-person-name txt-color" onclick="modalTogglePerson(this)">${persoana.post_title}` + 229 '<div class="mini-popup">' + 230 ' <div class="person-photo-col">' + 231 ' <div class="person-photo"' + 232 ` style="background-image: url(${personPhoto})"></div>` + 233 ` <div class="person-name">${persoana.post_title}</div>` + 234 ' </div>' + 235 ` <div class="person-info"><p>${persoana ? persoana.acf.descriere : ''}</p>` + 236 ' </div>' + 237 ' </div>' + 238 `</span>` 239 }).join(', '); 240 241 return '<div class="film-meta-row">' + 242 `<div class="meta-name">${functieSiPersoane.functie}</div>` + 243 `<div class="meta-content meta-content-popup">${oameni}</div>` + 244 '</div>'; 245 }).join(''); 246 } 247 var acf = movie.acf; 248 // console.log(movie); 249 250 var regizorPhoto = acf.regizor ? (acf.regizor.acf.poza ? acf.regizor.acf.poza.sizes.medium : placeholderPersonPhoto) : 'Unknown'; 251 var videoDetailsHtml = 252 `<div class="film-page-wrapper mCustomScrollbar" data-mcs-theme="dark" style="display: block;
252 background-image: url(${movie.acf.afis ? movie.acf.afis.sizes.medium_large : ''})">` + 253 '<div class="film-page-close" onclick="closeVideoModal();">' + 254 '<img src="/wp-content/themes/sahiavintage/assets_19/close.png" alt="x button">' + 255 '</div>' + 256 '<div class="play-btn" onclick="playVideo()">' + 257 // `<img src=${movie.acf.afis.sizes.large} alt="background">` + 258 '</div>' + 259 '<div class="film-page-footer">' + 260 261 '<div class="film-page-scroll">' + 262 `<div class="film-page-title"><span class="title-string" style="margin-right:15px"> ${movie.title.rendered}</span>` + 263 `<span data-link="/film/?movie=${movie.id}${lang === 'en' || lang === '?lang=en' ? '&lang=en' : ''}" onclick="shareLink(this)" class="movie-share-link notify-tooltip" style="width: 115px; display: inline-block; vertical-align: sub;"> 264 <span class="tooltiptext">Link copiat!</span> 265 <svg id="Layer_1" style="overflow:inherit; width: 115px;" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 224.67 64.6"> 266 <defs> 267 <style> 268 269 </style> 270 </defs> 271 <title>Copiaza link</title> 272 <path class="svg-lang" 273 d="M88.41,28.63a1.71,1.71,0,0,1-.72.87L68.83,42.8,53.45,53.65a2.1,2.1,0,0,1-.47.26.61.61,0,0,1-.88-.5,2.8,2.8,0,0,1,0-.52Q52,45.45,52,38c0-.1,0-.19,0-.3h-.22c-2.6,0-5.19,0-7.79.1-1.9.07-3.79.24-5.68.44A47.17,47.17,0,0,0,29.58,40a28.88,28.88,0,0,0-8,3.64,18.58,18.58,0,0,0-6.7,7.76l-.08.14c0-.08,0-.11,0-.14a35.92,35.92,0,0,1,1.62-10.26,28.74,28.74,0,0,1,8.08-12.62,36,36,0,0,1,9.38-6.12,50.59,50.59,0,0,1,10.57-3.46,59.36,59.36,0,0,1,6.5-1l1-.09c0-.11,0-.2,0-.3Q52,10.76,52,4a2.12,2.12,0,0,1,.06-.56A.58.58,0,0,1,52.83,3a2,2,0,0,1,.56.28L66.74,12.7,87.69,27.4a1.74,1.74,0,0,1,.72.86Z" 274 transform="translate(0 -3.01)"/> 275 <text style="font-size: 44px;" class="svg-lang" transform="translate(97.87 43.29) scale(0.97 1)">SHARE</text> 276 </svg> 277 </span>` + 278 279 `</div>` + 280 '<div class="film-page-meta-title meta-content-popup">' + 281 `<span class="name meta-person-name txt-color" onclick="modalTogglePerson(this)">${regizor_name}` + 282 '<div class="mini-popup position-left">' + 283 ' <div class="person-photo-col">' + 284 ' <div class="person-photo"' + 285 ` style="background-image: url(${regizorPhoto})"></div>` + 286 ` <div class="person-name">${acf.regizor ? acf.regizor.acf.post_title : 'Unknown'}</div>` + 287 ' </div>' + 288 ` <div class="person-info"><p>${acf.regizor ? acf.regizor.acf.descriere : 'Unknown'}</p>` + 289 ' </div>' + 290 ' </div>' + 291 `</span> / ` + 292 `<a href=${"/timeline/" + lang} class="film-year txt-color" onclick="setLocalStorage('year',${acf.an.ID})">${acf.an.post_title}</a> / ` + 293 `<span class="film-duration">${acf.durata}min</span> / <span class="film-duration">${acf.tip_film}</span>` + 294 '</div>' + 295 296 '<div class="film-page-content">' + 297 '<div class="left-side">' + 298 `<div class="film-excerpt">${movieInformation}</div>` + 299 '</div>' + 300 '<div class="right-side">' + 301 `${peopleAndPossitions}` + 302 '<div class="film-meta-row">' + 303 `<div class="meta-name">${locationPlaceholder}:</div>` + 304 '<div class="meta-content">' + 305 `${locations}` + 306 '</div>' + 307 '</div>' + 308 '<div class="film-meta-row">' + 309 '<div class="meta-name field-name"><span class="lang1">Tag</span><span class="lang2">Tag</span>:</div>' + 310 '<div class="meta-content">' + 311 `${movieTags}` + 312 '</div>' + 313 '</div>' + 314 '<div class="film-meta-row">' + 315 `<div class="meta-name"><span class="lang1">Collection</span><span class="lang2">Colectie</span>:</div>` + 316 `<div class="meta-content">${colectii}</div>` + 317 '</div></div></div></div></div></div>'; 318 319 320 // `<div id="fb-root"></div>`+ 321 322 // <!-- Your share button code --> 323 // `<div class="fb-share-button" data-href="https://www.your-domain.com/your-page.html" data-layout="button_count">`+ 324 // `</div>`+ 325 326 // var getImageName = function() { 327 // document.onclick = function(e) { 328 // if (e.target.tagName == 'IMG') { 329 // var image = e.target.getAttribute("src"); 330 // alert(image); 331 // } 332 // } 333 // } 334 335 // (function(d, s, id) { 336 // var js, fjs = d.getElementsByTagName(s)[0]; 337 // if (d.getElementById(id)) return; 338 // js = d.createElement(s); js.id = id; 339 // js.src = "https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.0"; 340 // fjs.parentNode.insertBefore(js, fjs); 341 // }(document, 'script', 'facebook-jssdk')); 342 343 // window.fbAsyncInit = function() { 344 // FB.init({appId: 'YOUR APP ID', status: true, cookie
344: true, 345 // xfbml: true}); 346 // }; 347 // (function() { 348 // var e = document.createElement('script'); e.async = true; 349 // e.src = document.location.protocol + 350 // '//connect.facebook.net/en_US/all.js'; 351 // document.getElementById('fb-root').appendChild(e); 352 // }()); 353 354 // $(document).ready(function(){ 355 // $('#share_button').click(function(e){ 356 // e.preventDefault(); 357 // FB.ui( 358 // { 359 // method: 'feed', 360 // name: 'This is the content of the "name" field.', 361 // link: 'http://www.groupstudy.in/articlePost.php?id=A_111213073144', 362 // picture: 'http://www.groupstudy.in/img/logo3.jpeg', 363 // caption: 'Top 3 reasons why you should care about your finance', 364 // description: "What happens when you don't take care of your finances? Just look at our country -- you spend irresponsibly, get in debt up to your eyeballs, and stress about how you're going to make ends meet. The difference is that you don't have a glut of taxpayersâ¦", 365 // message: "" 366 // }); 367 // }); 368 // }); 369 370 $('.main-wrapper').append(videoDetailsHtml); 371 372 var windowWidth = window.innerWidth; 373 374 $(window).resize(function () { 375 windowWidth = window.innerWidth; 376 if (windowWidth > 1170) { 377 $(".content").mCustomScrollbar(); 378 } 379 }); 380 381 if (windowWidth > 1170) { 382 $(".content").mCustomScrollbar(); 383 } 384 385 if (movie.acf.vimeo_id) { 386 options = { 387 id: movie.acf.vimeo_id, 388 // responsive: true, 389 // background: true, 390 byline: false, 391 controls: true, 392 portrait: false, 393 title: false, 394 playsinline: true, 395 transparent: false 396 }; 397 videoPlayer = new Vimeo.Player('movieClip', options); 398 videoPlayer.loadVideo(movie.acf.vimeo_id); 399 $('#movieClip').fadeIn(); 400 401 videoPlayer.on('pause', function () { 402 $('.film-page-wrapper').fadeIn(); 403 }) 404 405 // player.pause().then(function() { 406 // // the video was paused 407 // }).catch(function(error) { 408 // switch (error.name) { 409 // case 'PasswordError': 410 // // the video is password-protected and the viewer needs to enter the 411 // // password first 412 // break; 413 // 414 // case 'PrivacyError': 415 // // the video is private 416 // break; 417 // 418 // default: 419 // // some other error occurred 420 // break; 421 // } 422 // }); 423 } 424 425 $('.film-page-wrapper').on('scroll', function () { 426 // $('.scroll-page').addClass('scroll-hidden'); 427 setTimeout(function () { 428 $('.scroll-page .scroll-icon').animate({bottom: -100}, 200); 429 }, 500); 430 }); 431 432 $(window).resize(function () { 433 mainWrapperX = $('.main-wrapper').width(); 434 if (mainWrapperX > 1500) { 435 $('.scroll-icon-horizontal').hide(); 436 } else { 437 $('.scroll-icon-horizontal').show(); 438 } 439 }); 440} 441 442function shareLink(e) { 443 // console.log(e.attributes['data-link'].value); 444 445 $(e).find('.tooltiptext').addClass("fadeInOut"); 446 setTimeout(function(){$(e).find('.tooltiptext').removeClass("fadeInOut");}, 2000); 447 448 var copyElement = document.createElement("textarea"); 449 copyElement.style.position = 'fixed'; 450 copyElement.style.opacity = '0'; 451 copyElement.textContent = window.location.origin + e.attributes['data-link'].value; 452 var body = document.getElementsByTagName('body')[0]; 453 body.appendChild(copyElement); 454 copyElement.select(); 455 document.execCommand('copy'); 456 body.removeChild(copyElement); 457} 458 459function modalTogglePerson(elem) { 460 return // TODO remove for the people mmodal to be displayed 461 var miniPopup = $(elem).find('.mini-popup'); 462 if (!$(miniPopup).hasClass('active')) { 463 $('.mini-popup').removeClass('active'); 464 miniPopup.addClass('active'); 465 } else { 466 miniPopup.removeClass('active'); 467 } 468} 469 470 471///////////////////// catalin 2024 472let isMobile = ('ontouchstart' in document.documentElement && /mobi/i.test(navigator.userAgent)); 473if (isMobile) { 474 if (document.getElementById('mobile-categorie-swiper')) { 475 document.getElementById('mobile-categorie-swiper').style.removeProperty('display'); 476 document.getElementById('mobile-categorie-swiper').style.visibility = 'hidden'; 477 } 478 if (document.getElementById('mobile-categorie-swiper')) {
479 let dinamicElements = document.querySelectorAll('#subiecte-tip-footer ul li.subiecte-tip-footer-dinamic'); 480 for ( o = 0; o < dinamicElements.length; o++) { 481 dinamicElements[o].remove(); 482 } 483 document.querySelector('#subiecte-tip-footer ul').id = 'mobile-subiecte-tip-footer-fixed-solo'; 484 //console.log(window.getComputedStyle(document.querySelector('#subiecte-tip-footer ul li.subiecte-tip-footer-fixed')).getPropertyValue('flex-basis')); 485 } 486} 487$( document ).ready(function() { 488 $("#numar-an-selector").selectmenu({ 489 "position": { 490 my: "left top", 491 at: "left bottom", 492 collision: "none", 493 of: $('#numar-an-selector-wrapper'), 494 using: function (first, second){ 495 console.log(first,second, second.element.element[0]) 496 second.element.element 497 .css('top', second.target.top - second.element.height) 498 .css('left', first.left) 499 } 500 }, 501 "classes": { 502 "ui-selectmenu-menu": "ui-selectmenu-numar-an-selector" 503 }, 504 "change": function( event, ui ) { 505 window.location.href = ui.item.value; 506 }, 507 "close": function( event, ui ) { 508 $('.ui-selectmenu-numar-an-selector').css('position','') 509 } 510 }); 511 512 $('#numar-an-selector-wrapper').on('mousedown', function(e) { 513 if (e.target.id === 'numar-an-selector-wrapper' && !$('.ui-selectmenu-numar-an-selector').hasClass('ui-selectmenu-open')) { 514 e.stopPropagation(); 515 $('#numar-an-selector-button').click(); 516 } 517 }); 518 519 if (!isMobile) { 520 $('#subiecte-tip-footer-dinamic-activ-desktop') 521 .addClass('notransition') 522 .addClass('subiecte-tip-footer-dinamic-activ subiecte-tip-footer-dinamic-activ-php') 523 524 $('.subiecte-tip-footer-dinamic').hover( 525 function () { 526 $('.subiecte-tip-footer-dinamic.subiecte-tip-footer-dinamic-activ').not('.subiecte-tip-footer-dinamic-activ-php').removeClass('subiecte-tip-footer-dinamic-activ'); 527 $(this).addClass('subiecte-tip-footer-dinamic-activ'); 528 }, function () { 529 if (!$(this).hasClass('subiecte-tip-footer-dinamic-activ-php')) { 530 $(this).removeClass('subiecte-tip-footer-dinamic-activ'); 531 } 532 } 533 ) 534 } 535 536 $('.menu-items .complex').on('click', function() { 537 let thisParent = $(this).parent(); 538 $('.menu-items .menu-items-complex-open').not(thisParent).removeClass('menu-items-complex-open'); 539 thisParent.toggleClass('menu-items-complex-open'); 540 }) 541 542 const subiectAfis = document.getElementById('subiecte-top-picture-inner'); 543 if (subiectAfis) { 544 const xwiper = new Xwiper(subiectAfis); 545 546 xwiper.onSwipeLeft( 547 function (units = 0) { 548 let target = $('#subiecte-top-picture-inner'); 549 let currentX = parseInt(target.css('background-position-x')); 550 target.css('background-position-x', (currentX - Math.round(units)) + 'px'); 551 } 552 ); 553 554 xwiper.onSwipeRight( 555 function (units = 0) { 556 let target = $('#subiecte-top-picture-inner'); 557 let currentX = parseInt(target.css('background-position-x')); 558 target.css('background-position-x', (currentX + Math.round(units)) + 'px'); 559 } 560 ); 561 562 // xwiper.onSwipeUp(() => console.log('swipe up')); 563 564 // xwiper.onSwipeDown(() => console.log('swipe down')); 565 566 // xwiper.onTap(() => console.log('tap')); 567 } 568 569 const categoriiFooter = document.getElementById('mobile-categorie-swiper'); 570 let snapableElements = $('#mobile-categorie-swiper .subiecte-tip-footer-dinamic').length; 571 if (categoriiFooter && snapableElements > 1) { 572 let snapThreshold = Number($('#mobile-categorie-swiper > div > div').width()); 573 if ($('#subiecte-tip-footer-dinamic-activ-swiper')) { 574 let activIndex = $('#mobile-categorie-swiper > div > div').index($('#subiecte-tip-footer-dinamic-activ-swiper')); 575 if (activIndex > 0) { 576 $('#mobile-categorie-swiper > div').css('transform', 'translateX(' + (snapThreshold * -1 * activIndex) + 'px)'); 577 } 578 } 579 categoriiFooter.style.removeProperty('visibility'); 580 let startX = 0; 581 582 let startTransformX = 0; 583 let matrixPattern = /^\w*\((-?((\d+)|(\d*\.\d+)),\s*)*(-?(\d+)|(\d*\.\d+))\)/i; 584 585 let workingTimeout = null; 586 587 const xwiperCategorie = new Xwiper(categoriiFooter); 588 589 const funcMoveCategorie = function () { 590 if (startX != xwiperCategorie.touchSessionStartX) { 591 startX = xwiperCategorie.touchSessionStartX; 592 let transformStyle = $('#mobile-categorie-swiper > div').css('transform'); 593 let matrixValue = []; 594 if (matrixPattern.test(transformStyle)) { // When it satisfy the pattern. 595 let matrixCopy = transformStyle.replace(/^\w*\(/, '').replace(')', ''); 596 matrixValue = matrixCopy.split(/\s*,\s*/); 597 startTransformX = Number(matrixValue[4]); 598 } 599 } 600 let newTransformX= startTransformX + Math.round(( - startX + xwiperCategorie.touchEndX) ); 601 if (newTransformX > 0 && newTransformX > Math.round(snapThreshold / 2) - 1) { 602 newTransformX = Math.round(snapThreshold / 2) - 1; 603 } 604 if (newTransformX < 0 && Math.abs(newTransformX) > (snapableElements * snapThreshold) - Math.round(snapThreshold / 2) - 1) { 605 newTransformX = -1 * ( (snapableElements * snapThreshold) - Math.round(snapThreshold / 2) - 1 ); 606 } 607 $('#mobile-categorie-swiper > div').css('transform', 'translateX(' + newTransformX + 'px)'); 608 609 if (typeof workingTimeout === 'number') { 610 clearTimeout(workingTimeout); 611 workingTimeout = null; 612 } 613 }; 614 615 const funcEndCategorie = function () { 616 let transformStyle = $('#mobile-categorie-swiper > div').css('transform'); 617 let matrixValue = []; 618 let currentTransformX = 0; 619 let newTransformX = 0; 620 if (matrixPattern.test(transformStyle)) { // When it satisfy the pattern. 621 let matrixCopy = transformStyle.replace(/^\w*\(/, '').replace(')', ''); 622 matrixValue = matrixCopy.split(/\s*,\s*/); 623 currentTransformX = Number(matrixValue[4]); 624 newTransformX = currentTransformX; 625 } 626 if (currentTransformX % snapThreshold !== 0) { 627 // console.log( 628 // currentTransformX, 629 // Math.abs(currentTransformX % snapThreshold), 630 // snapThreshold, 631 // Math.round(snapThreshold / 2), 632 // currentTransformX % snapThreshold 633 // ) 634 let isMinus = currentTransformX < 0; 635// console.log(isMinus); 636 if (Math.abs(currentTransformX % snapThreshold) < Math.round(snapThreshold / 2)) { 637 newTransformX = currentTransformX - currentTransformX % snapThreshold; 638 } else { 639 newTransformX = currentTransformX - currentTransformX % snapThreshold; 640 if (isMinus) { 641 newTransformX = newTransformX - snapThreshold; 642 } else { 643 newTransformX = newTransformX + snapThreshold 644 } 645 } 646// console.log(currentTransformX) 647 $('#mobile-categorie-swiper > div').css('transform', 'translateX(' + newTransformX + 'px)'); 648 } 649 workingTimeout = setTimeout(function(){ 650 // console.log( 651 // newTransformX, 652 // Math.abs(newTransformX/snapThreshold), 653 // $('#mobile-categorie-swiper > div > div').eq(Math.abs(newTransformX/snapThreshold)) 654 // ) 655 let element = $('#mobile-categorie-swiper > div > div').eq(Math.abs(newTransformX/snapThreshold)); 656 if (element.length > 0 && element.attr('id') !== 'subiecte-tip-footer-dinamic-activ-swi
656per') { 657 // console.log('click', element.data('href')); 658 window.location.href = element.data('href'); 659 } 660 }, 1500); 661 } 662 663 xwiperCategorie.onSwipeLeft(funcMoveCategorie); 664 665 xwiperCategorie.onSwipeRight(funcMoveCategorie); 666 667 xwiperCategorie.onEnd(function () { 668 // console.log('end swipe'); 669 funcEndCategorie() 670 }) 671 } 672 673 const slides = document.getElementsByClassName("fitText"); 674 for (let i = 0; i < slides.length; i++) { 675 window.fitText( slides.item(i), 0.85 ); 676 } 677}); 678 679/*! 680* FitText.js 1.0 jQuery free version 681* 682* Copyright 2011, Dave Rupert http://daverupert.com 683* Released under the WTFPL license 684* http://sam.zoy.org/wtfpl/ 685* Modified by Slawomir Kolodziej http://slawekk.info 686* 687* Date: Tue Aug 09 2011 10:45:54 GMT+0200 (CEST) 688*/ 689(function(){ 690 691 var addEvent = function (el, type, fn) { 692 if (el.addEventListener) 693 el.addEventListener(type, fn, false); 694 else 695 el.attachEvent('on'+type, fn); 696 }; 697 698 var extend = function(obj,ext){ 699 for(var key in ext) 700 if(ext.hasOwnProperty(key)) 701 obj[key] = ext[key]; 702 return obj; 703 }; 704 705 window.fitText = function (el, kompressor, options) { 706 707 var settings = extend({ 708 'minFontSize' : -1/0, 709 'maxFontSize' : 1/0 710 },options); 711 712 var fit = function (el) { 713 var compressor = kompressor || 1; 714 715 var resizer = function () { 716 el.style.fontSize = Math.max(Math.min(el.clientWidth / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)) + 'px'; 717 }; 718 719 // Call once to set. 720 resizer(); 721 resizer(); 722 723 // Bind events 724 // If you have any js library which support Events, replace this part 725 // and remove addEvent function (or use original jQuery version) 726 addEvent(window, 'resize', resizer); 727 addEvent(window, 'orientationchange', resizer); 728 }; 729 730 if (el.length) 731 for(var i=0; i<el.length; i++) 732 fit(el[i]); 733 else 734 fit(el); 735 736 // return set of elements 737 return el; 738 }; 739})(); 740 741const defaults = { 742 threshold: 50, 743 moveThreshold: 0, 744 passive: false 745}; 746 747class Xwiper { 748 constructor(element, options = {}) { 749 this.options = { ...defaults, ...options }; 750 751 this.element = null; 752 this.touchSessionStartX = 0; 753 this.touchSessionStartY = 0; 754 this.touchStartX = 0; 755 this.touchStartY = 0; 756 this.touchEndX = 0; 757 this.touchEndY = 0; 758 this.onSwipeLeftAgent = null; 759 this.onSwipeRightAgent = null; 760 this.onSwipeUpAgent = null; 761 this.onSwipeDownAgent = null; 762 this.onTapAgent = null; 763 this.onEndAgent = null; 764 765 this.onTouchStart = this.onTouchStart.bind(this); 766 this.onTouchEnd = this.onTouchEnd.bind(this); 767 this.onTouchMove = this.onTouchMove.bind(this); 768 this.onSwipeLeft = this.onSwipeLeft.bind(this); 769 this.onSwipeRight = this.onSwipeRight.bind(this); 770 this.onSwipeUp = this.onSwipeUp.bind(this); 771 this.onSwipeDown = this.onSwipeDown.bind(this); 772 this.onTap = this.onTap.bind(this); 773 this.onEnd = this.onEnd.bind(this); 774 this.destroy = this.destroy.bind(this); 775 this.handleGesture = this.handleGesture.bind(this); 776 777 let eventOptions = this.options.passive ? { passive: true } : false; 778 779 this.element = (element instanceof EventTarget) ? element : document.querySelector(element); 780 781 this.element.addEventListener( 782 'touchstart', 783 this.onTouchStart, 784 eventOptions 785 ); 786 this.element.addEventListener('touchend', this.onTouchEnd, eventOptions); 787 this.element.addEventListener('touchmove', this.onTouchMove, eventOptions); 788 } 789 790 onTouchStart(event) { 791 this.touchStartX = event.changedTouches[0].clientX; 792 this.touchStartY = event.changedTouches[0].clientY; 793 this.touchSessionStartX = this.touchStartX; 794 this.touchSessionStartY = this.touchStartY; 795 } 796 797 onTouchEnd(event) { 798 this.touchEndX = event.changedTouches[0].clientX; 799 this.touchEndY = event.changedTouches[0].clientY; 800 this.handleGesture(event); 801 this.onEndAgent && this.onEndAgent(event.target); 802 } 803 804 onTouchMove(event) { 805 this.touchEndX = event.changedTouches[0].clientX; 806 this.touchEndY = event.changedTouches[0].clientY; 807 this.handleGesture(event,true); 808 this.touchStartX = event.changedTouches[0].clientX; 809 this.touchStartY = event.changedTouches[0].clientY; 810 } 811 812 onSwipeLeft(func) { 813 this.onSwipeLeftAgent = func; 814 } 815 onSwipeRight(func) { 816 this.onSwipeRightAgent = func; 817 } 818 onSwipeUp(func) { 819 this.onSwipeUpAgent = func; 820 } 821 onSwipeDown(func) { 822 this.onSwipeDownAgent = func; 823 } 824 onTap(func) { 825 this.onTapAgent = func; 826 } 827 828 onEnd(func) { 829 this.onEndAgent = func; 830 } 831 832 destroy() { 833 this.element.removeEventListener('touchstart', this.onTouchStart); 834 this.element.removeEventListener('touchend', this.onTouchEnd); 835 } 836 837 handleGesture(event, isMove = false) { 838 let threshold = this.options.threshold; 839 if (isMove) { 840 threshold = this.options.moveThreshold; 841 } 842 /** 843 * swiped left 844 */ 845 if (this.touchEndX + threshold <= this.touchStartX) { 846 this.onSwipeLeftAgent && this.onSwipeLeftAgent(this.touchStartX - this.touchEndX, event.target); 847 return 'swiped left'; 848 } 849 850 /** 851 * swiped right 852 */ 853 if (this.touchEndX - threshold >= this.touchStartX) { 854 this.onSwipeRightAgent && this.onSwipeRightAgent(this.touchEndX - this.touchStartX, event.target); 855 return 'swiped right'; 856 } 857 858 /** 859 * swiped up 860 */ 861 if (this.touchEndY + threshold <= this.touchStartY) { 862 this.onSwipeUpAgent && this.onSwipeUpAgent(this.touchStartY - this.touchEndY, event.target); 863 return 'swiped up'; 864 } 865 866 /** 867 * swiped down 868 */ 869 if (this.touchEndY - threshold >= this.touchStartY) { 870 this.onSwipeDownAgent && this.onSwipeDownAgent(this.touchEndY - this.touchStartY, event.target); 871 return 'swiped down'; 872 } 873 874 /** 875 * tap 876 */ 877 if (this.touchEndY === this.touchStartY) { 878 this.onTapAgent && this.onTapAgent(event.target); 879 return 'tap'; 880 } 881 } 882}
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.