summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-26 14:57:21 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-26 14:57:21 +0100
commita183b5d7e208222faa4fa193969faf2f89058a5b (patch)
tree9d759b7c6318b7e27b7a1402e936a87918e45db6 /core
parent7b2b74d731207596511316375b7909e28048a4d8 (diff)
parentc201bc01bb6fd46446945d740d9bd6cecc467e5c (diff)
downloadnextcloud-server-a183b5d7e208222faa4fa193969faf2f89058a5b.tar.gz
nextcloud-server-a183b5d7e208222faa4fa193969faf2f89058a5b.zip
Merge pull request #14208 from owncloud/oc-msg-remove-object-dependency
Remove dependency from arbitrary data object structure for easier usage
Diffstat (limited to 'core')
-rw-r--r--core/js/js.js107
1 files changed, 71 insertions, 36 deletions
diff --git a/core/js/js.js b/core/js/js.js
index a43df4014df..1e9ae4cc695 100644
--- a/core/js/js.js
+++ b/core/js/js.js
@@ -618,60 +618,95 @@ OC.addStyle.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
- * @todo Write documentation
+ * Displayes a "Saving..." message in the given message placeholder
+ *
+ * @param {Object} selector Placeholder to display the message in
*/
- startSaving:function(selector){
- OC.msg.startAction(selector, t('core', 'Saving...'));
+ startSaving: function(selector) {
+ this.startAction(selector, t('core', 'Saving...'));
},
/**
- * @param selector
- * @param data
- * @todo Write documentation
+ * Displayes a custom message in the given message placeholder
+ *
+ * @param {Object} selector Placeholder to display the message in
+ * @param {string} message Plain text message to display (no HTML allowed)
*/
- finishedSaving:function(selector, data){
- OC.msg.finishedAction(selector, data);
+ startAction: function(selector, message) {
+ $(selector).text(message)
+ .removeClass('success')
+ .removeClass('error')
+ .stop(true, true)
+ .show();
},
/**
- * @param selector
- * @param {string} message Message to display
- * @todo WRite documentation
+ * 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
*/
- startAction:function(selector, message){
- $(selector)
- .html( message )
- .removeClass('success')
+ finishedSaving: function(selector, response) {
+ this.finishedAction(selector, response);
+ },
+
+ /**
+ * 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')
.stop(true, true)
+ .delay(3000)
+ .fadeOut(900)
.show();
},
/**
- * @param selector
- * @param data
- * @todo Write documentation
+ * Displayes an error message in the given selector
+ *
+ * @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){
- if( data.status === "success" ){
- $(selector).html( data.data.message )
- .addClass('success')
- .removeClass('error')
- .stop(true, true)
- .delay(3000)
- .fadeOut(900)
- .show();
- }else{
- $(selector).html( data.data.message )
- .addClass('error')
- .removeClass('success')
- .show();
- }
+ finishedError: function(selector, message) {
+ $(selector).text(message)
+ .addClass('error')
+ .removeClass('success')
+ .show();
}
};