/ * S l i d e r
=== === === === === === === === === === === === === === === === == * /
/ * * C o d e K i t I m p o r t
* http : //incident57.com/codekit/
=== === === === === === === === === === === === === === === === == * /
// @codekit-append "VMM.Slider.Slide.js";
if ( typeof VMM != 'undefined' && typeof VMM . Slider == 'undefined' ) {
VMM . Slider = function ( parent , parent _config ) {
var config ,
timer ,
$slider ,
$slider _mask ,
$slider _container ,
$slides _items ,
$dragslide ,
$explainer ,
events = { } ,
data = [ ] ,
slides = [ ] ,
slide _positions = [ ] ,
slides _content = "" ,
current _slide = 0 ,
current _width = 960 ,
touch = {
move : false ,
x : 10 ,
y : 0 ,
off : 0 ,
dampen : 48
} ,
content = "" ,
_active = false ,
layout = parent ,
navigation = {
nextBtn : "" ,
prevBtn : "" ,
nextDate : "" ,
prevDate : "" ,
nextTitle : "" ,
prevTitle : ""
} ;
// CONFIG
if ( typeof parent _config != 'undefined' ) {
config = parent _config ;
} else {
config = {
preload : 4 ,
current _slide : 0 ,
interval : 10 ,
something : 0 ,
width : 720 ,
height : 400 ,
ease : "easeInOutExpo" ,
duration : 1000 ,
timeline : false ,
spacing : 15 ,
slider : {
width : 720 ,
height : 400 ,
content : {
width : 720 ,
height : 400 ,
padding : 120 ,
padding _default : 120
} ,
nav : {
width : 100 ,
height : 200
}
}
} ;
}
/ * P U B L I C V A R S
=== === === === === === === === === === === === === === === === == * /
this . ver = "0.6" ;
config . slider . width = config . width ;
config . slider . height = config . height ;
/ * P U B L I C F U N C T I O N S
=== === === === === === === === === === === === === === === === == * /
this . init = function ( d ) {
slides = [ ] ;
slide _positions = [ ] ;
if ( typeof d != 'undefined' ) {
this . setData ( d ) ;
} else {
trace ( "WAITING ON DATA" ) ;
}
} ;
this . width = function ( w ) {
if ( w != null && w != "" ) {
config . slider . width = w ;
reSize ( ) ;
} else {
return config . slider . width ;
}
}
this . height = function ( h ) {
if ( h != null && h != "" ) {
config . slider . height = h ;
reSize ( ) ;
} else {
return config . slider . height ;
}
}
/ * G E T T E R S A N D S E T T E R S
=== === === === === === === === === === === === === === === === == * /
this . setData = function ( d ) {
if ( typeof d != 'undefined' ) {
data = d ;
build ( ) ;
} else {
trace ( "NO DATA" ) ;
}
} ;
this . getData = function ( ) {
return data ;
} ;
this . setConfig = function ( d ) {
if ( typeof d != 'undefined' ) {
config = d ;
} else {
trace ( "NO CONFIG DATA" ) ;
}
}
this . getConfig = function ( ) {
return config ;
} ;
this . setSize = function ( w , h ) {
if ( w != null ) { config . slider . width = w } ;
if ( h != null ) { config . slider . height = h } ;
if ( _active ) {
reSize ( ) ;
}
}
this . active = function ( ) {
return _active ;
} ;
this . getCurrentNumber = function ( ) {
return current _slide ;
} ;
this . setSlide = function ( n ) {
goToSlide ( n ) ;
} ;
/ * O N E V E N T
=== === === === === === === === === === === === === === === === == * /
function onConfigSet ( ) {
trace ( "onConfigSet" ) ;
} ;
function reSize ( go _to _slide , from _start ) {
var _go _to _slide = true ,
_from _start = false ;
if ( go _to _slide != null ) { _go _to _slide = go _to _slide } ;
if ( from _start != null ) { _from _start = from _start } ;
current _width = config . slider . width ;
config . slider . nav . height = VMM . Lib . height ( navigation . prevBtnContainer ) ;
// Handle smaller sizes
if ( VMM . Browser . device == "mobile" || current _width <= 640 ) {
config . slider . content . padding = 10 ;
} else {
config . slider . content . padding = config . slider . content . padding _default ;
}
config . slider . content . width = current _width - ( config . slider . content . padding * 2 ) ;
VMM . Lib . width ( $slides _items , ( slides . length * config . slider . content . width ) ) ;
if ( _from _start ) {
VMM . Lib . css ( $slider _container , "left" , slides [ current _slide ] . leftpos ( ) ) ;
}
// RESIZE SLIDES
sizeSlides ( ) ;
// POSITION SLIDES
positionSlides ( ) ;
// POSITION NAV
VMM . Lib . css ( navigation . nextBtn , "left" , ( current _width - config . slider . nav . width ) ) ;
VMM . Lib . height ( navigation . prevBtn , config . slider . height ) ;
VMM . Lib . height ( navigation . nextBtn , config . slider . height ) ;
VMM . Lib . css ( navigation . nextBtnContainer , "top" , ( ( config . slider . height / 2 ) - ( config . slider . nav . height / 2 ) ) + 10 ) ;
VMM . Lib . css ( navigation . prevBtnContainer , "top" , ( ( config . slider . height / 2 ) - ( config . slider . nav . height / 2 ) ) + 10 ) ;
// Animate Changes
VMM . Lib . height ( $slider _mask , config . slider . height ) ;
VMM . Lib . width ( $slider _mask , current _width ) ;
if ( _go _to _slide ) {
goToSlide ( current _slide , "linear" , 1 ) ;
} ;
if ( current _slide == 0 ) {
VMM . Lib . visible ( navigation . prevBtn , false ) ;
}
}
function onDragFinish ( e , d ) {
trace ( "DRAG FINISH" ) ;
trace ( d . left _adjust ) ;
trace ( ( config . slider . width / 2 ) ) ;
if ( d . left _adjust < 0 ) {
if ( Math . abs ( d . left _adjust ) > ( config . slider . width / 2 ) ) {
//onNextClick(e);
if ( current _slide == slides . length - 1 ) {
backToCurrentSlide ( ) ;
} else {
goToSlide ( current _slide + 1 , "easeOutExpo" ) ;
upDate ( ) ;
}
} else {
backToCurrentSlide ( ) ;
}
} else if ( Math . abs ( d . left _adjust ) > ( config . slider . width / 2 ) ) {
if ( current _slide == 0 ) {
backToCurrentSlide ( ) ;
} else {
goToSlide ( current _slide - 1 , "easeOutExpo" ) ;
upDate ( ) ;
}
} else {
backToCurrentSlide ( ) ;
}
}
/ * N A V I G A T I O N
=== === === === === === === === === === === === === === === === == * /
function onNextClick ( e ) {
if ( current _slide == slides . length - 1 ) {
backToCurrentSlide ( ) ;
} else {
goToSlide ( current _slide + 1 ) ;
upDate ( ) ;
}
}
function onPrevClick ( e ) {
if ( current _slide == 0 ) {
backToCurrentSlide ( ) ;
} else {
goToSlide ( current _slide - 1 ) ;
upDate ( ) ;
}
}
function onKeypressNav ( e ) {
switch ( e . keyCode ) {
case 39 :
// RIGHT ARROW
onNextClick ( e ) ;
break ;
case 37 :
// LEFT ARROW
onPrevClick ( e ) ;
break ;
}
}
function onTouchUpdate ( e , b ) {
if ( slide _positions . length == 0 ) {
for ( var i = 0 ; i < slides . length ; i ++ ) {
slide _positions . push ( slides [ i ] . leftpos ( ) ) ;
}
}
if ( typeof b . left == "number" ) {
var _pos = b . left ;
var _slide _pos = - ( slides [ current _slide ] . leftpos ( ) ) ;
if ( _pos < _slide _pos - ( config . slider _width / 3 ) ) {
onNextClick ( ) ;
} else if ( _pos > _slide _pos + ( config . slider _width / 3 ) ) {
onPrevClick ( ) ;
} else {
VMM . Lib . animate ( $slider _container , config . duration , config . ease , { "left" : _slide _pos } ) ;
}
} else {
VMM . Lib . animate ( $slider _container , config . duration , config . ease , { "left" : _slide _pos } ) ;
}
if ( typeof b . top == "number" ) {
VMM . Lib . animate ( $slider _container , config . duration , config . ease , { "top" : - b . top } ) ;
} else {
}
} ;
function onExplainerClick ( e ) {
detachMessege ( ) ;
}
/ * U P D A T E
=== === === === === === === === === === === === === === === === == * /
function upDate ( ) {
config . current _slide = current _slide ;
VMM . fireEvent ( layout , "UPDATE" ) ;
} ;
/ * G E T D A T A
=== === === === === === === === === === === === === === === === == * /
function getData ( d ) {
data = d ;
} ;
/ * B U I L D S L I D E S
=== === === === === === === === === === === === === === === === == * /
function buildSlides ( d ) {
var i = 0 ;
VMM . attachElement ( $slides _items , "" ) ;
slides = [ ] ;
for ( i = 0 ; i < d . length ; i ++ ) {
var _slide = new VMM . Slider . Slide ( d [ i ] , $slides _items ) ;
//_slide.show();
slides . push ( _slide ) ;
}
}
function preloadSlides ( skip ) {
var i = 0 ;
if ( skip ) {
preloadTimeOutSlides ( ) ;
} else {
for ( i = 0 ; i < slides . length ; i ++ ) {
slides [ i ] . clearTimers ( ) ;
}
timer = setTimeout ( preloadTimeOutSlides , config . duration ) ;
}
}
function preloadTimeOutSlides ( ) {
var i = 0 ;
for ( i = 0 ; i < slides . length ; i ++ ) {
slides [ i ] . enqueue = true ;
}
for ( i = 0 ; i < config . preload ; i ++ ) {
if ( ! ( ( current _slide + i ) > slides . length - 1 ) ) {
slides [ current _slide + i ] . show ( ) ;
slides [ current _slide + i ] . enqueue = false ;
}
if ( ! ( ( current _slide - i ) < 0 ) ) {
slides [ current _slide - i ] . show ( ) ;
slides [ current _slide - i ] . enqueue = false ;
}
}
if ( slides . length > 50 ) {
for ( i = 0 ; i < slides . length ; i ++ ) {
if ( slides [ i ] . enqueue ) {
slides [ i ] . hide ( ) ;
}
}
}
sizeSlides ( ) ;
}
function sizeSlide ( slide _id ) {
}
/ * S I Z E S L I D E S
=== === === === === === === === === === === === === === === === == * /
function sizeSlides ( ) {
var i = 0 ,
layout _text _media = ".slider-item .layout-text-media .media .media-container " ,
layout _media = ".slider-item .layout-media .media .media-container " ,
layout _both = ".slider-item .media .media-container" ,
layout _caption = ".slider-item .media .media-container .media-shadow .caption" ,
is _skinny = false ,
mediasize = {
text _media : {
width : ( config . slider . content . width / 100 ) * 60 ,
height : config . slider . height - 60 ,
video : {
width : 0 ,
height : 0
} ,
text : {
width : ( ( config . slider . content . width / 100 ) * 40 ) - 30 ,
height : config . slider . height
}
} ,
media : {
width : config . slider . content . width ,
height : config . slider . height - 110 ,
video : {
width : 0 ,
height : 0
}
}
} ;
// Handle smaller sizes
if ( VMM . Browser . device == "mobile" || current _width < 641 ) {
is _skinny = true ;
}
VMM . master _config . sizes . api . width = mediasize . media . width ;
VMM . master _config . sizes . api . height = mediasize . media . height ;
mediasize . text _media . video = VMM . Util . ratio . fit ( mediasize . text _media . width , mediasize . text _media . height , 16 , 9 ) ;
mediasize . media . video = VMM . Util . ratio . fit ( mediasize . media . width , mediasize . media . height , 16 , 9 ) ;
VMM . Lib . css ( ".slider-item" , "width" , config . slider . content . width ) ;
VMM . Lib . height ( ".slider-item" , config . slider . height ) ;
if ( is _skinny ) {
mediasize . text _media . width = config . slider . content . width - ( config . slider . content . padding * 2 ) ;
mediasize . media . width = config . slider . content . width - ( config . slider . content . padding * 2 ) ;
mediasize . text _media . height = ( ( config . slider . height / 100 ) * 50 ) - 50 ;
mediasize . media . height = ( ( config . slider . height / 100 ) * 70 ) - 40 ;
mediasize . text _media . video = VMM . Util . ratio . fit ( mediasize . text _media . width , mediasize . text _media . height , 16 , 9 ) ;
mediasize . media . video = VMM . Util . ratio . fit ( mediasize . media . width , mediasize . media . height , 16 , 9 ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text" , "width" , "100%" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text" , "display" , "block" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container" , "display" , "block" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container" , "width" , mediasize . media . width ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container .start" , "width" , "auto" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .media" , "float" , "none" ) ;
VMM . Lib . addClass ( ".slider-item .content-container" , "pad-top" ) ;
VMM . Lib . css ( ".slider-item .media blockquote p" , "line-height" , "18px" ) ;
VMM . Lib . css ( ".slider-item .media blockquote p" , "font-size" , "16px" ) ;
VMM . Lib . css ( ".slider-item" , "overflow-y" , "auto" ) ;
} else {
VMM . Lib . css ( ".slider-item .layout-text-media .text" , "width" , "40%" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text" , "display" , "table-cell" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container" , "display" , "table-cell" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container" , "width" , "auto" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .text .container .start" , "width" , mediasize . text _media . text . width ) ;
//VMM.Lib.addClass(".slider-item .content-container", "pad-left");
VMM . Lib . removeClass ( ".slider-item .content-container" , "pad-top" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media .media" , "float" , "left" ) ;
VMM . Lib . css ( ".slider-item .layout-text-media" , "display" , "table" ) ;
VMM . Lib . css ( ".slider-item .media blockquote p" , "line-height" , "36px" ) ;
VMM . Lib . css ( ".slider-item .media blockquote p" , "font-size" , "28px" ) ;
VMM . Lib . css ( ".slider-item" , "display" , "table" ) ;
VMM . Lib . css ( ".slider-item" , "overflow-y" , "auto" ) ;
}
// MEDIA FRAME
VMM . Lib . css ( layout _text _media + ".media-frame" , "max-width" , mediasize . text _media . width ) ;
VMM . Lib . height ( layout _text _media + ".media-frame" , mediasize . text _media . height ) ;
VMM . Lib . width ( layout _text _media + ".media-frame" , mediasize . text _media . width ) ;
// WEBSITES
//VMM.Lib.css( layout_both + ".website", "max-width", 300 );
// IMAGES
VMM . Lib . css ( layout _text _media + "img" , "max-height" , mediasize . text _media . height ) ;
VMM . Lib . css ( layout _media + "img" , "max-height" , mediasize . media . height ) ;
// FIX FOR NON-WEBKIT BROWSERS
VMM . Lib . css ( layout _text _media + "img" , "max-width" , mediasize . text _media . width ) ;
VMM . Lib . css ( layout _text _media + ".avatar img" , "max-width" , 32 ) ;
VMM . Lib . css ( layout _text _media + ".avatar img" , "max-height" , 32 ) ;
VMM . Lib . css ( layout _media + ".avatar img" , "max-width" , 32 ) ;
VMM . Lib . css ( layout _media + ".avatar img" , "max-height" , 32 ) ;
VMM . Lib . css ( layout _text _media + ".article-thumb" , "max-width" , "50%" ) ;
//VMM.Lib.css( layout_text_media + ".article-thumb", "max-height", 100 );
VMM . Lib . css ( layout _media + ".article-thumb" , "max-width" , 200 ) ;
//VMM.Lib.css( layout_media + ".article-thumb", "max-height", 100 );
// IFRAME FULL SIZE VIDEO
VMM . Lib . width ( layout _text _media + ".media-frame" , mediasize . text _media . video . width ) ;
VMM . Lib . height ( layout _text _media + ".media-frame" , mediasize . text _media . video . height ) ;
VMM . Lib . width ( layout _media + ".media-frame" , mediasize . media . video . width ) ;
VMM . Lib . height ( layout _media + ".media-frame" , mediasize . media . video . height ) ;
VMM . Lib . css ( layout _media + ".media-frame" , "max-height" , mediasize . media . video . height ) ;
VMM . Lib . css ( layout _media + ".media-frame" , "max-width" , mediasize . media . video . width ) ;
// SOUNDCLOUD
VMM . Lib . height ( layout _media + ".soundcloud" , 168 ) ;
VMM . Lib . height ( layout _text _media + ".soundcloud" , 168 ) ;
VMM . Lib . width ( layout _media + ".soundcloud" , mediasize . media . width ) ;
VMM . Lib . width ( layout _text _media + ".soundcloud" , mediasize . text _media . width ) ;
VMM . Lib . css ( layout _both + ".soundcloud" , "max-height" , 168 ) ;
// MAPS
VMM . Lib . height ( layout _text _media + ".map" , mediasize . text _media . height ) ;
VMM . Lib . width ( layout _text _media + ".map" , mediasize . text _media . width ) ;
VMM . Lib . css ( layout _media + ".map" , "max-height" , mediasize . media . height ) ;
VMM . Lib . width ( layout _media + ".map" , mediasize . media . width ) ;
// DOCS
VMM . Lib . height ( layout _text _media + ".doc" , mediasize . text _media . height ) ;
VMM . Lib . width ( layout _text _media + ".doc" , mediasize . text _media . width ) ;
VMM . Lib . height ( layout _media + ".doc" , mediasize . media . height ) ;
VMM . Lib . width ( layout _media + ".doc" , mediasize . media . width ) ;
// IE8 NEEDS THIS
VMM . Lib . width ( layout _media + ".wikipedia" , mediasize . media . width ) ;
VMM . Lib . width ( layout _media + ".twitter" , mediasize . media . width ) ;
VMM . Lib . width ( layout _media + ".plain-text-quote" , mediasize . media . width ) ;
VMM . Lib . width ( layout _media + ".plain-text" , mediasize . media . width ) ;
VMM . Lib . css ( layout _both , "max-width" , mediasize . media . width ) ;
// CAPTION WIDTH
VMM . Lib . css ( layout _text _media + ".caption" , "max-width" , mediasize . text _media . video . width ) ;
VMM . Lib . css ( layout _media + ".caption" , "max-width" , mediasize . media . video . width ) ;
//VMM.Lib.css( layout_text_media + ".caption", "max-width", mediasize.text_media.width);
//VMM.Lib.css( layout_media + ".caption", "max-width", mediasize.media.width);
// MAINTAINS VERTICAL CENTER IF IT CAN
for ( i = 0 ; i < slides . length ; i ++ ) {
slides [ i ] . layout ( is _skinny ) ;
if ( slides [ i ] . content _height ( ) > config . slider . height + 20 ) {
slides [ i ] . css ( "display" , "block" ) ;
} else {
slides [ i ] . css ( "display" , "table" ) ;
}
}
}
/ * P O S I T I O N S L I D E S
=== === === === === === === === === === === === === === === === == * /
function positionSlides ( ) {
var pos = 0 ,
i = 0 ;
for ( i = 0 ; i < slides . length ; i ++ ) {
pos = i * ( config . slider . width + config . spacing ) ;
slides [ i ] . leftpos ( pos ) ;
}
}
/ * O P A C I T Y S L I D E S
=== === === === === === === === === === === === === === === === == * /
function opacitySlides ( n ) {
var _ease = "linear" ,
i = 0 ;
for ( i = 0 ; i < slides . length ; i ++ ) {
if ( i == current _slide ) {
slides [ i ] . animate ( config . duration , _ease , { "opacity" : 1 } ) ;
} else if ( i == current _slide - 1 || i == current _slide + 1 ) {
slides [ i ] . animate ( config . duration , _ease , { "opacity" : 0.1 } ) ;
} else {
slides [ i ] . opacity ( n ) ;
}
}
}
/ * G O T O S L I D E
goToSlide ( n , ease , duration ) ;
=== === === === === === === === === === === === === === === === == * /
function goToSlide ( n , ease , duration , fast , firstrun ) {
var _ease = config . ease ,
_duration = config . duration ,
is _last = false ,
is _first = false ,
_title = "" ,
_pos ;
/ * S T O P A N Y V I D E O P L A Y E R S A C T I V E
=== === === === === === === === === === === === === === === === == * /
VMM . ExternalAPI . youtube . stopPlayers ( ) ;
// Set current slide
current _slide = n ;
_pos = slides [ current _slide ] . leftpos ( ) ;
if ( current _slide == 0 ) { is _first = true } ;
if ( current _slide + 1 >= slides . length ) { is _last = true } ;
if ( ease != null && ease != "" ) { _ease = ease } ;
if ( duration != null && duration != "" ) { _duration = duration } ;
/ * N A V I G A T I O N
set proper nav titles and dates etc .
=== === === === === === === === === === === === === === === === == * /
// Handle smaller sizes
if ( VMM . Browser . device == "mobile" ) {
//if (VMM.Browser.device == "mobile" || current_width <= 640) {
VMM . Lib . visible ( navigation . prevBtn , false ) ;
VMM . Lib . visible ( navigation . nextBtn , false ) ;
} else {
if ( is _first ) {
VMM . Lib . visible ( navigation . prevBtn , false ) ;
} else {
VMM . Lib . visible ( navigation . prevBtn , true ) ;
_title = VMM . Util . unlinkify ( data [ current _slide - 1 ] . title )
if ( config . type == "timeline" ) {
if ( typeof data [ current _slide - 1 ] . date === "undefined" ) {
VMM . attachElement ( navigation . prevDate , _title ) ;
VMM . attachElement ( navigation . prevTitle , "" ) ;
} else {
VMM . attachElement ( navigation . prevDate , VMM . Date . prettyDate ( data [ current _slide - 1 ] . startdate , false , data [ current _slide - 1 ] . precisiondate ) ) ;
VMM . attachElement ( navigation . prevTitle , _title ) ;
}
} else {
VMM . attachElement ( navigation . prevTitle , _title ) ;
}
}
if ( is _last ) {
VMM . Lib . visible ( navigation . nextBtn , false ) ;
} else {
VMM . Lib . visible ( navigation . nextBtn , true ) ;
_title = VMM . Util . unlinkify ( data [ current _slide + 1 ] . title ) ;
if ( config . type == "timeline" ) {
if ( typeof data [ current _slide + 1 ] . date === "undefined" ) {
VMM . attachElement ( navigation . nextDate , _title ) ;
VMM . attachElement ( navigation . nextTitle , "" ) ;
} else {
VMM . attachElement ( navigation . nextDate , VMM . Date . prettyDate ( data [ current _slide + 1 ] . startdate , false , data [ current _slide + 1 ] . precisiondate ) ) ;
VMM . attachElement ( navigation . nextTitle , _title ) ;
}
} else {
VMM . attachElement ( navigation . nextTitle , _title ) ;
}
}
}
/ * A N I M A T E S L I D E
=== === === === === === === === === === === === === === === === == * /
if ( fast ) {
VMM . Lib . css ( $slider _container , "left" , - ( _pos - config . slider . content . padding ) ) ;
} else {
VMM . Lib . stop ( $slider _container ) ;
VMM . Lib . animate ( $slider _container , _duration , _ease , { "left" : - ( _pos - config . slider . content . padding ) } ) ;
}
if ( firstrun ) {
VMM . fireEvent ( layout , "LOADED" ) ;
}
/ * S E T V e r t i c a l S c o l l
=== === === === === === === === === === === === === === === === == * /
if ( slides [ current _slide ] . height ( ) > config . slider _height ) {
VMM . Lib . css ( ".slider" , "overflow-y" , "scroll" ) ;
} else {
VMM . Lib . css ( layout , "overflow-y" , "hidden" ) ;
var scroll _height = 0 ;
// FIXME: Chrome cannot optimize this try/catch block, which appears to be unnecessary – see https://github.com/NUKnightLab/TimelineJS/pull/681#issuecomment-52365420
try {
scroll _height = VMM . Lib . prop ( layout , "scrollHeight" ) ;
VMM . Lib . animate ( layout , _duration , _ease , { scrollTop : scroll _height - VMM . Lib . height ( layout ) } ) ;
}
catch ( err ) {
scroll _height = VMM . Lib . height ( layout ) ;
}
}
preloadSlides ( ) ;
VMM . fireEvent ( $slider , "MESSAGE" , "TEST" ) ;
}
function backToCurrentSlide ( ) {
VMM . Lib . stop ( $slider _container ) ;
VMM . Lib . animate ( $slider _container , config . duration , "easeOutExpo" , { "left" : - ( slides [ current _slide ] . leftpos ( ) ) + config . slider . content . padding } ) ;
}
/ * M E S S E G E S
=== === === === === === === === === === === === === === === === == * /
function showMessege ( e , msg , other ) {
trace ( "showMessege " + msg ) ;
//VMM.attachElement($timeline, $feedback);
VMM . attachElement ( $explainer , "<div class='vco-explainer'><div class='vco-explainer-container'><div class='vco-bezel'><div class='vco-gesture-icon'></div>" + "<div class='vco-message'><p>" + msg + "</p></div></div></div></div>" ) ;
} ;
function hideMessege ( ) {
VMM . Lib . animate ( $explainer , config . duration , config . ease , { "opacity" : 0 } , detachMessege ) ;
} ;
function detachMessege ( ) {
VMM . Lib . detach ( $explainer ) ;
}
/ * B U I L D N A V I G A T I O N
=== === === === === === === === === === === === === === === === == * /
function buildNavigation ( ) {
var temp _icon = "<div class='icon'> </div>" ;
navigation . nextBtn = VMM . appendAndGetElement ( $slider , "<div>" , "nav-next" ) ;
navigation . prevBtn = VMM . appendAndGetElement ( $slider , "<div>" , "nav-previous" ) ;
navigation . nextBtnContainer = VMM . appendAndGetElement ( navigation . nextBtn , "<div>" , "nav-container" , temp _icon ) ;
navigation . prevBtnContainer = VMM . appendAndGetElement ( navigation . prevBtn , "<div>" , "nav-container" , temp _icon ) ;
if ( config . type == "timeline" ) {
navigation . nextDate = VMM . appendAndGetElement ( navigation . nextBtnContainer , "<div>" , "date" , "" ) ;
navigation . prevDate = VMM . appendAndGetElement ( navigation . prevBtnContainer , "<div>" , "date" , "" ) ;
}
navigation . nextTitle = VMM . appendAndGetElement ( navigation . nextBtnContainer , "<div>" , "title" , "" ) ;
navigation . prevTitle = VMM . appendAndGetElement ( navigation . prevBtnContainer , "<div>" , "title" , "" ) ;
VMM . bindEvent ( ".nav-next" , onNextClick ) ;
VMM . bindEvent ( ".nav-previous" , onPrevClick ) ;
VMM . bindEvent ( window , onKeypressNav , 'keydown' ) ;
}
/ * B U I L D
=== === === === === === === === === === === === === === === === == * /
function build ( ) {
var _ _duration = 3000 ;
// Clear out existing content
VMM . attachElement ( layout , "" ) ;
// Get DOM Objects to local objects
$slider = VMM . getElement ( layout ) ;
$slider _mask = VMM . appendAndGetElement ( $slider , "<div>" , "slider-container-mask" ) ;
$slider _container = VMM . appendAndGetElement ( $slider _mask , "<div>" , "slider-container" ) ;
$slides _items = VMM . appendAndGetElement ( $slider _container , "<div>" , "slider-item-container" ) ;
// BUILD NAVIGATION
buildNavigation ( ) ;
// ATTACH SLIDES
buildSlides ( data ) ;
/ * M A K E S L I D E R D R A G G A B L E / T O U C H A B L E
=== === === === === === === === === === === === === === === === == * /
if ( VMM . Browser . device == "tablet" || VMM . Browser . device == "mobile" ) {
// Different Animation duration for touch
config . duration = 500 ;
_ _duration = 1000 ;
// Make touchable
$dragslide = new VMM . DragSlider ( ) ;
$dragslide . createPanel ( $slider , $slider _container , "" , config . touch , true ) ;
VMM . bindEvent ( $dragslide , onDragFinish , 'DRAGUPDATE' ) ;
// EXPLAINER
$explainer = VMM . appendAndGetElement ( $slider _mask , "<div>" , "vco-feedback" , "" ) ;
showMessege ( null , VMM . master _config . language . messages . swipe _nav ) ;
VMM . Lib . height ( $explainer , config . slider . height ) ;
VMM . bindEvent ( $explainer , onExplainerClick ) ;
VMM . bindEvent ( $explainer , onExplainerClick , 'touchend' ) ;
}
reSize ( false , true ) ;
VMM . Lib . visible ( navigation . prevBtn , false ) ;
goToSlide ( config . current _slide , "easeOutExpo" , _ _duration , true , true ) ;
_active = true ;
} ;
} ;
}