Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More progress indication cleanup

  • Loading branch information...
commit e7e8fccdf06337514c801cdc42f4f4f36a35becb 1 parent a1bb70f
@hpoydar authored
View
3  README.mdown
@@ -30,8 +30,7 @@ Admittedly this is software by me for me. I use Processing as a tool to inspire
## Development TODO
-* Figure out why image-based sketches need a second load before rendering
-* More progress indication, disable buttons
+* More progress indication, disable buttons (saving renderings)
* Code editing (bespin)
* Share renderings via bit.ly
* Endless pagination
View
4 _attachments/views/sketches/show.html
@@ -18,8 +18,8 @@
</p>
<ul class='info_options'>
- <li class='button no_toggle'><a href="#/sketch/reload/<%= item._id %>">Regenerate</a></li>
- <li class='button no_toggle'><a href="#/renderings/save/<%= item._id %>">Save</a></li>
+ <li class='button no_toggle progress'><a href="#/sketch/reload/<%= item._id %>">Regenerate</a></li>
+ <li class='button no_toggle progress'><a href="#/renderings/save/<%= item._id %>">Save</a></li>
</ul>
View
259 lib/javascripts/controller.js
@@ -23,6 +23,16 @@ $.CouchApp(function(app) {
flash = null;
};
+ // TODO: refactor to toggleProgress()
+ var displayProgress = function() {
+ $('#progress').show();
+ $('.button').addClass('progress');
+ };
+ var clearProgress = function() {
+ $('#progress').hide();
+ $('.button').removeClass('progress');
+ };
+
var menuSetup = function(selected_class, breadcrumbs) {
selected_class = selected_class || '';
@@ -65,6 +75,7 @@ $.CouchApp(function(app) {
};
bind('event-context-before', function(e, data) {
+ clearProgress();
displayFlash();
});
@@ -73,6 +84,7 @@ $.CouchApp(function(app) {
});
get('#/renderings/by/date', function() {
+ displayProgress();
menuSetup('renderings-by-date', ['Renderings', 'by date']);
var ctx = this;
couchapp.design.view("renderings-by-date", {
@@ -80,11 +92,13 @@ $.CouchApp(function(app) {
success: function(json) {
//console.log(json);
ctx.partial('views/renderings/index.html', {list: json.rows.reverse()});
+ clearProgress();
}
});
});
get('#/renderings/by/sketch', function() {
+ displayProgress();
menuSetup('renderings-by-sketch', ['Renderings', 'by sketch']);
var ctx = this;
couchapp.design.view("renderings-by-sketch", {
@@ -92,13 +106,12 @@ $.CouchApp(function(app) {
success: function(json) {
//console.log(json);
ctx.partial('views/renderings/index.html', {list: json.rows});
+ clearProgress();
}
});
});
-
get('#/rendering/:id', function() {
-
var ctx = this;
couchapp.db.openDoc(ctx.params["id"], {
success: function(json) {
@@ -115,7 +128,7 @@ $.CouchApp(function(app) {
});
get('#/sketch/:id', function() {
- $('#progress').show();
+ displayProgress();
var ctx = this;
couchapp.db.openDoc(ctx.params["id"], {
success: function(json) {
@@ -128,7 +141,7 @@ $.CouchApp(function(app) {
$('canvas#view').each(function() {
Processing(this, json.code);
});
- $('#progress').hide();
+ clearProgress();
}, to);
});
}
@@ -140,10 +153,9 @@ $.CouchApp(function(app) {
});
get('#/renderings/save/:sketch_id', function() {
-
+ displayProgress();
var ctx = this;
var tid = ctx.params['sketch_id'];
-
couchapp.db.openDoc(tid, {
success: function(json) {
//console.log(json);
@@ -179,142 +191,143 @@ $.CouchApp(function(app) {
"' - <a href='#/rendering/" + jsonb.id + "'>view</a>",
css_class: "success"
};
+ //clearProgress();
ctx.redirect('#/renderings/by/date');
}
});
-
}
});
-
});
get('#/rendering/delete/:id', function() {
- var ctx = this;
- if (!confirm('Are you sure?')) {
- ctx.redirect('#/rendering/' + ctx.params["id"]);
- return false;
- }
- couchapp.db.openDoc(ctx.params["id"], {
- success: function(json) {
- var sketch_name = json.sketch.name;
- couchapp.db.removeDoc(json, {
- success: function() {
- flash = {
- message: "Deleted rendering of '" + sketch_name + "'",
- css_class: "success"
- };
- ctx.redirect('#/renderings/by/date');
- }
- });
- return false;
- }
- });
- });
-
-
- get('#/manage/new', function() {
- $('#main').addClass('center');
- menuSetup('manage-new', ['Manage', 'New sketch template']);
- this.partial('views/manage/new.html');
- });
-
- post('#/manage/new', function() {
- var ctx = this;
- var date = new Date();
- var sketch_name = (ctx.params['sketch_name'].blank() ? ('Untitled ' + date) : ctx.params['sketch_name']);
-
- couchapp.db.saveDoc(
- {
- type: 'sketch',
- created_at: date.toJSON(),
- name: sketch_name,
- code: ctx.params['sketch_code'],
- }, {
- success: function(json) {
- flash = {
- message: "Stored sketch '" + sketch_name + "'",
- css_class: "success"
- };
- ctx.redirect('#/renderings/by/date');
- return false;
- }
- });
- flash = {
- message: "There was a problem storing your sketch",
- css_class: "error"
- };
- ctx.redirect('#/manage/new');
- });
+ var ctx = this;
+ if (!confirm('Are you sure?')) {
+ ctx.redirect('#/rendering/' + ctx.params["id"]);
+ return false;
+ }
+ displayProgress();
+ couchapp.db.openDoc(ctx.params["id"], {
+ success: function(json) {
+ var sketch_name = json.sketch.name;
+ couchapp.db.removeDoc(json, {
+ success: function() {
+ flash = {
+ message: "Deleted rendering of '" + sketch_name + "'",
+ css_class: "success"
+ };
+ //clearProgress();
+ ctx.redirect('#/renderings/by/date');
+ }
+ });
+ return false;
+ }
+ });
+ });
- get('#/manage/edit/:id', function() {
- $('#main').addClass('center');
- var ctx = this;
- couchapp.db.openDoc(ctx.params["id"], {
- success: function(json) {
- //console.log(json);
- menuSetup(('#/manage/edit/' + json._id).cssify(), ['Manage', 'Edit', json.name]);
- ctx.partial('views/manage/edit.html', {
- item: json,
- timestamp: couchapp.prettyDate(json.created_at)
- });
- }
- });
- });
+ get('#/manage/new', function() {
+ $('#main').addClass('center');
+ menuSetup('manage-new', ['Manage', 'New sketch template']);
+ this.partial('views/manage/new.html');
+ });
- put('#/manage/edit/:id', function() {
- var ctx = this;
- var sketch_name = (ctx.params['sketch_name'].blank() ? ('Untitled ' + date) : ctx.params['sketch_name']);
- couchapp.db.openDoc(ctx.params["id"], {
- success: function(json) {
+ post('#/manage/new', function() {
+ displayProgress();
+ var ctx = this;
+ var date = new Date();
+ var sketch_name = (ctx.params['sketch_name'].blank() ? ('Untitled ' + date) : ctx.params['sketch_name']);
+ couchapp.db.saveDoc(
+ {
+ type: 'sketch',
+ created_at: date.toJSON(),
+ name: sketch_name,
+ code: ctx.params['sketch_code'],
+ }, {
+ success: function(json) {
+ flash = {
+ message: "Stored sketch '" + sketch_name + "'",
+ css_class: "success"
+ };
+ ctx.redirect('#/renderings/by/date');
+ return false;
+ }
+ });
+ flash = {
+ message: "There was a problem storing your sketch",
+ css_class: "error"
+ };
+ ctx.redirect('#/manage/new');
+ });
- json.code = ctx.params['sketch_code'];
- json.name = sketch_name;
+ get('#/manage/edit/:id', function() {
+ $('#main').addClass('center');
+ var ctx = this;
+ couchapp.db.openDoc(ctx.params["id"], {
+ success: function(json) {
+ //console.log(json);
+ menuSetup(('#/manage/edit/' + json._id).cssify(), ['Manage', 'Edit', json.name]);
+ ctx.partial('views/manage/edit.html', {
+ item: json,
+ timestamp: couchapp.prettyDate(json.created_at)
+ });
+ }
+ });
+ });
- couchapp.db.saveDoc(json, {
- success: function(json) {
- //console.log('stored doc: ', json)
- flash = {
- message: "Updated sketch '" + sketch_name + "'",
- css_class: "success"
- };
- ctx.redirect('#/renderings/by/date');
- }
- });
- return false;
- }
- });
- });
+ put('#/manage/edit/:id', function() {
+ displayProgress();
+ var ctx = this;
+ var sketch_name = (ctx.params['sketch_name'].blank() ? ('Untitled ' + date) : ctx.params['sketch_name']);
+ couchapp.db.openDoc(ctx.params["id"], {
+ success: function(json) {
+ json.code = ctx.params['sketch_code'];
+ json.name = sketch_name;
+ couchapp.db.saveDoc(json, {
+ success: function(json) {
+ //console.log('stored doc: ', json)
+ flash = {
+ message: "Updated sketch '" + sketch_name + "'",
+ css_class: "success"
+ };
+ ctx.redirect('#/renderings/by/date');
+ }
+ });
+ return false;
+ }
+ });
+ });
- get('#/manage/delete/:id', function() {
- var ctx = this;
- if (!confirm('Are you sure?')) {
- ctx.redirect('#/manage/edit/' + ctx.params["id"]);
- return false;
- }
- couchapp.db.openDoc(ctx.params["id"], {
- success: function(json) {
- var sketch_name = json.name;
- couchapp.db.removeDoc(json, {
- success: function() {
- flash = {
- message: "Deleted sketch '" + sketch_name + "'",
- css_class: "success"
- };
- ctx.redirect('#/renderings/by/date');
- }
- });
- return false;
- }
- });
- });
+ get('#/manage/delete/:id', function() {
+ var ctx = this;
+ if (!confirm('Are you sure?')) {
+ ctx.redirect('#/manage/edit/' + ctx.params["id"]);
+ return false;
+ }
+ displayProgress();
+ couchapp.db.openDoc(ctx.params["id"], {
+ success: function(json) {
+ var sketch_name = json.name;
+ couchapp.db.removeDoc(json, {
+ success: function() {
+ flash = {
+ message: "Deleted sketch '" + sketch_name + "'",
+ css_class: "success"
+ };
+ ctx.redirect('#/renderings/by/date');
+ }
+ });
+ return false;
+ }
+ });
+ });
get('#/credits', function() {
this.partial('views/credits.html', {
list: APP_DATA.credits
});
});
- }
- });
+
+ } // with(this)
+ }); // Sammy#app
$(function() {
app.addLogger(function(e, data) {
View
3  lib/styles/screen.sass
@@ -356,6 +356,9 @@ label
:color #fff
:font-weight bold
:text-shadow 0px 1px 1px #4b5582
+ &.progress
+ a
+ :color #999
&.sketch_images
li
Please sign in to comment.
Something went wrong with that request. Please try again.