mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-22 14:17:57 +01:00
Fix zoom.
This commit is contained in:
parent
046789bb6a
commit
b9ff7f9c03
@ -1,130 +1,118 @@
|
||||
/*
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
* Copyright [2011] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
core.Monitor = function(fadeElement, logContentElem)
|
||||
{
|
||||
$assert(fadeElement, "fadeElement can not be null");
|
||||
$assert(logContentElem, "logContentElem can not be null");
|
||||
core.Monitor = new Class({
|
||||
initialize : function(fadeElement, logContentElem) {
|
||||
$assert(fadeElement, "fadeElement can not be null");
|
||||
$assert(logContentElem, "logContentElem can not be null");
|
||||
|
||||
this.pendingMessages = [];
|
||||
this.inProgress = false;
|
||||
this._container = fadeElement;
|
||||
this._currentMessage = null;
|
||||
this._logContentElem = logContentElem;
|
||||
this.pendingMessages = [];
|
||||
this.inProgress = false;
|
||||
this._container = fadeElement;
|
||||
this._currentMessage = null;
|
||||
this._logContentElem = logContentElem;
|
||||
|
||||
this._fxOpacity = fadeElement.effect('opacity', { duration: 6000 });
|
||||
this._fxOpacity = fadeElement.effect('opacity', { duration: 6000 });
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
core.Monitor.prototype._logMessage = function(msg, msgKind)
|
||||
{
|
||||
this._fxOpacity.clearTimer();
|
||||
if (msgKind == core.Monitor.MsgKind.ERROR)
|
||||
{
|
||||
msg = "<div id='small_error_icon'>" + msg + "</div>";
|
||||
}
|
||||
this._currentMessage = msg;
|
||||
this._fxOpacity.start(1, 0);
|
||||
this._logContentElem.innerHTML = msg;
|
||||
_logMessage : function(msg, msgKind) {
|
||||
this._fxOpacity.clearTimer();
|
||||
if (msgKind == core.Monitor.MsgKind.ERROR) {
|
||||
msg = "<div id='small_error_icon'>" + msg + "</div>";
|
||||
}
|
||||
this._currentMessage = msg;
|
||||
this._fxOpacity.start(1, 0);
|
||||
this._logContentElem.innerHTML = msg;
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
core.Monitor.prototype.logError = function(userMsg)
|
||||
{
|
||||
this.logMessage(userMsg, core.Monitor.MsgKind.ERROR);
|
||||
};
|
||||
logError : function(userMsg) {
|
||||
this.logMessage(userMsg, core.Monitor.MsgKind.ERROR);
|
||||
console.log(userMsg);
|
||||
},
|
||||
|
||||
core.Monitor.prototype.logFatal = function(userMsg)
|
||||
{
|
||||
this.logMessage(userMsg, core.Monitor.MsgKind.FATAL);
|
||||
};
|
||||
logFatal : function(userMsg) {
|
||||
this.logMessage(userMsg, core.Monitor.MsgKind.FATAL);
|
||||
},
|
||||
|
||||
core.Monitor.prototype.logMessage = function(msg, msgKind)
|
||||
{
|
||||
if (!msgKind)
|
||||
{
|
||||
msgKind = core.Monitor.MsgKind.INFO;
|
||||
}
|
||||
logMessage : function(msg, msgKind) {
|
||||
if (!msgKind) {
|
||||
msgKind = core.Monitor.MsgKind.INFO;
|
||||
}
|
||||
|
||||
if (msgKind == core.Monitor.MsgKind.FATAL)
|
||||
{
|
||||
// In this case, a modal dialog must be shown... No recovery is possible.
|
||||
new Windoo.Alert(msg,
|
||||
{
|
||||
'window': { theme:Windoo.Themes.aero,
|
||||
title:"Outch!!. An unexpected error.",
|
||||
'onClose':function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else
|
||||
{
|
||||
var messages = this.pendingMessages;
|
||||
var monitor = this;
|
||||
|
||||
if (!this.executer)
|
||||
{
|
||||
// Log current message ...
|
||||
monitor._logMessage(msg, msgKind);
|
||||
|
||||
// Start worker thread ...
|
||||
var disptacher = function()
|
||||
{
|
||||
if (messages.length > 0)
|
||||
if (msgKind == core.Monitor.MsgKind.FATAL) {
|
||||
// In this case, a modal dialog must be shown... No recovery is possible.
|
||||
new Windoo.Alert(msg,
|
||||
{
|
||||
var msgToDisplay = messages.shift();
|
||||
monitor._logMessage(msgToDisplay);
|
||||
}
|
||||
'window': { theme:Windoo.Themes.aero,
|
||||
title:"Outch!!. An unexpected error.",
|
||||
'onClose':function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var messages = this.pendingMessages;
|
||||
var monitor = this;
|
||||
|
||||
// Stop thread?
|
||||
if (messages.length == 0)
|
||||
{
|
||||
$clear(monitor.executer);
|
||||
monitor.executer = null;
|
||||
monitor._fxOpacity.hide();
|
||||
this._currentMessage = null;
|
||||
if (!this.executer) {
|
||||
// Log current message ...
|
||||
monitor._logMessage(msg, msgKind);
|
||||
|
||||
// Start worker thread ...
|
||||
var disptacher = function() {
|
||||
if (messages.length > 0) {
|
||||
var msgToDisplay = messages.shift();
|
||||
monitor._logMessage(msgToDisplay);
|
||||
}
|
||||
|
||||
// Stop thread?
|
||||
if (messages.length == 0) {
|
||||
$clear(monitor.executer);
|
||||
monitor.executer = null;
|
||||
monitor._fxOpacity.hide();
|
||||
this._currentMessage = null;
|
||||
}
|
||||
};
|
||||
this.executer = disptacher.periodical(600);
|
||||
} else {
|
||||
if (this._currentMessage != msg) {
|
||||
messages.push(msg);
|
||||
}
|
||||
};
|
||||
this.executer = disptacher.periodical(600);
|
||||
} else
|
||||
{
|
||||
if (this._currentMessage != msg)
|
||||
{
|
||||
messages.push(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
core.Monitor.setInstance = function(monitor)
|
||||
{
|
||||
core.Monitor.setInstance = function(monitor) {
|
||||
this.monitor = monitor;
|
||||
};
|
||||
|
||||
core.Monitor.getInstance = function()
|
||||
{
|
||||
core.Monitor.getInstance = function() {
|
||||
var result = this.monitor;
|
||||
if (result == null)
|
||||
{
|
||||
if (result == null) {
|
||||
result = {
|
||||
logError: function() {
|
||||
logError: function(msg) {
|
||||
console.log(msg)
|
||||
},
|
||||
logMessage: function() {
|
||||
|
||||
logMessage: function(msg) {
|
||||
console.log(msg)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -30,15 +30,11 @@ mindplot.MindmapDesigner = new Class({
|
||||
this._fireEvent("modelUpdate", event);
|
||||
}.bind(this));
|
||||
mindplot.ActionDispatcher.setInstance(this._actionDispatcher);
|
||||
|
||||
// Initial Zoom
|
||||
this._zoom = profile.zoom;
|
||||
|
||||
this._model = new mindplot.DesignerModel(profile);
|
||||
|
||||
// Init Screen manager..
|
||||
var screenManager = new mindplot.ScreenManager(profile.width, profile.height, divElement);
|
||||
this._workspace = new mindplot.Workspace(profile, screenManager, this._zoom);
|
||||
this._workspace = new mindplot.Workspace(profile, screenManager, this._model.getZoom());
|
||||
this._readOnly = profile.readOnly ? true : false;
|
||||
|
||||
// Init layout managers ...
|
||||
@ -198,22 +194,6 @@ mindplot.MindmapDesigner = new Class({
|
||||
|
||||
},
|
||||
|
||||
zoomOut : function(factor) {
|
||||
if (!factor)
|
||||
factor = 1.2;
|
||||
|
||||
var model = this.getModel();
|
||||
var scale = model.getZoom() * factor;
|
||||
if (scale <= 4) {
|
||||
model.setZoom(scale);
|
||||
this._workspace.setZoom(this._zoom);
|
||||
}
|
||||
else {
|
||||
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
selectAll : function() {
|
||||
var model = this.getModel();
|
||||
var objects = model.getObjects();
|
||||
@ -229,15 +209,33 @@ mindplot.MindmapDesigner = new Class({
|
||||
});
|
||||
},
|
||||
|
||||
|
||||
zoomOut : function(factor) {
|
||||
if (!factor)
|
||||
factor = 1.2;
|
||||
|
||||
var model = this.getModel();
|
||||
var scale = model.getZoom() * factor;
|
||||
if (scale <= 1.9) {
|
||||
model.setZoom(scale);
|
||||
this._workspace.setZoom(scale);
|
||||
}
|
||||
else {
|
||||
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
zoomIn : function(factor) {
|
||||
if (!factor)
|
||||
factor = 1.2;
|
||||
|
||||
var model = this.getModel();
|
||||
var scale = model.getZoom() / factor;
|
||||
|
||||
if (scale >= 0.3) {
|
||||
model.setZoom(scale);
|
||||
this._workspace.setZoom(this._zoom);
|
||||
this._workspace.setZoom(scale);
|
||||
}
|
||||
else {
|
||||
core.Monitor.getInstance().logMessage('Sorry, no more zoom can be applied. \n Why do you need more?');
|
||||
@ -383,7 +381,7 @@ mindplot.MindmapDesigner = new Class({
|
||||
var persistantManager = mindplot.PersistanceManager;
|
||||
var mindmap = this._mindmap;
|
||||
|
||||
var properties = {zoom:this._zoom, layoutManager:this._layoutManager.getClassName()};
|
||||
var properties = {zoom:this.getModel().getZoom(), layoutManager:this._layoutManager.getClassName()};
|
||||
persistantManager.save(mindmap, properties, onSavedHandler, saveHistory);
|
||||
this._fireEvent("save", {type:saveHistory});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user