Changeset 5957
- Timestamp:
- 01/24/12 23:03:35 (4 months ago)
- Location:
- vendors/wysiwyg-nicedit/0.9r23
- Files:
-
- 2 edited
-
nicEdit.js (modified) (6 diffs)
-
nicEditorIcons.gif (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
vendors/wysiwyg-nicedit/0.9r23/nicEdit.js
r3522 r5957 11 11 12 12 var nicEditorConfig = bkClass.extend({ 13 buttons : {14 'bold' : {name : __('Click to Bold'), command : 'Bold', tags : ['B','STRONG'], css : {'font-weight' : 'bold'}, key : 'b'},15 'italic' : {name : __('Click to Italic'), command : 'Italic', tags : ['EM','I'], css : {'font-style' : 'italic'}, key : 'i'},16 'underline' : {name : __('Click to Underline'), command : 'Underline', tags : ['U'], css : {'text-decoration' : 'underline'}, key : 'u'},17 'left' : {name : __('Left Align'), command : 'justifyleft', noActive : true},18 'center' : {name : __('Center Align'), command : 'justifycenter', noActive : true},19 'right' : {name : __('Right Align'), command : 'justifyright', noActive : true},20 'justify' : {name : __('Justify Align'), command : 'justifyfull', noActive : true},21 'ol' : {name : __('Insert Ordered List'), command : 'insertorderedlist', tags : ['OL']},22 'ul' :{name : __('Insert Unordered List'), command : 'insertunorderedlist', tags : ['UL']},23 'subscript' : {name : __('Click to Subscript'), command : 'subscript', tags : ['SUB']},24 'superscript' : {name : __('Click to Superscript'), command : 'superscript', tags : ['SUP']},25 'strikethrough' : {name : __('Click to Strike Through'), command : 'strikeThrough', css : {'text-decoration' : 'line-through'}},26 'removeformat' : {name : __('Remove Formatting'), command : 'removeformat', noActive : true},27 'indent' : {name : __('Indent Text'), command : 'indent', noActive : true},28 'outdent' : {name : __('Remove Indent'), command : 'outdent', noActive : true},29 'hr' : {name : __('Horizontal Rule'), command : 'insertHorizontalRule', noActive : true}30 },31 iconsPath : '../nicEditorIcons.gif',32 buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'],33 iconList : {"bgcolor":1,"forecolor":2,"bold":3,"center":4,"hr":5,"indent":6,"italic":7,"justify":8,"left":9,"ol":10,"outdent":11,"removeformat":12,"right":13,"save":24,"strikethrough":15,"subscript":16,"superscript":17,"ul":18,"underline":19,"image":20,"link":21,"unlink":22,"close":23,"arrow":25}34 13 buttons : { 14 'bold' : {name : __('Click to Bold'), command : 'Bold', tags : ['B','STRONG'], css : {'font-weight' : 'bold'}, key : 'b'}, 15 'italic' : {name : __('Click to Italic'), command : 'Italic', tags : ['EM','I'], css : {'font-style' : 'italic'}, key : 'i'}, 16 'underline' : {name : __('Click to Underline'), command : 'Underline', tags : ['U'], css : {'text-decoration' : 'underline'}, key : 'u'}, 17 'left' : {name : __('Left Align'), command : 'justifyleft', noActive : true}, 18 'center' : {name : __('Center Align'), command : 'justifycenter', noActive : true}, 19 'right' : {name : __('Right Align'), command : 'justifyright', noActive : true}, 20 'justify' : {name : __('Justify Align'), command : 'justifyfull', noActive : true}, 21 'ol' : {name : __('Insert Ordered List'), command : 'insertorderedlist', tags : ['OL']}, 22 'ul' : {name : __('Insert Unordered List'), command : 'insertunorderedlist', tags : ['UL']}, 23 'subscript' : {name : __('Click to Subscript'), command : 'subscript', tags : ['SUB']}, 24 'superscript' : {name : __('Click to Superscript'), command : 'superscript', tags : ['SUP']}, 25 'strikethrough' : {name : __('Click to Strike Through'), command : 'strikeThrough', css : {'text-decoration' : 'line-through'}}, 26 'removeformat' : {name : __('Remove Formatting'), command : 'removeformat', noActive : true}, 27 'indent' : {name : __('Indent Text'), command : 'indent', noActive : true}, 28 'outdent' : {name : __('Remove Indent'), command : 'outdent', noActive : true}, 29 'hr' : {name : __('Horizontal Rule'), command : 'insertHorizontalRule', noActive : true} 30 }, 31 iconsPath : '../nicEditorIcons.gif', 32 buttonList : ['save','bold','italic','underline','left','center','right','justify','ol','ul','fontSize','fontFamily','fontFormat','indent','outdent','image','upload','link','unlink','forecolor','bgcolor'], 33 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} 34 35 35 }); 36 36 ; … … 53 53 54 54 var nicSelectOptions = { 55 buttons : {56 'fontSize' : {name : __('Select Font Size'), type : 'nicEditorFontSizeSelect', command : 'fontsize'},57 'fontFamily' : {name : __('Select Font Family'), type : 'nicEditorFontFamilySelect', command : 'fontname'},58 'fontFormat' : {name : __('Select Font Format'), type : 'nicEditorFontFormatSelect', command : 'formatBlock'}59 }55 buttons : { 56 'fontSize' : {name : __('Select Font Size'), type : 'nicEditorFontSizeSelect', command : 'fontsize'}, 57 'fontFamily' : {name : __('Select Font Family'), type : 'nicEditorFontFamilySelect', command : 'fontname'}, 58 'fontFormat' : {name : __('Select Font Format'), type : 'nicEditorFontFormatSelect', command : 'formatBlock'} 59 } 60 60 }; 61 61 … … 64 64 65 65 var nicLinkOptions = { 66 buttons : {67 'link' : {name : 'Add Link', type : 'nicLinkButton', tags : ['A']},68 'unlink' : {name : 'Remove Link', command : 'unlink', noActive : true}69 }66 buttons : { 67 'link' : {name : 'Add Link', type : 'nicLinkButton', tags : ['A']}, 68 'unlink' : {name : 'Remove Link', command : 'unlink', noActive : true} 69 } 70 70 }; 71 71 … … 74 74 75 75 var nicColorOptions = { 76 buttons : {77 'forecolor' : {name : __('Change Text Color'), type : 'nicEditorColorButton', noClose : true},78 'bgcolor' : {name : __('Change Background Color'), type : 'nicEditorBgColorButton', noClose : true}79 }76 buttons : { 77 'forecolor' : {name : __('Change Text Color'), type : 'nicEditorColorButton', noClose : true}, 78 'bgcolor' : {name : __('Change Background Color'), type : 'nicEditorBgColorButton', noClose : true} 79 } 80 80 }; 81 81 … … 84 84 85 85 var nicImageOptions = { 86 buttons : {87 'image' : {name : 'Add Image', type : 'nicImageButton', tags : ['IMG']}88 }89 86 buttons : { 87 'image' : {name : 'Add Image', type : 'nicImageButton', tags : ['IMG']} 88 } 89 90 90 }; 91 91 … … 94 94 95 95 var nicSaveOptions = { 96 buttons : {97 'save' : {name : __('Save this content'), type : 'nicEditorSaveButton'}98 }96 buttons : { 97 'save' : {name : __('Save this content'), type : 'nicEditorSaveButton'} 98 } 99 99 }; 100 100 101 101 var nicEditorSaveButton=nicEditorButton.extend({init:function(){if(!this.ne.options.onSave){this.margin.setStyle({display:"none"})}},mouseClick:function(){var B=this.ne.options.onSave;var A=this.ne.selectedInstance;B(A.getContent(),A.elm.id,A)}});nicEditors.registerPlugin(nicPlugin,nicSaveOptions); 102 102 103 var nicXHTML=bkClass.extend({stripAttributes:["_moz_dirty","_moz_resizing","_extended"],noShort:["style","title","script","textarea","a"],cssReplace:{"font-weight:bold;":"strong","font-style:italic;":"em"},sizes:{1:"xx-small",2:"x-small",3:"small",4:"medium",5:"large",6:"x-large"},construct:function(A){this.ne=A;if(this.ne.options.xhtml){A.addEvent("get",this.cleanup.closure(this))}},cleanup:function(A){var B=A.getElm();var C=this.toXHTML(B);A.content=C},toXHTML:function(C,A,L){var G="";var O="";var P="";var I=C.nodeType;var Q=C.nodeName.toLowerCase();var N=C.hasChildNodes&&C.hasChildNodes();var B=new Array();switch(I){case 1:var H=C.attributes;switch(Q){case"b":Q="strong";break;case"i":Q="em";break;case"font":Q="span";break}if(A){for(var F=0;F<H.length;F++){var K=H[F];var M=K.nodeName.toLowerCase();var D=K.nodeValue;if(!K.specified||!D||bkLib.inArray(this.stripAttributes,M)||typeof (D)=="function"){continue}switch(M){case"style":var J=D.replace(/ /g,"");for(itm in this.cssReplace){if(J.indexOf(itm)!=-1){B.push(this.cssReplace[itm]);J=J.replace(itm,"")}}P+=J;D="";break;case"class":D=D.replace("Apple-style-span","");break;case"size":P+="font-size:"+this.sizes[D]+";";D="";break}if(D){O+=" "+M+'="'+D+'"'}}if(P){O+=' style="'+P+'"'}for(var F=0;F<B.length;F++){G+="<"+B[F]+">"}if(O==""&&Q=="span"){A=false}if(A){G+="<"+Q;if(Q!="br"){G+=O}}}if(!N&&!bkLib.inArray(this.noShort,M)){if(A){G+=" />"}}else{if(A){G+=">"}for(var F=0;F<C.childNodes.length;F++){var E=this.toXHTML(C.childNodes[F],true,true);if(E){G+=E}}}if(A&&N){G+="</"+Q+">"}for(var F=0;F<B.length;F++){G+="</"+B[F]+">"}break;case 3:G+=C.nodeValue;break}return G}});nicEditors.registerPlugin(nicXHTML); 104 105 var nicBBCode=bkClass.extend({construct:function(A){this.ne=A;if(this.ne.options.bbCode){A.addEvent("get",this.bbGet.closure(this));A.addEvent("set",this.bbSet.closure(this));var B=this.ne.loadedPlugins;for(itm in B){if(B[itm].toXHTML){this.xhtml=B[itm]}}}},bbGet:function(A){var B=this.xhtml.toXHTML(A.getElm());A.content=this.toBBCode(B)},bbSet:function(A){A.content=this.fromBBCode(A.content)},toBBCode:function(B){function A(D,C){B=B.replace(D,C)}A(/\n/gi,"");A(/<strong>(.*?)<\/strong>/gi,"[b]$1[/b]");A(/<em>(.*?)<\/em>/gi,"[i]$1[/i]");A(/<span.*?style="text-decoration:underline;">(.*?)<\/span>/gi,"[u]$1[/u]");A(/<ul>(.*?)<\/ul>/gi,"[list]$1[/list]");A(/<li>(.*?)<\/li>/gi,"[*]$1[]");A(/<ol>(.*?)<\/ol>/gi,"[list=1]$1[/list]");A(/<img.*?src="(.*?)".*?>/gi,"[img]$1[/img]");A(/<a.*?href="(.*?)".*?>(.*?)<\/a>/gi,"[url=$1]$2[/url]");A(/<br.*?>/gi,"\n");A(/<.*?>.*?<\/.*?>/gi,"");return B},fromBBCode:function(A){function B(D,C){A=A.replace(D,C)}B(/\[b\](.*?)\[\/b\]/gi,"<strong>$1</strong>");B(/\[i\](.*?)\[\/i\]/gi,"<em>$1</em>");B(/\[u\](.*?)\[\/u\]/gi,'<span style="text-decoration:underline;">$1</span>');B(/\[list\](.*?)\[\/list\]/gi,"<ul>$1</ul>");B(/\[list=1\](.*?)\[\/list\]/gi,"<ol>$1</ol>");B(/\[\*\](.*?)\[\/\*\]/gi,"<li>$1</li>");B(/\[img\](.*?)\[\/img\]/gi,'<img src="$1" />');B(/\[url=(.*?)\](.*?)\[\/url\]/gi,'<a href="$1">$2</a>');B(/\n/gi,"<br />");return A}});nicEditors.registerPlugin(nicBBCode); 106 107 nicEditor=nicEditor.extend({floatingPanel:function(){this.floating=new bkElement("DIV").setStyle({position:"absolute",top:"-1000px"}).appendTo(document.body);this.addEvent("focus",this.reposition.closure(this)).addEvent("blur",this.hide.closure(this));this.setPanel(this.floating)},reposition:function(){var B=this.selectedInstance.e;this.floating.setStyle({width:(parseInt(B.getStyle("width"))||B.clientWidth)+"px"});var A=B.offsetTop-this.floating.offsetHeight;if(A<0){A=B.offsetTop+B.offsetHeight}this.floating.setStyle({top:A+"px",left:B.offsetLeft+"px",display:"block"})},hide:function(){this.floating.setStyle({top:"-1000px"})}}); 108 109 110 var nicCodeOptions = { 111 buttons : { 112 'xhtml' : {name : 'Edit HTML', type : 'nicCodeButton'} 113 } 114 115 }; 116 117 var nicCodeButton=nicEditorAdvancedButton.extend({width:"350px",addPane:function(){this.addForm({"":{type:"title",txt:"Edit HTML"},code:{type:"content",value:this.ne.selectedInstance.getContent(),style:{width:"340px",height:"200px"}}})},submit:function(B){var A=this.inputs.code.value;this.ne.selectedInstance.setContent(A);this.removePane()}});nicEditors.registerPlugin(nicPlugin,nicCodeOptions); 118
Note: See TracChangeset
for help on using the changeset viewer.
