1var ua = navigator.userAgent; 2var nav_lang = navigator.language; 3var ie_ver = null; 4var phone_or_tablet = false; 5var tablet = false; 6var phone = false; 7var android = ua.match(/Android/i) != null; 8var country_code; 9 10 11//var isTouch; 12 13//var isIpad = ua.match(/iPad/i) != null; 14//var isIphone = (ua.match(/iPhone/i) != null) || (ua.match(/iPod/i) != null); 15 16/* if(ua.match(/Firefox/i) != null) browser = 'ff'; */ 17/* if(ua.match(/WebKit/i) != null) browser = 'wk'; */ 18 19/* 20if (document.documentMode) { // as of IE8 21// avvakta med IE, behövs troligen inte 22 browser = 'ie'; 23 ie_ver = document.documentMode; 24} 25*/ 26 27var months = Array( 'jan', 'feb', 'mar', 'apr', 'maj', 'jun', 'jul', 'aug', 'sep', 'okt', 'nov', 'dec'); 28var cal = { slice_lefts: Array( 1, 4, 4, 4, 4, 1, -1, -4, -4, -4, -4, -1), 29 slice_tops: Array( -5, -4, -1, 1, 4, 5, 5, 4, 1, -1, -4, -5), 30 slice_pos: '', 31 current_month_num: '' 32} 33 34// phone or tablet (ipad) view 35if($(window).width() == 768) tablet = true; 36if($(window).width() < 769) phone_or_tablet = true; 37if($(window).width() < 415) phone = true; 38 39 40$(function(){ 41 42 'use strict'; 43 44 //isTouch = ("ontouchstart" in window) || window.DocumentTouch && document instanceof DocumentTouch; 45 /* 46 if(isTouch) { 47 //$('body').addClass('touch'); 48 /*add fastclick js-plugin to remove the 300 ms delay when click fires. 49 $.getScript(js_dir+'_lib/fastclick-min.js') 50 .done(function() { 51 FastClick.attach(document.body); 52 }) 53 } 54 */ 55 56 if(android) $('body').addClass('android'); 57 58 59 // ============================================================================== Startsida 60 61 if($('body.home').length) { 62 //$('#Recommendations').css('background', 'none'); 63 catColumns(); 64 if(tablet) { //phone_or_tablet 65 $('#Navigation').append('<li class="menu-main newsletter"><h3>Nyhetsbrev</h3></li>'); 66 if(!$('#LightBox').is(':visible')) $('#Newsletter').appendTo('.menu-main.newsletter h3'); 67 } 68 } 69 70 // ============================================================================== Kategorisida 71 72 if($('body.category').length){ 73 $('#ShowThisMonth').change(function(){ 74 if($(this).is(':checked')) { 75 $('.img-wrapper:not(.available)').addClass('hide'); 76 } else { 77 $('.filter input:checkbox:checked:not(#ShowThisMonth)').each(function(){ 78 var s = $(this).attr('class'); 79 $('.img-wrapper:not(.available)').each(function(){ 80 if($(this).hasClass(s)) $(this).removeClass('hide'); 81 }) 82 }) 83 } 84 catColumns(); 85 }) 86 } 87 88 89 // ============================================================================== Kategorisida eller Månad 90 91 if(($('body.category').length) || $('body.parent-pageid-14').length){ 92 catColumns(); 93 94 $('.filter input:checkbox:not(#ShowThisMonth)') 95 .removeAttr('checked') 96 .change(function(){ 97 if($(this).prop('checked')){ 98 var m = ($('#ShowThisMonth').is(':checked')) ? '.available' : ''; 99 $('.img-wrapper.'+$(this).attr('class')+m).removeClass('hide'); 100 }else{ 101 $('.img-wrapper.'+$(this).attr('class')).addClass('hide'); 102 } 103 catColumns(); 104 }) 105 106 var i, svarighetsgrader = ['mycket-latt', 'latt', 'halvsvar', 'svar']; 107 for(i=0; i<svarighetsgrader.length; i++){ 108 if($('.img-wrapper.'+svarighetsgrader[i]+':visible').length) 109 $('.filter input:checkbox.'+svarighetsgrader[i]).prop('checked', true); 110 else 111 $('.filter input:checkbox.'+svarighetsgrader[i]) 112 .attr('disabled','disabled') 113 .parent().css({'opacity':0.5, background:'none'}) 114 .next().css('opacity',0.5); 115 } 116 } 117 118 // ============================================================================== Månad 119 120 if($('body.parent-pageid-14').length){ 121 $('nav .calender .current').removeClass('current'); 122 if(!phone_or_tablet) activeSlice('nav .calender .'+$('h1').text().toLowerCase().substr(0,3)+' .area'); 123 } 124 125 126 // ============================================================================== Calender area 127 128 if(!phone_or_tablet) { 129 $('.calender .area') 130 .each(function(){ 131 var pos = $(this).parent().position(); 132 $(this).data('left', pos.left); 133 $(this).data('top', pos.top); 134 }) 135 .mouseover(function(e){ 136 // loop through all slices and reset 137 $('.calender .show:not(.current) .area').each(function(){ 138 resetSlice($(this)); 139 }); 140 141 // move slice 142 if(!$(this).data('active')){ 143 cal.slice_pos = $(this).parent().position(); 144 cal.current_month_num = $(this).parent().prevAll().length; 145 146 $(this).parent().css({ 147 left: (cal.slice_pos.left + cal.slice_lefts[cal.current_month_num]) + 'px', 148 top: (cal.slice_pos.top + cal.slice_tops[cal.current_month_num]) + 'px' 149 }); 150 151 $(this).data('active', true); 152 } 153 }); 154 155 $('.calender').bind('mouseenter mouseleave', function(){ 156 $('.calender .show:not(.current) .area') 157 .each(function(){ 158 resetSlice($(this)); 159 }) 160 }) 161 162 $('.calender a.all').mouseover(function(){ 163 $('.calender .show:not(.current) .area') 164 .each(function(){ 165 resetSlice($(this)); 166 }) 167 }) 168 } 169 170 171 // ============================================================================== Misc 172 173 // menu 174 $('.menu-main .categories .cat-item').each(function(){ 175 var link_html = $('a', this); 176 $('a', this).remove(); 177 link_html.append(' <span>'+$.trim($(this).html())+'</span>'); 178 $(this).html(link_html); 179 }); 180 181 // menu position 182 var nav_offset = $('#Navigation').offset(); 183 var menuPosition = function() { 184 if(phone) return false;
185 186 var scroll_y = $(window).scrollTop(); 187 var leftbar_offset = $('nav').offset(); 188 189 if((scroll_y > nav_offset.top) && (!$('#Wrapper ~ #Navigation').length)){ 190 // move #Navigation outside #Leftbar 191 if(!$('#Wrapper ~ #Navigation').length) $('#Navigation').appendTo($('body')); 192 193 $('#Wrapper ~ #Navigation').css({ 194 left: leftbar_offset.left+'px', 195 width: $('nav').width()+'px', 196 }).addClass('float'); 197 198 } else if(scroll_y < nav_offset.top && $('#Wrapper ~ #Navigation').length){ 199 // put it back 200 $('#Navigation').appendTo($('#Page > nav')).removeClass('float'); 201 } 202 203 autocompleteFollowInput(); 204 205 if(($(window).width() <= 590) && ($(window).width() > 414)) { 206 $('.menu-main.faq a:first').html('FAQ'); 207 } 208 } 209 210 menuPosition(); 211 $(window).bind('scroll resize', function(){ menuPosition(); }) 212 213 if(phone) { 214 $('#PMenu').click(function(){ 215 $('#MainBar').toggle(); 216 $(this).toggleClass('open'); 217 $('#Page nav').toggleClass('show') 218 window.scrollTo(0, 0); 219 }); 220 221 // menu icon follow scroll 222 $(window).bind('scroll', function(){ 223 var sT = $(window).scrollTop(); 224 if(sT > 40) $('#PMenu').addClass('float') 225 else $('#PMenu').removeClass('float'); 226 }); 227 } 228 229 $('#Search') 230 .keyup(function(e) { 231 autoComplete($(this).val().toLowerCase()); 232 }) 233 234 /* hide search - autocomplete dropdown */ 235 $(document).on('click touchstart', function(e){ 236 237 // menu-autocomplete 238 if($('.ac_results').is(':visible')) { 239 var cn = e.target.parentNode.className; 240 if(!cn.match(/ac_over|ac_results/) && e.target.id != 'SearchSubmit') { 241 $('.ac_results').remove(); 242 $('#Search').val(''); 243 } 244 } else { 245 if(!e.target.id.match(/Search|SearchSubmit/i)) $('#Search').val(''); 246 } 247 248 // info-popup-link (hide popup if: popup is visible, not clicking on popup, not clicking on i-link) 249 if($('.i-popup-mess').length 250 && (e.target.className.indexOf('i-popup-mess')==-1) 251 && (e.target.parentElement.className.indexOf('i-popup-mess')==-1) 252 && (e.target.className.indexOf('i-link')==-1)) 253 $('.i-popup-mess, #i-popup-bg').remove(); 254 255 256 }); 257 258 /* executes when clicking on submit-button or enter key */ 259 $('#SearchSubmit').click(function(){ 260 if($('#Search').val() == '') { 261 $('#Search').focus(); 262 return false; 263 } 264 if(!$('.ac_results').length) { 265 showSearchLoader(); 266 $('#Searchform').submit(); 267 } 268 }) 269 //end search 270 271 /* move comment outside loop. (needs to be done before the window-height thing) */ 272 $('#CommentsBlock').insertAfter('#AllPlants').show(); 273 274 // current month slice 275 if(!$('body.parent-pageid-14').length && !phone_or_tablet) activeSlice('nav .calender .current .area'); 276 277 // mejl link 278 if($('a.mejl.red').length) $('a.mejl.red').click(function(){ getMail('red', 'skogsskafferiet', 'se', '', '') }); 279 280 // info-popup message 281 clickInfoMessageLink(); 282 283 // ipad-fix 284 if(tablet && ($('.box a.block').length)) { 285 $('.box a.block').each(function() { 286 $(this).removeAttr('onmouseover'); 287 }) 288 } 289 290 // if not swe - load translation stuff 291 // first check browser language and then check ip with freegeoip.net 292/* 293 var swe = ((nav_lang == 'sv') || (nav_lang == 'sv-FI') || (nav_lang == 'sv-SE')) ? true : false; 294 if(!swe) { 295 $.getJSON('https://freegeoip.net/json/', function(result) { 296 if((result.country_code.length > 1) && (result.country_code != 'SE')) { 297 country_code = result.country_code; 298 if(!phone) $('header').prepend("<div id='GTranslate'></div>"); 299 $.getScript('//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'); 300 } 301 }); 302 } 303*/ 304 305}); 306 307 308function clickInfoMessageLink() { 309 $('a.i-link').bind('click', function(e)Â { 310 e.preventDefault(); 311 312 var t = $(this).attr('data-text'); 313 314 // In mobile view the message appears in the middle of the screen with a transparent canvas behind. For non-mobile views the message is shown in a small popup close to the "i". 315 if(phone) { 316 317 $('<small class="i-popup-mess radius-large">'+t+'<div class="close"/></small>').appendTo('body'); 318 $('<div id="i-popup-bg" />').appendTo('body'); 319 320 $('.i-popup-mess').css({ 321 top: $(window).height()/2-$('.i-popup-mess').outerHeight()/2, 322 left: $(window).width()/2-$('.i-popup-mess').outerWidth()/2 323 }); 324 325 } else { 326 327 var target_id = e.target.attributes['data-id'].value; 328 // if clicking on the same i-message thats already open - do nothing. else remove 329 if($('.i-popup-mess').attr('data-id') == target_id) return false;
330 else $('.i-popup-mess').remove(); 331 332 var o = $(this).offset(); 333 var tail = $(e.target).hasClass('tail') ? '<div class="tail"/>' : ''; 334 335 $('<small class="i-popup-mess radius-large" data-id="'+target_id+'">'+t+'<div class="close"/>'+tail+'</small>').appendTo('body'); 336 337 var top = ($('#MapWrapper').is(':visible')) ? '100px' : o.top-$('.i-popup-mess').outerHeight()-20; 338 339 $('.i-popup-mess').css({ 340 top: top, 341 left: o.left-$('.i-popup-mess').outerWidth()/2 342 }); 343 344 if($(window).scrollTop() > $('.i-popup-mess').offset().top) $('html, body').animate({ scrollTop: $('.i-popup-mess').offset().top-10 }, 500); 345 346 //outside right side 347 var r = $('.i-popup-mess').offset().left + $('.i-popup-mess').outerWidth(); 348 var diff = r - $(window).width(); 349 350 if(diff > 0) { 351 var new_left = $('.i-popup-mess').offset().left - 60; 352 $('.i-popup-mess').css('left', new_left); 353 $('.i-popup-mess .tail').css('left', '82%'); 354 } 355 356 //outside top 357 var t = $('.i-popup-mess').offset().top; 358 if(t < 0) { 359 $('.i-popup-mess').css('top', 6); 360 $('.i-popup-mess .tail').hide(); 361 } 362 } 363 $('.i-popup-mess .close').click(function(){ $('.i-popup-mess, #i-popup-bg').remove(); }) 364 }) 365} 366 367// Autocomplete 368function autoComplete(str){ 369 if(str.length <= 1) { 370 $('.ac_results').remove(); 371 return false; 372 } 373 374 var a_result = []; 375 376 $.each(json_search, function(i, v) { 377 if(v.t.toLowerCase().indexOf(str) != -1) { 378 a_result.push([v.t, v.u]); 379 } 380 }) 381 382 $('.ac_results').remove(); 383 384 if(a_result.length > 0) { 385 a_result.sort(); 386 if(!$('.ac_results').length) { 387 $('#Searchform').append('<ul class="ac_results"></ul>'); 388 autocompleteFollowInput(); 389 } 390 $.each(a_result, function(i, v){ 391 var t = a_result[i][0]; 392 var reg = new RegExp(str, 'gi'); 393 var final_str = t.replace(reg, function(str) {return '<span>'+str+'</span>'}); 394 $('.ac_results').append('<li data-url="'+a_result[i][1]+'">'+final_str+'</li>') 395 }) 396 } 397 398 $('.ac_results li') 399 .mouseover(function(){ $(this).addClass('ac_over') }) 400 .mouseout(function(){ $(this).removeClass('ac_over') }) 401 .bind('click', function(){ // doesnt work with .click() for some reason 402 $('#Search').val($(this).text()); 403 showSearchLoader(); 404 window.location = site_url+'/'+$(this).attr('data-url'); 405 }) 406} 407 408function autocompleteFollowInput() { 409 var p = $('input#Search').position(); 410 $('.ac_results').css({ 411 top: (p.top+30)+'px' 412 }); 413} 414 415function activeSlice(slice){ 416 cal.slice_pos = $(slice).parent().position(); 417 cal.current_month_num = $(slice).parent().prevAll().length; 418 $(slice).parent().css({ 419 left: (cal.slice_pos.left + (cal.slice_lefts[cal.current_month_num])) + 'px', 420 top: (cal.slice_pos.top + (cal.slice_tops[cal.current_month_num])) + 'px' 421 }); 422} 423 424function resetSlice(s){ 425 s.parent().css({ 426 left: s.data('left')+'px', 427 top: s.data('top')+'px' 428 }); 429 s.data('active', false); 430} 431 432function catColumns(){ 433 var counter = 0; 434 435 $('#MainBar .img-wrapper:not(.hide)').each(function(){ 436 437 if($('body').is('.page,.archive,.home')) { 438 if(phone) { 439 $(this).removeClass('float-r'); 440 if(((counter)/2).toString().indexOf('.5') != -1) $(this).addClass('float-r'); 441 } else { 442 //if(!$(this).hasClass('thumb')) $(this).removeClass('middle'); 443 $(this).removeClass('middle'); 444 //if(((counter)/3).toString().indexOf('.3') != -1 && !$(this).hasClass('thumb')) $(this).addClass('middle'); 445 if(((counter)/3).toString().indexOf('.3') != -1) $(this).addClass('middle'); 446 } 447 } 448 449 if(!phone) { 450 $(this) 451 .mouseover(function(){ 452 $(this).addClass('hover'); 453 }) 454 .mouseleave(function(){ 455 $(this).removeClass('hover'); 456 }) 457 } 458 459 $(this).show(); 460 counter ++; 461 462 }) 463} 464 465function showMediumImage(a, img_src){ 466 if(img_src != ''){ 467 $('body').prepend('<div id="ImgPopup" class="img-wrapper medium radius-large popup"><div class="image"><img src="'+img_src+'" width="156" height="117" /></div></div>'); 468 469 var pos = $(a).offset(); 470 var left = pos.left - ($('#ImgPopup').width()/2) + ($(a).width()/2); 471 var top = pos.top - ($('#ImgPopup').height()) - 40; 472 473 $('#ImgPopup').css({ 474 left: left+'px', 475 top: top+'px' 476 }); 477 478 $(a).mouseout(function(){ 479 $('#ImgPopup').remove(); 480 }); 481 } 482} 483 484function menu(menu){ 485 $('#Navigation .menu-main.'+menu+' > ul').slideToggle(); 486 $('#Navigation .menu-main.'+menu+' a.down').toggleClass('up'); 487} 488 489function showSearchLoader(){ 490 if(!$('.search-submit-loader').length) { 491 $('#SearchSubmit').hide(); 492 $('<div class="search-submit-loader" />').insertAfter('#Search'); 493 } 494} 495 496 497function showLightBox(){ 498 $('#LightBox') 499 .css({ 500 height: $(document).height() 501 }) 502 .fadeIn(); 503} 504 505function lightBox(i){ 506 507 var img_src; 508 if($('#thumbNav .cur').length) img_src = images_big[$('#thumbNav .cur').index()]; 509 else if(typeof image_big != 'undefined') img_src = image_big; 510 else img_src = i; 511 512 var center_left = parseInt($(window).width()/2); 513 var center_top = parseInt($(window).height()/2+$(window).scrollTop()); 514 515 showLightBox(); 516 517 $('#LightBox')
518 .prepend('<div class="ajaxloader" style="left:'+(center_left-64)+'px; top:'+center_top+'px"></div>') 519 .click(function(){ 520 $(this) 521 .fadeOut() 522 .children().remove(); 523 }); 524 525 var img = new Image(); 526 527 $(img) 528 .on('load', function(){ 529 var L = parseInt(($(window).width()-this.naturalWidth)/2); 530 if(L<0) L = 0; // if image wider than screen 531 $(this) 532 .hide() 533 .css({ 534 left: L, 535 top: parseInt(($(window).height()-this.naturalHeight)/2+$(window).scrollTop()) 536 }) 537 .addClass('image'); 538 $('#LightBox').append(this); 539 $(this).fadeIn(); 540 // add close-x 541 var x_top = parseInt($('#LightBox .image').css('top'))-15; 542 var x_left = parseInt($('#LightBox .image').css('left')) + $('#LightBox .image').width()-15; 543 if(L==0) x_left = x_left-12; 544 $('#LightBox').prepend('<img class="close" src="'+template_url+'/_/img/icon_close.png" style="left:'+x_left+'px; top:'+x_top+'px" />') 545 }) 546 .attr('src', img_src); 547} 548 549function newsletterRespons(){ 550 $('#Newsletter').addClass('in-lightbox').append('<input type="button" value="stäng" class="bg-neg" onclick="location.href=\''+current_url.split('?')[0]+'\'">').appendTo('#LightBox'); 551} 552 553// calls after insta feed has been rendered 554function updateInstaFilters(){ 555 556 // add CSS 557 $('<link>').appendTo('head').attr({ 558 type: 'text/css', 559 rel: 'stylesheet', 560 href: 'https://assets.juicer.io/embed.css' 561 }); 562 $('ul.juicer-feed .j-truncate').text('... >>>'); 563 $('.juicer-feed h1.referral, .juicer-feed .j-poster, .feed-item .juicer').remove(); 564 $('.juicer-feed').show(); 565} 566 567function getMail(name, dom, country, subject, _body) { if(subject == undefined) subject = ""; if(_body == undefined)_body = ""; window.location.href="mai"+"lto"+":"+name+String.fromCharCode(64)+dom+String.fromCharCode(46)+country+"?Subject="+subject+"&Body="+_body;} 568 569function googleTranslateElementInit() { 570 var l,d; 571 l = (phone) ? 'HORIZONTAL' : 'SIMPLE'; 572 d = (phone) ? true : false; 573 new google.translate.TranslateElement({ 574 pageLanguage: 'sv', 575 includedLanguages: 'no,da,de,en,es,et,fi,fr,is,it,lv,nl,pl,ru', 576 gaTrack: true, 577 gaId: 'UA-11676213-4', 578 layout: eval('google.translate.TranslateElement.InlineLayout.'+l), 579 autoDisplay: d 580 }, 'GTranslate'); 581}
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.