[dw-free] delcommentcomplete event not called when the AJAX request errors
[commit: http://hg.dwscoalition.org/dw-free/rev/2015deb1e51c]
http://bugs.dwscoalition.org/show_bug.cgi?id=3745
Set our calling widget as the context (this) of the underlying ajaxtip
widget, so we can throw up accurate events on completion.
Patch by
fu.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=3745
Set our calling widget as the context (this) of the underlying ajaxtip
widget, so we can throw up accurate events on completion.
Patch by
Files modified:
- htdocs/js/jquery.ajaxtip.js
- htdocs/js/jquery.commentmanage.js
- htdocs/js/jquery.contextualhover.js
- htdocs/js/jquery.poll.js
- views/dev/tests/commentmanage.js
--------------------------------------------------------------------------------
diff -r e3d81dc5d30e -r 2015deb1e51c htdocs/js/jquery.ajaxtip.js
--- a/htdocs/js/jquery.ajaxtip.js Fri Jun 17 16:03:18 2011 +0800
+++ b/htdocs/js/jquery.ajaxtip.js Fri Jun 17 16:09:27 2011 +0800
@@ -106,6 +106,7 @@
type: opts.formmethod || "POST",
url : opts.endpoint ? self._endpointurl( opts.endpoint) : opts.url,
data: opts.data,
+ context: opts.context,
dataType: "json",
complete: function() {
@@ -120,10 +121,11 @@
success: opts.success,
error: opts.error ? opts.error : function( jqxhr, status, error ) {
if ( status == "abort" )
- self.element.ajaxtip("cancel");
+ this.element.ajaxtip("cancel");
else
- self.element.ajaxtip( "error", "Error contacting server. " + error);
- self._trigger( "complete" );
+ this.element.ajaxtip( "error", "Error contacting server. " + error);
+
+ this._trigger( "complete" );
}
});
@@ -145,17 +147,24 @@
});
$.extend( $.dw.ajaxtip, {
- closeall: function() {
+ closeall: function(e) {
$(".ajaxtip:visible").each(
function(){
- $(this).trigger("close");
+ var $this = $(this);
+
+ console.log($this, e.target, $this.has( e.target ).length > 0 );
+ if ( e && e.target && $this.has( e.target ).length > 0 ) {
+ // clicked inside this popup; do nothing
+ } else {
+ $(this).trigger("close");
+ }
})
}
})
})(jQuery);
jQuery(function($) {
- $(document).click(function() {
- $.dw.ajaxtip.closeall();
+ $(document).click(function(e) {
+ $.dw.ajaxtip.closeall(e);
});
});
diff -r e3d81dc5d30e -r 2015deb1e51c htdocs/js/jquery.commentmanage.js
--- a/htdocs/js/jquery.commentmanage.js Fri Jun 17 16:03:18 2011 +0800
+++ b/htdocs/js/jquery.commentmanage.js Fri Jun 17 16:09:27 2011 +0800
@@ -92,6 +92,7 @@
})
.ajaxtip("load", {
url: posturl,
+ context: self,
data: {
talkid : self.linkdata.id,
journal : self.options.journal,
@@ -161,6 +162,7 @@
.ajaxtip("load", {
url: posturl,
data: postdata,
+ context: self,
success: function( data, status, jqxhr ) {
if ( data.error ) {
self.element.ajaxtip( "error", "Error while trying to delete comment: " + data.error )
diff -r e3d81dc5d30e -r 2015deb1e51c htdocs/js/jquery.contextualhover.js
--- a/htdocs/js/jquery.contextualhover.js Fri Jun 17 16:03:18 2011 +0800
+++ b/htdocs/js/jquery.contextualhover.js Fri Jun 17 16:09:27 2011 +0800
@@ -83,6 +83,7 @@
.ajaxtip( "load", {
endpoint: "ctxpopup",
formmethod: "GET",
+ context: self,
data: {
"user": opts.username || "",
"userid": opts.userid || 0,
@@ -331,6 +332,7 @@
$link.ajaxtip({namespace: "changerelation"}).ajaxtip("load", {
endpoint: "changerelation",
+ context: self,
data: {
target: info.username,
action: action,
diff -r e3d81dc5d30e -r 2015deb1e51c htdocs/js/jquery.poll.js
--- a/htdocs/js/jquery.poll.js Fri Jun 17 16:03:18 2011 +0800
+++ b/htdocs/js/jquery.poll.js Fri Jun 17 16:09:27 2011 +0800
@@ -24,6 +24,7 @@
.ajaxtip({namespace: "pollanswer"})
.ajaxtip("load", {
endpoint: "poll",
+ context: self,
data: {
pollid : pollid,
pollqid : pollqid,
@@ -86,6 +87,7 @@
$submit.ajaxtip({namespace: "pollsubmit"})
.ajaxtip("load", {
endpoint: "pollvote",
+ context: self,
data: $poll.serialize(),
success: function( data, status, jqxhr ) {
if ( data.error ) {
diff -r e3d81dc5d30e -r 2015deb1e51c views/dev/tests/commentmanage.js
--- a/views/dev/tests/commentmanage.js Fri Jun 17 16:03:18 2011 +0800
+++ b/views/dev/tests/commentmanage.js Fri Jun 17 16:09:27 2011 +0800
@@ -285,7 +285,7 @@
.attr("checked", "checked")
.end()
.find("input[value='Delete']")
- .click();
+ .click()
this.server.respond();
} );
--------------------------------------------------------------------------------
