<commit_before>'use strict';

(function () {
  angular.module('google-maps').

  /**
   * A directive for embedding google maps into your app. 
   *
   * Usage:
   * <google-map map-id="myMapId" center="myCenter" zoom="myZoom" bounds="myBounds" mapOptions="myMapOptions"></google-map>
   *
   * myMapId:       just a string that is a unique identifier for your map (you may
   *                have multiple maps/instances of the directive)
   *
   * myCenter:      name that you want a center variable in the current scope to
   *                have. The value will be of the form { lat: 40, lng: -120 } 
   *
   * myZoom:        name that you want for a zoom variable in the current scope.
   *                Value will be an integer.
   *
   * myBounds:      name that you want for a bounds variable in the current scope.
   *                Value will be of the form { 
   *                  southWest: { lat: 40, lng: -120 }, 
   *                  northEast: { lat: 40, lng: -120 }
   *                }
   *
   * myMapOptions:  object in the current scope that is a
   *                google.maps.MapOptions object. If unspecified, will use the
   *                values in googleMapsDefaults.mapOptions.
   *                'googleMapsDefaults' is a service, so it is both injectable
   *                and overrideable.
   *
   * All attributes expect mapOptions are required. The myCenter, myZoom, and
   * myBounds variables do not have to exist in the current scope--they will be
   * created if necessary. All three have bi-directional association, i.e. drag
   * or zoom the map and they will update, update them and the map will change.
   * However, any initial state of these variables will be ignored.
   *
   * For more on configuring defaults, see module.js.
   *
   * If you need to get a handle on the google.maps.Map object, see
   * googleMapsContainer.js
   *
   *
   * Inspired by <NAME>'s angular-google-maps directive
   * https://github.com/nlaplante/angular-google-maps
   */
  directive('googleMap', ['$timeout', 'googleMapsUtils', 'googleMapControllerFactory',
    function ($timeout, googleMapsUtils, googleMapControllerFactory) {
  
    /** aliases **/
    var objToLatLng = googleMapsUtils.objToLatLng;
    var objToBounds = googleMapsUtils.objToBounds;
    var latLngToObj = googleMapsUtils.latLngToObj;
    var boundsToObj = googleMapsUtils.boundsToObj;


    /** link function **/

    function link(scope, element, attrs, controller) {
      // initialize scope
      if (!angular.isDefined(scope.center)) {
        scope.center = {};
      }
      if (!angular.isDefined(scope.bounds)) {
        scope.bounds = {};
      }

      // Make sure mapId is defined
      // Note: redundant check in MapController. Can't hurt.
      if (!attrs.hasOwnProperty('mapId')) {
        throw 'googleMap must have non-empty mapId attribute';
      }

      // Check what's defined in attrs
      // Note: this is also redundant since angular will throw an exception if
      // these attributes are not set. I may make these optional in the future
      // (pending angular support).
      var hasCenter = false;
      var hasZoom = false;
      var hasBounds = false;

      if (attrs.hasOwnProperty('center')) {
        hasCenter = true;
      }
      if (attrs.hasOwnProperty('zoom')) {
        hasZoom = true;
      }
      if (attrs.hasOwnProperty('bounds')) {
        hasBounds = true;
      }

      var updateScope = function() {
        $timeout(function () {
          if (hasCenter || hasZoom || hasBounds) {
            scope.$apply(function (s) {
              if (hasCenter) {
                scope.center = latLngToObj(controller.center);
              }
              if (hasZoom) {
                scope.zoom = controller.zoom;
              }
              if (hasBounds) {
                var b = controller.bounds;
                if (b) {
                  scope.bounds = boundsToObj(b);
                }
              }
            });
          }
        });
      };

      controller.addMapListener('drag', updateScope);
      controller.addMapListener('zoom_changed', updateScope);
      controller.addMapListener('center_changed', updateScope);
      // update values when map is loaded
      controller.addMapListenerOnce('bounds_changed', updateScope);
      <commit_msg>bounds_changed listener no longer a one-time listener.<commit_after>'use strict';

(function () {
  angular.module('google-maps').

  /**
   * A directive for embedding google maps into your app. 
   *
   * Usage:
   * <google-map map-id="myMapId" center="myCenter" zoom="myZoom" bounds="myBounds" mapOptions="myMapOptions"></google-map>
   *
   * myMapId:       just a string that is a unique identifier for your map (you may
   *                have multiple maps/instances of the directive)
   *
   * myCenter:      name that you want a center variable in the current scope to
   *                have. The value will be of the form { lat: 40, lng: -120 } 
   *
   * myZoom:        name that you want for a zoom variable in the current scope.
   *                Value will be an integer.
   *
   * myBounds:      name that you want for a bounds variable in the current scope.
   *                Value will be of the form { 
   *                  southWest: { lat: 40, lng: -120 }, 
   *                  northEast: { lat: 40, lng: -120 }
   *                }
   *
   * myMapOptions:  object in the current scope that is a
   *                google.maps.MapOptions object. If unspecified, will use the
   *                values in googleMapsDefaults.mapOptions.
   *                'googleMapsDefaults' is a service, so it is both injectable
   *                and overrideable.
   *
   * All attributes expect mapOptions are required. The myCenter, myZoom, and
   * myBounds variables do not have to exist in the current scope--they will be
   * created if necessary. All three have bi-directional association, i.e. drag
   * or zoom the map and they will update, update them and the map will change.
   * However, any initial state of these variables will be ignored.
   *
   * For more on configuring defaults, see module.js.
   *
   * If you need to get a handle on the google.maps.Map object, see
   * googleMapsContainer.js
   *
   *
   * Inspired by <NAME>'s angular-google-maps directive
   * https://github.com/nlaplante/angular-google-maps
   */
  directive('googleMap', ['$timeout', 'googleMapsUtils', 'googleMapControllerFactory',
    function ($timeout, googleMapsUtils, googleMapControllerFactory) {
  
    /** aliases **/
    var objToLatLng = googleMapsUtils.objToLatLng;
    var objToBounds = googleMapsUtils.objToBounds;
    var latLngToObj = googleMapsUtils.latLngToObj;
    var boundsToObj = googleMapsUtils.boundsToObj;


    /** link function **/

    function link(scope, element, attrs, controller) {
      // initialize scope
      if (!angular.isDefined(scope.center)) {
        scope.center = {};
      }
      if (!angular.isDefined(scope.bounds)) {
        scope.bounds = {};
      }

      // Make sure mapId is defined
      // Note: redundant check in MapController. Can't hurt.
      if (!attrs.hasOwnProperty('mapId')) {
        throw 'googleMap must have non-empty mapId attribute';
      }

      // Check what's defined in attrs
      // Note: this is also redundant since angular will throw an exception if
      // these attributes are not set. I may make these optional in the future
      // (pending angular support).
      var hasCenter = false;
      var hasZoom = false;
      var hasBounds = false;

      if (attrs.hasOwnProperty('center')) {
        hasCenter = true;
      }
      if (attrs.hasOwnProperty('zoom')) {
        hasZoom = true;
      }
      if (attrs.hasOwnProperty('bounds')) {
        hasBounds = true;
      }

      var updateScope = function() {
        $timeout(function () {
          if (hasCenter || hasZoom || hasBounds) {
            scope.$apply(function (s) {
              if (hasCenter) {
                scope.center = latLngToObj(controller.center);
              }
              if (hasZoom) {
                scope.zoom = controller.zoom;
              }
              if (hasBounds) {
                var b = controller.bounds;
                if (b) {
                  scope.bounds = boundsToObj(b);
                }
              }
            });
          }
        });
      };

      controller.addMapListener('drag', updateScope);
      controller.addMapListener('zoom_changed', updateScope);
      controller.addMapListener('center_changed', updateScope);
      controller.addMapListener('bounds_changed', updateScope);
      
{'fraction_non_alphanumeric': 0.09631597182122648, 'fraction_numerical': 0.0034646033029218154, 'mean_word_length': 2.0300909727081877, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5703270', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2336, 'n_words': 756}