Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit 410951b

Browse files
author
Dean Sofer
committed
fix(#3): jqLite.triggerHandler() doesn't accept event objects
- By passing an event string name instead events should resume firing properly. - Converted $() to angular.element - Converted .trigger() to .triggerHandler() in spec - Added 'ui.event' as a module dependency - Re-enabled tests - Regression introduced by d77bfe7
1 parent 7b4d6f0 commit 410951b

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

src/map.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
(function () {
2-
var app = angular.module('ui.map', []);
2+
var app = angular.module('ui.map', ['ui.event']);
33

44
//Setup map events from a google map object to trigger on a given element too,
55
//then we just use ui-event to catch events from an element
66
function bindMapEvents(scope, eventsStr, googleObject, element) {
77
angular.forEach(eventsStr.split(' '), function (eventName) {
88
//Prefix all googlemap events with 'map-', so eg 'click'
99
//for the googlemap doesn't interfere with a normal 'click' event
10-
var $event = { type: 'map-' + eventName };
11-
google.maps.event.addListener(googleObject, eventName, function (evt) {
12-
element.triggerHandler(angular.extend({}, $event, evt));
10+
google.maps.event.addListener(googleObject, eventName, function (event) {
11+
element.triggerHandler('map-' + eventName, event);
1312
//We create an $apply if it isn't happening. we need better support for this
1413
//We don't want to use timeout because tons of these events fire at once,
1514
//and we only need one $apply
@@ -18,7 +17,7 @@
1817
});
1918
}
2019

21-
app.directive('uiMap',
20+
app.value('uiMapConfig', {}).directive('uiMap',
2221
['uiMapConfig', '$parse', function (uiMapConfig, $parse) {
2322

2423
var mapEvents = 'bounds_changed center_changed click dblclick drag dragend ' +

test/googlemaps.js

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/mapSpec.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
xdescribe('uiMap', function () {
1+
describe('uiMap', function () {
22
var scope, $rootScope, $compile;
33

44
beforeEach(module('ui.map'));
@@ -10,17 +10,17 @@ xdescribe('uiMap', function () {
1010
function createMap(options, events) {
1111
scope.gmapOptions = options || {};
1212
scope.gmapEvents = events || {};
13-
$compile("<div ui-map='gmap' ui-options='gmapOptions'" +
14-
"' ui-event='gmapEvents'></div>")(scope);
13+
$compile("<div><div ui-map='gmap' ui-options='gmapOptions'" +
14+
"' ui-event='gmapEvents'></div></div>")(scope);
1515
}
1616

1717
function createWindow(options, events, inner) {
1818
scope.gOptions = options || {};
1919
scope.gEvents = events || {};
20-
inner = inner || angular.element('');
21-
var elm = angular.element("<div ui-map-info-window='ginfo' " +
22-
"ui-options='gOptions' ui-event='gEvents'></div>");
23-
elm.append(inner);
20+
var elm = angular.element("<div><div ui-map-info-window='ginfo' " +
21+
"ui-options='gOptions' ui-event='gEvents'></div></div>");
22+
if (inner)
23+
elm.children().append(inner);
2424
$compile(elm)(scope);
2525
}
2626

@@ -67,15 +67,15 @@ xdescribe('uiMap', function () {
6767
});
6868

6969
it('should create info window with given options & content', function () {
70-
var content = $('<h1>Hi</h1>');
70+
var content = angular.element('<h1>Hi</h1>');
7171
createWindow({ zIndex: 5 }, {}, content);
7272
expect(scope.ginfo.getZIndex()).toBe(5);
7373
expect(scope.ginfo.getContent().innerHTML)
74-
.toBe($('<div>').append(content).html());
74+
.toBe(angular.element('<div>').append(content).html());
7575
});
7676

7777
it('should $compile content and recognize scope changes', function () {
78-
var inner = $('<input ng-model="myVal">');
78+
var inner = angular.element('<input ng-model="myVal">');
7979
createWindow({}, {}, inner);
8080
createMap();
8181
scope.$apply(function () {
@@ -90,6 +90,7 @@ xdescribe('uiMap', function () {
9090
});
9191

9292
it('should recognize infowindow events in ui-event as "map-eventname"', function () {
93+
expect(scope.closed).toBeUndefined();
9394
createWindow({}, {
9495
'map-closeclick': 'closed = true'
9596
});

test/test.conf.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ files = [
55
JASMINE_ADAPTER,
66
'components/angular/angular.js',
77
'components/angular-mocks/angular-mocks.js',
8+
'components/angular-ui-utils/modules/event/event.js',
89
'src/*.js',
10+
'test/googlemaps.js',
911
'test/*Spec.js'
1012
];
1113

12-
// Avoid including minified version of angular and other libs again
13-
exclude = [
14-
'components/*/*.min.js'
15-
];
16-
1714
singleRun = true;
1815

16+
// level of logging
17+
// possible values = karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG
18+
// CLI --log-level debug
19+
logLevel = LOG_INFO,
20+
1921
reporters = [
2022
'dots'
2123
];

0 commit comments

Comments
 (0)