Skip to content
This repository
Browse code

Native fullscreen support

  • Loading branch information...
commit d88d30136f9aad4c756996cad0d477553dfd6cc3 1 parent 7f371ae
David Hellsing davidhellsing authored
11 docs/options/trueFullscreen.rst
Source Rendered
... ... @@ -0,0 +1,11 @@
  1 +==============
  2 +trueFullscreen
  3 +==============
  4 +
  5 + | type: **Boolean**
  6 + | default: **true**
  7 +
  8 +Galleria supports true fullscreen mode if it is supported by the browser (currently FF10+, Safari 5.1+ and Chrome 15+).
  9 +That means that it will enter a native OS fullscreen if the fullscreen method is triggered.
  10 +
  11 +If you don’t want this behavior, set this option to false.
1  docs/references/changelog.rst
Source Rendered
@@ -29,6 +29,7 @@ Changelog
29 29 * Added Galleria.run as the official initialization method
30 30 * Added Galleria.on as a static binder for events
31 31 * Added a fallback that uses domReady if the element is not found on the first init
  32 +* Added support for native fullscreen in Firefox 10+, Chrome and Safari 5+. You can disable it by setting trueFullscreen to false
32 33
33 34 1.2.6
34 35 -----
76 src/galleria.js
... ... @@ -1,5 +1,5 @@
1 1 /**
2   - * @preserve Galleria v 1.2.7b8 2012-03-12
  2 + * @preserve Galleria v 1.2.7d1 2012-03-28
3 3 * http://galleria.aino.se
4 4 *
5 5 * Copyright (c) 2012, Aino
@@ -1530,7 +1530,66 @@ Galleria = function() {
1530 1530
1531 1531 keymap: self._keyboard.map,
1532 1532
  1533 + // The native fullscreen handler
  1534 + os: {
  1535 +
  1536 + callback: F,
  1537 +
  1538 + support: (function() {
  1539 + var html = DOM().html;
  1540 + return html.requestFullscreen || html.mozRequestFullScreen || html.webkitRequestFullScreen;
  1541 + }()),
  1542 +
  1543 + enter: function(callback) {
  1544 + fullscreen.os.callback = callback || F;
  1545 + var html = DOM().html;
  1546 + if (html.requestFullscreen) {
  1547 + html.requestFullscreen();
  1548 + }
  1549 + else if (html.mozRequestFullScreen) {
  1550 + html.mozRequestFullScreen();
  1551 + }
  1552 + else if (html.webkitRequestFullScreen) {
  1553 + html.webkitRequestFullScreen();
  1554 + }
  1555 + },
  1556 +
  1557 + exit: function(callback) {
  1558 + fullscreen.os.callback = callback || F;
  1559 + if (doc.exitFullscreen) {
  1560 + doc.exitFullscreen();
  1561 + }
  1562 + else if (doc.mozCancelFullScreen) {
  1563 + doc.mozCancelFullScreen();
  1564 + }
  1565 + else if (doc.webkitCancelFullScreen) {
  1566 + doc.webkitCancelFullScreen();
  1567 + }
  1568 + },
  1569 +
  1570 + listen: function() {
  1571 + var handler = function() {
  1572 + if ( doc.fullscreen || doc.mozFullScreen || doc.webkitIsFullScreen ) {
  1573 + fullscreen._enter( fullscreen.os.callback );
  1574 + } else {
  1575 + fullscreen._exit(fullscreen.os.callback );
  1576 + }
  1577 + };
  1578 + doc.addEventListener( 'fullscreenchange', handler, false );
  1579 + doc.addEventListener( 'mozfullscreenchange', handler, false );
  1580 + doc.addEventListener( 'webkitfullscreenchange', handler, false );
  1581 + }
  1582 + },
  1583 +
1533 1584 enter: function(callback) {
  1585 + if ( self._options.trueFullscreen && fullscreen.os.support ) {
  1586 + fullscreen.os.enter(callback);
  1587 + } else {
  1588 + fullscreen._enter(callback);
  1589 + }
  1590 + },
  1591 +
  1592 + _enter: function(callback) {
1534 1593
1535 1594 fullscreen.active = true;
1536 1595
@@ -1649,6 +1708,14 @@ Galleria = function() {
1649 1708 },
1650 1709
1651 1710 exit: function(callback) {
  1711 + if ( self._options.trueFullscreen && fullscreen.os.support ) {
  1712 + fullscreen.os.exit( callback );
  1713 + } else {
  1714 + fullscreen._exit( callback );
  1715 + }
  1716 + },
  1717 +
  1718 + _exit: function(callback) {
1652 1719
1653 1720 fullscreen.active = false;
1654 1721
@@ -1705,6 +1772,8 @@ Galleria = function() {
1705 1772 }
1706 1773 };
1707 1774
  1775 + fullscreen.os.listen();
  1776 +
1708 1777 // the internal idle object for controlling idle states
1709 1778 var idle = this._idle = {
1710 1779
@@ -1746,7 +1815,7 @@ Galleria = function() {
1746 1815 elem = jQuery(elem);
1747 1816
1748 1817 $.each(idle.trunk, function(i, el) {
1749   - if ( el.length && !el.not(elem).length ) {
  1818 + if ( el && el.length && !el.not(elem).length ) {
1750 1819 self._idle.show(elem);
1751 1820 self._idle.trunk.splice(i, 1);
1752 1821 }
@@ -2047,7 +2116,7 @@ Galleria = function() {
2047 2116
2048 2117 show: function(index) {
2049 2118
2050   - lightbox.active = index = typeof index === 'number' ? index : self.getIndex();
  2119 + lightbox.active = index = typeof index === 'number' ? index : self.getIndex() || 0;
2051 2120
2052 2121 if ( !lightbox.initialized ) {
2053 2122 lightbox.init();
@@ -2228,6 +2297,7 @@ Galleria.prototype = {
2228 2297 transition: 'fade',
2229 2298 transitionInitial: undef, // legacy, deprecate in 1.3. Use initialTransition instead.
2230 2299 transitionSpeed: 400,
  2300 + trueFullscreen: true, // 1.2.7
2231 2301 useCanvas: false, // 1.2.4
2232 2302 vimeo: {
2233 2303 title: 0,

0 comments on commit d88d301

Please sign in to comment.
Something went wrong with that request. Please try again.