Skip to content

Commit

Permalink
removed ngm-event directive, as the angular parseJSON is now just a s…
Browse files Browse the repository at this point in the history
…imple JSON.parse, which would make the syntax in html awkward. Please use the specific directives like ngm-click, ... instead. Fixes #40.
  • Loading branch information
Tobias Bosch committed Jun 5, 2012
1 parent 1b9af3e commit e16b524
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 85 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
@@ -1,6 +1,10 @@
Changelog
=====================

1.0.7rc3
-------------
- Dropped ngm-event directives. Please use the event specific directives like ngm-click, ...

1.0.7rc2
-------------
- Update to angular 1.0 rc10
Expand Down
9 changes: 0 additions & 9 deletions README.md
Expand Up @@ -145,15 +145,6 @@ If the controller is used on more than one page, the instance of the controller
Note that the shared controller have the full scope functionality, e.g. for dependecy injection
or using `$watch`.

### Directive `ngm-event`

Syntax: `<div ngm-event="{event1:'handler1',event2:'handler2',...}">`

General event handler that integrates with jquery events, and also with jquery mobile events.
The value of the attribute is json and defines the event - handler mapping.

Usage: E.g. `<a href="#" ngm-event="{swiperight:'myFn()'}">`

### Event-Directives

The following event directives are supported:
Expand Down
16 changes: 0 additions & 16 deletions compiled/jquery-mobile-angular-adapter-1.0.7-rc3-SNAPSHOT.js
Expand Up @@ -1109,22 +1109,6 @@
(function (angular) {
var mod = angular.module('ng');

/**
* A widget to bind general events like touches, ....
*/
mod.directive("ngmEvent", function () {
return {
compile:function (element, attrs) {
var eventHandlers = angular.fromJson(attrs.ngmEvent);
return function (scope, element, attrs) {
for (var eventType in eventHandlers) {
registerEventHandler(scope, element, eventType, eventHandlers[eventType]);
}
}
}
}
});

function registerEventHandler(scope, element, eventType, handler) {
element.bind(eventType, function (event) {
var res = scope.$apply(handler, element);
Expand Down
Expand Up @@ -31927,22 +31927,6 @@ angular.element(document).find('head').append('<style type="text/css">@charset "
(function (angular) {
var mod = angular.module('ng');

/**
* A widget to bind general events like touches, ....
*/
mod.directive("ngmEvent", function () {
return {
compile:function (element, attrs) {
var eventHandlers = angular.fromJson(attrs.ngmEvent);
return function (scope, element, attrs) {
for (var eventType in eventHandlers) {
registerEventHandler(scope, element, eventType, eventHandlers[eventType]);
}
}
}
}
});

function registerEventHandler(scope, element, eventType, handler) {
element.bind(eventType, function (event) {
var res = scope.$apply(handler, element);
Expand Down

This file was deleted.

Large diffs are not rendered by default.

This file was deleted.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.opitzconsulting.html5</groupId>
<artifactId>jquery-mobile-angular-adapter</artifactId>
<version>1.0.7-rc2</version>
<version>1.0.7-rc3-SNAPSHOT</version>
<name>JQuery Mobile Angular Adapter</name>
<packaging>war</packaging>
<description>Adapter for using jquery mobile with angular</description>
Expand Down
16 changes: 0 additions & 16 deletions src/main/webapp/utils/event.js
@@ -1,22 +1,6 @@
(function (angular) {
var mod = angular.module('ng');

/**
* A widget to bind general events like touches, ....
*/
mod.directive("ngmEvent", function () {
return {
compile:function (element, attrs) {
var eventHandlers = angular.fromJson(attrs.ngmEvent);
return function (scope, element, attrs) {
for (var eventType in eventHandlers) {
registerEventHandler(scope, element, eventType, eventHandlers[eventType]);
}
}
}
}
});

function registerEventHandler(scope, element, eventType, handler) {
element.bind(eventType, function (event) {
var res = scope.$apply(handler, element);
Expand Down
55 changes: 32 additions & 23 deletions src/test/webapp/unit/utils/eventSpec.js
@@ -1,30 +1,39 @@
describe("event shortcuts", function () {
it("should eval the expression when the event is fired", function () {
var events = {taphold:'taphold', swipe:'swipe', swiperight:'swiperight',
swipeleft:'swipeleft',
pagebeforeshow:'pagebeforeshow',
pagebeforehide:'pagebeforehide',
pageshow:'pageshow',
pagehide:'pagehide',
click:'vclick'
};
for (var event in events) {
var d = testutils.compileInPage('<span ngm-' + event + '="executed=true"></span>');
describe('events', function () {
describe("event shortcuts", function () {
it("should eval the expression when the event is fired", function () {
var events = {taphold:'taphold', swipe:'swipe', swiperight:'swiperight',
swipeleft:'swipeleft',
pagebeforeshow:'pagebeforeshow',
pagebeforehide:'pagebeforehide',
pageshow:'pageshow',
pagehide:'pagehide',
click:'vclick'
};
for (var event in events) {
var d = testutils.compileInPage('<span ngm-' + event + '="executed=true"></span>');
var element = d.element;
var scope = element.scope();
element.trigger(events[event]);
expect(scope.executed).toEqual(true);
}
});

it("should work together with ng-model", function () {
var d = testutils.compileInPage('<input ngm-click="executed=true" type="text" ng-model="data">');
var element = d.element;
var scope = element.scope();
element.trigger(events[event]);
element.trigger('click');
expect(scope.executed).toEqual(true);
}
element.val('test');
testutils.triggerInputEvent(element);
expect(scope.data).toBe('test');
});


});

it("should work together with ng-model", function () {
var d = testutils.compileInPage('<input ng-click="executed=true" type="text" ng-model="data">');
var element = d.element;
var scope = element.scope();
element.trigger('click');
expect(scope.executed).toEqual(true);
element.val('test');
testutils.triggerInputEvent(element);
expect(scope.data).toBe('test');
describe('ngm-event', function() {
it("should execute teh ")
});

});

0 comments on commit e16b524

Please sign in to comment.