diff --git a/build/bundle.js b/build/bundle.js index 175e8ada..314d7c3b 100644 --- a/build/bundle.js +++ b/build/bundle.js @@ -6499,7 +6499,7 @@ var Level = Sandbox.extend({ }, this), this.getAnimationTime() * 1.2); }, - initName: function(options) { + initName: function() { if (!this.level.name || !this.level.id) { this.level.name = 'Rebase Classic'; console.warn('REALLY BAD FORM need ids and names'); @@ -10130,7 +10130,7 @@ KeyboardListener.prototype.mute = function() { }; KeyboardListener.prototype.keydown = function(e) { - var which = e.which; + var which = e.which || e.keyCode; var key = mapKeycodeToKey(which); if (key === undefined) { @@ -14460,16 +14460,22 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { var textNode = visBranch.get('text').node; - return (textNode === null) ? 1 : textNode.clientWidth; + return (textNode === null) ? 0 : textNode.clientWidth; + }; + + var firefoxFix = function(obj) { + if (!obj.w) { obj.w = 75; } + if (!obj.h) { obj.h = 20; } + return obj; }; var textNode = this.get('text').node; if (this.get('isHead')) { // HEAD is a special case - return { + return firefoxFix({ w: textNode.clientWidth, h: textNode.clientHeight - }; + }); } var maxWidth = 0; @@ -14478,11 +14484,12 @@ var VisBranch = VisBase.extend({ branch.obj.get('visBranch') )); }); + console.log('getting text size', textNode, 'width', textNode.clientWidth); - return { + return firefoxFix({ w: maxWidth, h: textNode.clientHeight - }; + }); }, getSingleRectSize: function() { @@ -16086,11 +16093,16 @@ var CommandPromptView = Backbone.View.extend({ }, onKeyDown: function(e) { + console.log('on keydown'); + console.log(e); + var el = e.srcElement; this.updatePrompt(el); }, onKeyUp: function(e) { + console.log('on key up'); + console.log(e); this.onKeyDown(e); // we need to capture some of these events. @@ -16106,7 +16118,7 @@ var CommandPromptView = Backbone.View.extend({ }, this) }; - var key = keyboard.mapKeycodeToKey(e.which); + var key = keyboard.mapKeycodeToKey(e.which || e.keyCode); if (keyToFuncMap[key] !== undefined) { e.preventDefault(); keyToFuncMap[key](); @@ -16123,6 +16135,7 @@ var CommandPromptView = Backbone.View.extend({ }, updatePrompt: function(el) { + el = el || {}; // firefox // i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this // super annoying delay to every keystroke... I have tried everything // to make this more performant. getting the srcElement from the event, @@ -16130,16 +16143,22 @@ var CommandPromptView = Backbone.View.extend({ // there's a very annoying and sightly noticeable command delay. // try.github.com also has this, so I'm assuming those engineers gave up as // well... - var val = this.badHtmlEncode(el.value); + var text = $('#commandTextField').val(); + var val = this.badHtmlEncode(text); this.commandSpan.innerHTML = val; // now mutate the cursor... - this.cursorUpdate(el.value.length, el.selectionStart, el.selectionEnd); + this.cursorUpdate(text.length, el.selectionStart, el.selectionEnd); // and scroll down due to some weird bug Main.getEvents().trigger('commandScrollDown'); }, cursorUpdate: function(commandLength, selectionStart, selectionEnd) { + if (selectionStart === undefined || selectionEnd === undefined) { + selectionStart = 0; + selectionEnd = 1; + } + // 10px for monospaced font at "1" zoom var zoom = require('../util/zoomLevel').detectZoom(); var widthPerChar = 10 * zoom; @@ -16148,7 +16167,7 @@ var CommandPromptView = Backbone.View.extend({ var width = String(numCharsSelected * widthPerChar) + 'px'; // now for positioning - var numLeft = Math.max(commandLength - selectionStart, 0); + var numLeft = (selectionStart !== undefined) ? Math.max(commandLength - selectionStart, 0) : 0; var left = String(-numLeft * widthPerChar) + 'px'; // one reflow? :D $(this.commandCursor).css({ @@ -18977,6 +18996,61 @@ exports.LevelArbiter = LevelArbiter; }); require("/src/js/level/arbiter.js"); +require.define("/src/js/level/builder.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); +var Backbone = require('backbone'); +var Q = require('q'); + +var util = require('../util'); +var Main = require('../app'); + +var Visualization = require('../visuals/visualization').Visualization; +var ParseWaterfall = require('../level/parseWaterfall').ParseWaterfall; +var Level = require('../level').Level; + +var Command = require('../models/commandModel').Command; +var GitShim = require('../git/gitShim').GitShim; + +var MultiView = require('../views/multiView').MultiView; +var CanvasTerminalHolder = require('../views').CanvasTerminalHolder; +var ConfirmCancelTerminal = require('../views').ConfirmCancelTerminal; +var NextLevelConfirm = require('../views').NextLevelConfirm; +var LevelToolbar = require('../views').LevelToolbar; + +var LevelBuilder = Level.extend({ + initialize: function(options) { + options = options || {}; + this.options = options; + this.level = {}; + + this.levelToolbar = new LevelToolbar({ + name: 'Level Builder' + }); + + this.level.startDialog = { + }; + + // call our grandparent, not us + Level.__super__.initialize.apply(this, [options]); + }, + + takeControl: function() { + Main.getEventBaton().stealBaton('processLevelBuilderCommand', this.processLevelCommand, this); + + LevelBuilder.__super__.takeControl.apply(this); + }, + + releaseControl: function() { + Main.getEventBaton().releaseBaton('processLevelBuilderCommand', this.processLevelCommand, this); + + LevelBuilder.__super__.releaseControl.apply(this); + } +}); + +exports.LevelBuilder = LevelBuilder; + +}); +require("/src/js/level/builder.js"); + require.define("/src/js/level/commands.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); var regexMap = { @@ -19118,7 +19192,7 @@ var Level = Sandbox.extend({ }, this), this.getAnimationTime() * 1.2); }, - initName: function(options) { + initName: function() { if (!this.level.name || !this.level.id) { this.level.name = 'Rebase Classic'; console.warn('REALLY BAD FORM need ids and names'); @@ -20509,7 +20583,7 @@ KeyboardListener.prototype.mute = function() { }; KeyboardListener.prototype.keydown = function(e) { - var which = e.which; + var which = e.which || e.keyCode; var key = mapKeycodeToKey(which); if (key === undefined) { @@ -20678,11 +20752,16 @@ var CommandPromptView = Backbone.View.extend({ }, onKeyDown: function(e) { + console.log('on keydown'); + console.log(e); + var el = e.srcElement; this.updatePrompt(el); }, onKeyUp: function(e) { + console.log('on key up'); + console.log(e); this.onKeyDown(e); // we need to capture some of these events. @@ -20698,7 +20777,7 @@ var CommandPromptView = Backbone.View.extend({ }, this) }; - var key = keyboard.mapKeycodeToKey(e.which); + var key = keyboard.mapKeycodeToKey(e.which || e.keyCode); if (keyToFuncMap[key] !== undefined) { e.preventDefault(); keyToFuncMap[key](); @@ -20715,6 +20794,7 @@ var CommandPromptView = Backbone.View.extend({ }, updatePrompt: function(el) { + el = el || {}; // firefox // i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this // super annoying delay to every keystroke... I have tried everything // to make this more performant. getting the srcElement from the event, @@ -20722,16 +20802,22 @@ var CommandPromptView = Backbone.View.extend({ // there's a very annoying and sightly noticeable command delay. // try.github.com also has this, so I'm assuming those engineers gave up as // well... - var val = this.badHtmlEncode(el.value); + var text = $('#commandTextField').val(); + var val = this.badHtmlEncode(text); this.commandSpan.innerHTML = val; // now mutate the cursor... - this.cursorUpdate(el.value.length, el.selectionStart, el.selectionEnd); + this.cursorUpdate(text.length, el.selectionStart, el.selectionEnd); // and scroll down due to some weird bug Main.getEvents().trigger('commandScrollDown'); }, cursorUpdate: function(commandLength, selectionStart, selectionEnd) { + if (selectionStart === undefined || selectionEnd === undefined) { + selectionStart = 0; + selectionEnd = 1; + } + // 10px for monospaced font at "1" zoom var zoom = require('../util/zoomLevel').detectZoom(); var widthPerChar = 10 * zoom; @@ -20740,7 +20826,7 @@ var CommandPromptView = Backbone.View.extend({ var width = String(numCharsSelected * widthPerChar) + 'px'; // now for positioning - var numLeft = Math.max(commandLength - selectionStart, 0); + var numLeft = (selectionStart !== undefined) ? Math.max(commandLength - selectionStart, 0) : 0; var left = String(-numLeft * widthPerChar) + 'px'; // one reflow? :D $(this.commandCursor).css({ @@ -23785,16 +23871,22 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { var textNode = visBranch.get('text').node; - return (textNode === null) ? 1 : textNode.clientWidth; + return (textNode === null) ? 0 : textNode.clientWidth; + }; + + var firefoxFix = function(obj) { + if (!obj.w) { obj.w = 75; } + if (!obj.h) { obj.h = 20; } + return obj; }; var textNode = this.get('text').node; if (this.get('isHead')) { // HEAD is a special case - return { + return firefoxFix({ w: textNode.clientWidth, h: textNode.clientHeight - }; + }); } var maxWidth = 0; @@ -23803,11 +23895,12 @@ var VisBranch = VisBase.extend({ branch.obj.get('visBranch') )); }); + console.log('getting text size', textNode, 'width', textNode.clientWidth); - return { + return firefoxFix({ w: maxWidth, h: textNode.clientHeight - }; + }); }, getSingleRectSize: function() { diff --git a/src/js/level/builder.js b/src/js/level/builder.js index c5e11952..7e606422 100644 --- a/src/js/level/builder.js +++ b/src/js/level/builder.js @@ -45,7 +45,7 @@ var LevelBuilder = Level.extend({ Main.getEventBaton().releaseBaton('processLevelBuilderCommand', this.processLevelCommand, this); LevelBuilder.__super__.releaseControl.apply(this); - }, + } }); exports.LevelBuilder = LevelBuilder; diff --git a/src/js/util/keyboard.js b/src/js/util/keyboard.js index 5c6c5b1f..dcb77d89 100644 --- a/src/js/util/keyboard.js +++ b/src/js/util/keyboard.js @@ -39,7 +39,7 @@ KeyboardListener.prototype.mute = function() { }; KeyboardListener.prototype.keydown = function(e) { - var which = e.which; + var which = e.which || e.keyCode; var key = mapKeycodeToKey(which); if (key === undefined) { diff --git a/src/js/views/commandViews.js b/src/js/views/commandViews.js index 4e8ef111..4760f153 100644 --- a/src/js/views/commandViews.js +++ b/src/js/views/commandViews.js @@ -74,11 +74,16 @@ var CommandPromptView = Backbone.View.extend({ }, onKeyDown: function(e) { + console.log('on keydown'); + console.log(e); + var el = e.srcElement; this.updatePrompt(el); }, onKeyUp: function(e) { + console.log('on key up'); + console.log(e); this.onKeyDown(e); // we need to capture some of these events. @@ -94,7 +99,7 @@ var CommandPromptView = Backbone.View.extend({ }, this) }; - var key = keyboard.mapKeycodeToKey(e.which); + var key = keyboard.mapKeycodeToKey(e.which || e.keyCode); if (keyToFuncMap[key] !== undefined) { e.preventDefault(); keyToFuncMap[key](); @@ -111,6 +116,7 @@ var CommandPromptView = Backbone.View.extend({ }, updatePrompt: function(el) { + el = el || {}; // firefox // i WEEEPPPPPPpppppppppppp that this reflow takes so long. it adds this // super annoying delay to every keystroke... I have tried everything // to make this more performant. getting the srcElement from the event, @@ -118,16 +124,22 @@ var CommandPromptView = Backbone.View.extend({ // there's a very annoying and sightly noticeable command delay. // try.github.com also has this, so I'm assuming those engineers gave up as // well... - var val = this.badHtmlEncode(el.value); + var text = $('#commandTextField').val(); + var val = this.badHtmlEncode(text); this.commandSpan.innerHTML = val; // now mutate the cursor... - this.cursorUpdate(el.value.length, el.selectionStart, el.selectionEnd); + this.cursorUpdate(text.length, el.selectionStart, el.selectionEnd); // and scroll down due to some weird bug Main.getEvents().trigger('commandScrollDown'); }, cursorUpdate: function(commandLength, selectionStart, selectionEnd) { + if (selectionStart === undefined || selectionEnd === undefined) { + selectionStart = 0; + selectionEnd = 1; + } + // 10px for monospaced font at "1" zoom var zoom = require('../util/zoomLevel').detectZoom(); var widthPerChar = 10 * zoom; @@ -136,7 +148,7 @@ var CommandPromptView = Backbone.View.extend({ var width = String(numCharsSelected * widthPerChar) + 'px'; // now for positioning - var numLeft = Math.max(commandLength - selectionStart, 0); + var numLeft = (selectionStart !== undefined) ? Math.max(commandLength - selectionStart, 0) : 0; var left = String(-numLeft * widthPerChar) + 'px'; // one reflow? :D $(this.commandCursor).css({ diff --git a/src/js/visuals/visBranch.js b/src/js/visuals/visBranch.js index c066fb91..5db9b1a4 100644 --- a/src/js/visuals/visBranch.js +++ b/src/js/visuals/visBranch.js @@ -201,16 +201,22 @@ var VisBranch = VisBase.extend({ getTextSize: function() { var getTextWidth = function(visBranch) { var textNode = visBranch.get('text').node; - return (textNode === null) ? 1 : textNode.clientWidth; + return (textNode === null) ? 0 : textNode.clientWidth; + }; + + var firefoxFix = function(obj) { + if (!obj.w) { obj.w = 75; } + if (!obj.h) { obj.h = 20; } + return obj; }; var textNode = this.get('text').node; if (this.get('isHead')) { // HEAD is a special case - return { + return firefoxFix({ w: textNode.clientWidth, h: textNode.clientHeight - }; + }); } var maxWidth = 0; @@ -219,11 +225,12 @@ var VisBranch = VisBase.extend({ branch.obj.get('visBranch') )); }); + console.log('getting text size', textNode, 'width', textNode.clientWidth); - return { + return firefoxFix({ w: maxWidth, h: textNode.clientHeight - }; + }); }, getSingleRectSize: function() { diff --git a/src/style/main.css b/src/style/main.css index d9e4cc23..a7345dec 100644 --- a/src/style/main.css +++ b/src/style/main.css @@ -895,3 +895,17 @@ div.levelIcon.solved div.index div.indexNum { background: #9bcbeb; } +/* Go Home Firefox, you're drunk */ +@-moz-document url-prefix() { + body { + display: block; + width: 100%; + height: 100%; + } + + #interfaceWrapper { + width: 100%; + height: 100%; + } +} + diff --git a/todo.txt b/todo.txt index 2288412c..d144a31c 100644 --- a/todo.txt +++ b/todo.txt @@ -13,6 +13,7 @@ Cases to handle / things to edit Small things to implement: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +[ ] esc on multiview quits absolutely Minor Bugs to fix: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~