Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Beata Lin committed Aug 16, 2011
1 parent 72fb1ba commit 799fdd1
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 142 deletions.
24 changes: 10 additions & 14 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,10 @@ <h1>From file</h1>
</script>

<script id="template-save" type="text/x-jquery-tmpl">
<div id="save-dialog" class="file-dialog" title="Save mind map">
<div id="save-dialog" class="file-dialog" title="Save mind map in local storage">
<h1>Local Storage</h1>
<p>You can save your mind map in your browser's local storage. Be aware that this is still experimental: the space is limited and there is no guarantee that the browser will keep this document forever.</p>
<button id="button-save-localstorage">Save</button>
<div class="seperator"></div>
<h1>To file</h1>
<p>Save the mind map as a file on your computer.</p>
<div id="button-save-hdd">Save</div>
</div>
</script>

Expand Down Expand Up @@ -121,19 +117,19 @@ <h1>To file</h1>
<td>Font style:</td>
<td><div
class="font-styles buttonset buttons-very-small buttons-less-padding">
<input type="checkbox" id="inspector-checkbox-font-bold" />
<input type="checkbox" id="inspector-checkbox-font-bold" />
<label
for="inspector-checkbox-font-bold" id="inspector-label-font-bold">B</label>
<input type="checkbox" id="inspector-checkbox-font-italic" />

<input type="checkbox" id="inspector-checkbox-font-italic" />
<label
for="inspector-checkbox-font-italic" id="inspector-label-font-italic">I</label>
for="inspector-checkbox-font-italic" id="inspector-label-font-italic">I</label>

<input
type="checkbox" id="inspector-checkbox-font-underline" />
type="checkbox" id="inspector-checkbox-font-underline" />
<label
for="inspector-checkbox-font-underline" id="inspector-label-font-underline">U</label>
for="inspector-checkbox-font-underline" id="inspector-label-font-underline">U</label>

