Merge branch 'MDL-44804-master' of git://github.com/FMCorz/moodle

This commit is contained in:
Marina Glancy 2014-03-31 11:03:31 +08:00
commit c531e2e632
8 changed files with 45 additions and 27 deletions

View File

@ -229,11 +229,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
*/
_getDialogueContent: function() {
var template = Y.Handlebars.compile(TEMPLATE),
canShowFilepicker = this.get('host').canShowFilepicker('image'),
content = Y.Node.create(template({
elementid: this.get('host').get('elementid'),
CSS: CSS,
component: COMPONENTNAME,
showFilepicker: this.get('host').canShowFilepicker('image'),
showFilepicker: canShowFilepicker,
alignments: ALIGNMENTS
}));
@ -244,9 +245,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this._form.one('.' + CSS.INPUTURL).on('blur', this._urlChanged, this);
this._form.one('.' + CSS.INPUTSUBMIT).on('click', this._setImage, this);
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
if (canShowFilepicker) {
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
}
return content;
},

File diff suppressed because one or more lines are too long

View File

@ -229,11 +229,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
*/
_getDialogueContent: function() {
var template = Y.Handlebars.compile(TEMPLATE),
canShowFilepicker = this.get('host').canShowFilepicker('image'),
content = Y.Node.create(template({
elementid: this.get('host').get('elementid'),
CSS: CSS,
component: COMPONENTNAME,
showFilepicker: this.get('host').canShowFilepicker('image'),
showFilepicker: canShowFilepicker,
alignments: ALIGNMENTS
}));
@ -244,9 +245,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this._form.one('.' + CSS.INPUTURL).on('blur', this._urlChanged, this);
this._form.one('.' + CSS.INPUTSUBMIT).on('click', this._setImage, this);
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
if (canShowFilepicker) {
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
}
return content;
},

View File

@ -227,11 +227,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
*/
_getDialogueContent: function() {
var template = Y.Handlebars.compile(TEMPLATE),
canShowFilepicker = this.get('host').canShowFilepicker('image'),
content = Y.Node.create(template({
elementid: this.get('host').get('elementid'),
CSS: CSS,
component: COMPONENTNAME,
showFilepicker: this.get('host').canShowFilepicker('image'),
showFilepicker: canShowFilepicker,
alignments: ALIGNMENTS
}));
@ -242,9 +243,12 @@ Y.namespace('M.atto_image').Button = Y.Base.create('button', Y.M.editor_atto.Edi
this._form.one('.' + CSS.INPUTURL).on('blur', this._urlChanged, this);
this._form.one('.' + CSS.INPUTSUBMIT).on('click', this._setImage, this);
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
if (canShowFilepicker) {
this._form.one('.' + CSS.IMAGEBROWSER).on('click', function() {
this.get('host').showFilepicker('image', this._filepickerCallback, this);
}, this);
}
return content;
},

View File

@ -69,10 +69,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
_content: null,
initializer: function() {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
if (this.get('host').canShowFilepicker('media')) {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
}
},
/**

View File

@ -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.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='<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"]});

View File

@ -69,10 +69,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
_content: null,
initializer: function() {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
if (this.get('host').canShowFilepicker('media')) {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
}
},
/**

View File

@ -67,10 +67,12 @@ Y.namespace('M.atto_media').Button = Y.Base.create('button', Y.M.editor_atto.Edi
_content: null,
initializer: function() {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
if (this.get('host').canShowFilepicker('media')) {
this.addButton({
icon: 'e/insert_edit_video',
callback: this._displayDialogue
});
}
},
/**