1/* 2 * jQuery itour v 3.2.0 3 * 4 * Copyright 2016, Linnik Yura | LI MASS CODE | http://masscode.ru 5 * 6 * Last Update 12.05.2017 7 */ 8 9(function ($) { 10 "use strict"; 11 var methods = { 12 init: function (options) { 13 var p = { 14 CSSClass:'anyClassName', //Assign for tour a unique class name to change the display styles of the tour. 15 tourID:'anyTourID', //This string allows you to save data with a unique name about tour progress. It can be used to save information on the progress of the tour for several users. Or save the progress of each tour separately 16 introShow:false, //If set to true, before the tour you will see the introductory slide, which will offer to see a tour. 17 introCover:false, //Path to the cover of tour 18 startStep:1, //Step from which the tour begins 19 tourMapEnable:true, //Tour Map Enable 20 tourMapPos:'right', //Tour Map Position 21 tourMapJump:true, //If set to false, then links of steps on the tour map will not be clickable 22 tourTitle:'Tour Title Default', //Tour title 23 tourMapVisible:false, //Specifies to show or hide the map of the tour at the start of the tour 24 spacing:10, //Indent highlighting around the element, px 25 overlayClickable:true, //This parameter enables or disables the click event for overlying layer 26 modalCancelVisible:false, //Shows a cancel button in modal window. 27 stepNumbersVisible:true, //Shows the total number of steps and the current step number 28 showAbsentElement:false, //Shows an absent element in tour map and find this element in DOM. 29 tourContinue:true, //This parameter add the ability to continue the unfinished tour. 30 textDirection:'ltr', //The direction property specifies the text direction/writing direction. (ltr, rtl) 31 steps:[{ 32 image:'', //Path to image file 33 title:'New Step Title', //Name of step 34 content:'New Step Description', //Description of step 35 contentPosition:'auto', //Position of message 36 name:'uniqueName', //Unique Name (<div data-name="uniqueName"></div>) of highlighted element or .className (<div class="className"></div>) or #idValue (<div id="idValue"></div>) 37 disable:false, //Block access to element 38 overlayOpacity:0.5, //For each step, you can specify the different opacity values of the overlay layer. 39 event:'next', //An event that you need to do to go to the next step 40 skip: false, //Step can be skipped if you set parameter "skip" to true. 41 nextText:'Next', //The text in the Next Button 42 prevText:'Prev', //The text in the Prev Button 43 trigger:false, //An event which is generated on the selected element, in the transition from step to step 44 stepID:'', //Unique ID Name. This name is assigned to the "html" tag as "data-step" attribute (If not specified, the plugin generates it automatically in the form: "step-N") 45 loc:false, //The path to the page on which the step should work 46 before:function(){}, //Triggered before the start of step 47 during:function(){}, //Triggered after the onset of step 48 after:function(){}, //Triggered After completion of the step, but before proceeding to the next 49 delayBefore:0, //The delay before the element search, ms 50 delayAfter:0 //The delay before the transition to the next step, ms 51 }], 52 create: function(){}, //Triggered when the itour is created 53 end: function(){}, //Triggered when the tour came to the end, or was interrupted. 54 lang: { //Default language settings 55 cancelText: 'Cancel Tour', //The text in the cancel tour button 56 hideText: 'Hide Tour Map', //The text in the hidden tour map button 57 tourMapText:'â¢â¢â¢', //The text in the show tour button 58 tourMapTitle: 'Tour Map', //Title of Tour map button 59 nextTextDefault:'Next', //The text in the Next Button 60 prevTextDefault:'Prev', //The text in the Prev Button 61 endText:'End Tour', 62 contDialogTitle:'Continue the unfinished tour?', //Title of continue dialog 63 contDialogContent:'Click "Continue" to start with step on which finished last time.', //Content of continue dialog 64 contDialogBtnBegin:'Start from beginning', //Text in the start button of continue dialog 65 contDialogBtnContinue:'Continue', //Text in the continue button of continue dialog 66 introTitle:'Welcome to the interactive tour', //Title of introduction dialog 67 introContent:'This tour will tell you about the main site functionalities', //Content of introduction dialog 68 introDialogBtnStart:'Start', //Text in the start button of introduction dialog 69 introDialogBtnCancel:'Cancel' //Text in the cancel button of introduction dialog 70 } 71 }; 72 return this.each(function (e) { 73 /**/ 74 /*detect IE brouser*/ 75 /**/ 76 var isIE = /*@cc_on!@*/false || document.documentMode; 77 if(isIE){ 78 $('html').addClass('bms'); 79 } 80 81 /**/ 82 /*creating base object*/ 83 /**/ 84 var hWrap = $('body'); 85 if(!hWrap.data().itour){ 86 hWrap.data().itour = {}; 87 } 88 if(!hWrap.data().itour.ini){ 89 90 hWrap.addClass('hWrap'); 91 92 /**/ 93 /*createt base data object*/ 94 /**/ 95 var hData = hWrap.data().itour; 96 97 /**/ 98 /*save all options in base data object*/ 99 /**/ 100 hData.opt = {}; 101 if (options) { 102 $.extend(p.lang, options.lang); 103 } 104 $.extend(hData.opt, p); 105 if (options) { 106 $.extend(hData.opt, options); 107 } 108 $.extend(hData.opt.lang, p.lang); 109
110 if(hWrap.data().itourLang){ 111 $.extend(hData.opt.lang, hWrap.data().itourLang); 112 } 113 114 /**/ 115 /*save user options*/ 116 /**/ 117 hData.userOpt = {}; 118 if (options) { 119 $.extend(hData.userOpt, options); 120 } 121 122 /**/ 123 /*creating object for addition vars*/ 124 /**/ 125 hData.v = {}; 126 127 /**/ 128 /*Creating tour map block*/ 129 /**/ 130 hData.v.hNavPos = $('<div class="hNavPos hNavPos-'+hData.opt.tourMapPos+'"></div>').appendTo('body'); 131 132 if(hData.opt.tourMapEnable === false || hData.opt.tourMapEnable === 'false'){ 133 $('html').addClass('hNav-disable'); 134 } 135 136 137 var oddDetect = function(){ 138 if($(window).height() & 1){ 139 $('html').addClass('vh-odd'); 140 }else{ 141 $('html').removeClass('vh-odd'); 142 } 143 if($(window).width() & 1){ 144 $('html').addClass('vw-odd'); 145 }else{ 146 $('html').removeClass('vw-odd'); 147 } 148 }; 149 oddDetect(); 150 151 152 153 if(hData.opt.textDirection == "rtl"){ 154 hData.v.hNavPos.addClass('rtl'); 155 } 156 157 /**/ 158 /*Any Tour ID*/ 159 /**/ 160 hData.v.tourid = ''; 161 if(hData.opt.tourTitle){ 162 hData.v.tourid = hData.opt.tourTitle; 163 hData.v.hNavHeader = $('<div class="hNavHeader">'+hData.opt.tourTitle+'</div>').prependTo(hData.v.hNavPos); 164 } 165 hData.v.hNavWrap = $('<div class="hNavWrap"></div>').appendTo(hData.v.hNavPos); 166 hData.v.hNavAction = $('<div class="hNavAction"></div>').appendTo(hData.v.hNavPos); 167 168 /**/ 169 /*save start state of style*/ 170 /**/ 171 hData.v.startStyle = hWrap.attr('style') || false; 172 173 /**/ 174 /*Step can be skipped if you set parameter "skip" to true.*/ 175 /**/ 176 var actualStepsCombine = []; 177 var actualIndex = 0; 178 179 var uid = 0; 180 var loc = location.href; 181 var stepReplace = function(hStepItem){ 182 183 if(!hStepItem.loc){ 184 hStepItem.loc = loc; 185 } 186 actualStepsCombine.push(hStepItem); 187 188 /**/ 189 /*Creating step links*/ 190 /**/ 191 var hStepItemTitle = hStepItem.title ? hStepItem.title : 'â'+(actualIndex+1); 192 var hindexStep = $('<div data-hindex="'+actualIndex+'" class="hStepItem">'+hStepItemTitle+'</div>').appendTo(hData.v.hNavWrap); 193 if(hStepItem.ready){ 194 hindexStep.addClass('hSuccess'); 195 } 196 actualIndex++; 197 }; 198 199 200 var escapeRe = function (value) { 201 return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&") 202 }; 203 204 205 206 for(var i = 0; i < hData.opt.steps.length; i++){ 207 var skip = hData.opt.steps[i].skip; 208 if(!skip){ 209 210 var hStepItem = hData.opt.steps[i]; 211 212 213 if(hData.opt.showAbsentElement || hStepItem.contentPosition == 'center'){ 214 stepReplace(hStepItem); 215 }else{ 216 var targetElement; 217 if($(hStepItem.name).length){ 218 targetElement = $(hStepItem.name); 219 }else{ 220 targetElement = $('[data-name *="'+hStepItem.name+'"]'); 221 } 222 if(targetElement.length){ 223 stepReplace(hStepItem); 224 } 225 } 226 } 227 hData.v.tourid = hData.v.tourid + hData.opt.steps[i].name; 228 } 229 hData.opt.steps = actualStepsCombine; 230 231 hData.opt.spacing = parseFloat(hData.opt.spacing); 232 233 /**/ 234 /*Save Desktop Events $ Save Touch Events*/ 235 /**/ 236 var iOs = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; 237 var clickEvent = iOs ? 'touchend' : 'click'; 238 var touchMoving = false; 239 if (iOs){ 240 document.ontouchmove = function(e){ 241 touchMoving = true; 242 } 243 document.ontouchend = function(e){ 244 setTimeout(function(){ 245 touchMoving = false; 246 },100); 247 } 248 } 249 var mousemoveEvent = 'mousemove.'+hData.hName; 250 var mousedownEvent = 'mousedown.'+hData.hName; 251 var mouseupEvent = 'mouseup.'+hData.hName; 252 if('ontouchstart' in window){ 253 mousemoveEvent = 'touchmove.'+hData.hName; 254 mousedownEvent = 'touchstart.'+hData.hName; 255 mouseupEvent = 'touchend.'+hData.hName; 256 } 257 hData.v.mousemoveEvent = mousemoveEvent; 258 hData.v.mouseupEvent = mouseupEvent; 259 hData.v.mousedownEvent = mousedownEvent; 260 261 /**/ 262 /*Add uniquee CSS Class to HTML tag*/ 263 /**/ 264 if(hData.opt.CSSClass){ 265 $('html').addClass(hData.opt.CSSClass); 266 } 267 268 /**/ 269 /*Overlay Elements*/ 270 /**/ 271 var hOverlayDisable = $('<div class="hOverlayDisable"></div>');
272 var hOverlayBottom = $('<div class="hOverlay hOverlayBottom"></div>'); 273 var hOverlayTop = $('<div class="hOverlay hOverlayTop"></div>'); 274 var hOverlayRight = $('<div class="hOverlay hOverlayRight"></div>'); 275 var hOverlayLeft = $('<div class="hOverlay hOverlayLeft"></div>'); 276 hData.v.overlays = hOverlayLeft.add(hOverlayRight).add(hOverlayTop).add(hOverlayBottom).appendTo('body'); 277 hData.v.hOverlayDisable = hOverlayDisable.appendTo('body'); 278 279 /**/ 280 /*Detect Privacy Mode in Safari (iOS)*/ 281 /**/ 282 try { localStorage.test = 2; } catch (e) { 283 alert('You are in Privacy Mode\nPlease deactivate Privacy Mode and then reload the page to view the Tour.'); 284 hWrap.itour('destroy'); 285 return false; 286 } 287 288 /**/ 289 /*This function converts the parameters of the object to a string*/ 290 /**/ 291 var toStringObjIndex = 0; 292 var typeDetect = function(per){ 293 if(typeof per == 'function'){ 294 //function 295 return typeof per; 296 } 297 if(typeof per == 'boolean'){ 298 //boolean 299 return typeof per; 300 } 301 if(typeof per == 'string'){ 302 //string 303 return typeof per; 304 } 305 if(typeof per == 'number'){ 306 //number 307 return typeof per; 308 } 309 if(typeof per == 'object'){ 310 if(Array.isArray(per)){ 311 //Array 312 return 'array'; 313 }else{ 314 //Object 315 return 'object'; 316 } 317 } 318 }; 319 var toStringObj = function(obj){ 320 var newIndex = toStringObjIndex++; 321 var objEnter = obj; 322 var tempObj = {}; 323 tempObj[newIndex] = {}; 324 325 for (var i in objEnter) { 326 var key1 = i; 327 var val = objEnter[key1]; 328 //function 329 if(typeDetect(val) == 'function'){ 330 tempObj[newIndex][key1] = val.toString(); 331 } 332 //array 333 if(typeDetect(val) == 'array'){ 334 var valEach = val; 335 for(var f = 0; f < valEach.length; f++){ 336 if(typeDetect(valEach[f]) == 'object'){ 337 var objMass = valEach[f]; 338 var val3 = toStringObj(objMass); 339 valEach[f] = val3; 340 } 341 } 342 tempObj[newIndex][key1] = valEach; 343 } 344 //object 345 if(typeDetect(val) == 'object'){ 346 var val2 = toStringObj(val); 347 tempObj[newIndex][key1] = val2; 348 } 349 //string, number, boolean 350 if(typeDetect(val) == 'string' || typeDetect(val) == 'number' || typeDetect(val) == 'boolean'){ 351 tempObj[newIndex][key1] = objEnter[key1]; 352 } 353 } 354 return tempObj[newIndex]; 355 }; 356 357 /**/ 358 /*Overlay Elements Positioning*/ 359 /**/ 360 var overlayPos = function(targetEl){ 361 362 if(targetEl && targetEl.length){ 363 var targetElWidth = Math.round(targetEl.outerWidth()); 364 var targetElHeight = Math.round(targetEl.outerHeight()); 365 var targetElTop = Math.round(targetEl.offset().top); 366 var targetElLeft = Math.round(targetEl.offset().left); 367 368 if(targetEl.is('body')){ 369 var wHalf = Math.round($(window).width()/2); 370 var hHalf = Math.round($(window).height()/2); 371 372 hOverlayTop.css({ 373 left:0, 374 top:0, 375 width:wHalf, 376 height:hHalf 377 });
378 379 hOverlayRight.css({ 380 left:wHalf, 381 top:0, 382 width:($(window).width() - wHalf), 383 height:hHalf 384 }); 385 386 hOverlayLeft.css({ 387 left:0, 388 top:hHalf, 389 width:wHalf, 390 height:($(window).height() - hHalf) 391 }); 392 393 hOverlayBottom.css({ 394 left:wHalf, 395 top:hHalf, 396 width:($(window).width() - wHalf), 397 height:($(window).height() - hHalf) 398 }); 399 }else{ 400 $('.itour-highlight').removeClass('itour-highlight'); 401 targetEl.addClass('itour-highlight'); 402 403 hOverlayBottom.css({ 404 left:((targetElLeft - hData.opt.spacing) - $(window).scrollLeft())+'px', 405 top:((targetElTop + hData.opt.spacing + targetElHeight) - $(window).scrollTop())+'px', 406 width:(($(window).width() - (targetElLeft - hData.opt.spacing)) + $(window).scrollLeft())+'px', 407 height:(($(window).height() - (targetElTop + hData.opt.spacing + targetElHeight))+$(window).scrollTop())+'px' 408 });
409 hOverlayTop.css({ 410 left:0, 411 top:0, 412 width:((((targetElLeft + hData.opt.spacing) + targetElWidth)) - $(window).scrollLeft())+'px', 413 height:((targetElTop - hData.opt.spacing) - $(window).scrollTop())+'px' 414 }); 415 hOverlayRight.css({ 416 left:((targetElLeft + hData.opt.spacing + targetElWidth) - $(window).scrollLeft())+'px', 417 top:0, 418 width:(($(window).width() - (targetElLeft + hData.opt.spacing + targetElWidth))+$(window).scrollLeft())+'px', 419 height:((targetElTop + hData.opt.spacing + targetElHeight)- $(window).scrollTop())+'px' 420 }); 421 422 hOverlayLeft.css({ 423 left:(0 - $(window).scrollLeft())+'px', 424 top:((targetElTop - hData.opt.spacing) - $(window).scrollTop())+'px', 425 width:((targetElLeft - hData.opt.spacing))+'px', 426 height:(($(window).height() - (targetElTop - hData.opt.spacing)) + $(window).scrollTop())+'px' 427 }); 428 } 429 430 setTimeout(function(){ 431 hData.v.overlays.addClass('noTransition'); 432 },310); 433 434 /**/ 435 /*Specifies the data for the starting step*/ 436 /**/ 437 var targetOpt = hData.opt.steps[hData.v.startIndex]; 438 var contentPos = $.trim(targetOpt.contentPosition).split(''); 439 var top; 440 var left; 441 var blockTransLeft = '0'; 442 var blockTransTop = '0'; 443 var blockLeft; 444 var blockTop; 445 var defOpacity = 0.5; 446 447 if(hData.opt.steps){ 448 if(hData.opt.steps[hData.v.startIndex].disable){ 449 hOverlayDisable.addClass('hOverlayDisableTrue'); 450 }else{ 451 hOverlayDisable.removeClass('hOverlayDisableTrue'); 452 } 453 if(hData.opt.steps[hData.v.startIndex].overlayOpacity >= 0){ 454 defOpacity = hData.opt.steps[hData.v.startIndex].overlayOpacity; 455 } 456 457 $(document).on('keyup.itour',function(e){ 458 if(parseFloat(e.keyCode) == 27){ 459 hWrap.itour('destroy'); 460 if (hData.opt.end !== undefined) {hData.opt.end();} 461 } 462 });
463 464 hData.v.overlays.css({opacity:defOpacity}); 465 /**/ 466 /*Positioning in center of the screen */ 467 /**/ 468 if(hData.opt.steps[hData.v.startIndex].contentPosition == 'center'){ 469 contentPos = ['c','c','c']; 470 left = '50%'; 471 top = '50%'; 472 }else{ 473 474 /**/ 475 /*Automatic positioning of message */ 476 /**/ 477 if(contentPos.length != 3 || contentPos[0] != 't' && contentPos[0] != 'r' && contentPos[0] != 'b' && contentPos[0] != 'l'){ 478 hData.opt.steps[hData.v.startIndex].contentPosition = 'auto'; 479 } 480 if(hData.opt.steps[hData.v.startIndex].contentPosition == 'auto'){ 481 var targetPosTop = (targetElTop - $(window).scrollTop()); 482 var maxSpace = targetPosTop; 483 contentPos = ['t','c','c']; 484 top = ((targetElTop - (hData.opt.spacing + 15)) - $(window).scrollTop()); 485 left = (targetElLeft + targetElWidth/2) - $(window).scrollLeft(); 486 var targetElBottom = ($(window).height() - (targetPosTop + targetElHeight)); 487 if(targetElBottom > maxSpace){ 488 maxSpace = targetElBottom; 489 contentPos = ['b','c','c']; 490 top = (targetElTop + hData.opt.spacing + targetElHeight + 15) - $(window).scrollTop(); 491 } 492 var targetPosLeft = (targetElLeft - $(window).scrollLeft()); 493 if(targetPosLeft > maxSpace){ 494 maxSpace = targetPosLeft; 495 contentPos = ['l','c','c']; 496 left = (targetElLeft - (hData.opt.spacing + 15)) - $(window).scrollLeft(); 497 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 498 } 499 var targetElRight = ($(window).width() - (targetPosLeft + targetElWidth)); 500 if(targetElRight > maxSpace){ 501 maxSpace = targetElRight; 502 contentPos = ['r','c','c']; 503 left = (targetElLeft + hData.opt.spacing + targetElWidth + 15) - $(window).scrollLeft(); 504 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 505 } 506 if(contentPos[0] == 'l' || contentPos[0] == 'r'){ 507 if((targetPosTop - targetElBottom) > 100 || (targetPosTop - targetElBottom) < -100){ 508 if(targetPosTop > targetElBottom){ 509 contentPos[1] = 'c'; 510 contentPos[2] = 't'; 511 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 512 513 /**/ 514 /*If the message is hidden behind the bottom of the screen*/ 515 /**/ 516 if((top + 50) > ($(window).scrollTop() + $(window).height())){ 517 contentPos[1] = 't'; 518 top = (targetElTop - hData.opt.spacing) - $(window).scrollTop(); 519 } 520 } 521 if(targetPosTop < targetElBottom){ 522 contentPos[1] = 'c'; 523 contentPos[2] = 'b'; 524 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 525 526 /**/ 527 /*If the message is hidden behind the top of the screen*/ 528 /**/ 529 if((top - 50) < $(window).scrollTop()){ 530 contentPos[1] = 'b'; 531 top = (targetElTop + targetElHeight + hData.opt.spacing) - $(window).scrollTop(); 532 } 533 } 534 }else{ 535 contentPos[1] = 'c'; 536 contentPos[2] = 'c'; 537 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 538 } 539 } 540 if(contentPos[0] == 't' || contentPos[0] == 'b'){ 541 if((targetPosLeft - targetElRight) > 100 || (targetPosLeft - targetElRight) < -100){ 542 if(targetPosLeft > targetElRight){ 543 contentPos[1] = 'c'; 544 contentPos[2] = 'l'; 545 left = (targetElLeft + targetElWidth/2) - $(window).scrollLeft(); 546 } 547 if(targetPosLeft < targetElRight){ 548 contentPos[1] = 'c'; 549 contentPos[2] = 'r'; 550 left = (targetElLeft + targetElWidth/2) - $(window).scrollLeft(); 551 } 552 }else{ 553 contentPos[1] = 'c'; 554 contentPos[2] = 'c'; 555 left = (targetElLeft + targetElWidth/2) - $(window).scrollLeft(); 556 } 557 } 558 }else{ 559 560 /**/ 561 /*Decoding of first symbol*/ 562 /**/ 563 if(contentPos[0] == 'r'){ 564 left = (targetElLeft + hData.opt.spacing + targetElWidth + 15) - $(window).scrollLeft(); 565 blockTransLeft = '0'; 566 blockLeft = '0'; 567 } 568 if(contentPos[0] == 'l'){ 569 left = (targetElLeft - (hData.opt.spacing + 15)) - $(window).scrollLeft(); 570 blockTransLeft = '-100%'; 571 blockLeft = '0'; 572 } 573 if(contentPos[0] == 'b'){ 574 top = ((targetElTop + hData.opt.spacing + targetElHeight) - $(window).scrollTop()) + 15; 575 blockTransTop = '0'; 576 blockTop = '0'; 577 } 578 if(contentPos[0] == 't'){
579 top = ((targetElTop - (hData.opt.spacing + 15)) - $(window).scrollTop()); 580 blockTransTop = '-100%'; 581 blockTop = '0'; 582 } 583 584 /**/ 585 /*Decoding of second symbol*/ 586 /**/ 587 if(contentPos[1] == 'c' && contentPos[0] == 'r' || contentPos[1] == 'c' && contentPos[0] == 'l'){ 588 top = (targetElTop + targetElHeight/2) - $(window).scrollTop(); 589 } 590 if(contentPos[1] == 'b'){ 591 top = (targetElTop + targetElHeight + hData.opt.spacing) - $(window).scrollTop(); 592 } 593 if(contentPos[1] == 't'){ 594 top = (targetElTop - hData.opt.spacing) - $(window).scrollTop(); 595 } 596 if(contentPos[1] == 'c' && contentPos[0] == 'b' || contentPos[1] == 'c' && contentPos[0] == 't'){ 597 left = (targetElLeft + targetElWidth/2) - $(window).scrollLeft(); 598 } 599 if(contentPos[1] == 'l'){ 600 left = (targetElLeft - hData.opt.spacing) - $(window).scrollLeft(); 601 } 602 if(contentPos[1] == 'r'){ 603 left = (targetElLeft + targetElWidth + hData.opt.spacing) - $(window).scrollLeft(); 604 } 605 } 606 607 } 608 609 /**/ 610 /*Set of the position code*/ 611 /**/ 612 hData.v.hContPos.css({left:left,top:top}).attr({ 613 'data-pos':contentPos[0], 614 'data-cone':contentPos[1], 615 'data-cont':contentPos[2] 616 });
617 618 hData.v.hContPos.stop(true).css({opacity:0}).show(); 619 620 /**/ 621 /*Position correction*/ 622 /**/ 623 if(contentPos[0] == 't' || contentPos[0] == 'b'){ 624 625 hData.v.hContBlock.removeAttr('style'); 626 627 var ww = $(window).width(); 628 var sum = (hData.v.hContBlock.offset().left + hData.v.hContBlock.width()); 629 if(sum > (ww - 5)){ 630 hData.v.hContBlock.css({marginLeft:-((sum - ww)+5)}); 631 } 632 633 634 635 if(hData.v.hContBlock.offset().left < 5){ 636 637 console.log((hData.v.hContBlock.offset().left*-1+5)) 638 639 640 hData.v.hContBlock.css({marginLeft:(hData.v.hContBlock.offset().left*-1+5)}) 641 } 642 } 643 644 if(contentPos[0] == 'l' || contentPos[0] == 'r'){ 645 646 hData.v.hContBlock.removeAttr('style'); 647 648 var ww = $(window).width(); 649 var sum = (hData.v.hContBlock.offset().left + hData.v.hContBlock.width()); 650 if(sum > (ww - 5)){ 651 hData.v.hContBlock.css({width:hData.v.hContBlock.width() - ((sum - ww)+5)}); 652 } 653 654 if(hData.v.hContBlock.offset().left < 5){ 655 hData.v.hContBlock.css({width:hData.v.hContBlock.width() - (hData.v.hContBlock.offset().left*-1+5)}) 656 } 657 658 } 659 660 if(contentPos[0] == 'c' & contentPos[1] == 'c' & contentPos[2] == 'c'){ 661 hData.v.hContBlock.removeAttr('style'); 662 } 663 664 /*Show Message Window*/ 665 hData.v.hContPos.stop(true).delay(500).animate({opacity:1}); 666 }else{ 667 console.log('Parameter "steps" is undefined or empty'); 668 } 669 } 670 }; 671 hData.v.overlayPos = overlayPos; 672 673 /**/ 674 /*Creating message block*/ 675 /**/ 676 hData.v.hContPos = $('<div>').addClass('hContPos').appendTo('body'); 677 hData.v.hContBlock = $('<div>').addClass('hContBlock').appendTo(hData.v.hContPos); 678 hData.v.hContBody = $('<div>').addClass('hContBody').appendTo(hData.v.hContBlock); 679 hData.v.hContFooter = $('<div>').addClass('hContFooter').appendTo(hData.v.hContBlock); 680 hData.v.hContHeader = $('<div>').addClass('hContHeader').prependTo(hData.v.hContBlock); 681 682 if(hData.opt.textDirection == "rtl"){ 683 hData.v.hContBlock.addClass('rtl'); 684 } 685 686 hData.v.hAction = $('<div>').addClass('hAction').prependTo(hData.v.hContBlock); 687 if(hData.opt.modalCancelVisible){ 688 hData.v.hCancelBtn = $('<span class="hCancelBtn hClose hRoundBtn" title="'+hData.opt.lang.cancelText+'">Ã</span>').appendTo(hData.v.hAction); 689 } 690 hData.v.hNavBtn = $('<span class="hNavBtn hRoundBtn" title="'+hData.opt.lang.tourMapTitle+'">'+hData.opt.lang.tourMapText+'</span>') 691 if(hData.opt.tourMapEnable === true || hData.opt.tourMapEnable === 'true'){ 692 hData.v.hNavBtn.appendTo(hData.v.hAction); 693 } 694 695 hData.v.hContImage = $('<div class="hContImage"></div>').prependTo(hData.v.hContBlock); 696 697 hData.v.stepNumbersVisible = $('<div class="hStepNumbers"></div>'); 698 699 $('<div class="hStepNumber"></div>').appendTo(hData.v.stepNumbersVisible); 700 $('<div class="hStepTotal">'+hData.opt.steps.length+'</div>').appendTo(hData.v.stepNumbersVisible); 701 702 /**/ 703 /*This function skip an absent element*/ 704 /**/ 705 var searchElement = function(mess){ 706 if((parseFloat(hData.v.startIndex) + 1) < hData.opt.steps.length){ 707 if(hData.opt.showAbsentElement){ 708 $('[data-hindex="'+hData.v.startIndex+'"]').addClass('hElAbsent'); 709 } 710 if(hData.v.event === 'next'){ 711 hData.v.startIndex++; 712 }else{ 713 hData.v.startIndex--; 714 } 715 if(!hData.v.event){ 716 hData.v.event = 'next'; 717 } 718 hStep(); 719 }else{ 720 console.log('Target is '+mess); 721 hWrap.itour('destroy'); 722 } 723 } 724 725 /**/ 726 /*Creating the tour map buttons*/ 727 /**/ 728 hData.v.hClose = $('<span class="hClose hBtn">'+hData.opt.lang.cancelText+'</span>').appendTo(hData.v.hNavAction); 729 hData.v.hHide = $('<span class="hHide hBtn">'+hData.opt.lang.hideText+'</span>').appendTo(hData.v.hNavAction); 730 731 /**/ 732 /*Changing the content of message block*/ 733 /**/ 734 hData.opt.startStep = parseFloat(hData.opt.startStep); 735 if(hData.opt.startStep < 1) { 736 hData.opt.startStep == 1; 737 } 738
739 var afterFunc = function(){ 740 if (hData.opt.steps[hData.v.startIndex].after !== undefined) {hData.opt.steps[hData.v.startIndex].after();} 741 }; 742 743 var hStep = function(){ 744 if(hData.v.overlays){ 745 hData.v.overlays.removeClass('noTransition'); 746 } 747 hData.v.overlayEnable = false; 748 setTimeout(function(){ 749 hData.v.overlayEnable = true; 750 },1000); 751 752 hData.v.hContPos.stop(true).fadeOut(100,function(){ 753 var changeDelay = 300; 754 if(hWrap.data().itour_go){ 755 changeDelay = 1; 756 localStorage.removeItem('itour_go'); 757 hWrap.data().itour_go = false; 758 } 759 760 setTimeout(function(){ 761 762 /**/ 763 /*Cleaning the content of message block*/ 764 /**/ 765 hData.v.hContPos.hide(); 766 hData.v.hContHeader.empty(); 767 hData.v.hContBody.empty(); 768 hData.v.hContFooter.empty(); 769 770 /**/ 771 /*If listed steps in parameters*/ 772 /**/ 773 if(hData.opt.steps){ 774 775 var targetOpt = hData.opt.steps[hData.v.startIndex]; 776 if(targetOpt){ 777 if (targetOpt.before !== undefined) {targetOpt.before();} 778 779 /**/ 780 /*The delay before the element search*/ 781 /**/ 782 setTimeout(function(){ 783 var targetElement; 784 if($(targetOpt.name).length){ 785 targetElement = $(targetOpt.name); 786 }else{ 787 targetElement = $('[data-name *="'+targetOpt.name+'"]') 788 } 789 hData.v.targetEl = targetElement; 790 791 /**/ 792 /*If the specified element (purpose) for this step*/ 793 /**/ 794 if(targetOpt.contentPosition == 'center'){ 795 hData.v.targetEl = $('body'); 796 } 797 798 if(hData.v.targetEl.length){ 799 if(hData.v.targetEl.is(':visible')){ 800 801 var myFunc = function(){ 802 803 $('[data-hindex="'+hData.v.startIndex+'"]').removeClass('hElAbsent'); 804 $('[data-hindex="'+hData.v.startIndex+'"]').removeClass('hElHidden'); 805 806 /**/ 807 /*Transmits the step data to the overlay function*/ 808 /**/ 809 810 $('html').removeAttr('data-step'); 811 var stepID = 'step-'+(hData.v.startIndex + 1); 812 if(targetOpt.stepID){ 813 stepID = targetOpt.stepID; 814 } 815 $('html').attr('data-step',stepID); 816 817 hData.v.overlayPos(hData.v.targetEl); 818 var targetOptTitle = targetOpt.title ? targetOpt.title : 'â'+(parseFloat(hData.v.startIndex)+1); 819 820 /**/ 821 /*Insert new content*/ 822 /**/ 823 if(targetOpt.image && $.trim(targetOpt.image) !== ''){ 824 $('<img>') 825 .attr('src',targetOpt.image) 826 .on('load',function(){ 827 hData.v.hContImage.html('<img src="'+targetOpt.image+'">'); 828 setTimeout(function(){ 829 var image = hData.v.hContImage.find('img'); 830 var coverHeight = image.height().toFixed(); 831 if(coverHeight & 1){ 832 coverHeight = (parseFloat(coverHeight)+1); 833 } 834 image.height(coverHeight); 835 },500) 836 }); 837 }else{ 838 hData.v.hContImage.empty(); 839 } 840 if(targetOpt.title){ 841 hData.v.hContHeader.html(targetOptTitle); 842 }else{ 843 hData.v.hContHeader.html(''); 844 } 845 846 hData.v.hContBody.html(targetOpt.content); 847 848 /**/ 849 /*Sets the text to the default buttons*/ 850 /**/ 851 if(!hData.opt.steps[hData.v.startIndex].prevText) {hData.opt.steps[hData.v.startIndex].prevText = hData.opt.lang.prevTextDefault;} 852 if(!hData.opt.steps[hData.v.startIndex].nextText) {hData.opt.steps[hData.v.startIndex].nextText = (parseFloat(hData.v.startIndex)+1) == hData.opt.steps.length ? hData.opt.lang.endText : hData.opt.lang.nextTextDefault;} 853 854 /**/ 855 /*Insert step numbers*/ 856 /**/ 857 var stepValue = parseFloat(hData.v.startIndex)+1; 858 $('.hStepNumber',hData.v.stepNumbersVisible).html(stepValue); 859 if(hData.opt.stepNumbersVisible){ 860 hData.v.stepNumbersVisible.appendTo(hData.v.hContFooter); 861 } 862 863 /**/ 864 /*Save step numbers in localStorage*/ 865 /**/ 866 if (typeof(Storage) !== "undefined"){ 867 var itour_data = {}; 868 if(stepValue > 1){ 869 itour_data = { 870 tourId:hData.v.tourid, 871 stepValue:stepValue, 872 page:location.href 873 }; 874 }else{ 875 itour_data = { 876 tourId:false, 877 stepValue:stepValue, 878 page:location.href 879 }; 880 } 881 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 882 } 883 884 /**/ 885 /*Insert buttons*/ 886 /**/ 887 //hData.v.hClose.clone().addClass('hBtnRight').appendTo(hData.v.hContFooter); 888 var prevIndex = hData.v.startIndex-1; 889 if(hData.opt.steps[prevIndex]){ 890 $('<span class="hBtn hPrev">'+hData.opt.steps[hData.v.startIndex].prevText+'</span>').appendTo(hData.v.hContFooter); 891 } 892 var hNext; 893 if(hData.opt.steps[hData.v.startIndex]){ 894 if(hData.opt.steps[hData.v.startIndex].ready){ 895 hNext = $('<span class="hBtn hNext">'+hData.opt.steps[hData.v.startIndex].nextText+'</span>').appendTo(hData.v.hContFooter); 896 } 897 } 898 899 if(!hData.opt.steps[hData.v.startIndex].event){ 900 hData.opt.steps[hData.v.startIndex].event = 'next'; 901 } 902 903 hData.v.customEvent = false; 904 hData.v.customTarget = false; 905 906 if(hData.opt.steps[hData.v.startIndex].event == 'next'){ 907 if(!$(hNext).length){ 908 hNext = $('<span class="hBtn hNext">'+hData.opt.steps[hData.v.startIndex].nextText+'</span>').appendTo(hData.v.hContFooter); 909 } 910 }else{ 911 912 if(typeof hData.opt.steps[hData.v.startIndex].event == 'object'){ 913 hData.v.customEvent = hData.opt.steps[hData.v.startIndex].event[0]; 914 hData.v.customTarget = hData.opt.steps[hData.v.startIndex].event[1];
915 } 916 917 if(typeof hData.opt.steps[hData.v.startIndex].event == 'string'){ 918 hData.v.customEvent = hData.opt.steps[hData.v.startIndex].event; 919 hData.v.customTarget = hData.v.targetEl; 920 } 921 922 if(hData.v.customEvent){ 923 if(hData.v.customTarget){ 924 hData.v.customTarget.attr('data-uid','h-'+uid++); 925 hData.v.customTargetSelector = '[data-uid="'+hData.v.customTarget.attr('data-uid')+'"]'; 926 if(hData.v.customTargetSelector){ 927 $(document).on(hData.v.customEvent+'.itour',hData.v.customTargetSelector,function(e){ 928 929 $(this).off(e); 930 targetOpt.ready = true; 931 932 /**/ 933 /*Step is marked as completed (painted over)*/ 934 /**/ 935 $('[data-hindex="'+hData.v.startIndex+'"]').addClass('hSuccess'); 936 afterFunc(); 937 setTimeout(function(){ 938 hData.v.startIndex++; 939 hStep(); 940 },targetOpt.delayAfter); 941 return true; 942 }); 943 }else{ 944 console.log('Custom target don\'t have class and id attributes'); 945 } 946 }else{ 947 console.log('Custom target is absent'); 948 } 949 }else{ 950 console.log('Custom event is absent'); 951 } 952 } 953 954 /**/ 955 /*Highlighting the active step*/ 956 /**/ 957 $('[data-hindex]').removeClass('hCur').filter('[data-hindex="'+hData.v.startIndex+'"]').addClass('hCur'); 958 if(hData.opt.steps[hData.v.startIndex].trigger && hData.opt.steps[hData.v.startIndex].trigger != false && hData.opt.steps[hData.v.startIndex].trigger != 'false'){ 959 hData.v.targetEl.trigger(hData.opt.steps[hData.v.startIndex].trigger); 960 } 961 962 /**/ 963 /*During callback function*/ 964 /**/ 965 if (targetOpt.during !== undefined) {targetOpt.during();} 966 }; 967 968 /**/ 969 /*Animation scroll to selected item*/ 970 /**/ 971 if(targetOpt.contentPosition == 'center'){ 972 myFunc(); 973 }else{ 974 if(hData.v.targetEl.offset().top < $(window).scrollTop()){ 975 hData.v.scrolling = true; 976 $('html,body').animate({scrollTop:(hData.v.targetEl.offset().top - $(window).height()/2)},changeDelay).promise().then(function(){ 977 setTimeout(function(){ 978 hData.v.scrolling = false; 979 myFunc(); 980 },1); 981 }); 982 }else{ 983 if((hData.v.targetEl.offset().top + hData.v.targetEl.outerHeight()) > ($(window).scrollTop() + $(window).height())){ 984 hData.v.scrolling = true; 985 $('html,body').animate({scrollTop:(hData.v.targetEl.offset().top - $(window).height()/2)},changeDelay).promise().then(function(){ 986 setTimeout(function(){ 987 hData.v.scrolling = false; 988 myFunc(); 989 },1); 990 }); 991 }else{ 992 myFunc(); 993 } 994 } 995 } 996 }else{ 997 searchElement('hidden'); 998 } 999 }else{ 1000 searchElement('absent'); 1001 } 1002 },targetOpt.delayBefore); 1003 }else{ 1004 hData.v.startIndex--; 1005 1006 /**/ 1007 /*Triggered when sequence is over*/ 1008 /**/ 1009 hWrap.itour('destroy'); 1010 if (hData.opt.end !== undefined) {hData.opt.end();} 1011 1012 /**/ 1013 /*Save step numbers in localStorage*/ 1014 /**/ 1015 if (typeof(Storage) !== "undefined"){ 1016 var itour_data = { 1017 tourId:false 1018 }; 1019 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1020 } 1021 } 1022 }else{ 1023 console.log('step data is missing'); 1024 } 1025 },changeDelay); 1026 });
1027 }; 1028 1029 1030 var startStep = function(){ 1031 var startMess = $('.startDialog').add('.startOverlay'); 1032 startMess.removeClass('hShow'); 1033 1034 var delayTimeout = 100; 1035 if(hWrap.data().itour_go){ 1036 delayTimeout = 1; 1037 } 1038 1039 setTimeout(function(){ 1040 startMess.remove(); 1041 1042 /**/ 1043 /*Show the tour map block by default, if there is a flag*/ 1044 /**/ 1045 if(hData.opt.tourMapVisible === true || hData.opt.tourMapVisible === "true"){ 1046 $('html').addClass('hNavOpen'); 1047 } 1048 $('html').removeClass('hIntroShow'); 1049 1050 /**/ 1051 /*Correcting start index*/ 1052 /**/ 1053 hData.v.startIndex = (parseFloat(hData.opt.startStep) - 1); 1054 1055 /**/ 1056 /*Start step function*/ 1057 /**/ 1058 hStep(); 1059 1060 },delayTimeout) 1061 }; 1062 1063 1064 /**/ 1065 /*Detect unfinished tour*/ 1066 /**/ 1067 var storageDetect = function(){ 1068 1069 var introMess = $('.introDialog'); 1070 introMess.removeClass('hShow'); 1071 1072 var delayTimeout = 100; 1073 if(hWrap.data().itour_go){ 1074 delayTimeout = 1; 1075 } 1076 1077 setTimeout(function(){ 1078 introMess.remove(); 1079 if (typeof(Storage) !== 'undefined'){ 1080 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1081 var nowLoc = location.href; 1082 var itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1083 if(itour_data.tourId == hData.v.tourid){ 1084 if(hWrap.data().itour_go){ 1085 hData.v.stepValue = itour_data.stepValue; 1086 hData.opt.startStep = hData.v.stepValue; 1087 startStep(); 1088 }else{ 1089 if(hData.opt.tourContinue){ 1090 hData.v.startDialog = $('<div>') 1091 .addClass('startDialog hContBlock') 1092 .html('<div class="hContHeader">'+hData.opt.lang.contDialogTitle+'</div><div class="hContBody">'+hData.opt.lang.contDialogContent+'</div><div class="hContFooter" style="text-align:right"><span class="hBtn startOverBtn">'+hData.opt.lang.contDialogBtnBegin+'</span><span class="hBtn continueBtn">'+hData.opt.lang.contDialogBtnContinue+'</span></div>') 1093 .appendTo('body'); 1094 1095 if(hData.opt.textDirection == "rtl"){ 1096 hData.v.startDialog.addClass('rtl'); 1097 } 1098 1099 hData.v.startOverlay = $('.startOverlay'); 1100 if(!hData.v.startOverlay.length){ 1101 hData.v.startOverlay = $('<div>').addClass('startOverlay').appendTo('body'); 1102 } 1103 hData.v.stepValue = itour_data.stepValue; 1104 1105 var pageLoc = itour_data.page; 1106 if(nowLoc.search(escapeRe(pageLoc)) === -1 && pageLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== pageLoc){ 1107 hData.v.otherPage = itour_data.page; 1108 }else{ 1109 hData.v.otherPage = false; 1110 } 1111 setTimeout(function(){ 1112 hData.v.startDialog.add(hData.v.startOverlay).addClass('hShow'); 1113 },100); 1114 }else{ 1115 startStep(); 1116 } 1117 } 1118 1119 }else{ 1120 1121 if(parseFloat(hData.opt.startStep) < 1) targetLoc = 1; 1122 if(targetLoc > hData.opt.steps.length) targetLoc = hData.opt.steps.length; 1123 1124 var targetLoc = hData.opt.steps[(parseFloat(hData.opt.startStep) - 1)].loc; 1125 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1126 1127 var itour_go = { 1128 opt:toStringObj(hData.opt) 1129 }; 1130 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1131 1132 /**/ 1133 /*Save step numbers in localStorage*/ 1134 /**/ 1135 var itour_data = {}; 1136 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1137 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1138 } 1139 $.extend(itour_data, { 1140 tourId:hData.v.tourid, 1141 stepValue:hData.opt.startStep 1142 }); 1143 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1144 1145 /**/ 1146 /*Redirect*/ 1147 /**/ 1148 location.href = targetLoc; 1149 }else{ 1150 startStep(); 1151 } 1152 } 1153 }else{ 1154 startStep(); 1155 } 1156 }else{ 1157 startStep(); 1158 } 1159 },delayTimeout); 1160 }; 1161 1162 1163 $(document).on('click','.hStartBtn',function(){ 1164 storageDetect(); 1165 });
1166 1167 $(document).on('click','._hStartBtn',function(){ 1168 1169 /**/ 1170 /*Set present and necessary location path*/ 1171 /**/ 1172 hData.v.startIndex = (parseFloat(hData.opt.startStep) - 1); 1173 var nowLoc = location.href; 1174 var targetLoc = nowLoc; 1175 var nextIndex = hData.v.startIndex; 1176 1177 /**/ 1178 /*Check presence of next step */ 1179 /**/ 1180 if(nextIndex < hData.opt.steps.length && nextIndex >= 0){ 1181 targetLoc = hData.opt.steps[nextIndex].loc; 1182 } 1183 /**/ 1184 /*compare the paths*/ 1185 /**/ 1186 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1187 1188 /*If the paths are not the same:*/ 1189 1190 /**/ 1191 /*create new options object for transfer to another page*/ 1192 /**/ 1193 1194 if (typeof(Storage) !== "undefined"){ 1195 var itour_go = { 1196 opt:toStringObj(hData.opt) 1197 }; 1198 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1199 1200 /**/ 1201 /*Save step numbers in localStorage*/ 1202 /*Get itour_data object from localStorage*/ 1203 /**/ 1204 var itour_data = {}; 1205 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1206 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1207 } 1208 1209 /**/ 1210 /*Merge the getting object with the new values*/ 1211 /**/ 1212 $.extend(itour_data, { 1213 tourId:hData.v.tourid, 1214 stepValue:hData.opt.startStep 1215 }); 1216 1217 /**/ 1218 /*Save new data in localStorage*/ 1219 /**/ 1220 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1221 1222 /**/ 1223 /*Redirect*/ 1224 /**/ 1225 location.href = targetLoc; 1226 }else{ 1227 brouserNotSupport() 1228 } 1229 }else{ 1230 storageDetect(); 1231 } 1232 }); 1233 1234 $(document).on('click','.startOverBtn',function(){ 1235 1236 1237 /**/ 1238 /*Set present and necessary location path*/ 1239 /**/ 1240 var nowLoc = location.href; 1241 var targetLoc = nowLoc; 1242 var nextIndex = (parseFloat(hData.opt.startStep) - 1); 1243 1244 /**/ 1245 /*Check presence of next step */ 1246 /**/ 1247 if(nextIndex < hData.opt.steps.length && nextIndex >= 0){ 1248 targetLoc = hData.opt.steps[nextIndex].loc; 1249 } 1250 /**/ 1251 /*compare the paths*/ 1252 /**/ 1253 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1254 1255 /*If the paths are not the same:*/ 1256 1257 /**/ 1258 /*create new options object for transfer to another page*/ 1259 /**/ 1260 if (typeof(Storage) !== "undefined"){ 1261 var itour_go = { 1262 opt:toStringObj(hData.opt) 1263 }; 1264 1265 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1266 1267 /**/ 1268 /*Save step numbers in localStorage*/ 1269 /*Get itour_data object from localStorage*/ 1270 /**/ 1271 var itour_data = {}; 1272 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1273 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1274 } 1275 1276 /**/ 1277 /*Merge the getting object with the new values*/ 1278 /**/ 1279 $.extend(itour_data, { 1280 tourId:hData.v.tourid, 1281 stepValue:hData.opt.startStep 1282 }); 1283 1284 /**/ 1285 /*Save new data in localStorage*/ 1286 /**/ 1287 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1288 1289 /**/ 1290 /*Redirect*/ 1291 /**/ 1292 location.href = targetLoc; 1293 }else{ 1294 brouserNotSupport() 1295 } 1296 }else{ 1297 startStep(); 1298 } 1299 }); 1300 1301 $(document).on('click','.continueBtn',function(){ 1302 1303 hData.opt.startStep = hData.v.stepValue; 1304 1305 if(hData.v.otherPage){ 1306 1307 1308 hData.v.customTarget = hData.v.otherPage; 1309 1310 /**/ 1311 /*Add Redirect Flag*/ 1312 /**/ 1313 if (typeof(Storage) !== 'undefined'){ 1314 if(localStorage){ 1315 var itour_go = { 1316 opt:toStringObj(hData.opt) 1317 } 1318 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1319 } 1320 } 1321 1322 /**/ 1323 /*Redirect*/ 1324 /**/ 1325 location.href = hData.v.customTarget; 1326 }else{ 1327 startStep(); 1328 } 1329 });
1330 1331 /**/ 1332 /*Update position after window resize*/ 1333 /**/ 1334 $(window).on('resize scroll',function(){ 1335 if(hData.ini){ 1336 if(!hData.v.scrolling){ 1337 hData.v.overlayPos(hData.v.targetEl); 1338 } 1339 oddDetect(); 1340 } 1341 }); 1342 1343 var brouserNotSupport = function(){ 1344 console.log('Your browser does not support multi-page'); 1345 hWrap.itour('destroy'); 1346 }; 1347 1348 /**/ 1349 /*This function call the next step*/ 1350 /**/ 1351 $(document).on('click','.hNext',function(){ 1352 1353 /**/ 1354 /*Set present and necessary location path*/ 1355 /**/ 1356 var nowLoc = location.href; 1357 var targetLoc = nowLoc; 1358 var nextIndex = (parseFloat(hData.v.startIndex) + 1); 1359 1360 /**/ 1361 /*Check presence of next step */ 1362 /**/ 1363 if(nextIndex < hData.opt.steps.length){ 1364 targetLoc = hData.opt.steps[nextIndex].loc; 1365 } 1366 1367 1368 hData.v.targetEl.off(hData.opt.steps[hData.v.startIndex].event+'.itour'); 1369 1370 if(hData.v.customTargetSelector){ 1371 $(hData.v.customTargetSelector).off(hData.v.customEvent+'.itour'); 1372 } 1373 1374 if(hData.opt.steps[hData.v.startIndex].event == 'next'){ 1375 hData.opt.steps[hData.v.startIndex].ready = true; 1376 $('[data-hindex="'+hData.v.startIndex+'"]').addClass('hSuccess'); 1377 } 1378 afterFunc(); 1379 setTimeout(function(){ 1380 /**/ 1381 /*compare the paths*/ 1382 /**/ 1383 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1384 /*If the paths are not the same:*/ 1385 /**/ 1386 /*create new options object for transfer to another page*/ 1387 /**/ 1388 if (typeof(Storage) !== "undefined"){ 1389 1390 var itour_go = { 1391 opt:toStringObj(hData.opt) 1392 }; 1393 1394 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1395 1396 /**/ 1397 /*Save step numbers in localStorage*/ 1398 /*Get itour_data object from localStorage*/ 1399 /**/ 1400 var itour_data = {}; 1401 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1402 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1403 } 1404 1405 /**/ 1406 /*Merge the getting object with the new values*/ 1407 /**/ 1408 $.extend(itour_data, { 1409 tourId:hData.v.tourid, 1410 stepValue:(parseFloat(itour_data.stepValue) + 1) 1411 }); 1412 1413 /**/ 1414 /*Save new data in localStorage*/ 1415 /**/ 1416 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1417 1418 /**/ 1419 /*Redirect*/ 1420 /**/ 1421 location.href = targetLoc; 1422 }else{ 1423 brouserNotSupport() 1424 } 1425 }else{ 1426 hData.v.startIndex++; 1427 hData.v.event = 'next'; 1428 hStep(); 1429 } 1430 },hData.opt.steps[hData.v.startIndex].delayAfter); 1431 }); 1432 1433 /**/ 1434 /*This function call the prev step*/ 1435 /**/ 1436 $(document).on('click','.hPrev',function(){ 1437 1438 /**/ 1439 /*Set present and necessary location path*/ 1440 /**/ 1441 var nowLoc = location.href; 1442 var targetLoc = nowLoc; 1443 var nextIndex = (parseFloat(hData.v.startIndex) - 1); 1444 1445 /**/ 1446 /*Check presence of next step */ 1447 /**/ 1448 if(nextIndex >= 0){ 1449 targetLoc = hData.opt.steps[nextIndex].loc; 1450 } 1451 1452 hData.v.targetEl.off(hData.opt.steps[hData.v.startIndex].event+'.itour'); 1453 1454 if(hData.v.customTargetSelector){ 1455 $(hData.v.customTargetSelector).off(hData.v.customEvent+'.itour'); 1456 } 1457 1458 if(hData.opt.steps[hData.v.startIndex].event == 'prev'){ 1459 hData.opt.steps[hData.v.startIndex].ready = true; 1460 $('[data-hindex="'+hData.v.startIndex+'"]').addClass('hSuccess'); 1461 } 1462 afterFunc(); 1463 setTimeout(function(){ 1464 1465 /**/ 1466 /*compare the paths*/ 1467 /**/
1468 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1469 /*If the paths are not the same:*/ 1470 /**/ 1471 /*create new options object for transfer to another page*/ 1472 /**/ 1473 if (typeof(Storage) !== "undefined"){ 1474 var itour_go = { 1475 opt:toStringObj(hData.opt) 1476 }; 1477 1478 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1479 1480 /**/ 1481 /*Save step numbers in localStorage*/ 1482 /*Get itour_data object from localStorage*/ 1483 /**/ 1484 var itour_data = {}; 1485 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1486 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1487 } 1488 1489 /**/ 1490 /*Merge the getting object with the new values*/ 1491 /**/ 1492 $.extend(itour_data, { 1493 tourId:hData.v.tourid, 1494 stepValue:(parseFloat(itour_data.stepValue) - 1) 1495 }); 1496 1497 /**/ 1498 /*Save new data in localStorage*/ 1499 /**/ 1500 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1501 1502 /**/ 1503 /*Redirect*/ 1504 /**/ 1505 location.href = targetLoc; 1506 }else{ 1507 brouserNotSupport() 1508 } 1509 }else{ 1510 hData.v.startIndex--; 1511 hData.v.event = 'prev'; 1512 hStep(); 1513 } 1514 },hData.opt.steps[hData.v.startIndex].delayAfter); 1515 }); 1516 1517 /**/ 1518 /*This function off tour*/ 1519 /**/ 1520 $(document).on('click','.hClose',function(){ 1521 hWrap.itour('destroy'); 1522 if (hData.opt.end !== undefined) {hData.opt.end();} 1523 }); 1524 1525 /**/ 1526 /*This function pass custom events*/ 1527 /**/ 1528 if(hData.opt.tourMapJump){ 1529 $(document).on('click','[data-hindex]',function(){ 1530 var stepLink = $(this); 1531 var stepLinkIndex = stepLink.attr('data-hindex'); 1532 var nowLoc = location.href; 1533 var targetLoc = hData.opt.steps[stepLinkIndex].loc; 1534 1535 1536 1537 if(parseFloat(hData.v.startIndex) !== parseFloat(stepLinkIndex)){ 1538 1539 if(nowLoc.search(escapeRe(targetLoc)) === -1 && targetLoc.search(escapeRe(nowLoc)) === -1 && nowLoc !== targetLoc){ 1540 1541 var itour_go = { 1542 opt:toStringObj(hData.opt) 1543 }; 1544 localStorage.setItem('itour_go',JSON.stringify(itour_go)); 1545 1546 /**/ 1547 /*Save step numbers in localStorage*/ 1548 /**/ 1549 var itour_data = {}; 1550 if(localStorage.getItem('itour_data-'+hData.opt.tourID)){ 1551 itour_data = $.parseJSON(localStorage.getItem('itour_data-'+hData.opt.tourID)); 1552 } 1553 $.extend(itour_data, { 1554 tourId:hData.v.tourid, 1555 stepValue:(parseFloat(stepLinkIndex) + 1) 1556 }); 1557 localStorage.setItem('itour_data-'+hData.opt.tourID,JSON.stringify(itour_data)); 1558 1559 /**/ 1560 /*Redirect*/ 1561 /**/ 1562 location.href = targetLoc; 1563 }else{ 1564 1565 hData.v.targetEl.off(hData.opt.steps[hData.v.startIndex].event+'.itour'); 1566 1567 if(hData.v.customTargetSelector){ 1568 $(hData.v.customTargetSelector).off(hData.v.customEvent+'.itour'); 1569 } 1570 afterFunc(); 1571 setTimeout(function(){ 1572 hData.v.startIndex = stepLinkIndex; 1573 hStep(); 1574 },hData.opt.steps[hData.v.startIndex].delayAfter); 1575 } 1576 } 1577 }); 1578 }else{ 1579 $('html').addClass('hMapJump-disable'); 1580 } 1581 1582 /**/ 1583 /*This function off tour*/ 1584 /**/ 1585 if(hData.opt.overlayClickable){ 1586 $(document).on(clickEvent,'.hOverlay',function(e){ 1587 if (touchMoving) return false; 1588 if(!$(e.target).is('.hContPos') && !$('.hContPos').find($(e.target)).length && hData.v.overlayEnable){ 1589 hWrap.itour('destroy'); 1590 if (hData.opt.end !== undefined) {hData.opt.end();} 1591 } 1592 }); 1593 } 1594 1595 /**/ 1596 /*Tour map toggle*/ 1597 /**/ 1598 hData.v.hNavBtn.on('click',function(){ 1599 if($('html').is('.hNavOpen')){ 1600 $('html').removeClass('hNavOpen'); 1601 hData.opt.tourMapVisible = false; 1602 }else{ 1603 $('html').addClass('hNavOpen'); 1604 hData.opt.tourMapVisible = true; 1605 } 1606 });
1607 hData.v.hHide.on('click',function(){ 1608 if($('html').is('.hNavOpen')){ 1609 $('html').removeClass('hNavOpen'); 1610 }else{ 1611 $('html').addClass('hNavOpen'); 1612 } 1613 }); 1614 1615 /**/ 1616 /*If steps is more then 0*/ 1617 /**/ 1618 hData.ini = true; 1619 if(hData.opt.steps.length == 0){ 1620 console.log('Mess: All target elements is absent.'); 1621 console.log('Council: Check the "Steps" parameter.') 1622 hWrap.itour('destroy'); 1623 }else{ 1624 1625 /**/ 1626 /*Creating intro message*/ 1627 /**/ 1628 if (hData.opt.introShow){ 1629 if(hWrap.data().itour_go){ 1630 storageDetect(); 1631 }else{ 1632 $('html').addClass('hIntroShow'); 1633 hData.v.introDialog = $('<div>') 1634 .addClass('introDialog hContBlock') 1635 .html('<div class="hContImage"></div><div class="hContHeader">'+hData.opt.lang.introTitle+'</div><div class="hContBody">'+hData.opt.lang.introContent+'</div><div class="hContFooter" style="text-align:right"><span class="hBtn hAbortBtn hClose">'+hData.opt.lang.introDialogBtnCancel+'</span><span class="hBtn hStartBtn">'+hData.opt.lang.introDialogBtnStart+'</span></div>') 1636 .appendTo('body'); 1637 if(hData.opt.introCover){ 1638 $('<img>') 1639 .attr('src',hData.opt.introCover) 1640 .addClass('hTourCover') 1641 .on('load',function(){ 1642 $(this).appendTo(hData.v.introDialog.find('.hContImage')); 1643 var coverHeight = $(this).height().toFixed(); 1644 if(coverHeight & 1){ 1645 coverHeight = (parseFloat(coverHeight)+1); 1646 } 1647 $(this).height(coverHeight); 1648 }); 1649 } 1650 if(hData.opt.textDirection == "rtl"){ 1651 hData.v.introDialog.addClass('rtl'); 1652 } 1653 hData.v.startOverlay = $('<div>').addClass('startOverlay').appendTo('body'); 1654 setTimeout(function(){ 1655 hData.v.introDialog.add(hData.v.startOverlay).addClass('hShow'); 1656 },100); 1657 } 1658 }else{ 1659 storageDetect(); 1660 } 1661 } 1662 1663 /**/ 1664 /*adding create indicator*/ 1665 /**/ 1666 hWrap.addClass('hCreate'); 1667 if (hData.opt.create !== undefined) {hData.opt.create();} 1668 1669 1670 }else{ 1671 console.log('Warning! \nDetected re-initialization of plugin. Check the code calling the plugin!'); 1672 } 1673 }); 1674 }, 1675 1676 /**/ 1677 /*Destroe Method*/ 1678 /**/ 1679 destroy: function (arg) { 1680 return this.each(function (e) { 1681 var hWrap = $('body'); 1682 var hData = hWrap.data().itour; 1683 if(hData){ 1684 if(hData.ini){ 1685 1686 localStorage.removeItem('itour_go'); 1687 hWrap.data().itour_go = false; 1688 1689 $('.itour-highlight').removeClass('itour-highlight'); 1690 $('html').removeAttr('data-step'); 1691 /**/ 1692 /*Return style*/ 1693 /**/ 1694 hWrap.removeClass('hWrap hCreate'); 1695 if(hData.v.startStyle){ 1696 hWrap.attr({style:hData.v.startStyle}); 1697 }else{ 1698 hWrap.removeAttr('style'); 1699 } 1700 $('html').removeClass('hNavOpen'); 1701 $('html').removeClass('hIntroShow'); 1702 $('html').removeClass('hNav-disable'); 1703 $('html').removeClass('hMapJump-disable'); 1704 $('html').removeClass('vh-odd'); 1705 $('html').removeClass('vw-odd'); 1706 if(hData.opt.CSSClass){ 1707 $('html').removeClass(hData.opt.CSSClass); 1708 } 1709 1710 $('[data-uid]').removeAttr('data-uid'); 1711 1712 1713 /**/ 1714 /*Delete plugin elements*/ 1715 /**/ 1716 $(hData.v.hContPos).remove(); 1717 $(hData.v.overlays).remove(); 1718 $(hData.v.hOverlayDisable).remove(); 1719 $(hData.v.hNavWrap).remove(); 1720 $(hData.v.hNavPos).remove(); 1721 $(hData.v.introDialog).remove(); 1722 $(hData.v.startOverlay).remove(); 1723 1724 /**/ 1725 /*Events off*/ 1726 /**/ 1727 $(document).off('click','.startOverBtn'); 1728 $(document).off('click','.continueBtn'); 1729 $(document).off('click','.hNext'); 1730 $(document).off('click','.hPrev'); 1731 $(document).off('click','.hStartBtn'); 1732 if(hData.opt.steps[hData.v.startIndex]){ 1733 if(hData.v.targetEl){ 1734 hData.v.targetEl.off(hData.opt.steps[hData.v.startIndex].event+'.itour'); 1735 } 1736 } 1737
1738 if(hData.v.customTargetSelector){ 1739 $(hData.v.customTargetSelector).off(hData.v.customEvent+'.itour'); 1740 } 1741 1742 $(document).off('click','.hClose'); 1743 hData.v.hHide.off('click'); 1744 $(document).off('click','.hOverlay'); 1745 $(document).off('click','[data-hindex]'); 1746 $(document).off('keyup.itour'); 1747 hData.v.hNavBtn.off('click'); 1748 1749 /**/ 1750 /*Delete data*/ 1751 /**/ 1752 hData.ini = false; 1753 if(!arg){ 1754 delete hWrap.data().itour; 1755 } 1756 }else{ 1757 console.log('Warning! \nDetected call of method Destroy for an element that is not associated with plugin. Check the code!'); 1758 } 1759 } 1760 }); 1761 } 1762 }; 1763 $.fn.itour = function (method) { 1764 if (methods[method]) { 1765 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); 1766 } else if (typeof method === 'object' || !method) { 1767 return methods.init.apply(this, arguments); 1768 } else { 1769 $.error("Method " + method + " in jQuery.itour doesn't exist"); 1770 } 1771 }; 1772 1773 $(window).on('load',function(){ 1774 1775 if (typeof(Storage) !== 'undefined'){ 1776 1777 if(localStorage){ 1778 1779 if(localStorage.getItem('itour_go')){ 1780 1781 1782 var typeDetect = function(per){ 1783 1784 1785 1786 if(typeof per == 'function'){ 1787 //function 1788 return typeof per; 1789 } 1790 if(typeof per == 'boolean'){ 1791 //boolean 1792 return typeof per; 1793 } 1794 if(typeof per == 'string'){ 1795 //string 1796 return typeof per; 1797 } 1798 if(typeof per == 'number'){ 1799 //number 1800 return typeof per; 1801 } 1802 1803 if(typeof per == 'object'){ 1804 if(Array.isArray(per)){ 1805 //Array 1806 return 'array' 1807 }else{ 1808 //Object 1809 return 'object' 1810 } 1811 } 1812 }; 1813 var toFuncObjIndex = 0; 1814 var stringToFunc = function(obj){ 1815 1816 var newIndex = toFuncObjIndex++; 1817 var objEnter = obj; 1818 var tempObj = {}; 1819 tempObj[newIndex] = {}; 1820 1821 for (var i in objEnter) { 1822 var key1 = i; 1823 var val = objEnter[key1]; 1824 //array 1825 1826 if(typeDetect(val) == 'array'){ 1827 var valEach = val; 1828 for(var f = 0; f < valEach.length; f++){ 1829 if(typeDetect(valEach[f]) == 'object'){ 1830 var objMass = valEach[f]; 1831 var val3 = stringToFunc(objMass); 1832 valEach[f] = val3; 1833 } 1834 } 1835 tempObj[newIndex][key1] = valEach; 1836 } 1837 //object 1838 if(typeDetect(val) == 'object'){ 1839 var val2 = stringToFunc(val); 1840 tempObj[newIndex][key1] = val2; 1841 } 1842 //string 1843 if(typeDetect(val) == 'string'){ 1844 1845 var words = 'function'; 1846 var re = new RegExp('(^|\\s)' + words + '(?=\\s|$)', 'g'); 1847 1848 //function 1849 //if(re.test(val)){ 1850 if(val.search(/function\(/gi) != -1 || val.search(/function \(/gi) != -1){ 1851 eval("tempObj[newIndex][key1] = "+objEnter[key1]+";"); 1852 }else{ 1853 tempObj[newIndex][key1] = val; 1854 } 1855 } 1856 //number, boolean 1857 if(typeDetect(val) == 'number' || typeDetect(val) == 'boolean'){ 1858 tempObj[newIndex][key1] = val; 1859 } 1860 } 1861 return tempObj[newIndex]; 1862 }; 1863 1864 $('body').data().itour_go = true; 1865 var itour_go = $.parseJSON(localStorage.getItem('itour_go')); 1866 var opt = itour_go.opt; 1867 var restoreObject = stringToFunc(opt); 1868 $('body').itour(restoreObject); 1869 } 1870 } 1871 } 1872 }); 1873 1874})(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.