12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- /* Directives for DOM manipulation and interaction. */
- /* Directive that can be used to make an input field react to the press of Enter. */
- eventManApp.directive('eventmanPressEnter', function () {
- return function (scope, element, attrs) {
- element.bind("keydown keypress", function (event) {
- if(event.which === 13) {
- scope.$apply(function (){
- scope.$eval(attrs.ngEnter);
- });
- event.preventDefault();
- }
- });
- };
- });
- eventManApp.directive('eventmanFocus', function () {
- function link(scope, element, attrs) {
- element[0].focus();
- };
- return {
- link: link
- };
- });
- eventManApp.directive('resetFocus', function () {
- function link(scope, element, attrs) {
- element.on('click', function() {
- // FIXME: that's so wrong! We need to make the new directive communicate.
- var el = angular.element(document.querySelector('#query-persons'));
- el.length && el[0].focus();
- });
- };
- return {
- link: link
- };
- });
- eventManApp.directive('escKey', function() {
- return function(scope, element, attrs) {
- element.bind('keydown keypress', function(evt) {
- if (evt.which === 27) {
- scope.$apply(function() {
- scope.$eval(attrs.escKey);
- });
- evt.preventDefault();
- }
- });
- };
- });
|