mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-44815 core: Add chooser type to boundingbox class
This commit is contained in:
parent
f500ff4e52
commit
b76ed36f85
@ -53,18 +53,19 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
// Set Default options
|
||||
var paramkey,
|
||||
params = {
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false
|
||||
};
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false,
|
||||
extraClasses: this._getClassNames()
|
||||
};
|
||||
|
||||
// Override with additional options
|
||||
for (paramkey in this.instanceconfig) {
|
||||
@ -316,6 +317,38 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
value: e.get('value'),
|
||||
name: e.get('name')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an array of class names prefixed with 'chooserdialogue-' and
|
||||
* the name of the type of dialogue.
|
||||
*
|
||||
* Note: Class name are converted to lower-case.
|
||||
*
|
||||
* If an array of arguments is supplied, each of these is prefixed and
|
||||
* lower-cased also.
|
||||
*
|
||||
* If no arguments are supplied, then the prefix is returned on it's
|
||||
* own.
|
||||
*
|
||||
* @method _getClassNames
|
||||
* @param {Array} [args] Any additional names to prefix and lower-case.
|
||||
* @return {Array}
|
||||
* @private
|
||||
*/
|
||||
_getClassNames: function(args) {
|
||||
var prefix = 'chooserdialogue-' + this.name,
|
||||
results = [];
|
||||
|
||||
results.push(prefix.toLowerCase());
|
||||
if (args) {
|
||||
var arg;
|
||||
for (arg in args) {
|
||||
results.push((prefix + '-' + arg).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1 +1 @@
|
||||
YUI.add("moodle-core-chooserdialogue",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};e.extend(n,e.Base,{panel:null,submitbutton:null,container:null,listenevents:[],bodycontent:null,headercontent:null,instanceconfig:null,hiddenRadioValue:null,setup_chooser_dialogue:function(e,t,n){this.bodycontent=e,this.headercontent=t,this.instanceconfig=n},prepare_chooser:function(){if(this.panel)return;e.one(e.config.doc.body).addClass("jschooser");var t,n={bodyContent:this.bodycontent.get("innerHTML"),headerContent:this.headercontent.get("innerHTML"),width:"540px",draggable:!0,visible:!1,zindex:100,modal:!0,shim:!0,closeButtonTitle:this.get("closeButtonTitle"),focusOnPreviousTargetAfterHide:!0,render:!1};for(t in this.instanceconfig)n[t]=this.instanceconfig[t];this.panel=new M.core.dialogue(n),this.bodycontent.remove(),this.headercontent.remove(),this.panel.hide(),this.panel.render(),this.container=this.panel.get("boundingBox").one(".choosercontainer"),this.options=this.container.all(".option input[type=radio]"),this.hiddenRadioValue=e.Node.create('<input type="hidden" value="" />'),this.container.one("form").appendChild(this.hiddenRadioValue),this.panel.get("boundingBox").addClass("chooserdialogue")},display_chooser:function(t){var n,r,i;this.prepare_chooser(),t.preventDefault(),n=this.panel.get("boundingBox"),r=this.container.one(".alloptions"),i=e.one("document").on("orientationchange",function(){this.center_dialogue(r)},this),this.listenevents.push(i),i=e.one("window").on("resize",function(){this.center_dialogue(r)},this),this.listenevents.push(i),i=this.container.on("click",this.check_options,this),this.listenevents.push(i),i=this.container.on("key_up",this.check_options,this),this.listenevents.push(i),i=this.container.on("dblclick",function(e){e.target.ancestor("div.option")&&(this.check_options(),this.submitbutton.setAttribute("disabled","disabled"),this.options.setAttribute("disabled","disabled"),this.cancel_listenevents(),this.container.one("form").submit())},this),this.listenevents.push(i),this.container.one("form").on("submit",function(){this.submitbutton.setAttribute("disabled","disabled"),this.options.setAttribute("disabled","disabled"),this.cancel_listenevents()},this),i=this.container.one(".addcancel").on("click",this.cancel_popup,this),this.listenevents.push(i),i=n.one("button.closebutton").on("click",this.cancel_popup,this),this.listenevents.push(i),i=e.one("document").on("keydown",this.handle_key_press,this),this.listenevents.push(i),this.submitbutton=this.container.one(".submitbutton"),this.submitbutton.set("disabled","true"),this.options.removeAttribute("disabled"),this.panel.show(t),this.center_dialogue(r),this.container.one(".option input[type=radio]").focus(),this.check_options()},cancel_listenevents:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()},center_dialogue:function(e){var t=this.panel.get("boundingBox"),n=t.get("winHeight"),r,i;if(this.panel.shouldResizeFullscreen())return;r=this.get("maxheight"),n<=r&&(n<=this.get("minheight")?r=this.get("minheight"):r=n),r>this.get("minheight")?this.panel.lockScroll&&!this.panel.lockScroll.isActive()&&this.panel.lockScroll.enableScrollLock(!0):this.panel.lockScroll&&this.panel.lockScroll.isActive()&&this.panel.lockScroll.disableScrollLock(),i=r,r-=110,e.setStyle("maxHeight",r+"px"),dialogueheight=t.getStyle("height"),dialogueheight.match(/.*px$/)?dialogueheight=dialogueheight.replace(/px$/,""):dialogueheight=i,dialogueheight<this.get("baseheight")&&(dialogueheight=this.get("baseheight"),e.setStyle("height",dialogueheight+"px")),this.panel.centerDialogue()},handle_key_press:function(e){e.keyCode===27&&this.cancel_popup(e)},cancel_popup:function(e){e.preventDefault(),this.hide()},hide:function(){this.cancel_listenevents(),this.container.detachAll(),this.panel.hide()},check_options:function(){this.options.each(function(e){var t=e.get("parentNode").get("parentNode");e.get("checked")?(t.addClass("selected"),this.option_selected(e),this.submitbutton.removeAttribute("disabled"),e.focus()):t.removeClass("selected")},this)},option_selected:function(e){this.hiddenRadioValue.setAttrs({value:e.get("value"),name:e.get("name")})}},{NAME:"moodle-core-chooserdialogue",ATTRS:{minheight:{value:300},baseheight:{value:400},maxheight:{value:660},closeButtonTitle:{validator:e.Lang.isString,value:"Close"}}}),M.core=M.core||{},M.core.chooserdialogue=n},"@VERSION@",{requires:["base","panel","moodle-core-notification"]});
|
||||
YUI.add("moodle-core-chooserdialogue",function(e,t){var n=function(){n.superclass.constructor.apply(this,arguments)};e.extend(n,e.Base,{panel:null,submitbutton:null,container:null,listenevents:[],bodycontent:null,headercontent:null,instanceconfig:null,hiddenRadioValue:null,setup_chooser_dialogue:function(e,t,n){this.bodycontent=e,this.headercontent=t,this.instanceconfig=n},prepare_chooser:function(){if(this.panel)return;e.one(e.config.doc.body).addClass("jschooser");var t,n={bodyContent:this.bodycontent.get("innerHTML"),headerContent:this.headercontent.get("innerHTML"),width:"540px",draggable:!0,visible:!1,zindex:100,modal:!0,shim:!0,closeButtonTitle:this.get("closeButtonTitle"),focusOnPreviousTargetAfterHide:!0,render:!1,extraClasses:this._getClassNames()};for(t in this.instanceconfig)n[t]=this.instanceconfig[t];this.panel=new M.core.dialogue(n),this.bodycontent.remove(),this.headercontent.remove(),this.panel.hide(),this.panel.render(),this.container=this.panel.get("boundingBox").one(".choosercontainer"),this.options=this.container.all(".option input[type=radio]"),this.hiddenRadioValue=e.Node.create('<input type="hidden" value="" />'),this.container.one("form").appendChild(this.hiddenRadioValue),this.panel.get("boundingBox").addClass("chooserdialogue")},display_chooser:function(t){var n,r,i;this.prepare_chooser(),t.preventDefault(),n=this.panel.get("boundingBox"),r=this.container.one(".alloptions"),i=e.one("document").on("orientationchange",function(){this.center_dialogue(r)},this),this.listenevents.push(i),i=e.one("window").on("resize",function(){this.center_dialogue(r)},this),this.listenevents.push(i),i=this.container.on("click",this.check_options,this),this.listenevents.push(i),i=this.container.on("key_up",this.check_options,this),this.listenevents.push(i),i=this.container.on("dblclick",function(e){e.target.ancestor("div.option")&&(this.check_options(),this.submitbutton.setAttribute("disabled","disabled"),this.options.setAttribute("disabled","disabled"),this.cancel_listenevents(),this.container.one("form").submit())},this),this.listenevents.push(i),this.container.one("form").on("submit",function(){this.submitbutton.setAttribute("disabled","disabled"),this.options.setAttribute("disabled","disabled"),this.cancel_listenevents()},this),i=this.container.one(".addcancel").on("click",this.cancel_popup,this),this.listenevents.push(i),i=n.one("button.closebutton").on("click",this.cancel_popup,this),this.listenevents.push(i),i=e.one("document").on("keydown",this.handle_key_press,this),this.listenevents.push(i),this.submitbutton=this.container.one(".submitbutton"),this.submitbutton.set("disabled","true"),this.options.removeAttribute("disabled"),this.panel.show(t),this.center_dialogue(r),this.container.one(".option input[type=radio]").focus(),this.check_options()},cancel_listenevents:function(){var e;while(this.listenevents.length)e=this.listenevents.shift(),e.detach()},center_dialogue:function(e){var t=this.panel.get("boundingBox"),n=t.get("winHeight"),r,i;if(this.panel.shouldResizeFullscreen())return;r=this.get("maxheight"),n<=r&&(n<=this.get("minheight")?r=this.get("minheight"):r=n),r>this.get("minheight")?this.panel.lockScroll&&!this.panel.lockScroll.isActive()&&this.panel.lockScroll.enableScrollLock(!0):this.panel.lockScroll&&this.panel.lockScroll.isActive()&&this.panel.lockScroll.disableScrollLock(),i=r,r-=110,e.setStyle("maxHeight",r+"px"),dialogueheight=t.getStyle("height"),dialogueheight.match(/.*px$/)?dialogueheight=dialogueheight.replace(/px$/,""):dialogueheight=i,dialogueheight<this.get("baseheight")&&(dialogueheight=this.get("baseheight"),e.setStyle("height",dialogueheight+"px")),this.panel.centerDialogue()},handle_key_press:function(e){e.keyCode===27&&this.cancel_popup(e)},cancel_popup:function(e){e.preventDefault(),this.hide()},hide:function(){this.cancel_listenevents(),this.container.detachAll(),this.panel.hide()},check_options:function(){this.options.each(function(e){var t=e.get("parentNode").get("parentNode");e.get("checked")?(t.addClass("selected"),this.option_selected(e),this.submitbutton.removeAttribute("disabled"),e.focus()):t.removeClass("selected")},this)},option_selected:function(e){this.hiddenRadioValue.setAttrs({value:e.get("value"),name:e.get("name")})},_getClassNames:function(e){var t="chooserdialogue-"+this.name,n=[];n.push(t.toLowerCase());if(e){var r;for(r in e)n.push((t+"-"+r).toLowerCase())}return n}},{NAME:"moodle-core-chooserdialogue",ATTRS:{minheight:{value:300},baseheight:{value:400},maxheight:{value:660},closeButtonTitle:{validator:e.Lang.isString,value:"Close"}}}),M.core=M.core||{},M.core.chooserdialogue=n},"@VERSION@",{requires:["base","panel","moodle-core-notification"]});
|
||||
|
@ -53,18 +53,19 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
// Set Default options
|
||||
var paramkey,
|
||||
params = {
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false
|
||||
};
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false,
|
||||
extraClasses: this._getClassNames()
|
||||
};
|
||||
|
||||
// Override with additional options
|
||||
for (paramkey in this.instanceconfig) {
|
||||
@ -316,6 +317,38 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
value: e.get('value'),
|
||||
name: e.get('name')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an array of class names prefixed with 'chooserdialogue-' and
|
||||
* the name of the type of dialogue.
|
||||
*
|
||||
* Note: Class name are converted to lower-case.
|
||||
*
|
||||
* If an array of arguments is supplied, each of these is prefixed and
|
||||
* lower-cased also.
|
||||
*
|
||||
* If no arguments are supplied, then the prefix is returned on it's
|
||||
* own.
|
||||
*
|
||||
* @method _getClassNames
|
||||
* @param {Array} [args] Any additional names to prefix and lower-case.
|
||||
* @return {Array}
|
||||
* @private
|
||||
*/
|
||||
_getClassNames: function(args) {
|
||||
var prefix = 'chooserdialogue-' + this.name,
|
||||
results = [];
|
||||
|
||||
results.push(prefix.toLowerCase());
|
||||
if (args) {
|
||||
var arg;
|
||||
for (arg in args) {
|
||||
results.push((prefix + '-' + arg).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -51,18 +51,19 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
// Set Default options
|
||||
var paramkey,
|
||||
params = {
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false
|
||||
};
|
||||
bodyContent : this.bodycontent.get('innerHTML'),
|
||||
headerContent : this.headercontent.get('innerHTML'),
|
||||
width : '540px',
|
||||
draggable : true,
|
||||
visible : false, // Hide by default
|
||||
zindex : 100, // Display in front of other items
|
||||
modal: true, // This dialogue should be modal.
|
||||
shim : true,
|
||||
closeButtonTitle : this.get('closeButtonTitle'),
|
||||
focusOnPreviousTargetAfterHide: true,
|
||||
render : false,
|
||||
extraClasses: this._getClassNames()
|
||||
};
|
||||
|
||||
// Override with additional options
|
||||
for (paramkey in this.instanceconfig) {
|
||||
@ -314,6 +315,38 @@ Y.extend(CHOOSERDIALOGUE, Y.Base, {
|
||||
value: e.get('value'),
|
||||
name: e.get('name')
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Return an array of class names prefixed with 'chooserdialogue-' and
|
||||
* the name of the type of dialogue.
|
||||
*
|
||||
* Note: Class name are converted to lower-case.
|
||||
*
|
||||
* If an array of arguments is supplied, each of these is prefixed and
|
||||
* lower-cased also.
|
||||
*
|
||||
* If no arguments are supplied, then the prefix is returned on it's
|
||||
* own.
|
||||
*
|
||||
* @method _getClassNames
|
||||
* @param {Array} [args] Any additional names to prefix and lower-case.
|
||||
* @return {Array}
|
||||
* @private
|
||||
*/
|
||||
_getClassNames: function(args) {
|
||||
var prefix = 'chooserdialogue-' + this.name,
|
||||
results = [];
|
||||
|
||||
results.push(prefix.toLowerCase());
|
||||
if (args) {
|
||||
var arg;
|
||||
for (arg in args) {
|
||||
results.push((prefix + '-' + arg).toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
},
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user