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

Commit

Permalink
Upgrade for MooTools 1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
cheeaun committed Oct 24, 2010
1 parent 74e1c27 commit fd18940
Show file tree
Hide file tree
Showing 13 changed files with 5,543 additions and 4,488 deletions.
9,697 changes: 5,368 additions & 4,329 deletions Demos/assets/mootools.js

Large diffs are not rendered by default.

52 changes: 24 additions & 28 deletions Source/MooEditable/MooEditable.Charmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,40 +310,36 @@ MooEditable.UI.CharacterDialog = function(editor){
} else if (button.hasClass('dialog-ok-button')){
this.close();
var sel = button.getPrevious('select.char');
var div = new Element('div').set('html', sel.options[sel.selectedIndex].getProperty('data-code').trim());
var div = new Element('div').set('html', $(sel.options[sel.selectedIndex]).getProperty('data-code').trim());
editor.selection.insertContent(div.get('html'));
}
}
});
};

MooEditable.Actions.extend({

charmap: {
title: MooEditable.lang.get('insertCustomCharacter'),
dialogs: {
prompt: function(editor){
return MooEditable.UI.CharacterDialog(editor);
}
},
command: function() {
this.dialogs.charmap.prompt.open();
},
events: {
toggleView: function(){
if (this.mode == 'textarea'){
var s = this.textarea.get('value');
// when switching from iframe to textarea, we need to convert special symbols to html entities
MooEditable.Actions.Settings.charmap.chars.each(function(e){
if (!['&', '>', '<', '"', ' '].contains(e[0])){
var r = new RegExp(String.fromCharCode(parseInt(e[1].replace('&#', '').replace(';', ''))), 'g');
s = s.replace(r, e[0]);
}
}, this);
this.textarea.set('value', s);
}
MooEditable.Actions.charmap = {
title: MooEditable.lang.get('insertCustomCharacter'),
dialogs: {
prompt: function(editor){
return MooEditable.UI.CharacterDialog(editor);
}
},
command: function() {
this.dialogs.charmap.prompt.open();
},
events: {
toggleView: function(){
if (this.mode == 'textarea'){
var s = this.textarea.get('value');
// when switching from iframe to textarea, we need to convert special symbols to html entities
MooEditable.Actions.Settings.charmap.chars.each(function(e){
if (!['&', '>', '<', '"', ' '].contains(e[0])){
var r = new RegExp(String.fromCharCode(parseInt(e[1].replace('&#', '').replace(';', ''))), 'g');
s = s.replace(r, e[0]);
}
}, this);
this.textarea.set('value', s);
}
}
}

});
};
2 changes: 1 addition & 1 deletion Source/MooEditable/MooEditable.Extras.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ MooEditable.lang.set({
insertHorizontalRule: 'Insert Horizontal Rule'
});

MooEditable.Actions.extend({
Object.append(MooEditable.Actions, {

formatBlock: {
title: MooEditable.lang.get('blockFormatting'),
Expand Down
22 changes: 9 additions & 13 deletions Source/MooEditable/MooEditable.Flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,14 @@ MooEditable.UI.FlashDialog = function(editor){
});
};

MooEditable.Actions.extend({

flash: {
title: MooEditable.lang.get('flashEmbed'),
dialogs: {
prompt: function(editor){
return MooEditable.UI.FlashDialog(editor);
}
},
command: function(){
this.dialogs.flash.prompt.open();
MooEditable.Actions.flash = {
title: MooEditable.lang.get('flashEmbed'),
dialogs: {
prompt: function(editor){
return MooEditable.UI.FlashDialog(editor);
}
},
command: function(){
this.dialogs.flash.prompt.open();
}

});
};
1 change: 0 additions & 1 deletion Source/MooEditable/MooEditable.Forecolor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,3 @@ MooEditable.Actions.forecolor = {
this.focus();
}
};

4 changes: 2 additions & 2 deletions Source/MooEditable/MooEditable.Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ MooEditable.Group = new Class({
var self = this;
this.toolbar = new MooEditable.UI.Toolbar({
onItemAction: function(){
var args = $splat(arguments);
var args = Array.from(arguments);
var item = args[0];
if (!self.activeEditor) return;
self.activeEditor.focus();
Expand All @@ -46,7 +46,7 @@ MooEditable.Group = new Class({
},

add: function(textarea, options){
return this.activeEditor = new MooEditable.Group.Item(textarea, this, $merge({toolbar: false}, this.options, options));
return this.activeEditor = new MooEditable.Group.Item(textarea, this, Object.merge({toolbar: false}, this.options, options));
}

});
Expand Down
33 changes: 15 additions & 18 deletions Source/MooEditable/MooEditable.Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,20 @@ MooEditable.UI.ImageDialog = function(editor){
this.close();
} else if (button.hasClass('dialog-ok-button')){
this.close();
var dialogAlignSelect = this.el.getElement('.dialog-align');
var node = editor.selection.getNode();
if (node.get('tag') == 'img'){
node.set('src', this.el.getElement('.dialog-url').get('value').trim());
node.set('alt', this.el.getElement('.dialog-alt').get('value').trim());
node.className = this.el.getElement('.dialog-class').get('value').trim();
node.set('align', this.el.getElement('.dialog-align').get('value'));
node.set('align', $(dialogAlignSelect.options[dialogAlignSelect.selectedIndex]).get('value'));
} else {
var div = new Element('div');
new Element('img', {
src: this.el.getElement('.dialog-url').get('value').trim(),
alt: this.el.getElement('.dialog-alt').get('value').trim(),
'class': this.el.getElement('.dialog-class').get('value').trim(),
align: this.el.getElement('.dialog-align').get('value')
align: $(dialogAlignSelect.options[dialogAlignSelect.selectedIndex]).get('value')
}).inject(div);
editor.selection.insertContent(div.get('html'));
}
Expand All @@ -104,21 +105,17 @@ MooEditable.UI.ImageDialog = function(editor){
});
};

MooEditable.Actions.extend({

image: {
title: MooEditable.lang.get('addEditImage'),
options: {
shortcut: 'm'
},
dialogs: {
prompt: function(editor){
return MooEditable.UI.ImageDialog(editor);
}
},
command: function(){
this.dialogs.image.prompt.open();
MooEditable.Actions.image = {
title: MooEditable.lang.get('addEditImage'),
options: {
shortcut: 'm'
},
dialogs: {
prompt: function(editor){
return MooEditable.UI.ImageDialog(editor);
}
},
command: function(){
this.dialogs.image.prompt.open();
}

});
};
62 changes: 40 additions & 22 deletions Source/MooEditable/MooEditable.Pagebreak.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,47 @@ MooEditable.lang.set({
pageBreak: 'Page break'
});

MooEditable.Actions.extend({

pagebreak: {
title: MooEditable.lang.get('pageBreak'),
command: function(){
this.selection.insertContent('<img class="mooeditable-visual-aid mooeditable-pagebreak">');
MooEditable.Actions.pagebreak = {
title: MooEditable.lang.get('pageBreak'),
command: function(){
this.selection.insertContent('<img class="mooeditable-visual-aid mooeditable-pagebreak">');
},
events: {
attach: function(editor){
if (Browser.ie){
// addListener instead of addEvent, because controlselect is a native event in IE
editor.doc.addListener('controlselect', function(e){
var el = e.target || e.srcElement;
if (el.tagName.toLowerCase() != 'img') return;
if (!document.id(el).hasClass('mooeditable-pagebreak')) return;
if (e.preventDefault){
e.preventDefault();
} else {
e.returnValue = false;
}
});
}
},
editorMouseDown: function(e, editor){
var el = e.target;
var isSmiley = (el.tagName.toLowerCase() == 'img') && $(el).hasClass('mooeditable-pagebreak');
Function.attempt(function(){
editor.doc.execCommand('enableObjectResizing', false, !isSmiley);
});
},
events: {
beforeToggleView: function(){ // code to run when switching from iframe to textarea
if (this.mode == 'iframe'){
var s = this.getContent().replace(/<img([^>]*)class="mooeditable-visual-aid mooeditable-pagebreak"([^>]*)>/gi, '<!-- page break -->');
this.setContent(s);
} else {
var s = this.textarea.get('value').replace(/<!-- page break -->/gi, '<img class="mooeditable-visual-aid mooeditable-pagebreak">');
this.textarea.set('value', s);
}
},
render: function(){
this.options.extraCSS = 'img.mooeditable-pagebreak { display:block; width:100%; height:16px; background: url('
+ MooEditable.Actions.Settings.pagebreak.imageFile + ') repeat-x; }'
+ this.options.extraCSS;
beforeToggleView: function(){ // code to run when switching from iframe to textarea
if (this.mode == 'iframe'){
var s = this.getContent().replace(/<img([^>]*)class="mooeditable-visual-aid mooeditable-pagebreak"([^>]*)>/gi, '<!-- page break -->');
this.setContent(s);
} else {
var s = this.textarea.get('value').replace(/<!-- page break -->/gi, '<img class="mooeditable-visual-aid mooeditable-pagebreak">');
this.textarea.set('value', s);
}
},
render: function(){
this.options.extraCSS = 'img.mooeditable-pagebreak { display:block; width:100%; height:16px; background: url('
+ MooEditable.Actions.Settings.pagebreak.imageFile + ') repeat-x; }'
+ this.options.extraCSS;
}
}

});
};
14 changes: 9 additions & 5 deletions Source/MooEditable/MooEditable.Smiley.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,24 @@ MooEditable.Actions.smiley = {
},
events: {
attach: function(editor){
if (Browser.Engine.trident){
if (Browser.ie){
// addListener instead of addEvent, because controlselect is a native event in IE
editor.doc.addListener('controlselect', function(e){
var el = e.target;
var el = e.target || e.srcElement;
if (el.tagName.toLowerCase() != 'img') return;
if (!$(el).hasClass('smiley')) return;
e.preventDefault();
if (!document.id(el).hasClass('smiley')) return;
if (e.preventDefault){
e.preventDefault();
} else {
e.returnValue = false;
}
});
}
},
editorMouseDown: function(e, editor){
var el = e.target;
var isSmiley = (el.tagName.toLowerCase() == 'img') && $(el).hasClass('smiley');
$try(function(){
Function.attempt(function(){
editor.doc.execCommand('enableObjectResizing', false, !isSmiley);
});
}
Expand Down
2 changes: 1 addition & 1 deletion Source/MooEditable/MooEditable.Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ MooEditable.UI.TableDialog = function(editor, dialog){
});
};

MooEditable.Actions.extend({
Object.append(MooEditable.Actions, {

tableadd:{
title: MooEditable.lang.get('addTable'),
Expand Down
6 changes: 3 additions & 3 deletions Source/MooEditable/MooEditable.UI.ButtonOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ MooEditable.UI.ButtonOverlay = new Class({

options: {
/*
onOpenOverlay: $empty,
onCloseOverlay: $empty,
onOpenOverlay: function(){},
onCloseOverlay: function(){},
*/
overlayHTML: '',
overlayClass: '',
Expand Down Expand Up @@ -111,4 +111,4 @@ MooEditable.UI.ButtonOverlay = new Class({
return this;
}

});
});
6 changes: 3 additions & 3 deletions Source/MooEditable/MooEditable.UI.MenuList.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ MooEditable.UI.MenuList = new Class({

options: {
/*
onAction: $empty,
onAction: function(){},
*/
title: '',
name: '',
Expand Down Expand Up @@ -62,7 +62,7 @@ MooEditable.UI.MenuList = new Class({
this.disabled = false;

// add hover effect for IE
if (Browser.Engine.trident) this.el.addEvents({
if (Browser.ie) this.el.addEvents({
mouseenter: function(e){ this.addClass('hover'); },
mouseleave: function(e){ this.removeClass('hover'); }
});
Expand All @@ -78,7 +78,7 @@ MooEditable.UI.MenuList = new Class({
},

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

enable: function(){
Expand Down
Loading

0 comments on commit fd18940

Please sign in to comment.