2016-03-15 74 views
0

我試圖建立一個自定義插件在CKEditor的其中一個選擇的單選按鈕列表中的元素的更改類所選元素的對話框。例如:CKEDITOR定製插件 - 與單選按鈕

選課BIG將添加類bigMEDIUM =>medSMALL =>sml

我阻塞在我必須檢索所選元素的值的部分。 Eveything否則會罰款,我在代碼託管波紋管應用類「MYCLASS」到最近的li標籤。

問題:如何獲取CKeditor的dialog元素中所選單選按鈕的值?

下面的代碼:

CKEDITOR.dialog.add('MyDialog', function (editor) { 
    function getListElement(editor, listTag) { 
     var range; 
     try { 
     range = editor.getSelection().getRanges()[ 0 ]; 
     } catch (e) { 
     return null; 
     } 

     range.shrink(CKEDITOR.SHRINK_TEXT); 
     return editor.elementPath(range.getCommonAncestor()).contains(listTag, 1); 
    } 

    return { 
     title: 'Size of the element', 
     minWidth: 400, 
     minHeight: 200, 
     contents: [ 
      { 
       id: 'tab-basic', 
       label: 'Size of an element', 
       elements: [ 
       { 
        type: 'radio', 
        id: 'bullet-size', 
        label: 'Size of the bullets', 
        items: [ [ 'BIG', 'big' ], [ 'MEDIUM', 'mdm' ],[ 'SMALL', 'sml' ] ], 
        style: 'color: green', 
        'default': 'big', 
       }, 
       ] 
      }, 
     ], 
     onOk: function() { 

     var editor = this.getParentEditor(), 
      element = getListElement(editor, 'ul'), 
      dialog = this, 
      config = editor.config, 
      lang = editor.lang, 
      style = new CKEDITOR.style(config.coreStyles_alpha); 

     editor.attachStyleStateChange(style, function(state) { 
      !editor.readOnly; 
     }); 
     count = element.getChildren().count(); 
     for(k=1; k <= count; k++){ 
      element.getChild(k-1).setAttribute('class', 'MyClass'); 
     } 
    } 
    } 
}); 

回答

1

這裏獲得價值的方式。裏面的onOk功能:

var my_variable = this.getVazlueOf(Id_of_you_tab, id_of_the_radio_list);