From: Kathy Lussier Date: Thu, 3 Nov 2016 18:03:10 +0000 (-0400) Subject: LP#1642086: Make jQuery available for both OPAC and staff use X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=dea9162642f2e5a0840e3cb1bbd3d10b061fa6d6;p=working%2FEvergreen.git LP#1642086: Make jQuery available for both OPAC and staff use First pass at moving files into common directory so that jQuery can be used in the OPAC in addition to the web client. Signed-off-by: Kathy Lussier Signed-off-by: Josh Stompro Conflicts: Open-ILS/src/templates/staff/base_js.tt2 Open-ILS/web/js/ui/default/common/Gruntfile.js Open-ILS/web/js/ui/default/common/bower.json Open-ILS/web/js/ui/default/staff/test/karma.conf.js --- diff --git a/Open-ILS/src/templates/staff/base_js.tt2 b/Open-ILS/src/templates/staff/base_js.tt2 index 82b662e432..2c865c3481 100644 --- a/Open-ILS/src/templates/staff/base_js.tt2 +++ b/Open-ILS/src/templates/staff/base_js.tt2 @@ -4,21 +4,21 @@ [% IF EXPAND_WEB_IMPORTS %] - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -49,7 +49,7 @@ [% ELSE %] - + [% END %] diff --git a/Open-ILS/src/templates/staff/config.tt2 b/Open-ILS/src/templates/staff/config.tt2 index c563d7ab97..a8366a8e2d 100644 --- a/Open-ILS/src/templates/staff/config.tt2 +++ b/Open-ILS/src/templates/staff/config.tt2 @@ -8,6 +8,6 @@ EVERGREEN_VERSION='0.0.1' EXPAND_WEB_IMPORTS = 1; # path to build files (js, css, fonts) -WEB_BUILD_PATH = ctx.media_prefix _ '/js/ui/default/staff/build/'; +WEB_BUILD_PATH = ctx.media_prefix _ '/js/ui/default/common/build/'; %] diff --git a/Open-ILS/web/js/ui/default/common/Gruntfile.js b/Open-ILS/web/js/ui/default/common/Gruntfile.js new file mode 100644 index 0000000000..d19c60d938 --- /dev/null +++ b/Open-ILS/web/js/ui/default/common/Gruntfile.js @@ -0,0 +1,232 @@ +module.exports = function(grunt) { + + // Project configuration. + var config = { + pkg: grunt.file.readJSON('package.json'), + + // copy the files we care about from fetched dependencies + // into our build directory + copy: { + + js : { + files: [{ + dest: 'build/js/', + flatten: true, + filter: 'isFile', + expand : true, + src: [ + 'node_modules/angular/angular.min.js', + 'node_modules/angular/angular.min.js.map', + 'node_modules/angular-animate/angular-animate.min.js', + 'node_modules/angular-animate/angular-animate.min.js.map', + 'node_modules/angular-sanitize/angular-sanitize.min.js', + 'node_modules/angular-sanitize/angular-sanitize.min.js.map', + 'node_modules/angular-route/angular-route.min.js', + 'node_modules/angular-route/angular-route.min.js.map', + 'node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js', + 'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js', + 'node_modules/angular-hotkeys/build/hotkeys.min.js', + 'node_modules/angular-file-saver/dist/angular-file-saver.bundle.min.js', + 'node_modules/angular-location-update/angular-location-update.min.js', + 'node_modules/angular-tree-control/angular-tree-control.js', + 'node_modules/ng-toast/dist/ngToast.min.js', + 'node_modules/jquery/dist/jquery.min.js', + 'node_modules/angular-cookies/angular-cookies.min.js', + 'node_modules/angular-cookies/angular-cookies.min.js.map', + 'node_modules/iframe-resizer/js/iframeResizer.min.js', + 'node_modules/iframe-resizer/js/iframeResizer.map', + 'node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js', + 'node_modules/angular-order-object-by/src/ng-order-object-by.js', + 'node_modules/lovefield/dist/lovefield.min.js', + 'node_modules/lovefield/dist/lovefield.min.js.map' + ] + }] + }, + + css : { + files : [{ + dest : 'build/css/', + flatten : true, + filter : 'isFile', + expand : true, + src : [ + 'node_modules/angular-hotkeys/build/hotkeys.min.css', + 'node_modules/bootstrap/dist/css/bootstrap.min.css', + 'node_modules/ngtoast/dist/ngToast.min.css', + 'node_modules/ngtoast/dist/ngToast-animations.min.css', + 'node_modules/angular-tree-control/css/tree-control.css', + 'node_modules/angular-tree-control/css/tree-control-attribute.css', + ] + }] + }, + + fonts : { + files : [{ + dest : 'build/fonts/', + flatten : true, + filter : 'isFile', + expand : true, + src : [ + 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', + 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', + 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', + 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff' + ] + }] + }, + + images : { + files : [{ + dest : 'build/images/', + flatten : true, + filter : 'isFile', + expand : true, + src : [ + 'node_modules/angular-tree-control/images/sample.png', + 'node_modules/angular-tree-control/images/node-opened-2.png', + 'node_modules/angular-tree-control/images/folder.png', + 'node_modules/angular-tree-control/images/node-closed.png', + 'node_modules/angular-tree-control/images/node-closed-light.png', + 'node_modules/angular-tree-control/images/node-opened.png', + 'node_modules/angular-tree-control/images/node-opened-light.png', + 'node_modules/angular-tree-control/images/folder-closed.png', + 'node_modules/angular-tree-control/images/node-closed-2.png', + 'node_modules/angular-tree-control/images/file.png' + ] + }] + } + }, + + // combine our CSS deps + // note: minification also supported, but not required (yet). + cssmin: { + combine: { + files: { + 'build/css/evergreen-staff-client-deps.<%= pkg.version %>.min.css' : [ + 'build/css/hotkeys.min.css', + 'build/css/bootstrap.min.css', + 'build/css/ngToast.min.css', + 'build/css/ngToast-animations.min.css', + 'build/css/tree-control.css', + 'build/css/tree-control-attribute.css', + ] + } + } + }, + + // concatenation + minification + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + }, + dev: { + files: [{ + expand: true, + src: ['build/js/ui-bootstrap.js', 'build/js/ui-bootstrap-tpls.js'], + dest: 'build/js', + cwd: '.', + rename: function (dst, src) { + return src.replace('.js', '.min.js'); + } + }], + }, + build: { + src: [ + // These are concatenated in order in the final build file. + // The order is important. + 'build/js/jquery.min.js', + 'build/js/angular.min.js', + 'build/js/angular-animate.min.js', + 'build/js/angular-sanitize.min.js', + 'build/js/angular-route.min.js', + 'build/js/ui-bootstrap.min.js', + 'build/js/ui-bootstrap-tpls.js', + 'build/js/hotkeys.min.js', + 'build/js/angular-tree-control.js', + 'build/js/ngToast.min.js', + 'build/js/lovefield.min.js', + // NOTE: OpenSRF must be installed + // XXX: Should not be hard-coded + '/openils/lib/javascript/JSON_v1.js', + '/openils/lib/javascript/opensrf.js', + '/openils/lib/javascript/opensrf_ws.js', + '../staff/services/core.js', + '../staff/services/strings.js', + '../staff/services/idl.js', + '../staff/services/event.js', + '../staff/services/net.js', + '../staff/services/auth.js', + '../staff/services/pcrud.js', + '../staff/services/env.js', + '../staff/services/org.js', + '../staff/services/startup.js', + '../staff/services/hatch.js', + '../staff/services/print.js', + '../staff/services/audio.js', + '../staff/services/coresvc.js', + '../staff/services/navbar.js', + '../staff/services/ui.js', + '../staff/services/date.js', + '../staff/services/op_change.js', + ], + dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js' + }, + }, + + // bare concat operation; useful for testing concat w/o minification + // to more easily detect if concat order is incorrect + concat: { + options: { + separator: ';', + } + }, + + exec : { + + // Generate test/data/IDL2js.js for unit tests. + // note: the output of this script is *not* part of the final build. + idl2js : { + command : 'cd ../staff/test/data && perl idl2js.pl', + }, + + // Remove the unit test IDL2js.js file. We don't need it after testing + rmidl2js : { + command : 'rm ../staff/test/data/IDL2js.js', + } + }, + + // unit tests configuration + karma : { + unit: { + configFile: '../staff/test/karma.conf.js', + //background: true // for now, visually babysit unit tests + } + } + }; + + // tell concat about our uglify build options (instead of repeating them) + config.concat.build = config.uglify.build; + + // apply our configuration + grunt.initConfig(config); + + // Load our modules + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-contrib-cssmin'); + grunt.loadNpmTasks('grunt-karma'); + grunt.loadNpmTasks('grunt-exec'); + + // note: "grunt concat" is not required + grunt.registerTask('build', ['copy', 'cssmin', 'uglify']); + + // test only, no minification + grunt.registerTask('test', ['copy', 'exec:idl2js', 'karma:unit', 'exec:rmidl2js']); + + // note: "grunt concat" is not requried + grunt.registerTask('all', ['test', 'cssmin', 'uglify']); + +}; + +// vim: ts=2:sw=2:softtabstop=2 diff --git a/Open-ILS/web/js/ui/default/common/package.json b/Open-ILS/web/js/ui/default/common/package.json new file mode 100644 index 0000000000..91c88fa37a --- /dev/null +++ b/Open-ILS/web/js/ui/default/common/package.json @@ -0,0 +1,44 @@ +{ + "name": "evergreen-staff-client", + "description": "Evergreen ILS Browser Staff Client", + "version": "0.0.1", + "license": "GPL", + "homepage": "http://evergreen-ils.org/", + "devDependencies": { + "angular": "~1.5", + "angular-animate": "~1.5.3", + "angular-ui-bootstrap": "~1.2.4", + "angular-cookies": "~1.5.8", + "angular-file-saver": "~1.1.0", + "angular-hotkeys": "^1.7.0", + "angular-location-update": "~0.0.2", + "angular-mocks": "~1.5.0", + "angular-route": "~1.5.0", + "angular-tree-control": "~0.2.28", + "angular-order-object-by": "rxfork/ngOrderObjectBy#npm", + "lovefield": "*", + "bootstrap": "~3.3.6", + "grunt": "~0.4.4", + "grunt-cli": "^0.1.13", + "grunt-contrib-concat": "^0.4.0", + "grunt-contrib-copy": "^0.5.0", + "grunt-contrib-cssmin": "^0.9.0", + "grunt-contrib-jasmine": "^0.6.4", + "grunt-contrib-uglify": "^0.4.0", + "grunt-exec": "^0.4.5", + "grunt-karma": "^0.8.3", + "iframe-resizer": "^3.5.5", + "jquery": "~2.2.1", + "karma": "^0.12.14", + "karma-jasmine": "^0.1.5", + "karma-phantomjs-launcher": "^1.0.0", + "karma-script-launcher": "~0.1.0", + "karma-spec-reporter": "0.0.12", + "karma-story-reporter": "^0.2.2", + "ng-toast": "~2.0.0", + "phantomjs-prebuilt": "^2.1.7" + }, + "scripts": { + "test": "grunt test" + } +} diff --git a/Open-ILS/web/js/ui/default/staff/Gruntfile.js b/Open-ILS/web/js/ui/default/staff/Gruntfile.js deleted file mode 100644 index e5941960fa..0000000000 --- a/Open-ILS/web/js/ui/default/staff/Gruntfile.js +++ /dev/null @@ -1,232 +0,0 @@ -module.exports = function(grunt) { - - // Project configuration. - var config = { - pkg: grunt.file.readJSON('package.json'), - - // copy the files we care about from fetched dependencies - // into our build directory - copy: { - - js : { - files: [{ - dest: 'build/js/', - flatten: true, - filter: 'isFile', - expand : true, - src: [ - 'node_modules/angular/angular.min.js', - 'node_modules/angular/angular.min.js.map', - 'node_modules/angular-animate/angular-animate.min.js', - 'node_modules/angular-animate/angular-animate.min.js.map', - 'node_modules/angular-sanitize/angular-sanitize.min.js', - 'node_modules/angular-sanitize/angular-sanitize.min.js.map', - 'node_modules/angular-route/angular-route.min.js', - 'node_modules/angular-route/angular-route.min.js.map', - 'node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js', - 'node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js', - 'node_modules/angular-hotkeys/build/hotkeys.min.js', - 'node_modules/angular-file-saver/dist/angular-file-saver.bundle.min.js', - 'node_modules/angular-location-update/angular-location-update.min.js', - 'node_modules/angular-tree-control/angular-tree-control.js', - 'node_modules/ng-toast/dist/ngToast.min.js', - 'node_modules/jquery/dist/jquery.min.js', - 'node_modules/angular-cookies/angular-cookies.min.js', - 'node_modules/angular-cookies/angular-cookies.min.js.map', - 'node_modules/iframe-resizer/js/iframeResizer.min.js', - 'node_modules/iframe-resizer/js/iframeResizer.map', - 'node_modules/iframe-resizer/js/iframeResizer.contentWindow.min.js', - 'node_modules/angular-order-object-by/src/ng-order-object-by.js', - 'node_modules/lovefield/dist/lovefield.min.js', - 'node_modules/lovefield/dist/lovefield.min.js.map' - ] - }] - }, - - css : { - files : [{ - dest : 'build/css/', - flatten : true, - filter : 'isFile', - expand : true, - src : [ - 'node_modules/angular-hotkeys/build/hotkeys.min.css', - 'node_modules/bootstrap/dist/css/bootstrap.min.css', - 'node_modules/ngtoast/dist/ngToast.min.css', - 'node_modules/ngtoast/dist/ngToast-animations.min.css', - 'node_modules/angular-tree-control/css/tree-control.css', - 'node_modules/angular-tree-control/css/tree-control-attribute.css', - ] - }] - }, - - fonts : { - files : [{ - dest : 'build/fonts/', - flatten : true, - filter : 'isFile', - expand : true, - src : [ - 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.eot', - 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.svg', - 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf', - 'node_modules/bootstrap/dist/fonts/glyphicons-halflings-regular.woff' - ] - }] - }, - - images : { - files : [{ - dest : 'build/images/', - flatten : true, - filter : 'isFile', - expand : true, - src : [ - 'node_modules/angular-tree-control/images/sample.png', - 'node_modules/angular-tree-control/images/node-opened-2.png', - 'node_modules/angular-tree-control/images/folder.png', - 'node_modules/angular-tree-control/images/node-closed.png', - 'node_modules/angular-tree-control/images/node-closed-light.png', - 'node_modules/angular-tree-control/images/node-opened.png', - 'node_modules/angular-tree-control/images/node-opened-light.png', - 'node_modules/angular-tree-control/images/folder-closed.png', - 'node_modules/angular-tree-control/images/node-closed-2.png', - 'node_modules/angular-tree-control/images/file.png' - ] - }] - } - }, - - // combine our CSS deps - // note: minification also supported, but not required (yet). - cssmin: { - combine: { - files: { - 'build/css/evergreen-staff-client-deps.<%= pkg.version %>.min.css' : [ - 'build/css/hotkeys.min.css', - 'build/css/bootstrap.min.css', - 'build/css/ngToast.min.css', - 'build/css/ngToast-animations.min.css', - 'build/css/tree-control.css', - 'build/css/tree-control-attribute.css', - ] - } - } - }, - - // concatenation + minification - uglify: { - options: { - banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' - }, - dev: { - files: [{ - expand: true, - src: ['build/js/ui-bootstrap.js', 'build/js/ui-bootstrap-tpls.js'], - dest: 'build/js', - cwd: '.', - rename: function (dst, src) { - return src.replace('.js', '.min.js'); - } - }], - }, - build: { - src: [ - // These are concatenated in order in the final build file. - // The order is important. - 'build/js/jquery.min.js', - 'build/js/angular.min.js', - 'build/js/angular-animate.min.js', - 'build/js/angular-sanitize.min.js', - 'build/js/angular-route.min.js', - 'build/js/ui-bootstrap.min.js', - 'build/js/ui-bootstrap-tpls.js', - 'build/js/hotkeys.min.js', - 'build/js/angular-tree-control.js', - 'build/js/ngToast.min.js', - 'build/js/lovefield.min.js', - // NOTE: OpenSRF must be installed - // XXX: Should not be hard-coded - '/openils/lib/javascript/JSON_v1.js', - '/openils/lib/javascript/opensrf.js', - '/openils/lib/javascript/opensrf_ws.js', - 'services/core.js', - 'services/strings.js', - 'services/idl.js', - 'services/event.js', - 'services/net.js', - 'services/auth.js', - 'services/pcrud.js', - 'services/env.js', - 'services/org.js', - 'services/startup.js', - 'services/hatch.js', - 'services/print.js', - 'services/audio.js', - 'services/coresvc.js', - 'services/navbar.js', - 'services/ui.js', - 'services/date.js', - 'services/op_change.js', - ], - dest: 'build/js/<%= pkg.name %>.<%= pkg.version %>.min.js' - }, - }, - - // bare concat operation; useful for testing concat w/o minification - // to more easily detect if concat order is incorrect - concat: { - options: { - separator: ';', - } - }, - - exec : { - - // Generate test/data/IDL2js.js for unit tests. - // note: the output of this script is *not* part of the final build. - idl2js : { - command : 'cd test/data && perl idl2js.pl', - }, - - // Remove the unit test IDL2js.js file. We don't need it after testing - rmidl2js : { - command : 'rm test/data/IDL2js.js', - } - }, - - // unit tests configuration - karma : { - unit: { - configFile: 'test/karma.conf.js', - //background: true // for now, visually babysit unit tests - } - } - }; - - // tell concat about our uglify build options (instead of repeating them) - config.concat.build = config.uglify.build; - - // apply our configuration - grunt.initConfig(config); - - // Load our modules - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); - grunt.loadNpmTasks('grunt-karma'); - grunt.loadNpmTasks('grunt-exec'); - - // note: "grunt concat" is not required - grunt.registerTask('build', ['copy', 'cssmin', 'uglify']); - - // test only, no minification - grunt.registerTask('test', ['copy', 'exec:idl2js', 'karma:unit', 'exec:rmidl2js']); - - // note: "grunt concat" is not requried - grunt.registerTask('all', ['test', 'cssmin', 'uglify']); - -}; - -// vim: ts=2:sw=2:softtabstop=2 diff --git a/Open-ILS/web/js/ui/default/staff/package.json b/Open-ILS/web/js/ui/default/staff/package.json deleted file mode 100644 index 91c88fa37a..0000000000 --- a/Open-ILS/web/js/ui/default/staff/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "evergreen-staff-client", - "description": "Evergreen ILS Browser Staff Client", - "version": "0.0.1", - "license": "GPL", - "homepage": "http://evergreen-ils.org/", - "devDependencies": { - "angular": "~1.5", - "angular-animate": "~1.5.3", - "angular-ui-bootstrap": "~1.2.4", - "angular-cookies": "~1.5.8", - "angular-file-saver": "~1.1.0", - "angular-hotkeys": "^1.7.0", - "angular-location-update": "~0.0.2", - "angular-mocks": "~1.5.0", - "angular-route": "~1.5.0", - "angular-tree-control": "~0.2.28", - "angular-order-object-by": "rxfork/ngOrderObjectBy#npm", - "lovefield": "*", - "bootstrap": "~3.3.6", - "grunt": "~0.4.4", - "grunt-cli": "^0.1.13", - "grunt-contrib-concat": "^0.4.0", - "grunt-contrib-copy": "^0.5.0", - "grunt-contrib-cssmin": "^0.9.0", - "grunt-contrib-jasmine": "^0.6.4", - "grunt-contrib-uglify": "^0.4.0", - "grunt-exec": "^0.4.5", - "grunt-karma": "^0.8.3", - "iframe-resizer": "^3.5.5", - "jquery": "~2.2.1", - "karma": "^0.12.14", - "karma-jasmine": "^0.1.5", - "karma-phantomjs-launcher": "^1.0.0", - "karma-script-launcher": "~0.1.0", - "karma-spec-reporter": "0.0.12", - "karma-story-reporter": "^0.2.2", - "ng-toast": "~2.0.0", - "phantomjs-prebuilt": "^2.1.7" - }, - "scripts": { - "test": "grunt test" - } -} diff --git a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js index 87d673130d..fc667e2a47 100644 --- a/Open-ILS/web/js/ui/default/staff/test/karma.conf.js +++ b/Open-ILS/web/js/ui/default/staff/test/karma.conf.js @@ -6,15 +6,15 @@ module.exports = function(config){ logLevel: config.LOG_INFO, files : [ - 'build/js/angular.min.js', - 'build/js/angular-route.min.js', - 'node_modules/angular-mocks/angular-mocks.js', // testing only - 'node_modules/angular-file-saver/dist/angular-file-saver.bundle.min.js', - 'node_modules/ng-toast/dist/ngToast.min.js', - 'node_modules/angular-sanitize/angular-sanitize.min.js', - 'build/js/ui-bootstrap.js', - 'build/js/hotkeys.min.js', - 'build/js/angular-cookies.min.js', + '../common/build/js/angular.min.js', + '../common/build/js/angular-route.min.js', + '../common/bower_components/angular-mocks/angular-mocks.js', // testing only + '../common/bower_components/angular-file-saver/dist/angular-file-saver.bundle.min.js', + '../common/bower_components/ngtoast/dist/ngToast.min.js', + '../common/bower_components/angular-sanitize/angular-sanitize.min.js', + '../common/build/js/ui-bootstrap.min.js', + '../common/build/js/hotkeys.min.js', + '../common/build/js/angular-cookies.min.js', /* OpenSRF must be installed first */ '/openils/lib/javascript/md5.js', '/openils/lib/javascript/JSON_v1.js',