jumping navigation

This commit is contained in:
Nicky Case 2017-07-12 09:42:17 -04:00
parent be5f818d6b
commit 335810b29d
19 changed files with 353 additions and 64 deletions

173
css/balloon.css Executable file
View file

@ -0,0 +1,173 @@
button[data-balloon] {
overflow: visible;
}
[data-balloon] {
position: relative;
}
[data-balloon]:before,
[data-balloon]:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
filter: alpha(opacity=0);
-khtml-opacity: 0;
-moz-opacity: 0;
opacity: 0;
pointer-events: none;
-webkit-transition: all 0.1s ease-out 0.1s;
transition: all 0.1s ease-out 0.1s;
bottom: 100%;
left: 50%;
position: absolute;
z-index: 10;
-webkit-transform: translate(-50%, 10px);
-ms-transform: translate(-50%, 10px);
transform: translate(-50%, 10px);
-webkit-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top;
}
[data-balloon]:after {
background: rgba(17, 17, 17, 0.9);
border-radius: 4px;
color: #fff;
content: attr(data-balloon);
font-size: 18px;
padding: .5em 1em;
white-space: nowrap;
margin-bottom: 11px;
}
[data-balloon]:before {
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%280%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
background-size: 100% auto;
height: 6px;
width: 18px;
content: "";
margin-bottom: 5px;
}
[data-balloon]:hover:before,
[data-balloon][data-balloon-visible]:before,
[data-balloon]:hover:after,
[data-balloon][data-balloon-visible]:after {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
filter: alpha(opacity=100);
-khtml-opacity: 1;
-moz-opacity: 1;
opacity: 1;
pointer-events: auto;
-webkit-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0);
}
[data-balloon].font-awesome:after {
font-family: FontAwesome;
}
[data-balloon][data-balloon-break]:after {
white-space: pre;
}
[data-balloon-pos="down"]:before,
[data-balloon-pos="down"]:after {
bottom: auto;
left: 50%;
top: 100%;
-webkit-transform: translate(-50%, -10px);
-ms-transform: translate(-50%, -10px);
transform: translate(-50%, -10px);
}
[data-balloon-pos="down"]:after {
margin-top: 11px;
}
[data-balloon-pos="down"]:before {
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28180%2018%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
background-size: 100% auto;
height: 6px;
width: 18px;
margin-top: 5px;
margin-bottom: 0;
}
[data-balloon-pos="down"]:hover:before,
[data-balloon-pos="down"][data-balloon-visible]:before,
[data-balloon-pos="down"]:hover:after,
[data-balloon-pos="down"][data-balloon-visible]:after {
-webkit-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0);
}
[data-balloon-pos="left"]:before,
[data-balloon-pos="left"]:after {
bottom: auto;
left: auto;
right: 100%;
top: 50%;
-webkit-transform: translate(10px, -50%);
-ms-transform: translate(10px, -50%);
transform: translate(10px, -50%);
}
[data-balloon-pos="left"]:after {
margin-right: 11px;
}
[data-balloon-pos="left"]:before {
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%28-90%2018%2018%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
background-size: 100% auto;
height: 18px;
width: 6px;
margin-right: 5px;
margin-bottom: 0;
}
[data-balloon-pos="left"]:hover:before,
[data-balloon-pos="left"][data-balloon-visible]:before,
[data-balloon-pos="left"]:hover:after,
[data-balloon-pos="left"][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
}
[data-balloon-pos="right"]:before,
[data-balloon-pos="right"]:after {
bottom: auto;
left: 100%;
top: 50%;
-webkit-transform: translate(-10px, -50%);
-ms-transform: translate(-10px, -50%);
transform: translate(-10px, -50%);
}
[data-balloon-pos="right"]:after {
margin-left: 11px;
}
[data-balloon-pos="right"]:before {
background: url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba%2817,%2017,%2017,%200.9%29%22%20transform%3D%22rotate%2890%206%206%29%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E') no-repeat;
background-size: 100% auto;
height: 18px;
width: 6px;
margin-bottom: 0;
margin-left: 5px;
}
[data-balloon-pos="right"]:hover:before,
[data-balloon-pos="right"][data-balloon-visible]:before,
[data-balloon-pos="right"]:hover:after,
[data-balloon-pos="right"][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%);
}
[data-balloon-length]:after {
white-space: normal;
}
[data-balloon-length="small"]:after {
width: 80px;
}
[data-balloon-length="medium"]:after {
width: 150px;
}
[data-balloon-length="large"]:after {
width: 260px;
}
[data-balloon-length="xlarge"]:after {
width: 90vw;
}
@media screen and (min-width: 768px) {
[data-balloon-length="xlarge"]:after {
width: 380px;
}
}
[data-balloon-length="fit"]:after {
width: 100%;
}

