mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-39220 Javascript: Editor shrinks using collapse button
This commit is contained in:
parent
3a8c4380c0
commit
919834f2eb
4 changed files with 1 additions and 70 deletions
|
@ -127,29 +127,6 @@ Y.extend(COLLAPSE, Y.Base, {
|
|||
statusbar.show();
|
||||
button.setContent(M.util.get_string('hideeditortoolbar', 'form'));
|
||||
}
|
||||
|
||||
// TinyMCE renders the toolbar and path bar as part of the textarea. So toggling these items
|
||||
// changes the required size of the rendered textarea. Frustrating but it's the way it's built.
|
||||
// So we get TinyMCE to resize itself for us. Clunky but it works.
|
||||
|
||||
// Get the tinyMCE editor object for this text area.
|
||||
editorid = editortable.ancestor('div').one('textarea').get('id');
|
||||
editor = tinyMCE.getInstanceById(editorid);
|
||||
|
||||
// Somehow, this editor did not exist.
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Resize editor to reflect presence of toolbar and path bar..
|
||||
iframe = editor.getBody();
|
||||
if (iframe) {
|
||||
size = tinymce.DOM.getSize(iframe);
|
||||
// If objects exist resize editor.
|
||||
if (size) {
|
||||
editor.theme.resizeTo(size.w, size.h);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggle_collapse_from_event : function(thisevent) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
YUI.add("moodle-editor_tinymce-collapse",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};e.extend(n,e.Base,{toggleNodeTemplate:null,init:function(){this.initialise_toggles(10)},editors_initialised:function(){return typeof tinyMCE!="undefined"},initialise_toggles:function(t){var n=this.editors_initialised(),r=this,i;if(!n&&t){setTimeout(function(){r.initialise_toggles(t-1)},100);return}this.toggleNodeTemplate=e.Node.create('<a class="toggle_editor_toolbar" />'),this.toggleNodeTemplate.setContent(M.util.get_string("showeditortoolbar","form")),e.one("body").delegate("click",this.toggle_collapse_from_event,"a.toggle_editor_toolbar",this);for(i in tinyMCE.editors)this.setup_collapse(tinyMCE.editors[i]);tinyMCE.onAddEditor.add(e.bind(this.add_setup_collapse_listener,this))},add_setup_collapse_listener:function(t,n){n.onInit.add(e.bind(this.setup_collapse,this))},setup_collapse:function(t){var n=e.Node(t.getElement()),r=e.Node(t.getContainer()).one("> table"),i;if(!n.hasClass("collapsible"))return;if(!r)return;i=this.toggleNodeTemplate.cloneNode(!0),r.get("parentNode").insert(i,r),e.Node(t.getElement()).hasClass("collapsed")?this.toggle_collapse(i,r,0):this.toggle_collapse(i,r,1)},toggle_collapse:function(e,t,n){var r=t.one("td.mceToolbar").ancestor("tr"),i=t.one(".mceStatusbar").ancestor("tr"),s,o,u;typeof n=="undefined"&&(r.getStyle("display")==="none"?n=1:n=0),n===0?(r.hide(),i.hide(),e.setContent(M.util.get_string("showeditortoolbar","form"))):(r.show(),i.show(),e.setContent(M.util.get_string("hideeditortoolbar","form"))),editorid=t.ancestor("div").one("textarea").get("id"),s=tinyMCE.getInstanceById(editorid);if(!s)return;o=s.getBody(),o&&(u=tinymce.DOM.getSize(o),u&&s.theme.resizeTo(u.w,u.h))},toggle_collapse_from_event:function(e){var t=e.target.ancestor("a",!0),n=e.target.ancestor("span",!0).one("table.mceLayout");this.toggle_collapse(t,n)}}),M.editor_collapse=M.editor_collapse||{},M.editor_collapse.init=function(e){return new n(e)}},"@VERSION@",{requires:["base","node","dom"]});
|
||||
YUI.add("moodle-editor_tinymce-collapse",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};e.extend(n,e.Base,{toggleNodeTemplate:null,init:function(){this.initialise_toggles(10)},editors_initialised:function(){return typeof tinyMCE!="undefined"},initialise_toggles:function(t){var n=this.editors_initialised(),r=this,i;if(!n&&t){setTimeout(function(){r.initialise_toggles(t-1)},100);return}this.toggleNodeTemplate=e.Node.create('<a class="toggle_editor_toolbar" />'),this.toggleNodeTemplate.setContent(M.util.get_string("showeditortoolbar","form")),e.one("body").delegate("click",this.toggle_collapse_from_event,"a.toggle_editor_toolbar",this);for(i in tinyMCE.editors)this.setup_collapse(tinyMCE.editors[i]);tinyMCE.onAddEditor.add(e.bind(this.add_setup_collapse_listener,this))},add_setup_collapse_listener:function(t,n){n.onInit.add(e.bind(this.setup_collapse,this))},setup_collapse:function(t){var n=e.Node(t.getElement()),r=e.Node(t.getContainer()).one("> table"),i;if(!n.hasClass("collapsible"))return;if(!r)return;i=this.toggleNodeTemplate.cloneNode(!0),r.get("parentNode").insert(i,r),e.Node(t.getElement()).hasClass("collapsed")?this.toggle_collapse(i,r,0):this.toggle_collapse(i,r,1)},toggle_collapse:function(e,t,n){var r=t.one("td.mceToolbar").ancestor("tr"),i=t.one(".mceStatusbar").ancestor("tr"),s,o,u;typeof n=="undefined"&&(r.getStyle("display")==="none"?n=1:n=0),n===0?(r.hide(),i.hide(),e.setContent(M.util.get_string("showeditortoolbar","form"))):(r.show(),i.show(),e.setContent(M.util.get_string("hideeditortoolbar","form")))},toggle_collapse_from_event:function(e){var t=e.target.ancestor("a",!0),n=e.target.ancestor("span",!0).one("table.mceLayout");this.toggle_collapse(t,n)}}),M.editor_collapse=M.editor_collapse||{},M.editor_collapse.init=function(e){return new n(e)}},"@VERSION@",{requires:["base","node","dom"]});
|
||||
|
|
|
@ -127,29 +127,6 @@ Y.extend(COLLAPSE, Y.Base, {
|
|||
statusbar.show();
|
||||
button.setContent(M.util.get_string('hideeditortoolbar', 'form'));
|
||||
}
|
||||
|
||||
// TinyMCE renders the toolbar and path bar as part of the textarea. So toggling these items
|
||||
// changes the required size of the rendered textarea. Frustrating but it's the way it's built.
|
||||
// So we get TinyMCE to resize itself for us. Clunky but it works.
|
||||
|
||||
// Get the tinyMCE editor object for this text area.
|
||||
editorid = editortable.ancestor('div').one('textarea').get('id');
|
||||
editor = tinyMCE.getInstanceById(editorid);
|
||||
|
||||
// Somehow, this editor did not exist.
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Resize editor to reflect presence of toolbar and path bar..
|
||||
iframe = editor.getBody();
|
||||
if (iframe) {
|
||||
size = tinymce.DOM.getSize(iframe);
|
||||
// If objects exist resize editor.
|
||||
if (size) {
|
||||
editor.theme.resizeTo(size.w, size.h);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggle_collapse_from_event : function(thisevent) {
|
||||
|
|
|
@ -125,29 +125,6 @@ Y.extend(COLLAPSE, Y.Base, {
|
|||
statusbar.show();
|
||||
button.setContent(M.util.get_string('hideeditortoolbar', 'form'));
|
||||
}
|
||||
|
||||
// TinyMCE renders the toolbar and path bar as part of the textarea. So toggling these items
|
||||
// changes the required size of the rendered textarea. Frustrating but it's the way it's built.
|
||||
// So we get TinyMCE to resize itself for us. Clunky but it works.
|
||||
|
||||
// Get the tinyMCE editor object for this text area.
|
||||
editorid = editortable.ancestor('div').one('textarea').get('id');
|
||||
editor = tinyMCE.getInstanceById(editorid);
|
||||
|
||||
// Somehow, this editor did not exist.
|
||||
if (!editor) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Resize editor to reflect presence of toolbar and path bar..
|
||||
iframe = editor.getBody();
|
||||
if (iframe) {
|
||||
size = tinymce.DOM.getSize(iframe);
|
||||
// If objects exist resize editor.
|
||||
if (size) {
|
||||
editor.theme.resizeTo(size.w, size.h);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toggle_collapse_from_event : function(thisevent) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue