1 /*!
  2  * This file is part of Aloha Editor
  3  * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
  4  * Licensed unter the terms of http://www.aloha-editor.com/license.html
  5  */
  6 
  7 /**
  8  * Registry base class.
  9  * TODO: document that it also contains Observable.
 10  *
 11  */
 12 define(
 13 ['aloha/jquery', 'aloha/observable'],
 14 function(jQuery, Observable) {
 15 	"use strict";
 16 
 17 	return Class.extend(Observable, {
 18 
 19 		_entries: null,
 20 
 21 		_constructor: function() {
 22 			this._entries = {};
 23 		},
 24 
 25 		/**
 26 		 * @event register
 27 		 * @param entry
 28 		 * @param id
 29 		 */
 30 		register: function(id, entry) {
 31 			this._entries[id] = entry;
 32 			this.trigger('register', entry, id);
 33 		},
 34 
 35 		/**
 36 		 * @event unregister
 37 		 * @param odEntry
 38 		 * @param id
 39 		 */
 40 		unregister: function(id) {
 41 			var oldEntry = this._entries[id];
 42 			delete this._entries[id];
 43 			this.trigger('unregister', oldEntry, id);
 44 		},
 45 		
 46 		get: function(id) {
 47 			return this._entries[id];
 48 		},
 49 		
 50 		has: function(id) {
 51 			return (this._entries[id] ? true : false);
 52 		},
 53 		
 54 		getEntries: function() {
 55 			// clone the entries so the user does not accidentally modify our _entries object.
 56 			return jQuery.extend({}, this._entries);
 57 		}
 58 	});
 59 });