diff --git a/nicEdit.js b/nicEdit.js
index c08b827..468cc84 100644
--- a/nicEdit.js
+++ b/nicEdit.js
@@ -4,7 +4,7 @@
* NicEdit is distributed under the terms of the MIT license
* For more information visit http://nicedit.com/
* Do not remove this copyright message
- */
+ */
var bkExtend = function(){
var args = arguments;
if (args.length == 1) args = [this, args[0]];
@@ -14,14 +14,14 @@ var bkExtend = function(){
function bkClass() { }
bkClass.prototype.construct = function() {};
bkClass.extend = function(def) {
- var classDef = function() {
- if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); }
- };
- var proto = new this(bkClass);
- bkExtend(proto,def);
- classDef.prototype = proto;
- classDef.extend = this.extend;
- return classDef;
+ var classDef = function() {
+ if (arguments[0] !== bkClass) { return this.construct.apply(this, arguments); }
+ };
+ var proto = new this(bkClass);
+ bkExtend(proto,def);
+ classDef.prototype = proto;
+ classDef.extend = this.extend;
+ return classDef;
};
var bkElement = bkClass.extend({
@@ -32,27 +32,27 @@ var bkElement = bkClass.extend({
elm = $BK(elm);
return elm;
},
-
+
appendTo : function(elm) {
- elm.appendChild(this);
+ elm.appendChild(this);
return this;
},
-
+
appendBefore : function(elm) {
- elm.parentNode.insertBefore(this,elm);
+ elm.parentNode.insertBefore(this,elm);
return this;
},
-
+
addEvent : function(type, fn) {
bkLib.addEvent(this,type,fn);
- return this;
+ return this;
},
-
+
setContent : function(c) {
this.innerHTML = c;
return this;
},
-
+
pos : function() {
var curleft = curtop = 0;
var o = obj = this;
@@ -65,12 +65,12 @@ var bkElement = bkClass.extend({
var b = (!window.opera) ? parseInt(this.getStyle('border-width') || this.style.border) || 0 : 0;
return [curleft+b,curtop+b+this.offsetHeight];
},
-
+
noSelect : function() {
bkLib.noSelect(this);
return this;
},
-
+
parentTag : function(t) {
var elm = this;
do {
@@ -81,16 +81,16 @@ var bkElement = bkClass.extend({
} while(elm);
return false;
},
-
+
hasClass : function(cls) {
return this.className.match(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'));
},
-
+
addClass : function(cls) {
if (!this.hasClass(cls)) { this.className += " nicEdit-"+cls };
return this;
},
-
+
removeClass : function(cls) {
if (this.hasClass(cls)) {
this.className = this.className.replace(new RegExp('(\\s|^)nicEdit-'+cls+'(\\s|$)'),' ');
@@ -107,7 +107,7 @@ var bkElement = bkClass.extend({
break;
case 'opacity':
elmStyle.opacity = st[itm];
- elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")";
+ elmStyle.filter = "alpha(opacity=" + Math.round(st[itm]*100) + ")";
break;
case 'className':
this.className = st[itm];
@@ -115,23 +115,23 @@ var bkElement = bkClass.extend({
default:
//if(document.compatMode || itm != "cursor") { // Nasty Workaround for IE 5.5
elmStyle[itm] = st[itm];
- //}
+ //}
}
}
return this;
},
-
+
getStyle : function( cssRule, d ) {
- var doc = (!d) ? document.defaultView : d;
+ var doc = (!d) ? document.defaultView : d;
if(this.nodeType == 1)
return (doc && doc.getComputedStyle) ? doc.getComputedStyle( this, null ).getPropertyValue(cssRule) : this.currentStyle[ bkLib.camelize(cssRule) ];
},
-
+
remove : function() {
this.parentNode.removeChild(this);
- return this;
+ return this;
},
-
+
setAttributes : function(at) {
for(var itm in at) {
this[itm] = at[itm];
@@ -142,17 +142,17 @@ var bkElement = bkClass.extend({
var bkLib = {
isMSIE : (navigator.appVersion.indexOf("MSIE") != -1),
-
+
addEvent : function(obj, type, fn) {
- (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn);
+ (obj.addEventListener) ? obj.addEventListener( type, fn, false ) : obj.attachEvent("on"+type, fn);
},
-
+
toArray : function(iterable) {
var length = iterable.length, results = new Array(length);
- while (length--) { results[length] = iterable[length] };
- return results;
+ while (length--) { results[length] = iterable[length] };
+ return results;
},
-
+
noSelect : function(element) {
if(element.setAttribute && element.nodeName.toLowerCase() != 'input' && element.nodeName.toLowerCase() != 'textarea') {
element.setAttribute('unselectable','on');
@@ -172,7 +172,7 @@ var bkLib = {
if(arr[i] == itm)
return i;
}
- return null;
+ return null;
},
cancelEvent : function(e) {
e = e || window.event;
@@ -225,30 +225,32 @@ var bkEvent = {
this.eventList[evType][i].apply(this,args);
}
}
- }
+ }
};
-function __(s) {
- return s;
+if (!__) {
+ __ = function(s) {
+ return s;
+ }
}
Function.prototype.closure = function() {
- var __method = this, args = bkLib.toArray(arguments), obj = args.shift();
- return function() { if(typeof(bkLib) != 'undefined') { return __method.apply(obj,args.concat(bkLib.toArray(arguments))); } };
+ var __method = this, args = bkLib.toArray(arguments), obj = args.shift();
+ return function() { if(typeof(bkLib) != 'undefined') { return __method.apply(obj,args.concat(bkLib.toArray(arguments))); } };
}
-
-Function.prototype.closureListener = function() {
- var __method = this, args = bkLib.toArray(arguments), object = args.shift();
- return function(e) {
- e = e || window.event;
- if(e.target) { var target = e.target; } else { var target = e.srcElement };
- return __method.apply(object, [e,target].concat(args) );
- };
-}
-
+Function.prototype.closureListener = function() {
+ var __method = this, args = bkLib.toArray(arguments), object = args.shift();
+ return function(e) {
+ e = e || window.event;
+ if(e.target) { var target = e.target; } else { var target = e.srcElement };
+ return __method.apply(object, [e,target].concat(args) );
+ };
+}
+
+
/* START CONFIG */
-
+
var nicEditorConfig = bkClass.extend({
buttons : {
'bold' : {name : __('Click to Bold'), command : 'Bold', tags : ['B','STRONG'], css : {'font-weight' : 'bold'}, key : 'b'},
@@ -259,7 +261,7 @@ var nicEditorConfig = bkClass.extend({
'right' : {name : __('Right Align'), command : 'justifyright', noActive : true},
'justify' : {name : __('Justify Align'), command : 'justifyfull', noActive : true},
'ol' : {name : __('Insert Ordered List'), command : 'insertorderedlist', tags : ['OL']},
- 'ul' : {name : __('Insert Unordered List'), command : 'insertunorderedlist', tags : ['UL']},
+ 'ul' : {name : __('Insert Unordered List'), command : 'insertunorderedlist', tags : ['UL']},
'subscript' : {name : __('Click to Subscript'), command : 'subscript', tags : ['SUB']},
'superscript' : {name : __('Click to Superscript'), command : 'superscript', tags : ['SUP']},
'strikethrough' : {name : __('Click to Strike Through'), command : 'strikeThrough', css : {'text-decoration' : 'line-through'}},
@@ -269,17 +271,17 @@ var nicEditorConfig = bkClass.extend({
'hr' : {name : __('Horizontal Rule'), command : 'insertHorizontalRule', noActive : true}
},
iconsPath : '../nicEditorIcons.gif',
- buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],
+ buttonList : ['save','bold','italic','underline','strikethrough','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','image','upload','link','unlink','removeformat','forecolor','bgcolor','indent','outdent','subscript','superscript','xhtml'],
iconList : {"xhtml":1,"bgcolor":2,"forecolor":3,"bold":4,"center":5,"hr":6,"indent":7,"italic":8,"justify":9,"left":10,"ol":11,"outdent":12,"removeformat":13,"right":14,"save":25,"strikethrough":16,"subscript":17,"superscript":18,"ul":19,"underline":20,"image":21,"link":22,"unlink":23,"close":24,"arrow":26,"upload":27}
-
+
});
-/* END CONFIG */
+/* END CONFIG */
var nicEditors = {
nicPlugins : [],
editors : [],
-
+
registerPlugin : function(plugin,options) {
this.nicPlugins.push({p : plugin, o : options});
},
@@ -291,7 +293,7 @@ var nicEditors = {
}
return nicEditors.editors;
},
-
+
findEditor : function(e) {
var editors = nicEditors.editors;
for(var i=0;i');
}
@@ -455,7 +457,7 @@ var nicEditorInstance = bkClass.extend({
this.elm.addEvent('mousedown',this.selected.closureListener(this)).addEvent('keypress',this.keyDown.closureListener(this)).addEvent('focus',this.selected.closure(this)).addEvent('blur',this.blur.closure(this)).addEvent('keyup',this.selected.closure(this));
this.ne.fireEvent('add',this);
},
-
+
remove : function() {
this.saveContent();
if(this.copyElm || this.options.hasPanel) {
@@ -466,21 +468,21 @@ var nicEditorInstance = bkClass.extend({
this.disable();
this.ne.fireEvent('remove',this);
},
-
+
disable : function() {
this.elm.setAttribute('contentEditable','false');
},
-
+
getSel : function() {
- return (window.getSelection) ? window.getSelection() : document.selection;
+ return (window.getSelection) ? window.getSelection() : document.selection;
},
-
+
getRng : function() {
var s = this.getSel();
if(!s || s.rangeCount === 0) { return; }
return (s.rangeCount > 0) ? s.getRangeAt(0) : s.createRange();
},
-
+
selRng : function(rng,s) {
if(window.getSelection) {
s.removeAllRanges();
@@ -489,7 +491,7 @@ var nicEditorInstance = bkClass.extend({
rng.select();
}
},
-
+
selElm : function() {
var r = this.getRng();
if(!r) { return; }
@@ -498,8 +500,8 @@ var nicEditorInstance = bkClass.extend({
if(r.cloneContents().childNodes.length == 1) {
for(var i=0;i'+((css) ? '' : '')+''+this.initialContent+'