From 0f119bf44a1a0597ee6b59ea8329f0a844bf8772 Mon Sep 17 00:00:00 2001 From: Hugo Lazzari Date: Tue, 9 Apr 2013 14:58:38 -0300 Subject: [PATCH] Removed from config template old sharedNotes options that aren't needed. Default file name to save file is the sharedNotes window name with all characters lowercased and all spaces transformed to '-'. Added config options to sharedNotes. --- .../resources/config.xml.template | 5 +- .../modules/sharednotes/SharedNotesOptions.as | 23 +++--- .../maps/SharedNotesEventMapDelegate.as | 34 ++++++--- .../sharednotes/views/SharedNotesWindow.mxml | 70 ++++--------------- .../sharednotes/views/ToolbarButton.mxml | 12 +++- .../views/components/PatchableTextArea.as | 13 ++-- 6 files changed, 66 insertions(+), 91 deletions(-) diff --git a/bigbluebutton-client/resources/config.xml.template b/bigbluebutton-client/resources/config.xml.template index 9ecb1a3b93..98608120c7 100755 --- a/bigbluebutton-client/resources/config.xml.template +++ b/bigbluebutton-client/resources/config.xml.template @@ -109,11 +109,8 @@ />--> - + @@ -93,11 +93,10 @@ textArea.visible = true; textArea.setCanvas(getMdiCanvas(parent) as MDICanvas); btnBackPlayback.visible = false; - btnPlayback.visible = options.enablePlayback; + btnPlayback.visible = false; playbackSlider.visible = false; lblPlaybackVersion.visible = false; - //textArea.addEventListener(Event.CHANGE, onTextChange); textArea.addEventListener(KeyboardEvent.KEY_DOWN, function(e:Event):void { if (!sendUpdateTimer.running) { sendUpdateTimer.reset(); @@ -108,17 +107,10 @@ sendUpdateTimer.addEventListener(TimerEvent.TIMER, function(e:Event):void { sendPatch(); - //dispatchEvent(new Event(SharedNotesDispatcher.SEND_PATCH_EVENT)); }); _dispatcher.dispatchEvent(new GetCurrentDocumentEvent()); - //addEventListener(ServerConnection.SYNCED_EVENT, onSynced); - //addEventListener(ServerConnection.SYNCING_EVENT, onSyncing); - - addEventListener(MDIWindowEvent.RESIZE, onResize); - //addEventListener(MDIWindowEvent.CLOSE, function(e:Event):void { if (client) client.shutdown(); }); - //client = new Client(this); - + addEventListener(MDIWindowEvent.RESIZE, onResize); onResize(); } @@ -133,7 +125,7 @@ sendPatchEvent.beginIndex = textArea.selectionBeginIndex; sendPatchEvent.endIndex = textArea.selectionEndIndex; //patchHistory.push(messageToSend.patchData); - _undoHistory.addItem([0,sendPatchEvent.patch]); + //_undoHistory.addItem([0,sendPatchEvent.patch]); _dispatcher.dispatchEvent(sendPatchEvent); _document = clientText; textArea.editable = true; @@ -141,37 +133,7 @@ } } - private function undoLastChange():void { - var newText:String = _initialDocument; - var myLastPatch:Array = null; - var myLastPatchIndex:int = -1; - sendUpdateTimer.stop(); - for (var i:int = 0; i < _undoHistory.length; i++) - { - var patchArray:Array = _undoHistory[i]; - LogUtil.debug("Number: " + patchArray[0] + " Index: " + i); - if(patchArray[0] == 0) { - myLastPatch = patchArray; - myLastPatchIndex = i; - } - newText = DiffPatch.patch(patchArray[1], newText); - } - if(myLastPatchIndex != -1) { - LogUtil.debug("Removi Number: " + _undoHistory[myLastPatchIndex][0] + " Index: " + myLastPatchIndex); - newText = DiffPatch.unpatch(_undoHistory[myLastPatchIndex][1], newText); - _undoHistory.removeItemAt(myLastPatchIndex); - textArea.editable = false; - onSyncing(); - var sendPatchEvent:SendPatchEvent = new SendPatchEvent(); - sendPatchEvent.patch = DiffPatch.diff(_document, newText); - _document = newText; - textArea.text = newText; - _dispatcher.dispatchEvent(sendPatchEvent); - textArea.editable = true; - onSynced(); - } - sendUpdateTimer.start(); - } + private function receivePatch(e:ReceivePatchEvent):void { if (e.patch != "") { @@ -179,7 +141,7 @@ _document = result; textArea.patchClientText(e.patch, e.beginIndex, e.endIndex); LogUtil.debug("ADD PATCH SERVER"); - _undoHistory.addItem([1,e.patch]); + //_undoHistory.addItem([1,e.patch]); } } @@ -230,15 +192,15 @@ const availableWidth:int = this.width - this.borderMetrics.left - this.borderMetrics.right; const availableHeight:int = this.height - this.borderMetrics.top - this.borderMetrics.bottom; - if (options.enablePlayback) { - if (BOTTOM_PADDING < Math.max(btnPlayback.height, btnBackPlayback.height) + 4) - BOTTOM_PADDING = Math.max(btnPlayback.height, btnBackPlayback.height) + 4; - btnPlayback.x = btnBackPlayback.x = LEFT_PADDING; - btnPlayback.y = btnBackPlayback.y = availableHeight - BOTTOM_PADDING + (BOTTOM_PADDING - Math.max(btnPlayback.height, btnBackPlayback.height)) / 2; - } else { + //if (options.enablePlayback) { + // if (BOTTOM_PADDING < Math.max(btnPlayback.height, btnBackPlayback.height) + 4) + // BOTTOM_PADDING = Math.max(btnPlayback.height, btnBackPlayback.height) + 4; + // btnPlayback.x = btnBackPlayback.x = LEFT_PADDING; + // btnPlayback.y = btnBackPlayback.y = availableHeight - BOTTOM_PADDING + (BOTTOM_PADDING - Math.max(btnPlayback.height, btnBackPlayback.height)) / 2; + //} else { btnPlayback.x = btnBackPlayback.x = 0; btnPlayback.y = btnBackPlayback.y = 0; - } + //} textArea.width = textArea.measuredWidth = txtPlayback.width = availableWidth - RIGHT_PADDING - LEFT_PADDING; textArea.height = textArea.measuredHeight = txtPlayback.height = availableHeight - TOP_PADDING - BOTTOM_PADDING; @@ -312,7 +274,7 @@ protected function btnSave_clickHandler(event:MouseEvent):void { - textArea.saveNotesToFile(); + textArea.saveNotesToFile(title); } @@ -337,10 +299,6 @@ } - public function get responseTimeout():int { - return options.responseTimeout; - } - override public function close(event:MouseEvent=null):void { //new Dispatcher().dispatchEvent(new Event(SHARED_NOTES_CLOSED, true)); super.close(event); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/ToolbarButton.mxml b/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/ToolbarButton.mxml index f5cd61a3a8..e2278b16fe 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/ToolbarButton.mxml +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/ToolbarButton.mxml @@ -41,6 +41,9 @@ import org.bigbluebutton.util.i18n.ResourceUtil; import org.bigbluebutton.modules.sharednotes.events.ToolbarButtonWindowEvent; import org.bigbluebutton.modules.sharednotes.events.JoinSharedNotesEvent; + import org.bigbluebutton.modules.sharednotes.events.GetCurrentDocumentEvent; + import org.bigbluebutton.modules.sharednotes.SharedNotesOptions; + [Embed(source="images/note_edit.png")] public var notes:Class; @@ -52,20 +55,25 @@ private var dispatcher:Dispatcher; private var window:SharedNotesWindow; private var _join:Boolean = false; + private var options:SharedNotesOptions = new SharedNotesOptions(); private function init():void{ _join = false; dispatcher = new Dispatcher(); this.addEventListener(SharedNotesWindow.SHARED_NOTES_CLOSED, closeEventHandler); + if(options.autoStart) { + openNotesWindow(); + } } - - private function openNotesWindow():void{ + + public function openNotesWindow(event:Event = null):void{ if (!this.selected) { if(!_join) { _join = true; dispatcher.dispatchEvent(new JoinSharedNotesEvent()); } dispatcher.dispatchEvent(new ToolbarButtonWindowEvent(ToolbarButtonWindowEvent.SHOW_WINDOW)); + dispatcher.dispatchEvent(new GetCurrentDocumentEvent()); this.selected = true; } else { dispatcher.dispatchEvent(new ToolbarButtonWindowEvent(ToolbarButtonWindowEvent.HIDE_WINDOW)); diff --git a/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/components/PatchableTextArea.as b/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/components/PatchableTextArea.as index fa31a26650..b9b7d340b1 100644 --- a/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/components/PatchableTextArea.as +++ b/bigbluebutton-client/src/org/bigbluebutton/modules/sharednotes/views/components/PatchableTextArea.as @@ -75,14 +75,15 @@ package org.bigbluebutton.modules.sharednotes.views.components return textField.text; } - public function saveNotesToFile():void { - this.textFieldText + public function saveNotesToFile(title:String):void { + var filename:String = title.replace(/\s+/g, '-').toLowerCase(); var _fileRef:FileReference = new FileReference(); _fileRef.addEventListener(Event.COMPLETE, function(e:Event):void { Alert.show(ResourceUtil.getInstance().getString('bbb.sharedNotes.save.complete'), "", Alert.OK, _canvas); }); - _fileRef.save(this.textFieldText, "sharedNotes.txt"); - LogUtil.debug("Tamanho Máximo: " + this.maxVerticalScrollPosition); + _fileRef.save(this.textFieldText, filename+".txt"); + + //Future code to add zoom and font format //var format:TextFormat = new TextFormat(); //format.color = 0x0000FF; //this.textField.setTextFormat( format, selectionBeginIndex, selectionBeginIndex+1 ) ; @@ -116,9 +117,9 @@ package org.bigbluebutton.modules.sharednotes.views.components else cursorLine = this.textField.getLineIndexOfChar(endIndex); - var relativePositon = cursorLine - this.verticalScrollPosition; + var relativePositon:Number = cursorLine - this.verticalScrollPosition; - var desloc = relativePositon - oldPosition; + var desloc:Number = relativePositon - oldPosition; this.verticalScrollPosition+=desloc; LogUtil.debug("relative: " + relativePositon);