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