Only send save operation of changes has been perfomed.

Change default SMTP port.
This commit is contained in:
Paulo Gustavo Veiga 2012-07-15 22:20:21 -03:00
parent d304909a86
commit 8d4b336908
9 changed files with 39 additions and 45 deletions

View File

@ -527,13 +527,6 @@ mindplot.Designer = new Class({
this._relPivot.start(nodes[0], pos);
},
needsSave:function () {
//@Todo: Review all this ...
return this._actionDispatcher._actionRunner.hasBeenChanged();
},
getMindmapProperties:function () {
return {zoom:this.getModel().getZoom()};
},

View File

@ -17,7 +17,7 @@
*/
mindplot.DesignerActionRunner = new Class({
initialize: function(commandContext, notifier) {
initialize:function (commandContext, notifier) {
$assert(commandContext, "commandContext can not be null");
this._undoManager = new mindplot.DesignerUndoManager();
@ -25,7 +25,7 @@ mindplot.DesignerActionRunner = new Class({
this._notifier = notifier;
},
execute:function(command) {
execute:function (command) {
$assert(command, "command can not be null");
command.execute(this._context);
this._undoManager.enqueue(command);
@ -34,29 +34,21 @@ mindplot.DesignerActionRunner = new Class({
},
undo: function() {
undo:function () {
this._undoManager.execUndo(this._context);
this.fireChangeEvent();
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
},
redo: function() {
redo:function () {
this._undoManager.execRedo(this._context);
this.fireChangeEvent();
mindplot.EventBus.instance.fireEvent(mindplot.EventBus.events.DoLayout);
},
fireChangeEvent : function () {
fireChangeEvent:function () {
var event = this._undoManager.buildEvent();
this._notifier.fireEvent("modelUpdate", event);
},
markAsChangeBase: function() {
return this._undoManager.markAsChangeBase();
},
hasBeenChanged: function() {
return this._undoManager.hasBeenChanged();
}
});

View File

@ -21,8 +21,6 @@ mindplot.DesignerUndoManager = new Class({
this._undoQueue = [];
this._redoQueue = [];
this._baseId = 0;
this._fireChange = fireChange;
},
enqueue:function(command) {
@ -62,9 +60,9 @@ mindplot.DesignerUndoManager = new Class({
},
markAsChangeBase: function() {
var undoLenght = this._undoQueue.length;
if (undoLenght > 0) {
var command = this._undoQueue[undoLenght - 1];
var undoLength = this._undoQueue.length;
if (undoLength > 0) {
var command = this._undoQueue[undoLength - 1];
this._baseId = command.getId();
} else {
this._baseId = 0;
@ -73,11 +71,11 @@ mindplot.DesignerUndoManager = new Class({
hasBeenChanged: function() {
var result = true;
var undoLenght = this._undoQueue.length;
if (undoLenght == 0 && this._baseId == 0) {
var undoLength= this._undoQueue.length;
if (undoLength == 0 && this._baseId == 0) {
result = false;
} else if (undoLenght > 0) {
var command = this._undoQueue[undoLenght - 1];
} else if (undoLength > 0) {
var command = this._undoQueue[undoLength - 1];
result = (this._baseId != command.getId());
}
return result;

View File

@ -23,12 +23,6 @@ mindplot.StandaloneActionDispatcher = new Class({
this._actionRunner = new mindplot.DesignerActionRunner(commandContext, this);
},
hasBeenChanged:function () {
// @todo: This don't seems to belong here.
this._actionRunner.hasBeenChanged();
},
addTopics:function (models, parentTopicsId) {
var command = new mindplot.commands.AddTopicCommand(models, parentTopicsId);
this.execute(command);

View File

@ -26,6 +26,12 @@ mindplot.widget.IMenu = new Class({
this._toolbarElems = [];
this._containerId = containerId;
this._mapId = mapId;
this._mindmapUpdated = false;
// Register update events ...
this._designer.addEvent('modelUpdate', function () {
this.setRequireChange(true);
}.bind(this));
},
clear:function () {
@ -35,9 +41,17 @@ mindplot.widget.IMenu = new Class({
},
discardChanges:function () {
// Avoid autosave before leaving the page ....
this.setRequireChange(false);
// Finally call discard function ...
var persistenceManager = mindplot.PersistenceManager.getInstance();
var mindmap = designer.getMindmap();
persistenceManager.discardChanges(mindmap.getId());
// Reload the page ...
window.location.reload();
},
save:function (saveElem, designer, saveHistory) {
@ -54,6 +68,7 @@ mindplot.widget.IMenu = new Class({
}
// Call persistence manager for saving ...
var menu = this;
var persistenceManager = mindplot.PersistenceManager.getInstance();
persistenceManager.save(mindmap, mindmapProp, saveHistory, {
onSuccess:function () {
@ -61,6 +76,7 @@ mindplot.widget.IMenu = new Class({
saveElem.setStyle('cursor', 'pointer');
$notify($msg('SAVE_COMPLETE'));
}
menu.setRequireChange(false);
},
onError:function () {
if (saveHistory) {
@ -69,5 +85,13 @@ mindplot.widget.IMenu = new Class({
}
}
});
},
isSaveRequired:function () {
return this._mindmapUpdated;
},
setRequireChange:function (value) {
this._mindmapUpdated = value;
}
});

View File

@ -304,14 +304,14 @@ mindplot.widget.Menu = new Class({
if (!readOnly) {
// To prevent the user from leaving the page with changes ...
$(window).addEvent('beforeunload', function () {
if (designer.needsSave()) {
if (this.isSaveRequired()) {
this.save(saveElem, designer, false);
}
}.bind(this));
// Autosave on a fixed period of time ...
(function () {
if (designer.needsSave()) {
if (this.isSaveRequired()) {
this.save(saveElem, designer, false);
}
}.bind(this)).periodical(30000);
@ -321,14 +321,7 @@ mindplot.widget.Menu = new Class({
var discardElem = $('discard');
if (discardElem) {
this._addButton('discard', false, false, function () {
// Avoid autosave before leaving the page ....
$(window).removeEvents(['beforeunload']);
// Discard changes ...
this.discardChanges();
// Reload the page ...
window.location.reload();
}.bind(this));
this._registerTooltip('discard', $msg('DISCARD_CHANGES'));
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

View File

@ -24,7 +24,7 @@ database.password=
#------------------------
# Plain SMTP Server Configuration
#------------------------
mail.smtp.port=465
mail.smtp.port=25
mail.smtp.host=localhost
mail.username=root
mail.password=