From 1cd8e151cf32ab9b1a22ce057ae47dbbaf9ca1e8 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Wed, 30 Nov 2016 05:25:52 -0500 Subject: [PATCH] webstaff: throw a kitchen sink at double-scrollbar issues This patch ameliorates, but does not eliminate, a bunch of cases where double-scrollbars could appear. [1] Adds iframe-resizer (https://github.com/davidjbradshaw/iframe-resizer, MIT license) as an option for automatically adjusting the height of an iframe to fit the contents. This can be enabled by ensuring that the page to be embedded brings in /js/ui/default/staff/build/js/iframeResizer.contentWindow.min.j and adding an 'autoresize' attribute to the egEmbedFrame directive. This is now used by the legacy reports page. [2] Gives a 'min-height' attribute to egEmbedFrame and sets a value for Dojo grid interfaces embedded by local and server admistration. [3] Adds a 'allow-escape' attribute to egEmbedFrame; when set to true, adds buttons to allow the user to open the embedded page in a new tab. [4] Removes some extraneous
s that were interferring with resizing for some grids. Signed-off-by: Galen Charlton Signed-off-by: Kathy Lussier --- .../global/cat/authority/browse_axis.tt2 | 2 -- .../browse_axis_authority_field_map.tt2 | 2 -- .../global/cat/authority/control_set.tt2 | 1 - .../authority/control_set_authority_field.tt2 | 2 -- .../cat/authority/control_set_bib_field.tt2 | 2 -- .../conify/global/cat/authority/thesaurus.tt2 | 2 -- .../conify/global/config/actor_sip_fields.tt2 | 1 - .../conify/global/config/asset_sip_fields.tt2 | 1 - .../conify/global/config/global_flag.tt2 | 1 - .../global/config/rule_circ_duration.tt2 | 1 - Open-ILS/src/templates/staff/base_js.tt2 | 1 + .../src/templates/staff/reporter/t_legacy.tt2 | 2 +- .../src/templates/staff/share/t_eframe.tt2 | 7 ++-- Open-ILS/web/js/ui/default/staff/Gruntfile.js | 5 ++- .../js/ui/default/staff/admin/local/app.js | 4 ++- .../js/ui/default/staff/admin/server/app.js | 4 ++- Open-ILS/web/js/ui/default/staff/bower.json | 3 +- .../js/ui/default/staff/services/eframe.js | 36 +++++++++++++++++-- Open-ILS/web/reports/oils_rpt_common.xhtml | 1 + 19 files changed, 53 insertions(+), 25 deletions(-) diff --git a/Open-ILS/src/templates/conify/global/cat/authority/browse_axis.tt2 b/Open-ILS/src/templates/conify/global/cat/authority/browse_axis.tt2 index 676edbb7dc..e9c580a49a 100644 --- a/Open-ILS/src/templates/conify/global/cat/authority/browse_axis.tt2 +++ b/Open-ILS/src/templates/conify/global/cat/authority/browse_axis.tt2 @@ -8,7 +8,6 @@
-
-
diff --git a/Open-ILS/src/templates/conify/global/cat/authority/control_set.tt2 b/Open-ILS/src/templates/conify/global/cat/authority/control_set.tt2 index 8c440a40c1..564d162f1e 100644 --- a/Open-ILS/src/templates/conify/global/cat/authority/control_set.tt2 +++ b/Open-ILS/src/templates/conify/global/cat/authority/control_set.tt2 @@ -8,7 +8,6 @@ -
-
-
diff --git a/Open-ILS/src/templates/conify/global/cat/authority/control_set_bib_field.tt2 b/Open-ILS/src/templates/conify/global/cat/authority/control_set_bib_field.tt2 index 7929cae329..e496b5dd1a 100644 --- a/Open-ILS/src/templates/conify/global/cat/authority/control_set_bib_field.tt2 +++ b/Open-ILS/src/templates/conify/global/cat/authority/control_set_bib_field.tt2 @@ -12,7 +12,6 @@ [% l('Showing only control set bib fields linked to authority field:') %] -
-
diff --git a/Open-ILS/src/templates/conify/global/cat/authority/thesaurus.tt2 b/Open-ILS/src/templates/conify/global/cat/authority/thesaurus.tt2 index 2b6673bb82..45846e7ec1 100644 --- a/Open-ILS/src/templates/conify/global/cat/authority/thesaurus.tt2 +++ b/Open-ILS/src/templates/conify/global/cat/authority/thesaurus.tt2 @@ -12,7 +12,6 @@ [% l('Showing only thesauri linked to control set:') %] -
-
diff --git a/Open-ILS/src/templates/conify/global/config/actor_sip_fields.tt2 b/Open-ILS/src/templates/conify/global/config/actor_sip_fields.tt2 index c3ff16a649..3ea23bf715 100644 --- a/Open-ILS/src/templates/conify/global/config/actor_sip_fields.tt2 +++ b/Open-ILS/src/templates/conify/global/config/actor_sip_fields.tt2 @@ -8,7 +8,6 @@ -
[% l('Delete Selected') %] -
[% l('Global Flags') %]
-
[% l('Delete Selected') %] -
+ diff --git a/Open-ILS/src/templates/staff/reporter/t_legacy.tt2 b/Open-ILS/src/templates/staff/reporter/t_legacy.tt2 index cbaa379ae6..738ca7f6b3 100644 --- a/Open-ILS/src/templates/staff/reporter/t_legacy.tt2 +++ b/Open-ILS/src/templates/staff/reporter/t_legacy.tt2 @@ -1 +1 @@ - + diff --git a/Open-ILS/src/templates/staff/share/t_eframe.tt2 b/Open-ILS/src/templates/staff/share/t_eframe.tt2 index 0562f665a0..0c9d72d456 100644 --- a/Open-ILS/src/templates/staff/share/t_eframe.tt2 +++ b/Open-ILS/src/templates/staff/share/t_eframe.tt2 @@ -1,8 +1,11 @@
+ +
diff --git a/Open-ILS/web/js/ui/default/staff/Gruntfile.js b/Open-ILS/web/js/ui/default/staff/Gruntfile.js index 4bfb43316e..2d982c41ef 100644 --- a/Open-ILS/web/js/ui/default/staff/Gruntfile.js +++ b/Open-ILS/web/js/ui/default/staff/Gruntfile.js @@ -32,7 +32,10 @@ module.exports = function(grunt) { 'bower_components/ngtoast/dist/ngToast.min.js', 'bower_components/jquery/dist/jquery.min.js', 'bower_components/angular-cookies/angular-cookies.min.js', - 'bower_components/angular-cookies/angular-cookies.min.js.map' + 'bower_components/angular-cookies/angular-cookies.min.js.map', + 'bower_components/iframe-resizer/js/iframeResizer.min.js', + 'bower_components/iframe-resizer/js/iframeResizer.map', + 'bower_components/iframe-resizer/js/iframeResizer.contentWindow.min.js' ] }] }, diff --git a/Open-ILS/web/js/ui/default/staff/admin/local/app.js b/Open-ILS/web/js/ui/default/staff/admin/local/app.js index 20b9647707..afceb4da76 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/local/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/local/app.js @@ -9,7 +9,7 @@ angular.module('egLocalAdmin', var resolver = {delay : function(egStartup) {return egStartup.go()}}; var eframe_template = - ''; + ''; // non-conify routes come first $routeProvider.when('/admin/local/money/cash_reports', { @@ -76,6 +76,8 @@ function($scope , $routeParams , $location , egCore) { var conify_path = '/eg/conify/global/' + $routeParams.schema + '/' + $routeParams.page; + $scope.min_height = 800; + // embed URL must include protocol/domain or it will be loaded via // push-state, resulting in an infinitely nested pages. $scope.local_admin_url = diff --git a/Open-ILS/web/js/ui/default/staff/admin/server/app.js b/Open-ILS/web/js/ui/default/staff/admin/server/app.js index a28987a0eb..962f0e520c 100644 --- a/Open-ILS/web/js/ui/default/staff/admin/server/app.js +++ b/Open-ILS/web/js/ui/default/staff/admin/server/app.js @@ -9,7 +9,7 @@ angular.module('egServerAdmin', var resolver = {delay : function(egStartup) {return egStartup.go()}}; var eframe_template = - ''; + ''; // old-style Confiy $routeProvider.when('/admin/server/legacy/:schema/:page', { @@ -51,6 +51,8 @@ function($scope , $routeParams , $location , egCore) { (angular.isDefined($routeParams.module) ? ($routeParams.module + '/') : '') + $routeParams.schema + '/' + $routeParams.page; + $scope.min_height = 800; + // embed URL must include protocol/domain or it will be loaded via // push-state, resulting in an infinitely nested pages. $scope.server_admin_url = diff --git a/Open-ILS/web/js/ui/default/staff/bower.json b/Open-ILS/web/js/ui/default/staff/bower.json index f332f3b55e..59fa196136 100644 --- a/Open-ILS/web/js/ui/default/staff/bower.json +++ b/Open-ILS/web/js/ui/default/staff/bower.json @@ -33,6 +33,7 @@ "angular-cookies": "^1.5.8" }, "resolutions": { - "angular": "~1.5.5" + "angular": "~1.5.5", + "iframe-resizer": "^3.5.5" } } diff --git a/Open-ILS/web/js/ui/default/staff/services/eframe.js b/Open-ILS/web/js/ui/default/staff/services/eframe.js index aa87c7b8bd..9bd6e3d6f0 100644 --- a/Open-ILS/web/js/ui/default/staff/services/eframe.js +++ b/Open-ILS/web/js/ui/default/staff/services/eframe.js @@ -18,12 +18,21 @@ angular.module('egCoreMod') // called after onload of each new iframe page onchange : '=?', + + // for tweaking height saveSpace : '@', + minHeight : '=?', + + // to display button for displaying embedded page + // in a new tab + allowEscape : '=?' }, templateUrl : './share/t_eframe', link: function (scope, element, attrs) { + scope.autoresize = 'autoresize' in attrs; + scope.showIframe = true; element.find('iframe').on( 'load', function() {scope.egEmbedFrameLoader(this)} @@ -38,6 +47,9 @@ angular.module('egCoreMod') // Set the initial iframe height to just under the window height. // leave room for the navbar, padding, margins, etc. $scope.height = $window.outerHeight - $scope.save_space; + if ($scope.minHeight && $scope.height < $scope.minHeight) { + $scope.height = $scope.minHeight; + } // browser client doesn't use cookies, so we don't load the // (at the time of writing, quite limited) angular.cookies @@ -78,9 +90,13 @@ angular.module('egCoreMod') $scope.frame = {dom:iframe}; $scope.iframe = iframe; - // Reset the iframe height to the final content height. - if ($scope.height < $scope.iframe.contentWindow.document.body.scrollHeight) - $scope.height = $scope.iframe.contentWindow.document.body.scrollHeight; + if ($scope.autoresize) { + iFrameResize({}, $scope.iframe); + } else { + // Reset the iframe height to the final content height. + if ($scope.height < $scope.iframe.contentWindow.document.body.scrollHeight) + $scope.height = $scope.iframe.contentWindow.document.body.scrollHeight; + } var page = $scope.iframe.contentWindow.location.href; console.debug('egEmbedFrameLoader(): ' + page); @@ -91,6 +107,10 @@ angular.module('egCoreMod') $scope.iframe.contentWindow.location); } + $scope.style = function() { + return 'height:' + $scope.height + 'px'; + } + // tell the iframe'd window its inside the staff client $scope.iframe.contentWindow.IAMXUL = true; @@ -106,6 +126,7 @@ angular.module('egCoreMod') // Adjust the height again if the iframe loads the openils.Util Dojo module $timeout(function () { + if ($scope.autoresize) return; // let iframe-resizer handle it if ($scope.iframe.contentWindow.openils && $scope.iframe.contentWindow.openils.Util) { // HACK! for patron reg page @@ -251,6 +272,15 @@ angular.module('egCoreMod') if ($scope.onchange) $scope.onchange(page); } + + // open a new tab with the embedded URL + $scope.escapeEmbed = function() { + $scope.showIframe = false; + $window.open($scope.url, '_blank').focus(); + } + $scope.restoreEmbed = function() { + $scope.showIframe = true; + } }] } }) diff --git a/Open-ILS/web/reports/oils_rpt_common.xhtml b/Open-ILS/web/reports/oils_rpt_common.xhtml index c1aad544c6..fbbae6ba84 100644 --- a/Open-ILS/web/reports/oils_rpt_common.xhtml +++ b/Open-ILS/web/reports/oils_rpt_common.xhtml @@ -10,6 +10,7 @@ parseOnLoad: true } +