Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Message Class
- * Handles displaying of messages
- * @author Danilo Bargen <gezuru@gmail.com>
- * @param string type Type of message (ok, info, alert, error)
- * @param string dest ID of destination DOM element
- * @param string message Message to be displayed
- * @param string bold Optional bold text preceding the error message
- */
- function Message (type, dest, message, bold) {
- this.id = new Date().getTime();
- this.type = type;
- this.dest = dest;
- if ( bold === undefined) {
- this.bold = '';
- }
- else {
- this.bold = bold;
- }
- this.message = message;
- this.showMessage = showMessage;
- this.hideMessage = hideMessage;
- this.clearAllMessages = clearAllMessages;
- }
- /**
- * Displays Message in previously defined DOM element
- * @author Danilo Bargen <gezuru@gmail.com>
- * @return false if invalid type was passed previously
- */
- function showMessage() {
- switch (this.type)
- {
- case 'ok':
- this.icon = 'check';
- this.classname = 'ok';
- break;
- case 'info':
- this.icon = 'info';
- this.classname = 'ok';
- break;
- case 'alert':
- this.icon = 'alert';
- this.classname = 'highlight';
- break;
- case 'error':
- this.icon = 'closethick';
- this.classname = 'error';
- break;
- default:
- return false;
- }
- this.msgHtml = '<div id="' + this.id + '" class="ui-state-' + this.classname + ' ui-corner-all" style="padding: 0em 0.6em;">';
- this.msgHtml = this.msgHtml + '<p><span class="ui-icon ui-icon-' + this.icon + '" style="float: left; margin-right: .3em;"></span>';
- this.msgHtml = this.msgHtml + '<strong>' + this.bold + '</strong> ' + this.message + '</p></div><br />';
- $('#'+this.id).remove();
- $('#'+this.dest).append(this.msgHtml);
- }
- /**
- * Removes Message from previously defined DOM element
- * @author Danilo Bargen <gezuru@gmail.com>
- */
- function hideMessage() {
- $('#'+this.id).remove();
- }
- /**
- * Removes all Messages from previously defined DOM element
- * @author Danilo Bargen <gezuru@gmail.com>
- */
- function clearAllMessages() {
- $('#'+this.dest).empty();
- }
Add Comment
Please, Sign In to add comment