Bug message: uncaught exception: text can not be null, line:0, : fixed.

This commit is contained in:
Paulo Gustavo Veiga 2012-09-01 10:17:15 -03:00
parent 00829bfcc4
commit c4f4756e4a
3 changed files with 36 additions and 35 deletions

View File

@ -17,17 +17,18 @@
*/ */
mindplot.model.NoteModel = new Class({ mindplot.model.NoteModel = new Class({
Extends: mindplot.model.FeatureModel, Extends:mindplot.model.FeatureModel,
initialize : function(attributes) { initialize:function (attributes) {
this.parent(mindplot.model.NoteModel.FEATURE_TYPE); this.parent(mindplot.model.NoteModel.FEATURE_TYPE);
this.setText(attributes.text); if (attributes.text)
this.setText(attributes.text);
}, },
getText:function() { getText:function () {
return this.getAttribute('text'); return this.getAttribute('text');
}, },
setText : function(text) { setText:function (text) {
$assert(text, 'text can not be null'); $assert(text, 'text can not be null');
this.setAttribute('text', text); this.setAttribute('text', text);
} }

View File

@ -170,7 +170,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
}, },
_noteTextToXML:function (document, elem, text) { _noteTextToXML:function (document, elem, text) {
if (text.indexOf('\n') == -1) { if (text.indexOf('\n') == -1 && text.indexOf("&") == -1 && text.indexOf("<") == -1 && text.indexOf("\"") == -1) {
elem.setAttribute('text', text); elem.setAttribute('text', text);
} else { } else {
var textDom = document.createElement("text"); var textDom = document.createElement("text");
@ -256,7 +256,7 @@ mindplot.persistence.XMLSerializer_Pela = new Class({
var topic = mindmap.createNode(type, id); var topic = mindmap.createNode(type, id);
var text = domElem.getAttribute('text'); var text = domElem.getAttribute('text');
if ($defined(text)) { if ($defined(text) && text) {
topic.setText(text); topic.setText(text);
} }

View File

@ -18,42 +18,42 @@
mindplot.widget.NoteEditor = new Class({ mindplot.widget.NoteEditor = new Class({
Extends:MooDialog, Extends:MooDialog,
initialize : function(model) { initialize:function (model) {
$assert(model, "model can not be null"); $assert(model, "model can not be null");
var panel = this._buildPanel(model); var panel = this._buildPanel(model);
this.parent({ this.parent({
closeButton:true, closeButton:true,
destroyOnClose:true, destroyOnClose:true,
title:'Note', title:'Note',
onInitialize: function(wrapper) { onInitialize:function (wrapper) {
wrapper.setStyle('opacity', 0); wrapper.setStyle('opacity', 0);
this.fx = new Fx.Morph(wrapper, { this.fx = new Fx.Morph(wrapper, {
duration: 600, duration:600,
transition: Fx.Transitions.Bounce.easeOut transition:Fx.Transitions.Bounce.easeOut
}); });
}, },
onBeforeOpen: function() { onBeforeOpen:function () {
this.overlay = new Overlay(this.options.inject, { this.overlay = new Overlay(this.options.inject, {
duration: this.options.duration duration:this.options.duration
}); });
if (this.options.closeOnOverlayClick) if (this.options.closeOnOverlayClick)
this.overlay.addEvent('click', this.close.bind(this)); this.overlay.addEvent('click', this.close.bind(this));
this.overlay.open(); this.overlay.open();
this.fx.start({ this.fx.start({
'margin-top': [-200, -100], 'margin-top':[-200, -100],
opacity: [0, 1] opacity:[0, 1]
}).chain(function() { }).chain(function () {
this.fireEvent('show'); this.fireEvent('show');
}.bind(this)); }.bind(this));
}, },
onBeforeClose: function() { onBeforeClose:function () {
this.fx.start({ this.fx.start({
'margin-top': [-100, 0], 'margin-top':[-100, 0],
opacity: 0 opacity:0
}).chain(function() { }).chain(function () {
this.fireEvent('hide'); this.fireEvent('hide');
}.bind(this)); }.bind(this));
this.overlay.destroy(); this.overlay.destroy();
@ -62,13 +62,13 @@ mindplot.widget.NoteEditor = new Class({
this.setContent(panel); this.setContent(panel);
}, },
_buildPanel : function (model) { _buildPanel:function (model) {
var result = new Element('div'); var result = new Element('div');
var form = new Element('form', {'action': 'none', 'id':'noteFormId'}); var form = new Element('form', {'action':'none', 'id':'noteFormId'});
// Add textarea ... // Add textarea ...
var textArea = new Element('textarea', var textArea = new Element('textarea',
{placeholder: 'Write your note here ...', {placeholder:'Write your note here ...',
required:true, required:true,
autofocus:'autofocus' autofocus:'autofocus'
}); });
@ -77,17 +77,17 @@ mindplot.widget.NoteEditor = new Class({
textArea.setStyles({ textArea.setStyles({
'width':'100%', 'width':'100%',
'height':80 'height':80, resize:'none'
,resize: 'none'
}); });
textArea.inject(form); textArea.inject(form);
// Register submit event ... // Register submit event ...
form.addEvent('submit', function(event) { form.addEvent('submit', function (event) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
if (textArea.value ) {
model.setValue(textArea.value); model.setValue(textArea.value);
}
this.close(); this.close();
}.bind(this)); }.bind(this));
@ -96,17 +96,17 @@ mindplot.widget.NoteEditor = new Class({
var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'right'}); var buttonContainer = new Element('div').setStyles({paddingTop:5, textAlign:'right'});
// Create accept button ... // Create accept button ...
var okButton = new Element('input', {type:'submit', value:'Accept','class':'btn-primary'}); var okButton = new Element('input', {type:'submit', value:'Accept', 'class':'btn-primary'});
okButton.addClass('button'); okButton.addClass('button');
okButton.inject(buttonContainer); okButton.inject(buttonContainer);
// Create remove button ... // Create remove button ...
if ($defined(model.getValue())) { if ($defined(model.getValue())) {
var rmButton = new Element('input', {type:'button', value:'Remove','class':'btn-primary'}); var rmButton = new Element('input', {type:'button', value:'Remove', 'class':'btn-primary'});
rmButton.setStyle('margin', '5px'); rmButton.setStyle('margin', '5px');
rmButton.addClass('button'); rmButton.addClass('button');
rmButton.inject(buttonContainer); rmButton.inject(buttonContainer);
rmButton.addEvent('click', function() { rmButton.addEvent('click', function () {
model.setValue(null); model.setValue(null);
this.close(); this.close();
}.bind(this)); }.bind(this));
@ -114,16 +114,16 @@ mindplot.widget.NoteEditor = new Class({
} }
// Create cancel button ... // Create cancel button ...
var cButton = new Element('input', {type:'button', value:'Cancel','class':'btn-secondary'}); var cButton = new Element('input', {type:'button', value:'Cancel', 'class':'btn-secondary'});
cButton.setStyle('margin', '5px'); cButton.setStyle('margin', '5px');
cButton.addClass('button'); cButton.addClass('button');
cButton.inject(buttonContainer); cButton.inject(buttonContainer);
cButton.addEvent('click', function() { cButton.addEvent('click', function () {
this.close(); this.close();
}.bind(this)); }.bind(this));
buttonContainer.inject(form); buttonContainer.inject(form);
result.addEvent('keydown', function(event) { result.addEvent('keydown', function (event) {
event.stopPropagation(); event.stopPropagation();
}); });
@ -131,7 +131,7 @@ mindplot.widget.NoteEditor = new Class({
return result; return result;
}, },
show : function() { show:function () {
this.open(); this.open();
} }