mirror of
https://github.com/moodle/moodle.git
synced 2025-07-23 23:31:58 +02:00
MDL-21400 fixed my own ugly mess in resizing of embedded stuff + converted to YUI3
This commit is contained in:
@@ -330,6 +330,53 @@ M.util.show_confirm_dialog = function(e, args) {
|
||||
});
|
||||
}
|
||||
|
||||
/** Useful for full embedding of various stuff */
|
||||
M.util.init_maximised_embed = function(Y, id) {
|
||||
var obj = Y.one('#'+id);
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var get_htmlelement_size = function(el, prop) {
|
||||
if (Y.Lang.isString(el)) {
|
||||
el = Y.one('#' + el);
|
||||
}
|
||||
var val = el.getStyle(prop);
|
||||
if (val == 'auto') {
|
||||
val = el.getComputedStyle(prop);
|
||||
}
|
||||
return parseInt(val);
|
||||
};
|
||||
|
||||
var resize_object = function() {
|
||||
obj.setStyle('width', '0px');
|
||||
obj.setStyle('height', '0px');
|
||||
var newwidth = get_htmlelement_size('content', 'width') - 15;
|
||||
|
||||
if (newwidth > 600) {
|
||||
obj.setStyle('width', newwidth + 'px');
|
||||
} else {
|
||||
obj.setStyle('width', '600px');
|
||||
}
|
||||
var pageheight = get_htmlelement_size('page', 'height');
|
||||
var objheight = get_htmlelement_size(obj, 'height');
|
||||
var newheight = objheight + parseInt(obj.get('winHeight')) - pageheight - 30;
|
||||
if (newheight > 400) {
|
||||
obj.setStyle('height', newheight + 'px');
|
||||
} else {
|
||||
obj.setStyle('height', '400px');
|
||||
}
|
||||
};
|
||||
|
||||
resize_object();
|
||||
// fix layout if window resized too
|
||||
window.onresize = function() {
|
||||
resize_object();
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
//=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===
|
||||
|
||||
function popupchecker(msg) {
|
||||
|
Reference in New Issue
Block a user