Permalink
Browse files

Blank the screen when B is pressed.

Unblank with any key or a click.
  • Loading branch information...
1 parent d52769d commit d62778da29c0913e954b65b7ad531ce1ffea2701 @reid reid committed Nov 5, 2010
Showing with 78 additions and 2 deletions.
  1. +2 −1 build/upstage-min.js
  2. +68 −0 js/blank.js
  3. +7 −0 js/keyboard.js
  4. +1 −1 rollup.properties
View
3 build/upstage-min.js
@@ -1 +1,2 @@
-YUI.add("upstage-controls",function(e){var a=e.Upstage,c=e.Node.create,d="boundingBox";function b(){b.superclass.constructor.apply(this,arguments);}b.NAME="controls";b.ATTRS={height:{value:37},total:{value:e.all(".slide").size(),readOnly:true},footer:{value:""},slide:{value:1}};b.HTML_PARSER={footer:function(f){return f.one(".credit").get("innerHTML");}};e.extend(b,e.Widget,{renderUI:function(){var g=this.get("contentBox");if(!g){return e.error("controls: contentBox is missing");}var f=c("<div class='nav'></div>");f.appendChild(c("<a class='prev' href='#'>&larr;</a>"));f.appendChild(c("<a class='currentSlide'>0/0</a>"));f.appendChild(c("<a class='next' href='#'>&rarr;</a>"));g.appendChild(f);g.setStyles({"height":0,"display":"block"});g.transition({duration:0.2,easing:"ease-out",height:this.get("height")+"px"});},bindUI:function(){var f=this.get(d);f.one(".prev").on("click",e.bind(a.fire,a,"warp",-1));f.one(".next").on("click",e.bind(a.fire,a,"warp",1));a.on("navigate",e.bind("set",this,"slide"));a.on("navigate",e.bind("syncUI",this));},syncUI:function(f){var g=this.get(d);g.one(".currentSlide").setContent(this.get("slide")+"/"+this.get("total"));g.one(".credit").setContent(this.get("footer"));}});a.on("start",function(){new b({srcNode:"#ft"}).render();});},"@VERSION@",{requires:["upstage-slideshow","widget","transition","node"]});YUI.add("upstage-gesture",function(h){var b=h.Upstage;var e=10;var a=500;function g(i,j,k){b.publish(i,{emitFacade:true,defaultFn:h.bind(b.fire,b,j,k)});}g("ui:tap","warp",1);g("ui:heldtap","position",1);g("ui:swipeleft","warp",1);g("ui:swiperight","warp",-1);var f=h.bind(b.fire,b);function c(o,k){var n=o.getData("gestureX"),i=k.pageX;if((n-i)>e){f("ui:swipeleft",o);}else{if((i-n)>e){f("ui:swiperight",o);}else{var m=o.getData("gestureDate").getTime(),j=(new Date).getTime(),l=j-m;if(l>a){f("ui:heldtap",l);}else{f("ui:tap",l);}}}}function d(i){switch(i.target.get("tagName").toUpperCase()){case"A":case"INPUT":case"BUTTON":case"VIDEO":case"OBJECT":return;}i.preventDefault();var j=i.currentTarget;j.once("selectstart",function(k){k.preventDefault();});j.setData("gestureX",i.pageX);j.setData("gestureDate",new Date);j.once("gesturemoveend",h.bind(c,this,j));}b.on("start",function(){h.one("body").delegate("gesturemovestart",d,".slide");});},"@VERSION@",{requires:["upstage-slideshow","event-move"]});YUI.add("upstage-keyboard",function(c){var a=c.Upstage;function b(d){switch(d.keyCode){case 32:case 34:case 39:case 40:a.fire("warp",1);break;case 33:case 37:case 38:a.fire("warp",-1);break;case 36:a.fire("position",1);break;case 35:a.fire("position",9999);break;}}a.on("start",function(){c.on("key",b,"body","down:");});},"@VERSION@",{requires:["upstage-slideshow","node","event"]});YUI.add("upstage-l10n",function(d){d.namespace("UpstageL10N");var b=d.UpstageL10N,c=d.Intl,a="upstage-l10n";b.setActiveLang=function(e){return c.setLang(a,e);};b.getActiveLang=function(){return c.getLang(a);};b.get=function(e,f){return c.get(a,e,f);};b.add=function(g,e){var f=c.add(a,g,e);if(!b.getActiveLang()){b.setActiveLang(g);}return f;};},"@VERSION@",{requires:["intl"],lang:["en"]});YUI.add("upstage-permalink",function(f){var b=f.Upstage,c=f.Selection.getText;f.HistoryHash.hashPrefix="!";var d=new f.HistoryHash,e,g;b.on("start",function(){e=f.one("title");g=c(e);b.fire("position",d.get("slide")||1);});b.on("navigate",function(h){d.addValue("slide",h);});b.on("transition",function(m){var l=m.details[1],i=l.getData("slide"),h=b.L10N.get("Slide"),j;if(i==1){j=g;}else{var k=l.one("h1");if(k){j=c(k);}if(!j){j=h+" "+l.getData("slide");}j=g+": "+j;}e.setContent(j);});function a(h){if(h&&h.newVal){h=h.newVal;}else{h=1;}b.fire("position",h);}d.on("slideChange",a);d.on("slideRemove",a);},"@VERSION@",{requires:["upstage-slideshow","node","history","selection"]});YUI.add("upstage-slideshow",function(b){b.namespace("Upstage");var a=b.Upstage;b.augment(a,b.EventTarget);a.on("start",function(){b.mix(a,{L10N:b.UpstageL10N});b.all(".slide").each(function(d,c){c++;d.set("id","slide"+c);d.setData("slide",c);});a.fire("position",1);});a.on("warp",function(d,e){if(e&&e.halt){e.halt();}var c=a.currentSlide+parseInt(d,10);a.fire("position",c);});a.on("position",function(c){c=Math.max(1,c);c=Math.min(c,b.all(".slide").size());var d=a.currentSlide||1;a.currentSlide=parseInt(c,10);if(d!=c){a.fire("navigate",c);a.fire("transition",b.one("#slide"+d),b.one("#slide"+c));}});a.publish("transition",{emitFacade:true,defaultFn:function(e){var d=e.details[0],c=e.details[1];d.setStyle("display","none");c.setStyle("display","block");}});},"@VERSION@",{requires:["upstage-l10n","oop","node","event-custom"]});YUI.add("upstage-transition-fade",function(d){var b=false;var a=new d.AsyncQueue;function c(){b=false;a.stop();}d.Upstage.on("transition",function(g){if(b){d.all(".slide").setStyles({"opacity":"1","display":"none"});return c();}g.preventDefault();b=true;var f=g.details[0],e=g.details[1];a.add(function(){a.pause();f.transition({duration:0.2,easing:"ease-out",opacity:0},d.bind(a.run,a));});a.add(function(){a.pause();e.setStyles({"opacity":"0","display":"block"});e.transition({duration:0.2,easing:"ease-out",opacity:1},d.bind(a.run,a));});a.add(function(){f.setStyles({"display":"none","opacity":"1"});});a.add(c);a.run();});},"@VERSION@",{requires:["upstage-slideshow","transition","async-queue"]});YUI.add("upstage",function(a){},"@VERSION@",{requires:["upstage-slideshow","upstage-controls","upstage-keyboard","upstage-gesture","upstage-permalink"]});
+YUI.add("upstage-blank",function(h){var a=h.Upstage,g="upstage-curtain",b="blank:on",e="blank:off",d,f=false;a.on("start",function(){var i=h.Node.create("<div id='"+g+"'></div>");i.setStyles({background:"#000",position:"absolute",top:0,left:0,width:"100%",height:"100%",zIndex:"100",display:"none"});h.one("body").append(i);d=i;d.on("click",h.bind(a.fire,a,"blank:off"));});a.on("blank",function(){if(!f){a.fire(b);}else{a.fire(e);}});function c(){return h.error("Curtain not found.");}a.on(b,function(){if(!d){return c();}d.setStyle("display","block");f=true;});a.on(e,function(){if(!d){return c();}d.setStyle("display","none");f=false;});},"@VERSION@",{requires:["upstage-slideshow","node"]});YUI.add("upstage-controls",function(e){var a=e.Upstage,c=e.Node.create,d="boundingBox";function b(){b.superclass.constructor.apply(this,arguments);}b.NAME="controls";b.ATTRS={height:{value:37},total:{value:e.all(".slide").size(),readOnly:true},footer:{value:""},slide:{value:1}};b.HTML_PARSER={footer:function(f){return f.one(".credit").get("innerHTML");}};e.extend(b,e.Widget,{renderUI:function(){var g=this.get("contentBox");if(!g){return e.error("controls: contentBox is missing");}var f=c("<div class='nav'></div>");f.appendChild(c("<a class='prev' href='#'>&larr;</a>"));f.appendChild(c("<a class='currentSlide'>0/0</a>"));f.appendChild(c("<a class='next' href='#'>&rarr;</a>"));g.appendChild(f);g.setStyles({"height":0,"display":"block"});g.transition({duration:0.2,easing:"ease-out",height:this.get("height")+"px"});},bindUI:function(){var f=this.get(d);f.one(".prev").on("click",e.bind(a.fire,a,"warp",-1));f.one(".next").on("click",e.bind(a.fire,a,"warp",1));a.on("navigate",e.bind("set",this,"slide"));a.on("navigate",e.bind("syncUI",this));},syncUI:function(f){var g=this.get(d);g.one(".currentSlide").setContent(this.get("slide")+"/"+this.get("total"));g.one(".credit").setContent(this.get("footer"));}});a.on("start",function(){new b({srcNode:"#ft"}).render();});},"@VERSION@",{requires:["upstage-slideshow","widget","transition","node"]});YUI.add("upstage-gesture",function(h){var b=h.Upstage;var e=10;var a=500;function g(i,j,k){b.publish(i,{emitFacade:true,defaultFn:h.bind(b.fire,b,j,k)});}g("ui:tap","warp",1);g("ui:heldtap","position",1);g("ui:swipeleft","warp",1);g("ui:swiperight","warp",-1);var f=h.bind(b.fire,b);function c(o,k){var n=o.getData("gestureX"),i=k.pageX;if((n-i)>e){f("ui:swipeleft",o);}else{if((i-n)>e){f("ui:swiperight",o);}else{var m=o.getData("gestureDate").getTime(),j=(new Date).getTime(),l=j-m;if(l>a){f("ui:heldtap",l);}else{f("ui:tap",l);}}}}function d(i){switch(i.target.get("tagName").toUpperCase()){case"A":case"INPUT":case"BUTTON":case"VIDEO":case"OBJECT":return;}i.preventDefault();var j=i.currentTarget;j.once("selectstart",function(k){k.preventDefault();});j.setData("gestureX",i.pageX);j.setData("gestureDate",new Date);j.once("gesturemoveend",h.bind(c,this,j));}b.on("start",function(){h.one("body").delegate("gesturemovestart",d,".slide");});},"@VERSION@",{requires:["upstage-slideshow","event-move"]});YUI.add("upstage-keyboard",function(c){var a=c.Upstage;function b(d){if(d.keyCode!=66){a.fire("blank:off");}switch(d.keyCode){case 32:case 34:case 39:case 40:a.fire("warp",1);break;case 33:case 37:case 38:a.fire("warp",-1);break;case 36:a.fire("position",1);break;case 35:a.fire("position",9999);break;case 66:a.fire("blank");break;}}a.on("start",function(){c.on("key",b,"body","down:");});},"@VERSION@",{requires:["upstage-slideshow","node","event"]});YUI.add("upstage-l10n",function(d){d.namespace("UpstageL10N");var b=d.UpstageL10N,c=d.Intl,a="upstage-l10n";b.setActiveLang=function(e){return c.setLang(a,e);};b.getActiveLang=function(){return c.getLang(a);};b.get=function(e,f){return c.get(a,e,f);};b.add=function(g,e){var f=c.add(a,g,e);if(!b.getActiveLang()){b.setActiveLang(g);}return f;};},"@VERSION@",{requires:["intl"],lang:["en"]});YUI.add("upstage-permalink",function(f){var b=f.Upstage,c=f.Selection.getText;f.HistoryHash.hashPrefix="!";var d=new f.HistoryHash,e,g;b.on("start",function(){e=f.one("title");g=c(e);b.fire("position",d.get("slide")||1);});b.on("navigate",function(h){d.addValue("slide",h);});b.on("transition",function(m){var l=m.details[1],i=l.getData("slide"),h=b.L10N.get("Slide"),j;if(i==1){j=g;}else{var k=l.one("h1");if(k){j=c(k);}if(!j){j=h+" "+l.getData("slide");}j=g+": "+j;}e.setContent(j);});function a(h){if(h&&h.newVal){h=h.newVal;}else{h=1;}b.fire("position",h);}d.on("slideChange",a);d.on("slideRemove",a);},"@VERSION@",{requires:["upstage-slideshow","node","history","selection"]});YUI.add("upstage-slideshow",function(b){b.namespace("Upstage");var a=b.Upstage;b.augment(a,b.EventTarget);a.on("start",function(){b.mix(a,{L10N:b.UpstageL10N});b.all(".slide").each(function(d,c){c++;d.set("id","slide"+c);d.setData("slide",c);});a.fire("position",1);});a.on("warp",function(d,e){if(e&&e.halt){e.halt();}var c=a.currentSlide+parseInt(d,10);a.fire("position",c);});a.on("position",function(c){c=Math.max(1,c);c=Math.min(c,b.all(".slide").size());var d=a.currentSlide||1;a.currentSlide=parseInt(c,10);if(d!=c){a.fire("navigate",c);a.fire("transition",b.one("#slide"+d),b.one("#slide"+c));}});a.publish("transition",{emitFacade:true,defaultFn:function(e){var d=e.details[0],c=e.details[1];d.setStyle("display","none");c.setStyle("display","block");}});},"@VERSION@",{requires:["upstage-l10n","oop","node","event-custom"]});YUI.add("upstage-transition-fade",function(d){var b=false;var a=new d.AsyncQueue;function c(){b=false;a.stop();}d.Upstage.on("transition",function(g){if(b){d.all(".slide").setStyles({"opacity":"1","display":"none"});return c();}g.preventDefault();b=true;var f=g.details[0],e=g.details[1];a.add(function(){a.pause();f.transition({duration:0.2,easing:"ease-out",opacity:0},d.bind(a.run,a));});a.add(function(){a.pause();e.setStyles({"opacity":"0","display":"block"});e.transition({duration:0.2,easing:"ease-out",opacity:1},d.bind(a.run,a));});a.add(function(){f.setStyles({"display":"none","opacity":"1"});
+});a.add(c);a.run();});},"@VERSION@",{requires:["upstage-slideshow","transition","async-queue"]});YUI.add("upstage",function(a){},"@VERSION@",{requires:["upstage-slideshow","upstage-controls","upstage-keyboard","upstage-blank","upstage-gesture","upstage-permalink"]});
View
68 js/blank.js
@@ -0,0 +1,68 @@
+// This module provides an event that blanks the screen.
+
+var Upstage = Y.Upstage,
+ // The ID of the curtain, the element that covers the slideshow.
+ CURTAIN_ID = "upstage-curtain",
+ ON = "blank:on",
+ OFF = "blank:off",
+ curtain,
+ blanked = false;
+
+// Create the curtain.
+Upstage.on("start", function () {
+
+ var div = Y.Node.create("<div id='" + CURTAIN_ID + "'></div>");
+
+ div.setStyles({
+ background : "#000",
+ position : "absolute",
+ top : 0,
+ left : 0,
+ width : "100%",
+ height : "100%",
+ zIndex : "100",
+ display : "none"
+ });
+
+ Y.one("body").append(div);
+
+ curtain = div;
+
+ // Unblank the screen when the curtain is clicked.
+ curtain.on("click", Y.bind(Upstage.fire, Upstage, "blank:off"));
+
+});
+
+// Toggle screen blanking.
+Upstage.on("blank", function () {
+
+ if (!blanked) Upstage.fire(ON);
+ else Upstage.fire(OFF);
+
+});
+
+function error () {
+ return Y.error("Curtain not found.");
+}
+
+// Blank the screen.
+Upstage.on(ON, function () {
+
+ if (!curtain) return error();
+
+ curtain.setStyle("display", "block");
+
+ blanked = true;
+
+});
+
+// Unblank the screen.
+Upstage.on(OFF, function () {
+
+ if (!curtain) return error();
+
+ curtain.setStyle("display", "none");
+
+ blanked = false;
+
+});
View
7 js/keyboard.js
@@ -4,6 +4,10 @@ var Upstage = Y.Upstage;
function keydown (ev) {
Y.log("upstage-keyboard: " + ev.type + ": " + ev.keyCode);
+
+ // Unblank the screen for all keys except B.
+ if (ev.keyCode != 66) Upstage.fire("blank:off");
+
switch (ev.keyCode) {
case 32: // space bar
case 34: // page down
@@ -22,6 +26,9 @@ function keydown (ev) {
case 35: // end
Upstage.fire("position", 9999);
break;
+ case 66: // B
+ Upstage.fire("blank");
+ break;
}
}
View
2 rollup.properties
@@ -4,7 +4,7 @@ component.rollup.modules.buildfiles=components.xml
#component.requires=upstage-controls, upstage-gesture, upstage-keyboard, upstage-l10n, upstage-slideshow
-component.requires=upstage-slideshow, upstage-controls, upstage-keyboard, upstage-gesture, upstage-permalink
+component.requires=upstage-slideshow, upstage-controls, upstage-keyboard, upstage-blank, upstage-gesture, upstage-permalink
component.lang.use=upstage-l10n
component.rollup.lang=${component._shared_lang}

0 comments on commit d62778d

Please sign in to comment.