From 789ff38c477924a2fb254da1ac1b734d0b657fef Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Sat, 6 Feb 2010 12:12:23 +0000 Subject: [PATCH] MDL-21400 converted iplookup to YUI3, removed in_head() --- iplookup/index.php | 7 +++---- iplookup/{functions.js => module.js} | 18 +++++++++--------- 2 files changed, 12 insertions(+), 13 deletions(-) rename iplookup/{functions.js => module.js} (84%) diff --git a/iplookup/index.php b/iplookup/index.php index c43e1517bda..f2d2231e72d 100644 --- a/iplookup/index.php +++ b/iplookup/index.php @@ -153,10 +153,9 @@ if (empty($CFG->googlemapkey)) { $info = implode(' - ', $info); $note = implode('
', $note); - $PAGE->requires->js("http://maps.google.com/maps?file=api&v=2&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); diff --git a/iplookup/functions.js b/iplookup/module.js similarity index 84% rename from iplookup/functions.js rename to iplookup/module.js index 529e01070ec..bf76d871fe4 100644 --- a/iplookup/functions.js +++ b/iplookup/module.js @@ -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); + } } -- 2.43.0