1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| var oEditor = tinymce.init({
selector: "textarea",
plugins: "save,code,textcolor,charmap,searchreplace,paste,wordcount",
toolbar: "save | insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
setup: function(editor) {
editor.on('keyup', function(e) {
var oBtnParent,
oBtnSave = this.buttons.save, // pas forcément d'intérêt si ce n'est pour gérer l'action "cmd"
oBody = this.getBody(),
txt = oBody.innerText || oBody.textContent;
// récup. la DIV parent
oBtnParent = document.querySelector('.mce-i-save').parentNode.parentNode;
// affiche/masque suivant le cas
oBtnParent.style.visibility = txt.length < 10 ? 'hidden' : 'visible';
})
}
}); |
Partager