reveal.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. /*!
  2. * reveal.js 1.3
  3. * http://lab.hakim.se/reveal-js
  4. * MIT licensed
  5. *
  6. * Copyright (C) 2012 Hakim El Hattab, http://hakim.se
  7. */
  8. var Reveal = (function(){
  9. var HORIZONTAL_SLIDES_SELECTOR = '#reveal .slides>section',
  10. VERTICAL_SLIDES_SELECTOR = '#reveal .slides>section.present>section',
  11. // The horizontal and verical index of the currently active slide
  12. indexh = 0,
  13. indexv = 0,
  14. // Configurations options, can be overridden at initialization time
  15. config = {
  16. controls: false,
  17. progress: false,
  18. history: false,
  19. transition: 'default',
  20. theme: 'default',
  21. mouseWheel: true,
  22. rollingLinks: true
  23. },
  24. // Slides may hold a data-state attribute which we pick up and apply
  25. // as a class to the body. This list contains the combined state of
  26. // all current slides.
  27. state = [],
  28. // Cached references to DOM elements
  29. dom = {},
  30. // Detect support for CSS 3D transforms
  31. supports3DTransforms = document.body.style['perspectiveProperty'] !== undefined ||
  32. document.body.style['WebkitPerspective'] !== undefined ||
  33. document.body.style['MozPerspective'] !== undefined ||
  34. document.body.style['msPerspective'] !== undefined ||
  35. document.body.style['OPerspective'] !== undefined,
  36. supports2DTransforms = document.body.style['transformProperty'] !== undefined ||
  37. document.body.style['WebkitTransform'] !== undefined ||
  38. document.body.style['MozTransform'] !== undefined ||
  39. document.body.style['msTransform'] !== undefined ||
  40. document.body.style['OTransform'] !== undefined,
  41. // Throttles mouse wheel navigation
  42. mouseWheelTimeout = 0,
  43. // Delays updates to the URL due to a Chrome thumbnailer bug
  44. writeURLTimeout = 0;
  45. /**
  46. * Starts up the slideshow by applying configuration
  47. * options and binding various events.
  48. */
  49. function initialize( options ) {
  50. if( !supports2DTransforms && !supports3DTransforms ) {
  51. document.body.setAttribute( 'class', 'no-transforms' );
  52. // If the browser doesn't support transforms we won't be
  53. // using JavaScript to control the presentation
  54. return;
  55. }
  56. // Cache references to DOM elements
  57. dom.wrapper = document.querySelector( '#reveal' );
  58. dom.progress = document.querySelector( '#reveal .progress' );
  59. dom.progressbar = document.querySelector( '#reveal .progress span' );
  60. dom.controls = document.querySelector( '#reveal .controls' );
  61. dom.controlsLeft = document.querySelector( '#reveal .controls .left' );
  62. dom.controlsRight = document.querySelector( '#reveal .controls .right' );
  63. dom.controlsUp = document.querySelector( '#reveal .controls .up' );
  64. dom.controlsDown = document.querySelector( '#reveal .controls .down' );
  65. // Bind all view events
  66. document.addEventListener('keydown', onDocumentKeyDown, false);
  67. document.addEventListener('touchstart', onDocumentTouchStart, false);
  68. window.addEventListener('hashchange', onWindowHashChange, false);
  69. dom.controlsLeft.addEventListener('click', preventAndForward( navigateLeft ), false);
  70. dom.controlsRight.addEventListener('click', preventAndForward( navigateRight ), false);
  71. dom.controlsUp.addEventListener('click', preventAndForward( navigateUp ), false);
  72. dom.controlsDown.addEventListener('click', preventAndForward( navigateDown ), false);
  73. // Copy options over to our config object
  74. extend( config, options );
  75. // Fall back on the 2D transform theme 'linear'
  76. if( supports3DTransforms === false ) {
  77. config.transition = 'linear';
  78. }
  79. if( config.controls ) {
  80. dom.controls.style.display = 'block';
  81. }
  82. if( config.progress ) {
  83. dom.progress.style.display = 'block';
  84. }
  85. if( config.transition !== 'default' ) {
  86. dom.wrapper.classList.add( config.transition );
  87. }
  88. if( config.theme !== 'default' ) {
  89. dom.wrapper.classList.add( config.theme );
  90. }
  91. if( config.mouseWheel ) {
  92. document.addEventListener('DOMMouseScroll', onDocumentMouseScroll, false); // FF
  93. document.addEventListener('mousewheel', onDocumentMouseScroll, false);
  94. }
  95. if( config.rollingLinks ) {
  96. // Add some 3D magic to our anchors
  97. linkify();
  98. }
  99. // Read the initial hash
  100. readURL();
  101. }
  102. /**
  103. * Extend object a with the properties of object b.
  104. * If there's a conflict, object b takes precedence.
  105. */
  106. function extend( a, b ) {
  107. for( var i in b ) {
  108. a[ i ] = b[ i ];
  109. }
  110. }
  111. /**
  112. * Prevents an events defaults behavior calls the
  113. * specified delegate.
  114. *
  115. * @param {Function} delegate The method to call
  116. * after the wrapper has been executed
  117. */
  118. function preventAndForward( delegate ) {
  119. return function( event ) {
  120. event.preventDefault();
  121. delegate.call();
  122. }
  123. }
  124. /**
  125. * Handler for the document level 'keydown' event.
  126. *
  127. * @param {Object} event
  128. */
  129. function onDocumentKeyDown( event ) {
  130. // FFT: Use document.querySelector( ':focus' ) === null
  131. // instead of checking contentEditable?
  132. // Disregard the event if the target is editable or a
  133. // modifier is present
  134. if ( event.target.contentEditable != 'inherit' || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return;
  135. var triggered = false;
  136. switch( event.keyCode ) {
  137. // p, page up
  138. case 80: case 33: navigatePrev(); triggered = true; break;
  139. // n, page down, space
  140. case 78: case 32: case 34: navigateNext(); triggered = true; break;
  141. // h, left
  142. case 72: case 37: navigateLeft(); triggered = true; break;
  143. // l, right
  144. case 76: case 39: navigateRight(); triggered = true; break;
  145. // k, up
  146. case 75: case 38: navigateUp(); triggered = true; break;
  147. // j, down
  148. case 74: case 40: navigateDown(); triggered = true; break;
  149. }
  150. if( triggered ) {
  151. event.preventDefault();
  152. }
  153. else if ( event.keyCode === 27 && supports3DTransforms ) {
  154. if( overviewIsActive() ) {
  155. deactivateOverview();
  156. }
  157. else {
  158. activateOverview();
  159. }
  160. event.preventDefault();
  161. }
  162. }
  163. /**
  164. * Handler for the document level 'touchstart' event.
  165. *
  166. * This enables very basic tap interaction for touch
  167. * devices. Added mainly for performance testing of 3D
  168. * transforms on iOS but was so happily surprised with
  169. * how smoothly it runs so I left it in here. Apple +1
  170. *
  171. * @param {Object} event
  172. */
  173. function onDocumentTouchStart( event ) {
  174. // We're only interested in one point taps
  175. if (event.touches.length === 1) {
  176. // Never prevent taps on anchors and images
  177. if( event.target.tagName.toLowerCase() === 'a' || event.target.tagName.toLowerCase() === 'img' ) {
  178. return;
  179. }
  180. event.preventDefault();
  181. var point = {
  182. x: event.touches[0].clientX,
  183. y: event.touches[0].clientY
  184. };
  185. // Define the extent of the areas that may be tapped
  186. // to navigate
  187. var wt = window.innerWidth * 0.3;
  188. var ht = window.innerHeight * 0.3;
  189. if( point.x < wt ) {
  190. navigateLeft();
  191. }
  192. else if( point.x > window.innerWidth - wt ) {
  193. navigateRight();
  194. }
  195. else if( point.y < ht ) {
  196. navigateUp();
  197. }
  198. else if( point.y > window.innerHeight - ht ) {
  199. navigateDown();
  200. }
  201. slide();
  202. }
  203. }
  204. /**
  205. * Handles mouse wheel scrolling, throttled to avoid
  206. * skipping multiple slides.
  207. */
  208. function onDocumentMouseScroll( event ){
  209. clearTimeout( mouseWheelTimeout );
  210. mouseWheelTimeout = setTimeout( function() {
  211. var delta = event.detail || -event.wheelDelta;
  212. if( delta > 0 ) {
  213. navigateNext();
  214. }
  215. else {
  216. navigatePrev();
  217. }
  218. }, 100 );
  219. }
  220. /**
  221. * Handler for the window level 'hashchange' event.
  222. *
  223. * @param {Object} event
  224. */
  225. function onWindowHashChange( event ) {
  226. readURL();
  227. }
  228. /**
  229. * Wrap all links in 3D goodness.
  230. */
  231. function linkify() {
  232. if( supports3DTransforms ) {
  233. var nodes = document.querySelectorAll( '#reveal .slides section a:not(.image)' );
  234. for( var i = 0, len = nodes.length; i < len; i++ ) {
  235. var node = nodes[i];
  236. if( node.textContent && !node.querySelector( 'img' ) && ( !node.className || !node.classList.contains( node, 'roll' ) ) ) {
  237. node.classList.add( 'roll' );
  238. node.innerHTML = '<span data-title="'+ node.text +'">' + node.innerHTML + '</span>';
  239. }
  240. };
  241. }
  242. }
  243. /**
  244. * Displays the overview of slides (quick nav) by
  245. * scaling down and arranging all slide elements.
  246. *
  247. * Experimental feature, might be dropped if perf
  248. * can't be improved.
  249. */
  250. function activateOverview() {
  251. dom.wrapper.classList.add( 'overview' );
  252. var horizontalSlides = Array.prototype.slice.call( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ) );
  253. for( var i = 0, len1 = horizontalSlides.length; i < len1; i++ ) {
  254. var hslide = horizontalSlides[i],
  255. htransform = 'translateZ(-2500px) translate(' + ( ( i - indexh ) * 105 ) + '%, 0%)';
  256. hslide.setAttribute( 'data-index-h', i );
  257. hslide.style.display = 'block';
  258. hslide.style.WebkitTransform = htransform;
  259. hslide.style.MozTransform = htransform;
  260. hslide.style.msTransform = htransform;
  261. hslide.style.OTransform = htransform;
  262. hslide.style.transform = htransform;
  263. if( !hslide.classList.contains( 'stack' ) ) {
  264. // Navigate to this slide on click
  265. hslide.addEventListener( 'click', onOverviewSlideClicked, true );
  266. }
  267. var verticalSlides = Array.prototype.slice.call( hslide.querySelectorAll( 'section' ) );
  268. for( var j = 0, len2 = verticalSlides.length; j < len2; j++ ) {
  269. var vslide = verticalSlides[j],
  270. vtransform = 'translate(0%, ' + ( ( j - indexv ) * 105 ) + '%)';
  271. vslide.setAttribute( 'data-index-h', i );
  272. vslide.setAttribute( 'data-index-v', j );
  273. vslide.style.display = 'block';
  274. vslide.style.WebkitTransform = vtransform;
  275. vslide.style.MozTransform = vtransform;
  276. vslide.style.msTransform = vtransform;
  277. vslide.style.OTransform = vtransform;
  278. vslide.style.transform = vtransform;
  279. // Navigate to this slide on click
  280. vslide.addEventListener( 'click', onOverviewSlideClicked, true );
  281. }
  282. }
  283. }
  284. /**
  285. * Exits the slide overview and enters the currently
  286. * active slide.
  287. */
  288. function deactivateOverview() {
  289. dom.wrapper.classList.remove( 'overview' );
  290. var slides = Array.prototype.slice.call( document.querySelectorAll( '#reveal .slides section' ) );
  291. for( var i = 0, len = slides.length; i < len; i++ ) {
  292. var element = slides[i];
  293. // Resets all transforms to use the external styles
  294. element.style.WebkitTransform = '';
  295. element.style.MozTransform = '';
  296. element.style.msTransform = '';
  297. element.style.OTransform = '';
  298. element.style.transform = '';
  299. element.removeEventListener( 'click', onOverviewSlideClicked );
  300. }
  301. slide();
  302. }
  303. /**
  304. * Checks if the overview is currently active.
  305. *
  306. * @return {Boolean} true if the overview is active,
  307. * false otherwise
  308. */
  309. function overviewIsActive() {
  310. return dom.wrapper.classList.contains( 'overview' );
  311. }
  312. /**
  313. * Invoked when a slide is and we're in the overview.
  314. */
  315. function onOverviewSlideClicked( event ) {
  316. // TODO There's a bug here where the event listeners are not
  317. // removed after deactivating the overview.
  318. if( overviewIsActive() ) {
  319. event.preventDefault();
  320. deactivateOverview();
  321. indexh = this.getAttribute( 'data-index-h' );
  322. indexv = this.getAttribute( 'data-index-v' );
  323. slide();
  324. }
  325. }
  326. /**
  327. * Updates one dimension of slides by showing the slide
  328. * with the specified index.
  329. *
  330. * @param {String} selector A CSS selector that will fetch
  331. * the group of slides we are working with
  332. * @param {Number} index The index of the slide that should be
  333. * shown
  334. *
  335. * @return {Number} The index of the slide that is now shown,
  336. * might differ from the passed in index if it was out of
  337. * bounds.
  338. */
  339. function updateSlides( selector, index ) {
  340. // Select all slides and convert the NodeList result to
  341. // an array
  342. var slides = Array.prototype.slice.call( document.querySelectorAll( selector ) );
  343. if( slides.length ) {
  344. // Enforce max and minimum index bounds
  345. index = Math.max(Math.min(index, slides.length - 1), 0);
  346. for( var i = 0; i < slides.length; i++ ) {
  347. var slide = slides[i];
  348. // Optimization; hide all slides that are three or more steps
  349. // away from the present slide
  350. if( overviewIsActive() === false ) {
  351. slide.style.display = Math.abs( index - i ) > 3 ? 'none' : 'block';
  352. }
  353. slides[i].classList.remove( 'past' );
  354. slides[i].classList.remove( 'present' );
  355. slides[i].classList.remove( 'future' );
  356. if( i < index ) {
  357. // Any element previous to index is given the 'past' class
  358. slides[i].classList.add( 'past' );
  359. }
  360. else if( i > index ) {
  361. // Any element subsequent to index is given the 'future' class
  362. slides[i].classList.add( 'future' );
  363. }
  364. // If this element contains vertical slides
  365. if( slide.querySelector( 'section' ) ) {
  366. slides[i].classList.add( 'stack' );
  367. }
  368. }
  369. // Mark the current slide as present
  370. slides[index].classList.add( 'present' );
  371. // If this slide has a state associated with it, add it
  372. // onto the current state of the deck
  373. var slideState = slides[index].dataset.state;
  374. if( slideState ) {
  375. state = state.concat( slideState.split( ' ' ) );
  376. }
  377. }
  378. else {
  379. // Since there are no slides we can't be anywhere beyond the
  380. // zeroth index
  381. index = 0;
  382. }
  383. return index;
  384. }
  385. /**
  386. * Updates the visual slides to represent the currently
  387. * set indices.
  388. */
  389. function slide() {
  390. // Remember the state before this slide
  391. var stateBefore = state.concat();
  392. // Reset the state array
  393. state.length = 0;
  394. // Activate and transition to the new slide
  395. indexh = updateSlides( HORIZONTAL_SLIDES_SELECTOR, indexh );
  396. indexv = updateSlides( VERTICAL_SLIDES_SELECTOR, indexv );
  397. // Apply the new state
  398. stateLoop: for( var i = 0, len = state.length; i < len; i++ ) {
  399. // Check if this state existed on the previous slide. If it
  400. // did, we will avoid adding it repeatedly.
  401. for( var j = 0; j < stateBefore.length; j++ ) {
  402. if( stateBefore[j] === state[i] ) {
  403. stateBefore.splice( j, 1 );
  404. continue stateLoop;
  405. }
  406. }
  407. document.documentElement.classList.add( state[i] );
  408. // Dispatch custom event
  409. var event = document.createEvent( "HTMLEvents" );
  410. event.initEvent( state[i], true, true );
  411. document.dispatchEvent( event );
  412. }
  413. // Clean up the remaints of the previous state
  414. while( stateBefore.length ) {
  415. document.documentElement.classList.remove( stateBefore.pop() );
  416. }
  417. // Update progress if enabled
  418. if( config.progress ) {
  419. dom.progressbar.style.width = ( indexh / ( document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR ).length - 1 ) ) * window.innerWidth + 'px';
  420. }
  421. // Close the overview if it's active
  422. if( overviewIsActive() ) {
  423. activateOverview();
  424. }
  425. updateControls();
  426. clearTimeout( writeURLTimeout );
  427. writeURLTimeout = setTimeout( writeURL, 1500 );
  428. }
  429. /**
  430. * Updates the state and link pointers of the controls.
  431. */
  432. function updateControls() {
  433. var routes = availableRoutes();
  434. // Remove the 'enabled' class from all directions
  435. [ dom.controlsLeft, dom.controlsRight, dom.controlsUp, dom.controlsDown ].forEach( function( node ) {
  436. node.classList.remove( 'enabled' );
  437. } )
  438. if( routes.left ) dom.controlsLeft.classList.add( 'enabled' );
  439. if( routes.right ) dom.controlsRight.classList.add( 'enabled' );
  440. if( routes.up ) dom.controlsUp.classList.add( 'enabled' );
  441. if( routes.down ) dom.controlsDown.classList.add( 'enabled' );
  442. }
  443. /**
  444. * Determine what available routes there are for navigation.
  445. *
  446. * @return {Object} containing four booleans: left/right/up/down
  447. */
  448. function availableRoutes() {
  449. var horizontalSlides = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR );
  450. var verticalSlides = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR );
  451. return {
  452. left: indexh > 0,
  453. right: indexh < horizontalSlides.length - 1,
  454. up: indexv > 0,
  455. down: indexv < verticalSlides.length - 1
  456. };
  457. }
  458. /**
  459. * Reads the current URL (hash) and navigates accordingly.
  460. */
  461. function readURL() {
  462. // Break the hash down to separate components
  463. var bits = window.location.hash.slice(2).split('/');
  464. // Read the index components of the hash
  465. indexh = parseInt( bits[0] ) || 0 ;
  466. indexv = parseInt( bits[1] ) || 0 ;
  467. navigateTo( indexh, indexv );
  468. }
  469. /**
  470. * Updates the page URL (hash) to reflect the current
  471. * state.
  472. */
  473. function writeURL() {
  474. if( config.history ) {
  475. var url = '/';
  476. // Only include the minimum possible number of components in
  477. // the URL
  478. if( indexh > 0 || indexv > 0 ) url += indexh;
  479. if( indexv > 0 ) url += '/' + indexv;
  480. window.location.hash = url;
  481. }
  482. }
  483. /**
  484. * Navigate to the next slide fragment.
  485. *
  486. * @return {Boolean} true if there was a next fragment,
  487. * false otherwise
  488. */
  489. function nextFragment() {
  490. // Vertical slides:
  491. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  492. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  493. if( verticalFragments.length ) {
  494. verticalFragments[0].classList.add( 'visible' );
  495. return true;
  496. }
  497. }
  498. // Horizontal slides:
  499. else {
  500. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment:not(.visible)' );
  501. if( horizontalFragments.length ) {
  502. horizontalFragments[0].classList.add( 'visible' );
  503. return true;
  504. }
  505. }
  506. return false;
  507. }
  508. /**
  509. * Navigate to the previous slide fragment.
  510. *
  511. * @return {Boolean} true if there was a previous fragment,
  512. * false otherwise
  513. */
  514. function previousFragment() {
  515. // Vertical slides:
  516. if( document.querySelector( VERTICAL_SLIDES_SELECTOR + '.present' ) ) {
  517. var verticalFragments = document.querySelectorAll( VERTICAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  518. if( verticalFragments.length ) {
  519. verticalFragments[ verticalFragments.length - 1 ].classList.remove( 'visible' );
  520. return true;
  521. }
  522. }
  523. // Horizontal slides:
  524. else {
  525. var horizontalFragments = document.querySelectorAll( HORIZONTAL_SLIDES_SELECTOR + '.present .fragment.visible' );
  526. if( horizontalFragments.length ) {
  527. horizontalFragments[ horizontalFragments.length - 1 ].classList.remove( 'visible' );
  528. return true;
  529. }
  530. }
  531. return false;
  532. }
  533. /**
  534. * Triggers a navigation to the specified indices.
  535. *
  536. * @param {Number} h The horizontal index of the slide to show
  537. * @param {Number} v The vertical index of the slide to show
  538. */
  539. function navigateTo( h, v ) {
  540. indexh = h === undefined ? indexh : h;
  541. indexv = v === undefined ? indexv : v;
  542. slide();
  543. }
  544. function navigateLeft() {
  545. // Prioritize hiding fragments
  546. if( overviewIsActive() || previousFragment() === false ) {
  547. indexh --;
  548. indexv = 0;
  549. slide();
  550. }
  551. }
  552. function navigateRight() {
  553. // Prioritize revealing fragments
  554. if( overviewIsActive() || nextFragment() === false ) {
  555. indexh ++;
  556. indexv = 0;
  557. slide();
  558. }
  559. }
  560. function navigateUp() {
  561. // Prioritize hiding fragments
  562. if( overviewIsActive() || previousFragment() === false ) {
  563. indexv --;
  564. slide();
  565. }
  566. }
  567. function navigateDown() {
  568. // Prioritize revealing fragments
  569. if( overviewIsActive() || nextFragment() === false ) {
  570. indexv ++;
  571. slide();
  572. }
  573. }
  574. /**
  575. * Navigates backwards, prioritized in the following order:
  576. * 1) Previous fragment
  577. * 2) Previous vertical slide
  578. * 3) Previous horizontal slide
  579. */
  580. function navigatePrev() {
  581. // Prioritize revealing fragments
  582. if( previousFragment() === false ) {
  583. if( availableRoutes().up ) {
  584. navigateUp();
  585. }
  586. else {
  587. // Fetch the previous horizontal slide, if there is one
  588. var previousSlide = document.querySelector( '#reveal .slides>section.past:nth-child(' + indexh + ')' );
  589. if( previousSlide ) {
  590. indexv = ( previousSlide.querySelectorAll('section').length + 1 ) || 0;
  591. indexh --;
  592. slide();
  593. }
  594. }
  595. }
  596. }
  597. /**
  598. * Same as #navigatePrev() but navigates forwards.
  599. */
  600. function navigateNext() {
  601. // Prioritize revealing fragments
  602. if( nextFragment() === false ) {
  603. availableRoutes().down ? navigateDown() : navigateRight();
  604. }
  605. }
  606. // Expose some methods publicly
  607. return {
  608. initialize: initialize,
  609. navigateTo: navigateTo,
  610. navigateLeft: navigateLeft,
  611. navigateRight: navigateRight,
  612. navigateUp: navigateUp,
  613. navigateDown: navigateDown
  614. };
  615. })();