View file

@ -44,10 +44,11 @@
<script src="js/sims/SandboxUI.js"></script> <script src="js/sims/SandboxUI.js"></script>
<!-- Slides --> <!-- Slides -->
<script src="js/slides/Slides_Intro.js"></script> <script src="js/slides/0_Slides_Intro.js"></script>
<script src="js/slides/Slides_OneOff.js"></script> <script src="js/slides/1_Slides_OneOff.js"></script>
<!--script src="js/slides/Slides_Iterated.js"></script> <script src="js/slides/2_Slides_Iterated.js"></script>
<script src="js/slides/Slides_Sandbox.js"></script--> <script src="js/slides/3_Slides_Tournament.js"></script>
<!--script src="js/slides/Slides_Sandbox.js"></script-->
<!-- Main Code --> <!-- Main Code -->
<script> <script>
@ -66,10 +67,10 @@ window.onload = function(){
}); });
// Slide Select // Slide Select
/*slideSelect = new SlideSelect({ slideSelect = new SlideSelect({
dom: $("#select"), dom: $("#select"),
slides: SLIDES slides: SLIDES
});*/ });
// First slide! // First slide!
slideshow.nextSlide(); slideshow.nextSlide();

View file

@ -3,14 +3,18 @@
var Scratcher = {}; var Scratcher = {};
exports.Scratcher = Scratcher; exports.Scratcher = Scratcher;
Scratcher.scratch = function(){ Scratcher.scratch = function(gotoID){
var dom = $("#scratcher"); var dom = $("#scratcher");
dom.style.display = "block"; dom.style.display = "block";
Scratcher.scratchAnim(true) Scratcher.scratchAnim(true)
.then(function(){ .then(function(){
if(gotoID){
publish("slideshow/goto", [gotoID]);
}else{
publish("slideshow/next"); publish("slideshow/next");
}
}) })
.then(function(){ .then(function(){
return Scratcher.scratchAnim(false); return Scratcher.scratchAnim(false);

View file

@ -16,7 +16,12 @@ function SlideSelect(config){
}; };
// Populate dots // Populate dots
for(var i=0; i<self.slides.length; i++) self.addDot(self.slides[i]); for(var i=0; i<self.slides.length; i++){
var slide = self.slides[i];
if(slide.id){
self.addDot(slide);
}
}
} }
@ -31,7 +36,7 @@ function SlideSelectDot(slide){
// On Click // On Click
self.dom.onclick = function(){ self.dom.onclick = function(){
publish("slideshow/goto", [slide.id]); publish("slideshow/scratch", [slide.id]);
}; };
// Listen to when the slide changes // Listen to when the slide changes

View file

@ -13,10 +13,18 @@ function Slideshow(config){
// Reset: INITIAL VARIABLES // Reset: INITIAL VARIABLES
self.reset = function(){ self.reset = function(){
// On End?
if(self.currentSlide && self.currentSlide.onend){
self.currentSlide.onend(self);
}
// Reset
self.dom.innerHTML = ""; self.dom.innerHTML = "";
self.slideIndex = -1; self.slideIndex = -1;
self.currentSlide = null; self.currentSlide = null;
self.objects = {}; self.objects = {};
}; };
self.reset(); self.reset();
@ -43,7 +51,7 @@ function Slideshow(config){
} }
// Send out message! // Send out message!
// publish("slideshow/slideChange", [self.currentSlide.id]); publish("slideshow/slideChange", [self.currentSlide.id]);
}; };
@ -106,23 +114,29 @@ function Slideshow(config){
////////////////////////////////////////////////// //////////////////////////////////////////////////
// FORCE go to a certain slide // FORCE go to a certain slide
/*self.gotoSlide = function(id){ self.gotoSlide = function(id){
// Go ALL the way to the past // Go ALL the way to the past
self.reset(); self.reset();
// And just move all the way forward, what a hack. // Slide & SlideIndex
// TODO: a more efficient one that looks at id's FIRST. self.currentSlide = self.slides.find(function(slide){
self.nextSlide(true); return slide.id==id;
while(self.currentSlide.id != id){ });
self.nextSlide(true); self.slideIndex = self.slides.indexOf(self.currentSlide);
}
// On JUMP & on Start
if(self.currentSlide.onjump) self.currentSlide.onjump(self);
if(self.currentSlide.onstart) self.currentSlide.onstart(self);
// Send out message!
publish("slideshow/slideChange", [self.currentSlide.id]);
}; };
// Subscribe to the "force goto" message... // Subscribe to the "force goto" message...
subscribe("slideshow/goto", function(id){ subscribe("slideshow/goto", function(id){
self.gotoSlide(id); self.gotoSlide(id);
});*/ });
} }

