editor-controller.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Activiti Modeler component part of the Activiti project
  3. * Copyright 2005-2014 Alfresco Software, Ltd. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2.1 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Lesser General Public License for more details.
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. 'use strict';
  19. angular.module('activitiModeler')
  20. .controller('EditorUnsavedChangesPopupCrtl', ['$rootScope', '$scope', '$http', '$location', '$window', function ($rootScope, $scope, $http, $location, $window) {
  21. $scope.ok = function () {
  22. if ($scope.handleResponseFunction) {
  23. $scope.handleResponseFunction(true);
  24. // Also clear any 'onbeforeunload', added by oryx
  25. $window.onbeforeunload = undefined;
  26. }
  27. $scope.$hide();
  28. };
  29. $scope.cancel = function () {
  30. if ($scope.handleResponseFunction) {
  31. $scope.handleResponseFunction(false);
  32. }
  33. $scope.$hide();
  34. };
  35. }]);
  36. activitiModule
  37. .directive('autoFocus', ['$timeout', '$parse', function($timeout, $parse) {
  38. return {
  39. restrict: 'AC',
  40. compile: function($element, attr) {
  41. return function(_scope, _element, _attrs) {
  42. var firstChild = (_attrs.focusFirstChild !== undefined);
  43. $timeout(function () {
  44. if (firstChild) {
  45. // look for first input-element in child-tree and focus that
  46. var inputs = _element.find('input');
  47. if (inputs && inputs.length > 0) {
  48. inputs[0].focus();
  49. }
  50. } else {
  51. // Focus element where the directive is put on
  52. _element[0].focus();
  53. }
  54. }, 100);
  55. }
  56. }
  57. };
  58. }]);