# google-maps-widget/1.93/js/gmw-admin.js

Maps Widget for Google Maps, version 1.93. 63 lines.

- Page: https://pluginprobe.com/plugins/google-maps-widget/1.93/code/js/gmw-admin.js
- Raw: https://pluginprobe.com/plugins/google-maps-widget/1.93/raw/js/gmw-admin.js
- Modified: 2014-09-22T15:29:50+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/google-maps-widget/1.93/code/js/gmw-admin.js#L10-L20`.

```javascript
/*
 * Google Maps Widget
 * (c) Web factory Ltd, 2012 - 2013
 */

jQuery(function($) {
  $('.gmw-tabs').each(function(i, el) {
    change_pin_type(el);
    change_link_type(el);
    $('.gmw_thumb_pin_type', el).on('change', function() { change_pin_type(el) });
    $('.gmw_thumb_link_type', el).on('change', function() { change_link_type(el) });
    el_id = $(el).attr('id');
    $(el).tabs({ active: get_active_tab(el_id),
                 activate: function(event, ui) { save_active_tab(this); }
    });
  });

  // get active tab index from cookie
  function get_active_tab(el_id) {
    id = parseInt(0 + $.cookie(el_id), 10);

    return id;
  } // get_active_tab

  // save active tab index to cookie
  function save_active_tab(elem) {
    $.cookie($(elem).attr('id'), $(elem).tabs('option', 'active'), { expires: 30 });
  } // save_active_tab

  // show/hide custom link field based on user's link type choice
  function change_link_type(widget) {
    if ($('.gmw_thumb_link_type', widget).val() == 'custom') {
      $('.gmw_thumb_link_section', widget).show();
    } else {
      $('.gmw_thumb_link_section', widget).hide();
    }
  } // link_type
  
  // show/hide custom pin URL field based on user's pin type choice
  function change_pin_type(widget) {
    if ($('.gmw_thumb_pin_type', widget).val() == 'custom') {
      $('.gmw_thumb_pin_type_custom_section', widget).show();
      $('.gmw_thumb_pin_type_predefined_section', widget).hide();
    } else {
      $('.gmw_thumb_pin_type_custom_section', widget).hide();
      $('.gmw_thumb_pin_type_predefined_section', widget).show();
    }
  } // pin_type

  // re-tab on GUI rebuild
  $('div[id*="googlemapswidget"]').ajaxSuccess(function(event, request, option) {
    $('.gmw-tabs').each(function(i, el) {
      change_pin_type(el);
      change_link_type(el);
      $('.gmw_thumb_pin_type', el).on('change', function() { change_pin_type(el) });
      $('.gmw_thumb_link_type', el).on('change', function() { change_link_type(el) });
      el_id = $(el).attr('id');
      $(el).tabs({ active: get_active_tab(el_id),
                   activate: function(event, ui) { save_active_tab(this); }
      });
    });
  });
}); // onload
```
