1/* 2 3 Content Timeline 3.3 4 5 Date organised content slider. 6 7 Copyright (c) 2012 Br0 (shindiristudio.com) 8 9 Project site: http://codecanyon.net/ 10 Project demo: http://shindiristudio.com/timeline 11 12 */ 13 14(function($){ 15 16 // EVENTS.timeline 17 18 // init.timeline : triggered when timeline is initialised 19 // scrollStart.timeline : triggered when item move animation starts 20 // scrollEnd.timeline : triggered when item move animation ends 21 // itemOpen.timeline : triggered on click to open item 22 // itemClose.timeline : triggered on click to close item 23 24 // --------------------------------------------------------- 25 26 // On KeyPress (left) : trigger $.timeline('left') 27 // On KeyPress (right) : trigger $.timeline('right') 28 29 // --------------------------------------------------------- 30 31 // $.timeline(METHODS) 32 33 // $.timeline('init') : initialises timeline 34 // $.timeline('destroy') : clears timeline data 35 // $.timeline('left') : moves one left by one element 36 // $.timeline('right') : moves right by one element 37 // $.timeline('open', id) : opens element with 'data-id' = id 38 // $.timeline('close', id): closes element with 'data-id' = id 39 // $.timeline('goTo', id) : goes to element width 'data-id' = id 40 41 42 //test if device is touch 43 function is_touch_device() { 44 return (('ontouchstart' in window) 45 || (navigator.MaxTouchPoints > 0) 46 || (navigator.msMaxTouchPoints > 0)); 47 } 48 49 //scale images 50 function imageFit(className) { 51 52 $(className).each(function () { 53 var ratioWrap = $(this).width() / $(this).outerHeight(); 54 var ratioImg = $(this).find("img").width() / $(this).find("img").outerHeight(); 55 56 if (ratioImg < 1 || ratioImg > 1.49) { 57 if (ratioWrap > ratioImg) { 58 $(this).find("img").css({"width": "100%", "height": "auto"}); 59 } else 60 $(this).find("img").css({"width": "auto", "height": "auto"}); 61 } else if (ratioImg == 1 || ratioImg == 0) { 62 if (ratioWrap > 1) { 63 $(this).find("img").css({"width": "100%", "height": "auto"}); 64 } else { 65 $(this).find("img").css({"width": "auto", "height": "100%"}); 66 } 67 } else { 68 $(this).find("img").css({"width": "auto", "height": "auto%"}); 69 } 70 }); 71 } 72 73 /* function to validate the existence of each key in the object to get the number of valid keys. */ 74 function objectSize(the_object) { 75 var object_size = 0; 76 for (key in the_object){ 77 if (the_object.hasOwnProperty(key)) { 78 object_size++; 79 } 80 } 81 return object_size; 82 } 83 84 //store unique years 85 function storeUniqueYears(arr) { 86 var a = []; 87 var objLength = objectSize(arr); 88 for (var i = 1; i < objLength+1; i++) { 89 if (a.indexOf(arr[i]) === -1) 90 a.push(arr[i]); 91 } 92 return a; 93 } 94 95 //store first unique years of items 96 function storeUniqueIds(arr) { 97 var a = [arr[1]]; 98 var counter = 0; 99 var objLength = objectSize(arr); 100 for (var i = 2; i < objLength + 1; i++) { 101 if (arr[i].slice(-4) != arr[i-1].slice(-4)) 102 a.push(arr[i]); 103 } 104 } 105 106 var t_methods = { 107 init : function( options ) { 108 109 // Default settings 110 var settings = $.extend( { 111 'my_debug' :0, 112 'autoplay' : false, 113 'vertical' :0, 114 'autoplay_mob' : false, 115 'itemClass' : '.item', // class used for timeline items 116 'itemOpenClass' : '.item_open', // class used for item details 117 'openTriggerClass' : '.item', // class of read more element (default uses whole item to trigger open event) 118 'closeText' : 'Close', // text of close button in open item 119 'itemMargin' : 10, // spacing between items 120 'scrollSpeed' : 500, // animation speed 121 'startItem' : 'last', // timeline start item id, 'last' or 'first' can be used insted 122 'easing' : 'easeOutSine', // jquery.easing function for animations, 123 'categories' : ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], // categories shown above timeline (months are default) 124 'nuberOfSegments' : [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], // number of elements per category (number of days) 125 'yearsOn' : true, // show years (can be any number you use in data-id (elementNumber/category/yearOrSomeOtherNumber)) 126 'swipeOn' : true, // turn on swipe moving function 127 'hideTimeline' : false, 128 'hideControles' : false, //hides the prev/next controles 129 'closeItemOnTransition' : false //if true, closes the item after transition 130 }, options); // Setings 131 var my_pfx,my_prop; 132 var my_transitions=function() { 133 var obj = document.createElement('div'), 134 props = ['perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective']; 135 for (var i in props) { 136 if ( obj.style[ props[i] ] !== undefined ) { 137 my_pfx = props[i].replace('Perspective','').toLowerCase(); 138 my_prop = "-" + my_pfx + "-transform"; 139 return true; 140 } 141 } 142 return false;
143 }(); 144 if(window.console&&settings.my_debug){ 145 console.log('width',{my_pfx:my_pfx,my_prop:my_prop,my_transitions:my_transitions}); 146 } 147 148 // main queries 149 var my_debug_12=settings.my_debug; 150 151 var $this = this; 152 153 154 var $body = $('body'), 155 $items = $this.find(settings.itemClass), 156 $itemsOpen = $this.find(settings.itemOpenClass), 157 itemWidth = $items.first().width(), 158 itemOpenWidth = $itemsOpen.first().width(), 159 closeItemOnTransition=settings.closeItemOnTransition; 160 161 my_styel_4_resize_image=function(my_scale){ 162 if(my_debug_12&&window.console){ 163 console.log("Resize image"); 164 } 165 $this.find(".item").each(function(i,v){ 166 var padd=$(v).find(".my_share_items").css('padding-top'); 167 padd=parseFloat(padd); 168 169 var bott=$(v).find(".con_borderImage").offset().top; 170 var h=$(v).find(".con_borderImage").height(); 171 bott+=h; 172 var bott_1=$(v).find(".my_timeline_content").offset().top;//+$(v).offset().top;//+$(v).find("h2").outerHeight()+$(v).find(".my_post_date").outerHeight()+h; 173 //var bott_1=$(v).offset().top()+$(v).find("h2").outerHeight()+$(v).find(".my_post_date").outerHeight()+h; 174 var rel_pos_image=$(v).find(".con_borderImage").offset().top-$(v).offset().top; 175 //bott=rel_pos_image+h; 176 var h_content=$(v).find(".my_timeline_content").height(); 177 //bott_1=$(v).height()-h_content; 178 //bott_1-=h_content; 179 if(my_debug_12&&window.console){ 180 console.log("Resize image",{rel_pos_image:rel_pos_image,h:h,h_content:h_content,padd:padd,bott:bott,bott_1:bott_1}); 181 } 182 //bott_1+=padd; 183 if(bott>bott_1){ 184 var diff=Math.abs(bott-bott_1); 185 //if(diff>padd)diff-=padd/2; 186 187 var h=$(v).find(".con_borderImage").height(); 188 if(typeof $(v).data('my-height')=='undefined'){ 189 $(v).data('my-height',h); 190 } 191 h-=diff; 192 $(v).find(".con_borderImage").height(h); 193 var diff_1=diff/2; 194 $(v).find(".con_borderImage img").css('top','-'+diff_1+'px'); 195 196 if(my_debug_12&&window.console){ 197 console.log("Resize image for diff",{diff:diff}); 198 } 199 }else { 200 var h; 201 if(typeof $(v).data('my-height')!='undefined'){ 202 h=$(v).data('my-height'); 203 $(v).find(".con_borderImage").height(h); 204 205 } 206 $(v).find(".con_borderImage img").css('top',''); 207 if(my_debug_12&&window.console){ 208 console.log("Resize image for return to original sized"); 209 } 210 211 } 212 }); 213 }; 214 //var 215 my_500px_window_function=function(){ 216 var my_trigger_width=settings.my_trigger_width; 217 var my_debug=settings.my_debug; 218 var itemWidth=parseFloat(settings.my_sizes.card.item_width); 219 var itemOpenWidth=parseFloat(settings.my_sizes.active.item_width); 220 var itemMargin=parseFloat(settings.my_sizes.card.margin); 221 var containerWidth=$this.width(); 222 containerWidth-=itemMargin; 223 if(my_debug){ 224 if(window.console){ 225 console.log('Item width',{c_w:containerWidth,i_w:itemWidth,o_w:itemOpenWidth}); 226 } 227 } 228 var my_scale=1; 229 var my_scale_open=1; 230 if(containerWidth<=my_trigger_width){ 231 if(containerWidth<itemWidth){ 232 233 my_scale=containerWidth/itemWidth; 234 235 //containerWidth-=itemMargin; 236 //var containerWidth_1=containerWidth-itemMargin; 237 //if($this.hasClass('my_style_style_2') || $this.hasClass('my_style_style_1')){ 238 var diff=-Math.abs(containerWidth-itemWidth)/2; 239 $this.find(".item .con_borderImage img").css('left',diff+'px'); 240 //} 241 $this.find(".item").width(containerWidth); 242 if($this.find(".my_timeline_content").length>0){ 243 var my_margin=$this.find(".my_timeline_content").css('margin-left'); 244 var m_l=parseFloat(my_margin); 245 $this.find(".my_timeline_content").width((containerWidth-2*m_l)); 246 } 247 248 }else { 249 250 $this.find(".item").width(itemWidth); 251 //if($this.hasClass('my_stylk_style_2')|| $this.hasClass('my_style_style_1')){ 252 $this.find(".item .con_borderImage img").css('left',''); 253 //} 254 if($this.find(".my_timeline_content").length>0){ 255 var my_margin=$this.find(".my_timeline_content").css('margin-left'); 256 var m_l=parseFloat(my_margin); 257 $this.find(".my_timeline_content").width((itemWidth-2*m_l)); 258 } 259 260 } 261 if(containerWidth<itemOpenWidth){ 262 var diff_1=-Math.abs(containerWidth-itemOpenWidth)/2; 263 $this.find(".item_open a.con_borderImage").css('left',diff_1+'px'); 264 265 my_scale_open=containerWidth/itemOpenWidth; 266 $this.find(".item_open").data('my-width',containerWidth); 267 $this.find(".item_open").width(containerWidth); 268 //$this.find(".item_open a.con_borderImage").width(containerWidth); 269 $this.find(".item_open_cwrapper").width(containerWidth); 270 271 }else { 272 $this.find(".item_open a.con_borderImage").css('left',''); 273 //$this.find(".item_open a.con_borderImage").width(itemOpenWidth); 274 275 $this.find(".item_open").data('my-width',itemOpenWidth); 276 $this.find(".item_open").width(itemOpenWidth); 277 $this.find(".item_open_cwrapper").width(itemOpenWidth); 278 279 } 280 }else { 281 if(containerWidth<itemWidth){ 282 my_scale=containerWidth/itemWidth; 283 284 //containerWidth-=itemMargin; 285 //var containerWidth_1=containerWidth-itemMargin; 286 //if($this.hasClass('my_style_style_2') || $this.hasClass('my_style_style_1')){ 287 var diff=-Math.abs(containerWidth-itemWidth)/2; 288 289 $this.find(".item .con_borderImage img").css('left',diff+'px'); 290 //} 291 $this.find(".item").width(containerWidth); 292 if($this.find(".my_timeline_content").length>0){ 293 var my_margin=$this.find(".my_timeline_content").css('margin-left'); 294 var m_l=parseFloat(my_margin); 295 $this.find(".my_timeline_content").width((containerWidth-2*m_l)); 296 } 297 298 }else { 299 300 $this.find(".item").width(itemWidth); 301 //if($this.hasClass('my_stylk_style_2')|| $this.hasClass('my_style_style_1')){ 302 $this.find(".item .con_borderImage img").css('left',''); 303 //} 304 if($this.find(".my_timeline_content").length>0){ 305 var my_margin=$this.find(".my_timeline_content").css('margin-left'); 306 var m_l=parseFloat(my_margin); 307 $this.find(".my_timeline_content").width((itemWidth-2*m_l)); 308 } 309 310 } 311 if(containerWidth<itemOpenWidth){ 312 var diff_1=-Math.abs(containerWidth-itemOpenWidth)/2; 313 $this.find(".item_open a.con_borderImage").css('left',diff_1+'px'); 314 315 my_scale_open=containerWidth/itemOpenWidth; 316 //$this.find(".item_open a.con_borderImage").width(containerWidth); 317 318 $this.find(".item_open").data('my-width',containerWidth); 319 $this.find(".item_open").width(containerWidth); 320 $this.find(".item_open_cwrapper").width(containerWidth); 321 322 }else { 323 $this.find(".item_open a.con_borderImage").css('left',''); 324 325 $this.find(".item_open").data('my-width',itemOpenWidth); 326 $this.find(".item_open").width(itemOpenWidth); 327 //$this.find(".item_open a.con_borderImage").width(itemOpenWidth); 328 329 $this.find(".item_open_cwrapper").width(itemOpenWidth); 330 331 } 332 } 333 if(my_scale<1){ 334 //$this.find(".t_left , .t_right").css('display','none'); 335 //$(head) 336 }else { 337 //$this.find(".t_left , .t_right").css('display','block'); 338 } 339 $this.find(".item_open").data('my-scale',my_scale_open); 340 $this.find(".item_open").data('my-cnt-width',containerWidth); 341 if(my_debug&&window.console){ 342 console.log("Scale new function",{my_scale:my_scale,my_scale_open:my_scale_open}); 343 } 344 return my_scale; 345 }; 346 var my_scale=1; 347 var my_scale_1=''; 348 my_scale=my_500px_window_function(); 349 // Trigger init event 350 $this.trigger('init.Timeline'); 351 352 353 // If no index found 354 var startIndex = $items.length-1; 355 356 // Find index of start element 357 if(settings.startItem == 'first') 358 { 359 startIndex = 0; 360 } 361 else if (settings.startItem == 'last') 362 { 363 startIndex = $items.length-1; 364 } 365 else { 366 $items.each(function(index){ 367 if(settings.startItem == $(this).attr('data-id')) 368 { 369 startIndex = index; 370 return true; 371 } 372 }); 373 } 374 $items.each(function(index){ 375 $(this).attr('data-count', index); 376 $(this).next(settings.itemOpenClass).attr('data-count', index); 377 if(!$(this).hasClass(settings.openTriggerClass)) { 378 $(this).find(settings.openTriggerClass).attr('data-count', index); 379 $(this).find(".my_read_more").attr('data-count', index); 380 } 381 382 }); 383 384 // Create wrapper elements, and needed properties 385 $this.append('<div style="clear:both"></div>'); 386 $this.css({width: '100%', 'overflow' : 'hidden', marginLeft : 'auto', marginRight : 'auto','text-align': 'center', height:0}); 387 388 389 $this.wrapInner('<div class="timeline_items" />'); 390 /** 391 * my wrap inner 392 */ 393 //$this.wrapInner('<div class="my_timeline_items_wrapper" />'); 394 /** 395 * end changes 396 */ 397 398 $this.find('.timeline_items').css('text-align','left'); 399 400 if('ontouchstart' in window) { 401 $this.addClass('timelineTouch'); 402 403 } 404 405 // ZoomOut placement fix 406 $this.wrapInner('<div class="timeline_items_holder" />'); 407 if(!settings.hideControles) { 408 $this.append('<div class="t_controles"><div class="t_left"></div><div class="t_right"></div></div>'); 409 } 410 $this.wrapInner('<div class="timeline_items_wrapper" />'); 411 412 if(settings.search_bar_position == 0) { 413 $this.prepend('<div class="search_bar_holder" style="transform:translate(0,-90px) !important;"><input id="search-cards" style="padding-left:10px;width: 50%; height: 100%; margin: auto; " placeholder="Search specific card..." type="text"/></div>'); 414 $('.timeline_line').addClass('search_pos'); 415 } 416 else if(settings.search_bar_position == 1) { 417 $this.prepend('<div class="search_bar_holder"><input id="search-cards" style="padding-left:10px; width: 50%; height: 100%; margin: auto;" placeholder="Search specific card..." type="text"/></div>'); 418 } 419 else { 420 $this.append('<div class="search_bar_holder" style="margin-bottom: 20px;"><input id="search-cards" style="padding-left:10px; width: 50%; height: 100%; margin: auto;" placeholder="Search specific card..." type="text"/></div>'); 421 } 422 /*$this.prepend('<div class="search_bar_holder" style="display:block !important; "><input id="search-cards" placeholder="Search specific card..." type="text"/></div>'); 423 $this.append('<div class="search_bar_holder" style="display:block !important;"><input id="search-cards" placeholder="Search specific card..." type="text"/></div>');*/ 424 $this.find('.timeline_items_holder').css({width: my_w_12+'px', marginLeft : 'auto', marginRight : 'auto'}); 425 426 427 //my_w_12-=40; 428 /** 429 * Set scale items 430 */ 431 var my_w_12=$this.width(); 432 var my_w_item_12=$this.find(".item").width(); 433 434 my_scale_items_12=function(my_scale){ 435 // if(my_w_12<600){ 436 var data = $this.data('timeline'); 437 var $iholder = $this.find('.timeline_items:first'); 438 var my_settings=$this.data('my_settings'); 439 var my_st=startIndex; 440 if(typeof data !='undefined'){ 441 if(data.currentIndex!='undefined'){ 442 my_st=data.currentIndex; 443 } 444 } 445 446 447 /*if(typeof my_settings!='undefined'){ 448 if(typeof my_settings.my_scale!='undefined'){ 449 my_scale_1=my_settings.my_scale; 450 } 451 }*/ 452 /*if(window.console){ 453 console.log('My settings',{sett:my_settings,my_st:my_st,my_scale_1:my_scale_1}); 454 }*/ 455 var my_w_12=$this.width(); 456 var my_w_item_12=$this.find(".item").width(); 457 //var my_scale=1; 458 /*if(window.console){ 459 console.log('Get scale factor',{my_scale:my_scale,item_width:my_w_item_12,width:my_w_12}); 460 }*/ 461 //my_scale=my_w_12/my_w_item_12; 462 //my_scale_1=parseFloat($this.find(".timeline_items_wrapper").css(my_prop)); 463 /* 464 if(my_w_item_12>my_w_12){ 465 my_scale=my_w_12/my_w_item_12; 466 if(window.console){ 467 console.log('Get scale factor',{my_scale:my_scale}); 468 } 469 if(my_transitions){ 470 my_scale_1=my_scale; 471 if(typeof data!='undefined'){ 472 data.my_scale=my_scale; 473 } 474 //$this.find(".item").css(my_prop,'scale('+my_scale+')'); 475 // 476 //bilo je pre 477 478 //$this.find(".timeline_items").css(my_prop,'scale('+my_scale+')'); 479 //$this.find(".my_timeline_items_wrapper").css(my_prop,'scale('+my_scale+')'); 480 $this.find(".timeline_items_wrapper").width(my_w_item_12); 481 $this.find(".timeline_items_wrapper").css(my_prop,'scale('+my_scale+')'); 482 $this.find(".timeline_items_holder").width(my_w_item_12); 483 var my_left_12_123=(my_w_item_12*(1-my_scale))/2; 484 $this.find(".timeline_items_wrapper").css('margin-left','-'+my_left_12_123+'px'); 485 var my_o_w_12=$this.find(".item_open").width()*my_scale; 486 487 var my_w_new_12=my_w_item_12; 488 var
488 my_scale_1=my_w_new_12/my_o_w_12; 489 //$this.find(".item_open").css(my_prop,'scale('+my_scale_1+')'); 490 if(window.console){ 491 console.log('width',{w:my_o_w_12,my_scale_1:my_scale_1}); 492 } 493 //$("#tl"+settings.my_id).append('<style type="text/css" id="my_timeline_css_'+settings.my_id+'">.timeline .item_open_cwrapper,.timeline .item_open, #content .timeline .item_open {width:'+my_w_new_12+'px !important;};</style>'); 494 //$this.find(".timeline_items_holder").css(my_prop,'scale('+my_scale+')'); 495 496 } 497 else { 498 //$this.find(".item").css('width',my_w_12+'px'); 499 } 500 501 }else if(my_scale_1!=''){ 502 $this.find(".timeline_items_wrapper").css('width',''); 503 $this.find(".timeline_items_wrapper").css(my_prop,''); 504 $this.find(".timeline_items_holder").css('width',''); 505 // var my_left_12_123=(my_w_item_12*(1-my_scale))/2; 506 $this.find(".timeline_items_wrapper").css('margin-left',''); 507 508 } 509 */ 510 var my_width=my_w_12; 511 var my_scale_1=1; 512 //set margin for selected start item 513 var startItemMargin = 0; 514 var itemWidth=$this.find(".item").width(); 515 if(my_debug_12&&window.console){ 516 console.log("Reposition element",{containerWidth:my_width,itemWidth:itemWidth}); 517 518 } 519 if((my_scale<1||my_scale==1)&&my_scale_1!=''&&(typeof my_settings!='undefined') ){ 520 if(my_st==0){ 521 //margin+=(itemWidth/2); 522 if(my_scale<1){ 523 margin=0; 524 } 525 else { 526 margin=(my_width-itemWidth-my_settings.itemMargin)/2; 527 if(data.options.align_start_item == 0){ 528 startItemMargin = 0; 529 } 530 else if(data.options.align_start_item == 1){ 531 startItemMargin = (my_width-itemWidth-my_settings.itemMargin)/2; 532 } 533 else { 534 startItemMargin = (my_width-itemWidth-my_settings.itemMargin); 535 } 536 } 537 538 } 539 if(my_st>0){ 540 if(my_scale<1){ 541 //bilo pre margin=-(startIndex)*(itemWidth)+(startIndex)*(settings.itemMargin*2*my_scale); 542 margin=-(my_st)*(itemWidth)-(my_st)*(my_settings.itemMargin); 543 //margin+='%'; 544 //width*=my_scale; 545 } 546 else { 547 margin=-(my_st)*(itemWidth+my_settings.itemMargin)+(my_width-itemWidth-my_settings.itemMargin)/2; 548 if(data.options.align_start_item == 0){ 549 startItemMargin = -(my_st)*(itemWidth+my_settings.itemMargin); 550 } 551 else if(data.options.align_start_item == 1){ 552 startItemMargin = -(my_st)*(itemWidth+my_settings.itemMargin)+(my_width-itemWidth-my_settings.itemMargin)/2; 553 } 554 else { 555 startItemMargin = (my_width-itemWidth-my_settings.itemMargin) - (my_st)*(itemWidth+my_settings.itemMargin); 556 } 557 558 } 559 //margin=-(startIndex-1/2)*(itemWidth+settings.itemMargin); 560 //margin=(startIndex-1)*(iteWidth+ 561 } 562 //$this.timeline("my_debug","Margin",{margin:margin,startIndex:startIndex}); 563 //margin=my_margin; 564 if(my_debug_12&&window.console){ 565 console.log("Scale margin Margin",{width:my_timeline_width,start:my_st,margin:margin}); 566 } 567 //$this.timeline("my_debug","margin",{margin:margin,width:my_timeline_width}); 568 569 // Set margin so start element would place in midle of the screen 570 571 //data.margin=margin; 572 //if(typeof data.open=='undefined' || (!data.open)){ 573 if(true){ //alwas call this 574 //for responsive view 575 if($(window).width() < 768){ 576 $iholder.css({marginLeft: margin}); 577 } 578 //for desktop view 579 else { 580 //alwas call this 581 $iholder.css({marginLeft: startItemMargin}); 582 } 583 //$iholder.css({marginLeft: margin}); 584 data.margin=margin; 585 } 586 else { 587 var my_width_1=data.itemWidth+data.options.itemMargin; 588 //var my_diff=Math.abs(margin)-Math.abs(data.margin); 589 var my_width=$this.find(".timeline_items_wrapper").width(); 590 var my_open_width=data.itemOpenWidth; 591 var my_diff=0; 592 //data.my_diff_window_resize=my_diff; 593 if(typeof data!='undefined'){ 594 $this.timeline("my_debug","Scale Factors",{my_scale:my_scale,my_scale_1:data.my_scale_1}); 595 } 596 if((my_scale==1)&&(data.my_scale_1<1)){ 597 //my_diff=-(my_width-my_width_1)/2; 598 //problem sa scale==1 i scale<1 599 if(my_debug_12&&window.console){ 600 console.log("My scale_1 <1 my_scale==1",my_diff); 601 } 602 var my_old_width=my_settings.my_width_12; 603 my_diff=-(my_width-my_old_width) 604 605 data.my_diff_window_resize=my_diff/2; 606 my_settings.my_width_12=my_width; 607 //data.margin+=my_diff/2; 608 }else if((my_scale<1)&&(data.my_scale_1==1)){ 609 //my_diff=(my_width-my_width_1)/2; 610 var my_old_width=my_settings.my_width_12; 611 my_diff=-(my_width-my_old_width) 612 if(my_debug_12&&window.console){ 613 console.log("My scall1 <1 my_scale_1==1",my_diff); 614 } 615 my_settings.my_width_12=my_width; 616 data.my_diff_window_resize=-my_diff/2; 617 //data.margin-=my_diff/2; 618 }else { 619 620 var my_old_width=my_settings.my_width_12; 621 my_diff=-(my_width-my_old_width);//+my_open_width; 622 if(my_debug_12&&window.console){ 623 console.log("My scale is same <1",{width:my_width,my_diff:my_diff,old_width:my_old_width}); 624 } 625 my_settings.my_width_12=my_width; 626 627 } 628 if(my_debug_12&&window.console){ 629 console.log("My scale function Diff margin",{my_scale:my_scale,my_scale_1:data.my_scale_1,my_diff:my_diff}); 630 } 631 //data.margin+=my_diff; 632 //$iholder.css({marginLeft: data.margin}); 633 634 } 635 } 636 if(typeof data!='undefined'){ 637 if(my_debug_12&&window.console){ 638 console.log('Get scale factor',{my_scale_1:data.my_scale_1}); 639 } 640 data.my_scale_1=my_scale; 641 642 } 643 //my_scale_1=my_scale; 644 return my_scale; 645 } 646 // } 647 //We dont use this method for scalling items beacuse some issues 648 //on timeline 649 my_scale=my_scale_items_12(my_scale); 650 itemWidth = $items.first().width(); 651 if(window.console&&settings.my_debug){ 652 console.log('width',{itemWidth:itemWidth,width:my_w_12,item:my_w_item_12,my_scale:my_scale}); 653 } 654 /** 655 * 656 */ 657 658 $items.css({paddingLeft:0 , paddingRight:0, marginLeft: settings.itemMargin/2, marginRight: settings.itemMargin/2, float: 'left', position:'relative'}); 659 660 $itemsOpen.each(function(){ 661 $(this).prepend('<div class="t_close" data-count="'+$(this).attr('data-count')+'" data-id="'+$(this).attr('data-id')+'">'+settings.closeText+'</div>'); 662 $(this).wrapInner('<div class="'+settings.itemOpenClass.substr(1)+'_cwrapper" />').find('div:first').css({position: 'relative'}); 663 $(this).css({width: 0, padding:0 , margin: 0, float: 'left', display : 'none', position : 'relative', overflow : 'hidden'}); 664 }); 665 666 667 // Get new queries 668 var $iholder = $this.find('.timeline_items:first'), 669 $line = $this.find('.t_line_wrapper:first'), 670 margin = 300/2 - (itemWidth + settings.itemMargin)*(1/2 + startIndex) , 671 width = (itemWidth + settings.itemMargin)*$items.length + (itemOpenWidth + settings.itemMargin) + 660 , 672 data = $this.data('timeline'); 673 var my_settings=$this.data('my_settings'); 674 var my_timeline_width=$this.width(); 675 var my_margin=(my_timeline_width/2); 676 var my_width=$this.find(".timeline_items_wrapper").width(); 677 678 679 680 //set margin for selected start item 681 var startItemMargin = 0; 682 /** 683 * Set start margin to center position of timeline 684 */ 685 if(startIndex==0){ 686 if(my_scale<1){ 687 margin=0; 688 } 689 else { 690 margin=(my_width-itemWidth-settings.itemMargin)/2; 691 if(settings.align_start_item == 0){ 692 startItemMargin = 0; 693 } 694 else if(settings.align_start_item == 1){ 695 startItemMargin = (my_width-itemWidth-settings.itemMargin)/2; 696 } 697 else { 698 startItemMargin = (my_width-itemWidth-settings.itemMargin); 699 } 700 } 701 } 702 if(startIndex>0){ 703 if(my_scale<1){ 704 margin=-(startIndex)*(itemWidth)-(startIndex)*(settings.itemMargin); 705 } 706 else { 707 margin=-(startIndex)*(itemWidth+settings.itemMargin)+(my_width-itemWidth-settings.itemMargin)/2; 708 if(settings.align_start_item == 0){ 709 startItemMargin = -(startIndex)*(itemWidth+settings.itemMargin); 710 } 711 else if(settings.align_start_item == 1){ 712 startItemMargin = -(startIndex)*(itemWidth+settings.itemMargin)+(my_width-itemWidth-settings.itemMargin)/2; 713 } 714 else { 715 startItemMargin = (my_width-itemWidth-settings.itemMargin) - (startIndex)*(itemWidth+settings.itemMargin); 716 } 717 718 } 719 } 720 if(window.console&&settings.my_debug){ 721 console.log("Margin",{width:my_timeline_width,start:startIndex,margin:margin}); 722 } 723 724 // Set margin so start element would place in midle of the screen 725 $iholder.css({width: width, marginLeft: startItemMargin}); 726 /** 727 * Chnages 728 */ 729 730 731 // If the plugin hasn't been initialized yet 732 if (!data){ 733 $this.data('timeline', { 734 currentIndex : startIndex, 735 itemCount : $items.length, 736 margin : margin, 737 itemWidth : itemWidth, 738 itemOpenWidth : itemOpenWidth, 739 lineMargin : 0, 740 lineViewCount : 0, 741 options : settings, 742 items : $items, 743 iholder : $iholder, 744 open : false, 745 noAnimation : false, 746 marginResponse: false, 747 mousedown : false, 748 my_open_item_center_12:false, 749 mousestartpos : 0, 750 751 }); 752 } 753 754 settings.my_scale=my_scale; 755 settings.my_width_12=$this.find(".timeline_items_wrapper").width();; 756 757 if(!settings.hideTimeline) { 758 $this.timeline('createElements'); 759 if($this.hasClass('timelineClean')) { 760 } 761 } 762 763 var data=$this.data('timeline'); 764 data.my_scale=my_scale; 765 data.my_scale_1=my_scale; 766 $this.data('my_settings',settings); 767 $this.timeline("my_debug","Autoplay set timeout",settings); 768 if($this.hasClass('my_style_style_4')){ 769 my_styel_4_resize_image(my_scale); 770 } 771 /** 772 * Autoplay function 773 */ 774 settings.my_autoplay_function=''; 775 settings.my_stop_autoplay=false; 776 my_autoplay_function_12=function(){ 777 //var $this=this; 778 $this.timeline('my_autoplay'); 779 }; 780 if(settings.autoplay){ 781 $this.timeline("my_debug","AutoplayStep",settings.autoplay_step); 782 if(settings.is_mobile&&settings.autoplay_mob){ 783 $this.timeline("my_debug","Autoplay for mobil",settings.autoplay_mob); 784 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step); 785 $this.data('my_settings',settings); 786 $this.bind('touchstart',function(e){ 787 settings.my_stop_autoplay=true; 788 $this.timeline("my_debug","Autoplay touch stop autoplay"); 789 $this.data('my_settings',settings); 790 /*if(settings.my_autoplay_function!=''){ 791 clearTimeout(settings.my_autoplay_function); 792 }*/ 793 794 /*if(settings.my_autoplay_function!=''){ 795 clearTimeout(settings.my_autoplay_function); 796 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step*6); 797 $this.data('my_settings',settings); 798 }*/ 799 }); 800 $this.bind('touchend',function(e){ 801 settings.my_stop_autoplay=false; 802 $this.timeline("my_debug","Autoplay touch end set new timeout"); 803 $this.data('my_settings',settings); 804 805 if(settings.my_autoplay_function!=''){ 806 clearTimeout(settings.my_autoplay_function); 807 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step*4); 808 $this.data('my_settings',settings); 809 } 810 }); 811 }else if(!settings.is_mobile){ 812 $this.timeline("my_debug","Autoplay set timeout",settings.autoplay_step); 813 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step); 814 $this.data('my_settings',settings); 815 $this.bind('mouseenter',function(e){ 816 settings.my_stop_autoplay=true; 817 $this.timeline("my_debug","Autoplay mouseover clear timeout"); 818 $this.data('my_settings',settings); 819 /*if(settings.my_autoplay_function!=''){ 820 clearTimeout(settings.my_autoplay_function); 821 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step); 822 $this.data('my_settings',settings); 823 }*/ 824 }); 825 $this.bind('mouseleave',function(e){ 826
826 settings.my_stop_autoplay=false; 827 $this.timeline("my_debug","Autoplay set timeout mouseout"); 828 $this.data('my_settings',settings); 829 /*if(settings.my_autoplay_function!=''){ 830 clearTimeout(settings.my_autoplay_function); 831 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step); 832 $this.data('my_settings',settings); 833 }*/ 834 }); 835 } 836 } 837 var myh12=$this.find(".item").height();//$(".t_left").height(); 838 var mydiff=0; 839 myh12-=mydiff;//*2; 840 var my_top_12=$this.find(".timeline_items_wrapper").css('margin-top'); 841 $this.find(".t_left , .t_right").css({top:my_top_12,height:myh12+'px'}); 842 var my_class_12_123=''; 843 $this.find(".t_left , .t_right").on('click',function(){ 844 845 }); 846 var my_scrolling_12_123=false; 847 /*$this.find(".t_left , .t_right").on("mouseenter",function(e){ 848 if(my_debug_12&&window.console){ 849 console.log('T left T right mouse enter'); 850 851 } 852 //return; 853 var $p=$(this); 854 my_slider_set_timeout_12=setTimeout(function(e){ 855 //var $p=$(e.target); 856 $p.finish(); 857 $this.find(".timeline_items_holder").finish('my_left_12'); 858 var w=$p.width(); 859 $p.data('my-w-12',w); 860 w+=20; 861 var m_l=$this.find(".timeline_items").css('margin-left'); 862 if(my_debug_12&&window.console){ 863 console.log('Animate t_left t_right before',{m_l:m_l,w:w}); 864 865 } 866 867 $this.find(".timeline_items").data('my-l-12',m_l); 868 869 m_l=parseFloat(m_l); 870 $this.timeline("my_debug","mouse eneter",{w:w,m_l:m_l}); 871 if($p.hasClass("t_left")){ 872 m_l=100; 873 my_class_12_123='t_left'; 874 }else { 875 my_class_12_123='t_right'; 876 m_l=-100; 877 } 878 if(my_debug_12&&window.console){ 879 console.log('Animate t_left t_right',{m_l:m_l,w:w}); 880 881 } 882 //$p.unbind("mouseleave",my_slider_mouse_leave_arrows); 883 //$p.on('mouseleave',my_slider_mouse_leave_arrows); 884 $p.animate({width:w},350,function(){ 885 886 }); 887 888 $this.find(".timeline_items_holder").animate({'margin-left':m_l,'queue':'my_left_12'},350); 889 my_slider_set_timeout_12=''; 890 var data = $this.data('timeline'); 891 892 //data.margin=m_l; 893 },200); 894 }); 895 my_slider_mouse_leave_arrows=function(e){ 896 //return; 897 //if(typeof data.open!='undefined' && data.open)return; 898 if(my_slider_set_timeout_12!=''){ 899 clearTimeout(my_slider_set_timeout_12); 900 my_slider_set_timeout_12=''; 901 if(my_debug_12&&window.console){ 902 console.log('Mouse leave arrow clear timeouyt'); 903 904 } 905 return; 906 }; 907 $(this).finish(); 908 $this.find(".timeline_items_holder").finish('my_left_12'); 909 910 var w=$(this).width(); 911 w-=20; 912 var m_l=$this.find(".timeline_items").css('margin-left'); 913 m_l=parseFloat(m_l); 914 if(my_debug_12&&window.console){ 915 console.log('Animate mouse leave t_left t_right before',{m_l:m_l,w:w}); 916 917 } 918 919 $this.timeline("my_debug","Mouse leave",{w:w,m_l:m_l,cl:my_class_12_123}); 920 if(my_class_12_123=="t_left"){ 921 m_l-=100; 922 }else { 923 m_l+=100; 924 } 925 if(my_debug_12&&window.console){ 926 console.log('Animate t_left t_right mouse leave',{m_l:m_l,w:w}); 927 928 } 929 930 $(this).animate({width:w},350,function(){ 931 932 }); 933 $this.find(".timeline_items_holder").animate({'margin-left':m_l,'queue':'my_left_12'},350); 934 //var data = $this.data('timeline'); 935 //data.margin=m_l; 936 };//); 937 */ 938 $this.find(".t_left , .t_right").on("mouseenter",function(e){ 939 //return; 940 var $p=$(this); 941 my_slider_set_timeout_12=setTimeout(function(e){ 942 //var $p=$(e.target); 943 $p.finish(); 944 $this.find(".timeline_items_holder").finish('my_left_12'); 945 946 var w=$p.width(); 947 $p.data('my-w-12',w); 948 w+=20; 949 var m_l=$this.find(".timeline_items").css('margin-left'); 950 $this.find(".timeline_items").data('my-l-12',m_l); 951 952 m_l=parseFloat(m_l); 953 $this.timeline("my_debug","mouse eneter",{w:w,m_l:m_l}); 954 if($p.hasClass("t_left")){ 955 m_l=100; 956 my_class_12_123='t_left'; 957 }else { 958 my_class_12_123='t_right';
959 m_l=-100; 960 } 961 //$p.unbind("mouseleave",my_slider_mouse_leave_arrows); 962 //$p.on('mouseleave',my_slider_mouse_leave_arrows); 963 $p.animate({width:w},350,function(){ 964 965 }); 966 967 $this.find(".timeline_items_holder").animate({'margin-left':m_l,'queue':'my_left_12'},350); 968 my_slider_set_timeout_12=''; 969 var data = $this.data('timeline'); 970 971 //data.margin=m_l; 972 },130); 973 }); 974 my_slider_mouse_leave_arrows=function(e){ 975 //return; 976 //if(typeof data.open!='undefined' && data.open)return; 977 if(my_slider_set_timeout_12!=''){ 978 clearTimeout(my_slider_set_timeout_12); 979 return; 980 }; 981 $(this).finish(); 982 $this.find(".timeline_items_holder").finish('my_left_12'); 983 984 var w=$(this).width(); 985 w-=20; 986 var m_l=$this.find(".timeline_items").css('margin-left'); 987 m_l=parseFloat(m_l); 988 $this.timeline("my_debug","Mouse leave",{w:w,m_l:m_l,cl:my_class_12_123}); 989 if(my_class_12_123=="t_left"){ 990 m_l=0; 991 }else { 992 m_l=0; 993 } 994 995 $(this).animate({width:w},350,function(){ 996 997 }); 998 $this.find(".timeline_items_holder").animate({'margin-left':m_l,'queue':'my_left_12'},350); 999 //var data = $this.data('timeline'); 1000 //data.margin=m_l; 1001 };//); 1002 $this.on("mouseleave",function(e){ 1003 $this.find(".t_left , .t_right").animate({opacity:0}
1003,150); 1004 }); 1005 $this.on("mouseenter",function(e){ 1006 $this.find(".t_left , .t_right").animate({opacity:1},150); 1007 }); 1008 $this.find(".t_left , .t_right").on("mouseleave",my_slider_mouse_leave_arrows); 1009 my_center_style_3=function(){ 1010 var c=$this.attr('class'); 1011 //console.log("Window.load",c) 1012 if($this.hasClass('my_style_style_3')){ 1013 $this.find(settings.itemClass).each(function(i,v){ 1014 var i_h=$this.find('img').height(); 1015 var t_h=$(v).find(".my_timeline_content").outerHeight(); 1016 var it_h=$this.find('.item').height(); 1017 var top=it_h-i_h-t_h; 1018 var p=0; 1019 if(top>0){ 1020 p=top/2; 1021 1022 } 1023 //console.log("Center style",{image_h:i_h,t_h:t_h,it_h:it_h,left:left,p:p}); 1024 $this.timeline("my_debug","Center style",{image_h:i_h,t_h:t_h,it_h:it_h,top:top,p:p}); 1025 if(p!=0){ 1026 $(v).find(".my_timeline_content").css('bottom',p+'px'); 1027 } 1028 1029 }); 1030 } 1031 }; 1032 //var my_click_12_left=false,my_click_12_right=false; 1033 my_center_style_3(); 1034 // Bind keyLeft and KeyRight functions 1035 $(document).keydown(function(e){ 1036 if (e.keyCode == 37) { 1037 $this.timeline('left'); 1038 return false; 1039 } 1040 if (e.keyCode == 39) { 1041 $this.timeline('right'); 1042 return false; 1043 } 1044 }); 1045 //scale image to window resizing 1046 $(window).resize(function(){ 1047 imageFit('.con_borderImage'); 1048 }); 1049 // Respond to window resizing 1050 $(window).resize(function() { 1051 var my_settings=$this.data('my_settings'); 1052 if(typeof my_settings=='undefined'){ 1053 my_settings=settings; 1054 } 1055 var data = $this.data('timeline'); 1056 var speed = data.options.scrollSpeed, 1057 easing = data.options.easing, 1058 $items = data.items, 1059 timelineWidth = $this.find('.timeline_line').width(), 1060 count = -1, 1061 found = false; 1062 var id; 1063 if(my_settings.vertical==1){ 1064 id=$this.find(".myVerticalRow:eq("+data.currentIndex+") .item").attr('data-id'); 1065 }else { 1066 id=$this.find(".item:eq("+data.currentIndex+")").attr('data-id'); 1067 } 1068 if(my_debug_12&&window.console){ 1069 console.log('Reposition Line',{data:data,id:id,curr:data.currentIndex}); 1070 1071 } 1072 var $nodes = $this.find('.t_line_node'); 1073 $nodes.removeClass('active'); 1074 var $goToNode = $nodes.parent().parent().find('[href="#'+id+'"]').addClass('active'); 1075 data.lineMargin = -parseInt($goToNode.parent().parent().attr('data-id'),10)*100; 1076 1077 // check if responsive width 1078 if(my_debug_12&&window.console){ 1079 console.log('Line margin',{margin:data.lineMargin}); 1080 1081 } 1082 if($this.find('.t_line_view:first').width() > $this.find('.timeline_line').width()) { 1083 data.lineMargin *=2; 1084 if ($goToNode.parent().hasClass('right')) data.lineMargin -= 100; 1085 } 1086 1087 if(data.noAnimation){ 1088 data.noAnimation = false; 1089 1090 $this.find('.t_line_wrapper').stop(true).css({marginLeft : data.lineMargin+'%'}); 1091 } 1092 else { 1093 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing ); 1094 } 1095 1096 //var id = $this.find('.active:first').attr('href').substr(1); 1097 /** 1098 * my chnage 1099 */ 1100 var my_w=$this.width(); 1101 var my_l=$this.find(".t_line_holder").width(); 1102 /*if(window.console){ 1103 console.log('Widths',{my_w:my_w,my_l:my_l}); 1104 }*/ 1105 1106 var my_diff=my_w-my_l; 1107 //var my_diff=my_w-my_l; 1108 if(my_diff<60&&my_diff>0){ 1109 /*if(window.console){ 1110 console.log('Diff',{my_diff:my_diff}); 1111 }*/ 1112 if(my_diff>0){ 1113 var my_p=my_diff/2+4; 1114 $this.find('#t_line_left').css('left','-'+my_p+'px'); 1115 $this.find('#t_line_right').css('right','-'+my_p+'px'); 1116 1117 } 1118 } 1119 var my_w_12=$this.width(); 1120 if($this.hasClass('my_style_style_4')){ 1121 my_styel_4_resize_image(my_scale); 1122 } 1123 /** 1124 * set width of content on full widt 1125 */ 1126 /*var my_w_item_12=$this.find(".item").width(); 1127 if(my_w_12<500){ 1128 if(my_w_item_12>my_w_12){ 1129 $this.find(".item").css('width',my_w_12); 1130 1131 } 1132 }*/ 1133 /*if(window.console){ 1134 console.log('width',my_w_12); 1135 }*/ 1136 //my_w_12-=40; 1137 $this.find('.timeline_items_holder').css({width: my_w_12+'px'}); 1138 /* 1139 * end changes 1140 */ 1141 1142 my_scale=my_500px_window_function(); 1143 my_scale_items_12(my_scale); 1144 1145 if(my_debug_12&&window.console){ 1146 console.log('Scale factor',my_scale); 1147 } 1148 my_500px_window_function(); 1149 var my_settings=$this.data('my_settings'); 1150 my_settings.my_scale=my_scale; 1151 $this.data('my_settings',my_settings); 1152 var data = $this.data('timeline'); 1153 data.my_resize_12=true; 1154 var my_width=$this.find(".timeline_items_wrapper").width(); 1155 var width; 1156 //bug when change or resize view from smaller to grater this width stays 1157 //same from previous width 1158 /*if(my_width<610){ 1159 width=260; 1160 }else { 1161 width = data.itemOpenWidth; 1162 }*/ 1163 width=$this.find(".item_open").width(); 1164 var my_scale_open=$this.find(".item_open").data('my-scale'); 1165 if(data.open){ 1166 if(typeof data != 'undefined') { 1167 var id = $items.eq(data.currentIndex).attr('data-id'); 1168 /* 1169 itemWidth = $items.first().width(), 1170 itemOpenWidth = $itemsOpen.first().find('div:first').width(); 1171 1172 data.margin += data.itemCount*(data.itemWidth-itemWidth); 1173 data.itemWidth = itemWidth; 1174 1175 if(data.open) data.margin += (data.itemOpenWidth-itemOpenWidth)/2; 1176 data.itemOpenWidth = itemOpenWidth; 1177 1178 1179 if($('body').width() < 767 && data.open && !data.marginResponse) { 1180 data.margin -= (itemWidth+settings.itemMargin)/2; 1181 data.marginResponse = true; 1182 } 1183 else if($('body').width() >= 767 && data.marginResponse && data.open) { 1184 data.margin += (itemWidth+settings.itemMargin)/2; 1185 data.marginResponse = false;
1186 } 1187 */ 1188 //var my_scale=data.my_scale; 1189 var my_diff_pos=0; 1190 width = data.itemOpenWidth; 1191 var my_width_12=$this.find(".item_open").data('my-width'); 1192 if(typeof my_width_12!='undefined'){ 1193 $this.timeline("my_debug","Open Change open width",{width:width,my_width_12:my_width_12}); 1194 width=my_width_12; 1195 1196 } 1197 $this.timeline("my_debug","Resize scale factors",{my_scale:my_scale,my_scale_open:my_scale_open}); 1198 1199 var my_width=$this.find(".timeline_items_wrapper").width(); 1200 if(my_scale<1 || my_scale_open<1){ 1201 1202 var my_o_12_w=width;//$this.find(".item_open").width(); 1203 var my_12_w=$this.find(".item").width(); 1204 var itemWidth=my_12_w; 1205 var containerWidth=my_width; 1206 if(my_scale_open<1&&my_scale==1){ 1207 var leftOrRight=Math.abs(containerWidth-itemWidth-data.options.itemMargin)/2; 1208 my_diff_pos=-(leftOrRight+data.options.itemMargin+itemWidth); 1209 1210 } 1211 else { 1212 // blio je my_diff_pos=-((my_width+data.options.itemMargin+width)/2);//-((data.itemWidth)+(data.options.itemMargin))/2-(my_o_12_w/2); 1213 if(my_scale<1){ 1214 my_diff_pos=-(my_width+width)/2; 1215 } 1216 else my_diff_pos=-((itemWidth+data.options.itemMargin+width)/2);//-((data.itemWidth)+(data.options.itemMargin))/2-(my_o_12_w/2);//my_diff_pos=-(my_width+data.optons) 1217 } 1218 $this.timeline("my_debug","Resize Calculate position scale<1",{itemWidth:itemWidth,openWidth:width,containerWidth:my_width,my_scale_1:my_scale_1,my_scale:my_scale,my_diff_pos:my_diff_pos}); 1219 1220 data.my_diff_pos=my_diff_pos; 1221 }else { 1222 //var my_old_width=my_settings.my_width_12; 1223 //my_diff=-(my_width-my_old_width) 1224 /*if(window.console){ 1225 console.log("My scall1 <1 my_scale_1==1",my_diff); 1226 }*/ 1227 my_diff_pos=-((data.itemWidth)+(data.options.itemMargin))/2-((width+data.options.itemMargin)/2); 1228 1229 $this.timeline("my_debug","Resize Calculate position scale==1",{my_scale:my_scale,my_diff_pos:my_diff_pos}); 1230 1231 my_settings.my_width_12=my_width; 1232 data.my_diff_pos=my_diff_pos; 1233 } 1234 1235 //data.my_diff_window_resize=-my_diff/2; 1236 1237 data.margin+=my_diff_pos; 1238 $this.timeline("my_debug","Data margin",{my_scale:my_scale,my_diff_pos:my_diff_pos,margin:data.margin}); 1239 1240 data.iholder.css('margin-left',data.margin); 1241 1242 /** 1243 * Pre bilo menjam samo margine 1244 * 1245 data.noAnimation = true; 1246 //$this.timeline('close',id,data.my_count); 1247 $this.timeline('goTo', id,data.my_count); 1248 */ 1249 } 1250 } 1251 }); 1252 1253 1254 $(document).ready(function(){ 1255 1256 $('.timeline_items .item img').on('dragstart', function(event) { 1257 if (!($(this).hasClass('timeline_rollover_bottom'))) 1258 event.preventDefault(); 1259 }); 1260 1261 1262 $('.timeline_items .timeline_rollover_bottom').on('dragstart', function(event) { 1263 1264 $(this).addClass("disableClick"); 1265 event.preventDefault(); 1266 }); 1267 /*$('.timeline_items .my_open_dialog').on('mousedown',function(e){ 1268 e.preventDefault(); 1269 e.stopPropagation(); 1270 }); 1271 $("#my_timeline_share_click").on('mousedown',function(e){ 1272 e.preventDefault(); 1273 e.stopPropagation(); 1274 });*/ 1275 1276 $('.timeline_items .timeline_rollover_bottom').on('mousedown', function(event) { 1277 if (!$(this).is("hover")) { 1278 $(this).removeClass("disableClick"); 1279 } 1280 }); 1281 1282 $('.timeline_items .timeline_rollover_bottom').on('click', function(event) { 1283 if ($(this).hasClass('disableClick')) { 1284 event.preventDefault(); 1285 event.stopPropagation(); 1286 } 1287 $(this).removeClass('disableClick') 1288 }); 1289 1290 //SEARCH CARDS 1291 $('#search-cards').keyup(function(){ 1292 1293 var valThis = $(this).val().toLowerCase(); 1294 1295 var data_count = 0; 1296 var data_count_open = 0; 1297 1298 if(valThis != '') { 1299 1300 $('.timeline .item, #content .timeline .item').each(function(){ 1301 1302 var textTitle = $(this).find('h2').text().toLowerCase(); 1303 var textSpan = $(this).find('span').text().toLowerCase(); 1304 1305 if($(this).find('h2').text().toLowerCase().indexOf(valThis) == -1 && $(this).find('span').text().toLowerCase().indexOf(valThis) == -1 1306 && $(this).next().find('h2').text().toLowerCase().indexOf(valThis) == -1){ 1307 1308 $(this).addClass('disable-cards-elements').find('*').addClass('disable-cards-elements'); 1309 /*$(this).attr('data-count', data_count); 1310 console.log($(this).attr('data-count')); 1311 data_count++;*/ 1312 1313 $('#t_line_backward').trigger('click'); 1314 } 1315 else { 1316 1317 $(this).removeClass('disable-cards-elements').find('*').removeClass('disable-cards-elements'); 1318 1319 $(this).attr('data-count', data_count); 1320 $(this).find('.read_more').attr('data-count', data_count); 1321 $(this).next().attr('data-count', data_count_open); 1322 $(this).next().find('.t_close').attr('data-count', data_count_open); 1323 1324 data_count++; 1325 data_count_open++; 1326 $('#t_line_backward').trigger('click'); 1327 } 1328 1329 }); 1330 } 1331 else { 1332 $('.timeline .item, #content .timeline .item').each(function(){ 1333 $(this).removeClass('disable-cards-elements').find('*').removeClass('disable-cards-elements'); 1334 $(this).attr('data-count', data_count); 1335 $(this).find('.read_more').attr('data-count', data_count); 1336 $(this).next().attr('data-count', data_count_open); 1337 $(this).next().find('.t_close').attr('data-count', data_count_open); 1338 1339 data_count++; 1340 data_count_open++; 1341 $('#t_line_backward').trigger('click'); 1342 }); 1343 } 1344 1345 }); 1346 }); 1347 1348 1349 1350 1351 1352 // Bind left on click 1353 $this.find('.t_left').click(function(){ 1354 var data = $this.data('timeline'), 1355 speed = data.options.scrollSpeed; 1356 //data.margin+=100; 1357 var my_do=false; 1358 data.my_click_12_left=false; 1359 //$this.find(".timeline_items").finish(); 1360 if (data.currentIndex > 0){ 1361 my_do=true; 1362 $this.find(".t_left , .t_right").animate({opacity:0}
1362,100); 1363 data.my_click_12_left=true; 1364 } 1365 1366 $this.timeline('left'); 1367 if(my_do){ 1368 setTimeout(function(){ 1369 $this.find(".t_left , .t_right").animate({opacity:1},100); 1370 data.my_click_12_left=false; 1371 },speed); 1372 } 1373 1374 }); 1375 1376 // Bind right on click 1377 $this.find('.t_right').click(function(){ 1378 //$this.find(".timeline_items").finish(); 1379 var data = $this.data('timeline'), 1380 speed = data.options.scrollSpeed; 1381 //data.margin-=100; 1382 var my_do=false; 1383 1384 data.my_click_12_right=false; 1385 if (data.currentIndex < data.itemCount-1){ 1386 my_do=true; 1387 data.my_click_12_right=true; 1388 $this.find(".t_left , .t_right").animate({opacity:0},100); 1389 } 1390 $this.timeline('right'); 1391 if(my_do){ 1392 setTimeout(function(){ 1393 $this.find(".t_left , .t_right").animate({opacity:1},100); 1394 data.my_click_12_right=false; 1395 },speed); 1396 } 1397 1398 }); 1399 1400 // SWIPE bind 1401 1402 if(settings.swipeOn) { 1403 $items.find('*').each(function(){ 1404 $(this).css({'-webkit-touch-callout': 'none', 1405 '-webkit-user-select': 'none', 1406 '-khtml-user-select': 'none', 1407 '-moz-user-select': 'none', 1408 '-ms-user-select': 'none', 1409 'user-select': 'none'}); 1410 }); 1411 $this.bind('touchstart',function(e){ 1412 $this.timeline('touchStart', e); 1413 }); 1414 1415 1416 $this.find(settings.itemClass).mousedown(function(e){ 1417 var c=$(e.target).attr('class'); 1418 /*if(window.console){ 1419 console.log('c',c); 1420 }*/ 1421 if($(e.target).hasClass("my_open_dialog")){ 1422 return; 1423 } 1424 if($(e.target).hasClass("my_icon")){ 1425 return; 1426 } 1427 $this.timeline('mouseDown', e.pageX); 1428 }); 1429 1430 1431 $(document).bind('touchend',function(e){ 1432 data = $this.data('timeline'); 1433 $this.timeline('touchEnd', data.touchpos); 1434 }); 1435 1436 $(document).mouseup(function(e){ 1437 var c=$(e.target).attr('class'); 1438 /*if(window.console){ 1439 console.log('c',c); 1440 }*/ 1441 if($(e.target).hasClass("my_open_dialog")){ 1442 return; 1443 } 1444 if($(e.target).hasClass("my_icon")){ 1445 return; 1446 } 1447 var data = $this.data('timeline'); 1448 if(typeof data != 'undefined' && data.mousedown) { 1449 $this.timeline('mouseUp', e.pageX); 1450 } 1451 }); 1452 } 1453 1454 1455 1456 // Bind open on click 1457 if(settings.my_post_link==0){ 1458 $this.find(settings.openTriggerClass).click(function(){ 1459 $this.timeline("my_debug","Click on read more",{id:$(this).attr('data-id'), count:$(this).attr('data-count')}); 1460 1461 $this.timeline('goTo',$(this).attr('data-id'), $(this).attr('data-count'), true); 1462 }); 1463 $this.find(".my_read_more").click(function(){ 1464 $this.timeline("my_debug","Click on read more",{id:$(this).attr('data-id'), count:$(this).attr('data-count')}); 1465 1466 $this.timeline('goTo',$(this).attr('data-id'), $(this).attr('data-count'), true); 1467 1468 }); 1469 }else { 1470 $this.find(".my_read_more").click(function(){ 1471 var url=$(this).data('href'); 1472 var win = window.open(url, '_blank'); 1473 win.focus() 1474 }); 1475 } 1476 // Bind close on click 1477 $this.find('.t_close').click(function(){ 1478 $this.timeline("my_debug","Click cloce open",{id:$(this).attr('data-id'), count:$(this).attr('data-count')}); 1479 1480 $this.timeline('close',$(this).attr('data-id'),$(this).attr('data-count')); 1481 }); 1482 1483 // Show when loaded 1484 $this.css({height: 'auto'}).show(); 1485 $this.prev('.timelineLoader').hide(); 1486 1487 // Reposition nodes due to their width 1488 $this.find('.t_line_node').each(function(){ 1489 if($(this).width() < 10) $(this).width(12); 1490 $(this).css({marginLeft: -$(this).width()/2}); 1491 }); 1492 /** 1493 * Changes width 1494 */ 1495 var my_w=$this.width(); 1496 var my_l=$this.find(".t_line_holder").width(); 1497 /*if(window.console){ 1498 console.log('Widths',{my_w:my_w,my_l:my_l}); 1499 }*/ 1500 //if(my_w<280){ 1501 var my_diff=my_w-my_l; 1502 if(my_diff<60&&my_diff>0){ 1503 /*if(window.console){ 1504 console.log('Diff',{my_diff:my_diff}); 1505 }*/ 1506 if(my_diff>0){ 1507 var my_p=my_diff/2+4; 1508 $this.find('#t_line_left').css('left','-'+my_p+'px'); 1509 $this.find('#t_line_right').css('right','-'+my_p+'px'); 1510 1511 } 1512 /*var my_w_1=my_w-40; 1513 var my_style=$this.find(".t_line_holder").attr('style'); 1514 if(window.console){ 1515 console.log('Style',my_style); 1516 } 1517 my_style=my_style.replace('width:100%;','width:'+my_w_1+'px !important;'); 1518 if(window.console){ 1519 console.log('Style new',my_style); 1520 } 1521 $this.find(".t_line_holder").attr('style',my_style); 1522 //$this.find(".timeline_line").css('width',my_w_1+'px !important') 1523 */ 1524 }else { 1525 $this.find('#t_line_left').css('left',''); 1526 $this.find('#t_line_right').css('right',''); 1527 1528 } 1529 /** 1530 * changes 1531 */ 1532 return $this; 1533 }, 1534 1535 // Clear data 1536 destroy : function( ) { 1537 $(document).unbind('mouseup'); 1538 $(window).unbind('resize'); 1539 var $this = this, 1540 data = $this.data('timeline'); 1541 $this.removeData('timeline'); 1542 1543 }, 1544 1545 touchStart : function(evt) { 1546 var $this = this, 1547 data = $this.data('timeline'), 1548 xmargin = 0; 1549 data.xpos = evt.originalEvent.touches[0].pageX, 1550 data.ypos = evt.originalEvent.touches[0].pageY; 1551 data.mousedown = true; 1552 data.touchHorizontal = false;
1553 data.mousestartpos = data.xpos; 1554 $this.unbind('touchmove'); 1555 $this.bind('touchmove', function(e){ 1556 var newx = e.originalEvent.touches[0].pageX, 1557 newy = e.originalEvent.touches[0].pageY; 1558 if(data.mousedown && !data.touchHorizontal) { 1559 if(Math.abs(newx-data.xpos) > Math.abs(newy-data.ypos)) { 1560 data.touchHorizontal = true; 1561 } 1562 } 1563 else if(data.touchHorizontal) { 1564 e.preventDefault(); 1565 data.touchpos = e.originalEvent.touches[0].pageX; 1566 xmargin = data.margin - data.xpos + e.originalEvent.touches[0].pageX; 1567 data.iholder.css('marginLeft', xmargin + 'px'); 1568 } 1569 data.mousedown = false 1570 }); 1571 }, 1572 1573 mouseDown : function(xpos) { 1574 var $this = this, 1575 data = $this.data('timeline'), 1576 xmargin = 0; 1577 data.mousedown = true; 1578 data.mousestartpos = xpos; 1579 1580 $('body').css('cursor','move'); 1581 $(document).mousemove(function(e){ 1582 xmargin = data.margin - xpos + e.pageX; 1583 data.iholder.css('marginLeft', xmargin + 'px'); 1584 }); 1585 }, 1586 1587 touchEnd : function(xpos) { 1588 var $this = this, 1589 data = $this.data('timeline'), 1590 itemWidth = data.itemWidth + data.options.itemMargin, 1591 itemC = data.currentIndex, 1592 mod = 0, 1593 xmargin = xpos - data.mousestartpos; 1594 itemWidth=$this.find(".item").width()+data.options.itemMargin; 1595 var my_calc_old_1=-itemWidth/2; 1596 var my_calc_old_2=itemWidth/2; 1597 var my_del=Math.floor(itemWidth/data.options.my_del); 1598 if(my_del>5)my_del=5; 1599 1600 my_calc_old_1=-itemWidth/my_del; 1601 my_calc_old_2=itemWidth/my_del; 1602 1603 if(typeof data.touchHorizontal != 'undefined' && data.touchHorizontal) { 1604 data.touchHorizontal = false; 1605 1606 itemC -= parseInt(xmargin/itemWidth); 1607 mod = xmargin%itemWidth; 1608 $this.timeline("my_debug","touchend",{xmargin:xmargin,mod:mod,my_del:my_del,my_calc_old_1:my_calc_old_1,my_calc_old_2:my_calc_old_2}); 1609 1610 if (xmargin < 0 && mod > my_calc_old_1) { 1611 itemC++; 1612 } 1613 if (xmargin > 0 && mod < my_calc_old_2) { 1614 itemC--; 1615 } 1616 1617 if(itemC < 0) { 1618 itemC = 0; 1619 } 1620 if(itemC >= data.itemCount) { 1621 itemC = data.itemCount-1; 1622 } 1623 1624 $this.timeline('goTo', data.items.eq(itemC).attr('data-id'), data.items.eq(itemC).attr('data-count')); 1625 if (data.options.closeItemOnTransition) 1626 $this.timeline('close', data.items.eq(itemC).attr('data-id')); 1627 } 1628 }, 1629 1630 mouseUp : function(xpos) { 1631 1632 var $this = this, 1633 data = $this.data('timeline'), 1634 itemWidth = data.itemWidth + data.options.itemMargin, 1635 itemC = data.currentIndex, 1636 mod = 0, 1637 xmargin = xpos - data.mousestartpos; 1638 data.mousedown = false; 1639 itemWidth=$this.find(".item").width()+data.options.itemMargin; 1640 var my_calc_old_1=-itemWidth/2; 1641 var my_calc_old_2=itemWidth/2; 1642 var my_del=Math.floor(itemWidth/data.options.my_del); 1643 if(my_del>5)my_del=5; 1644 1645 my_calc_old_1=-itemWidth/my_del; 1646 my_calc_old_2=itemWidth/my_del; 1647 1648 $(document).unbind('mousemove'); 1649 $('body').css('cursor','auto'); 1650 1651 itemC -= parseInt(xmargin/itemWidth); 1652 mod = xmargin%itemWidth; 1653 $this.timeline("my_debug","Mouse Up",{xmargin:xmargin,mod:mod,my_del:my_del,my_calc_old_1:my_calc_old_1,my_calc_old_2:my_calc_old_2}); 1654 1655 if (xmargin < 0 && mod < my_calc_old_1) { 1656 itemC++; 1657 } 1658 if (xmargin > 0 && mod > my_calc_old_2) { 1659 itemC--; 1660 } 1661 1662 if(itemC < 0) { 1663 itemC = 0; 1664 } 1665 if(itemC >= data.itemCount) { 1666 itemC = data.itemCount-1; 1667 }
1668 if(!is_touch_device()) { 1669 $this.timeline('goTo', data.items.eq(itemC).attr('data-id'), data.items.eq(itemC).attr('data-count')); 1670 if (data.options.closeItemOnTransition) {} 1671 $this.timeline('close', data.items.eq(itemC).attr('data-id')); 1672 } 1673 /*if (data.options.closeItemOnTransition) {} 1674 $this.timeline('close', data.items.eq(itemC).attr('data-id'));*/ 1675 1676 }, 1677 1678 open : function (id, data_count) { 1679 1680 var $this = this, 1681 data = $this.data('timeline'), 1682 $items = $this.find(data.options.itemOpenClass), 1683 speed = data.options.scrollSpeed, 1684 width = data.itemOpenWidth, 1685 easing = data.options.easing, 1686 itemMargin = data.options.itemMargin; 1687 var my_width_12=$this.find(".item_open").data('my-width'); 1688 if(typeof my_width_12!='undefined'){ 1689 $this.timeline("my_debug","Open Change open width",{width:width,my_width_12:my_width_12}); 1690 width=my_width_12; 1691 } 1692 $this.find(".item_open_cwrapper").width(width); 1693 1694 1695 var my_settings=$this.data('my_settings'); 1696 var my_scale=my_settings.my_scale; 1697 var my_scale_open=$this.find(".item_open").data('my-scale'); 1698 if((my_scale<1) ||(my_scale_open<1)){ 1699 var my_start_item=0; 1700 var my_end_item=1; 1701 var my_count=1; 1702 $this.timeline("my_debug","Open Start end pos scale<1",{my_start:my_start_item,my_end:my_end_item,my_count:my_count,my_scale:my_scale}); 1703 var my_width=$this.find(".timeline_items_wrapper").width(); 1704 /*if(my_width<610){ 1705 width=260; 1706 1707 }*/ 1708 //my_widthdata.options.itemMargin; 1709 $this.timeline("my_debug","Open open width",{width:width}); 1710 var itemWidth=$this.find(".item").width(); 1711 var my_width_1=itemWidth+data.options.itemMargin; 1712 $this.timeline("my_debug","Open my_scale<1",{itemWidth:itemWidth,my_width_1:my_width_1}); 1713 }else { 1714 var my_visible_area_left=Math.abs(data.margin); 1715 var my_width=$this.find(".timeline_items_wrapper").width(); 1716 var my_left=$this.find(".timeline_items_wrapper").offset().left; 1717 var my_visible_area_right=data.margin+my_width; 1718 var my_width_1=data.itemWidth+data.options.itemMargin; 1719 var my_start_item=Math.floor(Math.abs(my_visible_area_left)/my_width_1); 1720 var my_end_item=my_start_item+Math.ceil(my_width/my_width_1)-1; 1721 var my_total_items=Math.ceil(my_width/my_width_1); 1722 var my_pos_12=Math.floor(my_total_items/2); 1723 var my_pos=my_pos_12; 1724 $this.timeline("my_debug","Set correct position ",{my_pos_12:my_pos_12,my_total_items:my_total_items,my_width_1:my_width_1,my_pos_12:my_pos_12}); 1725 1726 1727 var my_inner_items=Math.ceil(my_width/my_width_1); 1728 /* if(my_width<610){ 1729 width=260; 1730 }*/ 1731 $this.timeline("my_debug","Open open width",{width:width,my_width:my_width}); 1732 $this.timeline("my_debug","Open Start end pos scale=1",{id:id,inner:my_inner_items,data_count:data_count,left:my_visible_area_left,right:my_visible_area_right,my_width_1:my_width_1,my_start:my_start_item,my_end:my_end_item}); 1733 $this.timeline("my_debug","Open Start end pos scale=1",{width:width,my_start_item:my_start_item,my_end_item:my_end_item}); 1734 var my_pom=0; 1735 var my_curr=data.currentIndex; 1736 var my_left; 1737 var my_margin,my_margin_abs; 1738 var my_diff_left,my_diff_right,my_diff_pos; 1739 var my_move=0; 1740 var my_center_pos; 1741 var my_pos_right=0,my_pos_left=0; 1742 if(typeof data.my_pos_curr!='undefined'){ 1743 $this.timeline("my_debug","Open Correct position",{my_curr:my_curr,new_pos:data.my_pos_curr}); 1744 1745 my_curr=data.my_pos_curr; 1746 1747 } 1748 $this.timeline("my_debug","Open position",{my_curr:my_curr,new_pos:data.my_pos_curr}); 1749 1750 if(data.margin>0){ 1751 my_start_item=0; 1752 my_end_item=my_start_item+Math.ceil(my_width/my_width_1)-1; 1753 /*my_pos=0; 1754 if(data_count>0){ 1755 my_pos=data_count-1; 1756 }*/ 1757 my_pos_left=0;//data.margin;//+data.options.itemMargin; 1758 } 1759 /*if(my_curr==0){ 1760 my_start_item=0; 1761 my_end_item+=Math.ceil(my_width/my_width_1)-1; 1762 }*/ 1763 my_margin=data.margin; 1764 my_margin_abs=Math.abs(my_margin); 1765 my_center_pos=(my_margin_abs)+my_width/2; 1766 $this.timeline("my_debug","Open position",{my_margin:my_margin,my_margin_abs:my_margin_abs,my_center_pos:my_center_pos}); 1767 1768 1769 if(my_curr>0){ 1770 if(data.margin<0){ 1771 /*$items.each(function(){ 1772 var my_count=$(this).attr('data-count'); 1773 if ($(this).attr('data-id') == id) { 1774 my_pos=$(this).attr('data-count')-my_start_item; 1775 } 1776 })*/; 1777 //$items.each(function(){ 1778 // var my_count=parseInt($(this).attr('data-count')); 1779 // var ci12=0; 1780 // if(my_count==my_start_item){ 1781 var my_left_off=$this.offset().left; 1782 1783 var my_left_off_1=0; 1784 if(my_start_item>0){ 1785 my_left_off_1=my_width_1*(my_start_item); 1786 } 1787 my_diff_left=my_left_off_1-my_margin_abs; 1788 $this.timeline("my_debug","Open Calcl left",{my_left_off:my_left_off,my_left_off_1:my_left_off_1,my_diff_left:my_diff_left}); 1789 1790 if(my_diff_left<0){ 1791 my_diff_left=my_width_1+my_diff_left; 1792 } 1793 $this.timeline("my_debug","Open Calcl left",{my_left_off:my_left_off,my_left_off_1:my_left_off_1,my_diff_left:my_diff_left}); 1794 1795 /*if(ci12==0){ 1796 var my_left_off; 1797 my_left_off=$(this).offset().left; 1798 var my_left_off_1=$this.find(".timeline_items_holder").offset().left; 1799 my_diff_left=my_left_off-my_left_off_1; 1800 if(my_diff_left<0){ 1801 my_diff_left=my_width_1+my_diff_left; 1802 } 1803 $this.timeline("my_debug","Calcl left",{my_left_off:my_left_off,my_left_off_1:my_left_off_1}) 1804 1805 }*/ 1806 /*ci12++; 1807 return false;
1808 } 1809 });*/ 1810 my_pos_left=my_margin_abs+my_diff_left; 1811 $this.timeline("my_debug","Open position",{my_pos_left:my_pos_left,my_margin:my_margin,my_margin_abs:my_margin_abs,my_center_pos:my_center_pos}); 1812 } 1813 }else { 1814 my_pos_left=data.margin; 1815 } 1816 } 1817 $items.each(function(){ 1818 var my_count=$(this).attr('data-count'); 1819 if ($(this).attr('data-id') == id) { 1820 1821 //if (!data_count || data_count == $(this).attr('data-count') && ((my_count>=my_start_item)&&(my_count<=my_end_item))) { 1822 if (!data_count || data_count == $(this).attr('data-count')){ 1823 //if (data_count == $(this).attr('data-count') && ((my_count>=my_start_item)&&(my_count<=my_end_item))){ 1824 //data.my_open_item_center_12=true; 1825 //$this.data('timeline',data); 1826 $this.timeline("my_debug","Set correct position ",{my_pos:my_pos,my_pos_12:my_pos_12}); 1827 //$(this).attr('data-count')-my_start_item; 1828 1829 var $newThis = $(this); 1830 1831 var data_count_temp = $(this).attr('data-count'); 1832 1833 /*console.log($(data.options.itemClass+'[data-count="'+data_count_temp+'"] div.read_more').length); 1834 console.log(data.options.itemClass); 1835 console.log($(this).attr('data-count'));*/ 1836 1837 if ($(data.options.itemClass+'[data-count="'+data_count_temp+'"] > .read_more[href="#"]').length == 0 || $(data.options.itemClass+'[data-count="'+data_count_temp+'"] > .my_read_more[href="#"]').length == 0 ) { 1838 1839 // Trigger itemOpen event 1840 $this.trigger('itemOpen.Timeline'); 1841 1842 // Open content and move margin 1843// 1844 $(this).stop(true).show().animate({width: width, marginLeft: itemMargin/2, marginRight: itemMargin/2}, speed, easing); 1845 1846 if (typeof $(this).attr('data-access') != 'undefined' && $(this).attr('data-access') != '') { 1847 var action = $(this).attr('data-access'); 1848 $.post(action, function(data){ 1849 1850 $('body').append('<div class="ajax_preloading_holder" style="display:none"></div>'); 1851 $('.ajax_preloading_holder').html(data); 1852 if ($('.ajax_preloading_holder img').length > 0 ) { 1853 $('.ajax_preloading_holder img').load(function() { 1854 $newThis.find('.item_open_content').html(data); 1855 $('.ajax_preloading_holder').remove(); 1856 $(this).attr('data-access', ''); 1857 1858 /* trigger */ 1859 var event = jQuery.Event( 'ajaxLoaded.timeline' ); 1860 event.element = $newThis.find('.item_open_content'); 1861 $( "body" ).trigger( event ); 1862 $this.trigger(event); 1863 var my_scale_open=$this.find(".item_open").data('my-scale'); 1864 $this.timeline("my_debug","My open scale",my_scale_open); 1865 if(my_scale_open<1){ 1866 var containerWidth=$this.find(".item_open").data('my-cnt-width'); 1867 var itemOpenWidth=parseFloat(my_settings.my_sizes.active.item_width); 1868 var diff=-(Math.abs(containerWidth-itemOpenWidth))/2; 1869 1870 $this.find(".item_open a.con_borderImage ").css('left',diff+'px'); 1871 $this.timeline("my_debug","My open scale",{cntWidth:containerWidth,itemOpenWidth:itemOpenWidth,diff:diff}); 1872 1873 }else { 1874 $this.find(".item_open a.con_borderImage ").css('left',''); 1875 } 1876 }); 1877 } 1878 else { 1879 $newThis.find('.item_open_content').html(data); 1880 $('.ajax_preloading_holder').remove(); 1881 $(this).attr('data-access', ''); 1882 1883 /* trigger */ 1884 var event = jQuery.Event( 'ajaxLoaded.timeline' ); 1885 event.element = $newThis.find('.item_open_content'); 1886 $( "body" ).trigger( event ); 1887 $this.trigger(event); 1888 var my_scale_open=$this.find(".item_open").data('my-scale'); 1889 $this.timeline("my_debug","My open scale",my_scale_open); 1890 if(my_scale_open<1){ 1891 var containerWidth=$this.find(".item_open").data('my-cnt-width'); 1892 var itemOpenWidth=parseFloat(my_settings.my_sizes.active.item_width); 1893 var diff=-(Math.abs(containerWidth-itemOpenWidth))/2; 1894 $this.find(".item_open a.con_borderImage ").css('left',diff+'px'); 1895 $this.timeline("my_debug","My open scale",{cntWidth:containerWidth,itemOpenWidth:itemOpenWidth,diff:diff}); 1896 1897 }else { 1898 $this.find(".item_open a.con_borderImage ").css('left',''); 1899 } 1900 } 1901 1902 }); 1903 } 1904 var my_scale_open=$this.find(".item_open").data('my-scale'); 1905 $this.timeline("my_debug","My open scale",my_scale_open); 1906 if(my_scale_open<1){ 1907 var containerWidth=$this.find(".item_open").data('my-cnt-width'); 1908 var itemOpenWidth=parseFloat(my_settings.my_sizes.active.item_width); 1909 var diff=-(Math.abs(containerWidth-itemOpenWidth))/2; 1910 $this.timeline("my_debug","My open scale",{cntWidth:containerWidth,itemOpenWidth:itemOpenWidth,diff:diff}); 1911 $this.find(".item_open a.con_borderImage ").css('left',diff+'px'); 1912 }else { 1913 $this.find(".item_open a.con_borderImage ").css('left',''); 1914 } 1915 if($('body').width() < 767) { 1916 // data.margin -= (data.itemWidth+data.options.itemMargin)/2; 1917 data.marginResponse = true; 1918 } 1919 else { 1920 data.marginResponse = false;
1921 } 1922 //data.margin -= (width + data.options.itemMargin + data.itemWidth)/2 - data.itemWidth/2; 1923 //data.margin-=(width+data.options.iyemMargin+data.itemWidth) 1924 //data.margin-=(my_pos+1)*my_width_1-(my_width_1-width)/2; 1925 if(my_scale==1&&my_scale_open==1){ 1926 my_margin=data.margin; 1927 my_margin_abs=Math.abs(my_margin); 1928 my_center_pos=(my_margin_abs)+my_width/2; 1929 $this.timeline("my_debug","Open position",{my_pos:my_pos,my_width_1:my_width_1,my_pos_left:my_pos_left,my_margin:my_margin,my_margin_abs:my_margin_abs,my_center_pos:my_center_pos}); 1930 $this.timeline("my_debug","Open position",{my_curr:my_curr,new_pos:data.my_pos_curr}); 1931 if(data.margin>0){ 1932 my_center_pos=my_width/2; 1933 my_pos_left=my_center_pos+width; 1934 my_diff_pos=-(my_width_1/2+width/2); 1935 }else { 1936 if(my_curr>0){ 1937 if(my_pos>0){ 1938 /*if(my_diff_left<my_width_1&&my_pos>1){ 1939 my_pos_left+=(my_pos)*my_width_1+width/2; 1940 }else 1941 */ 1942 my_pos_left+=(my_pos)*my_width_1; 1943 $this.timeline("my_debug","Open Position left is ",{my_pos_left:my_pos_left,my_center_pos:my_center_pos}); 1944 1945 if(my_pos_left>my_center_pos){ 1946 my_pos_left+=width/2; 1947 my_diff_pos=my_center_pos-my_pos_left; 1948 }else { 1949 1950 var my_diff_1=my_center_pos-my_pos_left; 1951 var my_diff_2=width-my_diff_1; 1952 1953 if(my_diff_2<width){ 1954 my_diff_pos=-my_diff_2/2; 1955 1956 }else { 1957 my_pos_left-=width/2; 1958 my_diff_pos=my_center_pos-my_pos_left; 1959 1960 } 1961 $this.timeline("my_debug","Open Position is smaller",{my_diff_1:my_diff_1,my_diff_2:my_diff_2,my_diff_pos:my_diff_pos}); 1962 1963 } 1964 1965 }else { 1966 my_pos_left+=(my_pos)*my_width_1; 1967 $this.timeline("my_debug","Open Position left is ",{my_pos_left:my_pos_left,my_center_pos:my_center_pos}); 1968 1969 if(my_pos_left>my_center_pos){ 1970 my_pos_left+=width/2; 1971 my_diff_pos=my_center_pos-my_pos_left; 1972 }else { 1973 1974 var my_diff_1=my_center_pos-my_pos_left; 1975 var my_diff_2=width-my_diff_1; 1976 if(my_diff_2<width){ 1977 my_diff_pos=-my_diff_2/2; 1978 //my_pos_left+=my_diff_2/2; 1979 }else { 1980 my_pos_left-=width/2; 1981 my_diff_pos=my_center_pos-my_pos_left; 1982 } 1983 //my_pos_left+=my_diff_1/2; 1984 } 1985 1986 } 1987 1988 }else { 1989 /*var my_visible_area_left=Math.abs(data.margin); 1990 var my_width=$this.find(".timeline_items_wrapper").width(); 1991 var my_left=$this.find(".timeline_items_wrapper").offset().left; 1992 var my_visible_area_right=data.margin+my_width; 1993 var my_width_1=data.itemWidth+data.options.itemMargin; 1994 var my_start_item=Math.floor(Math.abs(my_visible_area_left)/my_width_1); 1995 var my_end_item=my_start_item+Math.ceil(my_width/my_width_1)-1; 1996 var my_total_items=Math.ceil(my_width/my_width_1); 1997 var my_pos_12=Math.floor(my_total_items/2); 1998 my_margin=data.margin; 1999 my_margin_abs=Math.abs(my_margin); 2000 my_center_pos=(my_margin_abs)+my_width/2; 2001 //my_left=0; 2002 //my_pos_left=my_width_1+width/2;//+data.options.itemOpenMargin; 2003 //my_diff_pos=my_center_pos-my_pos_left; 2004 */ 2005 my_diff_pos=-(my_width_1/2+width/2); 2006 //my_diff_pos=-(my_width_1/2+itemWidth/2); 2007 2008 } 2009 } 2010 my_diff_pos-=data.options.itemMargin/2; 2011 data.my_diff_pos=my_diff_pos; 2012 $this.timeline("my_debug","Open Position",{my_diff_1:my_diff_1,my_width:my_width,my_width_1:my_width_1,my_pos_left:my_pos_left,my_pos:my_pos,my_left:my_left,my_diff_left:my_diff_left,my_curr:my_curr,margin_abs:my_margin_abs,my_center_pos:my_center_pos,my_diff_pos:my_diff_pos,margin:data.margin}); 2013 2014 }else { 2015 var my_o_12_w=width;//$this.find(".item_open").width(); 2016 var my_12_w=$this.find(".item").width(); 2017 var itemWidth=my_12_w; 2018 var containerWidth=my_width; 2019 var my_scale_open=$this.find(".item_open").data('my-scale'); 2020 if(my_scale_open<1&&my_scale==1){ 2021 var leftOrRight=Math.abs(containerWidth-itemWidth-data.options.itemMargin)/2; 2022 my_diff_pos=-(leftOrRight+data.options.itemMargin+itemWidth); 2023 } 2024 else my_diff_pos=-(width/2+my_width_1/2+data.options.itemMargin/2);//((data.itemWidth)+(data.options.itemMargin))/2-(my_o_12_w/2); 2025 $this.timeline("my_debug","Open Position",{my_o_12_w:my_o_12_w,my_scale:my_scale,my_diff_pos:my_diff_pos}); 2026 2027 data.my_diff_pos=my_diff_pos; 2028 2029 } 2030 2031 /*if(typeof data.my_click_12_left!='undefined' && data.my_click_12_left){ 2032 my_diff_pos+=100; 2033 }else if(typeof data.my_click_12_right!='undefined' && data.my_click_12_right){ 2034 my_diff_pos-=100; 2035 }*/ 2036 data.margin+=my_diff_pos; 2037 /*if(data.my_resize_12!='undefined' && data.my_resize_12){ 2038 data.margin-=data.my_diff_window_resize; 2039 data.my_resize_12=false; 2040 $this.timeline("my_debug"," Open position my diff",data.my_diff_window_resize); 2041 2042 }*/ 2043 2044 /*if(my_pos>0){
2045 my_pom=(my_width-width-(my_pos*my_width_1))/2; 2046 data.margin=-(width)-my_pom; 2047 }else { 2048 */ 2049 /* 2050 if(data.currentIndex==my_count&&my_count==0){ 2051 //my_pos=1; 2052 2053 }else if(my_count==data.currentIndex&&my_count==(data.items.length-1)){ 2054 //my_pos=1; 2055 }else{ 2056 2057 } 2058 var left=$(this).offset().left; 2059 var my_pom_left=left-my_left; 2060 //var my_pom_right=my_width-left 2061 var my_pom_right=0; 2062 if(my_pom_left>0){ 2063 my_pom_right=my_width-(left+my_width_1); 2064 } 2065 if(my_pom_left<0){ 2066 data.margin+=(my_width-width-Math.abs(my_width_1-my_pom_left))/2;//+Math.abs(my_pom_left); 2067 }else { 2068 2069 } 2070 2071 $this.timeline("my_debug","Position",{left_d:my_left,pom_r:my_pom_right,pom_l:my_pom_left,left:left,margin:data.margin}); 2072 /*if(my_pos>0){ 2073 //my_pom=(my_width-width+(my_pos*my_width_1))/2; 2074 //data.margin=-(my_width-width)/2-my_pom; 2075 2076 }else { 2077 2078 }*/ 2079 2080 2081 //$this.timeline("my_debug","Pomeraj",{my_pom:my_pom,my_pos:my_pos}); 2082 2083 //if (false) 2084 /*if(data.my_resize_12!='undefined' && data.my_resize_12){ 2085 //data.margin+=data.my_diff_window_resize; 2086 //$this.timeline("my_debug","Open Change global margin",data.my_diff_window_resize); 2087 //data.iholder.css('margin-left',data.margin); 2088 } 2089 else { 2090 */ 2091 if(false){ 2092 data.iholder.stop(true).animate({marginLeft : data.margin}, speed, easing,function(){ 2093 //data.my_open_item_center_12=false; 2094 //$this.data('timeline',data); 2095 }); 2096 } 2097 //} 2098 data.open = id; 2099 data.my_count=$(this).attr('data-count'); 2100 }} 2101 } 2102 2103 }); 2104 return $this; 2105 2106 2107 }, 2108 2109 close : function (id, idOpen, dataCountOpen) { 2110 var $this = this, 2111 data = $this.data('timeline'), 2112 $items = $this.find(data.options.itemOpenClass), 2113 speed = data.options.scrollSpeed, 2114 width = data.itemOpenWidth, 2115 easing = data.options.easing; 2116 var my_visible_area_left=data.margin; 2117 var my_width=$this.find(".timeline_items_wrapper").width(); 2118 var my_visible_area_right=data.margin+my_width; 2119 var my_width_1=data.itemWidth+data.options.itemMargin; 2120 var my_start_item=Math.floor(Math.abs(my_visible_area_left)/my_width_1); 2121 var my_end_item=my_start_item+Math.floor(my_width/my_width_1); 2122 2123 2124 $items.each(function(){ 2125 var my_count=$(this).attr('data-count'); 2126 2127 if ($(this).attr('data-id') == id && $(this).is(":visible")) { 2128 // Trigger itemOpen event 2129 $this.trigger('itemClose.Timeline'); 2130 var my_pos=$(this).attr('data-count')-my_start_item; 2131 2132 // Close content and move margin 2133 $(this).stop(true).animate({width: 0, margin:0}, speed, easing, function(){$(this).hide();}); 2134 /*if (data.marginResponse) { 2135 data.margin += (data.itemWidth+data.options.itemMargin)/2; 2136 }*/ 2137 //$this.timeline("my_debug","Margin differenec",{my_diff:data.my_diff_pos}); 2138 2139 2140 //data.margin += (width + data.options.itemMargin)/2; 2141 data.margin+=Math.abs(data.my_diff_pos);//(width)+my_pos*width; 2142 2143 data.iholder.stop(true).animate({marginLeft : data.margin}, speed, easing); 2144 data.open = false; 2145 } 2146 }); 2147 if(idOpen) { 2148 /* 2149 * commented by dragan dont open item because some margins are not ok 2150 * remove this functionality 2151 */ 2152 if ($(this).find('.item[data-count="'+dataCountOpen+'"] a.read_more[href="#"]').length==0 || $(this).find('.item[data-count="'+dataCountOpen+'"] a.my_read_more[href="#"]').length==0){ 2153 2154 //if(data.my_resize_12!='undefined' && data.my_resize_12) 2155 $this.timeline("my_debug","Close Open an item",{idOpe
2155n:idOpen,dataCount:dataCountOpen}); 2156 $this.timeline('open', idOpen, dataCountOpen); 2157 /*setTimeout(function(){ 2158 var data = $this.data('timeline'); 2159 data.my_resize_12=false; 2160 2161 },speed);*/ 2162 } 2163 } 2164 return $this; 2165 }, 2166 my_debug:function(t,o){ 2167 var $this = this; 2168 var settings=$this.data('my_settings'); 2169 if(settings.my_debug){ 2170 if(window.console){ 2171 console.log("Timeline\n"+t,o); 2172 } 2173 } 2174 }, 2175 my_autoplay:function(){ 2176 var $this = this, 2177 data = $this.data('timeline'), 2178 speed = data.options.scrollSpeed, 2179 easing = data.options.easing; 2180 var settings=$this.data('my_settings'); 2181 if(settings.my_stop_autoplay || data.open || $(".pp_fade").is(":visible")){ 2182 $this.timeline("my_debug","Autoplay is disabled",{s:settings}); 2183 var t=settings.autoplay_step; 2184 if(settings.is_mobile)t=t*4; 2185 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,t); 2186 $this.data('my_settings',settings); 2187 2188 return; 2189 } 2190 if (data.currentIndex == data.itemCount-1) 2191 { 2192 settings.my_dir='left'; 2193 }else if(data.currentIndex==0){ 2194 settings.my_dir='right'; 2195 }else if(typeof settings.my_dir=='undefiined'){ 2196 settings.my_dir='right'; 2197 } 2198 if(settings.my_dir=='right'){ 2199 $this.timeline('right'); 2200 }else { 2201 $this.timeline('left'); 2202 } 2203 $this.data('my_settings',settings); 2204 $this.timeline("my_debug","Autoplay",settings.my_dir); 2205 setTimeout(function(){ 2206 settings.my_autoplay_function=setTimeout(my_autoplay_function_12,settings.autoplay_step); 2207 $this.data('my_settings',settings); 2208 },settings.scrollSpeed); 2209 }, 2210 // Move one step left 2211 right : function() { 2212 var $this = this, 2213 data = $this.data('timeline'), 2214 speed = data.options.scrollSpeed, 2215 $items = data.items, 2216 easing = data.options.easing; 2217 2218 var countElements = 0; 2219 var dataItemsId = {}; 2220 var dataItemsCount = {}; 2221 $items.each(function (){ 2222 if(!$(this).hasClass('disable-cards-elements')){ 2223 dataItemsId[countElements] = $(this).attr('data-id'); 2224 dataItemsCount[countElements] = $(this).attr('data-count'); 2225 countElements++; 2226 2227 } 2228 }); 2229 2230 //if (data.currentIndex < data.itemCount-1) 2231 if (data.currentIndex < countElements-1) 2232 { 2233 var dataId = dataItemsId[data.currentIndex+1]; 2234 var dataCount = dataItemsCount[data.currentIndex+1]; 2235 $this.timeline('goTo', dataId, dataCount); 2236 if (data.options.closeItemOnTransition) 2237 $this.timeline('close', dataId); 2238 } 2239 else 2240 { 2241 data.iholder.stop(true).animate({marginLeft : data.margin-50}, speed/2, easing).animate({marginLeft : data.margin}, speed/2, easing); 2242 } 2243 return $this 2244 }, 2245 2246 // Move one step right 2247 left : function( ) { 2248 var $this = this, 2249 data = $this.data('timeline'), 2250 speed = data.options.scrollSpeed, 2251 $items = data.items, 2252 easing = data.options.easing; 2253 2254 var countElements = 0; 2255 var dataItemsId = {}; 2256 var dataItemsCount = {}; 2257 2258 $items.each(function (){ 2259 if(!$(this).hasClass('disable-cards-elements')){ 2260 dataItemsId[countElements] = $(this).attr('data-id'); 2261 dataItemsCount[countElements] = $(this).attr('data-count'); 2262 countElements++; 2263 2264 } 2265 }); 2266 2267 if (data.currentIndex > 0) 2268 { 2269 var dataId = dataItemsId[data.currentIndex-1]; 2270 var dataCount = dataItemsCount[data.currentIndex-1]; 2271 $this.timeline('goTo', dataId, dataCount); 2272 if (data.options.closeItemOnTransition) 2273 $this.timeline('close', dataId); 2274 } 2275 else 2276 { 2277 data.iholder.stop(true).animate({marginLeft : data.margin+50}, speed/2, easing).animate({marginLeft : data.margin}, speed/2, easing); 2278 } 2279 return $this; 2280 }, 2281 2282 // Go to item 2283 goTo : function (id, data_count, openElement) { 2284 2285 var $this = this, 2286 data = $this.data('timeline'), 2287 speed = data.options.scrollSpeed, 2288 easing = data.options.easing, 2289 $items = data.items, 2290 timelineWidth = $this.find('.timeline_line').width(), 2291 count = -1, 2292 found = false;
2293 var my_settings=$this.data('my_settings'); 2294 var my_scale=my_settings.my_scale; 2295 $this.timeline("my_debug","Go to scale",{id:id,data_count:data_count,scale:my_scale}); 2296 2297 if(data.my_open_item_center_12){ 2298 $this.timeline("my_debug","open item return"); 2299 return; 2300 } 2301 // Find item index 2302 $items.each(function(index){ 2303 if(id == $(this).attr('data-id')) 2304 { 2305 if (!data_count || data_count == $(this).attr('data-count')) 2306 { 2307 found = true; 2308 count = parseInt($(this).attr('data-count')); 2309 return false; 2310 } 2311 } 2312 }); 2313 2314 // Move if fount 2315 if(found) 2316 { 2317 // Move lineView to current element 2318 var $nodes = $this.find('.t_line_node'); 2319 $nodes.removeClass('active'); 2320 var $goToNode = $nodes.parent().parent().find('[href="#'+id+'"]').addClass('active'); 2321 data.lineMargin = -parseInt($goToNode.parent().parent().attr('data-id'),10)*100; 2322 2323 // check if responsive width 2324 if($this.find('.t_line_view:first').width() > $this.find('.timeline_line').width()) { 2325 data.lineMargin *=2; 2326 if ($goToNode.parent().hasClass('right')) data.lineMargin -= 100; 2327 } 2328 2329 if(data.noAnimation){ 2330 data.noAnimation = false; 2331 2332 $this.find('.t_line_wrapper').stop(true).css({marginLeft : data.lineMargin+'%'}); 2333 } 2334 else { 2335 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing ); 2336 } 2337 2338 2339 if(data.open) { 2340 /*if(data_count){ 2341 data.my_pos_curr=count; 2342 }*/ 2343 $this.timeline('close', data.open, id, data_count); 2344 delete data.my_pos_curr; 2345 2346 $this.timeline("my_debug","Go to Close postion",data.open); 2347 } 2348 else if (openElement) { 2349 delete data.my_pos_curr; 2350 $this.timeline("my_debug"," Go To Open postion",openElement); 2351 /*console.log($(this).find('.item[data-count="'+data_count+'"] a.read_more[href="#"]').length==0) 2352 if ($(this).find('.item[data-count="'+data_count+'"] a.read_more[href="#"]').length==0)*/ 2353 //data.my_pos_curr=data_count; 2354 $this.timeline('open', id, data_count); 2355 delete data.my_pos_curr; 2356 2357 2358 } 2359 delete data.my_pos_curr; 2360 2361 // Trigger ScrollStart event 2362 $this.trigger('scrollStart.Timeline'); 2363 2364 // Scroll 2365 var my_pre_index_123=data.currentIndex; 2366 var itemWidth=$this.find(".item").width(); 2367 if(my_scale==1){ 2368 2369 data.margin += (itemWidth + data.options.itemMargin)*(data.currentIndex - count); 2370 } else { 2371 //var my_w_12=$this.find(".timeline_items_holder").width(); 2372 //data.margin+=((my_w_12+data.options.itemMargin)*(data.currentIndex - count)); 2373 data.margin+=(data.currentIndex - count)*(itemWidth)+(data.currentIndex - count)*(data.options.itemMargin); 2374 //console.log(data.margin); 2375 } 2376 2377 data.currentIndex = count; 2378 $this.timeline("my_debug","Go To Count",{curr:data.currentIndex,width:data.itemWidth,my_scale:my_scale,count:count,pre:my_pre_index_123,margin:data.margin}); 2379 2380 /** 2381 * Code for changing margin 2382 */ 2383 var my_width=$this.find(".timeline_items_wrapper").width(); 2384 var my_margin=data.margin+(data.current_index-count)*(data.itemWidth+data.itemMargin)+(my_width-data.itemWidth-data.itemMargin)/2 2385 2386 /*if(data.currentIndex ==0 && my_pre_index_123==1){ 2387 data.margin+=(data.itemWidth/2); 2388 2389 }else if (data.currentIndex ==1 && my_pre_index_123==0){ 2390 data.margin-=(data.itemWidth/2); 2391 }*/ 2392 $this.timeline("my_debug","Go to Count",{count:count,pre:my_pre_index_123,margin:data.margin,my_margin:my_margin}); 2393 2394 var multiply = (parseInt(data.iholder.css('margin-left')) - data.margin)/data.itemWidth; 2395 /*if(data.my_resize_12!='undefined' && data.my_resize_12){ 2396 2397 }else { 2398 */ 2399 /*if(data.my_resize_12!='undefined' && data.my_resize_12){ 2400 data.margin+=data.my_diff_window_resize; 2401 $this.timeline("my_debug","Open Change global margin",data.my_diff_window_resize); 2402 data.iholder.css('margin-left',data.margin); 2403 data.my_diff_window_resize=0; 2404 }*/ 2405 if($('#t_line_backward').hasClass('backward-clicked') || $('#t_line_forward').hasClass('forward-clicked')){ 2406 speed = 200; 2407 } 2408 data.iholder.stop(true).animate({marginLeft : data.margin}, speed+(speed/5)*(Math.abs(multiply)-1), easing, function(){ 2409 // Trigger ScrollStop event 2410 $this.trigger('scrollStop.Timeline'); 2411 }); 2412 //} 2413 } 2414 return $this; 2415 }, 2416 2417 //move line to start 2418 lineBackward : function() { 2419 2420 var $this = this, 2421 data = $this.data('timeline'), 2422 speed = data.options.scrollSpeed, 2423 easing = data.options.easing; 2424 2425 $this.find('.t_line_backward').addClass('backward-clicked'); 2426 2427 var $nodes = $this.find('.t_line_node'); 2428 var $goToNode = $nodes.first().addClass('active'); 2429 2430 $this.find('#t_line_backward').addClass('backward-clicked'); 2431 2432 data.lineMargin = -parseInt($goToNode.parent().parent().attr('data-id'),10)*100; 2433 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing); 2434 2435 var dataId = data.items.eq(0).attr('data-id'); 2436 var dataCount = data.items.eq(0).attr('data-count'); 2437 2438 $this.timeline('goTo', dataId, dataCount); 2439 2440 $this.trigger('scrollStart.Timeline'); 2441 2442 $this.find('#t_line_backward').removeClass('backward-clicked'); 2443 }, 2444 2445 // move line to the left 2446 lineLeft : function() { 2447 var $this = this, 2448 data = $this.data('timeline'), 2449 speed = data.options.scrollSpeed, 2450 easing = data.options.easing; 2451 if (data.lineMargin != 0 && data.options.categories) { 2452 data.lineMargin += 100; 2453 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing); 2454 } 2455 2456 }, 2457 2458 // move line to the right 2459 lineRight : function() { 2460 var $this = this, 2461 data = $this.data('timeline'), 2462 speed = data.options.scrollSpeed, 2463 easing = data.options.easing; 2464 if ($this.find('.t_line_view:first').width() > $this.find('.timeline_line').width()) 2465 var viewCount = data.lineViewCount*2; 2466 else 2467 var viewCount = data.lineViewCount; 2468 2469 if (data.lineMargin != -(viewCount-1)*100 && data.options.categories) { 2470 data.lineMargin -= 100; 2471 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing); 2472 } 2473 2474 }, 2475 2476 //move line to end 2477 lineForward : function() { 2478 var $this = this, 2479 data = $this.data('timeline'), 2480 speed = data.options.scrollSpeed, 2481 easing = data.options.easing; 2482 2483 $this.find('#t_line_forward').addClass('forward-clicked'); 2484 2485 var $nodes = $this.find('.t_line_node'); 2486 var $goToNode = $nodes.last().addClass('active'); 2487 2488 data.lineMargin = -parseInt($goToNode.parent().parent().attr('data-id'),10)*100; 2489 $this.find('.t_line_wrapper').stop(true).animate({marginLeft : data.lineMargin+'%'}, speed, easing); 2490 2491 var dataId = data.items.eq(data.itemCount-1).attr('data-id'); 2492 var dataCount = data.items.eq(data.itemCount-1).attr('data-count'); 2493 2494 $this.timeline('goTo', dataId, dataCount); 2495 2496 $this.find('#t_line_forward').removeClass('forward-clicked'); 2497 2498 if (data.options.closeItemOnTransition) 2499 $this.timeline('close', dataId); 2500 2501 }, 2502 2503 searchBarToggle : function() { 2504 var $this = this, 2505 data = $this.data('timeline'), 2506 speed = data.options.scrollSpeed, 2507 easing = data.options.easing; 2508 2509 $this.find('.search_bar_holder').slideToggle(200); 2510 2511 }, 2512 2513 // Create timeline elements and css dependent properties 2514 createElements : function() { 2515 var $this = this, 2516 data = $this.data('timeline'), 2517 $items = data.items; 2518 var html = ''; 2519 if(data.options.search_bar_position == 0) { 2520 html = '\n' + 2521 /* ' <div class="search_bar_holder" style="display:block !important;"><input id="search-cards" placeholder="Search specific card..." type="text"/></div>\n'+*/ 2522 ' <div class="timeline_line" style="text-align: left; position:relative; margin-left:auto; margin-right:auto;">\n' + 2523 ' </div>\n'; 2524 $this.prepend(html); 2525 } 2526 else { 2527 html = '\n' + 2528 /* ' <div class="search_bar_holder" style="display:block !important;"><input id="search-cards" placeholder="Search specific card..." type="text"/></div>\n'+*/ 2529 ' <div class="timeline_line" style="text-align: left; position:relative; margin-left:auto; margin-right:auto;">\n' + 2530 ' </div>\n'; 2531 $this.prepend(html); 2532 } 2533 2534 var timelineWidth = $this.find('.timeline_line').width(), 2535 nodes = new Array(), 2536 months = [''].concat(data.options.categories); 2537 monthsDays = [0].concat(data.options.nuberOfSegments), 2538 minM = months.length, 2539 minY = 99999, 2540 maxM = 0, 2541 maxY = 0; 2542 if(!data.options.yearsOn) maxY = 99999; 2543 2544 var yearsArr = {}; 2545 if(!data.options.categories) { 2546 $items.each(function(){ 2547 var dataId = $(this).attr('data-id'), 2548 dataArray = dataId.split('/'), 2549 d = parseInt(dataArray[0],10), 2550 m = ($.inArray(dataArray[1],months) != -1) ? $.inArray(dataArray[1],months) : parseInt(dataArray[1],10), 2551 y = parseInt(dataArray[2],10); 2552 if(d < minY) minY = d; 2553 if(d > maxY) maxY = d; 2554 }); 2555 minY -= 10; 2556 maxY += 10; 2557 } 2558 // find timeline date range and make node elements 2559 var myMinYear=2000000,myMaxYear=0,myYearsCount=0,myYearsArr={}, itemIds = []; 2560 if(data.options.my_is_years){ 2561 2562 $items.each(function(index){ 2563 var dataId = $(this).attr('data-id'), 2564 nodeName = $(this).attr('data-name'), 2565 dataDesc = $(this).attr('data-description'), 2566 dataArray = dataId.split('/'); 2567 var y=parseInt(dataArray[2]); 2568 if(typeof yearsArr[y] == 'undefined') { 2569 myYearsCount++; 2570 myYearsArr[myYearsCount] = y; 2571 itemIds[myYearsCount] = dataId; 2572 } 2573 if(y<myMinYear){ 2574 myMinYear=y; 2575 } 2576 if(y>myMaxYear){ 2577 myMaxYear=y; 2578 } 2579 }); 2580 //store unique years 2581 var uniques = storeUniqueYears(myYearsArr); 2582 //set up counter for unique years 2583 myYearsCount = uniques.length; 2584 if(window.console&&data.options.my_debug){ 2585 console.log('Min max years',{min:myMinYear,max:myMaxYear,yearsCount:myYearsCount}); 2586 2587 2588 } 2589 } 2590 //}else {*/ 2591 var myCount=0,myCountSegments=-1,myYearsSegments={},myYearsSegmentsStr={}; 2592 var myIncrementSegment=true; 2593 //array of items unique years ids 2594 var dataIds = []; 2595 var counter = 0; 2596 2597 $items.each(function(index){ 2598 var dataId = $(this).attr('data-id'), 2599 nodeName = $(this).attr('data-name'), 2600 dataDesc = $(this).attr('data-description'), 2601 dataArray = dataId.split('/'), 2602 d = parseInt(dataArray[0],10), 2603 m = ($.inArray(dataArray[1],months) != -1) ? $.inArray(dataArray[1],months) : parseInt(dataArray[1],10), 2604 y = parseInt(dataArray[2],10); 2605 2606 2607 2608 if(data.options.my_is_years){ 2609 if(data.options.is_mobile == 1) 2610 { 2611 data.options.my_years_view = 9; 2612 data.options.my_show_years = 9; 2613 }
2614 if(myYearsCount<=data.options.my_years_view){ 2615 if(typeof myYearsSegments[0]=='undefined'){ 2616 myYearsSegments[0]=[]; 2617 } 2618 var isActive = (index == data.currentIndex ? ' active' : ''); 2619 //var y1=d; 2620 //var y=y1; 2621 var y1=y; 2622 var leftPos; 2623 var pIndex=myYearsArr[y]; 2624 for(var i = 0; i< dataIds.length; i++){ 2625 if(dataId.slice(-4) == dataIds[i].slice(-4)) 2626 return true; 2627 } 2628 dataIds.push(dataId); 2629 leftPos=(100/(myYearsCount+1))*(counter+1); 2630 counter++; 2631 var isActive = (index == data.currentIndex ? ' active' : ''); 2632 var nName = ((typeof nodeName != 'undefined') ? nodeName : d); 2633 // Store node element 2634 nodes[dataId] = '<a href="#'+dataId+'" class="t_line_node'+isActive+'" style="left: '+leftPos+'%; position:absolute; text-align:center;">'+nName; 2635 2636 if(typeof dataDesc != 'undefined') nodes[dataId]+= '<span class="t_node_desc '+(dataDesc ? '' : 't_node_desc_empty')+'" style="white-space:nowrap; position:absolute; z-index: 1;" ><span>'+dataDesc+'</span></span>'; 2637 2638 nodes[dataId]+='</a>\n'; 2639 if(typeof yearsArr[y] == 'undefined') { 2640 2641 if(window.console&&data.options.my_debug){ 2642 console.log('ADD Segemnt',{year:y,count:myCountSegments}); 2643 } 2644 yearsArr[y] = {}; 2645 if(myCount==0){ 2646 myYearsSegmentsStr[0]=y+'-'; 2647 }else if(myCount==(data.options.my_show_years-1)){ 2648 myYearsSegmentsStr[0]+=y; 2649 }else if(index==(myYearsCount-1)){ 2650 myYearsSegmentsStr[0]+=y; 2651 } 2652 var l=myYearsSegments[0].length; 2653 myYearsSegments[0][l]=nodes[dataId]; 2654 2655 myCount++; 2656 } 2657 2658 }else { 2659 if(data.options.is_mobile == 1) 2660 { 2661 data.options.my_years_view = 9; 2662 data.options.my_show_years = 9; 2663 } 2664 if(myIncrementSegment&&(myCount%data.options.my_show_years==0)){ 2665 myCountSegments++; 2666 myCount=0; 2667 } 2668 if(typeof myYearsSegments[myCountSegments]=='undefined'){ 2669 myYearsSegments[myCountSegments]=[]; 2670 } 2671 //if(typeof yearsArr[y][m] == 'undefined') yearsArr[y][m] = {}; 2672 //yearsArr[y][m][d] = dataId; 2673 var isActive = (index == data.currentIndex ? ' active' : ''); 2674 //var y1=d; 2675 var y1=y; 2676 var leftPos; 2677 var pIndex=myYearsArr[y]; 2678 leftPos=(100/(data.options.my_show_years+1))*(myCount+1); 2679 var nName = ((typeof nodeName != 'undefined') ? nodeName : d); 2680 // Store node element 2681 nodes[dataId] = '<a href="#'+dataId+'" class="t_line_node'+isActive+'" style="left: '+leftPos+'%; position:absolute; text-align:center;">'+nName; 2682 2683 if(typeof dataDesc != 'undefined') nodes[dataId]+= '<span class="t_node_desc '+(dataDesc ? '' : 't_node_desc_empty')+'" style="white-space:nowrap; position:absolute; z-index: 1;" ><span>'+dataDesc+'</span></span>'; 2684 2685 nodes[dataId]+='</a>\n'; 2686 //if(typeof myYearsSegments[myCountSegments]) 2687 if(typeof yearsArr[y] == 'undefined') { 2688 myIncrementSegment=true; 2689 if(window.console&&data.options.my_debug){ 2690 console.log('ADD Segemnt',{year:y,count:myCountSegments}); 2691 } 2692 yearsArr[y] = {}; 2693 if(myCount==0){ 2694 myYearsSegmentsStr[myCountSegments]=y+'-'; 2695 }
2695else if(myCount==(data.options.my_show_years-1)){ 2696 myYearsSegmentsStr[myCountSegments]+=y; 2697 }else if(index==(myYearsCount-1)){ 2698 myYearsSegmentsStr[myCountSegments]+=y; 2699 } 2700 var l=myYearsSegments[myCountSegments].length; 2701 myYearsSegments[myCountSegments][l]=nodes[dataId]; 2702 2703 myCount++; 2704 }else { 2705 if(myCount==0){ 2706 myIncrementSegment=false; 2707 2708 } 2709 } 2710 } 2711 } 2712 else { 2713 if(typeof yearsArr[y] == 'undefined') yearsArr[y] = {}; 2714 if(typeof yearsArr[y][m] == 'undefined') yearsArr[y][m] = {}; 2715 yearsArr[y][m][d] = dataId; 2716 var isActive = (index == data.currentIndex ? ' active' : ''); 2717 2718 if(data.options.categories) { 2719 var leftPos; 2720 leftPos = (100/monthsDays[m])*d; 2721 } 2722 else { 2723 var leftPos = (100/(maxY-minY))*(d-minY); 2724 } 2725 var nName = ((typeof nodeName != 'undefined') ? nodeName : d); 2726 // Store node element 2727 nodes[dataId] = '<a href="#'+dataId+'" class="t_line_node'+isActive+'" style="left: '+leftPos+'%; position:absolute; text-align:center;">'+nName; 2728 2729 if(typeof dataDesc != 'undefined') nodes[dataId]+= '<span class="t_node_desc '+(dataDesc ? '' : 't_node_desc_empty')+'" style="white-space:nowrap; position:absolute; z-index: 1;" ><span>'+dataDesc+'</span></span>'; 2730 2731 nodes[dataId]+='</a>\n'; 2732 2733 } 2734 }); 2735 //} 2736 // Make wrapper elements 2737 html = '\n' + 2738 ' <div id="t_line_backward" style="position: absolute; display:none;" data-clicked="false"></div><div id="t_line_left" style="position: absolute;"></div><div id="t_line_right" style="position: absolute;"></div><div id="t_line_forward" style="position: absolute; display:none;" data-clicked="false"></div><div id="search_timeline_bar_icon" style="position: absolute; display:none;"></div>\n' + 2739 ' <div class="t_line_holder" style="position:relative; overflow: hidden; width:100%;">\n' + 2740 ' <div class="t_line_wrapper" style="white-space:nowrap;">\n'; 2741 2742 // Prepare for loop, every view has 2 months, we show both if first has nodes in it 2743 2744 if (!data.options.categories) { 2745 html += 2746 '<div class="t_line_view" data-id="'+cnt+'" style="position:relative; display:inline-block; width:100%;">\n'+ 2747 ' <div class="t_line_m" style="width:100%; border:0; position:absolute; top:0;">\n'; 2748 for (var x in nodes) { 2749 html += nodes[x]; 2750 } 2751 html += '</div>\n'+ 2752 '</div>'; 2753 } 2754 else { 2755 if(data.options.my_is_years){ 2756 2757 var cnt = 0; 2758 var firstMonth = true; 2759 var myCountT=0; 2760 if(window.console&&data.options.my_debug){ 2761 console.log('Years sefgments',myYearsSegments); 2762 console.log('Years segemnts str',myYearsSegmentsStr); 2763 } 2764 if(myYearsCount<=data.options.my_years_view){ 2765 html += 2766 '<div class="t_line_view" data-id="'+cnt+'" style="position:relative; display:inline-block; width:100%;">\n'+ 2767 ' <div class="t_line_m" style="width:100%; border:0; position:absolute; top:0;">\n'; 2768 $.each(myYearsSegments[0],function(i,mySegments){ 2769 html+=mySegments 2770 }); 2771 html += '</div>\n'+ 2772 '</div>'; 2773 //line added for update!!! 2774 cnt++; 2775 }else { 2776 //for(var mySegments in myYearsSegments){ 2777 $.each(myYearsSegments,function(i,mySegments){ 2778 2779 /* html += 2780 '<div class="t_line_view" data-id="'+cnt+'" style="position:relative; display:inline-block;">\n'+ 2781 ' <div class="t_line_m" style="position:absolute; top:0;">\n'+ 2782 ' <h4 class="t_line_month" style="position:abolute; width:100% top:0; text-align:center;">'+months[mnth]+(data.options.yearsOn ? '<span class="t_line_month_year"> '+(yr < 0 ? (-yr)+' B.C.' : yr)+'</span>' : '' )+'</h4>\n'; 2783 2784 */ 2785 if (firstMonth) { 2786 firstMonth = !firstMonth; 2787 html += 2788 '<div class="t_line_view" data-id="'+cnt+'" style="position:relative; display:inline-block;">\n'+ 2789 ' <div class="t_line_m" style="position:absolute; top:0;">\n'+ 2790 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;">'+(data.options.yearsOn? '<span class="t_line_month_year">'+myYearsSegmentsStr[i]+'</span>' : '' )+'</h4>\n'; 2791 2792 // Fill with nodes 2793 /*for (dy in yearsArr[yr][mnth]) { 2794 html+= nodes[yearsArr[yr][mnth][dy]]; 2795 2796 }*/ 2797 $.each(mySegments,function(my_i,my_v){ 2798 html+=my_v; 2799 }); 2800 html += 2801 ' </div> <!-- KRAJ PRVOG -->\n'; 2802 /*if(i==(myCountSegments)){ 2803 cnt++; 2804 2805 }*/ 2806 } 2807 else { 2808 firstMonth = !firstMonth; 2809 html += 2810 ' <div class="t_line_m right" style="position:absolute; top:0;">\n'+ 2811 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;">'+(data.options.yearsOn ? '<span class="t_line_month_year"> '+myYearsSegmentsStr[i]+'</span>' : '' )+'</h4>\n'; 2812 2813 // Fill with nodes 2814 /*for (dy in yearsArr[yr][mnth]) { 2815 html+= nodes[yearsArr[yr][mnth][dy]]; 2816 2817 }*/ 2818 $.each(mySegments,function(my_i,my_v){ 2819 html+=my_v; 2820 }); 2821 html += 2822 ' </div><!-- KRAJ DRUGOG -->\n'+ 2823 ' <div style="clear:both"></div>\n'+ 2824 ' </div>'; 2825 cnt++; 2826 2827 } 2828 2829 //cnt++; 2830 //html += 2831 // ' </div> <!-- KRAJ PRVOG -->\n';
2832 //myCountT++; 2833 //} 2834 }); 2835 if (!firstMonth) { 2836 html += 2837 ' <div class="t_line_m right" style="position:absolute; top:0;">\n'+ 2838 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;"></h4>\n'+ 2839 ' </div>\n'+ 2840 ' <div style="clear:both"></div>\n'+ 2841 ' </div>'; 2842 cnt++; 2843 } 2844 } 2845 }else { 2846 var firstMonth = true; 2847 var cnt = 0; 2848 for(var yr in yearsArr) { 2849 for(var mnth in yearsArr[yr]) { 2850 if (firstMonth) { 2851 firstMonth = !firstMonth; 2852 html += 2853 '<div class="t_line_view" data-id="'+cnt+'" style="position:relative; display:inline-block;">\n'+ 2854 ' <div class="t_line_m" style="position:absolute; top:0;">\n'+ 2855 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;">'+months[mnth]+(data.options.yearsOn ? '<span class="t_line_month_year"> '+(yr < 0 ? (-yr)+' B.C.' : yr)+'</span>' : '' )+'</h4>\n'; 2856 2857 // Fill with nodes 2858 for (dy in yearsArr[yr][mnth]) { 2859 html+= nodes[yearsArr[yr][mnth][dy]]; 2860 2861 } 2862 html += 2863 ' </div> <!-- KRAJ PRVOG -->\n'; 2864 } 2865 else { 2866 firstMonth = !firstMonth; 2867 html += 2868 ' <div class="t_line_m right" style="position:absolute; top:0;">\n'+ 2869 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;">'+(typeof months[mnth] !== 'undefined' ? months[mnth] : '')+(data.options.yearsOn ? '<span class="t_line_month_year"> '+yr+'</span>' : '' )+'</h4>\n'; 2870 2871 // Fill with nodes 2872 for (dy in yearsArr[yr][mnth]) { 2873 html+= nodes[yearsArr[yr][mnth][dy]]; 2874 2875 } 2876 html += 2877 ' </div><!-- KRAJ DRUGOG -->\n'+ 2878 ' <div style="clear:both"></div>\n'+ 2879 ' </div>'; 2880 cnt++; 2881 2882 } 2883 } 2884 } 2885 if (!firstMonth) { 2886 html += 2887 ' <div class="t_line_m right" style="position:absolute; top:0;">\n'+ 2888 ' <h4 class="t_line_month" style="position:absolute; width:100%; top:0; text-align:center;"></h4>\n'+ 2889 ' </div>\n'+ 2890 ' <div style="clear:both"></div>\n'+ 2891 ' </div>'; 2892 cnt++; 2893 } 2894 2895 } 2896 2897 2898 html += '\n' + 2899 ' <div style="clear:both"></div>\n'+ 2900 ' </div>\n'+ 2901 ' </div>\n'; 2902 2903 } 2904 2905 // Set number of View elements 2906 data.lineViewCount = cnt; 2907 // Add generated html and set width & margin for dinamic timeline 2908 $this.find('.timeline_line:first').html(html); 2909 2910 $this.find('.t_line_node').each(function () { 2911 var $thisNode = $(this); 2912 $(this).find('span').hide(); 2913 $(this).hover(function () {
2914 if(is_touch_device()){ 2915 window.location = $(this).attr('href'); 2916 return; 2917 } 2918 $items.each(function () { 2919 if ($(this).attr('data-id') == $thisNode.attr('href').substr(1)) { 2920 $(this).addClass('item_node_hover'); 2921 } 2922 }); 2923 $(".my_timeline_hover_12_123").finish(); 2924 var $this = $(this).parents('.timeline'); 2925 var settings = $this.data('my_settings'); 2926 $this.timeline('my_debug', 'Hover', {s: settings}); 2927 var off = $(this).offset(); 2928 var html1 = $(this).find('.t_node_desc').html(); 2929 var my_settings = $this.data('my_settings'); 2930 var my_transitions = my_settings.my_transitions; 2931 var my_pfx = my_settings.my_pfx; 2932 var html;//='<span class="t_node_desc" style="top:1px;opacity:1;">'+html1+"</span>"; 2933 if (my_transitions) { 2934 html = '<span class="t_node_desc" style="' + my_pfx + '-transform:top 200ms,opacity 500ms">' + html1 + "</span>"; 2935 } else { 2936 html = '<span class="t_node_desc" style="top:0px;opacity:1;">' + html1 + "</span>"; 2937 } 2938 var id = $this.attr('id'); 2939 $(".my_timeline_hover_12_123").attr('id', id); 2940 $(".my_timeline_hover_12_123").html(html); 2941 $(".my_timeline_hover_12_123").find('span').show(); 2942 $(".my_timeline_hover_12_123").find('.t_node_desc').css({opacity: 1, top: '0px'}); 2943 var w = $(".my_timeline_hover_12_123").width(); 2944 var l = off.left - w / 3 + 6; 2945 var top = off.top - 13; 2946 if (!my_transitions) { 2947 $(".my_timeline_hover_12_123").css({ 2948 top: top + 'px', 2949 left: l + 'px' 2950 }).animate({opacity: 1}, 500); 2951 } 2952 else $(".my_timeline_hover_12_123").css({top: top + 'px', left: l + 'px', opacity: 1}); 2953 2954 2955 }, function () { 2956 var $this = $(this).parents('.timeline'); 2957 var settings = $this.data('my_settings'); 2958 $this.find(".item").removeClass("item_node_hover"); 2959 $this.timeline('my_debug', 'Hover out', {s: settings}); 2960 $(".my_timeline_hover_12_123").finish(); 2961 $(".my_timeline_hover_12_123").animate({opacity: 0}, 500, function () { 2962 2963 }); 2964 2965 }); 2966 2967 //Position lineView to selected item 2968 if ($(this).hasClass('active')) { 2969 data.lineMargin = -parseInt($(this).parent().parent('.t_line_view').attr('data-id'), 10) * 100; 2970 if (data.options.rtl) { 2971 $this.find('.t_line_wrapper').css('margin-right', data.lineMargin + '%'); 2972 } 2973 else $this.find('.t_line_wrapper').css('margin-left', data.lineMargin + '%'); 2974 } 2975 // Bind goTo function to click event 2976 $(this).click(function (e) { 2977 e.preventDefault(); 2978 $this.find('.t_line_node').removeClass('active'); 2979 $(this).addClass('active'); 2980 $this.timeline('goTo', $(this).attr('href').substr(1)); 2981 if (data.options.closeItemOnTransition) 2982 $this.timeline('close', $(this).attr('href').substr(1)); 2983 2984 }); 2985 }); 2986 2987 $this.find('#t_line_backward').click(function() { 2988 $this.timeline('lineBackward'); 2989 }); 2990 2991 $this.find('#t_line_left').click(function(){ 2992 $this.timeline('lineLeft'); 2993 }); 2994 2995 $this.find('#t_line_right').click(function(){ 2996 $this.timeline('lineRight'); 2997 }); 2998 2999 $this.find('#t_line_forward').click(function() { 3000 $this.timeline('lineForward'); 3001 }); 3002 3003 $this.find('#search_timeline_bar_icon').click(function() { 3004 $this.timeline('searchBarToggle'); 3005 }); 3006 3007 } 3008 }; 3009 3010 // Initiate methods 3011 $.fn.timeline = function( method ) { 3012 3013 if ( t_methods[method] ) { 3014 return t_methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); 3015 } else if ( typeof method === 'object' || ! method ) { 3016 return t_methods.init.apply( this, arguments ); 3017 } else { 3018 $.error( 'Method ' + method + ' does not exist on jQuery.timeline' ); 3019 } 3020 3021 }; 3022 3023 //scale images 3024 $(window).load(function(){ 3025 imageFit('.con_borderImage'); 3026 }) 3027 3028 3029 3030})(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.