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

Fixing IE7 issue with latest version of MooTools (1.4.5) #58

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 24 additions & 9 deletions Source/MooEditable/MooEditable.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ this.MooEditable = new Class({
html: '<!DOCTYPE html><html><head><meta charset="UTF-8">{BASEHREF}<style>{BASECSS} {EXTRACSS}</style>{EXTERNALCSS}</head><body></body></html>',
rootElement: 'p',
baseURL: '',
dimensions: null
dimensions: null,
linksInNewWindow: false
},

initialize: function(el, options){
Expand Down Expand Up @@ -132,7 +133,6 @@ this.MooEditable = new Class({
height: dimensions.y
}
});

this.toolbar = new MooEditable.UI.Toolbar({
onItemAction: function(){
var args = Array.from(arguments);
Expand Down Expand Up @@ -198,7 +198,7 @@ this.MooEditable = new Class({
});
});
});

// contentWindow and document references
this.win = this.iframe.contentWindow;
this.doc = this.win.document;
Expand All @@ -216,7 +216,7 @@ this.MooEditable = new Class({
this.doc.open();
this.doc.write(docHTML);
this.doc.close();

// Turn on Design Mode
// IE fired load event twice if designMode is set
(Browser.ie) ? this.doc.body.contentEditable = true : this.doc.designMode = 'On';
Expand Down Expand Up @@ -254,6 +254,7 @@ this.MooEditable = new Class({
focus: this.editorFocus.bind(this),
blur: this.editorBlur.bind(this)
});

this.win.addEvents({
focus: this.editorFocus.bind(this),
blur: this.editorBlur.bind(this)
Expand Down Expand Up @@ -616,7 +617,10 @@ this.MooEditable = new Class({
protect.push(a);
return '<!-- mooeditable:protect:' + (protect.length-1) + ' -->';
});
this.doc.body.set('html', this.ensureRootElement(content));

this.doc.body.innerHTML = this.ensureRootElement(content);
//this.doc.body.set('html', this.ensureRootElement(content)); // breaks in IE7 with mootools 1.4.5

return this;
},

Expand Down Expand Up @@ -667,6 +671,7 @@ this.MooEditable = new Class({
}
val = el.get('html').replace(/\n\n/g, '');
}

return val;
},

Expand Down Expand Up @@ -1507,16 +1512,26 @@ MooEditable.Actions = {
dialogs: {
alert: MooEditable.UI.AlertDialog.pass(MooEditable.Locale.get('selectTextHyperlink')),
prompt: function(editor){
return MooEditable.UI.PromptDialog(MooEditable.Locale.get('enterURL'), 'http://', function(url){
editor.execute('createlink', false, url.trim());
return MooEditable.UI.PromptDialog(MooEditable.Locale.get('enterURL') + ' (start with http:// for external URLs and / for internal URLs)', '', function(url){
var url = url.trim();
editor.execute('createlink', false, url);

if (editor.options.linksInNewWindow) {
if (url && (url.contains('http://') || url.contains('https://'))) {
var node = editor.selection.getNode();
node.set('target', '_blank');
this.saveContent();
}
}
});
}
},
command: function(){
var selection = this.selection;
var dialogs = this.dialogs.createlink;
if (selection.isCollapsed()){
var node = selection.getNode();
var node = selection.getNode();

if (node.get('tag') == 'a' || selection.isCollapsed()){
if (node.get('tag') == 'a' && node.get('href')){
selection.selectNode(node);
var prompt = dialogs.prompt;
Expand Down