View file

@ -110,8 +110,6 @@ function Iterated(config){
self.playerB.chooseHat(id); self.playerB.chooseHat(id);
}; };
self.chooseOpponent("tft");
self.playOneRound = function(yourMove){ self.playOneRound = function(yourMove){
// Make your moves! // Make your moves!
@ -136,8 +134,8 @@ function Iterated(config){
// Payoff Matrix // Payoff Matrix
self.dehighlightPayoff(); self.dehighlightPayoff();
// Buttons // End Round
self.activateButtons(); publish("iterated/round/end");
}); });
@ -147,23 +145,21 @@ function Iterated(config){
}; };
subscribe("iterated/cooperate", function(){ subscribe("iterated/cooperate", function(){
publish("iterated/round/start");
self.playOneRound(PD.COOPERATE); self.playOneRound(PD.COOPERATE);
self.deactivateButtons();
}); });
subscribe("iterated/cheat", function(){ subscribe("iterated/cheat", function(){
publish("iterated/round/start");
self.playOneRound(PD.CHEAT); self.playOneRound(PD.CHEAT);
self.deactivateButtons();
}); });
self.activateButtons = function(){ subscribe("iterated/newOpponent", function(id){
publish("buttonCooperate/activate"); self.chooseOpponent(id);
publish("buttonCheat/activate"); self.playerA.resetFace();
}; self.playerB.resetFace();
self.deactivateButtons = function(){ });
publish("buttonCooperate/deactivate"); self.chooseOpponent("tft");
publish("buttonCheat/deactivate");
};
/////////////////////////////////////////////// ///////////////////////////////////////////////
///////////// ADD, REMOVE, KILL /////////////// ///////////// ADD, REMOVE, KILL ///////////////
@ -176,6 +172,7 @@ function Iterated(config){
// Remove... // Remove...
self.remove = function(INSTANT){ self.remove = function(INSTANT){
app.destroy();
return _remove(self); return _remove(self);
}; };
@ -229,6 +226,13 @@ function IteratedPeep(config){
self.eyebrows.visible = false; self.eyebrows.visible = false;
self.animated.addChild(self.eyebrows); self.animated.addChild(self.eyebrows);
// RESET FACE
self.resetFace = function(){
self.eyebrows.visible = false;
self.face.gotoAndStop(1);
self.restingFace = true;
};
// Position & Flip? // Position & Flip?
g.y = 236; g.y = 236;
//g.rotation = 1; //g.rotation = 1;

View file

@ -107,6 +107,7 @@ function Splash(config){
// Remove... // Remove...
self.remove = function(INSTANT){ self.remove = function(INSTANT){
app.destroy();
return _remove(self); return _remove(self);
}; };

View file

@ -378,12 +378,12 @@ function Tournament(config){
}; };
// Remove... // Remove...
self.remove = function(INSTANT){
return _remove(self);
};
// TODO: KILL ALL LISTENERS, TOO. // TODO: KILL ALL LISTENERS, TOO.
// TODO: Don't screw up when paused or looking at new tab // TODO: Don't screw up when paused or looking at new tab
self.remove = function(INSTANT){
app.destroy();
return _remove(self);
};
} }

