# HG changeset patch # User hertzhaft # Date 1332799280 -7200 # Node ID 6488318df736e187fbb3d27e73ad634d1287efee # Parent 86ba65b86d52ac501bc429955d6727581d7ae29c stuff for svg testing diff -r 86ba65b86d52 -r 6488318df736 webapp/src/main/webapp/jquery/jquery-test-svg.html --- a/webapp/src/main/webapp/jquery/jquery-test-svg.html Mon Mar 26 23:22:33 2012 +0200 +++ b/webapp/src/main/webapp/jquery/jquery-test-svg.html Tue Mar 27 00:01:20 2012 +0200 @@ -2,7 +2,7 @@ - jQuery.digilibSVG test + jquery.digilib.svg.js test @@ -19,8 +19,8 @@ - - + + @@ -40,7 +43,13 @@

digilib doesn't work! Please switch on Javascript or notify the server administrator!

-
DEBUG
+ + about + +
+ +
+ diff -r 86ba65b86d52 -r 6488318df736 webapp/src/main/webapp/jquery/jquery.digilib.svg.css --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.svg.css Tue Mar 27 00:01:20 2012 +0200 @@ -0,0 +1,12 @@ +/* + * CSS style file for jQuery digilib + * + * Martin Raspe, Robert Casties, 26.3.2012 + */ + +#dl_svgdiv img { + width: 700px; + height: 200px; + position: absolute; + top: 10px; +} diff -r 86ba65b86d52 -r 6488318df736 webapp/src/main/webapp/jquery/jquery.digilib.svg.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.svg.js Tue Mar 27 00:01:20 2012 +0200 @@ -0,0 +1,122 @@ +/* Copyright (c) 2011 Martin Raspe, Robert Casties + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU Lesser General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public License +along with this program. If not, see . + +Authors: + Martin Raspe, Robert Casties, 26.3.2012 +*/ + +/** + * digilib SVG plugin (display a SVG on top if scaler image and zoom/rotate/mirror etc.) +**/ + +/* jslint browser: true, debug: true, forin: true +*/ + +(function($) { + + // plugin object with digilib data + var digilib = null; + // the functions made available by digilib + var fn = null; + // affine geometry plugin + var geom = null; + + var defaults = {}; + + var actions = { + "test" : function(options) { + var onLoadXML = function (xml) { + settings.xml = xml; + settings.$toolBar = setupToolBar(settings); + $digilib.each(function() { + var $elem = $(this); + $elem.data(pluginName, settings); + }); + }; + var onLoadScalerImg = function () { + var $svgDiv = $('
'); + $('body').append($svgDiv); + // size SVG div like scaler img + var $scalerImg = $digilib.find('img.pic'); + var scalerImgRect = geom.rectangle($scalerImg); + scalerImgRect.adjustDiv($svgDiv); + console.debug('$svgDiv', scalerImgRect); + var $svg = $svgDiv.svg({ + 'onLoad' : drawInitial + }); + settings.$elem = $digilib; + settings.$svgDiv = $svgDiv; + settings.$svg = $svg; + // set SVG data + $svg.data('digilib', data); + $svg.data(pluginName, settings); + }; + // fetch the XML measuring unit list + $.ajax({ + type : "GET", + url : "svg/archimedes.xml", + dataType : "xml", + success : onLoadXML + }); + data.$img.load(onLoadScalerImg); + return this; + } + }; + + // plugin installation called by digilib on plugin object. + var install = function (plugin) { + digilib = plugin; + console.debug('installing svg plugin. digilib:', digilib); + fn = digilib.fn; + // import geometry classes + geom = fn.geometry; + // add defaults, actions, buttons + $.extend(true, digilib.defaults, defaults); // make deep copy + $.extend(digilib.actions, actions); + // export functions + // fn.test = test; + }; + + // plugin initialization + var init = function (data) { + console.debug('initialising digilibSVG plugin. data:', data); + var $data = $(data); + $data.bind('setup', handleSetup); + }; + + var handleSetup = function (evt) { + console.debug("svg: handleSetup"); + var data = this; + var settings = data.settings; + }; + + // plugin object with name and init + // shared objects filled by digilib on registration + var plugin = { + name : 'svg', + install : install, + init : init, + buttons : {}, + actions : {}, + fn : {}, + plugins : {} + }; + + if ($.fn.digilib == null) { + $.error("jquery.digilib.svg must be loaded after jquery.digilib!"); + } else { + $.fn.digilib('plugin', plugin); + } +})(jQuery); diff -r 86ba65b86d52 -r 6488318df736 webapp/src/main/webapp/jquery/test.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/jquery/test.svg Tue Mar 27 00:01:20 2012 +0200 @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff -r 86ba65b86d52 -r 6488318df736 webapp/src/main/webapp/jquery/test1.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/webapp/src/main/webapp/jquery/test1.svg Tue Mar 27 00:01:20 2012 +0200 @@ -0,0 +1,130 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +