edit view nw

This commit is contained in:
Peter Cottle 2013-01-11 23:57:00 -08:00
parent 5c5637d701
commit 895d186b36
4 changed files with 152 additions and 16 deletions

View file

@ -14094,6 +14094,11 @@ var MarkdownGrabber = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
options.fillerText = options.fromObj.options.markdowns.join('\n');
}
this.JSON = { this.JSON = {
previewText: options.previewText || 'Preview', previewText: options.previewText || 'Preview',
fillerText: options.fillerText || '## Enter some markdown!\n\n\n' fillerText: options.fillerText || '## Enter some markdown!\n\n\n'
@ -14205,6 +14210,18 @@ var DemonstrationBuilder = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
var toEdit = options.fromObj.options;
options = _.extend(
{},
options,
toEdit,
{
beforeMarkdown: toEdit.beforeMarkdowns.join('\n'),
afterMarkdown: toEdit.afterMarkdowns.join('\n')
}
);
}
this.JSON = {}; this.JSON = {};
this.container = new ModalTerminal({ this.container = new ModalTerminal({
@ -14216,23 +14233,25 @@ var DemonstrationBuilder = ContainedBase.extend({
this.beforeMarkdownView = new MarkdownGrabber({ this.beforeMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.beforeMarkdown,
previewText: 'Before demonstration Markdown' previewText: 'Before demonstration Markdown'
}); });
this.beforeCommandView = new TextGrabber({ this.beforeCommandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to set up the demonstration view (before it is displayed)', helperText: 'The git command(s) to set up the demonstration view (before it is displayed)',
initialText: 'git checkout -b bugFix' initialText: options.beforeCommand || 'git checkout -b bugFix'
}); });
this.commandView = new TextGrabber({ this.commandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to demonstrate to the reader', helperText: 'The git command(s) to demonstrate to the reader',
initialText: 'git commit' initialText: options.command || 'git commit'
}); });
this.afterMarkdownView = new MarkdownGrabber({ this.afterMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.afterMarkdown,
previewText: 'After demonstration Markdown' previewText: 'After demonstration Markdown'
}); });
@ -14292,8 +14311,9 @@ var MultiViewBuilder = ContainedBase.extend({
}, },
events: { events: {
'click div.deleteButton': 'deleteView', 'click div.deleteButton': 'deleteOneView',
'click div.testButton': 'testOneView', 'click div.testButton': 'testOneView',
'click div.editButton': 'editOneView',
'click div.testEntireView': 'testEntireView', 'click div.testEntireView': 'testEntireView',
'click div.addView': 'addView', 'click div.addView': 'addView',
'click div.saveView': 'saveView', 'click div.saveView': 'saveView',
@ -14366,7 +14386,31 @@ var MultiViewBuilder = ContainedBase.extend({
}); });
}, },
deleteView: function(ev) { editOneView: function(ev) {
var el = ev.srcElement;
var index = $(el).attr('data-index');
var type = $(el).attr('data-type');
var whenDone = Q.defer();
var builder = new this.typeToConstructor[type]({
deferred: whenDone,
fromObj: this.getChildViews()[index]
});
whenDone.promise
.then(_.bind(function() {
var newView = {
type: type,
options: builder.getExportObj()
};
var views = this.getChildViews();
views[index] = newView;
this.setChildViews(views);
}, this))
.fail(function() { })
.done();
},
deleteOneView: function(ev) {
var el = ev.srcElement; var el = ev.srcElement;
var index = $(el).attr('data-index'); var index = $(el).attr('data-index');
var toSlice = this.getChildViews(); var toSlice = this.getChildViews();
@ -14376,7 +14420,7 @@ var MultiViewBuilder = ContainedBase.extend({
this.update(); this.update();
}, },
addChildViewObj: function(newObj) { addChildViewObj: function(newObj, index) {
var childViews = this.getChildViews(); var childViews = this.getChildViews();
childViews.push(newObj); childViews.push(newObj);
this.setChildViews(childViews); this.setChildViews(childViews);
@ -22315,6 +22359,11 @@ var MarkdownGrabber = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
options.fillerText = options.fromObj.options.markdowns.join('\n');
}
this.JSON = { this.JSON = {
previewText: options.previewText || 'Preview', previewText: options.previewText || 'Preview',
fillerText: options.fillerText || '## Enter some markdown!\n\n\n' fillerText: options.fillerText || '## Enter some markdown!\n\n\n'
@ -22426,6 +22475,18 @@ var DemonstrationBuilder = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
var toEdit = options.fromObj.options;
options = _.extend(
{},
options,
toEdit,
{
beforeMarkdown: toEdit.beforeMarkdowns.join('\n'),
afterMarkdown: toEdit.afterMarkdowns.join('\n')
}
);
}
this.JSON = {}; this.JSON = {};
this.container = new ModalTerminal({ this.container = new ModalTerminal({
@ -22437,23 +22498,25 @@ var DemonstrationBuilder = ContainedBase.extend({
this.beforeMarkdownView = new MarkdownGrabber({ this.beforeMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.beforeMarkdown,
previewText: 'Before demonstration Markdown' previewText: 'Before demonstration Markdown'
}); });
this.beforeCommandView = new TextGrabber({ this.beforeCommandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to set up the demonstration view (before it is displayed)', helperText: 'The git command(s) to set up the demonstration view (before it is displayed)',
initialText: 'git checkout -b bugFix' initialText: options.beforeCommand || 'git checkout -b bugFix'
}); });
this.commandView = new TextGrabber({ this.commandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to demonstrate to the reader', helperText: 'The git command(s) to demonstrate to the reader',
initialText: 'git commit' initialText: options.command || 'git commit'
}); });
this.afterMarkdownView = new MarkdownGrabber({ this.afterMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.afterMarkdown,
previewText: 'After demonstration Markdown' previewText: 'After demonstration Markdown'
}); });
@ -22513,8 +22576,9 @@ var MultiViewBuilder = ContainedBase.extend({
}, },
events: { events: {
'click div.deleteButton': 'deleteView', 'click div.deleteButton': 'deleteOneView',
'click div.testButton': 'testOneView', 'click div.testButton': 'testOneView',
'click div.editButton': 'editOneView',
'click div.testEntireView': 'testEntireView', 'click div.testEntireView': 'testEntireView',
'click div.addView': 'addView', 'click div.addView': 'addView',
'click div.saveView': 'saveView', 'click div.saveView': 'saveView',
@ -22587,7 +22651,31 @@ var MultiViewBuilder = ContainedBase.extend({
}); });
}, },
deleteView: function(ev) { editOneView: function(ev) {
var el = ev.srcElement;
var index = $(el).attr('data-index');
var type = $(el).attr('data-type');
var whenDone = Q.defer();
var builder = new this.typeToConstructor[type]({
deferred: whenDone,
fromObj: this.getChildViews()[index]
});
whenDone.promise
.then(_.bind(function() {
var newView = {
type: type,
options: builder.getExportObj()
};
var views = this.getChildViews();
views[index] = newView;
this.setChildViews(views);
}, this))
.fail(function() { })
.done();
},
deleteOneView: function(ev) {
var el = ev.srcElement; var el = ev.srcElement;
var index = $(el).attr('data-index'); var index = $(el).attr('data-index');
var toSlice = this.getChildViews(); var toSlice = this.getChildViews();
@ -22597,7 +22685,7 @@ var MultiViewBuilder = ContainedBase.extend({
this.update(); this.update();
}, },
addChildViewObj: function(newObj) { addChildViewObj: function(newObj, index) {
var childViews = this.getChildViews(); var childViews = this.getChildViews();
childViews.push(newObj); childViews.push(newObj);
this.setChildViews(childViews); this.setChildViews(childViews);

View file

@ -257,6 +257,9 @@
<div class="uiButton uiButtonRed box deleteButton" data-index="<%=i%>"> <div class="uiButton uiButtonRed box deleteButton" data-index="<%=i%>">
Delete Delete
</div> </div>
<div class="uiButton uiButtonWhite box editButton" data-index="<%=i%>" data-type="<%= views[i].type %>">
Edit
</div>
<div class="uiButton box testButton" data-index="<%=i%>"> <div class="uiButton box testButton" data-index="<%=i%>">
Test Test
</div> </div>

View file

@ -56,6 +56,11 @@ var MarkdownGrabber = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
options.fillerText = options.fromObj.options.markdowns.join('\n');
}
this.JSON = { this.JSON = {
previewText: options.previewText || 'Preview', previewText: options.previewText || 'Preview',
fillerText: options.fillerText || '## Enter some markdown!\n\n\n' fillerText: options.fillerText || '## Enter some markdown!\n\n\n'
@ -167,6 +172,18 @@ var DemonstrationBuilder = ContainedBase.extend({
initialize: function(options) { initialize: function(options) {
options = options || {}; options = options || {};
this.deferred = options.deferred || Q.defer(); this.deferred = options.deferred || Q.defer();
if (options.fromObj) {
var toEdit = options.fromObj.options;
options = _.extend(
{},
options,
toEdit,
{
beforeMarkdown: toEdit.beforeMarkdowns.join('\n'),
afterMarkdown: toEdit.afterMarkdowns.join('\n')
}
);
}
this.JSON = {}; this.JSON = {};
this.container = new ModalTerminal({ this.container = new ModalTerminal({
@ -178,23 +195,25 @@ var DemonstrationBuilder = ContainedBase.extend({
this.beforeMarkdownView = new MarkdownGrabber({ this.beforeMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.beforeMarkdown,
previewText: 'Before demonstration Markdown' previewText: 'Before demonstration Markdown'
}); });
this.beforeCommandView = new TextGrabber({ this.beforeCommandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to set up the demonstration view (before it is displayed)', helperText: 'The git command(s) to set up the demonstration view (before it is displayed)',
initialText: 'git checkout -b bugFix' initialText: options.beforeCommand || 'git checkout -b bugFix'
}); });
this.commandView = new TextGrabber({ this.commandView = new TextGrabber({
container: this, container: this,
helperText: 'The git command(s) to demonstrate to the reader', helperText: 'The git command(s) to demonstrate to the reader',
initialText: 'git commit' initialText: options.command || 'git commit'
}); });
this.afterMarkdownView = new MarkdownGrabber({ this.afterMarkdownView = new MarkdownGrabber({
container: this, container: this,
withoutButton: true, withoutButton: true,
fillerText: options.afterMarkdown,
previewText: 'After demonstration Markdown' previewText: 'After demonstration Markdown'
}); });
@ -254,8 +273,9 @@ var MultiViewBuilder = ContainedBase.extend({
}, },
events: { events: {
'click div.deleteButton': 'deleteView', 'click div.deleteButton': 'deleteOneView',
'click div.testButton': 'testOneView', 'click div.testButton': 'testOneView',
'click div.editButton': 'editOneView',
'click div.testEntireView': 'testEntireView', 'click div.testEntireView': 'testEntireView',
'click div.addView': 'addView', 'click div.addView': 'addView',
'click div.saveView': 'saveView', 'click div.saveView': 'saveView',
@ -328,7 +348,31 @@ var MultiViewBuilder = ContainedBase.extend({
}); });
}, },
deleteView: function(ev) { editOneView: function(ev) {
var el = ev.srcElement;
var index = $(el).attr('data-index');
var type = $(el).attr('data-type');
var whenDone = Q.defer();
var builder = new this.typeToConstructor[type]({
deferred: whenDone,
fromObj: this.getChildViews()[index]
});
whenDone.promise
.then(_.bind(function() {
var newView = {
type: type,
options: builder.getExportObj()
};
var views = this.getChildViews();
views[index] = newView;
this.setChildViews(views);
}, this))
.fail(function() { })
.done();
},
deleteOneView: function(ev) {
var el = ev.srcElement; var el = ev.srcElement;
var index = $(el).attr('data-index'); var index = $(el).attr('data-index');
var toSlice = this.getChildViews(); var toSlice = this.getChildViews();
@ -338,7 +382,7 @@ var MultiViewBuilder = ContainedBase.extend({
this.update(); this.update();
}, },
addChildViewObj: function(newObj) { addChildViewObj: function(newObj, index) {
var childViews = this.getChildViews(); var childViews = this.getChildViews();
childViews.push(newObj); childViews.push(newObj);
this.setChildViews(childViews); this.setChildViews(childViews);

View file

@ -1,7 +1,8 @@
Big Things Big Things
~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] descriptions for levels? [ ] descriptions for levels?
[ ] import random level [ ] import random level JSON
[ ] export / import tree from JSON
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~