From d61a91c23ee622d18bdad90d906075d098e9df9d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 8 Jan 2018 17:10:19 -0500 Subject: [PATCH] experimenting with 'import' statements wip Signed-off-by: Bill Erickson --- Open-ILS/web/js/ui/default/staff/app.js | 2 +- Open-ILS/web/js/ui/default/staff/services/core.js | 6 +++-- Open-ILS/web/js/ui/default/staff/services/ui.js | 32 ++++++++++++++++++++++- 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/Open-ILS/web/js/ui/default/staff/app.js b/Open-ILS/web/js/ui/default/staff/app.js index 26eee4af78..5cf6737174 100644 --- a/Open-ILS/web/js/ui/default/staff/app.js +++ b/Open-ILS/web/js/ui/default/staff/app.js @@ -4,12 +4,12 @@ * Splash Page */ -//import angular from 'angular'; import angular from 'angular'; import ngRoute from 'angular-route'; import uiBootstrap from 'angular-ui-bootstrap'; import egCoreMod from './services/core.js'; import egUiMod from './services/ui.js'; +import focusMe from './services/ui.js'; angular.module('egHome', [ngRoute, uiBootstrap, egCoreMod, egUiMod]) diff --git a/Open-ILS/web/js/ui/default/staff/services/core.js b/Open-ILS/web/js/ui/default/staff/services/core.js index 40055c4fbb..094761a3f7 100644 --- a/Open-ILS/web/js/ui/default/staff/services/core.js +++ b/Open-ILS/web/js/ui/default/staff/services/core.js @@ -3,11 +3,13 @@ * egCoreMod houses all of the services, etc. required by all pages * for basic functionality. */ -export default egCoreMod = angular.module('egCoreMod', ['cfp.hotkeys', 'ngFileSaver', 'ngCookies', 'ngToast']) +export default 'egCoreMod'; +angular.module('egCoreMod', ['cfp.hotkeys', 'ngFileSaver', 'ngCookies', 'ngToast']) .config(['ngToastProvider', function(ngToastProvider) { ngToastProvider.configure({ verticalPosition: 'bottom', animation: 'fade' }); -}]); +}]) + diff --git a/Open-ILS/web/js/ui/default/staff/services/ui.js b/Open-ILS/web/js/ui/default/staff/services/ui.js index 47632ed696..65a7fa37ec 100644 --- a/Open-ILS/web/js/ui/default/staff/services/ui.js +++ b/Open-ILS/web/js/ui/default/staff/services/ui.js @@ -1,13 +1,40 @@ /** * UI tools and directives. */ +export default 'egUiMod'; + +// TODO: just a test. (No need to import directives linked to angular +// modules that are already imported). Would be useful for standalone +// directives. +export function focusMe($timeout, $parse) { + return { + link: function(scope, element, attrs) { + var model = $parse(attrs.focusMe); + scope.$watch(model, function(value) { + if(value === true) + $timeout(function() {element[0].focus()}); + }); + element.bind('blur', function() { + $timeout(function() { + scope.$apply(model.assign(scope, false)); + }); + }) + } + }; +} + +focusMe.$inject = ['$timeout', '$parse']; + angular.module('egUiMod', ['egCoreMod', 'ui.bootstrap']) +.directive('focusMe', focusMe) /** * * $scope.iAmOpen = true; */ + +/* .directive('focusMe', ['$timeout','$parse', function($timeout , $parse) { @@ -26,6 +53,7 @@ function($timeout , $parse) { } }; }]) +*/ /** * @@ -1258,4 +1286,6 @@ function($window , egStrings) { } return service; -}]); +}]) + +.name; // must come last! -- 2.11.0