summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-01-19 13:35:53 +0100
committermr <mr@mrautenberg.de>2011-01-19 13:35:53 +0100
commitf5107eebb9afc0a54c34b6cbbf6859022e8f19c8 (patch)
tree5a2cb56a87224fa9b8ac11807c40b01cb8f62ec1
parent8da8b742db45faeff56afc5b70d1ca263e4c0bb0 (diff)
javascripts: fix status changes - changes to delete model
-rwxr-xr-xpublic/javascripts/toxcreate.js22
-rw-r--r--views/model.haml4
2 files changed, 16 insertions, 10 deletions
diff --git a/public/javascripts/toxcreate.js b/public/javascripts/toxcreate.js
index c74701a..5acabe9 100755
--- a/public/javascripts/toxcreate.js
+++ b/public/javascripts/toxcreate.js
@@ -14,6 +14,10 @@ $(function() {
});
};
+ trim = function() {
+ return this.replace(/^\s+|\s+$/g, '');
+ }
+
checkStati = function(stati, subjectstr) {
stati = stati.split(", ");
$("body")
@@ -36,15 +40,15 @@ $(function() {
'_method': 'get'
},
success: function(data) {
- var erg = data.search(/Running|Creating|Upload|Validating/);
- status_changed = false;
- if(erg < 0) status_changed = true;
- $("span#model_" + id + "_status").animate({"opacity": "0.1"},1000);
+ var status_before = "";
+ if ($("span#model_" + id + "_status").html()) status_before = $("span#model_" + id + "_status").html().trim();
+ var status_after = data.trim();
+ $("span#model_" + id + "_status").animate({"opacity": "0.2"},1000);
$("span#model_" + id + "_status").animate({"opacity": "1"},1000);
- if( status_changed ) {
+ if( status_before != status_after) {
$("span#model_" + id + "_status").html(data);
loadModel(id, 'model');
- id = -1;
+ if (status_after == "Completed") id = -1;
}
},
error: function(data) {
@@ -100,7 +104,8 @@ jQuery.fn.deleteModel = function(type, options) {
var opts = $.extend(defaults, options);
this.bind(opts.trigger_on, function() {
if(confirm(opts.confirm_message)) {
- $(opts.elem).fadeTo("slow",0.5);
+ $("div#model_" + opts.id).fadeTo("slow",0.5);
+ $("span#model_" + opts.id + "_status").html("Deleting");
$.ajax({
type: opts.method,
url: opts.action,
@@ -109,9 +114,10 @@ jQuery.fn.deleteModel = function(type, options) {
'_method': 'delete'
},
success: function(data) {
- $(opts.elem).fadeTo("slow",0).slideUp("slow").remove();
+ $("div#model_" + opts.id).fadeTo("slow",0).slideUp("slow").remove();
},
error: function(data) {
+ $("span#model_" + opts.id + "_status").html("Delete Error");
//alert("model delete error!");
}
});
diff --git a/views/model.haml b/views/model.haml
index 6c2aa56..6374bd8 100644
--- a/views/model.haml
+++ b/views/model.haml
@@ -1,5 +1,5 @@
- uri = url_for("/model/#{model.id}", :full)
-- js = "$('#delete_#{model.id}').deleteModel('DELETE', {elem: '#model_#{model.id}'});\n " + "$('#show_model_#{model.id}_warnings').toggleWarnings('#{model.id}');"
+- js = "$('#delete_#{model.id}').deleteModel('DELETE', {id: '#{model.id}'});\n " + "$('#show_model_#{model.id}_warnings').toggleWarnings('#{model.id}');"
:javascript
$(function() {
#{js}
@@ -12,7 +12,7 @@
%dl
%dt Status:
%dd
- %span{:id => "model_#{model.id}_status", :class => model.status}
+ %span{:id => "model_#{model.id}_status", :class => "model_status"}
= haml :model_status, :locals=>{:model=>model}, :layout => false
- if is_authorized(model.web_uri, "DELETE")
(