Permalink
Browse files

gallery-2012.05.02-20-10 wrumsby gallery-full-screen

  • Loading branch information...
1 parent 39028df commit e6f8b25c5aa375b0b9d6f9ff9ea472b7d93a0f53 YUI Builder committed May 2, 2012
@@ -0,0 +1,29 @@
+# My Custom Module Build Properties
+
+# As long as the 'builder' project is cloned to the default folder
+# next to the 'yui3-gallery' project folder, the 'builddir' property does not
+# need to be changed
+#
+# If the 'builder' project is checked out to an alternate location, this
+# property should be updated to point to the checkout location.
+builddir=../../../builder/componentbuild
+
+# The name of the component. E.g. event, attribute, widget
+component=gallery-full-screen
+
+# The list of files which should be concatenated to create the component
+# NOTE: For a css component. (e.g. cssfonts, cssgrids etc.) use component.cssfiles instead.
+# component.jsfiles=my.custom.module.js, my.custom.moduleHelperClass.js, my.custom.moduleSubComponentClass.js
+component.jsfiles=full-screen.js
+
+# The list of modules this component. requires. Used to set up the Y.add module call for YUI 3.
+component.requires=arraylist, base-build, node-core, node-base
+
+# The list of modules this component. supersedes. Used to set up the Y.add module call for YUI 3.
+component.supersedes=
+
+# The list of modules that are optional for this module. Used to set up the Y.add module call for YUI 3.
+component.optional=
+# If your module has a skin file, set this flag to "true"
+component.skinnable=false
+#component.skinnable=true
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- YUI 3 Gallery Component Build File -->
+<project name="FullScreen" default="local">
+ <description>FullScreen Module Build File</description>
+ <property file="build.properties" />
+ <import file="${builddir}/3.x/bootstrap.xml" description="Default Build Properties and Targets" />
+</project>
@@ -0,0 +1,171 @@
+/**
+ * Provides a browser FullScreen API inspired by the W3C Recommendation
+ * http://dvcs.w3.org/hg/fullscreen/raw-file/tip/Overview.html
+ *
+ * @module gallery-full-screen
+ **/
+
+'use strict';
+
+var doc = Y.config.doc,
+ docNode = Y.one(doc.documentElement),
+ Lang = Y.Lang;
+
+/**
+ * FullScreen API
+ *
+ * @class FullScreen
+ * @constructor
+ * @extends Base
+ **/
+function FullScreen(config) {
+ FullScreen.superclass.constructor.apply(this, arguments);
+}
+
+FullScreen.NAME = 'fullScreen';
+
+FullScreen.ATTRS = {
+ /**
+ * FullScreen Node if FullScreen mode is enabled otherwise null.
+ *
+ * @attribute node
+ * @type Node
+ **/
+ 'node': {
+ value: null,
+ readOnly: true
+ }
+};
+
+/**
+ * @event change
+ * @param node
+ **/
+
+Y.extend(FullScreen, Y.Base, {
+ /**
+ * @property _isSupported
+ * @type Boolean
+ * @private
+ **/
+ _isSupported: false,
+
+ /**
+ * @property _vendorPrefix
+ * @type String
+ * @private
+ **/
+ _vendorPrefix: '',
+
+ initializer: function() {
+ this.publish('change', {
+ emitFacade: true,
+ broadcast: 2
+ });
+
+ this.before('change', function(e) {
+ var isEnabled = this.get('enabled');
+
+ this._set('node', isEnabled ? e.node : null);
+ });
+ },
+
+ /**
+ * Indicates if FullScreen mode is supported by this browser.
+ *
+ * @method isSupported
+ * @return {Boolean}
+ **/
+ isSupported: function() {
+ return this._isSupported;
+ },
+
+ /**
+ * Indicates if FullScreen mode is enabled.
+ *
+ * @method isEnabled
+ * @return {Boolean}
+ **/
+ isEnabled: function() {
+ return false;
+ },
+
+ /**
+ * Exit FullScreen mode.
+ *
+ * @method exit
+ **/
+ exit: function() {
+ }
+});
+
+Y.FullScreen = new FullScreen();
+
+(function() {
+ var VENDOR_PREFIXES = new Y.ArrayList(['webkit', 'moz']);
+
+ if (!Lang.isUndefined(doc.cancelFullScreen) || !Lang.isUndefined(doc.exitFullScreen)) {
+ Y.FullScreen._isSupported = true;
+ } else {
+ // TODO: use the functional programming module to do a .some()
+ VENDOR_PREFIXES.each(function(item) {
+ if (!Y.FullScreen._isSupported && !Lang.isUndefined(doc[item + 'CancelFullScreen'])) {
+ Y.FullScreen._isSupported = true;
+ Y.FullScreen._vendorPrefix = item;
+ }
+ });
+ }
+}());
+
+if (Y.FullScreen.isSupported()) {
+ switch (Y.FullScreen._vendorPrefix) {
+ case 'webkit':
+ Y.mix(FullScreen.prototype, {
+ isEnabled: function() {
+ return doc.webkitIsFullScreen;
+ },
+
+ exit: function() {
+ doc.webkitCancelFullScreen();
+
+ this.fire('change', { node: null });
+ }
+ }, true);
+
+ break;
+ case 'moz':
+ Y.mix(FullScreen.prototype, {
+ isEnabled: function() {
+ return doc.mozFullScreen;
+ },
+
+ exit: function() {
+ doc.mozCancelFullScreen();
+
+ this.fire('change', { node: null });
+ }
+ }, true);
+
+ break;
+ default:
+ Y.mix(FullScreen.prototype, {
+ isEnabled: function() {
+ return Lang.isUndefined(doc.fullscreenEnabled) ? doc.fullScreen : doc.fullscreenEnabled;
+ },
+
+ exit: function() {
+ doc.exitFullscreen();
+
+ this.fire('change', { node: null });
+ }
+ }, true);
+ }
+}
+
+if (Y.FullScreen.isSupported()) {
+ docNode.addClass('fullscreen');
+ docNode.removeClass('no-fullscreen');
+} else {
+ docNode.removeClass('fullscreen');
+ docNode.addClass('no-fullscreen');
+}

0 comments on commit e6f8b25

Please sign in to comment.