diff --git a/build/bundle.js b/build/bundle.js index 71b2e319..982484c2 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -15457,6 +15457,7 @@ var GitDemonstrationView = ContainedBase.extend({ title: options.title || 'Git Demonstration' }); this.render(); + this.checkScroll(); this.navEvents = _.clone(Backbone.Events); this.navEvents.on('positive', this.positive, this); @@ -15479,6 +15480,31 @@ var GitDemonstrationView = ContainedBase.extend({ } }, + checkScroll: function() { + console.log('checking scroll'); + var children = this.$('div.demonstrationText').children(); + var heights = _.map(children, function(child) { return child.clientHeight; }); + var totalHeight = _.reduce(heights, function(a, b) { return a + b; }); + console.log(children, heights, totalHeight); + if (totalHeight < this.$('div.demonstrationText').height()) { + this.$('div.demonstrationText').addClass('noLongText'); + } + }, + + dispatchBeforeCommand: function() { + if (!this.options.beforeCommand) { + return; + } + // here we just split the command and push them through to the git engine + util.splitTextCommand(this.options.beforeCommand, function(commandStr) { + this.mainVis.gitEngine.dispatch(new Command({ + rawStr: commandStr + }), Q.defer()); + }, this); + // then harsh refresh + this.mainVis.gitVisuals.refreshTreeHarsh(); + }, + takeControl: function() { this.hasControl = true; this.keyboardListener.listen(); @@ -15598,6 +15624,7 @@ var GitDemonstrationView = ContainedBase.extend({ }); this.mainVis.customEvents.on('paperReady', _.bind(function() { this.visFinished = true; + this.dispatchBeforeCommand(); if (this.shown) { // show the canvas once its done if we are shown this.show(); @@ -16977,6 +17004,41 @@ var Views = require('../views'); var ModalTerminal = Views.ModalTerminal; var ContainedBase = Views.ContainedBase; +var MultiView = require('../views/multiView').MultiView; + +var TextGrabber = ContainedBase.extend({ + tagName: 'div', + className: 'textGrabber box vertical', + template: _.template($('#text-grabber').html()), + + initialize: function(options) { + options = options || {}; + this.JSON = { + helperText: options.helperText || 'Enter some text' + }; + + this.container = options.container || new ModalTerminal({ + title: 'Enter some text' + }); + this.render(); + if (options.initialText) { + this.setText(options.initialText); + } + + if (!options.wait) { + this.show(); + } + }, + + getText: function() { + return this.$('textarea').val(); + }, + + setText: function(str) { + this.$('textarea').val(str); + } +}); + var MarkdownGrabber = ContainedBase.extend({ tagName: 'div', className: 'markdownGrabber box horizontal', @@ -17007,7 +17069,7 @@ var MarkdownGrabber = ContainedBase.extend({ var confirmCancel = new Views.ConfirmCancelView({ deferred: buttonDefer, - destination: this.getDestination() + destination: this }); } @@ -17074,6 +17136,18 @@ var DemonstrationBuilder = ContainedBase.extend({ withoutButton: true, previewText: 'Before demonstration Markdown' }); + this.beforeCommandView = new TextGrabber({ + container: this, + helperText: 'The git command(s) to set up the demonstration view (before it is displayed)', + initialText: 'git checkout -b bugFix' + }); + + this.commandView = new TextGrabber({ + container: this, + helperText: 'The git command(s) to demonstrate to the reader', + initialText: 'git commit' + }); + this.afterMarkdownView = new MarkdownGrabber({ container: this, withoutButton: true, @@ -17101,15 +17175,20 @@ var DemonstrationBuilder = ContainedBase.extend({ }, testView: function() { - var module = require('../views/gitDemonstrationView'); - new module.GitDemonstrationView(this.getExportObj()); + new MultiView({ + childViews: [{ + type: 'GitDemonstrationView', + options: this.getExportObj() + }] + }); }, getExportObj: function() { return { beforeMarkdowns: this.beforeMarkdownView.exportToArray(), afterMarkdowns: this.afterMarkdownView.exportToArray(), - gitCommand: 'git commit' + command: this.commandView.getText(), + beforeCommand: this.beforeCommandView.getText() }; }, @@ -17130,6 +17209,7 @@ var DemonstrationBuilder = ContainedBase.extend({ exports.MarkdownGrabber = MarkdownGrabber; exports.DemonstrationBuilder = DemonstrationBuilder; +exports.TextGrabber = TextGrabber; }); @@ -21638,6 +21718,41 @@ var Views = require('../views'); var ModalTerminal = Views.ModalTerminal; var ContainedBase = Views.ContainedBase; +var MultiView = require('../views/multiView').MultiView; + +var TextGrabber = ContainedBase.extend({ + tagName: 'div', + className: 'textGrabber box vertical', + template: _.template($('#text-grabber').html()), + + initialize: function(options) { + options = options || {}; + this.JSON = { + helperText: options.helperText || 'Enter some text' + }; + + this.container = options.container || new ModalTerminal({ + title: 'Enter some text' + }); + this.render(); + if (options.initialText) { + this.setText(options.initialText); + } + + if (!options.wait) { + this.show(); + } + }, + + getText: function() { + return this.$('textarea').val(); + }, + + setText: function(str) { + this.$('textarea').val(str); + } +}); + var MarkdownGrabber = ContainedBase.extend({ tagName: 'div', className: 'markdownGrabber box horizontal', @@ -21668,7 +21783,7 @@ var MarkdownGrabber = ContainedBase.extend({ var confirmCancel = new Views.ConfirmCancelView({ deferred: buttonDefer, - destination: this.getDestination() + destination: this }); } @@ -21735,6 +21850,18 @@ var DemonstrationBuilder = ContainedBase.extend({ withoutButton: true, previewText: 'Before demonstration Markdown' }); + this.beforeCommandView = new TextGrabber({ + container: this, + helperText: 'The git command(s) to set up the demonstration view (before it is displayed)', + initialText: 'git checkout -b bugFix' + }); + + this.commandView = new TextGrabber({ + container: this, + helperText: 'The git command(s) to demonstrate to the reader', + initialText: 'git commit' + }); + this.afterMarkdownView = new MarkdownGrabber({ container: this, withoutButton: true, @@ -21762,15 +21889,20 @@ var DemonstrationBuilder = ContainedBase.extend({ }, testView: function() { - var module = require('../views/gitDemonstrationView'); - new module.GitDemonstrationView(this.getExportObj()); + new MultiView({ + childViews: [{ + type: 'GitDemonstrationView', + options: this.getExportObj() + }] + }); }, getExportObj: function() { return { beforeMarkdowns: this.beforeMarkdownView.exportToArray(), afterMarkdowns: this.afterMarkdownView.exportToArray(), - gitCommand: 'git commit' + command: this.commandView.getText(), + beforeCommand: this.beforeCommandView.getText() }; }, @@ -21791,6 +21923,7 @@ var DemonstrationBuilder = ContainedBase.extend({ exports.MarkdownGrabber = MarkdownGrabber; exports.DemonstrationBuilder = DemonstrationBuilder; +exports.TextGrabber = TextGrabber; }); @@ -22236,6 +22369,7 @@ var GitDemonstrationView = ContainedBase.extend({ title: options.title || 'Git Demonstration' }); this.render(); + this.checkScroll(); this.navEvents = _.clone(Backbone.Events); this.navEvents.on('positive', this.positive, this); @@ -22258,6 +22392,31 @@ var GitDemonstrationView = ContainedBase.extend({ } }, + checkScroll: function() { + console.log('checking scroll'); + var children = this.$('div.demonstrationText').children(); + var heights = _.map(children, function(child) { return child.clientHeight; }); + var totalHeight = _.reduce(heights, function(a, b) { return a + b; }); + console.log(children, heights, totalHeight); + if (totalHeight < this.$('div.demonstrationText').height()) { + this.$('div.demonstrationText').addClass('noLongText'); + } + }, + + dispatchBeforeCommand: function() { + if (!this.options.beforeCommand) { + return; + } + // here we just split the command and push them through to the git engine + util.splitTextCommand(this.options.beforeCommand, function(commandStr) { + this.mainVis.gitEngine.dispatch(new Command({ + rawStr: commandStr + }), Q.defer()); + }, this); + // then harsh refresh + this.mainVis.gitVisuals.refreshTreeHarsh(); + }, + takeControl: function() { this.hasControl = true; this.keyboardListener.listen(); @@ -22377,6 +22536,7 @@ var GitDemonstrationView = ContainedBase.extend({ }); this.mainVis.customEvents.on('paperReady', _.bind(function() { this.visFinished = true; + this.dispatchBeforeCommand(); if (this.shown) { // show the canvas once its done if we are shown this.show(); diff --git a/index.html b/index.html index 9297a581..63e3d81f 100644 --- a/index.html +++ b/index.html @@ -204,19 +204,19 @@ + +