Changeset 7279
- Timestamp:
- May 19, 2008, 11:16:28 PM (14 years ago)
- Location:
- OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne/editor_plugin.js
r7267 r7279 7 7 +'" onmousedown="return false;" onclick="return false;" title="'+tinymce.DOM.encode(s.title)+'">';if(s.image){h+='<img class="mceIcon" src="'+s.image+'" /></a>';}else{h+='<span class="mceIcon '+s['class']+'"></span></a>';} 8 8 return h;},postRender:function(){tinymce.dom.Event.add(this.id,'click',this.showMenu,this);}});tinymce.create('tinymce.ui.OpenPNECmdButton:tinymce.ui.Button',{renderHTML:function(){var s=this.settings;var h='<a id="'+this.id+'" href="javascript:;" class="mceButton mceButtonEnabled '+s['class']+'" style="width:40px;" onmousedown="return false;" onclick="return false;" title="'+tinymce.DOM.encode(s.title)+'"><img class="mceIcon" style="width:40px;" src="'+s.image+'" /></a>';return h;}});tinymce.PluginManager.requireLangPack('openpne');var config=pne_mce_editor_get_config();tinymce.create('tinymce.plugins.OpenPNEPlugin',{init:function(ed,url){var t=this;ed.settings.content_css=url+"/css/editor.css";ed.addCommand('mceOpenPNE_op_b',function(){tinyMCE.execCommand("Bold");});ed.addCommand('mceOpenPNE_op_u',function(){tinyMCE.execCommand("Underline");});ed.addCommand('mceOpenPNE_op_s',function(){tinyMCE.execCommand("Strikethrough");});ed.addCommand('mceOpenPNE_op_i',function(){tinyMCE.execCommand("Italic");});ed.addCommand('mceOpenPNE_op_large',function(){tinyMCE.execCommand("Fontsize",false,5);});ed.addCommand('mceOpenPNE_op_small',function(){tinyMCE.execCommand("Fontsize",false,1);});ed.addCommand('mceOpenPNE_op_image',function(){window.open(config.op_image.contentURL,'','width=600,height=550,toolbar=no,scrollbars=yes,left=10,top=10');});ed.addCommand('mceOpenPNE_op_cmd',function(){window.open('http://www.openpne.jp/cmd/');});for(var key in config){var value=config[key];if(value.isEnabled&&key!="op_color"){ed.addButton(key,{title:'{#openpne.'+key+'}',image:value.imageURL,cmd:'mceOpenPNE_'+key});}} 9 ed.onBeforeSetContent.add(function(ed,o){o.content=t._textToPreview(o.content);});ed.onPostProcess.add(function(ed,o){if(o.save){if(ed.isHidden()){o.content=ed.getElement().value.replace(/\n\n/g,"\n \n");}else{o.content=t._previewToText(o.content,ed);}}});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('mce_editor_textarea_op_b',n.nodeName.toLowerCase()=='b');cm.setActive('mce_editor_textarea_op_u',n.nodeName.toLowerCase()=='u');cm.setActive('mce_editor_textarea_op_s',n.nodeName.toLowerCase()=='s');cm.setActive('mce_editor_textarea_op_i',n.nodeName.toLowerCase()=='i');});},createControl:function(n,cm){var c=null;if(n=="op_color"&&config["op_color"].isEnabled){c=this._createOpenPNEColorButton("op_color",{title:"{#openpne.op_color}",image:config["op_color"].imageURL,cmd:"ForeColor"},cm);} 9 ed.onBeforeSetContent.add(function(ed,o){o.content=t._textToPreview(o.content);});ed.onPostProcess.add(function(ed,o){if(o.save){if(ed.isHidden()){o.content=ed.getElement().value.replace(/\n\n/g,"\n \n");}else{o.content=t._previewToText(o.content,ed);}}});ed.onNodeChange.add(function(ed,cm,n){cm.setActive('mce_editor_textarea_op_b',false);cm.setActive('mce_editor_textarea_op_u',false);cm.setActive('mce_editor_textarea_op_s',false);cm.setActive('mce_editor_textarea_op_i',false);cm.setActive('mce_editor_textarea_op_large',false);cm.setActive('mce_editor_textarea_op_small',false);var elm=n;while(elm.parentNode){var tagname=t._getTagName(elm);if((tagname=="large"||tagname=="small")&&(cm.get('mce_editor_textarea_op_large').isActive()||cm.get('mce_editor_textarea_op_small').isActive())){elm=elm.parentNode;continue;} 10 cm.setActive('mce_editor_textarea_op_'+tagname,true);elm=elm.parentNode;}});},createControl:function(n,cm){var c=null;if(n=="op_color"&&config["op_color"].isEnabled){c=this._createOpenPNEColorButton("op_color",{title:"{#openpne.op_color}",image:config["op_color"].imageURL,cmd:"ForeColor"},cm);} 10 11 if(n=="op_emoji_docomo"||n=="op_emoji_au"&&config["op_emoji_au"].isEnabled||n=="op_emoji_softbank"&&config["op_emoji_softbank"].isEnabled){var emoji_config={op_emoji_docomo:{carrier:"i",emoji:[{start:1,end:252}],title:"{#openpne."+n+"}",image:config[n].imageURL},op_emoji_au:{carrier:"e",emoji:[{start:1,end:518},{start:700,end:822}],title:"{#openpne."+n+"}",image:config[n].imageURL},op_emoji_softbank:{carrier:"s",emoji:[{start:1,end:485}],title:"{#openpne."+n+"}",image:config[n].imageURL}} 11 12 c=this._createOpenPNEEmojiButton(n,emoji_config[n],cm);} 12 13 if(n=="op_cmd"){c=this._createOpenPNECmdButton(n,{title:"{#openpne.op_cmd}",image:config["op_cmd"].imageURL,cmd:"mceOpenPNE_op_cmd"},cm);} 13 return c;},getInfo:function(){return{longname:'OpenPNE plugin',author:'Kousuke Ebihara',version:"1.0"}},_createOpenPNEColorButton:function(id,s,cm){var t=cm,ed=t.editor,cmd,c;if(t.get(id)){return null;} 14 return c;},getInfo:function(){return{longname:'OpenPNE plugin',author:'Kousuke Ebihara',version:"1.0"}},_getTagName:function(elm){var tagname=elm.nodeName.toLowerCase();if(Prototype.Browser.WebKit&&tagname=="span"){if(elm.style.fontWeight=='bold'){return'b';} 15 if(elm.style.textDecoration=='underline'){return'u';} 16 if(elm.style.textDecoration=='line-through'){return's';} 17 if(elm.style.fontStyle=='italic'){return'i';} 18 if(elm.style.fontSize=='x-large'){return'large';} 19 if(elm.style.fontSize=='x-small'){return'small';}}else if(tagname!="span"){var convertList={strike:"s",strong:"b",em:"i"};if(convertList[tagname]){return convertList[tagname];} 20 var size=elm.getAttribute("size");if(tagname=="font"&&size=="5"){return"large";} 21 if(tagname=="font"&&size=="1"){return"small";}} 22 return tagname;},_createOpenPNEColorButton:function(id,s,cm){var t=cm,ed=t.editor,cmd,c;if(t.get(id)){return null;} 14 23 s.title=ed.translate(s.title);s.scope=s.scope||ed;if(!s.onclick){s.onclick=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};} 15 24 if(!s.onselect){s.onselect=function(v){ed.execCommand(s.cmd,s.ui||false,v||s.value);};} -
OpenPNE/trunk/public_html/js/tiny_mce/plugins/openpne/editor_plugin.js.src
r7267 r7279 166 166 }); 167 167 ed.onNodeChange.add(function(ed, cm, n) { 168 cm.setActive('mce_editor_textarea_op_b', n.nodeName.toLowerCase() == 'b'); 169 cm.setActive('mce_editor_textarea_op_u', n.nodeName.toLowerCase() == 'u'); 170 cm.setActive('mce_editor_textarea_op_s', n.nodeName.toLowerCase() == 's'); 171 cm.setActive('mce_editor_textarea_op_i', n.nodeName.toLowerCase() == 'i'); 168 cm.setActive('mce_editor_textarea_op_b', false); 169 cm.setActive('mce_editor_textarea_op_u', false); 170 cm.setActive('mce_editor_textarea_op_s', false); 171 cm.setActive('mce_editor_textarea_op_i', false); 172 cm.setActive('mce_editor_textarea_op_large', false); 173 cm.setActive('mce_editor_textarea_op_small', false); 174 175 var elm = n; 176 while (elm.parentNode) { 177 var tagname = t._getTagName(elm); 178 if ((tagname == "large" || tagname == "small") && (cm.get('mce_editor_textarea_op_large').isActive() || cm.get('mce_editor_textarea_op_small').isActive())) { 179 elm = elm.parentNode; 180 continue; 181 } 182 cm.setActive('mce_editor_textarea_op_' + tagname, true); 183 elm = elm.parentNode; 184 } 172 185 }); 173 186 }, … … 216 229 version : "1.0" 217 230 } 231 }, 232 233 _getTagName : function(elm) { 234 var tagname = elm.nodeName.toLowerCase(); 235 if (Prototype.Browser.WebKit && tagname == "span") { 236 if (elm.style.fontWeight == 'bold') { return 'b'; } 237 if (elm.style.textDecoration == 'underline') { return 'u'; } 238 if (elm.style.textDecoration == 'line-through') { return 's'; } 239 if (elm.style.fontStyle == 'italic') { return 'i'; } 240 if (elm.style.fontSize == 'x-large') { return 'large'; } 241 if (elm.style.fontSize == 'x-small') { return 'small'; } 242 } else if (tagname != "span") { 243 var convertList = {strike: "s", strong: "b", em: "i"}; 244 if (convertList[tagname]) { 245 return convertList[tagname]; 246 } 247 248 var size = elm.getAttribute("size"); 249 if (tagname == "font" && size == "5") { 250 return "large"; 251 } 252 if (tagname == "font" && size == "1") { 253 return "small"; 254 } 255 } 256 257 return tagname; 218 258 }, 219 259
Note: See TracChangeset
for help on using the changeset viewer.