2013-10-23 06:46:07 +02:00
/ *
* jQuery Foundation Joyride Plugin 2.1
* http : //foundation.zurb.com
* Copyright 2013 , ZURB
* Free to use under the MIT license .
* http : //www.opensource.org/licenses/mit-license.php
* /
/*jslint unparam: true, browser: true, indent: 2 */
; ( function ( $ , window , undefined ) {
'use strict' ;
var defaults = {
'version' : '2.1' ,
'tipLocation' : 'bottom' , // 'top' or 'bottom' in relation to parent
'nubPosition' : 'auto' , // override on a per tooltip bases
'scroll' : true , // whether to scroll to tips
'scrollSpeed' : 300 , // Page scrolling speed in milliseconds
'timer' : 0 , // 0 = no timer , all other numbers = timer in milliseconds
'autoStart' : false , // true or false - false tour starts when restart called
'startTimerOnClick' : true , // true or false - true requires clicking the first button start the timer
'startOffset' : 0 , // the index of the tooltip you want to start on (index of the li)
'nextButton' : true , // true or false to control whether a next button is used
'tipAnimation' : 'fade' , // 'pop' or 'fade' in each tip
'pauseAfter' : [ ] , // array of indexes where to pause the tour after
'tipAnimationFadeSpeed' : 300 , // when tipAnimation = 'fade' this is speed in milliseconds for the transition
'cookieMonster' : false , // true or false to control whether cookies are used
'cookieName' : 'joyride' , // Name the cookie you'll use
'cookieDomain' : false , // Will this cookie be attached to a domain, ie. '.notableapp.com'
'cookiePath' : false , // Set to '/' if you want the cookie for the whole website
'localStorage' : false , // true or false to control whether localstorage is used
'localStorageKey' : 'joyride' , // Keyname in localstorage
'tipContainer' : 'body' , // Where will the tip be attached
'modal' : false , // Whether to cover page with modal during the tour
'expose' : false , // Whether to expose the elements at each step in the tour (requires modal:true)
'postExposeCallback' : $ . noop , // A method to call after an element has been exposed
'preRideCallback' : $ . noop , // A method to call before the tour starts (passed index, tip, and cloned exposed element)
'postRideCallback' : $ . noop , // A method to call once the tour closes (canceled or complete)
'preStepCallback' : $ . noop , // A method to call before each step
'postStepCallback' : $ . noop , // A method to call after each step
'template' : { // HTML segments for tip layout
'link' : '<a href="#close" class="joyride-close-tip">X</a>' ,
'timer' : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>' ,
'tip' : '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>' ,
'wrapper' : '<div class="joyride-content-wrapper" role="dialog"></div>' ,
'button' : '<a href="#" class="joyride-next-tip"></a>' ,
'modal' : '<div class="joyride-modal-bg"></div>' ,
'expose' : '<div class="joyride-expose-wrapper"></div>' ,
'exposeCover' : '<div class="joyride-expose-cover"></div>'
}
} ,
Modernizr = Modernizr || false ,
settings = { } ,
methods = {
init : function ( opts ) {
return this . each ( function ( ) {
if ( $ . isEmptyObject ( settings ) ) {
settings = $ . extend ( true , defaults , opts ) ;
// non configurable settings
settings . document = window . document ;
settings . $document = $ ( settings . document ) ;
settings . $window = $ ( window ) ;
settings . $content _el = $ ( this ) ;
settings . $body = $ ( settings . tipContainer ) ;
settings . body _offset = $ ( settings . tipContainer ) . position ( ) ;
settings . $tip _content = $ ( '> li' , settings . $content _el ) ;
settings . paused = false ;
settings . attempts = 0 ;
settings . tipLocationPatterns = {
top : [ 'bottom' ] ,
bottom : [ ] , // bottom should not need to be repositioned
left : [ 'right' , 'top' , 'bottom' ] ,
right : [ 'left' , 'top' , 'bottom' ]
} ;
// are we using jQuery 1.7+
methods . jquery _check ( ) ;
// can we create cookies?
if ( ! $ . isFunction ( $ . cookie ) ) {
settings . cookieMonster = false ;
}
// generate the tips and insert into dom.
if ( ( ! settings . cookieMonster || ! $ . cookie ( settings . cookieName ) ) &&
( ! settings . localStorage || ! methods . support _localstorage ( ) || ! localStorage . getItem ( settings . localStorageKey ) ) ) {
settings . $tip _content . each ( function ( index ) {
methods . create ( { $li : $ ( this ) , index : index } ) ;
} ) ;
// show first tip
if ( settings . autoStart )
{
if ( ! settings . startTimerOnClick && settings . timer > 0 ) {
methods . show ( 'init' ) ;
methods . startTimer ( ) ;
} else {
methods . show ( 'init' ) ;
}
}
}
settings . $document . on ( 'click.joyride' , '.joyride-next-tip, .joyride-modal-bg' , function ( e ) {
e . preventDefault ( ) ;
if ( settings . $li . next ( ) . length < 1 ) {
methods . end ( ) ;
} else if ( settings . timer > 0 ) {
clearTimeout ( settings . automate ) ;
methods . hide ( ) ;
methods . show ( ) ;
methods . startTimer ( ) ;
} else {
methods . hide ( ) ;
methods . show ( ) ;
}
} ) ;
settings . $document . on ( 'click.joyride' , '.joyride-close-tip' , function ( e ) {
e . preventDefault ( ) ;
methods . end ( ) ;
} ) ;
settings . $window . bind ( 'resize.joyride' , function ( e ) {
if ( settings . $li ) {
if ( settings . exposed && settings . exposed . length > 0 ) {
var $els = $ ( settings . exposed ) ;
$els . each ( function ( ) {
var $this = $ ( this ) ;
methods . un _expose ( $this ) ;
methods . expose ( $this ) ;
} ) ;
}
if ( methods . is _phone ( ) ) {
methods . pos _phone ( ) ;
} else {
methods . pos _default ( ) ;
}
}
} ) ;
} else {
methods . restart ( ) ;
}
} ) ;
} ,
// call this method when you want to resume the tour
resume : function ( ) {
methods . set _li ( ) ;
methods . show ( ) ;
} ,
nextTip : function ( ) {
if ( settings . $li . next ( ) . length < 1 ) {
methods . end ( ) ;
} else if ( settings . timer > 0 ) {
clearTimeout ( settings . automate ) ;
methods . hide ( ) ;
methods . show ( ) ;
methods . startTimer ( ) ;
} else {
methods . hide ( ) ;
methods . show ( ) ;
}
} ,
tip _template : function ( opts ) {
var $blank , content , $wrapper ;
opts . tip _class = opts . tip _class || '' ;
$blank = $ ( settings . template . tip ) . addClass ( opts . tip _class ) ;
content = $ . trim ( $ ( opts . li ) . html ( ) ) +
methods . button _text ( opts . button _text ) +
settings . template . link +
methods . timer _instance ( opts . index ) ;
$wrapper = $ ( settings . template . wrapper ) ;
if ( opts . li . attr ( 'data-aria-labelledby' ) ) {
$wrapper . attr ( 'aria-labelledby' , opts . li . attr ( 'data-aria-labelledby' ) )
}
if ( opts . li . attr ( 'data-aria-describedby' ) ) {
$wrapper . attr ( 'aria-describedby' , opts . li . attr ( 'data-aria-describedby' ) )
}
$blank . append ( $wrapper ) ;
$blank . first ( ) . attr ( 'data-index' , opts . index ) ;
$ ( '.joyride-content-wrapper' , $blank ) . append ( content ) ;
return $blank [ 0 ] ;
} ,
timer _instance : function ( index ) {
var txt ;
if ( ( index === 0 && settings . startTimerOnClick && settings . timer > 0 ) || settings . timer === 0 ) {
txt = '' ;
} else {
txt = methods . outerHTML ( $ ( settings . template . timer ) [ 0 ] ) ;
}
return txt ;
} ,
button _text : function ( txt ) {
if ( settings . nextButton ) {
txt = $ . trim ( txt ) || 'Next' ;
txt = methods . outerHTML ( $ ( settings . template . button ) . append ( txt ) [ 0 ] ) ;
} else {
txt = '' ;
}
return txt ;
} ,
create : function ( opts ) {
// backwards compatibility with data-text attribute
var buttonText = opts . $li . attr ( 'data-button' ) || opts . $li . attr ( 'data-text' ) ,
tipClass = opts . $li . attr ( 'class' ) ,
$tip _content = $ ( methods . tip _template ( {
tip _class : tipClass ,
index : opts . index ,
button _text : buttonText ,
li : opts . $li
} ) ) ;
$ ( settings . tipContainer ) . append ( $tip _content ) ;
} ,
show : function ( init ) {
var opts = { } , ii , opts _arr = [ ] , opts _len = 0 , p ,
$timer = null ;
// are we paused?
if ( settings . $li === undefined || ( $ . inArray ( settings . $li . index ( ) , settings . pauseAfter ) === - 1 ) ) {
// don't go to the next li if the tour was paused
if ( settings . paused ) {
settings . paused = false ;
} else {
methods . set _li ( init ) ;
}
settings . attempts = 0 ;
if ( settings . $li . length && settings . $target . length > 0 ) {
if ( init ) { //run when we first start
settings . preRideCallback ( settings . $li . index ( ) , settings . $next _tip ) ;
if ( settings . modal ) {
methods . show _modal ( ) ;
}
}
settings . preStepCallback ( settings . $li . index ( ) , settings . $next _tip ) ;
// parse options
opts _arr = ( settings . $li . data ( 'options' ) || ':' ) . split ( ';' ) ;
opts _len = opts _arr . length ;
for ( ii = opts _len - 1 ; ii >= 0 ; ii -- ) {
p = opts _arr [ ii ] . split ( ':' ) ;
if ( p . length === 2 ) {
opts [ $ . trim ( p [ 0 ] ) ] = $ . trim ( p [ 1 ] ) ;
}
}
settings . tipSettings = $ . extend ( { } , settings , opts ) ;
settings . tipSettings . tipLocationPattern = settings . tipLocationPatterns [ settings . tipSettings . tipLocation ] ;
if ( settings . modal && settings . expose ) {
methods . expose ( ) ;
}
// scroll if not modal
if ( ! /body/i . test ( settings . $target . selector ) && settings . scroll ) {
methods . scroll _to ( ) ;
}
if ( methods . is _phone ( ) ) {
methods . pos _phone ( true ) ;
} else {
methods . pos _default ( true ) ;
}
$timer = $ ( '.joyride-timer-indicator' , settings . $next _tip ) ;
if ( /pop/i . test ( settings . tipAnimation ) ) {
$timer . outerWidth ( 0 ) ;
if ( settings . timer > 0 ) {
settings . $next _tip . show ( ) ;
$timer . animate ( {
width : $ ( '.joyride-timer-indicator-wrap' , settings . $next _tip ) . outerWidth ( )
} , settings . timer ) ;
} else {
settings . $next _tip . show ( ) ;
}
} else if ( /fade/i . test ( settings . tipAnimation ) ) {
$timer . outerWidth ( 0 ) ;
if ( settings . timer > 0 ) {
settings . $next _tip . fadeIn ( settings . tipAnimationFadeSpeed ) ;
settings . $next _tip . show ( ) ;
$timer . animate ( {
width : $ ( '.joyride-timer-indicator-wrap' , settings . $next _tip ) . outerWidth ( )
} , settings . timer ) ;
} else {
settings . $next _tip . fadeIn ( settings . tipAnimationFadeSpeed ) ;
}
}
settings . $current _tip = settings . $next _tip ;
// Focus next button for keyboard users.
$ ( '.joyride-next-tip' , settings . $current _tip ) . focus ( ) ;
methods . tabbable ( settings . $current _tip ) ;
// skip non-existent targets
} else if ( settings . $li && settings . $target . length < 1 ) {
methods . show ( ) ;
} else {
methods . end ( ) ;
}
} else {
settings . paused = true ;
}
} ,
// detect phones with media queries if supported.
is _phone : function ( ) {
if ( Modernizr ) {
return Modernizr . mq ( 'only screen and (max-width: 767px)' ) ;
}
return ( settings . $window . width ( ) < 767 ) ? true : false ;
} ,
support _localstorage : function ( ) {
if ( Modernizr ) {
return Modernizr . localstorage ;
} else {
return ! ! window . localStorage ;
}
} ,
hide : function ( ) {
if ( settings . modal && settings . expose ) {
methods . un _expose ( ) ;
}
if ( ! settings . modal ) {
$ ( '.joyride-modal-bg' ) . hide ( ) ;
}
settings . $current _tip . hide ( ) ;
settings . postStepCallback ( settings . $li . index ( ) , settings . $current _tip ) ;
} ,
set _li : function ( init ) {
if ( init ) {
settings . $li = settings . $tip _content . eq ( settings . startOffset ) ;
methods . set _next _tip ( ) ;
settings . $current _tip = settings . $next _tip ;
} else {
settings . $li = settings . $li . next ( ) ;
methods . set _next _tip ( ) ;
}
methods . set _target ( ) ;
} ,
set _next _tip : function ( ) {
settings . $next _tip = $ ( '.joyride-tip-guide[data-index=' + settings . $li . index ( ) + ']' ) ;
} ,
set _target : function ( ) {
var cl = settings . $li . attr ( 'data-class' ) ,
id = settings . $li . attr ( 'data-id' ) ,
$sel = function ( ) {
if ( id ) {
return $ ( settings . document . getElementById ( id ) ) ;
} else if ( cl ) {
return $ ( '.' + cl ) . filter ( ":visible" ) . first ( ) ;
} else {
return $ ( 'body' ) ;
}
} ;
settings . $target = $sel ( ) ;
} ,
scroll _to : function ( ) {
var window _half , tipOffset ;
window _half = settings . $window . height ( ) / 2 ;
tipOffset = Math . ceil ( settings . $target . offset ( ) . top - window _half + settings . $next _tip . outerHeight ( ) ) ;
$ ( "html, body" ) . stop ( ) . animate ( {
scrollTop : tipOffset
} , settings . scrollSpeed ) ;
} ,
paused : function ( ) {
if ( ( $ . inArray ( ( settings . $li . index ( ) + 1 ) , settings . pauseAfter ) === - 1 ) ) {
return true ;
}
return false ;
} ,
destroy : function ( ) {
if ( ! $ . isEmptyObject ( settings ) ) {
settings . $document . off ( '.joyride' ) ;
}
$ ( window ) . off ( '.joyride' ) ;
$ ( '.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg' ) . off ( '.joyride' ) ;
$ ( '.joyride-tip-guide, .joyride-modal-bg' ) . remove ( ) ;
clearTimeout ( settings . automate ) ;
settings = { } ;
} ,
restart : function ( ) {
if ( ! settings . autoStart )
{
if ( ! settings . startTimerOnClick && settings . timer > 0 ) {
methods . show ( 'init' ) ;
methods . startTimer ( ) ;
} else {
methods . show ( 'init' ) ;
}
settings . autoStart = true ;
}
else
{
methods . hide ( ) ;
settings . $li = undefined ;
methods . show ( 'init' ) ;
}
} ,
pos _default : function ( init ) {
var half _fold = Math . ceil ( settings . $window . height ( ) / 2 ) ,
tip _position = settings . $next _tip . offset ( ) ,
$nub = $ ( '.joyride-nub' , settings . $next _tip ) ,
nub _width = Math . ceil ( $nub . outerWidth ( ) / 2 ) ,
nub _height = Math . ceil ( $nub . outerHeight ( ) / 2 ) ,
toggle = init || false ;
// tip must not be "display: none" to calculate position
if ( toggle ) {
settings . $next _tip . css ( 'visibility' , 'hidden' ) ;
settings . $next _tip . show ( ) ;
}
if ( ! /body/i . test ( settings . $target . selector ) ) {
var
topAdjustment = settings . tipSettings . tipAdjustmentY ? parseInt ( settings . tipSettings . tipAdjustmentY ) : 0 ,
leftAdjustment = settings . tipSettings . tipAdjustmentX ? parseInt ( settings . tipSettings . tipAdjustmentX ) : 0 ;
if ( methods . bottom ( ) ) {
settings . $next _tip . css ( {
top : ( settings . $target . offset ( ) . top + nub _height + settings . $target . outerHeight ( ) + topAdjustment ) ,
left : settings . $target . offset ( ) . left - settings . $next _tip . outerWidth ( ) + leftAdjustment } ) ;
if ( /right/i . test ( settings . tipSettings . nubPosition ) ) {
settings . $next _tip . css ( 'left' , settings . $target . offset ( ) . left + settings . $target . outerWidth ( ) ) ;
}
methods . nub _position ( $nub , settings . tipSettings . nubPosition , 'top' ) ;
} else if ( methods . top ( ) ) {
settings . $next _tip . css ( {
top : ( settings . $target . offset ( ) . top - settings . $next _tip . outerHeight ( ) - nub _height - topAdjustment ) ,
left : settings . $target . offset ( ) . left - ( settings . $next _tip . outerWidth ( ) * . 8 ) + leftAdjustment } ) ;
methods . nub _position ( $nub , settings . tipSettings . nubPosition , 'bottom' ) ;
} else if ( methods . right ( ) ) {
settings . $next _tip . css ( {
top : settings . $target . offset ( ) . top + topAdjustment ,
left : ( settings . $target . outerWidth ( ) + settings . $target . offset ( ) . left + nub _width ) + leftAdjustment } ) ;
methods . nub _position ( $nub , settings . tipSettings . nubPosition , 'left' ) ;
} else if ( methods . left ( ) ) {
settings . $next _tip . css ( {
top : settings . $target . offset ( ) . top + topAdjustment ,
left : ( settings . $target . offset ( ) . left - settings . $next _tip . outerWidth ( ) - nub _width ) - leftAdjustment } ) ;
methods . nub _position ( $nub , settings . tipSettings . nubPosition , 'right' ) ;
}
if ( ! methods . visible ( methods . corners ( settings . $next _tip ) ) && settings . attempts < settings . tipSettings . tipLocationPattern . length ) {
$nub . removeClass ( 'bottom' )
. removeClass ( 'top' )
. removeClass ( 'right' )
. removeClass ( 'left' ) ;
settings . tipSettings . tipLocation = settings . tipSettings . tipLocationPattern [ settings . attempts ] ;
settings . attempts ++ ;
methods . pos _default ( true ) ;
}
} else if ( settings . $li . length ) {
methods . pos _modal ( $nub ) ;
}
if ( toggle ) {
settings . $next _tip . hide ( ) ;
settings . $next _tip . css ( 'visibility' , 'visible' ) ;
}
} ,
pos _phone : function ( init ) {
var tip _height = settings . $next _tip . outerHeight ( ) ,
tip _offset = settings . $next _tip . offset ( ) ,
target _height = settings . $target . outerHeight ( ) ,
$nub = $ ( '.joyride-nub' , settings . $next _tip ) ,
nub _height = Math . ceil ( $nub . outerHeight ( ) / 2 ) ,
toggle = init || false ;
$nub . removeClass ( 'bottom' )
. removeClass ( 'top' )
. removeClass ( 'right' )
. removeClass ( 'left' ) ;
if ( toggle ) {
settings . $next _tip . css ( 'visibility' , 'hidden' ) ;
settings . $next _tip . show ( ) ;
}
if ( ! /body/i . test ( settings . $target . selector ) ) {
if ( methods . top ( ) ) {
settings . $next _tip . offset ( { top : settings . $target . offset ( ) . top - tip _height - nub _height } ) ;
$nub . addClass ( 'bottom' ) ;
} else {
settings . $next _tip . offset ( { top : settings . $target . offset ( ) . top + target _height + nub _height } ) ;
$nub . addClass ( 'top' ) ;
}
} else if ( settings . $li . length ) {
methods . pos _modal ( $nub ) ;
}
if ( toggle ) {
settings . $next _tip . hide ( ) ;
settings . $next _tip . css ( 'visibility' , 'visible' ) ;
}
} ,
pos _modal : function ( $nub ) {
methods . center ( ) ;
$nub . hide ( ) ;
methods . show _modal ( ) ;
} ,
show _modal : function ( ) {
if ( $ ( '.joyride-modal-bg' ) . length < 1 ) {
$ ( 'body' ) . append ( settings . template . modal ) . show ( ) ;
}
if ( /pop/i . test ( settings . tipAnimation ) ) {
$ ( '.joyride-modal-bg' ) . show ( ) ;
} else {
$ ( '.joyride-modal-bg' ) . fadeIn ( settings . tipAnimationFadeSpeed ) ;
}
} ,
expose : function ( ) {
var expose ,
exposeCover ,
el ,
origCSS ,
randId = 'expose-' + Math . floor ( Math . random ( ) * 10000 ) ;
if ( arguments . length > 0 && arguments [ 0 ] instanceof $ ) {
el = arguments [ 0 ] ;
} else if ( settings . $target && ! /body/i . test ( settings . $target . selector ) ) {
el = settings . $target ;
} else {
return false ;
}
if ( el . length < 1 ) {
if ( window . console ) {
console . error ( 'element not valid' , el ) ;
}
return false ;
}
expose = $ ( settings . template . expose ) ;
settings . $body . append ( expose ) ;
// console.log("JOYRIDE >> EXPOSE INFO >> el[0].clientWidth: " + el[0].clientWidth + ", el: " , el , ", el[0]: " , el[0] , ", el.offset: " , el.offset() , ", el.clientWidth: " + el.clientWidth + ", el.outerWidth: " + el.outerWidth(true))
2013-10-23 18:45:19 +02:00
// console.log("JOYRIDE >> EXPOSE INFO >> el.css('margin'): " + el.css('margin'));
// console.log("JOYRIDE >> EXPOSE INFO >> el.css('margin-left'): " + el.css('margin-left'));
2013-10-23 06:46:07 +02:00
expose . css ( {
2013-10-23 18:45:19 +02:00
// margin: el.css('margin'),
top : el . offset ( ) . top - 2 , // CAVEMAN PADDING!
left : el . offset ( ) . left - 2 , // CAVEMAN PADDING!
width : el [ 0 ] . clientWidth + 4 , // CAVEMAN PADDING!
height : el [ 0 ] . clientHeight + 4 // CAVEMAN PADDING!
2013-10-23 06:46:07 +02:00
// width: el.outerWidth(true),
// height: el.outerHeight(true)
} ) ;
exposeCover = $ ( settings . template . exposeCover ) ;
origCSS = {
zIndex : el . css ( 'z-index' ) ,
position : el . css ( 'position' )
} ;
el . css ( 'z-index' , expose . css ( 'z-index' ) * 1 + 1 ) ;
if ( origCSS . position == 'static' ) {
el . css ( 'position' , 'relative' ) ;
}
el . data ( 'expose-css' , origCSS ) ;
exposeCover . css ( {
2013-10-23 18:45:19 +02:00
top : el . offset ( ) . top - 2 , // CAVEMAN PADDING!
left : el . offset ( ) . left - 2 , // CAVEMAN PADDING!
width : el [ 0 ] . clientWidth + 4 , // CAVEMAN PADDING!
height : el [ 0 ] . clientHeight + 4 // CAVEMAN PADDING!
// top: el.offset().top,
// left: el.offset().left,
// width: el.outerWidth(true),
// height: el.outerHeight(true)
2013-10-23 06:46:07 +02:00
} ) ;
settings . $body . append ( exposeCover ) ;
expose . addClass ( randId ) ;
exposeCover . addClass ( randId ) ;
if ( settings . tipSettings [ 'exposeClass' ] ) {
expose . addClass ( settings . tipSettings [ 'exposeClass' ] ) ;
exposeCover . addClass ( settings . tipSettings [ 'exposeClass' ] ) ;
}
el . data ( 'expose' , randId ) ;
settings . postExposeCallback ( settings . $li . index ( ) , settings . $next _tip , el ) ;
methods . add _exposed ( el ) ;
} ,
un _expose : function ( ) {
var exposeId ,
el ,
expose ,
origCSS ,
clearAll = false ;
if ( arguments . length > 0 && arguments [ 0 ] instanceof $ ) {
el = arguments [ 0 ] ;
} else if ( settings . $target && ! /body/i . test ( settings . $target . selector ) ) {
el = settings . $target ;
} else {
return false ;
}
if ( el . length < 1 ) {
if ( window . console ) {
console . error ( 'element not valid' , el ) ;
}
return false ;
}
exposeId = el . data ( 'expose' ) ;
expose = $ ( '.' + exposeId ) ;
if ( arguments . length > 1 ) {
clearAll = arguments [ 1 ] ;
}
if ( clearAll === true ) {
$ ( '.joyride-expose-wrapper,.joyride-expose-cover' ) . remove ( ) ;
} else {
expose . remove ( ) ;
}
origCSS = el . data ( 'expose-css' ) ;
if ( origCSS . zIndex == 'auto' ) {
el . css ( 'z-index' , '' ) ;
} else {
el . css ( 'z-index' , origCSS . zIndex ) ;
}
if ( origCSS . position != el . css ( 'position' ) ) {
if ( origCSS . position == 'static' ) { // this is default, no need to set it.
el . css ( 'position' , '' ) ;
} else {
el . css ( 'position' , origCSS . position ) ;
}
}
el . removeData ( 'expose' ) ;
el . removeData ( 'expose-z-index' ) ;
methods . remove _exposed ( el ) ;
} ,
add _exposed : function ( el ) {
settings . exposed = settings . exposed || [ ] ;
if ( el instanceof $ ) {
settings . exposed . push ( el [ 0 ] ) ;
} else if ( typeof el == 'string' ) {
settings . exposed . push ( el ) ;
}
} ,
remove _exposed : function ( el ) {
var search ;
if ( el instanceof $ ) {
search = el [ 0 ]
} else if ( typeof el == 'string' ) {
search = el ;
}
settings . exposed = settings . exposed || [ ] ;
for ( var i = 0 ; i < settings . exposed . length ; i ++ ) {
if ( settings . exposed [ i ] == search ) {
settings . exposed . splice ( i , 1 ) ;
return ;
}
}
} ,
center : function ( ) {
var $w = settings . $window ;
settings . $next _tip . css ( {
top : ( ( ( $w . height ( ) - settings . $next _tip . outerHeight ( ) ) / 2 ) + $w . scrollTop ( ) ) ,
left : ( ( ( $w . width ( ) - settings . $next _tip . outerWidth ( ) ) / 2 ) + $w . scrollLeft ( ) )
} ) ;
return true ;
} ,
bottom : function ( ) {
return /bottom/i . test ( settings . tipSettings . tipLocation ) ;
} ,
top : function ( ) {
return /top/i . test ( settings . tipSettings . tipLocation ) ;
} ,
right : function ( ) {
return /right/i . test ( settings . tipSettings . tipLocation ) ;
} ,
left : function ( ) {
return /left/i . test ( settings . tipSettings . tipLocation ) ;
} ,
corners : function ( el ) {
var w = settings . $window ,
window _half = w . height ( ) / 2 ,
tipOffset = Math . ceil ( settings . $target . offset ( ) . top - window _half + settings . $next _tip . outerHeight ( ) ) , //using this to calculate since scroll may not have finished yet.
right = w . width ( ) + w . scrollLeft ( ) ,
offsetBottom = w . height ( ) + tipOffset ,
bottom = w . height ( ) + w . scrollTop ( ) ,
top = w . scrollTop ( ) ;
if ( tipOffset < top ) {
if ( tipOffset < 0 ) {
top = 0 ;
} else {
top = tipOffset ;
}
}
if ( offsetBottom > bottom ) {
bottom = offsetBottom ;
}
return [
el . offset ( ) . top < top ,
right < el . offset ( ) . left + el . outerWidth ( ) ,
bottom < el . offset ( ) . top + el . outerHeight ( ) ,
w . scrollLeft ( ) > el . offset ( ) . left
] ;
} ,
visible : function ( hidden _corners ) {
var i = hidden _corners . length ;
while ( i -- ) {
if ( hidden _corners [ i ] ) return false ;
}
return true ;
} ,
nub _position : function ( nub , pos , def ) {
if ( pos === 'auto' ) {
nub . addClass ( def ) ;
} else {
nub . addClass ( pos ) ;
}
} ,
startTimer : function ( ) {
if ( settings . $li . length ) {
settings . automate = setTimeout ( function ( ) {
methods . hide ( ) ;
methods . show ( ) ;
methods . startTimer ( ) ;
} , settings . timer ) ;
} else {
clearTimeout ( settings . automate ) ;
}
} ,
end : function ( ) {
if ( settings . cookieMonster ) {
$ . cookie ( settings . cookieName , 'ridden' , { expires : 365 , domain : settings . cookieDomain , path : settings . cookiePath } ) ;
}
if ( settings . localStorage ) {
localStorage . setItem ( settings . localStorageKey , true ) ;
}
if ( settings . timer > 0 ) {
clearTimeout ( settings . automate ) ;
}
if ( settings . modal && settings . expose ) {
methods . un _expose ( ) ;
}
if ( settings . $current _tip ) {
settings . $current _tip . hide ( ) ;
}
if ( settings . $li ) {
settings . postStepCallback ( settings . $li . index ( ) , settings . $current _tip ) ;
settings . postRideCallback ( settings . $li . index ( ) , settings . $current _tip ) ;
}
$ ( '.joyride-modal-bg' ) . hide ( ) ;
} ,
jquery _check : function ( ) {
// define on() and off() for older jQuery
if ( ! $ . isFunction ( $ . fn . on ) ) {
$ . fn . on = function ( types , sel , fn ) {
return this . delegate ( sel , types , fn ) ;
} ;
$ . fn . off = function ( types , sel , fn ) {
return this . undelegate ( sel , types , fn ) ;
} ;
return false ;
}
return true ;
} ,
outerHTML : function ( el ) {
// support FireFox < 11
return el . outerHTML || new XMLSerializer ( ) . serializeToString ( el ) ;
} ,
version : function ( ) {
return settings . version ;
} ,
tabbable : function ( el ) {
$ ( el ) . on ( 'keydown' , function ( event ) {
if ( ! event . isDefaultPrevented ( ) && event . keyCode &&
// Escape key.
event . keyCode === 27 ) {
event . preventDefault ( ) ;
methods . end ( ) ;
return ;
}
// Prevent tabbing out of tour items.
if ( event . keyCode !== 9 ) {
return ;
}
var tabbables = $ ( el ) . find ( ":tabbable" ) ,
first = tabbables . filter ( ":first" ) ,
last = tabbables . filter ( ":last" ) ;
if ( event . target === last [ 0 ] && ! event . shiftKey ) {
first . focus ( 1 ) ;
event . preventDefault ( ) ;
} else if ( event . target === first [ 0 ] && event . shiftKey ) {
last . focus ( 1 ) ;
event . preventDefault ( ) ;
}
} ) ;
}
} ;
$ . fn . joyride = function ( method ) {
if ( methods [ method ] ) {
return methods [ method ] . apply ( this , Array . prototype . slice . call ( arguments , 1 ) ) ;
} else if ( typeof method === 'object' || ! method ) {
return methods . init . apply ( this , arguments ) ;
} else {
$ . error ( 'Method ' + method + ' does not exist on jQuery.joyride' ) ;
}
} ;
} ( jQuery , this ) ) ;