markdown grabber

This commit is contained in:
Peter Cottle 2013-01-09 14:37:08 -08:00
parent 36bfd99d9e
commit 3ade2bdd71
8 changed files with 329 additions and 12 deletions

View file

@ -9662,8 +9662,7 @@ exports.InteractiveRebaseView = InteractiveRebaseView;
}); });
require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var _ = require('underscore');
var Q = require('q'); var Q = require('q');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
@ -9671,6 +9670,7 @@ var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.
var Main = require('../app'); var Main = require('../app');
var Constants = require('../util/constants'); var Constants = require('../util/constants');
var KeyboardListener = require('../util/keyboard').KeyboardListener; var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var BaseView = Backbone.View.extend({ var BaseView = Backbone.View.extend({
getDestination: function() { getDestination: function() {
@ -16096,7 +16096,6 @@ var SeriesView = BaseView.extend({
// property changing but it's the 11th hour... // property changing but it's the 11th hour...
var toLoop = this.$('div.levelIcon').each(function(index, el) { var toLoop = this.$('div.levelIcon').each(function(index, el) {
var id = $(el).attr('data-id'); var id = $(el).attr('data-id');
console.log('updating id', id);
$(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id)); $(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id));
}); });
}, },
@ -16920,6 +16919,97 @@ HeadlessGit.prototype.sendCommand = function(value) {
exports.HeadlessGit = HeadlessGit; exports.HeadlessGit = HeadlessGit;
});
require.define("/src/js/views/builderViews.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var util = require('../util');
var KeyboardListener = require('../util/keyboard').KeyboardListener;
var Views = require('../views');
var ModalTerminal = Views.ModalTerminal;
var ContainedBase = Views.ContainedBase;
var MarkdownGrabber = ContainedBase.extend({
tagName: 'div',
className: 'MarkdownGrabber box horizontal',
template: _.template($('#markdown-grabber-view').html()),
events: {
'keyup textarea': 'keyup'
},
initialize: function(options) {
options = options || {};
this.deferred = options.deferred || Q.defer();
this.options = options;
this.JSON = {};
this.container = new ModalTerminal({
title: options.title || 'Enter some markdown'
});
this.render();
if (!options.withoutButton) {
// do button stuff
var buttonDefer = Q.defer();
buttonDefer.promise
.then(_.bind(function() {
this.confirmed();
}, this))
.fail(_.bind(function() {
this.cancelled();
}, this))
.done();
var confirmCancel = new Views.ConfirmCancelView({
deferred: buttonDefer,
destination: this.getDestination()
});
}
this.updatePreview();
if (!options.wait) {
this.show();
}
},
confirmed: function() {
this.die();
this.deferred.resolve(this.getRawText());
},
cancelled: function() {
this.die();
this.deferred.resolve();
},
keyup: function() {
if (!this.throttledPreview) {
this.throttledPreview = _.throttle(
_.bind(this.updatePreview, this),
500
);
}
this.throttledPreview();
},
getRawText: function() {
return this.$('textarea').val();
},
updatePreview: function() {
var raw = this.getRawText();
var HTML = require('markdown').markdown.toHTML(raw);
this.$('div.insidePreview').html(HTML);
}
});
exports.MarkdownGrabber = MarkdownGrabber;
}); });
require.define("/src/js/app/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); require.define("/src/js/app/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
@ -21031,7 +21121,8 @@ var toGlobalize = {
Sandbox: require('../level/sandbox'), Sandbox: require('../level/sandbox'),
GitDemonstrationView: require('../views/gitDemonstrationView'), GitDemonstrationView: require('../views/gitDemonstrationView'),
Markdown: require('markdown'), Markdown: require('markdown'),
LevelDropdownView: require('../views/levelDropdownView') LevelDropdownView: require('../views/levelDropdownView'),
BuilderViews: require('../views/builderViews')
}; };
_.each(toGlobalize, function(module) { _.each(toGlobalize, function(module) {
@ -21413,6 +21504,98 @@ exports.detectZoom = detectZoom;
}); });
require("/src/js/util/zoomLevel.js"); require("/src/js/util/zoomLevel.js");
require.define("/src/js/views/builderViews.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var util = require('../util');
var KeyboardListener = require('../util/keyboard').KeyboardListener;
var Views = require('../views');
var ModalTerminal = Views.ModalTerminal;
var ContainedBase = Views.ContainedBase;
var MarkdownGrabber = ContainedBase.extend({
tagName: 'div',
className: 'MarkdownGrabber box horizontal',
template: _.template($('#markdown-grabber-view').html()),
events: {
'keyup textarea': 'keyup'
},
initialize: function(options) {
options = options || {};
this.deferred = options.deferred || Q.defer();
this.options = options;
this.JSON = {};
this.container = new ModalTerminal({
title: options.title || 'Enter some markdown'
});
this.render();
if (!options.withoutButton) {
// do button stuff
var buttonDefer = Q.defer();
buttonDefer.promise
.then(_.bind(function() {
this.confirmed();
}, this))
.fail(_.bind(function() {
this.cancelled();
}, this))
.done();
var confirmCancel = new Views.ConfirmCancelView({
deferred: buttonDefer,
destination: this.getDestination()
});
}
this.updatePreview();
if (!options.wait) {
this.show();
}
},
confirmed: function() {
this.die();
this.deferred.resolve(this.getRawText());
},
cancelled: function() {
this.die();
this.deferred.resolve();
},
keyup: function() {
if (!this.throttledPreview) {
this.throttledPreview = _.throttle(
_.bind(this.updatePreview, this),
500
);
}
this.throttledPreview();
},
getRawText: function() {
return this.$('textarea').val();
},
updatePreview: function() {
var raw = this.getRawText();
var HTML = require('markdown').markdown.toHTML(raw);
this.$('div.insidePreview').html(HTML);
}
});
exports.MarkdownGrabber = MarkdownGrabber;
});
require("/src/js/views/builderViews.js");
require.define("/src/js/views/commandViews.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore'); require.define("/src/js/views/commandViews.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone; var Backbone = (!require('../util').isBrowser()) ? Backbone = require('backbone') : Backbone = window.Backbone;
@ -22008,8 +22191,7 @@ exports.GitDemonstrationView = GitDemonstrationView;
}); });
require("/src/js/views/gitDemonstrationView.js"); require("/src/js/views/gitDemonstrationView.js");
require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var GitError = require('../util/errors').GitError; require.define("/src/js/views/index.js",function(require,module,exports,__dirname,__filename,process,global){var _ = require('underscore');
var _ = require('underscore');
var Q = require('q'); var Q = require('q');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone; var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
@ -22017,6 +22199,7 @@ var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.
var Main = require('../app'); var Main = require('../app');
var Constants = require('../util/constants'); var Constants = require('../util/constants');
var KeyboardListener = require('../util/keyboard').KeyboardListener; var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var BaseView = Backbone.View.extend({ var BaseView = Backbone.View.extend({
getDestination: function() { getDestination: function() {
@ -22871,7 +23054,6 @@ var SeriesView = BaseView.extend({
// property changing but it's the 11th hour... // property changing but it's the 11th hour...
var toLoop = this.$('div.levelIcon').each(function(index, el) { var toLoop = this.$('div.levelIcon').each(function(index, el) {
var id = $(el).attr('data-id'); var id = $(el).attr('data-id');
console.log('updating id', id);
$(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id)); $(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id));
}); });
}, },

View file

@ -227,6 +227,26 @@
</div> </div>
</script> </script>
<script type="text/html" id="markdown-grabber-view">
<div class="inputSide box vertical">
<div class="markdownGrabberInput">
<textarea>## Enter some markdown!</textarea>
</div>
</div>
<div class="box vertical flex1">
<p class="helperText textAlignCenter">
Preview
</p>
<div class="markdownGrabberPreview box flex1 vertical">
<div class="insidePreview">
</div>
</div>
</div>
</script>
<script type="text/html" id="modal-alert-template"> <script type="text/html" id="modal-alert-template">
<h2> <h2>
<%= title %> <%= title %>

View file

@ -22,7 +22,8 @@ var toGlobalize = {
Sandbox: require('../level/sandbox'), Sandbox: require('../level/sandbox'),
GitDemonstrationView: require('../views/gitDemonstrationView'), GitDemonstrationView: require('../views/gitDemonstrationView'),
Markdown: require('markdown'), Markdown: require('markdown'),
LevelDropdownView: require('../views/levelDropdownView') LevelDropdownView: require('../views/levelDropdownView'),
BuilderViews: require('../views/builderViews')
}; };
_.each(toGlobalize, function(module) { _.each(toGlobalize, function(module) {

View file

@ -0,0 +1,88 @@
var _ = require('underscore');
var Q = require('q');
// horrible hack to get localStorage Backbone plugin
var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.Backbone;
var util = require('../util');
var KeyboardListener = require('../util/keyboard').KeyboardListener;
var Views = require('../views');
var ModalTerminal = Views.ModalTerminal;
var ContainedBase = Views.ContainedBase;
var MarkdownGrabber = ContainedBase.extend({
tagName: 'div',
className: 'MarkdownGrabber box horizontal',
template: _.template($('#markdown-grabber-view').html()),
events: {
'keyup textarea': 'keyup'
},
initialize: function(options) {
options = options || {};
this.deferred = options.deferred || Q.defer();
this.options = options;
this.JSON = {};
this.container = new ModalTerminal({
title: options.title || 'Enter some markdown'
});
this.render();
if (!options.withoutButton) {
// do button stuff
var buttonDefer = Q.defer();
buttonDefer.promise
.then(_.bind(function() {
this.confirmed();
}, this))
.fail(_.bind(function() {
this.cancelled();
}, this))
.done();
var confirmCancel = new Views.ConfirmCancelView({
deferred: buttonDefer,
destination: this.getDestination()
});
}
this.updatePreview();
if (!options.wait) {
this.show();
}
},
confirmed: function() {
this.die();
this.deferred.resolve(this.getRawText());
},
cancelled: function() {
this.die();
this.deferred.resolve();
},
keyup: function() {
if (!this.throttledPreview) {
this.throttledPreview = _.throttle(
_.bind(this.updatePreview, this),
500
);
}
this.throttledPreview();
},
getRawText: function() {
return this.$('textarea').val();
},
updatePreview: function() {
var raw = this.getRawText();
var HTML = require('markdown').markdown.toHTML(raw);
this.$('div.insidePreview').html(HTML);
}
});
exports.MarkdownGrabber = MarkdownGrabber;

View file

@ -1,4 +1,3 @@
var GitError = require('../util/errors').GitError;
var _ = require('underscore'); var _ = require('underscore');
var Q = require('q'); var Q = require('q');
// horrible hack to get localStorage Backbone plugin // horrible hack to get localStorage Backbone plugin
@ -7,6 +6,7 @@ var Backbone = (!require('../util').isBrowser()) ? require('backbone') : window.
var Main = require('../app'); var Main = require('../app');
var Constants = require('../util/constants'); var Constants = require('../util/constants');
var KeyboardListener = require('../util/keyboard').KeyboardListener; var KeyboardListener = require('../util/keyboard').KeyboardListener;
var GitError = require('../util/errors').GitError;
var BaseView = Backbone.View.extend({ var BaseView = Backbone.View.extend({
getDestination: function() { getDestination: function() {

View file

@ -271,7 +271,6 @@ var SeriesView = BaseView.extend({
// property changing but it's the 11th hour... // property changing but it's the 11th hour...
var toLoop = this.$('div.levelIcon').each(function(index, el) { var toLoop = this.$('div.levelIcon').each(function(index, el) {
var id = $(el).attr('data-id'); var id = $(el).attr('data-id');
console.log('updating id', id);
$(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id)); $(el).toggleClass('solved', Main.getLevelArbiter().isLevelSolved(id));
}); });
}, },

View file

@ -14,6 +14,10 @@ html, body {
color: #eee; color: #eee;
} }
li {
margin: 10px 0;
}
code { code {
background: grey; background: grey;
padding: 4px; padding: 4px;
@ -24,6 +28,10 @@ p {
word-wrap: break-word; word-wrap: break-word;
} }
.textAlignCenter {
text-align: center;
}
/* Box Model */ /* Box Model */
html, html,
body, body,
@ -514,6 +522,7 @@ li.rebaseEntry,
margin-top: 30%; margin-top: 30%;
} }
p.helperText,
div.terminal-text p.helperText, div.terminal-text p.helperText,
.iRebaseDialog p.helperText { .iRebaseDialog p.helperText {
font-size: 10px; font-size: 10px;
@ -728,12 +737,28 @@ div.levelIcon.solved div.index div.indexNum {
display: none; display: none;
} }
/* Git demonstration view */ /* Git demonstration view, and MarkdownGrabber */
.MarkdownGrabber {
padding: 10px;
}
.MarkdownGrabber textarea {
width: 90%;
height: 600px;
resize: none;
}
.markdownGrabberPreview div.insidePreview {
padding: 8px;
}
.MarkdownGrabber > div.inputSide,
.gitDemonstrationView > div.demonstrationText { .gitDemonstrationView > div.demonstrationText {
width: 50%; width: 50%;
} }
.MarkdownGrabber div.markdownGrabberPreview,
.gitDemonstrationView > div.visHolder { .gitDemonstrationView > div.visHolder {
box-shadow: 0 0 10px rgba(0, 0, 0, 0.7); box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
border-radius: 3px; border-radius: 3px;
@ -745,6 +770,7 @@ div.levelIcon.solved div.index div.indexNum {
padding: 10px; padding: 10px;
} }
.MarkdownGrabber,
.gitDemonstrationView { .gitDemonstrationView {
min-height: 400px; min-height: 400px;
} }

View file

@ -3,9 +3,9 @@ Big Things
[ ] level builder dialog tester [ ] level builder dialog tester
[ ] level builder dialog builder [ ] level builder dialog builder
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] get automated SHA hash appending in the html source :OOOOO... template? or what?
Cases to handle / things to edit Cases to handle / things to edit
======================= =======================
@ -31,6 +31,7 @@ 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] sandbox and level command refresh
[x] level builder finish [x] level builder finish
[x] level builder? :OOO [x] level builder? :OOO
* basically just an extension of level (or sandbox), that has commands like * basically just an extension of level (or sandbox), that has commands like