ここの情報は古いです。ご理解頂いた上でお取り扱いください。

Changeset 7279


Ignore:
Timestamp:
May 19, 2008, 11:16:28 PM (11 years ago)
Author:
ebihara
Message:

#2448:多重に装飾されている文字にカーソルをあわせた際に、すべての装飾ボタンがアクティブにならなかったのを修正

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  
    77+'" 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>';}
    88return 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);}
     9ed.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;}
     10cm.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);}
    1011if(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}}
    1112c=this._createOpenPNEEmojiButton(n,emoji_config[n],cm);}
    1213if(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;}
     14return 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';}
     15if(elm.style.textDecoration=='underline'){return'u';}
     16if(elm.style.textDecoration=='line-through'){return's';}
     17if(elm.style.fontStyle=='italic'){return'i';}
     18if(elm.style.fontSize=='x-large'){return'large';}
     19if(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];}
     20var size=elm.getAttribute("size");if(tagname=="font"&&size=="5"){return"large";}
     21if(tagname=="font"&&size=="1"){return"small";}}
     22return tagname;},_createOpenPNEColorButton:function(id,s,cm){var t=cm,ed=t.editor,cmd,c;if(t.get(id)){return null;}
    1423s.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);};}
    1524if(!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  
    166166            });
    167167            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                }
    172185            });
    173186        },
     
    216229                version : "1.0"
    217230            }
     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;
    218258        },
    219259
Note: See TracChangeset for help on using the changeset viewer.