Fix add links.

This commit is contained in:
Paulo Veiga
2011-10-08 20:36:47 -03:00
parent 52587c0eaa
commit 5d1ab3cb6e
19 changed files with 333 additions and 306 deletions

View File

@@ -34,7 +34,7 @@ mindplot.widget.FloatingTip = new Class({
showOn: 'mouseenter',
hideOn: 'mouseleave',
showDelay: 500,
hideDelay: 0,
hideDelay: 250,
className: 'floating-tip',
offset: {x: 0, y: 0},
fx: { 'duration': 'short' }
@@ -71,9 +71,13 @@ mindplot.widget.FloatingTip = new Class({
return this;
}
var tip = this._create(element);
if (tip == null) return this;
if (tip == null)
return this;
element.store('floatingtip', tip);
this._animate(tip, 'in');
tip.addEvent(this.options.showOn, this.boundShow);
tip.addEvent(this.options.hideOn, this.boundHide);
this.fireEvent('show', [tip, element]);
return this;
},

View File

@@ -64,25 +64,36 @@ mindplot.widget.LinkEditor = new Class({
var result = new Element('div');
var form = new Element('form', {'action': 'none', 'id':'linkFormId'});
// Add textarea ...
var textArea = new Element('textarea', {placeholder: 'Write your note here ...'});
if (model.getValue() != null)
textArea.value = model.getValue();
// Add combo ...
var select = new Element('select');
select.setStyles({margin: '5px'});
new Element('option', {text:'URL'}).inject(select);
new Element('option', {text:'Mail'}).inject(select);
select.inject(form);
textArea.setStyles({'width':'100%', 'height':80,resize: 'none'
});
textArea.inject(form);
// Add Input ...
var input = new Element('input', {placeholder: 'http://www.example.com/',type:'url',required:true});
if (model.getValue() != null)
input.value = model.getValue();
input.setStyles({'width':'70%'});
input.inject(form);
// Register submit event ...
form.addEvent('submit', function(event) {
event.stopPropagation();
event.preventDefault();
model.setValue(input.value);
this.close();
}.bind(this));
// Add buttons ...
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
// Create accept button ...
var okButton = new Element('input', {type:'button', value:'Accept','class':'btn-primary'});
var okButton = new Element('input', {type:'submit', value:'Accept','class':'btn-primary'});
okButton.addClass('button');
okButton.addEvent('click', function() {
model.setValue(textArea.value);
this.close();
}.bind(this));
okButton.inject(buttonContainer);
// Create remove button ...
@@ -91,16 +102,16 @@ mindplot.widget.LinkEditor = new Class({
rmButton.setStyle('margin', '5px');
rmButton.addClass('button');
rmButton.inject(buttonContainer);
rmButton.addEvent('click', function() {
rmButton.addEvent('click', function(event) {
model.setValue(null);
event.stopPropagation();
this.close();
}.bind(this));
buttonContainer.inject(form);
}
// Create cancel button ...
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-primary'});
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-secondary'});
cButton.setStyle('margin', '5px');
cButton.addClass('button');
cButton.inject(buttonContainer);

View File

@@ -0,0 +1,91 @@
/*
* 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.
*/
mindplot.widget.LinkIconTooltip = new Class({
Extends: mindplot.widget.FloatingTip,
initialize : function(linkIcon) {
$assert(linkIcon, "linkIcon can not be null");
this.parent(linkIcon.getImage()._peer._native, {
// Content can also be a function of the target element!
content: this._buildContent.pass(linkIcon, this),
html: true,
position: 'bottom',
arrowOffset : 10,
center: true,
arrowSize: 15,
offset : {x:10,y:20}
});
},
_buildContent : function(linkIcon) {
var result = new Element('div');
result.setStyles({
padding:'5px',
width:'100%'
});
var title = new Element('div', {text:'Link'});
title.setStyles({
'font-weight':'bold',
color:'black',
'padding-bottom':'5px',
width: '100px'
});
title.inject(result);
var text = new Element('div', {text: "URL: " + linkIcon.getModel().getUrl()});
text.setStyles({
'white-space': 'pre-wrap',
'word-wrap': 'break-word'
}
);
text.inject(result);
var imgContainer = new Element('div');
imgContainer.setStyles({
width: '100%',
textAlign: 'center',
'padding-bottom':'5px',
'padding-top': '5px'
});
var img = new Element('img', {
src: 'http://open.thumbshots.org/image.pxf?url=' + linkIcon.getModel().getUrl(),
img : linkIcon.getModel().getUrl(),
alt : linkIcon.getModel().getUrl()
}
);
img.setStyles({
padding: '5px'
}
);
var link = new Element('a', {
href : linkIcon.getModel().getUrl(),
alt : 'Open in new window ...',
target : '_blank'
});
img.inject(link);
link.inject(imgContainer);
imgContainer.inject(result);
return result;
}
});

View File

@@ -65,24 +65,33 @@ mindplot.widget.NoteEditor = new Class({
var form = new Element('form', {'action': 'none', 'id':'noteFormId'});
// Add textarea ...
var textArea = new Element('textarea', {placeholder: 'Write your note here ...'});
var textArea = new Element('textarea', {placeholder: 'Write your note here ...',required:true});
if (model.getValue() != null)
textArea.value = model.getValue();
textArea.setStyles({'width':'100%', 'height':80,resize: 'none'
textArea.setStyles({
'width':'100%',
'height':80
,resize: 'none'
});
textArea.inject(form);
// Register submit event ...
form.addEvent('submit', function(event) {
event.preventDefault();
event.stopPropagation();
model.setValue(textArea.value);
this.close();
}.bind(this));
// Add buttons ...
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'center'});
// Create accept button ...
var okButton = new Element('input', {type:'button', value:'Accept','class':'btn-primary'});
var okButton = new Element('input', {type:'submit', value:'Accept','class':'btn-primary'});
okButton.addClass('button');
okButton.addEvent('click', function() {
model.setValue(textArea.value);
this.close();
}.bind(this));
okButton.inject(buttonContainer);
// Create remove button ...
@@ -100,7 +109,7 @@ mindplot.widget.NoteEditor = new Class({
// Create cancel button ...
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-primary'});
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-secondary'});
cButton.setStyle('margin', '5px');
cButton.addClass('button');
cButton.inject(buttonContainer);