View file

@ -79,9 +79,14 @@ SLIDES.push({
message:"slideshow/next" message:"slideshow/next"
}); });
},
onend: function(self){
self.objects.iterated.dehighlightPayoff();
self.remove("topWords");
self.remove("btmWords");
self.remove("btnNext");
} }
},{
onstart:function(){
}
}); });

View file

@ -0,0 +1,71 @@
SLIDES.push({
id: "iterated",
onjump: function(self){
// Iterated Simulation
self.add({id:"iterated", type:"Iterated", x:130, y:133});
},
onstart: function(self){
// ROUNDS
var ROUNDS = [
{id:"tft", num:5},
//{id:"all_d", num:4},
//{id:"all_c", num:4},
//{id:"grudge", num:5},
//{id:"prober", num:7}
];
ROUND_INDEX = 0;
ROUND_NUM = 0;
self.add({
id:"buttonCheat", type:"Button", x:275, y:403,
text_id:"label_cheat",
message:"iterated/cheat"
});
self.add({
id:"buttonCooperate", type:"Button", x:495, y:400,
text_id:"label_cooperate",
message:"iterated/cooperate"
});
_.listenerRoundStart = subscribe("iterated/round/start", function(){
publish("buttonCheat/deactivate");
publish("buttonCooperate/deactivate");
});
_.listenerRoundEnd = subscribe("iterated/round/end", function(){
publish("buttonCheat/activate");
publish("buttonCooperate/activate");
// Next round
ROUND_NUM++;
if(ROUND_NUM >= ROUNDS[ROUND_INDEX].num){
// Next opponent
ROUND_NUM = 0;
ROUND_INDEX++;
if(ROUND_INDEX >= ROUNDS.length){
publish("slideshow/scratch"); // NEXT SLIDE, WHATEVER
}else{
publish("iterated/newOpponent",[ROUNDS[ROUND_INDEX].id]);
}
}
});
},
onend: function(self){
self.clear();
}
},{
onstart: function(self){}
});

View file

View file

View file

View file

View file

View file

@ -1,23 +0,0 @@
SLIDES.push({
id: "iterated",
add:[
// The Iterated simulation
{id:"iterated", type:"Iterated", x:130, y:125},
// Buttons
{
id:"buttonCheat", type:"Button", x:275, y:403,
text_id:"label_cheat",
message:"iterated/cheat"
},
{
id:"buttonCooperate", type:"Button", x:495, y:400,
text_id:"label_cooperate",
message:"iterated/cooperate"
}
]
});

View file

@ -232,3 +232,37 @@ rules
<p id="label_reproduce_top_5"> <p id="label_reproduce_top_5">
3) reproduce top 5 3) reproduce top 5
</p> </p>
<!-- - - - - - - - - - - - - - - - - -->
<!-- - - - NAVIGATING CHAPTERS - - - -->
<!-- - - - - - - - - - - - - - - - - -->
<p id="chapter_intro">
0. Introduction
</p>
<p id="chapter_oneoff">
1. One Game
</p>
<p id="chapter_iterated">
2. Repeated Game
</p>
<p id="chapter_tournament">
3. One Tournament
</p>
<p id="chapter_evolution">
4. Repeated Tournament
</p>
<p id="chapter_noise">
5. Making Mistaeks
</p>
<p id="chapter_sandbox">
6. Sandbox
</p>
<p id="chapter_conclusion">
7. Conclusion
</p>
<p id="chapter_credits">
X. Credits
</p>