MDL-21400 converted iplookup to YUI3, removed in_head()

This commit is contained in:
Petr Skoda 2010-02-06 12:12:23 +00:00
parent c6f5f39ad5
commit 789ff38c47
2 changed files with 12 additions and 13 deletions

View File

@ -153,10 +153,9 @@ if (empty($CFG->googlemapkey)) {
$info = implode(' - ', $info);
$note = implode('<br />', $note);
$PAGE->requires->js("http://maps.google.com/maps?file=api&amp;v=2&amp;key=$CFG->googlemapkey", true)->in_head();
$PAGE->requires->js('/iplookup/functions.js')->in_head();
$PAGE->requires->yui2_lib('event');
$PAGE->requires->js_function_call('iplookup_load', array($latitude, $longitude));
$PAGE->requires->js(new moodle_url("http://maps.google.com/maps?file=api&v=2&key=$CFG->googlemapkey"));
$module = array('name'=>'core_iplookup', 'fullpath'=>'/iplookup/module.js');
$PAGE->requires->js_init_call('M.core_iplookup.init', array($latitude, $longitude), true, $module);
$PAGE->set_title(get_string('iplookup', 'admin').': '.$info);
$PAGE->set_heading($info);

View File

@ -22,7 +22,9 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
function iplookup_load(latitude, longitude) {
M.core_iplookup = {};
M.core_iplookup.init = function(Y, latitude, longitude) {
if (GBrowserIsCompatible()) {
var map = new GMap2(document.getElementById("map"));
map.addControl(new GSmallMapControl());
@ -32,12 +34,10 @@ function iplookup_load(latitude, longitude) {
map.addOverlay(new GMarker(point));
map.setMapType(G_HYBRID_MAP);
YAHOO.utils.Event.addListener(document.body, 'unload', iplookup_unload);
}
}
function iplookup_unload() {
if (GBrowserIsCompatible()) {
GUnload();
}
Y.on('unload', function() {
if (GBrowserIsCompatible()) {
GUnload();
}
}, document.body);
}
}