Commit 29d661b4 authored by dje's avatar dje
Browse files

update image viewer

parent f4723239
Loading
Loading
Loading
Loading
+1 −0
Changes for package.json: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
  "scripts": {},
  "dependencies": {
    "install": "^0.12.1",
    "openseadragon": "^2.4.0",
    "readline": "^1.3.0",
    "xmldom": "^0.1.27"
  }
+22 −12
Changes for plugins/img_viewer/img_viewer.js: 22 added lines, 12 removed lines.
Original line number Diff line number Diff line
$(document).ready(function(){
  $('body').prepend("<div id='img_dialog_wrap' title='Image viewer'></div>");
  //$('body').prepend("<div id='img_dialog_wrap' title='Image viewer'></div>");
  $('body').prepend('<div id="img_dialog_wrap" class="modal" tabindex="-1" role="dialog">'+
            '<div class="modal-dialog" role="document">'+
              '<div class="modal-content">'+
                '<div class="modal-header">'+
                  '<h5 class="modal-title">Visionneuse</h5>'+
                  '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'+
                    '<span aria-hidden="true">&times;</span>'+
                  '</button>'+
                '</div>'+
                '<div class="modal-body">'+
                  '<p>Modal body text goes here.</p>'+
                '</div>'+
                '<div class="modal-footer">'+
                  '<button type="button" class="btn btn-secondary" data-dismiss="modal">ok</button>'+
                '</div>'+
              '</div>'+
            '</div>'+
          '</div>');
  $('#img_dialog_wrap').hide();
  $('.viewable').css('cursor', 'pointer')
})

function openImageInDialog(href, source){
  
  $('#img_dialog_wrap').load(href).dialog({
    position: {
      my: "center",
      at: "center",
      of: source ? source : window
    },
    height: 650,
    width: 900,
  
  });
  console.log(href)
  $('#img_dialog_wrap .modal-body').load(href);
  $('#img_dialog_wrap').modal();
}

MAX.openImageInDialog = openImageInDialog
 No newline at end of file
