Skip to content
Snippets Groups Projects
Commit a183b5d7 authored by Morris Jobke's avatar Morris Jobke
Browse files

Merge pull request #14208 from owncloud/oc-msg-remove-object-dependency

Remove dependency from arbitrary data object structure for easier usage
parents 7b2b74d7 c201bc01
No related branches found
No related tags found
No related merge requests found
...@@ -618,60 +618,95 @@ OC.addStyle.loaded=[]; ...@@ -618,60 +618,95 @@ OC.addStyle.loaded=[];
OC.addScript.loaded=[]; OC.addScript.loaded=[];
/** /**
* @todo Write documentation * A little class to manage a status field for a "saving" process.
* It can be used to display a starting message (e.g. "Saving...") and then
* replace it with a green success message or a red error message.
*
* @namespace OC.msg
*/ */
OC.msg={ OC.msg = {
/** /**
* @param selector * Displayes a "Saving..." message in the given message placeholder
* @todo Write documentation *
* @param {Object} selector Placeholder to display the message in
*/ */
startSaving:function(selector){ startSaving: function(selector) {
OC.msg.startAction(selector, t('core', 'Saving...')); this.startAction(selector, t('core', 'Saving...'));
}, },
/** /**
* @param selector * Displayes a custom message in the given message placeholder
* @param data *
* @todo Write documentation * @param {Object} selector Placeholder to display the message in
* @param {string} message Plain text message to display (no HTML allowed)
*/ */
finishedSaving:function(selector, data){ startAction: function(selector, message) {
OC.msg.finishedAction(selector, data); $(selector).text(message)
.removeClass('success')
.removeClass('error')
.stop(true, true)
.show();
}, },
/** /**
* @param selector * Displayes an success/error message in the given selector
* @param {string} message Message to display *
* @todo WRite documentation * @param {Object} selector Placeholder to display the message in
* @param {Object} response Response of the server
* @param {Object} response.data Data of the servers response
* @param {string} response.data.message Plain text message to display (no HTML allowed)
* @param {string} response.status is being used to decide whether the message
* is displayed as an error/success
*/ */
startAction:function(selector, message){ finishedSaving: function(selector, response) {
$(selector) this.finishedAction(selector, response);
.html( message ) },
.removeClass('success')
/**
* Displayes an success/error message in the given selector
*
* @param {Object} selector Placeholder to display the message in
* @param {Object} response Response of the server
* @param {Object} response.data Data of the servers response
* @param {string} response.data.message Plain text message to display (no HTML allowed)
* @param {string} response.status is being used to decide whether the message
* is displayed as an error/success
*/
finishedAction: function(selector, response) {
if (response.status === "success") {
this.finishedSuccess(selector, response.data.message);
} else {
this.finishedError(selector, response.data.message);
}
},
/**
* Displayes an success message in the given selector
*
* @param {Object} selector Placeholder to display the message in
* @param {string} message Plain text success message to display (no HTML allowed)
*/
finishedSuccess: function(selector, message) {
$(selector).text(message)
.addClass('success')
.removeClass('error') .removeClass('error')
.stop(true, true) .stop(true, true)
.delay(3000)
.fadeOut(900)
.show(); .show();
}, },
/** /**
* @param selector * Displayes an error message in the given selector
* @param data *
* @todo Write documentation * @param {Object} selector Placeholder to display the message in
* @param {string} message Plain text error message to display (no HTML allowed)
*/ */
finishedAction:function(selector, data){ finishedError: function(selector, message) {
if( data.status === "success" ){ $(selector).text(message)
$(selector).html( data.data.message ) .addClass('error')
.addClass('success') .removeClass('success')
.removeClass('error') .show();
.stop(true, true)
.delay(3000)
.fadeOut(900)
.show();
}else{
$(selector).html( data.data.message )
.addClass('error')
.removeClass('success')
.show();
}
} }
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment