Commit 42331f5c authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge remote-tracking branch 'origin/raos_work' into crose_work

parents 377c9cf3 076db686
......@@ -64,9 +64,9 @@ if (!QfqNS) {
this.fadeOutDuration = 400;
this.timerId = null;
this.userOkButtonHandlers = new QfqNS.Helper.FunctionList();
this.userCancelButtonHandlers = new QfqNS.Helper.FunctionList();
this.userSaveButtonHandlers = new QfqNS.Helper.FunctionList();
this.userOkButtonHandlers = new n.Helper.FunctionList();
this.userCancelButtonHandlers = new n.Helper.FunctionList();
this.userSaveButtonHandlers = new n.Helper.FunctionList();
};
/**
......@@ -111,7 +111,7 @@ if (!QfqNS) {
return "alert-danger";
/* jshint -W086 */
default:
QfqNS.Log.warning("Message type '" + this.messageType + "' unknown. Use default type.");
n.Log.warning("Message type '" + this.messageType + "' unknown. Use default type.");
case "info":
return "alert-success";
/* jshint +W086 */
......@@ -181,7 +181,7 @@ if (!QfqNS) {
return buttons;
/* jshint -W086 */
default:
QfqNS.Log.warning("Buttons '" + this.buttons + "' unknown. Use default buttons");
n.Log.warning("Buttons '" + this.buttons + "' unknown. Use default buttons");
case "none":
break;
/* jshint +W086 */
......
......@@ -25,7 +25,7 @@ if (!QfqNS) {
this._tabActiveSelector = '#' + this.tabId + ' .active a[data-toggle="tab"]';
this.tabs = {};
this.currentTab = this.getActiveTabFromDOM();
this.userTabShowHandlers = new QfqNS.Helper.FunctionList();
this.userTabShowHandlers = new n.Helper.FunctionList();
// Fill this.tabs
......@@ -99,13 +99,13 @@ if (!QfqNS) {
* @param event
*/
n.BSTabs.prototype.tabShowHandler = function (event) {
QfqNS.Log.debug('Enter: BSTabs.tabShowHandler()');
n.Log.debug('Enter: BSTabs.tabShowHandler()');
this.currentTab = event.target.hash.slice(1);
var that = this;
QfqNS.Log.debug("BSTabs.tabShowHandler(): invoke user handler(s)");
n.Log.debug("BSTabs.tabShowHandler(): invoke user handler(s)");
this.userTabShowHandlers.call(that);
QfqNS.Log.debug('Exit: BSTabs.tabShowHandler()');
n.Log.debug('Exit: BSTabs.tabShowHandler()');
};
/**
......@@ -187,7 +187,7 @@ if (!QfqNS) {
n.BSTabs.prototype.getContainingTabIdForFormControl = function (formControlName) {
var $formControl = $("[name='" + formControlName + "']");
if ($formControl.length === 0) {
QfqNS.Log.debug("BSTabs.getContainingTabForFormControl(): unable to find form control with name '" + formControlName + "'");
n.Log.debug("BSTabs.getContainingTabForFormControl(): unable to find form control with name '" + formControlName + "'");
return null;
}
......
......@@ -62,15 +62,15 @@ if (!QfqNS) {
* @private
*/
n.FileUpload.prototype.setupOnChangeHandler = function () {
$(this.formSelector + " :file").on('change', this.handleFileUpload.bind(this));
$(this.formSelector + " :file").on('change', this.performFileUpload.bind(this));
};
/**
* @private
* @param event
*/
n.FileUpload.prototype.handleFileUpload = function (event) {
this.fileUploadStartCallbacks.call(event);
n.FileUpload.prototype.performFileUpload = function (event) {
this.fileUploadStartCallbacks.call(event.target);
var data = this.prepareData(event.target);
......@@ -82,8 +82,8 @@ if (!QfqNS) {
processData: false,
contentType: false
})
.done(this.ajaxSuccessHandler.bind(this))
.fail(this.ajaxErrorHandler.bind(this));
.done(this.ajaxSuccessHandler.bind(this, event.target))
.fail(this.ajaxErrorHandler.bind(this, event.target));
};
n.FileUpload.prototype.prepareData = function (htmlFileInput) {
......@@ -110,9 +110,9 @@ if (!QfqNS) {
* @param jqXHR
*/
n.FileUpload.prototype.ajaxSuccessHandler = function (data, textStatus, jqXHR) {
this.fileUploadSuccessCallbacks.call(data, textStatus);
this.fileUploadEndCallbacks.call(this);
n.FileUpload.prototype.ajaxSuccessHandler = function (uploadTriggeredBy, data, textStatus, jqXHR) {
this.fileUploadSuccessCallbacks.call(uploadTriggeredBy, data, textStatus);
this.fileUploadEndCallbacks.call(uploadTriggeredBy);
};
/**
......@@ -121,9 +121,9 @@ if (!QfqNS) {
* @param textStatus
* @param errorThrown
*/
n.FileUpload.prototype.ajaxErrorHandler = function (jqXHR, textStatus, errorThrown) {
this.fileUploadErrorCallbacks.call(textStatus, errorThrown);
this.fileUploadEndCallbacks.call(this);
n.FileUpload.prototype.ajaxErrorHandler = function (uploadTriggeredBy, jqXHR, textStatus, errorThrown) {
this.fileUploadErrorCallbacks.call(uploadTriggeredBy, textStatus, errorThrown);
this.fileUploadEndCallbacks.call(uploadTriggeredBy);
};
......
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
/* global $ */
if (!QfqNS) {
var QfqNS = {};
}
if (!QfqNS.Helper) {
QfqNS.Helper = {};
}
(function (n) {
'use strict';
n.showAjaxError = function (jqHXR, textStatus, errorThrown) {
var alert = new QfqNS.Alert("Error:<br> " +
errorThrown, "error");
alert.show();
};
})(QfqNS.Helper);
\ No newline at end of file
......@@ -14,7 +14,7 @@ if (!QfqNS) {
this.pageState = location.hash.slice(1);
this.data = null;
this.inPoppingHandler = false;
this.userPopStateHandlers = new QfqNS.Helper.FunctionList();
this.userPopStateHandlers = new n.Helper.FunctionList();
window.addEventListener("popstate", this.popStateHandler.bind(this));
};
......@@ -26,18 +26,18 @@ if (!QfqNS) {
*/
n.PageState.prototype.popStateHandler = function (event) {
QfqNS.Log.debug("Enter: PageState.popStateHandler()");
n.Log.debug("Enter: PageState.popStateHandler()");
this.inPoppingHandler = true;
this.pageState = location.hash.slice(1);
this.data = window.history.state;
QfqNS.Log.debug("PageState.popStateHandler(): invoke user pop state handler(s)");
n.Log.debug("PageState.popStateHandler(): invoke user pop state handler(s)");
this.userPopStateHandlers.call(this);
this.inPoppingHandler = false;
QfqNS.Log.debug("Exit: PageState.popStateHandler()");
n.Log.debug("Exit: PageState.popStateHandler()");
};
......
......@@ -38,6 +38,8 @@ if (!QfqNS) {
this.setupFormUpdateHandler();
this.fileUploader = new QfqNS.FileUpload('#' + this.formId, this.fileUploadTo, this.getSip());
this.fileUploader.addFileUploadStartHandler(this.startUploadHandler);
this.fileUploader.addFileUploadEndHandler(this.endUploadHandler);
};
n.QfqForm.prototype.setBsTabs = function (bsTabs) {
......@@ -72,10 +74,7 @@ if (!QfqNS) {
n.QfqForm.prototype.formUpdateHandler = function () {
var that = this;
$.post(this.dataRefreshUrl, this.form.serialize(), "json")
.fail(function (jqXHR, textStatus, errorThrown) {
var alert = new QfqNS.Alert("Error:<br>" + errorThrown, "error");
alert.show();
})
.fail(n.Helper.showAjaxError)
.done(function (data) {
this.handleFormUpdate(data);
}.bind(that));
......@@ -167,7 +166,7 @@ if (!QfqNS) {
alert.addOkButtonHandler(function () {
$.post(that.deleteUrl)
.done(that.ajaxDeleteSuccessDispatcher.bind(that))
.fail(that.ajaxDeleteFailureHandler.bind(that));
.fail(n.Helper.showAjaxError);
});
alert.show();
};
......@@ -314,25 +313,7 @@ if (!QfqNS) {
* @private
*/
n.QfqForm.prototype.submitFailureHandler = function (form, textStatus, jqXHR, errorThrown) {
this.showAjaxError(errorThrown);
};
/**
*
* @param jqXHR
* @param textStatus
* @param errorThrown
*
* @private
*/
n.QfqForm.prototype.ajaxDeleteFailureHandler = function (jqXHR, textStatus, errorThrown) {
this.showAjaxError(errorThrown);
};
n.QfqForm.prototype.showAjaxError = function (errorThrown) {
var alert = new QfqNS.Alert("Error:<br> " +
errorThrown, "error");
alert.show();
n.Helper.showAjaxError(errorThrown);
};
......@@ -527,6 +508,29 @@ if (!QfqNS) {
}
};
/**
* @private
* @param triggeredBy
*/
n.QfqForm.prototype.startUploadHandler = function (triggeredBy) {
$(triggeredBy).after(
$('<i>').addClass('spinner')
);
};
/**
* @private
* @param triggeredBy
*/
n.QfqForm.prototype.endUploadHandler = function (triggeredBy) {
var $siblings = $(triggeredBy).siblings();
$siblings.filter("i").remove();
};
n.QfqForm.prototype.ajaxFileUploadErrorHandler = function (triggeredBy, jqHXR, textStatus, errorThrown) {
n.Helper.showAjaxError(jqHXR, textStatus, errorThrown);
};
/**
* Retrieve SIP as stored in hidden input field.
*
......
......@@ -21,31 +21,31 @@ if (!QfqNS) {
deleteUrl: "typo3conf/ext/qfq/qfq/api/delete.php",
refreshUrl: "typo3conf/ext/qfq/qfq/api/load.php",
fileUploadTo: "typo3conf/ext/qfq/qfq/api/upload.php",
pageState: new QfqNS.PageState()
pageState: new n.PageState()
}, settings
);
try {
this.bsTabs = new QfqNS.BSTabs(this.settings.tabsId);
this.bsTabs = new n.BSTabs(this.settings.tabsId);
var currentState = this.settings.pageState.getPageState();
if (currentState !== "") {
this.bsTabs.activateTab(currentState);
QfqNS.PageTitle.setSubTitle(this.bsTabs.getTabName(currentState));
n.PageTitle.setSubTitle(this.bsTabs.getTabName(currentState));
} else {
this.settings.pageState.setPageState(this.bsTabs.getCurrentTab(), QfqNS.PageTitle.get());
this.settings.pageState.setPageState(this.bsTabs.getCurrentTab(), n.PageTitle.get());
}
this.bsTabs.addTabShowHandler(this.tabShowHandler.bind(this));
this.settings.pageState.addStateActivationHandler(this.popStateHandler.bind(this));
} catch (e) {
QfqNS.Log.message(e.message);
n.Log.message(e.message);
this.bsTabs = null;
}
try {
this.qfqForm = new QfqNS.QfqForm(
this.qfqForm = new n.QfqForm(
this.settings.formId,
this.settings.submitTo,
this.settings.deleteUrl,
......@@ -54,7 +54,7 @@ if (!QfqNS) {
this.qfqForm.setBsTabs(this.bsTabs);
this.qfqForm.destroyFormUserCallbacks.addFunction(this.destroyFormHandler.bind(this));
} catch (e) {
QfqNS.Log.error(e.message);
n.Log.error(e.message);
this.qfqForm = null;
}
};
......@@ -74,20 +74,20 @@ if (!QfqNS) {
// Therefore, we have to make sure, that tabShowHandler() does not save the page state while we're restoring
// a previous state, i.e. we're called because of the popStateHandler() below.
if (this.settings.pageState.inPoppingHandler) {
QfqNS.Log.debug("Prematurely terminating QfqPage.tabShowHandler(): called due to page state" +
n.Log.debug("Prematurely terminating QfqPage.tabShowHandler(): called due to page state" +
" restoration.");
return;
}
var currentTabId = bsTabs.getCurrentTab();
QfqNS.Log.debug('Saving state: ' + currentTabId);
QfqNS.PageTitle.setSubTitle(bsTabs.getTabName(currentTabId));
this.settings.pageState.setPageState(currentTabId, QfqNS.PageTitle.get());
n.Log.debug('Saving state: ' + currentTabId);
n.PageTitle.setSubTitle(bsTabs.getTabName(currentTabId));
this.settings.pageState.setPageState(currentTabId, n.PageTitle.get());
};
n.QfqPage.prototype.popStateHandler = function (pageState) {
this.bsTabs.activateTab(pageState.getPageState());
QfqNS.PageTitle.set(pageState.getPageData());
n.PageTitle.set(pageState.getPageData());
};
})(QfqNS);
\ No newline at end of file
......@@ -42,12 +42,12 @@ if (!QfqNS) {
}
var alert = new QfqNS.Alert("Do you really want to delete the record?", "warning", "yesno");
var alert = new n.Alert("Do you really want to delete the record?", "warning", "yesno");
var that = this;
alert.addOkButtonHandler(function () {
$.post(that.deleteUrl + "?s=" + sip)
.done(that.ajaxDeleteSuccessDispatcher.bind(that, $recordElement))
.fail(that.ajaxDeleteFailureHandler.bind(that));
.fail(n.Helper.showAjaxError);
});
alert.show();
};
......@@ -84,11 +84,11 @@ if (!QfqNS) {
return;
}
if (data.redirect && data.redirect === "no") {
var alert = new QfqNS.Alert("redirect=='no' not allowed", "error");
var alert = new n.Alert("redirect=='no' not allowed", "error");
alert.show();
}
var info = new QfqNS.Alert("Record successfully deleted", "info");
var info = new n.Alert("Record successfully deleted", "info");
info.timeout = 1500;
info.show();
$recordElement.fadeOut(function () {
......@@ -96,12 +96,6 @@ if (!QfqNS) {
});
};
n.QfqRecordList.prototype.ajaxDeleteFailureHandler = function (jqXHR, textStatus, errorThrown) {
var alert = new QfqNS.Alert("Error:<br> " +
errorThrown, "error");
alert.show();
};
n.QfqRecordList.prototype.getRecordElement = function (element) {
return $(element).closest('.' + this.recordClass);
};
......@@ -116,7 +110,7 @@ if (!QfqNS) {
if (!data.message) {
throw Error("Status is 'error' but required 'message' attribute is missing.");
}
var alert = new QfqNS.Alert(data.message, "error");
var alert = new n.Alert(data.message, "error");
alert.show();
};
......
#qfqAlertContainer {
@spinner : url(data:image/gif;base64,R0lGODlhEAAQAKIAAP///9bW1szMzL29vXt7e3Nzc2ZmZv4BAiH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBwAHACwAAAAAEAAQAAADPAi6QRQrymJMkcwFatuLXOFt1bWEYBmNq6awGDCicUhjIYzBwTBAmc9CQBSkLJGiYKZi+EgdV60ZCwIjCQAh+QQFBwAHACwAAAYABgAIAAADE3gz1/LCwaYYbYTQYkxpnEdlRwIAIfkEBQcABwAsAAACAAYACAAAAxN4OqMnUKgoVzuEuGJMUZznZE4CACH5BAUHAAcALAIAAAAIAAYAAAMUeKozqyKKQ8iRohhTTjsa91DWkwAAIfkEBQcABwAsBgAAAAgABgAAAxR4RNddxhR3oDxjtHWEF9QHUtmRAAAh+QQFBwAHACwKAAIABgAIAAADFHhE12WmOCjbaviMgYUXzQc225EAACH5BAUHAAcALAoABgAGAAgAAAMTeEqkV8YUBaVjagwnulDel21KAgAh+QQFBwAHACwGAAoACAAGAAADFHiqRKvFmHLGOHGKLU47XPdYz5EAADs=);
@alert_container_id : #qfqAlertContainer;
@spinner_class : spinner;
@{alert_container_id} {
position: fixed;
top: 0;
left: 0;
width: 100%;
z-index: 1000;
.alert {
margin-bottom: 2px;
}
}
#qfqAlertContainer .alert {
margin-bottom: 2px;
i.@{spinner_class} {
display: inline-block;
background: @spinner no-repeat;
//height: image-height(@spinner);
//width: image-width(@spinner);
height: 16px;
width: 16px;
}
/*inline elements in horizontal mode are too much left*/
.form-horizontal .form-inline .form-group {
margin: 0;
}
.form-horizontal {
.form-inline {
.form-group {
margin: 0;
}
}
.form-inline .control-label {
font-weight: normal;
}
/* reduce unwished padding-top offset */
.checkbox {
padding-top: 0;
}
/* reduce unwished padding-top offset */
.form-horizontal .checkbox, .form-horizontal .checkbox-inline, .form-horizontal .radio, .form-horizontal .radio-inline {
padding-top: 0;
.checkbox-inline {
padding-top: 0;
margin-top: -4px;
}
.radio {
padding-top: 0;
}
.radio-inline {
padding-top: 0;
margin-top: -4px;
}
input[type=file] {
display: inline;
}
}
/* checkbox, inline oriented, have a different unwished offset */
.form-horizontal .checkbox-inline, .form-horizontal .radio-inline {
margin-top: -4px;
}
\ No newline at end of file
.form-inline {
.control-label {
font-weight: normal;
}
}
......@@ -630,7 +630,7 @@
<label for="fileupload" class="control-label">File upload</label>
</div>
<div class="col-md-6">
<input id="fileupload" type="file" name="fileupload" class="form-control">
<input id="fileupload" type="file" name="fileupload">
</div>
<div class=" col-md-4">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment