diff --git a/build/bundle.js b/build/bundle.js index d828d32e..7303e125 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -4483,6 +4483,7 @@ var DisabledMap = require('../level/disabledMap').DisabledMap; var Command = require('../models/commandModel').Command; var GitShim = require('../git/gitShim').GitShim; +var Views = require('../views'); var ModalTerminal = require('../views').ModalTerminal; var ModalAlert = require('../views').ModalAlert; var MultiView = require('../views/multiView').MultiView; @@ -4643,8 +4644,10 @@ var Sandbox = Backbone.View.extend({ 'exit level': this.exitLevel, 'level': this.startLevel, 'sandbox': this.exitLevel, - 'levels': this.showLevels + 'levels': this.showLevels, + 'iosAlert': this.iosAlert }; + var method = commandMap[command.get('method')]; if (!method) { throw new Error('no method for that wut'); } @@ -4670,6 +4673,16 @@ var Sandbox = Backbone.View.extend({ } }, + iosAlert: function(command, deferred) { + var whenClosed = Q.defer(); + var view = new Views.iOSKeyboardView({ + deferred: whenClosed + }); + whenClosed.promise.then(function() { + command.finishWith(deferred); + }); + }, + delay: function(command, deferred) { var amount = parseInt(command.get('regexResults')[1], 10); setTimeout(function() { @@ -6393,17 +6406,13 @@ var init = function() { /* hacky demo functionality */ if (/\?demo/.test(window.location.href)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix"); + eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix; help"); }, 500); } - if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent) || true) { - var Views = require('../views'); + if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', 'iOS keyboardPop'); + eventBaton.trigger('commandSubmitted', 'iOS alert'); }, 600); - setTimeout(function() { - new Views.iOSKeyboardView(); - }, 1000); } }; @@ -9867,28 +9876,6 @@ var ModalAlert = ContainedBase.extend({ } }); -var iOSKeyboardView = Backbone.View.extend({ - initialize: function(options) { - options = options || {}; - this.deferred = options.deferred || Q.defer(); - - this.modalAlert = new ModalAlert({ - markdowns: [ - '## iOS device', - '', - 'On iOS, user input is needed to bring up the keyboard. Click ', - 'on this window to bring up the keyboard so you can type commands' - ] - }); - this.modalAlert.container.navEvents.on('click', this.clicked, this); - }, - - clicked: function() { - this.modalAlert.die(); - $('#commandTextField').focus(); - } -}); - var ConfirmCancelTerminal = Backbone.View.extend({ initialize: function(options) { options = options || {}; @@ -9900,7 +9887,6 @@ var ConfirmCancelTerminal = Backbone.View.extend({ options.modalAlert )); - var buttonDefer = Q.defer(); this.buttonDefer = buttonDefer; this.confirmCancel = new ConfirmCancelView({ @@ -9966,6 +9952,23 @@ var ConfirmCancelTerminal = Backbone.View.extend({ } }); +var iOSKeyboardView = ConfirmCancelTerminal.extend({ + initialize: function(options) { + options = options || {}; + options.modalAlert = { + markdowns: [ + '## iOS device', + '', + "On iOS, javascript can't bring up the software keyboard so unfortunately ", + "there's no way for you to enter commands :-/ Try visiting the site on desktop ", + "to get the full experience, or submit a pull request if you have an idea on how ", + "to integrate user input on iOS" + ] + }; + ConfirmCancelTerminal.prototype.initialize.apply(this, [options]); + } +}); + var NextLevelConfirm = ConfirmCancelTerminal.extend({ initialize: function(options) { options = options || {}; @@ -12920,7 +12923,8 @@ var regexMap = { 'exit level': /^exit level($|\s)/, 'sandbox': /^sandbox($|\s)/, 'level': /^level\s?([a-zA-Z0-9]*)/, - 'levels': /^levels($|\s)/ + 'levels': /^levels($|\s)/, + 'iosAlert': /^iOS alert($|\s)/ }; var parse = function(str) { @@ -16716,17 +16720,13 @@ var init = function() { /* hacky demo functionality */ if (/\?demo/.test(window.location.href)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix"); + eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix; help"); }, 500); } - if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent) || true) { - var Views = require('../views'); + if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', 'iOS keyboardPop'); + eventBaton.trigger('commandSubmitted', 'iOS alert'); }, 600); - setTimeout(function() { - new Views.iOSKeyboardView(); - }, 1000); } }; @@ -19766,6 +19766,7 @@ var DisabledMap = require('../level/disabledMap').DisabledMap; var Command = require('../models/commandModel').Command; var GitShim = require('../git/gitShim').GitShim; +var Views = require('../views'); var ModalTerminal = require('../views').ModalTerminal; var ModalAlert = require('../views').ModalAlert; var MultiView = require('../views/multiView').MultiView; @@ -19926,8 +19927,10 @@ var Sandbox = Backbone.View.extend({ 'exit level': this.exitLevel, 'level': this.startLevel, 'sandbox': this.exitLevel, - 'levels': this.showLevels + 'levels': this.showLevels, + 'iosAlert': this.iosAlert }; + var method = commandMap[command.get('method')]; if (!method) { throw new Error('no method for that wut'); } @@ -19953,6 +19956,16 @@ var Sandbox = Backbone.View.extend({ } }, + iosAlert: function(command, deferred) { + var whenClosed = Q.defer(); + var view = new Views.iOSKeyboardView({ + deferred: whenClosed + }); + whenClosed.promise.then(function() { + command.finishWith(deferred); + }); + }, + delay: function(command, deferred) { var amount = parseInt(command.get('regexResults')[1], 10); setTimeout(function() { @@ -20031,7 +20044,8 @@ var regexMap = { 'exit level': /^exit level($|\s)/, 'sandbox': /^sandbox($|\s)/, 'level': /^level\s?([a-zA-Z0-9]*)/, - 'levels': /^levels($|\s)/ + 'levels': /^levels($|\s)/, + 'iosAlert': /^iOS alert($|\s)/ }; var parse = function(str) { @@ -21684,28 +21698,6 @@ var ModalAlert = ContainedBase.extend({ } }); -var iOSKeyboardView = Backbone.View.extend({ - initialize: function(options) { - options = options || {}; - this.deferred = options.deferred || Q.defer(); - - this.modalAlert = new ModalAlert({ - markdowns: [ - '## iOS device', - '', - 'On iOS, user input is needed to bring up the keyboard. Click ', - 'on this window to bring up the keyboard so you can type commands' - ] - }); - this.modalAlert.container.navEvents.on('click', this.clicked, this); - }, - - clicked: function() { - this.modalAlert.die(); - $('#commandTextField').focus(); - } -}); - var ConfirmCancelTerminal = Backbone.View.extend({ initialize: function(options) { options = options || {}; @@ -21717,7 +21709,6 @@ var ConfirmCancelTerminal = Backbone.View.extend({ options.modalAlert )); - var buttonDefer = Q.defer(); this.buttonDefer = buttonDefer; this.confirmCancel = new ConfirmCancelView({ @@ -21783,6 +21774,23 @@ var ConfirmCancelTerminal = Backbone.View.extend({ } }); +var iOSKeyboardView = ConfirmCancelTerminal.extend({ + initialize: function(options) { + options = options || {}; + options.modalAlert = { + markdowns: [ + '## iOS device', + '', + "On iOS, javascript can't bring up the software keyboard so unfortunately ", + "there's no way for you to enter commands :-/ Try visiting the site on desktop ", + "to get the full experience, or submit a pull request if you have an idea on how ", + "to integrate user input on iOS" + ] + }; + ConfirmCancelTerminal.prototype.initialize.apply(this, [options]); + } +}); + var NextLevelConfirm = ConfirmCancelTerminal.extend({ initialize: function(options) { options = options || {}; diff --git a/src/js/app/index.js b/src/js/app/index.js index a30cc70f..a8c95453 100644 --- a/src/js/app/index.js +++ b/src/js/app/index.js @@ -119,17 +119,13 @@ var init = function() { /* hacky demo functionality */ if (/\?demo/.test(window.location.href)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix"); + eventBaton.trigger('commandSubmitted', "gc; git checkout HEAD~1; git commit; git checkout -b bugFix; gc; gc; git rebase -i HEAD~2; git rebase master; git checkout master; gc; gc; git merge bugFix; help"); }, 500); } - if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent) || true) { - var Views = require('../views'); + if (/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent)) { setTimeout(function() { - eventBaton.trigger('commandSubmitted', 'iOS keyboardPop'); + eventBaton.trigger('commandSubmitted', 'iOS alert'); }, 600); - setTimeout(function() { - new Views.iOSKeyboardView(); - }, 1000); } }; diff --git a/src/js/level/sandbox.js b/src/js/level/sandbox.js index a9175694..dd94fce7 100644 --- a/src/js/level/sandbox.js +++ b/src/js/level/sandbox.js @@ -12,6 +12,7 @@ var DisabledMap = require('../level/disabledMap').DisabledMap; var Command = require('../models/commandModel').Command; var GitShim = require('../git/gitShim').GitShim; +var Views = require('../views'); var ModalTerminal = require('../views').ModalTerminal; var ModalAlert = require('../views').ModalAlert; var MultiView = require('../views/multiView').MultiView; @@ -172,8 +173,10 @@ var Sandbox = Backbone.View.extend({ 'exit level': this.exitLevel, 'level': this.startLevel, 'sandbox': this.exitLevel, - 'levels': this.showLevels + 'levels': this.showLevels, + 'iosAlert': this.iosAlert }; + var method = commandMap[command.get('method')]; if (!method) { throw new Error('no method for that wut'); } @@ -199,6 +202,16 @@ var Sandbox = Backbone.View.extend({ } }, + iosAlert: function(command, deferred) { + var whenClosed = Q.defer(); + var view = new Views.iOSKeyboardView({ + deferred: whenClosed + }); + whenClosed.promise.then(function() { + command.finishWith(deferred); + }); + }, + delay: function(command, deferred) { var amount = parseInt(command.get('regexResults')[1], 10); setTimeout(function() { diff --git a/src/js/level/sandboxCommands.js b/src/js/level/sandboxCommands.js index ac721b09..897a21ad 100644 --- a/src/js/level/sandboxCommands.js +++ b/src/js/level/sandboxCommands.js @@ -44,7 +44,8 @@ var regexMap = { 'exit level': /^exit level($|\s)/, 'sandbox': /^sandbox($|\s)/, 'level': /^level\s?([a-zA-Z0-9]*)/, - 'levels': /^levels($|\s)/ + 'levels': /^levels($|\s)/, + 'iosAlert': /^iOS alert($|\s)/ }; var parse = function(str) { diff --git a/src/js/views/index.js b/src/js/views/index.js index 3d537fe4..e7b97358 100644 --- a/src/js/views/index.js +++ b/src/js/views/index.js @@ -288,28 +288,6 @@ var ModalAlert = ContainedBase.extend({ } }); -var iOSKeyboardView = Backbone.View.extend({ - initialize: function(options) { - options = options || {}; - this.deferred = options.deferred || Q.defer(); - - this.modalAlert = new ModalAlert({ - markdowns: [ - '## iOS device', - '', - 'On iOS, user input is needed to bring up the keyboard. Click ', - 'on this window to bring up the keyboard so you can type commands' - ] - }); - this.modalAlert.container.navEvents.on('click', this.clicked, this); - }, - - clicked: function() { - this.modalAlert.die(); - $('#commandTextField').focus(); - } -}); - var ConfirmCancelTerminal = Backbone.View.extend({ initialize: function(options) { options = options || {}; @@ -321,7 +299,6 @@ var ConfirmCancelTerminal = Backbone.View.extend({ options.modalAlert )); - var buttonDefer = Q.defer(); this.buttonDefer = buttonDefer; this.confirmCancel = new ConfirmCancelView({ @@ -387,6 +364,23 @@ var ConfirmCancelTerminal = Backbone.View.extend({ } }); +var iOSKeyboardView = ConfirmCancelTerminal.extend({ + initialize: function(options) { + options = options || {}; + options.modalAlert = { + markdowns: [ + '## iOS device', + '', + "On iOS, javascript can't bring up the software keyboard so unfortunately ", + "there's no way for you to enter commands :-/ Try visiting the site on desktop ", + "to get the full experience, or submit a pull request if you have an idea on how ", + "to integrate user input on iOS" + ] + }; + ConfirmCancelTerminal.prototype.initialize.apply(this, [options]); + } +}); + var NextLevelConfirm = ConfirmCancelTerminal.extend({ initialize: function(options) { options = options || {};