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

Commit

Permalink
More clean-up on the functions and API.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Mar 11, 2009
1 parent 205dbc4 commit d221bab
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
3 changes: 2 additions & 1 deletion Source/MooEditable/MooEditable.Extras.js
Expand Up @@ -22,9 +22,10 @@ MooEditable.Actions.extend({
states: {
tags: ['p', 'h1', 'h2', 'h3']
},
command: function(name){
command: function(menulist, name){
var argument = '<' + name + '>';
this.execute('formatBlock', false, argument);
this.focus();
}
},

Expand Down
12 changes: 8 additions & 4 deletions Source/MooEditable/MooEditable.UI.MenuList.js
Expand Up @@ -45,7 +45,7 @@ MooEditable.UI.MenuList = new Class({
title: self.options.title,
html: html,
events: {
change: self.action.bind(self)
change: self.change.bind(self)
}
});

Expand All @@ -60,11 +60,15 @@ MooEditable.UI.MenuList = new Class({
return this;
},

action: function(e){
e.stop();
change: function(e){
e.preventDefault();
if (this.disabled) return;
var name = e.target.value;
this.fireEvent('action', [this, name]);
this.action(name);
},

action: function(){
this.fireEvent('action', [this].concat($A(arguments)));
},

enable: function(){
Expand Down
30 changes: 16 additions & 14 deletions Source/MooEditable/MooEditable.js
Expand Up @@ -116,7 +116,7 @@ var MooEditable = new Class({
onItemAction: function(){
var args = $splat(arguments);
var item = args[0];
self.action(item.name, Array.slice(args, 1));
self.action(item.name, args);
}
});
this.attach();
Expand Down Expand Up @@ -242,7 +242,7 @@ var MooEditable = new Class({
this.saveContent();
this.textarea.setStyle('display', '').removeClass('mooeditable-textarea').inject(this.container, 'before');
this.textarea.removeEvent('keypress', this.textarea.retrieve('mooeditable:textareaKeyListener'));
this.container.destroy();
this.container.dispose();
this.fireEvent('detach', this);
return this;
},
Expand Down Expand Up @@ -381,7 +381,7 @@ var MooEditable = new Class({
action: function(command, args){
var action = MooEditable.Actions[command];
if (action.command && $type(action.command) == 'function'){
action.command.attempt(args, this);
action.command.run(args, this);
} else {
this.focus();
this.execute(command, false, args);
Expand Down Expand Up @@ -850,7 +850,7 @@ MooEditable.UI.Button = new Class({
title: title,
text: text,
events: {
click: self.action.bind(self),
click: self.click.bind(self),
mousedown: function(e){ e.preventDefault(); }
}
});
Expand All @@ -867,10 +867,14 @@ MooEditable.UI.Button = new Class({
return this;
},

action: function(e){
click: function(e){
e.preventDefault();
if (this.disabled) return;
this.fireEvent('action', this);
this.action(e);
},

action: function(){
this.fireEvent('action', [this].concat($A(arguments)));
},

enable: function(){
Expand Down Expand Up @@ -965,15 +969,14 @@ MooEditable.UI.Dialog = new Class({
MooEditable.UI.AlertDialog = function(alertText){
var html = alertText + ' <button class="dialog-ok-button">OK</button>';
return dialog = new MooEditable.UI.Dialog(html, {
'class': 'alert-dialog mooeditable-dialog'
}).addEvents({
open: function(){
'class': 'alert-dialog mooeditable-dialog',
onOpen: function(){
var button = this.el.getElement('.dialog-ok-button');
(function(){
button.focus();
}).delay(10);
},
click: function(e){
onClick: function(e){
e.preventDefault();
if (e.target.tagName.toLowerCase() != 'button') return;
if ($(e.target).hasClass('dialog-ok-button')) this.close();
Expand All @@ -987,16 +990,15 @@ MooEditable.UI.PromptDialog = function(questionText, answerText, fn){
+ '</label> <button class="dialog-ok-button">OK</button>'
+ '<button class="dialog-cancel-button">Cancel</button>';
return new MooEditable.UI.Dialog(html, {
'class': 'prompt-dialog mooeditable-dialog'
}).addEvents({
open: function(){
'class': 'prompt-dialog mooeditable-dialog',
onOpen: function(){
var input = this.el.getElement('.mooeditable-dialog-input');
(function(){
input.focus()
input.select();
}).delay(10);
},
click: function(e){
onClick: function(e){
e.preventDefault();
if (e.target.tagName.toLowerCase() != 'button') return;
var button = $(e.target);
Expand Down

0 comments on commit d221bab

Please sign in to comment.