mirror of
https://github.com/pcottle/learnGitBranching.git
synced 2025-06-26 07:58:34 +02:00
button clicking and left right nav integration for git demonstration view
This commit is contained in:
parent
0c4319911e
commit
e0c4ac795b
5 changed files with 143 additions and 14 deletions
102
build/bundle.js
102
build/bundle.js
|
@ -9810,13 +9810,29 @@ var LeftRightView = PositiveNegativeBase.extend({
|
||||||
'click .right': 'positive'
|
'click .right': 'positive'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
positive: function() {
|
||||||
|
this.pipeEvents.trigger('positive');
|
||||||
|
LeftRightView.__super__.positive.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
negative: function() {
|
||||||
|
this.pipeEvents.trigger('negative');
|
||||||
|
LeftRightView.__super__.negative.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
if (!options.destination || !options.events) {
|
if (!options.destination || !options.events) {
|
||||||
throw new Error('needmore');
|
throw new Error('needmore');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.destination = options.destination;
|
this.destination = options.destination;
|
||||||
this.navEvents = options.events;
|
|
||||||
|
// we switch to a system where every leftrightview has its own
|
||||||
|
// events system to add support for git demonstration view taking control of the
|
||||||
|
// click events
|
||||||
|
this.pipeEvents = options.events;
|
||||||
|
this.navEvents = _.clone(Backbone.Events);
|
||||||
|
|
||||||
this.JSON = {
|
this.JSON = {
|
||||||
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
||||||
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
||||||
|
@ -15315,7 +15331,17 @@ var MultiView = Backbone.View.extend({
|
||||||
}, this), this.navEventDebounce, true);
|
}, this), this.navEventDebounce, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lock: function() {
|
||||||
|
this.locked = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
unlock: function() {
|
||||||
|
this.locked = false;
|
||||||
|
},
|
||||||
|
|
||||||
navForward: function() {
|
navForward: function() {
|
||||||
|
// we need to prevent nav changes when a git demonstration view hasnt finished
|
||||||
|
if (this.locked) { return; }
|
||||||
if (this.currentIndex === this.childViews.length - 1) {
|
if (this.currentIndex === this.childViews.length - 1) {
|
||||||
this.hideViewIndex(this.currentIndex);
|
this.hideViewIndex(this.currentIndex);
|
||||||
this.finish();
|
this.finish();
|
||||||
|
@ -15386,6 +15412,9 @@ var MultiView = Backbone.View.extend({
|
||||||
showLeft: (index !== 0),
|
showLeft: (index !== 0),
|
||||||
lastNav: (index === this.childViewJSONs.length - 1)
|
lastNav: (index === this.childViewJSONs.length - 1)
|
||||||
});
|
});
|
||||||
|
if (view.receiveMetaNav) {
|
||||||
|
view.receiveMetaNav(leftRight, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
@ -15480,12 +15509,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
receiveMetaNav: function(navView, metaContainerView) {
|
||||||
|
var _this = this;
|
||||||
|
navView.navEvents.on('positive', this.positive, this);
|
||||||
|
this.metaContainerView = metaContainerView;
|
||||||
|
},
|
||||||
|
|
||||||
checkScroll: function() {
|
checkScroll: function() {
|
||||||
console.log('checking scroll');
|
|
||||||
var children = this.$('div.demonstrationText').children();
|
var children = this.$('div.demonstrationText').children();
|
||||||
var heights = _.map(children, function(child) { return child.clientHeight; });
|
var heights = _.map(children, function(child) { return child.clientHeight; });
|
||||||
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
||||||
console.log(children, heights, totalHeight);
|
|
||||||
if (totalHeight < this.$('div.demonstrationText').height()) {
|
if (totalHeight < this.$('div.demonstrationText').height()) {
|
||||||
this.$('div.demonstrationText').addClass('noLongText');
|
this.$('div.demonstrationText').addClass('noLongText');
|
||||||
}
|
}
|
||||||
|
@ -15508,12 +15541,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
this.hasControl = true;
|
this.hasControl = true;
|
||||||
this.keyboardListener.listen();
|
this.keyboardListener.listen();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.lock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseControl: function() {
|
releaseControl: function() {
|
||||||
if (!this.hasControl) { return; }
|
if (!this.hasControl) { return; }
|
||||||
this.hasControl = false;
|
this.hasControl = false;
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.unlock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
|
@ -15524,11 +15561,17 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
positive: function() {
|
positive: function() {
|
||||||
if (this.demonstrated) {
|
if (this.demonstrated || !this.hasControl) {
|
||||||
|
// dont do anything if we are demonstrating, and if
|
||||||
|
// we receive a meta nav event and we aren't listening,
|
||||||
|
// then dont do anything either
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.demonstrated = true;
|
this.demonstrated = true;
|
||||||
|
this.demonstrate();
|
||||||
|
},
|
||||||
|
|
||||||
|
demonstrate: function() {
|
||||||
this.$el.toggleClass('demonstrating', true);
|
this.$el.toggleClass('demonstrating', true);
|
||||||
|
|
||||||
var whenDone = Q.defer();
|
var whenDone = Q.defer();
|
||||||
|
@ -22392,12 +22435,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
receiveMetaNav: function(navView, metaContainerView) {
|
||||||
|
var _this = this;
|
||||||
|
navView.navEvents.on('positive', this.positive, this);
|
||||||
|
this.metaContainerView = metaContainerView;
|
||||||
|
},
|
||||||
|
|
||||||
checkScroll: function() {
|
checkScroll: function() {
|
||||||
console.log('checking scroll');
|
|
||||||
var children = this.$('div.demonstrationText').children();
|
var children = this.$('div.demonstrationText').children();
|
||||||
var heights = _.map(children, function(child) { return child.clientHeight; });
|
var heights = _.map(children, function(child) { return child.clientHeight; });
|
||||||
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
||||||
console.log(children, heights, totalHeight);
|
|
||||||
if (totalHeight < this.$('div.demonstrationText').height()) {
|
if (totalHeight < this.$('div.demonstrationText').height()) {
|
||||||
this.$('div.demonstrationText').addClass('noLongText');
|
this.$('div.demonstrationText').addClass('noLongText');
|
||||||
}
|
}
|
||||||
|
@ -22420,12 +22467,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
this.hasControl = true;
|
this.hasControl = true;
|
||||||
this.keyboardListener.listen();
|
this.keyboardListener.listen();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.lock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseControl: function() {
|
releaseControl: function() {
|
||||||
if (!this.hasControl) { return; }
|
if (!this.hasControl) { return; }
|
||||||
this.hasControl = false;
|
this.hasControl = false;
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.unlock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
|
@ -22436,11 +22487,17 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
positive: function() {
|
positive: function() {
|
||||||
if (this.demonstrated) {
|
if (this.demonstrated || !this.hasControl) {
|
||||||
|
// dont do anything if we are demonstrating, and if
|
||||||
|
// we receive a meta nav event and we aren't listening,
|
||||||
|
// then dont do anything either
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.demonstrated = true;
|
this.demonstrated = true;
|
||||||
|
this.demonstrate();
|
||||||
|
},
|
||||||
|
|
||||||
|
demonstrate: function() {
|
||||||
this.$el.toggleClass('demonstrating', true);
|
this.$el.toggleClass('demonstrating', true);
|
||||||
|
|
||||||
var whenDone = Q.defer();
|
var whenDone = Q.defer();
|
||||||
|
@ -22699,13 +22756,29 @@ var LeftRightView = PositiveNegativeBase.extend({
|
||||||
'click .right': 'positive'
|
'click .right': 'positive'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
positive: function() {
|
||||||
|
this.pipeEvents.trigger('positive');
|
||||||
|
LeftRightView.__super__.positive.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
negative: function() {
|
||||||
|
this.pipeEvents.trigger('negative');
|
||||||
|
LeftRightView.__super__.negative.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
if (!options.destination || !options.events) {
|
if (!options.destination || !options.events) {
|
||||||
throw new Error('needmore');
|
throw new Error('needmore');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.destination = options.destination;
|
this.destination = options.destination;
|
||||||
this.navEvents = options.events;
|
|
||||||
|
// we switch to a system where every leftrightview has its own
|
||||||
|
// events system to add support for git demonstration view taking control of the
|
||||||
|
// click events
|
||||||
|
this.pipeEvents = options.events;
|
||||||
|
this.navEvents = _.clone(Backbone.Events);
|
||||||
|
|
||||||
this.JSON = {
|
this.JSON = {
|
||||||
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
||||||
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
||||||
|
@ -23575,7 +23648,17 @@ var MultiView = Backbone.View.extend({
|
||||||
}, this), this.navEventDebounce, true);
|
}, this), this.navEventDebounce, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lock: function() {
|
||||||
|
this.locked = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
unlock: function() {
|
||||||
|
this.locked = false;
|
||||||
|
},
|
||||||
|
|
||||||
navForward: function() {
|
navForward: function() {
|
||||||
|
// we need to prevent nav changes when a git demonstration view hasnt finished
|
||||||
|
if (this.locked) { return; }
|
||||||
if (this.currentIndex === this.childViews.length - 1) {
|
if (this.currentIndex === this.childViews.length - 1) {
|
||||||
this.hideViewIndex(this.currentIndex);
|
this.hideViewIndex(this.currentIndex);
|
||||||
this.finish();
|
this.finish();
|
||||||
|
@ -23646,6 +23729,9 @@ var MultiView = Backbone.View.extend({
|
||||||
showLeft: (index !== 0),
|
showLeft: (index !== 0),
|
||||||
lastNav: (index === this.childViewJSONs.length - 1)
|
lastNav: (index === this.childViewJSONs.length - 1)
|
||||||
});
|
});
|
||||||
|
if (view.receiveMetaNav) {
|
||||||
|
view.receiveMetaNav(leftRight, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
|
@ -75,12 +75,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
receiveMetaNav: function(navView, metaContainerView) {
|
||||||
|
var _this = this;
|
||||||
|
navView.navEvents.on('positive', this.positive, this);
|
||||||
|
this.metaContainerView = metaContainerView;
|
||||||
|
},
|
||||||
|
|
||||||
checkScroll: function() {
|
checkScroll: function() {
|
||||||
console.log('checking scroll');
|
|
||||||
var children = this.$('div.demonstrationText').children();
|
var children = this.$('div.demonstrationText').children();
|
||||||
var heights = _.map(children, function(child) { return child.clientHeight; });
|
var heights = _.map(children, function(child) { return child.clientHeight; });
|
||||||
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
var totalHeight = _.reduce(heights, function(a, b) { return a + b; });
|
||||||
console.log(children, heights, totalHeight);
|
|
||||||
if (totalHeight < this.$('div.demonstrationText').height()) {
|
if (totalHeight < this.$('div.demonstrationText').height()) {
|
||||||
this.$('div.demonstrationText').addClass('noLongText');
|
this.$('div.demonstrationText').addClass('noLongText');
|
||||||
}
|
}
|
||||||
|
@ -103,12 +107,16 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
takeControl: function() {
|
takeControl: function() {
|
||||||
this.hasControl = true;
|
this.hasControl = true;
|
||||||
this.keyboardListener.listen();
|
this.keyboardListener.listen();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.lock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
releaseControl: function() {
|
releaseControl: function() {
|
||||||
if (!this.hasControl) { return; }
|
if (!this.hasControl) { return; }
|
||||||
this.hasControl = false;
|
this.hasControl = false;
|
||||||
this.keyboardListener.mute();
|
this.keyboardListener.mute();
|
||||||
|
|
||||||
|
if (this.metaContainerView) { this.metaContainerView.unlock(); }
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function() {
|
reset: function() {
|
||||||
|
@ -119,11 +127,17 @@ var GitDemonstrationView = ContainedBase.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
positive: function() {
|
positive: function() {
|
||||||
if (this.demonstrated) {
|
if (this.demonstrated || !this.hasControl) {
|
||||||
|
// dont do anything if we are demonstrating, and if
|
||||||
|
// we receive a meta nav event and we aren't listening,
|
||||||
|
// then dont do anything either
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.demonstrated = true;
|
this.demonstrated = true;
|
||||||
|
this.demonstrate();
|
||||||
|
},
|
||||||
|
|
||||||
|
demonstrate: function() {
|
||||||
this.$el.toggleClass('demonstrating', true);
|
this.$el.toggleClass('demonstrating', true);
|
||||||
|
|
||||||
var whenDone = Q.defer();
|
var whenDone = Q.defer();
|
||||||
|
|
|
@ -146,13 +146,29 @@ var LeftRightView = PositiveNegativeBase.extend({
|
||||||
'click .right': 'positive'
|
'click .right': 'positive'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
positive: function() {
|
||||||
|
this.pipeEvents.trigger('positive');
|
||||||
|
LeftRightView.__super__.positive.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
|
negative: function() {
|
||||||
|
this.pipeEvents.trigger('negative');
|
||||||
|
LeftRightView.__super__.negative.apply(this);
|
||||||
|
},
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
if (!options.destination || !options.events) {
|
if (!options.destination || !options.events) {
|
||||||
throw new Error('needmore');
|
throw new Error('needmore');
|
||||||
}
|
}
|
||||||
|
|
||||||
this.destination = options.destination;
|
this.destination = options.destination;
|
||||||
this.navEvents = options.events;
|
|
||||||
|
// we switch to a system where every leftrightview has its own
|
||||||
|
// events system to add support for git demonstration view taking control of the
|
||||||
|
// click events
|
||||||
|
this.pipeEvents = options.events;
|
||||||
|
this.navEvents = _.clone(Backbone.Events);
|
||||||
|
|
||||||
this.JSON = {
|
this.JSON = {
|
||||||
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
showLeft: (options.showLeft === undefined) ? true : options.showLeft,
|
||||||
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
lastNav: (options.lastNav === undefined) ? false : options.lastNav
|
||||||
|
|
|
@ -95,7 +95,17 @@ var MultiView = Backbone.View.extend({
|
||||||
}, this), this.navEventDebounce, true);
|
}, this), this.navEventDebounce, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
lock: function() {
|
||||||
|
this.locked = true;
|
||||||
|
},
|
||||||
|
|
||||||
|
unlock: function() {
|
||||||
|
this.locked = false;
|
||||||
|
},
|
||||||
|
|
||||||
navForward: function() {
|
navForward: function() {
|
||||||
|
// we need to prevent nav changes when a git demonstration view hasnt finished
|
||||||
|
if (this.locked) { return; }
|
||||||
if (this.currentIndex === this.childViews.length - 1) {
|
if (this.currentIndex === this.childViews.length - 1) {
|
||||||
this.hideViewIndex(this.currentIndex);
|
this.hideViewIndex(this.currentIndex);
|
||||||
this.finish();
|
this.finish();
|
||||||
|
@ -166,6 +176,9 @@ var MultiView = Backbone.View.extend({
|
||||||
showLeft: (index !== 0),
|
showLeft: (index !== 0),
|
||||||
lastNav: (index === this.childViewJSONs.length - 1)
|
lastNav: (index === this.childViewJSONs.length - 1)
|
||||||
});
|
});
|
||||||
|
if (view.receiveMetaNav) {
|
||||||
|
view.receiveMetaNav(leftRight, this);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
4
todo.txt
4
todo.txt
|
@ -6,8 +6,6 @@ Big Things
|
||||||
Medium things:
|
Medium things:
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
[ ] get automated SHA hash appending in the html source :OOOOO... template? or what?t
|
[ ] get automated SHA hash appending in the html source :OOOOO... template? or what?t
|
||||||
[ ] text grabber for commands
|
|
||||||
[ ] turn off button clicking for demonstration view :O
|
|
||||||
|
|
||||||
|
|
||||||
Cases to handle / things to edit
|
Cases to handle / things to edit
|
||||||
|
@ -34,6 +32,8 @@ Ideas for cleaning
|
||||||
Done things:
|
Done things:
|
||||||
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
(I only started this on Dec 17th 2012 to get a better sense of what was done)
|
||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
[x] turn off button clicking for demonstration view :O
|
||||||
|
[x] text grabber for commands
|
||||||
[x] way to close testing view
|
[x] way to close testing view
|
||||||
[x] allow demonstration view to have git commands beforehand
|
[x] allow demonstration view to have git commands beforehand
|
||||||
[x] demonstration builder progress
|
[x] demonstration builder progress
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue