* @var integer
*/
_loadingOverlayVisibleTimer: 0,
+
+ /**
+ * suppresses errors
+ * @var boolean
+ */
+ _suppressErrors: false,
/**
* Initializes AJAXProxy.
this.confirmationDialog = null;
this.loading = null;
+ this._suppressErrors = false;
// send request immediately after initialization
if (this.options.autoSend) {
this.sendRequest();
}
+
+ var self = this;
+ $(window).on('beforeunload', function() { self._suppressErrors = true; });
},
/**
var data = $.parseJSON(jqXHR.responseText);
// call child method if applicable
+ var $showError = true;
if ($.isFunction(this.options.failure)) {
- this.options.failure(jqXHR, textStatus, errorThrown, data);
+ $showError = this.options.failure(jqXHR, textStatus, errorThrown, jqXHR.responseText);
}
- var $randomID = WCF.getRandomID();
- $('<div class="ajaxDebugMessage" id="' + $randomID + '"><p>' + data.message + '</p><p>Stacktrace:</p><p>' + data.stacktrace + '</p></div>').wcfDialog({ title: WCF.Language.get('wcf.global.error.title') });
+ if (!this._suppressErrors && $showError !== false) {
+ $('<div class="ajaxDebugMessage"><p>' + data.message + '</p><p>Stacktrace:</p><p>' + data.stacktrace + '</p></div>').wcfDialog({ title: WCF.Language.get('wcf.global.error.title') });
+ }
}
// failed to parse JSON
catch (e) {
- var $randomID = WCF.getRandomID();
- $('<div class="ajaxDebugMessage" id="' + $randomID + '"><p style="padding: 3px;">' + jqXHR.responseText + '.</p></div>').wcfDialog({ title: WCF.Language.get('wcf.global.error.title') });
+ // call child method if applicable
+ var $showError = true;
+ if ($.isFunction(this.options.failure)) {
+ $showError = this.options.failure(jqXHR, textStatus, errorThrown, jqXHR.responseText);
+ }
+
+ if (!this._suppressErrors && $showError !== false) {
+ $('<div class="ajaxDebugMessage"><p>' + jqXHR.responseText + '</p></div>').wcfDialog({ title: WCF.Language.get('wcf.global.error.title') });
+ }
}
this._after();
*/
_activeElementID: '',
+ /**
+ * cancels popover
+ * @var boolean
+ */
+ _cancelPopover: false,
+
/**
* element data
* @var object
init: function(selector) {
// assign default values
this._activeElementID = '';
+ this._cancelPopover = false;
this._data = { };
this._defaultDimensions = {
height: 150,
};
$element.hover($.proxy(this._overElement, this), $.proxy(this._out, this));
+
+ if ($element.getTagName() === 'a') {
+ $element.click($.proxy(this._cancel, this));
+ }
}
}, this));
},
+ /**
+ * Cancels popovers if link is being clicked
+ */
+ _cancel: function(event) {
+ this._cancelPopover = true;
+ this._hide(true);
+ },
+
/**
* Triggered once an element is being hovered.
*
* @param object event
*/
_overElement: function(event) {
+ if (this._cancelPopover) {
+ return;
+ }
+
if (this._peOverElement !== null) {
this._peOverElement.stop();
}
* Prepares popover to be displayed.
*/
_prepare: function() {
+ if (this._cancelPopover) {
+ return;
+ }
+
if (this._peOut !== null) {
this._peOut.stop();
}
* Displays the popover.
*/
_show: function() {
+ if (this._cancelPopover) {
+ return;
+ }
+
this._popover.stop().wcfFadeIn();
if (this._data[this._activeElementID].loading) {
this._popover.stop();
if (disableAnimation) {
+ sekf._popover.css({ opacity: 0 });
self._popoverContent.empty().css({ height: 'auto', opacity: 0, width: 'auto' });
}
else {
* Triggered once element *or* popover is now longer hovered.
*/
_out: function(event) {
+ if (this._cancelPopover) {
+ return;
+ }
+
this._hoverElementID = '';
this._hoverElement = false;
this._hoverPopover = false;