+13 −14
Changes for plugins/img_viewer/img_viewer.xqm: 13 added lines, 14 removed lines.
Original line number Diff line number Diff line
@@ -11,20 +11,20 @@ declare variable $max.plugin.img_viewer:IMG_HEIGHT_PARAMETER := "viewerHeight";
declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$projectId}/plugins/img_viewer/{$path=.+}/{$img}")
function max.plugin.img_viewer:searchPage($projectId, $path, $img){
%rest:path("/{$projectId}/plugins/img_viewer/{$path=.+}/{$img}")
function max.plugin.img_viewer:viewer($projectId, $path, $img){

  let $tileSourcesPath := max.config:getBaseURI() 
                            ||"/"|| $projectId ||"/"|| $path ||"/"|| $img ||".dzi"
  return 
  <div id='img_viewer'>
    <div id="openseadragon1" style="width: 800px; height: 600px;"></div>
    <script src="{max.config:getBaseURI() || '/'||$projectId|| '/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/openseadragon.min.js'}">
    <script src="{max.config:getBaseURI() || $projectId|| '/core/ui/js/openseadragon.min.js'}">
    </script>
    <script type="text/javascript">{
      "var viewer = OpenSeadragon({
          id: 'openseadragon1',
          prefixUrl: '"||max.config:getBaseURI()||'/'||$projectId||"/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/images/',
          prefixUrl: '"||max.config:getBaseURI()|| $projectId||"/core/ui/lib/openseadragon/images/',
          tileSources: '" || $tileSourcesPath || "'
      });"}
    </script>
@@ -39,7 +39,7 @@ function max.plugin.img_viewer:searchPage($projectId, $path, $img){
declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$projectId}/plugins/img_viewer/simple_gallery/{$path=.+}")
%rest:path("/{$projectId}/plugins/img_viewer/simple_gallery/{$path=.+}")
function max.plugin.img_viewer:simpleGallery($projectId, $path){
                                           
  let $tileSources :=
@@ -48,9 +48,9 @@ function max.plugin.img_viewer:simpleGallery($projectId, $path){
  return 
  <html>
    <head>
      <script src="{max.config:getBaseURI() || '/'||$projectId||'/core/ui/js/lib/jquery/dist/jquery.min.js'}">
      <script src="{max.config:getBaseURI() || '/'||$projectId||'/core/ui/lib/jquery.min.js'}">
      </script>
      <script src="{max.config:getBaseURI() || '/'||$projectId||'/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/openseadragon.min.js'}">
      <script src="{max.config:getBaseURI() || '/'||$projectId||'/core/ui/lib/openseadragon/openseadragon.min.js'}">
      </script>
    </head>
    <div id='img_viewer'>
@@ -60,7 +60,7 @@ function max.plugin.img_viewer:simpleGallery($projectId, $path){
        <script type="text/javascript">{
      "var viewer = OpenSeadragon({
          id: 'openseadragon',
          prefixUrl: '"||max.config:getBaseURI()||'/'||$projectId||"/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/images/',
          prefixUrl: '"||max.config:getBaseURI()||'/'||$projectId||"/core/ui/lib/openseadragon/images/',
          tileSources: ["||string-join($tileSources,'')||"],
        sequenceMode: true,
        showReferenceStrip: true,
@@ -76,18 +76,18 @@ function max.plugin.img_viewer:simpleGallery($projectId, $path){
declare
%rest:GET
%output:method("html")
%rest:path("/editions/{$projectId}/plugins/img_viewer/single_image/{$img=.+}")
%rest:path("/{$projectId}/plugins/img_viewer/single_image/{$img=.+}")
function max.plugin.img_viewer:single_image($projectId, $img){
let $imgPath:= max.config:getBaseURI() ||"/"|| $projectId || "/"|| $img
let $imgPath:= max.config:getBaseURI() || $projectId || "/"|| $img
  return 
  <div id='img_viewer'>
    <div id="openseadragon1" style="width: 800px; height: 600px;"></div>
    <script src="{max.config:getBaseURI() || '/' || $projectId ||'/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/openseadragon.min.js'}">
    <div id="openseadragon1" style="width: {max.plugin.img_viewer:getViewerWidth($projectId)}; height: {max.plugin.img_viewer:getViewerHeight($projectId)};"></div>
    <script src="{max.config:getBaseURI() || $projectId ||'/core/ui/lib/openseadragon/openseadragon.min.js'}">
    </script>
    <script type="text/javascript">{
      "var viewer = OpenSeadragon({
          id: 'openseadragon1',
          prefixUrl: '"||max.config:getBaseURI()||"/"|| $projectId || "/core/ui/js/lib/openseadragon/built-openseadragon/openseadragon/images/',
          prefixUrl: '"||max.config:getBaseURI()||$projectId || "/core/ui/lib/openseadragon/images/',
          tileSources: {type:'image', url:'"||$imgPath||"'}
      });"}
    </script>
@@ -96,7 +96,6 @@ let $imgPath:= max.config:getBaseURI() ||"/"|| $projectId || "/"|| $img
};



(:returns viewer width from project configuration:)
declare %private function max.plugin.img_viewer:getViewerWidth($projectId){
  max.config:getPluginByName($projectId, $max.plugin.img_viewer:PLUGIN_ID)//parameter
+1 −1
Changes for tools/demo/demo_lorem_config_inc.xml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
     <plugin name="img_viewer">
       <parameters>
         <!--@xsl(default:false): added to xslt parameters map if true -->
         <parameter key="imagesRepository" value="ui/images/tiles/" xsl="true"/>
         <parameter key="imagesRepository" value="ui/images/" xsl="true"/>
         <parameter key="viewerWidth" value="400px"/>
         <parameter key="viewerHeight" value="600px"/>
       </parameters>