1 /*!
  2 * This file is part of Aloha Editor Project http://aloha-editor.org
  3 * Copyright © 2010-2011 Gentics Software GmbH, aloha@gentics.com
  4 * Contributors http://aloha-editor.org/contribution.php 
  5 * Licensed unter the terms of http://www.aloha-editor.org/license.html
  6 *//*
  7 * Aloha Editor is free software: you can redistribute it and/or modify
  8 * it under the terms of the GNU Affero General Public License as published by
  9 * the Free Software Foundation, either version 3 of the License, or
 10 * (at your option) any later version.*
 11 *
 12 * Aloha Editor is distributed in the hope that it will be useful,
 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 15 * GNU Affero General Public License for more details.
 16 *
 17 * You should have received a copy of the GNU Affero General Public License
 18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 19 */
 20 
 21 define(
 22 ['aloha/core', 'util/class', 'aloha/jquery'],
 23 function( Aloha, Class, jQuery ) {
 24 	"use strict";
 25 	
 26 	var
 27 //		Aloha = window.Aloha,
 28 //		Class = window.Class,
 29 		GENTICS = window.GENTICS;
 30 
 31 /**
 32  * Message Object
 33  * @namespace Aloha
 34  * @class Message
 35  * @constructor
 36  * @param {Object} data object which contains the parts of the message
 37  *		title: the title
 38  *		text: the message text to be displayed
 39  *		type: one of Aloha.Message.Type
 40  *		callback: callback function, which will be triggered after the message was confirmed, closed or accepted
 41  */
 42 Aloha.Message = Class.extend({
 43 	_constructor: function (data) {
 44 		this.title = data.title;
 45 		this.text = data.text;
 46 		this.type = data.type;
 47 		this.callback = data.callback;
 48 	},
 49 
 50 
 51 
 52 	/**
 53 	 * Returns a textual representation of the message
 54 	 * @return textual representation of the message
 55 	 * @hide
 56 	 */
 57 	toString: function () {
 58 	  return this.type + ': ' + this.message;
 59 	}
 60 });
 61 
 62 /**
 63  * Message types enum. Contains all allowed types of messages
 64  * @property
 65  */
 66 Aloha.Message.Type = {
 67 	// reserved for messages
 68 	//	SUCCESS : 'success',
 69 	//	INFO : 'info',
 70 	//	WARN : 'warn',
 71 	//	CRITICAL : 'critical',
 72 	CONFIRM : 'confirm', // confirm dialog, like js confirm()
 73 	ALERT : 'alert', // alert dialog like js alert()
 74 	WAIT : 'wait' // wait dialog with loading bar. has to be hidden via Aloha.hideMessage()
 75 };
 76 
 77 /**
 78  * This is the message line
 79  * @hide
 80  */
 81 Aloha.MessageLine = Class.extend({
 82 	messages: [],
 83 
 84 	/**
 85 	 * Add a new message to the message line
 86 	 * @param message message to add
 87 	 * @return void
 88 	 * @hide
 89 	 */
 90 	add: function(message) {
 91 		var messageline = '',
 92 			messagesLength = this.messages.length,
 93 			i;
 94 		
 95 		// dummy implementation to add a message
 96 		this.messages[messagesLength] = message;
 97 		while(messagesLength > 4) {
 98 			this.messages.shift();
 99 			--messagesLength;
100 		}
101 
102 		for ( i = 0; i < messagesLength; i++) {
103 			messageline += this.messages[i].toString() + '<br/>';
104 		}
105 		jQuery('#gtx_aloha_messageline').html(messageline);
106 	}
107 });
108 
109 110 /**
111  * Message Line Object
112  * @hide
113  */
114 Aloha.MessageLine = new Aloha.MessageLine();
115 
116 });
117