在焦点和模糊上更改TinyMCE的边框颜色

For*_*low 5 javascript jquery tinymce focus onblur

我在TinyMCE上使用jQuery.当TinyMCE编辑器处于焦点时,我试图让边框颜色改变,然后在模糊处,改变回来.

在ui.css中,我添加/更改了这些:

.defaultSkin table.mceLayout {border:0; border-left:1px solid #93a6e1; border-right:1px solid #93a6e1;}
.defaultSkin table.mceLayout tr.mceFirst td {border-top:1px solid #93a6e1;}
.defaultSkin table.mceLayout tr.mceLast td {border-bottom:1px solid #93a6e1;}
Run Code Online (Sandbox Code Playgroud)

我设法为init脚本到达此处:

$().ready(function() {

    function tinymce_focus(){
        $('.defaultSkin table.mceLayout').css({'border-color' : '#6478D7'});
        $('.defaultSkin table.mceLayout tr.mceFirst td').css({'border-top-color' : '#6478D7'});
        $('.defaultSkin table.mceLayout tr.mceLast td').css({'border-bottom-color' : '#6478D7'});
    }

    function tinymce_blur(){
        $('.defaultSkin table.mceLayout').css({'border-color' : '#93a6e1'});
        $('.defaultSkin table.mceLayout tr.mceFirst td').css({'border-top-color' : '#93a6e1'});
        $('.defaultSkin table.mceLayout tr.mceLast td').css({'border-bottom-color' : '#93a6e1'});
    }

    $('textarea.tinymce').tinymce({
        script_url : 'JS/tinymce/tiny_mce.js',
        theme : "advanced",
        mode : "exact",
          theme : "advanced",
          invalid_elements : "b,i,iframe,font,input,textarea,select,button,form,fieldset,legend,script,noscript,object,embed,table,img,a,h1,h2,h3,h4,h5,h6",

          //theme options 
          theme_advanced_buttons1 : "cut,copy,paste,pastetext,pasteword,selectall,|,undo,redo,|,cleanup,removeformat,|", 
          theme_advanced_buttons2 : "bold,italic,underline,|,bullist,numlist,|,forecolor,backcolor,|", 
          theme_advanced_buttons3 : "", 
          theme_advanced_buttons4 : "", 
          theme_advanced_toolbar_location : "top", 
          theme_advanced_toolbar_align : "left", 
          theme_advanced_statusbar_location : "none", 
          theme_advanced_resizing : false,

          //plugins
          plugins : "inlinepopups,paste",
          dialog_type : "modal",
        paste_auto_cleanup_on_paste : true,


        setup : function(ed) {
              ed.onClick.add(function(ed, evt) {
                  tinymce_focus(); 
              });

           }



    });    


});
Run Code Online (Sandbox Code Playgroud)

...但是这个(onclick,更改,边框颜色)是我唯一能够成功运作的东西.我所有的其他尝试都阻止了TinyMCE加载或者什么也没做.我浏览了TinyMCE维基页面和他们的论坛,但是却无法将散落在周围的小块信息中的全部图片拼凑起来.

有没有办法做到这一点?我只是忽略了一些简单的东西,或者实际上它实际上是非常复杂的东西?

For*_*low 4

我重新审视了这个问题,最终得到了一个支持更多浏览器的 jQuery 解决方案,因为在 ed.getDoc() 上使用 addEventListener() 函数是偶然的,并且 AddEvent() 函数在 ed 上根本不起作用.getDoc()(“对象不支持函数”错误)。

以下内容已确认适用于 IE8、Safari 5.1.7、Chrome 19、firefox 3.6 和 12。它似乎不适用于 Opera 11.64。

setup: function(ed){
            ed.onInit.add(function(ed){
                $(ed.getDoc()).contents().find('body').focus(function(){tinymce_focus();});
                $(ed.getDoc()).contents().find('body').blur(function(){tinymce_blur();});                   
            });
        }
Run Code Online (Sandbox Code Playgroud)