2009-06-07 18:59:43 +00:00
|
|
|
/*
|
2012-10-04 20:48:01 -03:00
|
|
|
* Copyright [2012] [wisemapping]
|
2011-07-27 08:25:10 -03:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2011-10-08 20:36:47 -03:00
|
|
|
mindplot.NoteIcon = new Class({
|
2012-08-29 20:17:35 -03:00
|
|
|
Extends:mindplot.Icon,
|
|
|
|
initialize:function (topic, noteModel, readOnly) {
|
2011-09-02 18:25:34 -03:00
|
|
|
$assert(topic, 'topic can not be null');
|
|
|
|
|
2011-10-08 20:36:47 -03:00
|
|
|
this.parent(mindplot.NoteIcon.IMAGE_URL);
|
2011-10-14 22:56:20 -03:00
|
|
|
this._linksModel = noteModel;
|
2011-07-27 08:25:10 -03:00
|
|
|
this._topic = topic;
|
2012-08-29 20:17:35 -03:00
|
|
|
this._readOnly = readOnly;
|
2009-06-07 18:59:43 +00:00
|
|
|
|
2011-08-25 22:08:39 -03:00
|
|
|
this._registerEvents();
|
|
|
|
},
|
2011-07-27 08:25:10 -03:00
|
|
|
|
2012-08-29 20:17:35 -03:00
|
|
|
_registerEvents:function () {
|
2011-08-25 22:08:39 -03:00
|
|
|
this._image.setCursor('pointer');
|
2014-04-20 23:57:39 -03:00
|
|
|
var me = this;
|
2011-07-27 08:25:10 -03:00
|
|
|
|
2012-08-29 20:17:35 -03:00
|
|
|
if (!this._readOnly) {
|
|
|
|
// Add on click event to open the editor ...
|
|
|
|
this.addEvent('click', function (event) {
|
2014-04-20 23:57:39 -03:00
|
|
|
me._topic.showNoteEditor();
|
2012-08-29 20:17:35 -03:00
|
|
|
event.stopPropagation();
|
2014-04-20 23:57:39 -03:00
|
|
|
});
|
2012-08-29 20:17:35 -03:00
|
|
|
}
|
2014-04-20 23:57:39 -03:00
|
|
|
this._tip = new mindplot.widget.FloatingTip($(me.getImage()._peer._native), {
|
2014-05-02 18:07:55 -03:00
|
|
|
title: $msg('NOTE'),
|
|
|
|
container: 'body',
|
2011-10-07 00:21:49 -03:00
|
|
|
// Content can also be a function of the target element!
|
2014-05-02 18:07:55 -03:00
|
|
|
content: this._buildTooltipContent(),
|
2012-08-29 20:17:35 -03:00
|
|
|
html:true,
|
2014-05-02 18:07:55 -03:00
|
|
|
placement:'bottom'
|
2011-10-07 00:21:49 -03:00
|
|
|
});
|
2014-04-20 23:57:39 -03:00
|
|
|
|
2011-07-27 08:25:10 -03:00
|
|
|
},
|
|
|
|
|
2014-05-02 18:07:55 -03:00
|
|
|
_buildTooltipContent: function() {
|
|
|
|
var result = $('<div></div>').css({padding:'5px'});
|
|
|
|
|
|
|
|
var text = $('<div></div>').text(this._linksModel.getText())
|
|
|
|
.css({
|
|
|
|
'white-space':'pre-wrap',
|
|
|
|
'word-wrap':'break-word'
|
|
|
|
}
|
|
|
|
);
|
|
|
|
result.append(text);
|
|
|
|
return result;
|
|
|
|
},
|
|
|
|
|
2012-08-29 20:17:35 -03:00
|
|
|
getModel:function () {
|
2011-10-14 22:56:20 -03:00
|
|
|
return this._linksModel;
|
2011-07-27 08:25:10 -03:00
|
|
|
}
|
|
|
|
});
|
2009-06-07 18:59:43 +00:00
|
|
|
|
2012-02-20 11:32:37 -03:00
|
|
|
mindplot.NoteIcon.IMAGE_URL = "images/notes.png";
|
2009-06-07 18:59:43 +00:00
|
|
|
|