mirror of
https://github.com/moodle/moodle.git
synced 2025-07-25 08:11:39 +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 ===
|
//=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===
|
||||||
|
|
||||||
function popupchecker(msg) {
|
function popupchecker(msg) {
|
||||||
|
@@ -409,6 +409,7 @@ EOT;
|
|||||||
</object>
|
</object>
|
||||||
</div>
|
</div>
|
||||||
EOT;
|
EOT;
|
||||||
|
$PAGE->requires->js_init_call('M.util.init_maximised_embed', array('resourceobject'), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
|
@@ -1035,9 +1035,6 @@ function lesson_get_media_html($lesson, $context) {
|
|||||||
} else {
|
} else {
|
||||||
// anything else - just try object tag enlarged as much as possible
|
// anything else - just try object tag enlarged as much as possible
|
||||||
$code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
|
$code = resourcelib_embed_general($url, $title, $clicktoopen, $mimetype);
|
||||||
$PAGE->requires->yui2_lib('dom');
|
|
||||||
$PAGE->requires->js('/mod/url/functions.js');
|
|
||||||
$PAGE->requires->js_function_call('imscp_setup_object', null, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $code;
|
return $code;
|
||||||
|
@@ -1,69 +0,0 @@
|
|||||||
// This file is part of Moodle - http://moodle.org/
|
|
||||||
//
|
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Moodle is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Javascript helper function for Resource module
|
|
||||||
*
|
|
||||||
* @package mod-resource
|
|
||||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
||||||
*/
|
|
||||||
|
|
||||||
function resource_init_object() {
|
|
||||||
YAHOO.util.Event.onDOMReady(function () {
|
|
||||||
imscp_setup_object();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function imscp_setup_object() {
|
|
||||||
resource_resize_object();
|
|
||||||
|
|
||||||
// fix layout if window resized too
|
|
||||||
window.onresize = function() {
|
|
||||||
resource_resize_object();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function resource_resize_object() {
|
|
||||||
var obj = YAHOO.util.Dom.get('resourceobject');
|
|
||||||
obj.style.width = '0px';
|
|
||||||
obj.style.height = '0px';
|
|
||||||
var newwidth = resource_get_htmlelement_size('content', 'width') - 15;
|
|
||||||
if (newwidth > 600) {
|
|
||||||
obj.style.width = newwidth + 'px';
|
|
||||||
} else {
|
|
||||||
obj.style.width = '600px';
|
|
||||||
}
|
|
||||||
var pageheight = resource_get_htmlelement_size('page', 'height');
|
|
||||||
var objheight = resource_get_htmlelement_size(obj, 'height');
|
|
||||||
var newheight = objheight + parseInt(YAHOO.util.Dom.getViewportHeight()) - pageheight - 30;
|
|
||||||
if (newheight > 400) {
|
|
||||||
obj.style.height = newheight + 'px';
|
|
||||||
} else {
|
|
||||||
obj.style.height = '400px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function resource_get_htmlelement_size(el, prop) {
|
|
||||||
var val = YAHOO.util.Dom.getStyle(el, prop);
|
|
||||||
if (val == 'auto') {
|
|
||||||
if (el.get) {
|
|
||||||
el = el.get('element'); // get real HTMLElement from YUI element
|
|
||||||
}
|
|
||||||
val = YAHOO.util.Dom.getComputedStyle(YAHOO.util.Dom.get(el), prop);
|
|
||||||
}
|
|
||||||
return parseInt(val);
|
|
||||||
}
|
|
@@ -104,9 +104,6 @@ function resource_display_embed($resource, $cm, $course, $file) {
|
|||||||
} else {
|
} else {
|
||||||
// anything else - just try object tag enlarged as much as possible
|
// anything else - just try object tag enlarged as much as possible
|
||||||
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
|
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
|
||||||
$PAGE->requires->yui2_lib('dom');
|
|
||||||
$PAGE->requires->js('/mod/url/functions.js');
|
|
||||||
$PAGE->requires->js_function_call('url_init_object');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource_print_header($resource, $cm, $course);
|
resource_print_header($resource, $cm, $course);
|
||||||
|
@@ -1,69 +0,0 @@
|
|||||||
// This file is part of Moodle - http://moodle.org/
|
|
||||||
//
|
|
||||||
// Moodle is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// Moodle is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Javascript helper function for URL module
|
|
||||||
*
|
|
||||||
* @package mod-url
|
|
||||||
* @copyright 2009 Petr Skoda (http://skodak.org)
|
|
||||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
||||||
*/
|
|
||||||
|
|
||||||
function url_init_object() {
|
|
||||||
YAHOO.util.Event.onDOMReady(function () {
|
|
||||||
imscp_setup_object();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function imscp_setup_object() {
|
|
||||||
url_resize_object();
|
|
||||||
|
|
||||||
// fix layout if window resized too
|
|
||||||
window.onresize = function() {
|
|
||||||
url_resize_object();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function url_resize_object() {
|
|
||||||
var obj = YAHOO.util.Dom.get('resourceobject');
|
|
||||||
obj.style.width = '0px';
|
|
||||||
obj.style.height = '0px';
|
|
||||||
var newwidth = url_get_htmlelement_size('content', 'width') - 15;
|
|
||||||
if (newwidth > 600) {
|
|
||||||
obj.style.width = newwidth + 'px';
|
|
||||||
} else {
|
|
||||||
obj.style.width = '600px';
|
|
||||||
}
|
|
||||||
var pageheight = url_get_htmlelement_size('page', 'height');
|
|
||||||
var objheight = url_get_htmlelement_size(obj, 'height');
|
|
||||||
var newheight = objheight + parseInt(YAHOO.util.Dom.getViewportHeight()) - pageheight - 30;
|
|
||||||
if (newheight > 400) {
|
|
||||||
obj.style.height = newheight + 'px';
|
|
||||||
} else {
|
|
||||||
obj.style.height = '400px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function url_get_htmlelement_size(el, prop) {
|
|
||||||
var val = YAHOO.util.Dom.getStyle(el, prop);
|
|
||||||
if (val == 'auto') {
|
|
||||||
if (el.get) {
|
|
||||||
el = el.get('element'); // get real HTMLElement from YUI element
|
|
||||||
}
|
|
||||||
val = YAHOO.util.Dom.getComputedStyle(YAHOO.util.Dom.get(el), prop);
|
|
||||||
}
|
|
||||||
return parseInt(val);
|
|
||||||
}
|
|
@@ -265,9 +265,6 @@ function url_display_embed($url, $cm, $course) {
|
|||||||
} else {
|
} else {
|
||||||
// anything else - just try object tag enlarged as much as possible
|
// anything else - just try object tag enlarged as much as possible
|
||||||
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
|
$code = resourcelib_embed_general($fullurl, $title, $clicktoopen, $mimetype);
|
||||||
$PAGE->requires->yui2_lib('dom');
|
|
||||||
$PAGE->requires->js('/mod/url/functions.js', true);
|
|
||||||
$PAGE->requires->js_function_call('url_init_object');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url_print_header($url, $cm, $course);
|
url_print_header($url, $cm, $course);
|
||||||
|
Reference in New Issue
Block a user