Skip to content

Commit

Permalink
MDL-21400 converted iplookup to YUI3, removed in_head()
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Feb 6, 2010
1 parent c6f5f39 commit 789ff38
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions iplookup/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,9 @@
$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);
Expand Down
18 changes: 9 additions & 9 deletions iplookup/functions.js → iplookup/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}
}

0 comments on commit 789ff38

Please sign in to comment.