From c92341bff0765a294b87745a18219265a14aeff8 Mon Sep 17 00:00:00 2001 From: Brandon Bergren <bdragon@rtk0.net> Date: Tue, 1 Dec 2009 19:47:53 +0000 Subject: [PATCH] Add a way to bind controls that we aren't able to set the id/classes on from the Drupal side. This lets us work around the fact that gmap_widget_setup() completely fails to work on CCK fields. Example: <code> $remap = array( 'edit-field-latitude-0-value' => array('classes' => array('gmap-locpick_latitude'), 'id' => 'gmap-loc0-locpick_latitude0'), 'edit-field-longitude-0-value' => array('classes' => array('gmap-locpick_longitude'), 'id' => 'gmap-loc0-locpick_longitude0'), 'edit-field-address-0-value' => array('classes' => array('gmap-locpick_address'), 'id' => 'gmap-loc0-locpick_address0'), ); drupal_add_js(array('gmap_remap_widgets' => $remap), 'setting'); /* ... stuff copied from gmap_set_location(), etc... */ </code> --- js/gmap.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/js/gmap.js b/js/gmap.js index 79a9485..9e3dd6b 100755 --- a/js/gmap.js +++ b/js/gmap.js @@ -77,6 +77,14 @@ if (settings || (Drupal.settings && Drupal.settings.gmap)) { var mapid = obj.id.split('-'); + if (Drupal.settings['gmap_remap_widgets']) { + if (Drupal.settings['gmap_remap_widgets'][obj.id]) { + jQuery.each(Drupal.settings['gmap_remap_widgets'][obj.id].classes, function() { + jQuery(obj).addClass(this); + }); + mapid = Drupal.settings['gmap_remap_widgets'][obj.id].id.split('-'); + } + } var instanceid = mapid.pop(); mapid.shift(); mapid = mapid.join('-'); @@ -523,5 +531,10 @@ if (Drupal.jsEnabled) { } Drupal.behaviors.GMap = function (context) { + if (Drupal.settings && Drupal.settings['gmap_remap_widgets']) { + jQuery.each(Drupal.settings['gmap_remap_widgets'], function(key, val) { + $('#'+ key).addClass('gmap-control'); + }); + } $('.gmap-control:not(.gmap-processed)', context).addClass('gmap-processed').each(function () {Drupal.gmap.setup.call(this)}); }; -- GitLab