new Trip(tripData, userOptions)
Trip
Parameters:
Name | Type | Description |
---|---|---|
tripData |
Array.<Object> | |
userOptions |
Object |
Members
-
<static> this.settings :Object
-
It is used to keep user and default settings.
Type:
- Object
Methods
-
<static> addAnimation(o)
-
Add animation on the trip block.
Parameters:
Name Type Description o
Object -
<static> bindKeyEvents()
-
Bind keydown events on document.
-
<static> bindResizeEvents()
-
When users resize its browser, we will rerun Trip and restart the timer. TODO: We have to debounce this function later to make performance better.
-
<static> canGoNext() → {Boolean}
-
Check whether we can go to next trip or not.
Returns:
whether we can go to next trip
- Type
- Boolean
-
<static> canGoPrev() → {Boolean}
-
Check whether we can go to previous trip or not.
Returns:
whether we can go to previous trip
- Type
- Boolean
-
<static> cleanup()
-
Clean up all stuffs when we are going to start / restart a trip, so we can make we won't mess up with old stuffs.
-
<static> create()
-
This is a method wrapper.
-
<static> createOverlay()
-
This method is used to create overlay. If the overlay is in the DOM tree, we will not create it again.
-
<static> createTripBlock()
-
This method is used to create a trip block at the first time when start. If the trip block already exists on the DOM tree, we will not create it again.
-
<static> decreaseIndex()
-
We can call this method to decrease tripIndex because we are not allowed to manipualte the value directly.
-
<static> doLastOperation()
-
This is the last operation when we successfully finish all trips in the end.
-
<static> getCurrentTripObject() → {Object}
-
This method is used to get current trip data.
Returns:
current trip data
- Type
- Object
-
<static> getReplacedTripContent(content) → {String}
-
This method is used to replace all passed content with
tripIndex
andtripTotal
information.Parameters:
Name Type Description content
String Returns:
replaced content
- Type
- String
-
<static> hasSpecialDirections(position) → {Boolean}
-
Check whether position is special or not
Parameters:
Name Type Description position
String position
Returns:
whether position is speical direction or not
- Type
- Boolean
-
<static> hideExpose()
-
Make exposed element back to normal state and hide overlay.
-
<static> hideProgressBar()
-
Hide the progress bar and stop animations.
-
<static> hideTripBlock()
-
Hide the trip block.
-
<static> increaseIndex()
-
We can call this method to increase tripIndex because we are not allowed to manipualte the value directly.
-
<static> init()
-
Initialize Trip.
-
<static> isFirst() → {Boolean}
-
Check whether current trip is the first one.
Returns:
whether current trip is the first one
- Type
- Boolean
-
<static> isLast() → {Boolean}
-
Check whether current trip is the last one.
Returns:
whether current trip is the last one
- Type
- Boolean
-
<static> isTripDataValid(o) → {Boolean}
-
Check whether tripData is valid
Parameters:
Name Type Description o
Object tripData
Returns:
whether tripData is valid
- Type
- Boolean
-
<static> keyEvent(e)
-
Bound keydown events. We will do specific actions when matched keys are pressed by user.
Parameters:
Name Type Description e
Event -
<static> next()
-
next API, which will jump to next the trip.
-
<static> pause()
-
pause API, which will pause the trip.
-
<static> pauseOrResume()
-
This is an wrapper for pause and resume API.
-
<static> pauseProgressBar()
-
Pause the progress bar.
-
<static> preInit()
-
This is used to preInit Trip.js. For current use, we will try to override this.console if there is no window.console like IE.
-
<static> prev()
-
prev API, which will jump to previous trip.
-
<static> removeAnimation()
-
Remove animation from the trip block.
-
<static> resume()
-
pause API, which will pause the trip.
-
<static> resumeProgressBar(remainingTime)
-
Resumse the progress bar.
Parameters:
Name Type Description remainingTime
Number -
<static> run()
-
This is the main function to control each trip. In this method, we will make sure every tripData is valid and use that to do following works like showing trip, setup timer and trigger registered callbacks at the right timing.
-
<static> setTripBlock(o)
-
Based on current trip data, we will use this method to set all stuffs we want like content, prev / next labels, close button, used animations.
Parameters:
Name Type Description o
Object -
<static> setTripBlockPosition(o, horizontalOrVertical)
-
This method is mainly used to help us position the trip block. As you can see, we will find out the $sel and its positions first then put our trip block at the right location.
Parameters:
Name Type Description o
Object horizontalOrVertical
String -
<static> showCurrentTrip(o)
-
Show current trip. In this method, we will control all stuffs about current trip including animation, timer, expose, progress bar.
Parameters:
Name Type Description o
Object -
<static> showExpose()
-
Expose element which has hasExpose property.
-
<static> showProgressBar(delay)
-
This is used to show progress bar UI. We will use jQuery to manipulate the animation.
Parameters:
Name Type Description delay
Number -
<static> showTripBlock(o)
-
After we positioned our trip block, we have to show it on the screen. If the trip block is not on the screen, we will scroll the $root element and then make sure it is definitely on the screen.
Parameters:
Name Type Description o
Object -
<static> start()
-
Start Trip.
-
<static> stop()
-
Stop API, which will stop the trip.
-
<static> unbindKeyEvents()
-
Remove keydown events from document.
-
<static> unbindResizeEvents()
-
Remove resize event from window.