mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-44972 Atto: Focus on the first input field in forms in dialogues.
This commit is contained in:
parent
3917871e90
commit
e5ddec38cd
@ -209,7 +209,8 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||
focusAfterHide: true,
|
||||
width: 600
|
||||
width: 600,
|
||||
focusSelector: SELECTORS.EQUATION_TEXT
|
||||
});
|
||||
|
||||
var content = this._getDialogueContent();
|
||||
|
File diff suppressed because one or more lines are too long
@ -209,7 +209,8 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||
focusAfterHide: true,
|
||||
width: 600
|
||||
width: 600,
|
||||
focusSelector: SELECTORS.EQUATION_TEXT
|
||||
});
|
||||
|
||||
var content = this._getDialogueContent();
|
||||
|
@ -207,7 +207,8 @@ Y.namespace('M.atto_equation').Button = Y.Base.create('button', Y.M.editor_atto.
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('pluginname', COMPONENTNAME),
|
||||
focusAfterHide: true,
|
||||
width: 600
|
||||
width: 600,
|
||||
focusSelector: SELECTORS.EQUATION_TEXT
|
||||
});
|
||||
|
||||
var content = this._getDialogueContent();
|
||||
|
@ -50,6 +50,9 @@ var CSS = {
|
||||
IMAGEPREVIEW: 'atto_image_preview',
|
||||
IMAGEPREVIEWBOX: 'atto_image_preview_box'
|
||||
},
|
||||
SELECTORS = {
|
||||
INPUTURL: '.' + CSS.INPUTURL
|
||||
},
|
||||
ALIGNMENTS = [
|
||||
// Vertical alignment.
|
||||
{
|
||||
@ -253,7 +256,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('imageproperties', COMPONENTNAME),
|
||||
width: '480px',
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.INPUTURL
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
File diff suppressed because one or more lines are too long
@ -50,6 +50,9 @@ var CSS = {
|
||||
IMAGEPREVIEW: 'atto_image_preview',
|
||||
IMAGEPREVIEWBOX: 'atto_image_preview_box'
|
||||
},
|
||||
SELECTORS = {
|
||||
INPUTURL: '.' + CSS.INPUTURL
|
||||
},
|
||||
ALIGNMENTS = [
|
||||
// Vertical alignment.
|
||||
{
|
||||
@ -253,7 +256,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('imageproperties', COMPONENTNAME),
|
||||
width: '480px',
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.INPUTURL
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -48,6 +48,9 @@ var CSS = {
|
||||
IMAGEPREVIEW: 'atto_image_preview',
|
||||
IMAGEPREVIEWBOX: 'atto_image_preview_box'
|
||||
},
|
||||
SELECTORS = {
|
||||
INPUTURL: '.' + CSS.INPUTURL
|
||||
},
|
||||
ALIGNMENTS = [
|
||||
// Vertical alignment.
|
||||
{
|
||||
@ -251,7 +254,8 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('imageproperties', COMPONENTNAME),
|
||||
width: '480px',
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.INPUTURL
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -35,12 +35,16 @@ YUI.add('moodle-atto_link-button', function (Y, NAME) {
|
||||
|
||||
var COMPONENTNAME = 'atto_link',
|
||||
CSS = {
|
||||
NEWWINDOW: 'atto_link_openinnewwindow'
|
||||
NEWWINDOW: 'atto_link_openinnewwindow',
|
||||
URLINPUT: 'atto_link_urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.atto_link_urlentry'
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_link_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth url" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth url {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
|
||||
// Add the repository browser button.
|
||||
'{{#if showFilepicker}}' +
|
||||
@ -111,7 +115,8 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createlink', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-atto_link-button",function(e,t){var n="atto_link",r={NEWWINDOW:"atto_link_openinnewwindow"},i='<form class="atto_form"><label for="{{elementid}}_atto_link_urlentry">{{get_string "enterurl" component}}</label><input class="fullwidth url" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>{{#if showFilepicker}}<button class="openlinkbrowser">{{get_string "browserepositories" component}}</button><br/>{{/if}}<input type="checkbox" class="newwindow" id="{{elementid}}_{{CSS.NEWWINDOW}}"/><label class="sameline" for="{{elementid}}_{{CSS.NEWWINDOW}}">{{get_string "openinnewwindow" component}}</label><br/><div class="mdl-align"><br/><button type="submit" class="submit">{{get_string "createlink" component}}</button></div></form>';e.namespace("M.atto_link").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.addButton({icon:"e/insert_edit_link",callback:this._displayDialogue,tags:"a"}),this.addButton({buttonName:"unlink",callback:this._unlink,icon:"e/remove_link",title:"unlink",tags:"a"})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1||this._currentSelection.collapsed)return;var e=this.getDialogue({headerContent:M.util.get_string("createlink",n),focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()),this._resolveAnchors(),e.show()},_resolveAnchors:function(){var t=this.get("host").getSelectionParentNode(),n,r,i,s;if(!t)return;n=this._findSelectedAnchors(e.one(t)),n.length>0&&(r=n[0],this._currentSelection=this.get("host").getSelectionFromNode(r),i=r.getAttribute("href"),s=r.getAttribute("target"),i!==""&&this._content.one(".url").setAttribute("value",i),s==="_blank"?this._content.one(".newwindow").setAttribute("checked","checked"):this._content.one(".newwindow").removeAttribute("checked"))},_filepickerCallback:function(e){this.getDialogue().set("focusAfterHide",null).hide(),e.url!==""&&(this.get("host").setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},_setLink:function(t){var n,r,i,s,o,u=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=this._content.one(".url"),o=n.get("value");if(o!==""){this.editor.focus(),u.setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,o),i=u.getSelectionParentNode();if(!i)return;s=this._findSelectedAnchors(e.one(i)),e.Array.each(s,function(e){r=this._content.one(".newwindow"),r.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")},this),this.markUpdated()}},_findSelectedAnchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&this.get("host").selectionContainsNode(e)&&r.push(e)},this),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},_getDialogueContent:function(){var t=this.get("host").canShowFilepicker("link"),s=e.Handlebars.compile(i);return this._content=e.Node.create(s({showFilepicker:t,component:n,CSS:r})),this._content.one(".submit").on("click",this._setLink,this),t&&this._content.one(".openlinkbrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("link",this._filepickerCallback,this)},this),this._content},_unlink:function(){var e=this.get("host"),t=e.getSelection();if(t&&t.length)if(t[0].startOffset===t[0].endOffset){var n=e.getSelectedNodes();n&&(n.each(function(t){var n=t.ancestor("a",!0);n&&(e.setSelection(e.getSelectionFromNode(n)),document.execCommand("unlink",!1,null))},this),this.markUpdated())}else document.execCommand("unlink",!1,null),this.markUpdated()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
|
||||
YUI.add("moodle-atto_link-button",function(e,t){var n="atto_link",r={NEWWINDOW:"atto_link_openinnewwindow",URLINPUT:"atto_link_urlentry"},i={URLINPUT:".atto_link_urlentry"},s='<form class="atto_form"><label for="{{elementid}}_atto_link_urlentry">{{get_string "enterurl" component}}</label><input class="fullwidth url {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>{{#if showFilepicker}}<button class="openlinkbrowser">{{get_string "browserepositories" component}}</button><br/>{{/if}}<input type="checkbox" class="newwindow" id="{{elementid}}_{{CSS.NEWWINDOW}}"/><label class="sameline" for="{{elementid}}_{{CSS.NEWWINDOW}}">{{get_string "openinnewwindow" component}}</label><br/><div class="mdl-align"><br/><button type="submit" class="submit">{{get_string "createlink" component}}</button></div></form>';e.namespace("M.atto_link").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.addButton({icon:"e/insert_edit_link",callback:this._displayDialogue,tags:"a"}),this.addButton({buttonName:"unlink",callback:this._unlink,icon:"e/remove_link",title:"unlink",tags:"a"})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1||this._currentSelection.collapsed)return;var e=this.getDialogue({headerContent:M.util.get_string("createlink",n),focusAfterHide:!0,focusSelector:i.URLINPUT});e.set("bodyContent",this._getDialogueContent()),this._resolveAnchors(),e.show()},_resolveAnchors:function(){var t=this.get("host").getSelectionParentNode(),n,r,i,s;if(!t)return;n=this._findSelectedAnchors(e.one(t)),n.length>0&&(r=n[0],this._currentSelection=this.get("host").getSelectionFromNode(r),i=r.getAttribute("href"),s=r.getAttribute("target"),i!==""&&this._content.one(".url").setAttribute("value",i),s==="_blank"?this._content.one(".newwindow").setAttribute("checked","checked"):this._content.one(".newwindow").removeAttribute("checked"))},_filepickerCallback:function(e){this.getDialogue().set("focusAfterHide",null).hide(),e.url!==""&&(this.get("host").setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,e.url))},_setLink:function(t){var n,r,i,s,o,u=this.get("host");t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide(),n=this._content.one(".url"),o=n.get("value");if(o!==""){this.editor.focus(),u.setSelection(this._currentSelection),document.execCommand("unlink",!1,null),document.execCommand("createLink",!1,o),i=u.getSelectionParentNode();if(!i)return;s=this._findSelectedAnchors(e.one(i)),e.Array.each(s,function(e){r=this._content.one(".newwindow"),r.get("checked")?e.setAttribute("target","_blank"):e.removeAttribute("target")},this),this.markUpdated()}},_findSelectedAnchors:function(e){var t=e.get("tagName"),n,r;return t&&t.toLowerCase()==="a"?[e]:(r=[],e.all("a").each(function(e){!n&&this.get("host").selectionContainsNode(e)&&r.push(e)},this),r.length>0?r:(n=e.ancestor("a"),n?[n]:[]))},_getDialogueContent:function(){var t=this.get("host").canShowFilepicker("link"),i=e.Handlebars.compile(s);return this._content=e.Node.create(i({showFilepicker:t,component:n,CSS:r})),this._content.one(".submit").on("click",this._setLink,this),t&&this._content.one(".openlinkbrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("link",this._filepickerCallback,this)},this),this._content},_unlink:function(){var e=this.get("host"),t=e.getSelection();if(t&&t.length)if(t[0].startOffset===t[0].endOffset){var n=e.getSelectedNodes();n&&(n.each(function(t){var n=t.ancestor("a",!0);n&&(e.setSelection(e.getSelectionFromNode(n)),document.execCommand("unlink",!1,null))},this),this.markUpdated())}else document.execCommand("unlink",!1,null),this.markUpdated()}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
|
||||
|
@ -35,12 +35,16 @@ YUI.add('moodle-atto_link-button', function (Y, NAME) {
|
||||
|
||||
var COMPONENTNAME = 'atto_link',
|
||||
CSS = {
|
||||
NEWWINDOW: 'atto_link_openinnewwindow'
|
||||
NEWWINDOW: 'atto_link_openinnewwindow',
|
||||
URLINPUT: 'atto_link_urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.atto_link_urlentry'
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_link_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth url" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth url {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
|
||||
// Add the repository browser button.
|
||||
'{{#if showFilepicker}}' +
|
||||
@ -111,7 +115,8 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createlink', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -33,12 +33,16 @@
|
||||
|
||||
var COMPONENTNAME = 'atto_link',
|
||||
CSS = {
|
||||
NEWWINDOW: 'atto_link_openinnewwindow'
|
||||
NEWWINDOW: 'atto_link_openinnewwindow',
|
||||
URLINPUT: 'atto_link_urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.atto_link_urlentry'
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_link_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth url" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth url {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_link_urlentry" size="32"/><br/>' +
|
||||
|
||||
// Add the repository browser button.
|
||||
'{{#if showFilepicker}}' +
|
||||
@ -109,7 +113,8 @@ Y.namespace('M.atto_link').Button = Y.Base.create('button', Y.M.editor_atto.Edit
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createlink', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -34,10 +34,16 @@ YUI.add('moodle-atto_media-button', function (Y, NAME) {
|
||||
*/
|
||||
|
||||
var COMPONENTNAME = 'atto_media',
|
||||
CSS = {
|
||||
URLINPUT: 'urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.' + CSS.URLINPUT
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth urlentry" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button>' +
|
||||
'<label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component}}</label>' +
|
||||
'<input class="fullwidth nameentry" type="text" id="{{elementid}}_atto_media_nameentry" size="32" required="true"/>' +
|
||||
@ -92,7 +98,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createmedia', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -113,7 +120,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
component: COMPONENTNAME,
|
||||
elementid: this.get('host').get('elementid')
|
||||
elementid: this.get('host').get('elementid'),
|
||||
CSS: CSS
|
||||
}));
|
||||
|
||||
this._content.one('.submit').on('click', this._setMedia, this);
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-atto_media-button",function(e,t){var n="atto_media",r='<form class="atto_form"><label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label><input class="fullwidth urlentry" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/><button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button><label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component}}</label><input class="fullwidth nameentry" type="text" id="{{elementid}}_atto_media_nameentry" size="32" required="true"/><div class="mdl-align"><br/><button class="submit" type="submit">{{get_string "createmedia" component}}</button></div></form>';e.namespace("M.atto_media").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.get("host").canShowFilepicker("media")&&this.addButton({icon:"e/insert_edit_video",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("createmedia",n),focusAfterHide:!0});e.set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=e.Handlebars.compile(r);return this._content=e.Node.create(t({component:n,elementid:this.get("host").get("elementid")})),this._content.one(".submit").on("click",this._setMedia,this),this._content.one(".openmediabrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("media",this._filepickerCallback,this)},this),this._content},_filepickerCallback:function(e){e.url!==""&&(this._content.one(".urlentry").set("value",e.url),this._content.one(".nameentry").set("value",e.file))},_setMedia:function(t){t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide();var n=t.currentTarget.ancestor(".atto_form"),r=n.one(".urlentry").get("value"),i=n.one(".nameentry").get("value"),s=this.get("host");if(r!==""&&i!==""){s.setSelection(this._currentSelection);var o='<a href="'+e.Escape.html(r)+'">'+i+"</a>";s.insertContentAtFocusPoint(o),this.markUpdated()}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
|
||||
YUI.add("moodle-atto_media-button",function(e,t){var n="atto_media",r={URLINPUT:"urlentry"},i={URLINPUT:"."+r.URLINPUT},s='<form class="atto_form"><label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label><input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/><button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button><label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component}}</label><input class="fullwidth nameentry" type="text" id="{{elementid}}_atto_media_nameentry" size="32" required="true"/><div class="mdl-align"><br/><button class="submit" type="submit">{{get_string "createmedia" component}}</button></div></form>';e.namespace("M.atto_media").Button=e.Base.create("button",e.M.editor_atto.EditorPlugin,[],{_currentSelection:null,_content:null,initializer:function(){this.get("host").canShowFilepicker("media")&&this.addButton({icon:"e/insert_edit_video",callback:this._displayDialogue})},_displayDialogue:function(){this._currentSelection=this.get("host").getSelection();if(this._currentSelection===!1)return;var e=this.getDialogue({headerContent:M.util.get_string("createmedia",n),focusAfterHide:!0,focusSelector:i.URLINPUT});e.set("bodyContent",this._getDialogueContent()).show()},_getDialogueContent:function(){var t=e.Handlebars.compile(s);return this._content=e.Node.create(t({component:n,elementid:this.get("host").get("elementid"),CSS:r})),this._content.one(".submit").on("click",this._setMedia,this),this._content.one(".openmediabrowser").on("click",function(e){e.preventDefault(),this.get("host").showFilepicker("media",this._filepickerCallback,this)},this),this._content},_filepickerCallback:function(e){e.url!==""&&(this._content.one(".urlentry").set("value",e.url),this._content.one(".nameentry").set("value",e.file))},_setMedia:function(t){t.preventDefault(),this.getDialogue({focusAfterHide:null}).hide();var n=t.currentTarget.ancestor(".atto_form"),r=n.one(".urlentry").get("value"),i=n.one(".nameentry").get("value"),s=this.get("host");if(r!==""&&i!==""){s.setSelection(this._currentSelection);var o='<a href="'+e.Escape.html(r)+'">'+i+"</a>";s.insertContentAtFocusPoint(o),this.markUpdated()}}})},"@VERSION@",{requires:["moodle-editor_atto-plugin"]});
|
||||
|
@ -34,10 +34,16 @@ YUI.add('moodle-atto_media-button', function (Y, NAME) {
|
||||
*/
|
||||
|
||||
var COMPONENTNAME = 'atto_media',
|
||||
CSS = {
|
||||
URLINPUT: 'urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.' + CSS.URLINPUT
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth urlentry" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button>' +
|
||||
'<label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component}}</label>' +
|
||||
'<input class="fullwidth nameentry" type="text" id="{{elementid}}_atto_media_nameentry" size="32" required="true"/>' +
|
||||
@ -92,7 +98,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createmedia', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -113,7 +120,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
component: COMPONENTNAME,
|
||||
elementid: this.get('host').get('elementid')
|
||||
elementid: this.get('host').get('elementid'),
|
||||
CSS: CSS
|
||||
}));
|
||||
|
||||
this._content.one('.submit').on('click', this._setMedia, this);
|
||||
|
@ -32,10 +32,16 @@
|
||||
*/
|
||||
|
||||
var COMPONENTNAME = 'atto_media',
|
||||
CSS = {
|
||||
URLINPUT: 'urlentry'
|
||||
},
|
||||
SELECTORS = {
|
||||
URLINPUT: '.' + CSS.URLINPUT
|
||||
},
|
||||
TEMPLATE = '' +
|
||||
'<form class="atto_form">' +
|
||||
'<label for="{{elementid}}_atto_media_urlentry">{{get_string "enterurl" component}}</label>' +
|
||||
'<input class="fullwidth urlentry" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<input class="fullwidth {{CSS.URLINPUT}}" type="url" id="{{elementid}}_atto_media_urlentry" size="32"/><br/>' +
|
||||
'<button class="openmediabrowser" type="button">{{get_string "browserepositories" component}}</button>' +
|
||||
'<label for="{{elementid}}_atto_media_nameentry">{{get_string "entername" component}}</label>' +
|
||||
'<input class="fullwidth nameentry" type="text" id="{{elementid}}_atto_media_nameentry" size="32" required="true"/>' +
|
||||
@ -90,7 +96,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createmedia', COMPONENTNAME),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.URLINPUT
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -111,7 +118,8 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
|
||||
this._content = Y.Node.create(template({
|
||||
component: COMPONENTNAME,
|
||||
elementid: this.get('host').get('elementid')
|
||||
elementid: this.get('host').get('elementid'),
|
||||
CSS: CSS
|
||||
}));
|
||||
|
||||
this._content.one('.submit').on('click', this._setMedia, this);
|
||||
|
@ -159,7 +159,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
if (this._currentSelection !== false && (!this._currentSelection.collapsed)) {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createtable', COMPONENT),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -879,7 +880,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
_editTable: function() {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('edittable', COMPONENT),
|
||||
focusAfterHide: false
|
||||
focusAfterHide: false,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
File diff suppressed because one or more lines are too long
@ -159,7 +159,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
if (this._currentSelection !== false && (!this._currentSelection.collapsed)) {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createtable', COMPONENT),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -879,7 +880,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
_editTable: function() {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('edittable', COMPONENT),
|
||||
focusAfterHide: false
|
||||
focusAfterHide: false,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -157,7 +157,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
if (this._currentSelection !== false && (!this._currentSelection.collapsed)) {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('createtable', COMPONENT),
|
||||
focusAfterHide: true
|
||||
focusAfterHide: true,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
@ -877,7 +878,8 @@ Y.namespace('M.atto_table').Button = Y.Base.create('button', Y.M.editor_atto.Edi
|
||||
_editTable: function() {
|
||||
var dialogue = this.getDialogue({
|
||||
headerContent: M.util.get_string('edittable', COMPONENT),
|
||||
focusAfterHide: false
|
||||
focusAfterHide: false,
|
||||
focusSelector: SELECTORS.CAPTION
|
||||
});
|
||||
|
||||
// Set the dialogue content, and then show the dialogue.
|
||||
|
@ -312,7 +312,9 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
show : function() {
|
||||
var result = null,
|
||||
header = this.headerNode,
|
||||
content = this.bodyNode;
|
||||
content = this.bodyNode,
|
||||
focusSelector = this.get('focusSelector'),
|
||||
focusNode = null;
|
||||
|
||||
result = DIALOGUE.superclass.show.call(this);
|
||||
|
||||
@ -323,11 +325,19 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
|
||||
}
|
||||
|
||||
if (header && header !== '') {
|
||||
header.focus();
|
||||
} else if (content && content !== '') {
|
||||
content.focus();
|
||||
// Try and find a node to focus on using the focusSelector attribute.
|
||||
if (focusSelector !== '') {
|
||||
focusNode = this.get('boundingBox').one(focusSelector);
|
||||
}
|
||||
if (!focusNode) {
|
||||
// Fall back to the header or the content if no focus node was found yet.
|
||||
if (header && header !== '') {
|
||||
focusNode = header;
|
||||
} else if (content && content !== '') {
|
||||
focusNode = content;
|
||||
}
|
||||
}
|
||||
focusNode.focus();
|
||||
return result;
|
||||
},
|
||||
|
||||
@ -534,6 +544,19 @@ Y.Base.modifyAttrs(DIALOGUE, {
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Selector to a node that should recieve focus when this dialogue is shown.
|
||||
*
|
||||
* The default behaviour is to focus on the header.
|
||||
*
|
||||
* @attribute focusSelector
|
||||
* @default ''
|
||||
* @type String
|
||||
*/
|
||||
focusSelector: {
|
||||
value: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* A convenience Attribute, which can be used as a shortcut for the
|
||||
* `align` Attribute.
|
||||
|
File diff suppressed because one or more lines are too long
@ -312,7 +312,9 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
show : function() {
|
||||
var result = null,
|
||||
header = this.headerNode,
|
||||
content = this.bodyNode;
|
||||
content = this.bodyNode,
|
||||
focusSelector = this.get('focusSelector'),
|
||||
focusNode = null;
|
||||
|
||||
result = DIALOGUE.superclass.show.call(this);
|
||||
|
||||
@ -323,11 +325,19 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
|
||||
}
|
||||
|
||||
if (header && header !== '') {
|
||||
header.focus();
|
||||
} else if (content && content !== '') {
|
||||
content.focus();
|
||||
// Try and find a node to focus on using the focusSelector attribute.
|
||||
if (focusSelector !== '') {
|
||||
focusNode = this.get('boundingBox').one(focusSelector);
|
||||
}
|
||||
if (!focusNode) {
|
||||
// Fall back to the header or the content if no focus node was found yet.
|
||||
if (header && header !== '') {
|
||||
focusNode = header;
|
||||
} else if (content && content !== '') {
|
||||
focusNode = content;
|
||||
}
|
||||
}
|
||||
focusNode.focus();
|
||||
return result;
|
||||
},
|
||||
|
||||
@ -532,6 +542,19 @@ Y.Base.modifyAttrs(DIALOGUE, {
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Selector to a node that should recieve focus when this dialogue is shown.
|
||||
*
|
||||
* The default behaviour is to focus on the header.
|
||||
*
|
||||
* @attribute focusSelector
|
||||
* @default ''
|
||||
* @type String
|
||||
*/
|
||||
focusSelector: {
|
||||
value: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* A convenience Attribute, which can be used as a shortcut for the
|
||||
* `align` Attribute.
|
||||
|
33
lib/yui/src/notification/js/dialogue.js
vendored
33
lib/yui/src/notification/js/dialogue.js
vendored
@ -283,7 +283,9 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
show : function() {
|
||||
var result = null,
|
||||
header = this.headerNode,
|
||||
content = this.bodyNode;
|
||||
content = this.bodyNode,
|
||||
focusSelector = this.get('focusSelector'),
|
||||
focusNode = null;
|
||||
|
||||
result = DIALOGUE.superclass.show.call(this);
|
||||
|
||||
@ -294,11 +296,19 @@ Y.extend(DIALOGUE, Y.Panel, {
|
||||
this.lockScroll.enableScrollLock(this.shouldResizeFullscreen());
|
||||
}
|
||||
|
||||
if (header && header !== '') {
|
||||
header.focus();
|
||||
} else if (content && content !== '') {
|
||||
content.focus();
|
||||
// Try and find a node to focus on using the focusSelector attribute.
|
||||
if (focusSelector !== '') {
|
||||
focusNode = this.get('boundingBox').one(focusSelector);
|
||||
}
|
||||
if (!focusNode) {
|
||||
// Fall back to the header or the content if no focus node was found yet.
|
||||
if (header && header !== '') {
|
||||
focusNode = header;
|
||||
} else if (content && content !== '') {
|
||||
focusNode = content;
|
||||
}
|
||||
}
|
||||
focusNode.focus();
|
||||
return result;
|
||||
},
|
||||
|
||||
@ -505,6 +515,19 @@ Y.Base.modifyAttrs(DIALOGUE, {
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Selector to a node that should recieve focus when this dialogue is shown.
|
||||
*
|
||||
* The default behaviour is to focus on the header.
|
||||
*
|
||||
* @attribute focusSelector
|
||||
* @default ''
|
||||
* @type String
|
||||
*/
|
||||
focusSelector: {
|
||||
value: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* A convenience Attribute, which can be used as a shortcut for the
|
||||
* `align` Attribute.
|
||||
|
Loading…
x
Reference in New Issue
Block a user