summaryrefslogtreecommitdiffstats
path: root/js/vendor/angular-ui/modules/directives/event/event.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/vendor/angular-ui/modules/directives/event/event.js')
-rw-r--r--js/vendor/angular-ui/modules/directives/event/event.js27
1 files changed, 27 insertions, 0 deletions
diff --git a/js/vendor/angular-ui/modules/directives/event/event.js b/js/vendor/angular-ui/modules/directives/event/event.js
new file mode 100644
index 000000000..4373baf76
--- /dev/null
+++ b/js/vendor/angular-ui/modules/directives/event/event.js
@@ -0,0 +1,27 @@
+/**
+ * General-purpose Event binding. Bind any event not natively supported by Angular
+ * Pass an object with keynames for events to ui-event
+ * Allows $event object and $params object to be passed
+ *
+ * @example <input ui-event="{ focus : 'counter++', blur : 'someCallback()' }">
+ * @example <input ui-event="{ myCustomEvent : 'myEventHandler($event, $params)'}">
+ *
+ * @param ui-event {string|object literal} The event to bind to as a string or a hash of events with their callbacks
+ */
+angular.module('ui.directives').directive('uiEvent', ['$parse',
+ function ($parse) {
+ return function (scope, elm, attrs) {
+ var events = scope.$eval(attrs.uiEvent);
+ angular.forEach(events, function (uiEvent, eventName) {
+ var fn = $parse(uiEvent);
+ elm.bind(eventName, function (evt) {
+ var params = Array.prototype.slice.call(arguments);
+ //Take out first paramater (event object);
+ params = params.splice(1);
+ scope.$apply(function () {
+ fn(scope, {$event: evt, $params: params});
+ });
+ });
+ });
+ };
+ }]);