mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-43869 Atto: id escaping so Atto works with when there is : in the id.
(Quiz) Also includes fixes for Atto when the repositories should not be displayed.
This commit is contained in:
parent
55c0403c6c
commit
b269f635f6
@ -200,49 +200,55 @@ M.atto_image = M.atto_image || {
|
||||
}
|
||||
},
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
html += '<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_image_urlentry').on('blur', M.atto_image.url_changed, this);
|
||||
content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image, this, elementid);
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
File diff suppressed because one or more lines are too long
@ -200,49 +200,55 @@ M.atto_image = M.atto_image || {
|
||||
}
|
||||
},
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
html += '<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_image_urlentry').on('blur', M.atto_image.url_changed, this);
|
||||
content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image, this, elementid);
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
@ -198,49 +198,55 @@ M.atto_image = M.atto_image || {
|
||||
}
|
||||
},
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_image_urlentry">' + M.util.get_string('enterurl', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_image_urlentry" size="32"/>' +
|
||||
'<br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
html += '<button id="openimagebrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_image') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<div style="display:none" role="alert" id="atto_image_altwarning" class="warning">' +
|
||||
M.util.get_string('presentationoraltrequired', 'atto_image') +
|
||||
'</div>' +
|
||||
'<label for="atto_image_altentry">' + M.util.get_string('enteralt', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="text" value="" id="atto_image_altentry" size="32"/>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_image_presentation"/>' +
|
||||
'<label class="sameline" for="atto_image_presentation">' + M.util.get_string('presentation', 'atto_image') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_widthentry">' + M.util.get_string('width', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_widthentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label class="sameline" for="atto_image_heightentry">' + M.util.get_string('height', 'atto_image') +
|
||||
'</label>' +
|
||||
'<input type="text" value="" id="atto_image_heightentry" size="10"/>' +
|
||||
'<br/>' +
|
||||
'<label for="atto_image_preview">' + M.util.get_string('preview', 'atto_image') +
|
||||
'</label>' +
|
||||
'<img src="#" width="200" id="atto_image_preview" alt="" style="display: none;"/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_image_urlentrysubmit">' +
|
||||
M.util.get_string('createimage', 'atto_image') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_image');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_image_urlentry').on('blur', M.atto_image.url_changed, this);
|
||||
content.one('#atto_image_urlentrysubmit').on('click', M.atto_image.set_image, this, elementid);
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'image')) {
|
||||
content.one('#openimagebrowser').on('click', M.atto_image.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
@ -238,29 +238,35 @@ M.atto_link = M.atto_link || {
|
||||
* @return string
|
||||
*/
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>' +
|
||||
'<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
html += '<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link, this, elementid);
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-atto_link-button",function(e,t){M.atto_link=M.atto_link||{dialogue:null,selection:null,display_chooser:function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_link.selection=M.editor_atto.get_selection();if(M.atto_link.selection!==!1&&!M.atto_link.selection.collapsed){var n;M.atto_link.dialogue?n=M.atto_link.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_link.get_form_content(t)),n.set("headerContent",M.util.get_string("createlink","atto_link")),M.atto_link.resolve_anchors(),n.show(),M.atto_link.dialogue=n}},init:function(e){var t=M.util.image_url("e/insert_edit_link","core");M.editor_atto.add_toolbar_button(e.elementid,"link",t,e.group,this.display_chooser,this)},resolve_anchors:function(){var t=M.editor_atto.get_selection_parent_node(),n,r,i;if(!t)return;n=M.atto_link.find_selected_anchors(e.one(t)),n.length>0&&(r=n[0],M.atto_link.selection=M.editor_atto.get_selection_from_node(r),i=r.getAttribute("href"),target=r.getAttribute("target"),i!==""&&e.one("#atto_link_urlentry").set("value",i),target==="_blank"?e.one("#atto_link_openinnewwindow").set("checked","checked"):e.one("#atto_link_openinnewwindow").set("checked",""))},open_filepicker:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"link",M.atto_link.filepicker_callback)},filepicker_callback:function(e){M.atto_link.dialogue.hide(),e.url!==""&&(M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},set_link:function(t,n){var r,i,s,o,u;t.preventDefault(),M.atto_link.dialogue.hide(),r=t.currentTarget.ancestor(".atto_form").one("input[type=url]"),u=r.get("value");if(u!==""){M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,u),s=M.editor_atto.get_selection_parent_node();if(!s)return;o=M.atto_link.find_selected_anchors(e.one(s)),e.Array.each(o,function(e){i=t.currentTarget.ancestor(".atto_form").one("input[type=checkbox]"),i.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")}),M.editor_atto.text_updated(n)}},find_selected_anchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&M.editor_atto.selection_contains_node(e)&&r.push(e)}),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},get_form_content:function(t){var n=e.Node.create('<form class="atto_form"><label for="atto_link_urlentry">'+M.util.get_string("enterurl","atto_link")+"</label>"+'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>'+'<button id="openlinkbrowser" data-editor="'+e.Escape.html(t)+'">'+M.util.get_string("browserepositories","atto_link")+"</button>"+"<br/>"+'<input type="checkbox" id="atto_link_openinnewwindow"/>'+'<label class="sameline" for="atto_link_openinnewwindow">'+M.util.get_string("openinnewwindow","atto_link")+"</label>"+"<br/>"+'<div class="mdl-align">'+"<br/>"+'<button id="atto_link_urlentrysubmit">'+M.util.get_string("createlink","atto_link")+"</button>"+"</div>"+"</form>"+"<hr/>"+M.util.get_string("accessibilityhint","atto_link"));return n.one("#atto_link_urlentrysubmit").on("click",M.atto_link.set_link,this,t),n.one("#openlinkbrowser").on("click",M.atto_link.open_filepicker),n}}},"@VERSION@",{requires:["node","escape"]});
|
||||
YUI.add("moodle-atto_link-button",function(e,t){M.atto_link=M.atto_link||{dialogue:null,selection:null,display_chooser:function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_link.selection=M.editor_atto.get_selection();if(M.atto_link.selection!==!1&&!M.atto_link.selection.collapsed){var n;M.atto_link.dialogue?n=M.atto_link.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_link.get_form_content(t)),n.set("headerContent",M.util.get_string("createlink","atto_link")),M.atto_link.resolve_anchors(),n.show(),M.atto_link.dialogue=n}},init:function(e){var t=M.util.image_url("e/insert_edit_link","core");M.editor_atto.add_toolbar_button(e.elementid,"link",t,e.group,this.display_chooser,this)},resolve_anchors:function(){var t=M.editor_atto.get_selection_parent_node(),n,r,i;if(!t)return;n=M.atto_link.find_selected_anchors(e.one(t)),n.length>0&&(r=n[0],M.atto_link.selection=M.editor_atto.get_selection_from_node(r),i=r.getAttribute("href"),target=r.getAttribute("target"),i!==""&&e.one("#atto_link_urlentry").set("value",i),target==="_blank"?e.one("#atto_link_openinnewwindow").set("checked","checked"):e.one("#atto_link_openinnewwindow").set("checked",""))},open_filepicker:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"link",M.atto_link.filepicker_callback)},filepicker_callback:function(e){M.atto_link.dialogue.hide(),e.url!==""&&(M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},set_link:function(t,n){var r,i,s,o,u;t.preventDefault(),M.atto_link.dialogue.hide(),r=t.currentTarget.ancestor(".atto_form").one("input[type=url]"),u=r.get("value");if(u!==""){M.editor_atto.set_selection(M.atto_link.selection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,u),s=M.editor_atto.get_selection_parent_node();if(!s)return;o=M.atto_link.find_selected_anchors(e.one(s)),e.Array.each(o,function(e){i=t.currentTarget.ancestor(".atto_form").one("input[type=checkbox]"),i.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")}),M.editor_atto.text_updated(n)}},find_selected_anchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&M.editor_atto.selection_contains_node(e)&&r.push(e)}),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},get_form_content:function(t){var n='<form class="atto_form"><label for="atto_link_urlentry">'+M.util.get_string("enterurl","atto_link")+"</label>"+'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>';M.editor_atto.can_show_filepicker(t,"link")&&(n+='<button id="openlinkbrowser" data-editor="'+e.Escape.html(t)+'">'+M.util.get_string("browserepositories","atto_link")+"</button>"+"<br/>"),n+='<input type="checkbox" id="atto_link_openinnewwindow"/><label class="sameline" for="atto_link_openinnewwindow">'+M.util.get_string("openinnewwindow","atto_link")+"</label>"+"<br/>"+'<div class="mdl-align">'+"<br/>"+'<button id="atto_link_urlentrysubmit">'+M.util.get_string("createlink","atto_link")+"</button>"+"</div>"+"</form>"+"<hr/>"+M.util.get_string("accessibilityhint","atto_link");var r=e.Node.create(n);return r.one("#atto_link_urlentrysubmit").on("click",M.atto_link.set_link,this,t),M.editor_atto.can_show_filepicker(t,"link")&&r.one("#openlinkbrowser").on("click",M.atto_link.open_filepicker),r}}},"@VERSION@",{requires:["node","escape"]});
|
||||
|
@ -238,29 +238,35 @@ M.atto_link = M.atto_link || {
|
||||
* @return string
|
||||
*/
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>' +
|
||||
'<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
html += '<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link, this, elementid);
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
@ -236,29 +236,35 @@ M.atto_link = M.atto_link || {
|
||||
* @return string
|
||||
*/
|
||||
get_form_content : function(elementid) {
|
||||
var content = Y.Node.create('<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>' +
|
||||
'<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>' +
|
||||
'<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link'));
|
||||
var html = '<form class="atto_form">' +
|
||||
'<label for="atto_link_urlentry">' + M.util.get_string('enterurl', 'atto_link') +
|
||||
'</label>' +
|
||||
'<input class="fullwidth" type="url" value="" id="atto_link_urlentry" size="32"/><br/>';
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
html += '<button id="openlinkbrowser" data-editor="' + Y.Escape.html(elementid) + '">' +
|
||||
M.util.get_string('browserepositories', 'atto_link') +
|
||||
'</button>' +
|
||||
'<br/>';
|
||||
}
|
||||
html += '<input type="checkbox" id="atto_link_openinnewwindow"/>' +
|
||||
'<label class="sameline" for="atto_link_openinnewwindow">' + M.util.get_string('openinnewwindow', 'atto_link') +
|
||||
'</label>' +
|
||||
'<br/>' +
|
||||
'<div class="mdl-align">' +
|
||||
'<br/>' +
|
||||
'<button id="atto_link_urlentrysubmit">' +
|
||||
M.util.get_string('createlink', 'atto_link') +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'</form>' +
|
||||
'<hr/>' + M.util.get_string('accessibilityhint', 'atto_link');
|
||||
|
||||
var content = Y.Node.create(html);
|
||||
|
||||
content.one('#atto_link_urlentrysubmit').on('click', M.atto_link.set_link, this, elementid);
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
if (M.editor_atto.can_show_filepicker(elementid, 'link')) {
|
||||
content.one('#openlinkbrowser').on('click', M.atto_link.open_filepicker);
|
||||
}
|
||||
return content;
|
||||
}
|
||||
};
|
||||
|
@ -26,6 +26,11 @@ M.atto_media = M.atto_media || {
|
||||
dialogue : null,
|
||||
selection : null,
|
||||
init : function(params) {
|
||||
|
||||
if (!M.editor_atto.can_show_filepicker(params.elementid, 'media')) {
|
||||
// Do not show this button if we can't browse repositories.
|
||||
return;
|
||||
}
|
||||
var display_chooser = function(e, elementid) {
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-atto_media-button",function(e,t){M.atto_media=M.atto_media||{dialogue:null,selection:null,init:function(e){var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_media.selection=M.editor_atto.get_selection();if(M.atto_media.selection!==!1){var n;M.atto_media.dialogue?n=M.atto_media.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_media.get_form_content(t)),n.set("headerContent",M.util.get_string("createmedia","atto_media")),n.centerDialogue(),n.show(),M.atto_media.dialogue=n}},n=M.util.image_url("e/insert_edit_video","core");M.editor_atto.add_toolbar_button(e.elementid,"media",n,e.group,t,this)},open_browser:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"media",M.atto_media.filepicker_callback)},filepicker_callback:function(t){if(t.url!==""){var n=e.one("#atto_media_urlentry");n.set("value",t.url),n=e.one("#atto_media_nameentry"),n.set("value",t.file)}},set_media:function(t,n){t.preventDefault(),M.atto_media.dialogue.hide();var r=t.currentTarget.ancestor(".atto_form").one("#atto_media_urlentry"),i=r.get("value");r=t.currentTarget.ancestor(".atto_form").one("#atto_media_nameentry");var s=r.get("value");if(i!==""&&s!==""){M.editor_atto.set_selection(M.atto_media.selection);var o='<a href="'+e.Escape.html(i)+'">'+s+"</a>";document.selection&&document.selection.createRange().pasteHTML?document.selection.createRange().pasteHTML(o):document.execCommand("insertHTML",!1,o),M.editor_atto.text_updated(n)}},get_form_content:function(t){var n=e.Node.create('<form class="atto_form"><label for="atto_media_urlentry">'+M.util.get_string("enterurl","atto_media")+"</label>"+'<input class="fullwidth" type="url" value="" id="atto_media_urlentry" size="32"/><br/>'+'<button id="openmediabrowser" data-editor="'+e.Escape.html(t)+'">'+M.util.get_string("browserepositories","atto_media")+"</button>"+'<label for="atto_media_nameentry">'+M.util.get_string("entername","atto_media")+"</label>"+'<input class="fullwidth" type="text" value="" id="atto_media_nameentry" size="32" required="true"/>'+'<div class="mdl-align">'+"<br/>"+'<button id="atto_media_urlentrysubmit">'+M.util.get_string("createmedia","atto_media")+"</button>"+"</div>"+"</form>"+"<hr/>"+M.util.get_string("accessibilityhint","atto_media"));return n.one("#atto_media_urlentrysubmit").on("click",M.atto_media.set_media,this,t),n.one("#openmediabrowser").on("click",M.atto_media.open_browser),n}}},"@VERSION@",{requires:["node","escape"]});
|
||||
YUI.add("moodle-atto_media-button",function(e,t){M.atto_media=M.atto_media||{dialogue:null,selection:null,init:function(e){if(!M.editor_atto.can_show_filepicker(e.elementid,"media"))return;var t=function(e,t){e.preventDefault(),M.editor_atto.is_active(t)||M.editor_atto.focus(t),M.atto_media.selection=M.editor_atto.get_selection();if(M.atto_media.selection!==!1){var n;M.atto_media.dialogue?n=M.atto_media.dialogue:n=new M.core.dialogue({visible:!1,modal:!0,close:!0,draggable:!0}),n.render(),n.set("bodyContent",M.atto_media.get_form_content(t)),n.set("headerContent",M.util.get_string("createmedia","atto_media")),n.centerDialogue(),n.show(),M.atto_media.dialogue=n}},n=M.util.image_url("e/insert_edit_video","core");M.editor_atto.add_toolbar_button(e.elementid,"media",n,e.group,t,this)},open_browser:function(e){var t=this.getAttribute("data-editor");e.preventDefault(),M.editor_atto.show_filepicker(t,"media",M.atto_media.filepicker_callback)},filepicker_callback:function(t){if(t.url!==""){var n=e.one("#atto_media_urlentry");n.set("value",t.url),n=e.one("#atto_media_nameentry"),n.set("value",t.file)}},set_media:function(t,n){t.preventDefault(),M.atto_media.dialogue.hide();var r=t.currentTarget.ancestor(".atto_form").one("#atto_media_urlentry"),i=r.get("value");r=t.currentTarget.ancestor(".atto_form").one("#atto_media_nameentry");var s=r.get("value");if(i!==""&&s!==""){M.editor_atto.set_selection(M.atto_media.selection);var o='<a href="'+e.Escape.html(i)+'">'+s+"</a>";document.selection&&document.selection.createRange().pasteHTML?document.selection.createRange().pasteHTML(o):document.execCommand("insertHTML",!1,o),M.editor_atto.text_updated(n)}},get_form_content:function(t){var n=e.Node.create('<form class="atto_form"><label for="atto_media_urlentry">'+M.util.get_string("enterurl","atto_media")+"</label>"+'<input class="fullwidth" type="url" value="" id="atto_media_urlentry" size="32"/><br/>'+'<button id="openmediabrowser" data-editor="'+e.Escape.html(t)+'">'+M.util.get_string("browserepositories","atto_media")+"</button>"+'<label for="atto_media_nameentry">'+M.util.get_string("entername","atto_media")+"</label>"+'<input class="fullwidth" type="text" value="" id="atto_media_nameentry" size="32" required="true"/>'+'<div class="mdl-align">'+"<br/>"+'<button id="atto_media_urlentrysubmit">'+M.util.get_string("createmedia","atto_media")+"</button>"+"</div>"+"</form>"+"<hr/>"+M.util.get_string("accessibilityhint","atto_media"));return n.one("#atto_media_urlentrysubmit").on("click",M.atto_media.set_media,this,t),n.one("#openmediabrowser").on("click",M.atto_media.open_browser),n}}},"@VERSION@",{requires:["node","escape"]});
|
||||
|
@ -26,6 +26,11 @@ M.atto_media = M.atto_media || {
|
||||
dialogue : null,
|
||||
selection : null,
|
||||
init : function(params) {
|
||||
|
||||
if (!M.editor_atto.can_show_filepicker(params.elementid, 'media')) {
|
||||
// Do not show this button if we can't browse repositories.
|
||||
return;
|
||||
}
|
||||
var display_chooser = function(e, elementid) {
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
|
@ -24,6 +24,11 @@ M.atto_media = M.atto_media || {
|
||||
dialogue : null,
|
||||
selection : null,
|
||||
init : function(params) {
|
||||
|
||||
if (!M.editor_atto.can_show_filepicker(params.elementid, 'media')) {
|
||||
// Do not show this button if we can't browse repositories.
|
||||
return;
|
||||
}
|
||||
var display_chooser = function(e, elementid) {
|
||||
e.preventDefault();
|
||||
if (!M.editor_atto.is_active(elementid)) {
|
||||
|
@ -355,7 +355,6 @@ M.editor_atto = M.editor_atto || {
|
||||
* @param object params for this editor instance.
|
||||
*/
|
||||
init : function(params) {
|
||||
var textarea = Y.one('#' +params.elementid);
|
||||
var wrapper = Y.Node.create('<div class="' + CSS.WRAPPER + '" />');
|
||||
var atto = Y.Node.create('<div id="' + params.elementid + 'editable" ' +
|
||||
'contenteditable="true" ' +
|
||||
@ -367,6 +366,9 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Editable content wrapper.
|
||||
var content = Y.Node.create('<div class="' + CSS.CONTENTWRAPPER + '" />');
|
||||
var elementid = params.elementid.replace(':', '\\:');
|
||||
var textarea = Y.one('#' +elementid);
|
||||
|
||||
content.appendChild(atto);
|
||||
|
||||
// Add everything to the wrapper.
|
||||
@ -395,19 +397,19 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Copy the current value back to the textarea when focus leaves us.
|
||||
atto.on('blur', function() {
|
||||
this.text_updated(params.elementid);
|
||||
this.text_updated(elementid);
|
||||
}, this);
|
||||
|
||||
// Listen for Arrow left and Arrow right keys.
|
||||
Y.one(Y.config.doc.body).delegate('key',
|
||||
this.keyboard_navigation,
|
||||
'down:37,39',
|
||||
'#' + params.elementid + '_toolbar',
|
||||
'#' + elementid + '_toolbar',
|
||||
this,
|
||||
params.elementid);
|
||||
elementid);
|
||||
|
||||
// Save the file picker options for later.
|
||||
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
|
||||
M.editor_atto.filepickeroptions[elementid] = params.filepickeroptions;
|
||||
|
||||
// Init each of the plugins
|
||||
var i, j;
|
||||
@ -415,7 +417,7 @@ M.editor_atto = M.editor_atto || {
|
||||
var group = params.plugins[i].group;
|
||||
for (j = 0; j < params.plugins[i].plugins.length; j++) {
|
||||
var plugin = params.plugins[i].plugins[j];
|
||||
plugin.params.elementid = params.elementid;
|
||||
plugin.params.elementid = elementid;
|
||||
plugin.params.group = group;
|
||||
|
||||
M['atto_' + plugin.name].init(plugin.params);
|
||||
@ -507,6 +509,18 @@ M.editor_atto = M.editor_atto || {
|
||||
Y.one('#' + elementid + '_toolbar').setAttribute('aria-activedescendant', current.generateID());
|
||||
},
|
||||
|
||||
/**
|
||||
* Should we show the filepicker for this filetype?
|
||||
*
|
||||
* @param string elementid for this editor instance.
|
||||
* @param string type The media type for the file picker
|
||||
* @return boolean
|
||||
*/
|
||||
can_show_filepicker : function(elementid, type) {
|
||||
var options = M.editor_atto.filepickeroptions[elementid];
|
||||
return ((typeof options[type]) !== "undefined");
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the filepicker.
|
||||
* @param string elementid for this editor instance.
|
||||
|
File diff suppressed because one or more lines are too long
@ -355,7 +355,6 @@ M.editor_atto = M.editor_atto || {
|
||||
* @param object params for this editor instance.
|
||||
*/
|
||||
init : function(params) {
|
||||
var textarea = Y.one('#' +params.elementid);
|
||||
var wrapper = Y.Node.create('<div class="' + CSS.WRAPPER + '" />');
|
||||
var atto = Y.Node.create('<div id="' + params.elementid + 'editable" ' +
|
||||
'contenteditable="true" ' +
|
||||
@ -367,6 +366,9 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Editable content wrapper.
|
||||
var content = Y.Node.create('<div class="' + CSS.CONTENTWRAPPER + '" />');
|
||||
var elementid = params.elementid.replace(':', '\\:');
|
||||
var textarea = Y.one('#' +elementid);
|
||||
|
||||
content.appendChild(atto);
|
||||
|
||||
// Add everything to the wrapper.
|
||||
@ -395,19 +397,19 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Copy the current value back to the textarea when focus leaves us.
|
||||
atto.on('blur', function() {
|
||||
this.text_updated(params.elementid);
|
||||
this.text_updated(elementid);
|
||||
}, this);
|
||||
|
||||
// Listen for Arrow left and Arrow right keys.
|
||||
Y.one(Y.config.doc.body).delegate('key',
|
||||
this.keyboard_navigation,
|
||||
'down:37,39',
|
||||
'#' + params.elementid + '_toolbar',
|
||||
'#' + elementid + '_toolbar',
|
||||
this,
|
||||
params.elementid);
|
||||
elementid);
|
||||
|
||||
// Save the file picker options for later.
|
||||
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
|
||||
M.editor_atto.filepickeroptions[elementid] = params.filepickeroptions;
|
||||
|
||||
// Init each of the plugins
|
||||
var i, j;
|
||||
@ -415,7 +417,7 @@ M.editor_atto = M.editor_atto || {
|
||||
var group = params.plugins[i].group;
|
||||
for (j = 0; j < params.plugins[i].plugins.length; j++) {
|
||||
var plugin = params.plugins[i].plugins[j];
|
||||
plugin.params.elementid = params.elementid;
|
||||
plugin.params.elementid = elementid;
|
||||
plugin.params.group = group;
|
||||
|
||||
M['atto_' + plugin.name].init(plugin.params);
|
||||
@ -507,6 +509,18 @@ M.editor_atto = M.editor_atto || {
|
||||
Y.one('#' + elementid + '_toolbar').setAttribute('aria-activedescendant', current.generateID());
|
||||
},
|
||||
|
||||
/**
|
||||
* Should we show the filepicker for this filetype?
|
||||
*
|
||||
* @param string elementid for this editor instance.
|
||||
* @param string type The media type for the file picker
|
||||
* @return boolean
|
||||
*/
|
||||
can_show_filepicker : function(elementid, type) {
|
||||
var options = M.editor_atto.filepickeroptions[elementid];
|
||||
return ((typeof options[type]) !== "undefined");
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the filepicker.
|
||||
* @param string elementid for this editor instance.
|
||||
|
26
lib/editor/atto/yui/src/editor/js/editor.js
vendored
26
lib/editor/atto/yui/src/editor/js/editor.js
vendored
@ -353,7 +353,6 @@ M.editor_atto = M.editor_atto || {
|
||||
* @param object params for this editor instance.
|
||||
*/
|
||||
init : function(params) {
|
||||
var textarea = Y.one('#' +params.elementid);
|
||||
var wrapper = Y.Node.create('<div class="' + CSS.WRAPPER + '" />');
|
||||
var atto = Y.Node.create('<div id="' + params.elementid + 'editable" ' +
|
||||
'contenteditable="true" ' +
|
||||
@ -365,6 +364,9 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Editable content wrapper.
|
||||
var content = Y.Node.create('<div class="' + CSS.CONTENTWRAPPER + '" />');
|
||||
var elementid = params.elementid.replace(':', '\\:');
|
||||
var textarea = Y.one('#' +elementid);
|
||||
|
||||
content.appendChild(atto);
|
||||
|
||||
// Add everything to the wrapper.
|
||||
@ -393,19 +395,19 @@ M.editor_atto = M.editor_atto || {
|
||||
|
||||
// Copy the current value back to the textarea when focus leaves us.
|
||||
atto.on('blur', function() {
|
||||
this.text_updated(params.elementid);
|
||||
this.text_updated(elementid);
|
||||
}, this);
|
||||
|
||||
// Listen for Arrow left and Arrow right keys.
|
||||
Y.one(Y.config.doc.body).delegate('key',
|
||||
this.keyboard_navigation,
|
||||
'down:37,39',
|
||||
'#' + params.elementid + '_toolbar',
|
||||
'#' + elementid + '_toolbar',
|
||||
this,
|
||||
params.elementid);
|
||||
elementid);
|
||||
|
||||
// Save the file picker options for later.
|
||||
M.editor_atto.filepickeroptions[params.elementid] = params.filepickeroptions;
|
||||
M.editor_atto.filepickeroptions[elementid] = params.filepickeroptions;
|
||||
|
||||
// Init each of the plugins
|
||||
var i, j;
|
||||
@ -413,7 +415,7 @@ M.editor_atto = M.editor_atto || {
|
||||
var group = params.plugins[i].group;
|
||||
for (j = 0; j < params.plugins[i].plugins.length; j++) {
|
||||
var plugin = params.plugins[i].plugins[j];
|
||||
plugin.params.elementid = params.elementid;
|
||||
plugin.params.elementid = elementid;
|
||||
plugin.params.group = group;
|
||||
|
||||
M['atto_' + plugin.name].init(plugin.params);
|
||||
@ -505,6 +507,18 @@ M.editor_atto = M.editor_atto || {
|
||||
Y.one('#' + elementid + '_toolbar').setAttribute('aria-activedescendant', current.generateID());
|
||||
},
|
||||
|
||||
/**
|
||||
* Should we show the filepicker for this filetype?
|
||||
*
|
||||
* @param string elementid for this editor instance.
|
||||
* @param string type The media type for the file picker
|
||||
* @return boolean
|
||||
*/
|
||||
can_show_filepicker : function(elementid, type) {
|
||||
var options = M.editor_atto.filepickeroptions[elementid];
|
||||
return ((typeof options[type]) !== "undefined");
|
||||
},
|
||||
|
||||
/**
|
||||
* Show the filepicker.
|
||||
* @param string elementid for this editor instance.
|
||||
|
Loading…
x
Reference in New Issue
Block a user