Ports Marc Edit Tiles (KMIG-99,103,111)
authorBill Erickson <berickxx@gmail.com>
Wed, 29 Oct 2014 21:05:39 +0000 (17:05 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
    Cross-port: 2b9072c

Open-ILS/web/opac/locale/en-US/lang.dtd
Open-ILS/xul/staff_client/chrome/content/main/main.js
Open-ILS/xul/staff_client/chrome/content/main/menu.js
Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul

index ef72fec..306f941 100644 (file)
 <!ENTITY staff.main.menu.file.label "File">
 <!ENTITY staff.main.menu.file.new.accesskey "N">
 <!ENTITY staff.main.menu.file.new.label "New Window">
+<!ENTITY staff.main.menu.file.open.record.windows.horizontal "Tile MARC Records (Horizontal)">
+<!ENTITY staff.main.menu.file.open.record.windows.vertical "Tile MARC Records (Vertical)">
 <!ENTITY staff.main.menu.file.new_tab.accesskey "T">
 <!ENTITY staff.main.menu.file.new_tab.label "New Tab">
 <!ENTITY staff.main.menu.file.portal.label "Home">
index 1886dec..9e3ad41 100644 (file)
@@ -819,5 +819,43 @@ function auto_login(loginInfo) {
     }
     return should_test_server;
 }
+    
+function tileWindows(urlList, isVertical, winCount, winIndex, aContinue) {
+    if(aContinue == true && tempWindow.closed == false) {
+        //check if window finished openning
+        if(tempWindow.g == undefined || tempWindow.g.menu == undefined) {
+            setTimeout(
+                function() {
+                    tileWindows(urlList, isVertical, winCount, winIndex, true);
+                }, 500);
+            return null;
+        }
+        tempWindow = null;
+    }
+    var scrWidth = window.screen.width;
+    var scrHeight = window.screen.height;
+    var placement = '';
+    if (urlList.length > 0) {
+        var url = urlList.shift();
+        //stack windows vertically or horizontally
+        if (isVertical) {
+            var winWidth = scrWidth / winCount;
+            placement = 'screenX=' + winWidth * (winIndex) + ',width=' + winWidth+ ',height=' + scrHeight;
+        } else {
+            var winHeight = scrHeight / winCount;
+            placement = 'screenY=' + winHeight * (winIndex) + ',width=' + scrWidth+ ',height=' + winHeight
+        }
+        tempWindow = xulG.window.open(urls.XUL_MENU_FRAME
+            + '?server=' + window.escape(G.data.server) + '&firstURL=' + window.escape(url),
+            '_blank','chrome,resizable,sizemode="normal",' + placement);
+        tempWindow.xulG = xulG;
+        winIndex++;
+        setTimeout(
+            function() {
+                tileWindows(urlList, isVertical, winCount, winIndex, true);
+            }, 500);
+
+    }
+}
 
 dump('exiting main/main.js\n');
index 26034ba..54248c8 100644 (file)
@@ -275,6 +275,35 @@ main.menu.prototype = {
                 ['oncommand'],
                 function() { obj.close_all_tabs(); }
             ],
+            
+            'cmd_open_record_windows_horizontal' : [
+                ['oncommand'],
+                function(event) {
+                    var bibURLs = obj.get_opac_record_urls();
+                    if(bibURLs && bibURLs.length > 0)
+                    {
+                    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
+                        getService(Components.interfaces.nsIWindowMediator);
+                    wm.getMostRecentWindow('eg_main').tileWindows(bibURLs, false, bibURLs.length, 0, false);
+                    } else {
+                        alert("No Records to Display");
+                    }
+                }
+            ],
+            'cmd_open_record_windows_vertical' : [
+                ['oncommand'],
+                function(event) {
+                    var bibURLs = obj.get_opac_record_urls();
+                    if(bibURLs && bibURLs.length > 0)
+                    {
+                    var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].
+                        getService(Components.interfaces.nsIWindowMediator);
+                    wm.getMostRecentWindow('eg_main').tileWindows(bibURLs, true, bibURLs.length, 0, false);
+                    } else {
+                        alert("No Records to Display");
+                    }
+                }
+            ],
 
             /* Edit Menu */
             'cmd_edit_copy_buckets' : [
@@ -2969,6 +2998,42 @@ commands:
         } catch(E) {
             alert('Error in menu.js, render_toolbar_layout('+layout+'): ' + E);
         }
+    },
+
+    'get_opac_record_urls'  : function() {
+        var bibURLs = [];
+        var panelCount = this.controller.view.panels.childNodes.length;
+        for (var i = 1; i < panelCount; i++) {
+            var panel = this.controller.view.panels.childNodes[ i ];
+            if (panel
+                && panel.firstChild
+                && panel.firstChild.nodeName == 'iframe'
+                && panel.firstChild.contentWindow
+                )
+            {
+                var cw = panel.firstChild.contentWindow;
+                var iframes = cw.document.getElementsByTagName('iframe');
+
+                if(iframes.length > 0)
+                {
+                    for (var y = 0; y < iframes.length; y++) {
+                        if(iframes[y].getAttribute('src').match(/^[https|chrome|oils].*/)
+                            && iframes[y].contentDocument
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0]
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow
+                            && iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow.location)
+                            {
+                                var opac_url = iframes[y].contentDocument.getElementsByTagName('browser')[0].contentWindow.location;
+                                opac_url = opac_url.toString();
+                                if (opac_url.match(/eg\/opac\/record\/\d+/) || opac_url.match(/\/skin\/default\/xml\/rdetail.xml\?r=\d+/)) {
+                                        bibURLs.push(urls.XUL_OPAC_WRAPPER + '?opac_url=' + window.escape( opac_url ) + '&show_nav_buttons=false,&default_view=marc_edit');
+                                    }
+                            }
+                    }
+                }
+            }
+         }
+         return bibURLs;
     }
 }
 
index b7f3eef..9fe3ded 100644 (file)
@@ -15,6 +15,8 @@
     <command id="cmd_close_all_tabs" />
     <command id="cmd_shutdown" />
     <command id="cmd_portal" />
+    <command id="cmd_open_record_windows_horizontal" />
+    <command id="cmd_open_record_windows_vertical" />
 
     <command id="cmd_edit_copy_buckets" />
     <command id="cmd_edit_volume_buckets" />
         <menuitem label="&staff.main.menu.file.close_tab.label;" accesskey="&staff.main.menu.file.close_tab.accesskey;" command="cmd_close_tab"/>
         <menuitem label="&staff.main.menu.tabs.close;" accesskey="&staff.main.menu.tabs.close.accesskey;" command="cmd_close_all_tabs"/>
         <menuitem label="&staff.main.menu.file.close.label;" accesskey="&staff.main.menu.file.close.accesskey;" command="cmd_close_window"/>
+        <menuitem label="&staff.main.menu.file.open.record.windows.vertical;" command="cmd_open_record_windows_vertical"/>
+        <menuitem label="&staff.main.menu.file.open.record.windows.horizontal;" command="cmd_open_record_windows_horizontal"/>
         <menuseparator />
         <menuitem label="&staff.main.menu.quit;" accesskey="&staff.main.menu.quit.accesskey;" command="cmd_shutdown"/>
     </menupopup>