Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Fixed some bugs in MooEditable.UI.PromptDialog - memory leak on event…
Browse files Browse the repository at this point in the history
…s attaching
  • Loading branch information
cheeaun committed Mar 1, 2009
1 parent 47588b7 commit e44363e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions Source/MooEditable/MooEditable.js
Expand Up @@ -179,7 +179,8 @@ var MooEditable = new Class({
mousedown: stop,
keydown: stop
});
self.selection.setRange(range);
self.focus();
if (range) self.selection.setRange(range);
}
});
});
Expand Down Expand Up @@ -859,8 +860,9 @@ MooEditable.UI.Dialog = new Class({
return this;
},

open: function(){
open: function(fn){
this.el.setStyle('display', '');
fn.attempt(null, this);
this.fireEvent('open', this);
return this;
},
Expand Down Expand Up @@ -1024,22 +1026,19 @@ MooEditable.Actions = new Hash({
},
dialogs: {
alert: MooEditable.UI.AlertDialog('Please select the text you wish to hyperlink.'),
prompt: MooEditable.UI.PromptDialog('Enter URL', 'http://')
prompt: MooEditable.UI.PromptDialog('Enter URL', 'http://', function(url){
this.execute('createlink', false, url.trim());
})
},
command: function(){
if (this.selection.isCollapsed()){
this.dialogs.createlink.alert.open();
} else {
var text = this.selection.getText();
var url = /^(https?|ftp|rmtp|mms):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i;
this.dialogs.createlink.prompt.addEvents({
open: function(){
if (url.test(text)) this.el.getElement('.mooeditable-dialog-input').set('value', text);
},
clickOK: function(url){
this.execute('createlink', false, url.trim());
}
}).open();
this.dialogs.createlink.prompt.open(function(){
if (url.test(text)) this.el.getElement('.mooeditable-dialog-input').set('value', text);
});
}
}
},
Expand Down

0 comments on commit e44363e

Please sign in to comment.