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

Commit

Permalink
FireFox uses b and i instead of strong and em, so do a replace on tog…
Browse files Browse the repository at this point in the history
…gle and load so that they work as expected
  • Loading branch information
Ryan Mitchell authored and cheeaun committed Nov 15, 2009
1 parent 976c196 commit 51b4291
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions Source/MooEditable/MooEditable.js
Expand Up @@ -596,6 +596,11 @@ this.MooEditable = new Class({
source = source.replace(/<b\b[^>]*>(.*?)<\/b[^>]*>/gi, '<strong>$1</strong>');
source = source.replace(/<i\b[^>]*>(.*?)<\/i[^>]*>/gi, '<em>$1</em>');
source = source.replace(/<u\b[^>]*>(.*?)<\/u[^>]*>/gi, '<span style="text-decoration: underline;">$1</span>');
source = source.replace(/<strong><span style="font-weight: normal;">(.*)<\/span><\/strong>/gi, '$1');
source = source.replace(/<em><span style="font-weight: normal;">(.*)<\/span><\/em>/gi, '$1');
source = source.replace(/<span style="text-decoration: underline;"><span style="font-weight: normal;">(.*)<\/span><\/span>/gi, '$1');
source = source.replace(/<strong style="font-weight: normal;">(.*)<\/strong>/gi, '$1');
source = source.replace(/<em style="font-weight: normal;">(.*)<\/em>/gi, '$1');

// Replace uppercase element names with lowercase
source = source.replace(/<[^> ]*/g, function(match){return match.toLowerCase();});
Expand Down Expand Up @@ -1080,6 +1085,25 @@ MooEditable.Actions = new Hash({
states: {
tags: ['b', 'strong'],
css: {'font-weight': 'bold'}
},
events: {
beforeToggleView: function(){
if(Browser.Engine.gecko){
var s = this.textarea.get('value')
.replace(/<strong([^>]*)>/gi, '<b$1>')
.replace(/<\/strong>/gi, '</b>')
this.textarea.set('value',s);
}
},
attach: function(){
if(Browser.Engine.gecko){
var s = this.textarea.get('value')
.replace(/<strong([^>]*)>/gi, '<b$1>')
.replace(/<\/strong>/gi, '</b>')
this.textarea.set('value',s);
this.setContent(s);
}
}
}
},

Expand All @@ -1091,6 +1115,29 @@ MooEditable.Actions = new Hash({
states: {
tags: ['i', 'em'],
css: {'font-style': 'italic'}
},
events: {
beforeToggleView: function(){
if(Browser.Engine.gecko){
var s = this.textarea.get('value')
.replace(/<embed([^>]*)>/gi, '<tmpembed$1>')
.replace(/<em([^>]*)>/gi, '<i$1>')
.replace(/<tmpembed([^>]*)>/gi, '<embed$1>')
.replace(/<\/em>/gi, '</i>');
this.textarea.set('value',s);
}
},
attach: function(){
if(Browser.Engine.gecko){
var s = this.textarea.get('value')
.replace(/<embed([^>]*)>/gi, '<tmpembed$1>')
.replace(/<em([^>]*)>/gi, '<i$1>')
.replace(/<tmpembed([^>]*)>/gi, '<embed$1>')
.replace(/<\/em>/gi, '</i>');
this.textarea.set('value',s);
this.setContent(s);
}
}
}
},

Expand Down

0 comments on commit 51b4291

Please sign in to comment.