1 /*
  2  * 	Copyright (C) 2012-2013 DFKI GmbH
  3  * 	Deutsches Forschungszentrum fuer Kuenstliche Intelligenz
  4  * 	German Research Center for Artificial Intelligence
  5  * 	http://www.dfki.de
  6  * 
  7  * 	Permission is hereby granted, free of charge, to any person obtaining a 
  8  * 	copy of this software and associated documentation files (the 
  9  * 	"Software"), to deal in the Software without restriction, including 
 10  * 	without limitation the rights to use, copy, modify, merge, publish, 
 11  * 	distribute, sublicense, and/or sell copies of the Software, and to 
 12  * 	permit persons to whom the Software is furnished to do so, subject to 
 13  * 	the following conditions:
 14  * 
 15  * 	The above copyright notice and this permission notice shall be included 
 16  * 	in all copies or substantial portions of the Software.
 17  * 
 18  * 	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 
 19  * 	OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
 20  * 	MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 
 21  * 	IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 
 22  * 	CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 
 23  * 	TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 
 24  * 	SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 25  */
 26 
 27 
 28 newMediaPlugin = {
 29 		/**  @memberOf WaitReadyIndicatorImpl# */
 30 		initialize: function(callBack){//, mediaManager){//DISABLED this argument is currently un-used -> disabled
 31 			
 32 			
 33 			require(['waitDialog'], function(dlg){
 34 
 35 				/**  @memberOf WaitReadyIndicatorImpl# */
 36 				var _pluginName = 'waitReadyIndicator';
 37 				
 38 				/** 
 39 				 * @type mmir.LanguageManager
 40 				 * @memberOf WaitReadyIndicatorImpl#
 41 				 */
 42 				var languageManager = require('languageManager');
 43 				
 44 				/**  @memberOf WaitReadyIndicatorImpl# */
 45 				var _id = 'media-plugin-wait';
 46 				
 47 				/**  @memberOf WaitReadyIndicatorImpl# */
 48 				var caption;
 49 				
 50 				/**  @memberOf WaitReadyIndicatorImpl# */
 51 				var cssUrl = 'mmirf/vendor/styles/' + dlg.styleUrl;//TODO make this configurable / retrieve this setting from somewhere
 52 				
 53 				//load the stylesheet file for the wait-dialog
 54 				// (does nothing, if this load-function was already called before)
 55 				dlg._loadStyle(cssUrl);
 56 				
 57 				//create the DOM elements for the wait dialog (hidden)
 58 				dlg.create(_id);//, {type: 'verbose', theme: 'a'});//DISABLED: these are the default options
 59 				
 60 				//invoke the passed-in initializer-callback and export the public functions:
 61 				callBack({waitReadyImpl: {
 62 						/**
 63 						 * Shows wait dialog.
 64 						 * 
 65 						 * @public
 66 						 * @memberOf WaitReadyIndicatorImpl.prototype
 67 						 * @see mmir.MediaManager#_preparing
 68 						 */
 69 					    preparing: function (){
 70 					    	var text = typeof caption !== 'undefined'? caption : languageManager.getText('loadingText');
 71 					    	dlg.show(text, _id);
 72 					    },
 73 					    /**
 74 					     * Hides wait dialog.
 75 					     * 
 76 						 * @public
 77 						 * @memberOf WaitReadyIndicatorImpl.prototype
 78 						 * @see mmir.MediaManager#_ready
 79 						 */
 80 		    			ready: function(){
 81 		    				dlg.hide(_id);
 82 		    			},
 83 		    			/**
 84 		    			 * Set caption for wait dialog.
 85 		    			 * 
 86 		    			 * <p>
 87 		    			 * By default (i.e. not set), the dictionary entry for
 88 		    			 * "loadingText" is used as caption / label.
 89 		    			 * 
 90 		    			 * @param {String} text
 91 		    			 * 		set the caption / label for the wait-dialog.<br>
 92 		    			 * 		If <code>undefined</code>, the default caption will be used.
 93 		    			 * 
 94 						 * @public
 95 						 * @memberOf WaitReadyIndicatorImpl.prototype
 96 						 * @see mmir.MediaManager#ready
 97 						 * @see mmir.LanguageManager#getText
 98 						 */
 99 					    setWaitCaption: function(text){
100 		    				caption = text;
101 		    			},
102 		    			/**
103 		    			 * Get current caption for wait dialog.
104 		    			 * 
105 		    			 * NOTE if none is set, then internally the value of "loadingText"
106 		    			 * property of the current language dictionary will be used.
107 		    			 * 
108 						 * @public
109 						 * @memberOf WaitReadyIndicatorImpl.prototype
110 						 * @see mmir.MediaManager#_ready
111 						 * @see #setWaitCaption
112 						 */
113 					    getWaitCaption: function(){
114 		    				return caption;
115 		    			}
116 				}});
117 				
118 			});
119 			
120 		}
121 };