2013-06-04 14 views
1

작은 메소드 addButton()으로 Button을 만들었습니다.TinyMCE4 자기 생성 버튼을 토글하는 법

버튼 상태를 어떻게 토글 할 수 있습니까? 첫 간단한 경우

나는 전체 화면 (내장 기능보다는 다른 기능) 있는 버튼이 있고 전체 화면 상태 를받은 후 그것을 숨길하고 "전체 화면을 종료"버튼으로 대체하고자합니다.

그러나 나는 그들을 표시하거나 숨길 수있는 올바른 방법을 찾지 못했습니다.

나는 버튼이 ID를 얻을 것이라는 점을 알고있다,하지만 난

답변

0

당신이 버튼을 추가하면 어느 ... 잘 모릅니다 :

var customFullscreenState = false; 
function toggleFullscreen() { 
    customFullscreenState = !customFullscreenState; 

    if (customFullscreenState) { 
     // do something, we are active 
    } else { 
     // do something else, we're unactive 
    } 

    editor.fire('CustomFullscreenStateChanged', {state: fullscreenState}); 
} 
와 이벤트를

editor.addButton('customFullscreen', { 
    tooltip: 'Fullscreen', 
    shortcut: 'Ctrl+Alt+F', 
    onClick: toggleCustomFullscreen, 
    onPostRender: function() { 
     var self = this; 

     editor.on('CustomFullscreenStateChanged', function(e) { 
      if (e.state) { 
       self.name('Close fullscreen'); 
       //self.active(e.state); // uncomment for "pressed" look 
      } else { 
       self.name('Fullscreen'); 
      } 
     }); 
    } 
}); 

및 처리

상태에 따라 다른 버튼처럼 보이게하고 다른 두 가지 일을 수행 할 수 있어야하지만, 액션과 텍스트를 변경하는 버튼은 여전히 ​​하나뿐입니다.