| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 | 
							- /* global $, config, Prezi, Util, connection, setLargeVideoVisible, dockToolbar */
 - var Etherpad = (function (my) {
 -     var etherpadName = null;
 -     var etherpadIFrame = null;
 -     var domain = null;
 -     var options = "?showControls=true&showChat=false&showLineNumbers=true&useMonospaceFont=false";
 - 
 -     /**
 -      * Initializes the etherpad.
 -      */
 -     my.init = function (name) {
 - 
 -         if (config.etherpad_base && !etherpadName) {
 - 
 -             domain = config.etherpad_base;
 - 
 -             if (!name) {
 -                 // In case we're the focus we generate the name.
 -                 etherpadName = Math.random().toString(36).substring(7) +
 -                                 '_' + (new Date().getTime()).toString();
 -                 shareEtherpad();
 -             }
 -             else
 -                 etherpadName = name;
 - 
 -             enableEtherpadButton();
 -         }
 -     };
 - 
 -     /**
 -      * Opens/hides the Etherpad.
 -      */
 -     my.toggleEtherpad = function (isPresentation) {
 -         if (!etherpadIFrame)
 -             createIFrame();
 - 
 -         var largeVideo = null;
 -         if (Prezi.isPresentationVisible())
 -             largeVideo = $('#presentation>iframe');
 -         else
 -             largeVideo = $('#largeVideo');
 - 
 -         if ($('#etherpad>iframe').css('visibility') === 'hidden') {
 -             largeVideo.fadeOut(300, function () {
 -                 if (Prezi.isPresentationVisible()) {
 -                     largeVideo.css({opacity: '0'});
 -                 } else {
 -                     VideoLayout.setLargeVideoVisible(false);
 -                     ToolbarToggler.dockToolbar(true);
 -                 }
 - 
 -                 $('#etherpad>iframe').fadeIn(300, function () {
 -                     document.body.style.background = '#eeeeee';
 -                     $('#etherpad>iframe').css({visibility: 'visible'});
 -                     $('#etherpad').css({zIndex: 2});
 -                 });
 -             });
 -         }
 -         else if ($('#etherpad>iframe')) {
 -             $('#etherpad>iframe').fadeOut(300, function () {
 -                 $('#etherpad>iframe').css({visibility: 'hidden'});
 -                 $('#etherpad').css({zIndex: 0});
 -                 document.body.style.background = 'black';
 -                 if (!isPresentation) {
 -                     $('#largeVideo').fadeIn(300, function () {
 -                         VideoLayout.setLargeVideoVisible(true);
 -                         ToolbarToggler.dockToolbar(false);
 -                     });
 -                 }
 -             });
 -         }
 -         resize();
 -     };
 - 
 -     /**
 -      * Resizes the etherpad.
 -      */
 -     function resize() {
 -         if ($('#etherpad>iframe').length) {
 -             var remoteVideos = $('#remoteVideos');
 -             var availableHeight
 -                 = window.innerHeight - remoteVideos.outerHeight();
 -             var availableWidth = Util.getAvailableVideoWidth();
 - 
 -             $('#etherpad>iframe').width(availableWidth);
 -             $('#etherpad>iframe').height(availableHeight);
 -         }
 -     }
 - 
 -     /**
 -      * Shares the Etherpad name with other participants.
 -      */
 -     function shareEtherpad() {
 -         connection.emuc.addEtherpadToPresence(etherpadName);
 -         connection.emuc.sendPresence();
 -     }
 - 
 -     /**
 -      * Creates the Etherpad button and adds it to the toolbar.
 -      */
 -     function enableEtherpadButton() {
 -         if (!$('#etherpadButton').is(":visible"))
 -             $('#etherpadButton').css({display: 'inline-block'});
 -     }
 - 
 -     /**
 -      * Creates the IFrame for the etherpad.
 -      */
 -     function createIFrame() {
 -         etherpadIFrame = document.createElement('iframe');
 -         etherpadIFrame.src = domain + etherpadName + options;
 -         etherpadIFrame.frameBorder = 0;
 -         etherpadIFrame.scrolling = "no";
 -         etherpadIFrame.width = $('#largeVideoContainer').width() || 640;
 -         etherpadIFrame.height = $('#largeVideoContainer').height() || 480;
 -         etherpadIFrame.setAttribute('style', 'visibility: hidden;');
 - 
 -         document.getElementById('etherpad').appendChild(etherpadIFrame);
 -     }
 - 
 -     /**
 -      * On Etherpad added to muc.
 -      */
 -     $(document).bind('etherpadadded.muc', function (event, jid, etherpadName) {
 -         console.log("Etherpad added", etherpadName);
 -         if (config.etherpad_base && !focus) {
 -             Etherpad.init(etherpadName);
 -         }
 -     });
 - 
 -     /**
 -      * On focus changed event.
 -      */
 -     $(document).bind('focusechanged.muc', function (event, focus) {
 -         console.log("Focus changed");
 -         if (config.etherpad_base)
 -             shareEtherpad();
 -     });
 - 
 -     /**
 -      * On video selected event.
 -      */
 -     $(document).bind('video.selected', function (event, isPresentation) {
 -         if (!config.etherpad_base)
 -             return;
 - 
 -         if (etherpadIFrame && etherpadIFrame.style.visibility !== 'hidden')
 -             Etherpad.toggleEtherpad(isPresentation);
 -     });
 - 
 -     /**
 -      * Resizes the etherpad, when the window is resized.
 -      */
 -     $(window).resize(function () {
 -         resize();
 -     });
 - 
 -     return my;
 - }(Etherpad || {}));
 
 
  |