<input
type="checkbox" id="inspector-checkbox-font-linethrough" />
<label
Expand Down Expand Up @@ -283,4 +279,4 @@ <h2 class='image-description'>To download the map right-click the
</script>
/PRODUCTION -->
</body>
</html>
</html>
17 changes: 13 additions & 4 deletions src/js/ApplicationController.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Creates a new Application Controller.
*
*
* @constructor
*/
mindmaps.ApplicationController = function() {
Expand Down Expand Up @@ -59,8 +59,7 @@ mindmaps.ApplicationController = function() {
}

function doExportDocument() {
var presenter = new mindmaps.ExportMapPresenter(eventBus,
mindmapModel, new mindmaps.ExportMapView());
var presenter = new mindmaps.ExportMapPresenter(eventBus, mindmapModel);
presenter.go();
}

Expand Down Expand Up @@ -90,10 +89,20 @@ mindmaps.ApplicationController = function() {
var exportCommand = commandRegistry.get(mindmaps.ExportCommand);
exportCommand.setHandler(doExportDocument);

var urlParams = mindmaps.Util.getUrlParams();

eventBus.subscribe(mindmaps.Event.IMAGE_EXPORT, function(image){
$('<form action="'
+ urlParams.target
+ '" method="post"><input type="hidden" name="image" value="'
+ image + '" /></form>').appendTo('body').trigger('submit');
});

eventBus.subscribe(mindmaps.Event.DOCUMENT_CLOSED, function() {
saveDocumentCommand.setEnabled(false);
closeDocumentCommand.setEnabled(false);
exportCommand.setEnabled(false);
window.location.href = urlParams.exit;
});

eventBus.subscribe(mindmaps.Event.DOCUMENT_OPENED, function() {
Expand All @@ -118,4 +127,4 @@ mindmaps.ApplicationController = function() {
};

this.init();
};
};
73 changes: 37 additions & 36 deletions src/js/Command.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Creates a new command. Base class for all commands
*
*
* @constructor
* @borrows EventEmitter
*/
Expand All @@ -9,7 +9,7 @@ mindmaps.Command = function() {
this.shortcut = null;
/**
* The handler function.
*
*
* @private
* @function
*/
Expand Down Expand Up @@ -52,7 +52,7 @@ mindmaps.Command.prototype = {

/**
* Registers a new handler.
*
*
* @param {Function} handler
*/
setHandler : function(handler) {
Expand All @@ -71,7 +71,7 @@ mindmaps.Command.prototype = {

/**
* Sets the enabled state of the command.
*
*
* @param {Boolean} enabled
*/
setEnabled : function(enabled) {
Expand All @@ -90,7 +90,7 @@ EventEmitter.mixin(mindmaps.Command);

/**
* Creates a new CreateNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -105,7 +105,7 @@ mindmaps.CreateNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new CreateSiblingNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -120,7 +120,7 @@ mindmaps.CreateSiblingNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new DeleteNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -135,7 +135,7 @@ mindmaps.DeleteNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new EditNodeCaptionCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -149,7 +149,7 @@ mindmaps.EditNodeCaptionCommand.prototype = new mindmaps.Command();

/**
* Creates a new ToggleNodeFoldedCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -166,7 +166,7 @@ mindmaps.ToggleNodeFoldedCommand.prototype = new mindmaps.Command();

/**
* Creates a new UndoCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -181,7 +181,7 @@ mindmaps.UndoCommand.prototype = new mindmaps.Command();

/**
* Creates a new RedoCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -200,7 +200,7 @@ mindmaps.RedoCommand.prototype = new mindmaps.Command();

/**
* Creates a new CopyNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -215,7 +215,7 @@ mindmaps.CopyNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new CutNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -230,7 +230,7 @@ mindmaps.CutNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new PasteNodeCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -249,7 +249,7 @@ mindmaps.PasteNodeCommand.prototype = new mindmaps.Command();

/**
* Creates a new NewDocumentCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -263,7 +263,7 @@ mindmaps.NewDocumentCommand.prototype = new mindmaps.Command();

/**
* Creates a new OpenDocumentCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -278,22 +278,37 @@ mindmaps.OpenDocumentCommand.prototype = new mindmaps.Command();

/**
* Creates a new SaveDocumentCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
mindmaps.SaveDocumentCommand = function() {
this.id = "SAVE_DOCUMENT_COMMAND";
this.label = "Local Storage...";
this.icon = "ui-icon-disk";
this.description = "Save the mind map in the local storage";
};
mindmaps.SaveDocumentCommand.prototype = new mindmaps.Command();

/**
* Creates a new ExportCommand.
* post to target in api version
*
* @constructor
* @augments mindmaps.Command
*/
mindmaps.ExportCommand = function() {
this.id = "EXPORT_COMMAND";
this.icon = "ui-icon-disk";
this.label = "Save...";
this.shortcut = "ctrl+s";
this.icon = "ui-icon-disk";
this.description = "Save the mind map";
};
mindmaps.SaveDocumentCommand.prototype = new mindmaps.Command();
mindmaps.ExportCommand.prototype = new mindmaps.Command();

/**
* Creates a new CloseDocumentCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -307,7 +322,7 @@ mindmaps.CloseDocumentCommand.prototype = new mindmaps.Command();

/**
* Creates a new HelpCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -323,7 +338,7 @@ mindmaps.HelpCommand.prototype = new mindmaps.Command();

/**
* Creates a new PrintCommand.
*
*
* @constructor
* @augments mindmaps.Command
*/
Expand All @@ -335,17 +350,3 @@ mindmaps.PrintCommand = function() {
this.description = "Print the mind map";
};
mindmaps.PrintCommand.prototype = new mindmaps.Command();

/**
* Creates a new ExportCommand.
*
* @constructor
* @augments mindmaps.Command
*/
mindmaps.ExportCommand = function() {
this.id = "EXPORT_COMMAND";
this.icon = "ui-icon-image";
this.label = "Export As Image...";
this.description = "Export the mind map";
};
mindmaps.ExportCommand.prototype = new mindmaps.Command();
22 changes: 14 additions & 8 deletions src/js/Event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Events that the event bus carries.
*
*
* @namespace
*/
mindmaps.Event = {
Expand All @@ -22,6 +22,12 @@ mindmaps.Event = {
*/
DOCUMENT_CLOSED : "DocumentClosedEvent",

/**
* @event
* @param {String} base64EncodedImage
*/
IMAGE_EXPORT : "ImageExportEvent",

/**
* @event
* @param {mindmaps.Node} node
Expand Down Expand Up @@ -49,7 +55,7 @@ mindmaps.Event = {

/**
* Some parameter of the node font attribute has changed.
*
*
* @event
* @param {mindmaps.Node} node
*/
Expand Down Expand Up @@ -91,19 +97,19 @@ mindmaps.Event = {
* @param {Number} zoomFactor
*/
ZOOM_CHANGED : "ZoomChangedEvent",

/**
* @event
* @param {String} message
*/
NOTIFICATION_INFO: "NotificationInfoEvent",

/**
* @event
* @param {String} message
*/
NOTIFICATION_WARN: "NotificationWarnEvent",

/**
* @event
* @param {String} message
Expand All @@ -113,10 +119,10 @@ mindmaps.Event = {

/**
* Simple Event bus powered by EventEmitter.
*
*
* @constructor
* @augments EventEmitter
*
*
*/
mindmaps.EventBus = EventEmitter;

Expand All @@ -129,4 +135,4 @@ if (mindmaps.DEBUG) {

old.apply(this, arguments);
};
}
}
Loading

0 comments on commit 799fdd1

Please sign in to comment.