diff --git a/lib/sanitizer.rb b/lib/sanitizer.rb index 98d42d8a..d1c71ed3 100644 --- a/lib/sanitizer.rb +++ b/lib/sanitizer.rb @@ -48,7 +48,8 @@ module Sanitizer svg_attributes = Set.new %w[accent-height accumulate additive alphabetic arabic-form ascent attributeName attributeType baseProfile bbox begin - by calcMode cap-height class clip-path clip-rule color color-rendering + by calcMode cap-height class clip-path clip-rule color + color-interpolation-filters color-rendering content cx cy d dx dy descent display dur end fill fill-opacity fill-rule filterRes filterUnits font-family font-size font-stretch font-style font-variant font-weight from fx fy g1 g2 glyph-name gradientUnits diff --git a/public/javascripts/page_helper.js b/public/javascripts/page_helper.js index 3362199c..6d945a14 100644 --- a/public/javascripts/page_helper.js +++ b/public/javascripts/page_helper.js @@ -86,6 +86,7 @@ function setupSVGedit(path){ editor.addEventListener("load", function() { editor.svgEditor.setCustomHandlers({ 'save': function(window,svg){ + editor.svgEditor.setConfig({no_save_warning: true}); window.opener.postMessage(svg, window.location.protocol + '//' + window.location.host); window.close(); } diff --git a/public/svg-edit/Makefile b/public/svg-edit/Makefile index 3446a13a..35bfa425 100644 --- a/public/svg-edit/Makefile +++ b/public/svg-edit/Makefile @@ -1,8 +1,9 @@ NAME=svg-edit VERSION=2.5 -MAKEDOCS=naturaldocs/NaturalDocs PACKAGE=$(NAME)-$(VERSION) -YUI=build/yuicompressor.jar +MAKEDOCS=naturaldocs/NaturalDocs +CLOSURE=build/tools/closure-compiler.jar +YUICOMPRESS=build/tools/yuicompressor.jar ZIP=zip all: release firefox opera @@ -10,18 +11,21 @@ all: release firefox opera build/$(PACKAGE): rm -rf config mkdir config - $(MAKEDOCS) -i editor/ -o html docs/ -p config/ -oft -r + if [ -x $(MAKEDOCS) ] ; then $(MAKEDOCS) -i editor/ -o html docs/ -p config/ -oft -r ; fi mkdir -p build/$(PACKAGE) cp -r editor/* build/$(PACKAGE) -find build/$(PACKAGE) -name .svn -type d -exec rm -rf {} \; # minify spin button - java -jar $(YUI) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.js > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.js + java -jar $(YUICOMPRESS) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.js > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.js + java -jar $(CLOSURE) --js build/$(PACKAGE)/spinbtn/JQuerySpinBtn.js --js_output_file build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min-closure.js # minify SVG-edit files - java -jar $(YUI) build/$(PACKAGE)/svg-editor.js > build/$(PACKAGE)/svg-editor.min.js - java -jar $(YUI) build/$(PACKAGE)/svgcanvas.js > build/$(PACKAGE)/svgcanvas.min.js + java -jar $(YUICOMPRESS) build/$(PACKAGE)/svg-editor.js > build/$(PACKAGE)/svg-editor.min.js + java -jar $(CLOSURE) --js build/$(PACKAGE)/svg-editor.js --js_output_file build/$(PACKAGE)/svg-editor.min-closure.js + java -jar $(YUICOMPRESS) build/$(PACKAGE)/svgcanvas.js > build/$(PACKAGE)/svgcanvas.min.js + java -jar $(CLOSURE) --js build/$(PACKAGE)/svgcanvas.js --js_output_file build/$(PACKAGE)/svgcanvas.min-closure.js # CSS files do not work remotely -# java -jar $(YUI) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.css > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.css -# java -jar $(YUI) build/$(PACKAGE)/svg-editor.css > build/$(PACKAGE)/svg-editor.min.css +# java -jar $(YUICOMPRESS) build/$(PACKAGE)/spinbtn/JQuerySpinBtn.css > build/$(PACKAGE)/spinbtn/JQuerySpinBtn.min.css +# java -jar $(YUICOMPRESS) build/$(PACKAGE)/svg-editor.css > build/$(PACKAGE)/svg-editor.min.css release: build/$(PACKAGE) cd build ; $(ZIP) $(PACKAGE).zip -r $(PACKAGE) ; cd .. diff --git a/public/svg-edit/build/tools/closure-compiler.jar b/public/svg-edit/build/tools/closure-compiler.jar new file mode 100644 index 00000000..7374f2d3 Binary files /dev/null and b/public/svg-edit/build/tools/closure-compiler.jar differ diff --git a/public/svg-edit/build/yuicompressor.jar b/public/svg-edit/build/tools/yuicompressor.jar similarity index 100% rename from public/svg-edit/build/yuicompressor.jar rename to public/svg-edit/build/tools/yuicompressor.jar diff --git a/public/svg-edit/editor/extensions/ext-eyedropper.js b/public/svg-edit/editor/extensions/ext-eyedropper.js new file mode 100644 index 00000000..35341c65 --- /dev/null +++ b/public/svg-edit/editor/extensions/ext-eyedropper.js @@ -0,0 +1,90 @@ +/* + * ext-eyedropper.js + * + * Licensed under the Apache License, Version 2 + * + * Copyright(c) 2010 Jeff Schiller + * + */ + +svgEditor.addExtension("eyedropper", function(S) { + var svgcontent = S.svgcontent, + svgns = "http://www.w3.org/2000/svg", + svgdoc = S.svgroot.parentNode.ownerDocument, + ChangeElementCommand = svgCanvas.getPrivateMethods().ChangeElementCommand, + addToHistory = svgCanvas.getPrivateMethods().addCommandToHistory, + currentStyle = {fillPaint: "red", fillOpacity: 1.0, + strokePaint: "black", strokeOpacity: 1.0, + strokeWidth: 5, strokeDashArray: null, + opacity: 1.0 }; + + return { + name: "eyedropper", + svgicons: "extensions/eyedropper-icon.xml", + buttons: [{ + id: "tool_eyedropper", + type: "mode", + title: "Eye Dropper Tool", + events: { + "click": function() { + svgCanvas.setMode("eyedropper"); + } + } + }], + + // if we have selected an element, grab its paint and enable the eye dropper button + selectedChanged: function(opts) { + // if we are in eyedropper mode, we don't want to disable the eye-dropper tool + var mode = svgCanvas.getMode(); + if (mode == "eyedropper") return; + + var elem = null; + var tool = $('#tool_eyedropper'); + // enable-eye-dropper if one element is selected + if (opts.elems.length == 1 && opts.elems[0] && + $.inArray(opts.elems[0].nodeName, ['svg', 'g', 'use']) == -1) + { + elem = opts.elems[0]; + tool.removeClass('disabled'); + // grab the current style + currentStyle.fillPaint = elem.getAttribute("fill") || "black"; + currentStyle.fillOpacity = elem.getAttribute("fill-opacity") || 1.0; + currentStyle.strokePaint = elem.getAttribute("stroke"); + currentStyle.strokeOpacity = elem.getAttribute("stroke-opacity") || 1.0; + currentStyle.strokeWidth = elem.getAttribute("stroke-width"); + currentStyle.strokeDashArray = elem.getAttribute("stroke-dasharray"); + currentStyle.opacity = elem.getAttribute("opacity") || 1.0; + } + // disable eye-dropper tool + else { + tool.addClass('disabled'); + } + }, + + mouseDown: function(opts) { + var mode = svgCanvas.getMode(); + if (mode == "eyedropper") { + var e = opts.event; + var target = e.target; + if ($.inArray(target.nodeName, ['svg', 'g', 'use']) == -1) { + var changes = {}; + + var change = function(elem, attrname, newvalue) { + changes[attrname] = elem.getAttribute(attrname); + elem.setAttribute(attrname, newvalue); + }; + + if (currentStyle.fillPaint) change(target, "fill", currentStyle.fillPaint); + if (currentStyle.fillOpacity) change(target, "fill-opacity", currentStyle.fillOpacity); + if (currentStyle.strokePaint) change(target, "stroke", currentStyle.strokePaint); + if (currentStyle.strokeOpacity) change(target, "stroke-opacity", currentStyle.strokeOpacity); + if (currentStyle.strokeWidth) change(target, "stroke-width", currentStyle.strokeWidth); + if (currentStyle.strokeDashArray) change(target, "stroke-dasharray", currentStyle.strokeDashArray); + if (currentStyle.opacity) change(target, "opacity", currentStyle.opacity); + + addToHistory(new ChangeElementCommand(target, changes)); + } + } + }, + }; +}); diff --git a/public/svg-edit/editor/extensions/eyedropper-icon.xml b/public/svg-edit/editor/extensions/eyedropper-icon.xml new file mode 100644 index 00000000..c05576aa --- /dev/null +++ b/public/svg-edit/editor/extensions/eyedropper-icon.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + Layer 1 + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/svg-edit/editor/extensions/eyedropper.png b/public/svg-edit/editor/extensions/eyedropper.png new file mode 100644 index 00000000..61987c4b Binary files /dev/null and b/public/svg-edit/editor/extensions/eyedropper.png differ diff --git a/public/svg-edit/editor/extensions/helloworld-icon.xml b/public/svg-edit/editor/extensions/helloworld-icon.xml index 68b6d964..0b1ba1a0 100644 --- a/public/svg-edit/editor/extensions/helloworld-icon.xml +++ b/public/svg-edit/editor/extensions/helloworld-icon.xml @@ -5,11 +5,10 @@ in the extension. The SVG inside the group makes up the actual icon, and needs use a viewBox instead of width/height for it to scale properly. - Multiple icons can be included, each within their own group. A final element - with ID "svg_eof" must be included too. + Multiple icons can be included, each within their own group. --> - + Layer 1 @@ -19,5 +18,4 @@ - \ No newline at end of file diff --git a/public/svg-edit/editor/jquery-ui/jquery-ui-1.8.custom.min.js b/public/svg-edit/editor/jquery-ui/jquery-ui-1.8.custom.min.js index 420006a2..6e660216 100755 --- a/public/svg-edit/editor/jquery-ui/jquery-ui-1.8.custom.min.js +++ b/public/svg-edit/editor/jquery-ui/jquery-ui-1.8.custom.min.js @@ -1,12 +1,12 @@ -/*! - * jQuery UI 1.8 - * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://docs.jquery.com/UI - */ /* +/*! + * jQuery UI 1.8 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI + *//* * jQuery UI 1.8 * * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) @@ -15,15 +15,15 @@ * * http://docs.jquery.com/UI */ -jQuery.ui||(function(a){a.ui={version:"1.8",plugin:{add:function(c,d,f){var e=a.ui[c].prototype;for(var b in f){e.plugins[b]=e.plugins[b]||[];e.plugins[b].push([d,f[b]])}},call:function(b,d,c){var f=b.plugins[d];if(!f||!b.element[0].parentNode){return}for(var e=0;e0){return true}e[b]=1;d=(e[b]>0);e[b]=0;return d},isOverAxis:function(c,b,d){return(c>b)&&(c<(b+d))},isOver:function(g,c,f,e,b,d){return a.ui.isOverAxis(g,f,b)&&a.ui.isOverAxis(c,e,d)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};a.fn.extend({_focus:a.fn.focus,focus:function(b,c){return typeof b==="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus();(c&&c.call(d))},b)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var b;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){b=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{b=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!b.length?a(document):b},zIndex:function(e){if(e!==undefined){return this.css("zIndex",e)}if(this.length){var c=a(this[0]),b,d;while(c.length&&c[0]!==document){b=c.css("position");if(b=="absolute"||b=="relative"||b=="fixed"){d=parseInt(c.css("zIndex"));if(!isNaN(d)&&d!=0){return d}}c=c.parent()}}return 0}});a.extend(a.expr[":"],{data:function(d,c,b){return !!a.data(d,b[3])},focusable:function(c){var d=c.nodeName.toLowerCase(),b=a.attr(c,"tabindex");return(/input|select|textarea|button|object/.test(d)?!c.disabled:"a"==d||"area"==d?c.href||!isNaN(b):!isNaN(b))&&!a(c)["area"==d?"parents":"closest"](":hidden").length},tabbable:function(c){var b=a.attr(c,"tabindex");return(isNaN(b)||b>=0)&&a(c).is(":focusable")}})})(jQuery);;/*! - * jQuery UI Widget 1.8 - * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://docs.jquery.com/UI/Widget - */ /* +jQuery.ui||(function(a){a.ui={version:"1.8",plugin:{add:function(c,d,f){var e=a.ui[c].prototype;for(var b in f){e.plugins[b]=e.plugins[b]||[];e.plugins[b].push([d,f[b]])}},call:function(b,d,c){var f=b.plugins[d];if(!f||!b.element[0].parentNode){return}for(var e=0;e0){return true}e[b]=1;d=(e[b]>0);e[b]=0;return d},isOverAxis:function(c,b,d){return(c>b)&&(c<(b+d))},isOver:function(g,c,f,e,b,d){return a.ui.isOverAxis(g,f,b)&&a.ui.isOverAxis(c,e,d)},keyCode:{BACKSPACE:8,CAPS_LOCK:20,COMMA:188,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38}};a.fn.extend({_focus:a.fn.focus,focus:function(b,c){return typeof b==="number"?this.each(function(){var d=this;setTimeout(function(){a(d).focus();(c&&c.call(d))},b)}):this._focus.apply(this,arguments)},enableSelection:function(){return this.attr("unselectable","off").css("MozUserSelect","").unbind("selectstart.ui")},disableSelection:function(){return this.attr("unselectable","on").css("MozUserSelect","none").bind("selectstart.ui",function(){return false})},scrollParent:function(){var b;if((a.browser.msie&&(/(static|relative)/).test(this.css("position")))||(/absolute/).test(this.css("position"))){b=this.parents().filter(function(){return(/(relative|absolute|fixed)/).test(a.curCSS(this,"position",1))&&(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}else{b=this.parents().filter(function(){return(/(auto|scroll)/).test(a.curCSS(this,"overflow",1)+a.curCSS(this,"overflow-y",1)+a.curCSS(this,"overflow-x",1))}).eq(0)}return(/fixed/).test(this.css("position"))||!b.length?a(document):b},zIndex:function(e){if(e!==undefined){return this.css("zIndex",e)}if(this.length){var c=a(this[0]),b,d;while(c.length&&c[0]!==document){b=c.css("position");if(b=="absolute"||b=="relative"||b=="fixed"){d=parseInt(c.css("zIndex"));if(!isNaN(d)&&d!=0){return d}}c=c.parent()}}return 0}});a.extend(a.expr[":"],{data:function(d,c,b){return !!a.data(d,b[3])},focusable:function(c){var d=c.nodeName.toLowerCase(),b=a.attr(c,"tabindex");return(/input|select|textarea|button|object/.test(d)?!c.disabled:"a"==d||"area"==d?c.href||!isNaN(b):!isNaN(b))&&!a(c)["area"==d?"parents":"closest"](":hidden").length},tabbable:function(c){var b=a.attr(c,"tabindex");return(isNaN(b)||b>=0)&&a(c).is(":focusable")}})})(jQuery);;/*! + * jQuery UI Widget 1.8 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Widget + *//* * jQuery UI Widget 1.8 * * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) @@ -32,18 +32,18 @@ jQuery.ui||(function(a){a.ui={version:"1.8",plugin:{add:function(c,d,f){var e=a. * * http://docs.jquery.com/UI/Widget */ -(function(b){var a=b.fn.remove;b.fn.remove=function(c,d){return this.each(function(){if(!d){if(!c||b.filter(c,[this]).length){b("*",this).add(this).each(function(){b(this).triggerHandler("remove")})}}return a.call(b(this),c,d)})};b.widget=function(d,f,c){var e=d.split(".")[0],h;d=d.split(".")[1];h=e+"-"+d;if(!c){c=f;f=b.Widget}b.expr[":"][h]=function(i){return !!b.data(i,d)};b[e]=b[e]||{};b[e][d]=function(i,j){if(arguments.length){this._createWidget(i,j)}};var g=new f();g.options=b.extend({},g.options);b[e][d].prototype=b.extend(true,g,{namespace:e,widgetName:d,widgetEventPrefix:b[e][d].prototype.widgetEventPrefix||d,widgetBaseClass:h},c);b.widget.bridge(d,b[e][d])};b.widget.bridge=function(d,c){b.fn[d]=function(g){var e=typeof g==="string",f=Array.prototype.slice.call(arguments,1),h=this;g=!e&&f.length?b.extend.apply(null,[true,g].concat(f)):g;if(e&&g.substring(0,1)==="_"){return h}if(e){this.each(function(){var i=b.data(this,d),j=i&&b.isFunction(i[g])?i[g].apply(i,f):i;if(j!==i&&j!==undefined){h=j;return false}})}else{this.each(function(){var i=b.data(this,d);if(i){if(g){i.option(g)}i._init()}else{b.data(this,d,new c(g,this))}})}return h}};b.Widget=function(c,d){if(arguments.length){this._createWidget(c,d)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(d,e){this.element=b(e).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(e)[this.widgetName],d);var c=this;this.element.bind("remove."+this.widgetName,function(){c.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled")},widget:function(){return this.element},option:function(e,f){var d=e,c=this;if(arguments.length===0){return b.extend({},c.options)}if(typeof e==="string"){if(f===undefined){return this.options[e]}d={};d[e]=f}b.each(d,function(g,h){c._setOption(g,h)});return c},_setOption:function(c,d){this.options[c]=d;if(c==="disabled"){this.widget()[d?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",d)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(d,e,f){var h=this.options[d];e=b.Event(e);e.type=(d===this.widgetEventPrefix?d:this.widgetEventPrefix+d).toLowerCase();f=f||{};if(e.originalEvent){for(var c=b.event.props.length,g;c;){g=b.event.props[--c];e[g]=e.originalEvent[g]}}this.element.trigger(e,f);return !(b.isFunction(h)&&h.call(this.element[0],e,f)===false||e.isDefaultPrevented())}}})(jQuery);;/*! - * jQuery UI Mouse 1.8 - * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://docs.jquery.com/UI/Mouse - * - * Depends: - * jquery.ui.widget.js - */ /* +(function(b){var a=b.fn.remove;b.fn.remove=function(c,d){return this.each(function(){if(!d){if(!c||b.filter(c,[this]).length){b("*",this).add(this).each(function(){b(this).triggerHandler("remove")})}}return a.call(b(this),c,d)})};b.widget=function(d,f,c){var e=d.split(".")[0],h;d=d.split(".")[1];h=e+"-"+d;if(!c){c=f;f=b.Widget}b.expr[":"][h]=function(i){return !!b.data(i,d)};b[e]=b[e]||{};b[e][d]=function(i,j){if(arguments.length){this._createWidget(i,j)}};var g=new f();g.options=b.extend({},g.options);b[e][d].prototype=b.extend(true,g,{namespace:e,widgetName:d,widgetEventPrefix:b[e][d].prototype.widgetEventPrefix||d,widgetBaseClass:h},c);b.widget.bridge(d,b[e][d])};b.widget.bridge=function(d,c){b.fn[d]=function(g){var e=typeof g==="string",f=Array.prototype.slice.call(arguments,1),h=this;g=!e&&f.length?b.extend.apply(null,[true,g].concat(f)):g;if(e&&g.substring(0,1)==="_"){return h}if(e){this.each(function(){var i=b.data(this,d),j=i&&b.isFunction(i[g])?i[g].apply(i,f):i;if(j!==i&&j!==undefined){h=j;return false}})}else{this.each(function(){var i=b.data(this,d);if(i){if(g){i.option(g)}i._init()}else{b.data(this,d,new c(g,this))}})}return h}};b.Widget=function(c,d){if(arguments.length){this._createWidget(c,d)}};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(d,e){this.element=b(e).data(this.widgetName,this);this.options=b.extend(true,{},this.options,b.metadata&&b.metadata.get(e)[this.widgetName],d);var c=this;this.element.bind("remove."+this.widgetName,function(){c.destroy()});this._create();this._init()},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled")},widget:function(){return this.element},option:function(e,f){var d=e,c=this;if(arguments.length===0){return b.extend({},c.options)}if(typeof e==="string"){if(f===undefined){return this.options[e]}d={};d[e]=f}b.each(d,function(g,h){c._setOption(g,h)});return c},_setOption:function(c,d){this.options[c]=d;if(c==="disabled"){this.widget()[d?"addClass":"removeClass"](this.widgetBaseClass+"-disabled "+this.namespace+"-state-disabled").attr("aria-disabled",d)}return this},enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(d,e,f){var h=this.options[d];e=b.Event(e);e.type=(d===this.widgetEventPrefix?d:this.widgetEventPrefix+d).toLowerCase();f=f||{};if(e.originalEvent){for(var c=b.event.props.length,g;c;){g=b.event.props[--c];e[g]=e.originalEvent[g]}}this.element.trigger(e,f);return !(b.isFunction(h)&&h.call(this.element[0],e,f)===false||e.isDefaultPrevented())}}})(jQuery);;/*! + * jQuery UI Mouse 1.8 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Mouse + * + * Depends: + * jquery.ui.widget.js + *//* * jQuery UI Mouse 1.8 * * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) @@ -55,30 +55,30 @@ jQuery.ui||(function(a){a.ui={version:"1.8",plugin:{add:function(c,d,f){var e=a. * Depends: * jquery.ui.widget.js */ -(function(a){a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(c){return b._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(b._preventClickEvent){b._preventClickEvent=false;c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(d){d.originalEvent=d.originalEvent||{};if(d.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(d));this._mouseDownEvent=d;var c=this,e=(d.which==1),b=(typeof this.options.cancel=="string"?a(d.target).parents().add(d.target).filter(this.options.cancel).length:false);if(!e||b||!this._mouseCapture(d)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(d)!==false);if(!this._mouseStarted){d.preventDefault();return true}}this._mouseMoveDelegate=function(f){return c._mouseMove(f)};this._mouseUpDelegate=function(f){return c._mouseUp(f)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(a.browser.safari||d.preventDefault());d.originalEvent.mouseHandled=true;return true},_mouseMove:function(b){if(a.browser.msie&&!b.button){return this._mouseUp(b)}if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,b)!==false);(this._mouseStarted?this._mouseDrag(b):this._mouseUp(b))}return !this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(b.target==this._mouseDownEvent.target);this._mouseStop(b)}return false},_mouseDistanceMet:function(b){return(Math.max(Math.abs(this._mouseDownEvent.pageX-b.pageX),Math.abs(this._mouseDownEvent.pageY-b.pageY))>=this.options.distance)},_mouseDelayMet:function(b){return this.mouseDelayMet},_mouseStart:function(b){},_mouseDrag:function(b){},_mouseStop:function(b){},_mouseCapture:function(b){return true}})})(jQuery);;/* - * jQuery UI Draggable 1.8 - * - * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT (MIT-LICENSE.txt) - * and GPL (GPL-LICENSE.txt) licenses. - * - * http://docs.jquery.com/UI/Draggables - * - * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js - */ (function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative"}(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit()},destroy:function(){if(!this.element.data("draggable")){return}this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this},_mouseCapture:function(b){var c=this.options;if(this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")){return false}this.handle=this._getHandle(b);if(!this.handle){return false}return true},_mouseStart:function(b){var c=this.options;this.helper=this._createHelper(b);this._cacheHelperProportions();if(a.ui.ddmanager){a.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(b);this.originalPageX=b.pageX;this.originalPageY=b.pageY;(c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt));if(c.containment){this._setContainment()}if(this._trigger("start",b)===false){this._clear();return false}this._cacheHelperProportions();if(a.ui.ddmanager&&!c.dropBehaviour){a.ui.ddmanager.prepareOffsets(this,b)}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(b,true);return true},_mouseDrag:function(b,d){this.position=this._generatePosition(b);this.positionAbs=this._convertPositionTo("absolute");if(!d){var c=this._uiHash();if(this._trigger("drag",b,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(a.ui.ddmanager){a.ui.ddmanager.drag(this,b)}return false},_mouseStop:function(c){var d=false;if(a.ui.ddmanager&&!this.options.dropBehaviour){d=a.ui.ddmanager.drop(this,c)}if(this.dropped){d=this.dropped;this.dropped=false}if(!this.element[0]||!this.element[0].parentNode){return false}if((this.options.revert=="invalid"&&!d)||(this.options.revert=="valid"&&d)||this.options.revert===true||(a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d))){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){if(b._trigger("stop",c)!==false){b._clear()}})}else{if(this._trigger("stop",c)!==false){this._clear()}}return false},cancel:function(){if(this.helper.is(".ui-draggable-dragging")){this._mouseUp({})}else{this._clear()}return this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==b.target){c=true}});return c},_createHelper:function(c){var d=this.options;var b=a.isFunction(d.helper)?a(d.helper.apply(this.element[0],[c])):(d.helper=="clone"?this.element.clone():this.element);if(!b.parents("body").length){b.appendTo((d.appendTo=="parent"?this.element[0].parentNode:d.appendTo))}if(b[0]!=this.element[0]&&!(/(fixed|absolute)/).test(b.css("position"))){b.css("position","absolute")}return b},_adjustOffsetFromHelper:function(b){if(typeof b=="string"){b=b.split(" ")}if(a.isArray(b)){b={left:+b[0],top:+b[1]||0}}if("left" in b){this.offset.click.left=b.left+this.margins.left}if("right" in b){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if("top" in b){this.offset.click.top=b.top+this.margins.top}if("bottom" in b){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])){b.left+=this.scrollParent.scrollLeft();b.top+=this.scrollParent.scrollTop()}if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)){b={top:0,left:0}}return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var b=this.element.position();return{top:b.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if(e.containment=="parent"){e.containment=this.helper[0].parentNode}if(e.containment=="document"||e.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(e.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(e.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!(/^(document|window|parent)$/).test(e.containment)&&e.containment.constructor!=Array){var c=a(e.containment)[0];if(!c){return}var d=a(e.containment).offset();var b=(a(c).css("overflow")!="hidden");this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(b?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(b?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}else{if(e.containment.constructor==Array){this.containment=e.containment}}},_convertPositionTo:function(f,h){if(!h){h=this.position}var c=f=="absolute"?1:-1;var e=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=(/(html|body)/i).test(b[0].tagName);return{top:(h.top+this.offset.relative.top*c+this.offset.parent.top*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(g?0:b.scrollTop()))*c)),left:(h.left+this.offset.relative.left*c+this.offset.parent.left*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:b.scrollLeft())*c))}},_generatePosition:function(e){var h=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,i=(/(html|body)/i).test(b[0].tagName);var d=e.pageX;var c=e.pageY;if(this.originalPosition){if(this.containment){if(e.pageX-this.offset.click.leftthis.containment[2]){d=this.containment[2]+this.offset.click.left}if(e.pageY-this.offset.click.top>this.containment[3]){c=this.containment[3]+this.offset.click.top}}if(h.grid){var g=this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1];c=this.containment?(!(g-this.offset.click.topthis.containment[3])?g:(!(g-this.offset.click.topthis.containment[2])?f:(!(f-this.offset.click.left').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})},stop:function(b,c){a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","opacity",{start:function(c,d){var b=a(d.helper),e=a(this).data("draggable").options;if(b.css("opacity")){e._opacity=b.css("opacity")}b.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._opacity){a(c.helper).css("opacity",d._opacity)}}});a.ui.plugin.add("draggable","scroll",{start:function(c,d){var b=a(this).data("draggable");if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){b.overflowOffset=b.scrollParent.offset()}},drag:function(d,e){var c=a(this).data("draggable"),f=c.options,b=false;if(c.scrollParent[0]!=document&&c.scrollParent[0].tagName!="HTML"){if(!f.axis||f.axis!="x"){if((c.overflowOffset.top+c.scrollParent[0].offsetHeight)-d.pageY=0;v--){var s=g.snapElements[v].left,n=s+g.snapElements[v].width,m=g.snapElements[v].top,A=m+g.snapElements[v].height;if(!((s-y");if(!d.values){d.values=[this._valueMin(),this._valueMin()]}if(d.values.length&&d.values.length!=2){d.values=[d.values[0],d.values[0]]}}else{this.range=b("
")}this.range.appendTo(this.element).addClass("ui-slider-range");if(d.range=="min"||d.range=="max"){this.range.addClass("ui-slider-range-"+d.range)}this.range.addClass("ui-widget-header")}if(b(".ui-slider-handle",this.element).length==0){b('').appendTo(this.element).addClass("ui-slider-handle")}if(d.values&&d.values.length){while(b(".ui-slider-handle",this.element).length').appendTo(this.element).addClass("ui-slider-handle")}}this.handles=b(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).hover(function(){if(!d.disabled){b(this).addClass("ui-state-hover")}},function(){b(this).removeClass("ui-state-hover")}).focus(function(){if(!d.disabled){b(".ui-slider .ui-state-focus").removeClass("ui-state-focus");b(this).addClass("ui-state-focus")}else{b(this).blur()}}).blur(function(){b(this).removeClass("ui-state-focus")});this.handles.each(function(e){b(this).data("index.ui-slider-handle",e)});this.handles.keydown(function(j){var g=true;var f=b(this).data("index.ui-slider-handle");if(c.options.disabled){return}switch(j.keyCode){case b.ui.keyCode.HOME:case b.ui.keyCode.END:case b.ui.keyCode.PAGE_UP:case b.ui.keyCode.PAGE_DOWN:case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:g=false;if(!c._keySliding){c._keySliding=true;b(this).addClass("ui-state-active");c._start(j,f)}break}var h,e,i=c._step();if(c.options.values&&c.options.values.length){h=e=c.values(f)}else{h=e=c.value()}switch(j.keyCode){case b.ui.keyCode.HOME:e=c._valueMin();break;case b.ui.keyCode.END:e=c._valueMax();break;case b.ui.keyCode.PAGE_UP:e=h+((c._valueMax()-c._valueMin())/a);break;case b.ui.keyCode.PAGE_DOWN:e=h-((c._valueMax()-c._valueMin())/a);break;case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:if(h==c._valueMax()){return}e=h+i;break;case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(h==c._valueMin()){return}e=h-i;break}c._slide(j,f,e);return g}).keyup(function(f){var e=b(this).data("index.ui-slider-handle");if(c._keySliding){c._keySliding=false;c._stop(f,e);c._change(f,e);b(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(e){var f=this.options;if(f.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var i={x:e.pageX,y:e.pageY};var k=this._normValueFromMouse(i);var d=this._valueMax()-this._valueMin()+1,g;var l=this,j;this.handles.each(function(m){var n=Math.abs(k-l.values(m));if(d>n){d=n;g=b(this);j=m}});if(f.range==true&&this.values(1)==f.min){g=b(this.handles[++j])}this._start(e,j);this._mouseSliding=true;l._handleIndex=j;g.addClass("ui-state-active").focus();var h=g.offset();var c=!b(e.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=c?{left:0,top:0}:{left:e.pageX-h.left-(g.width()/2),top:e.pageY-h.top-(g.height()/2)-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)};k=this._normValueFromMouse(i);this._slide(e,j,k);this._animateOff=true;return true},_mouseStart:function(c){return true},_mouseDrag:function(e){var c={x:e.pageX,y:e.pageY};var d=this._normValueFromMouse(c);this._slide(e,this._handleIndex,d);return false},_mouseStop:function(c){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(c,this._handleIndex);this._change(c,this._handleIndex);this._handleIndex=null;this._clickOffset=null;this._animateOff=false;return false},_detectOrientation:function(){this.orientation=this.options.orientation=="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var d,i;if("horizontal"==this.orientation){d=this.elementSize.width;i=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{d=this.elementSize.height;i=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}var g=(i/d);if(g>1){g=1}if(g<0){g=0}if("vertical"==this.orientation){g=1-g}var f=this._valueMax()-this._valueMin(),j=g*f,c=j%this.options.step,h=this._valueMin()+j-c;if(c>(this.options.step/2)){h+=this.options.step}return parseFloat(h.toFixed(5))},_start:function(e,d){var c={handle:this.handles[d],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(d);c.values=this.values()}this._trigger("start",e,c)},_slide:function(g,f,e){var h=this.handles[f];if(this.options.values&&this.options.values.length){var c=this.values(f?0:1);if((this.options.values.length==2&&this.options.range===true)&&((f==0&&e>c)||(f==1&&e1){this.options.values[e]=this._trimValue(h);this._refreshValue();this._change(null,e)}if(arguments.length){if(b.isArray(arguments[0])){var g=this.options.values,d=arguments[0];for(var f=0,c=g.length;fthis._valueMax()){c=this._valueMax()}return c},_valueMin:function(){var c=this.options.min;return c},_valueMax:function(){var c=this.options.max;return c},_refreshValue:function(){var g=this.options.range,e=this.options,m=this;var d=(!this._animateOff)?e.animate:false;if(this.options.values&&this.options.values.length){var j,i;this.handles.each(function(q,o){var p=(m.values(q)-m._valueMin())/(m._valueMax()-m._valueMin())*100;var n={};n[m.orientation=="horizontal"?"left":"bottom"]=p+"%";b(this).stop(1,1)[d?"animate":"css"](n,e.animate);if(m.options.range===true){if(m.orientation=="horizontal"){(q==0)&&m.range.stop(1,1)[d?"animate":"css"]({left:p+"%"},e.animate);(q==1)&&m.range[d?"animate":"css"]({width:(p-lastValPercent)+"%"},{queue:false,duration:e.animate})}else{(q==0)&&m.range.stop(1,1)[d?"animate":"css"]({bottom:(p)+"%"},e.animate);(q==1)&&m.range[d?"animate":"css"]({height:(p-lastValPercent)+"%"},{queue:false,duration:e.animate})}}lastValPercent=p})}else{var k=this.value(),h=this._valueMin(),l=this._valueMax(),f=l!=h?(k-h)/(l-h)*100:0;var c={};c[m.orientation=="horizontal"?"left":"bottom"]=f+"%";this.handle.stop(1,1)[d?"animate":"css"](c,e.animate);(g=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[d?"animate":"css"]({width:f+"%"},e.animate);(g=="max")&&(this.orientation=="horizontal")&&this.range[d?"animate":"css"]({width:(100-f)+"%"},{queue:false,duration:e.animate});(g=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[d?"animate":"css"]({height:f+"%"},e.animate);(g=="max")&&(this.orientation=="vertical")&&this.range[d?"animate":"css"]({height:(100-f)+"%"},{queue:false,duration:e.animate})}}});b.extend(b.ui.slider,{version:"1.8"})})(jQuery);; \ No newline at end of file +(function(a){a.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var b=this;this.element.bind("mousedown."+this.widgetName,function(c){return b._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(b._preventClickEvent){b._preventClickEvent=false;c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(d){d.originalEvent=d.originalEvent||{};if(d.originalEvent.mouseHandled){return}(this._mouseStarted&&this._mouseUp(d));this._mouseDownEvent=d;var c=this,e=(d.which==1),b=(typeof this.options.cancel=="string"?a(d.target).parents().add(d.target).filter(this.options.cancel).length:false);if(!e||b||!this._mouseCapture(d)){return true}this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet){this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay)}if(this._mouseDistanceMet(d)&&this._mouseDelayMet(d)){this._mouseStarted=(this._mouseStart(d)!==false);if(!this._mouseStarted){d.preventDefault();return true}}this._mouseMoveDelegate=function(f){return c._mouseMove(f)};this._mouseUpDelegate=function(f){return c._mouseUp(f)};a(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);(a.browser.safari||d.preventDefault());d.originalEvent.mouseHandled=true;return true},_mouseMove:function(b){if(a.browser.msie&&!b.button){return this._mouseUp(b)}if(this._mouseStarted){this._mouseDrag(b);return b.preventDefault()}if(this._mouseDistanceMet(b)&&this._mouseDelayMet(b)){this._mouseStarted=(this._mouseStart(this._mouseDownEvent,b)!==false);(this._mouseStarted?this._mouseDrag(b):this._mouseUp(b))}return !this._mouseStarted},_mouseUp:function(b){a(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;this._preventClickEvent=(b.target==this._mouseDownEvent.target);this._mouseStop(b)}return false},_mouseDistanceMet:function(b){return(Math.max(Math.abs(this._mouseDownEvent.pageX-b.pageX),Math.abs(this._mouseDownEvent.pageY-b.pageY))>=this.options.distance)},_mouseDelayMet:function(b){return this.mouseDelayMet},_mouseStart:function(b){},_mouseDrag:function(b){},_mouseStop:function(b){},_mouseCapture:function(b){return true}})})(jQuery);;/* + * jQuery UI Draggable 1.8 + * + * Copyright (c) 2010 AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Draggables + * + * Depends: + * jquery.ui.core.js + * jquery.ui.mouse.js + * jquery.ui.widget.js + */(function(a){a.widget("ui.draggable",a.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper=="original"&&!(/^(?:r|a|f)/).test(this.element.css("position"))){this.element[0].style.position="relative"}(this.options.addClasses&&this.element.addClass("ui-draggable"));(this.options.disabled&&this.element.addClass("ui-draggable-disabled"));this._mouseInit()},destroy:function(){if(!this.element.data("draggable")){return}this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this},_mouseCapture:function(b){var c=this.options;if(this.helper||c.disabled||a(b.target).is(".ui-resizable-handle")){return false}this.handle=this._getHandle(b);if(!this.handle){return false}return true},_mouseStart:function(b){var c=this.options;this.helper=this._createHelper(b);this._cacheHelperProportions();if(a.ui.ddmanager){a.ui.ddmanager.current=this}this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};a.extend(this.offset,{click:{left:b.pageX-this.offset.left,top:b.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(b);this.originalPageX=b.pageX;this.originalPageY=b.pageY;(c.cursorAt&&this._adjustOffsetFromHelper(c.cursorAt));if(c.containment){this._setContainment()}if(this._trigger("start",b)===false){this._clear();return false}this._cacheHelperProportions();if(a.ui.ddmanager&&!c.dropBehaviour){a.ui.ddmanager.prepareOffsets(this,b)}this.helper.addClass("ui-draggable-dragging");this._mouseDrag(b,true);return true},_mouseDrag:function(b,d){this.position=this._generatePosition(b);this.positionAbs=this._convertPositionTo("absolute");if(!d){var c=this._uiHash();if(this._trigger("drag",b,c)===false){this._mouseUp({});return false}this.position=c.position}if(!this.options.axis||this.options.axis!="y"){this.helper[0].style.left=this.position.left+"px"}if(!this.options.axis||this.options.axis!="x"){this.helper[0].style.top=this.position.top+"px"}if(a.ui.ddmanager){a.ui.ddmanager.drag(this,b)}return false},_mouseStop:function(c){var d=false;if(a.ui.ddmanager&&!this.options.dropBehaviour){d=a.ui.ddmanager.drop(this,c)}if(this.dropped){d=this.dropped;this.dropped=false}if(!this.element[0]||!this.element[0].parentNode){return false}if((this.options.revert=="invalid"&&!d)||(this.options.revert=="valid"&&d)||this.options.revert===true||(a.isFunction(this.options.revert)&&this.options.revert.call(this.element,d))){var b=this;a(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){if(b._trigger("stop",c)!==false){b._clear()}})}else{if(this._trigger("stop",c)!==false){this._clear()}}return false},cancel:function(){if(this.helper.is(".ui-draggable-dragging")){this._mouseUp({})}else{this._clear()}return this},_getHandle:function(b){var c=!this.options.handle||!a(this.options.handle,this.element).length?true:false;a(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==b.target){c=true}});return c},_createHelper:function(c){var d=this.options;var b=a.isFunction(d.helper)?a(d.helper.apply(this.element[0],[c])):(d.helper=="clone"?this.element.clone():this.element);if(!b.parents("body").length){b.appendTo((d.appendTo=="parent"?this.element[0].parentNode:d.appendTo))}if(b[0]!=this.element[0]&&!(/(fixed|absolute)/).test(b.css("position"))){b.css("position","absolute")}return b},_adjustOffsetFromHelper:function(b){if(typeof b=="string"){b=b.split(" ")}if(a.isArray(b)){b={left:+b[0],top:+b[1]||0}}if("left" in b){this.offset.click.left=b.left+this.margins.left}if("right" in b){this.offset.click.left=this.helperProportions.width-b.right+this.margins.left}if("top" in b){this.offset.click.top=b.top+this.margins.top}if("bottom" in b){this.offset.click.top=this.helperProportions.height-b.bottom+this.margins.top}},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var b=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0])){b.left+=this.scrollParent.scrollLeft();b.top+=this.scrollParent.scrollTop()}if((this.offsetParent[0]==document.body)||(this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&a.browser.msie)){b={top:0,left:0}}return{top:b.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:b.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var b=this.element.position();return{top:b.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:b.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else{return{top:0,left:0}}},_cacheMargins:function(){this.margins={left:(parseInt(this.element.css("marginLeft"),10)||0),top:(parseInt(this.element.css("marginTop"),10)||0)}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e=this.options;if(e.containment=="parent"){e.containment=this.helper[0].parentNode}if(e.containment=="document"||e.containment=="window"){this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,a(e.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a(e.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]}if(!(/^(document|window|parent)$/).test(e.containment)&&e.containment.constructor!=Array){var c=a(e.containment)[0];if(!c){return}var d=a(e.containment).offset();var b=(a(c).css("overflow")!="hidden");this.containment=[d.left+(parseInt(a(c).css("borderLeftWidth"),10)||0)+(parseInt(a(c).css("paddingLeft"),10)||0)-this.margins.left,d.top+(parseInt(a(c).css("borderTopWidth"),10)||0)+(parseInt(a(c).css("paddingTop"),10)||0)-this.margins.top,d.left+(b?Math.max(c.scrollWidth,c.offsetWidth):c.offsetWidth)-(parseInt(a(c).css("borderLeftWidth"),10)||0)-(parseInt(a(c).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,d.top+(b?Math.max(c.scrollHeight,c.offsetHeight):c.offsetHeight)-(parseInt(a(c).css("borderTopWidth"),10)||0)-(parseInt(a(c).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}else{if(e.containment.constructor==Array){this.containment=e.containment}}},_convertPositionTo:function(f,h){if(!h){h=this.position}var c=f=="absolute"?1:-1;var e=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,g=(/(html|body)/i).test(b[0].tagName);return{top:(h.top+this.offset.relative.top*c+this.offset.parent.top*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():(g?0:b.scrollTop()))*c)),left:(h.left+this.offset.relative.left*c+this.offset.parent.left*c-(a.browser.safari&&a.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():g?0:b.scrollLeft())*c))}},_generatePosition:function(e){var h=this.options,b=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&a.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,i=(/(html|body)/i).test(b[0].tagName);var d=e.pageX;var c=e.pageY;if(this.originalPosition){if(this.containment){if(e.pageX-this.offset.click.leftthis.containment[2]){d=this.containment[2]+this.offset.click.left}if(e.pageY-this.offset.click.top>this.containment[3]){c=this.containment[3]+this.offset.click.top}}if(h.grid){var g=this.originalPageY+Math.round((c-this.originalPageY)/h.grid[1])*h.grid[1];c=this.containment?(!(g-this.offset.click.topthis.containment[3])?g:(!(g-this.offset.click.topthis.containment[2])?f:(!(f-this.offset.click.left').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1000}).css(a(this).offset()).appendTo("body")})},stop:function(b,c){a("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});a.ui.plugin.add("draggable","opacity",{start:function(c,d){var b=a(d.helper),e=a(this).data("draggable").options;if(b.css("opacity")){e._opacity=b.css("opacity")}b.css("opacity",e.opacity)},stop:function(b,c){var d=a(this).data("draggable").options;if(d._opacity){a(c.helper).css("opacity",d._opacity)}}});a.ui.plugin.add("draggable","scroll",{start:function(c,d){var b=a(this).data("draggable");if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){b.overflowOffset=b.scrollParent.offset()}},drag:function(d,e){var c=a(this).data("draggable"),f=c.options,b=false;if(c.scrollParent[0]!=document&&c.scrollParent[0].tagName!="HTML"){if(!f.axis||f.axis!="x"){if((c.overflowOffset.top+c.scrollParent[0].offsetHeight)-d.pageY=0;v--){var s=g.snapElements[v].left,n=s+g.snapElements[v].width,m=g.snapElements[v].top,A=m+g.snapElements[v].height;if(!((s-y");if(!d.values){d.values=[this._valueMin(),this._valueMin()]}if(d.values.length&&d.values.length!=2){d.values=[d.values[0],d.values[0]]}}else{this.range=b("
")}this.range.appendTo(this.element).addClass("ui-slider-range");if(d.range=="min"||d.range=="max"){this.range.addClass("ui-slider-range-"+d.range)}this.range.addClass("ui-widget-header")}if(b(".ui-slider-handle",this.element).length==0){b('').appendTo(this.element).addClass("ui-slider-handle")}if(d.values&&d.values.length){while(b(".ui-slider-handle",this.element).length').appendTo(this.element).addClass("ui-slider-handle")}}this.handles=b(".ui-slider-handle",this.element).addClass("ui-state-default ui-corner-all");this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(e){e.preventDefault()}).hover(function(){if(!d.disabled){b(this).addClass("ui-state-hover")}},function(){b(this).removeClass("ui-state-hover")}).focus(function(){if(!d.disabled){b(".ui-slider .ui-state-focus").removeClass("ui-state-focus");b(this).addClass("ui-state-focus")}else{b(this).blur()}}).blur(function(){b(this).removeClass("ui-state-focus")});this.handles.each(function(e){b(this).data("index.ui-slider-handle",e)});this.handles.keydown(function(j){var g=true;var f=b(this).data("index.ui-slider-handle");if(c.options.disabled){return}switch(j.keyCode){case b.ui.keyCode.HOME:case b.ui.keyCode.END:case b.ui.keyCode.PAGE_UP:case b.ui.keyCode.PAGE_DOWN:case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:g=false;if(!c._keySliding){c._keySliding=true;b(this).addClass("ui-state-active");c._start(j,f)}break}var h,e,i=c._step();if(c.options.values&&c.options.values.length){h=e=c.values(f)}else{h=e=c.value()}switch(j.keyCode){case b.ui.keyCode.HOME:e=c._valueMin();break;case b.ui.keyCode.END:e=c._valueMax();break;case b.ui.keyCode.PAGE_UP:e=h+((c._valueMax()-c._valueMin())/a);break;case b.ui.keyCode.PAGE_DOWN:e=h-((c._valueMax()-c._valueMin())/a);break;case b.ui.keyCode.UP:case b.ui.keyCode.RIGHT:if(h==c._valueMax()){return}e=h+i;break;case b.ui.keyCode.DOWN:case b.ui.keyCode.LEFT:if(h==c._valueMin()){return}e=h-i;break}c._slide(j,f,e);return g}).keyup(function(f){var e=b(this).data("index.ui-slider-handle");if(c._keySliding){c._keySliding=false;c._stop(f,e);c._change(f,e);b(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();return this},_mouseCapture:function(e){var f=this.options;if(f.disabled){return false}this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();var i={x:e.pageX,y:e.pageY};var k=this._normValueFromMouse(i);var d=this._valueMax()-this._valueMin()+1,g;var l=this,j;this.handles.each(function(m){var n=Math.abs(k-l.values(m));if(d>n){d=n;g=b(this);j=m}});if(f.range==true&&this.values(1)==f.min){g=b(this.handles[++j])}this._start(e,j);this._mouseSliding=true;l._handleIndex=j;g.addClass("ui-state-active").focus();var h=g.offset();var c=!b(e.target).parents().andSelf().is(".ui-slider-handle");this._clickOffset=c?{left:0,top:0}:{left:e.pageX-h.left-(g.width()/2),top:e.pageY-h.top-(g.height()/2)-(parseInt(g.css("borderTopWidth"),10)||0)-(parseInt(g.css("borderBottomWidth"),10)||0)+(parseInt(g.css("marginTop"),10)||0)};k=this._normValueFromMouse(i);this._slide(e,j,k);this._animateOff=true;return true},_mouseStart:function(c){return true},_mouseDrag:function(e){var c={x:e.pageX,y:e.pageY};var d=this._normValueFromMouse(c);this._slide(e,this._handleIndex,d);return false},_mouseStop:function(c){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(c,this._handleIndex);this._change(c,this._handleIndex);this._handleIndex=null;this._clickOffset=null;this._animateOff=false;return false},_detectOrientation:function(){this.orientation=this.options.orientation=="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(e){var d,i;if("horizontal"==this.orientation){d=this.elementSize.width;i=e.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{d=this.elementSize.height;i=e.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}var g=(i/d);if(g>1){g=1}if(g<0){g=0}if("vertical"==this.orientation){g=1-g}var f=this._valueMax()-this._valueMin(),j=g*f,c=j%this.options.step,h=this._valueMin()+j-c;if(c>(this.options.step/2)){h+=this.options.step}return parseFloat(h.toFixed(5))},_start:function(e,d){var c={handle:this.handles[d],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(d);c.values=this.values()}this._trigger("start",e,c)},_slide:function(g,f,e){var h=this.handles[f];if(this.options.values&&this.options.values.length){var c=this.values(f?0:1);if((this.options.values.length==2&&this.options.range===true)&&((f==0&&e>c)||(f==1&&e1){this.options.values[e]=this._trimValue(h);this._refreshValue();this._change(null,e)}if(arguments.length){if(b.isArray(arguments[0])){var g=this.options.values,d=arguments[0];for(var f=0,c=g.length;fthis._valueMax()){c=this._valueMax()}return c},_valueMin:function(){var c=this.options.min;return c},_valueMax:function(){var c=this.options.max;return c},_refreshValue:function(){var g=this.options.range,e=this.options,m=this;var d=(!this._animateOff)?e.animate:false;if(this.options.values&&this.options.values.length){var j,i;this.handles.each(function(q,o){var p=(m.values(q)-m._valueMin())/(m._valueMax()-m._valueMin())*100;var n={};n[m.orientation=="horizontal"?"left":"bottom"]=p+"%";b(this).stop(1,1)[d?"animate":"css"](n,e.animate);if(m.options.range===true){if(m.orientation=="horizontal"){(q==0)&&m.range.stop(1,1)[d?"animate":"css"]({left:p+"%"},e.animate);(q==1)&&m.range[d?"animate":"css"]({width:(p-lastValPercent)+"%"},{queue:false,duration:e.animate})}else{(q==0)&&m.range.stop(1,1)[d?"animate":"css"]({bottom:(p)+"%"},e.animate);(q==1)&&m.range[d?"animate":"css"]({height:(p-lastValPercent)+"%"},{queue:false,duration:e.animate})}}lastValPercent=p})}else{var k=this.value(),h=this._valueMin(),l=this._valueMax(),f=l!=h?(k-h)/(l-h)*100:0;var c={};c[m.orientation=="horizontal"?"left":"bottom"]=f+"%";this.handle.stop(1,1)[d?"animate":"css"](c,e.animate);(g=="min")&&(this.orientation=="horizontal")&&this.range.stop(1,1)[d?"animate":"css"]({width:f+"%"},e.animate);(g=="max")&&(this.orientation=="horizontal")&&this.range[d?"animate":"css"]({width:(100-f)+"%"},{queue:false,duration:e.animate});(g=="min")&&(this.orientation=="vertical")&&this.range.stop(1,1)[d?"animate":"css"]({height:f+"%"},e.animate);(g=="max")&&(this.orientation=="vertical")&&this.range[d?"animate":"css"]({height:(100-f)+"%"},{queue:false,duration:e.animate})}}});b.extend(b.ui.slider,{version:"1.8"})})(jQuery);; \ No newline at end of file diff --git a/public/svg-edit/editor/js-hotkeys/README.md b/public/svg-edit/editor/js-hotkeys/README.md index 4abcd7ab..696e9894 100644 --- a/public/svg-edit/editor/js-hotkeys/README.md +++ b/public/svg-edit/editor/js-hotkeys/README.md @@ -1,47 +1,32 @@ #About -**jQuery.hotkeys** is a plug-in that lets you easily add and remove handlers for keyboard events anywhere in your code supporting almost any key combination. +**jQuery Hotkeys** is a plug-in that lets you easily add and remove handlers for keyboard events anywhere in your code supporting almost any key combination. -It is based on a library [Shortcut.js](http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js) written by [Binny V A](http://www.openjs.com/). +This plugin is based off of the plugin by Tzury Bar Yochay: [jQuery.hotkeys](http://github.com/tzuryby/hotkeys) The syntax is as follows: -
-$(expression).bind(,, );
-$(expression).unbind(,, );
 
-$(document).bind('keydown', 'Ctrl+a', fn);
-
-// e.g. replace '$' sign with 'EUR'
-$('input.foo').bind('keyup', '$', function(){
-    this.value = this.value.replace('$', 'EUR');
-});
-
-$('div.foo').unbind('keydown', 'Ctrl+a', fn);
-
-## [Live Demo](http://jshotkeys.googlepages.com/test-static-01.html) + $(expression).bind(types, keys, handler); + $(expression).unbind(types, handler); + + $(document).bind('keydown', 'ctrl+a', fn); + + // e.g. replace '$' sign with 'EUR' + $('input.foo').bind('keyup', '$', function(){ + this.value = this.value.replace('$', 'EUR'); + }); ## Types Supported types are `'keydown'`, `'keyup'` and `'keypress'` -## Options -The options are `'combi'` i.e. the key combination, and `'disableInInput'` which allow your code not to be executed when the cursor is located inside an input ( `$(elem).is('input') || $(elem).is('textarea')` ). - -As you can see, the key combination can be passed as string or as an object. You may pass an object in case you wish to override the default option for `disableInInput` which is set to `false`: -
-$(document).bind('keydown', {combi:'a', disableinInput: true}, fn);
-
-I.e. when cursor is within an input field, `'a'` will be inserted into the input field without interfering. +## Notes If you want to use more than one modifiers (e.g. alt+ctrl+z) you should define them by an alphabetical order e.g. alt+ctrl+shift -Modifiers are case insensitive, i.e. 'Ctrl+a' 'ctrl+a'. - -## Handler -In previous versions there was an option propagate which is removed now and implemented at the user code level. - -When using jQuery, if an event handler returns false, jQuery will call `stopPropagation()` and `preventDefault()` +Hotkeys aren't tracked if you're inside of an input element (unless you explicitly bind the hotkey directly to the input). This helps to avoid conflict with normal user typing. ## jQuery Compatibility -Tested with *jQuery 1.2.6* + +Works with jQuery 1.4.2 and newer. It known to be working with all the major browsers on all available platforms (Win/Mac/Linux) @@ -51,43 +36,10 @@ It known to be working with all the major browsers on all available platforms (W * Safari-3 * Chrome-0.2 -## Features added in this version (0.7.x) - * Implemented as $.fn - let you use `this`. - * jQuery selectors are supported. - * Extending `$.fn.bind` and `$.fn.unbind` so you get a single interface for binding events to handlers - -## Overriding jQuery -The plugin wraps the following jQuery methods: - * $.fn.bind - * $.fn.unbind - * $.find - -Even though the plugin overrides these methods, the original methods will *always* be called. - -The plugin will add functionality only for the `keydown`, `keyup` and `keypress` event types. Any other types are passed untouched to the original `'bind()'` and `'unbind()'` methods. - -Moreover, if you call `bind()` without passing the shortcut key combination e.g. `$(document).bind('keydown', fn)` only the original `'bind()'` method will be executed. - -I also modified the `$.fn.find` method by adding a single line at the top of the function body. here is the code: - -
-    jQuery.fn.find = function( selector ) {
-        // the line I added
-        this.query=selector;
-        // call jQuery original find
-        return jQuery.fn.__find__.apply(this, arguments);
-    };
-
- -You can read about this at [jQuery's User Group](http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d) - -###Notes +### Addendum Firefox is the most liberal one in the manner of letting you capture all short-cuts even those that are built-in in the browser such as `Ctrl-t` for new tab, or `Ctrl-a` for selecting all text. You can always bubble them up to the browser by returning `true` in your handler. Others, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will *not* pass those events to the DOM at all. -*So, if you bind `Ctrl-Q` or `Alt-F4` and your Safari/Opera window is closed don't be surprised.* - - -###Current Version is: beta 0.7 \ No newline at end of file +*So, if you bind `Ctrl-Q` or `Alt-F4` and your Safari/Opera window is closed don't be surprised.* \ No newline at end of file diff --git a/public/svg-edit/editor/js-hotkeys/jquery.hotkeys.min.js b/public/svg-edit/editor/js-hotkeys/jquery.hotkeys.min.js index 2060e5ba..52d95517 100644 --- a/public/svg-edit/editor/js-hotkeys/jquery.hotkeys.min.js +++ b/public/svg-edit/editor/js-hotkeys/jquery.hotkeys.min.js @@ -1,19 +1,15 @@ -(function(jQuery){jQuery.fn.__bind__=jQuery.fn.bind;jQuery.fn.__unbind__=jQuery.fn.unbind;jQuery.fn.__find__=jQuery.fn.find;var hotkeys={version:'0.7.9',override:/keypress|keydown|keyup/g,triggersMap:{},specialKeys:{27:'esc',9:'tab',32:'space',13:'return',8:'backspace',145:'scroll',20:'capslock',144:'numlock',19:'pause',45:'insert',36:'home',46:'del',35:'end',33:'pageup',34:'pagedown',37:'left',38:'up',39:'right',40:'down',109:'-',112:'f1',113:'f2',114:'f3',115:'f4',116:'f5',117:'f6',118:'f7',119:'f8',120:'f9',121:'f10',122:'f11',123:'f12',191:'/'},shiftNums:{"`":"~","1":"!","2":"@","3":"#","4":"$","5":"%","6":"^","7":"&","8":"*","9":"(","0":")","-":"_","=":"+",";":":","'":"\"",",":"<",".":">","/":"?","\\":"|"},newTrigger:function(type,combi,callback){var result={};result[type]={};result[type][combi]={cb:callback,disableInInput:false};return result;}};hotkeys.specialKeys=jQuery.extend(hotkeys.specialKeys,{96:'0',97:'1',98:'2',99:'3',100:'4',101:'5',102:'6',103:'7',104:'8',105:'9',106:'*',107:'+',109:'-',110:'.',111:'/'});jQuery.fn.find=function(selector){this.query=selector;return jQuery.fn.__find__.apply(this,arguments);};jQuery.fn.unbind=function(type,combi,fn){if(jQuery.isFunction(combi)){fn=combi;combi=null;} -if(combi&&typeof combi==='string'){var selectorId=((this.prevObject&&this.prevObject.query)||(this[0].id&&this[0].id)||this[0]).toString();var hkTypes=type.split(' ');for(var x=0;x","/":"?","\\":"|"}};function a(d){if(typeof d.data!=="string"){return}var c=d.handler,e=d.data.toLowerCase().split(" ");d.handler=function(n){if(this!==n.target&&(/textarea|select/i.test(n.target.nodeName)||n.target.type==="text")){return}var h=n.type!=="keypress"&&b.hotkeys.specialKeys[n.which],o=String.fromCharCode(n.which).toLowerCase(),k,m="",g={};if(n.altKey&&h!=="alt"){m+="alt+"}if(n.ctrlKey&&h!=="ctrl"){m+="ctrl+"}if(n.metaKey&&!n.ctrlKey&&h!=="meta"){m+="meta+"}if(n.shiftKey&&h!=="shift"){m+="shift+"}if(h){g[m+h]=true}else{g[m+o]=true;g[m+b.hotkeys.shiftNums[o]]=true;if(m==="shift+"){g[b.hotkeys.shiftNums[o]]=true}}for(var j=0,f=e.length;j * { - float: left; -} - span.zoom_tool { line-height: 26px; padding: 3px; } -.magic_field input { - margin-top: 5px; +#zoom_panel label { + margin-top: 2px; } .dropdown { @@ -701,6 +698,21 @@ span.zoom_tool { height: 26px; } +#toggle_stroke_tools { + letter-spacing: -.2em; + padding-right: 8px; +} + +#toggle_stroke_tools:hover { + cursor: pointer; + background: #FFC; +} + +.stroke_tool { + display: none; + white-space: nowrap; +} + .color_tool > *:first-child { -moz-border-radius-topleft: 4px; -moz-border-radius-bottomleft: 4px; @@ -739,6 +751,8 @@ span.zoom_tool { #svg_editor #tools_bottom_3 { +// position: relative; + z-index: 2; } #svg_editor #copyright { @@ -1023,4 +1037,4 @@ span.zoom_tool { -webkit-border-radius: 0px; } -foreignObject {line-height:1.0} \ No newline at end of file +foreignObject {line-height:1.0} diff --git a/public/svg-edit/editor/svg-editor.html b/public/svg-edit/editor/svg-editor.html index 1a6a9b5b..7746b8ce 100644 --- a/public/svg-edit/editor/svg-editor.html +++ b/public/svg-edit/editor/svg-editor.html @@ -19,6 +19,8 @@ + + + + diff --git a/public/svg-edit/editor/svg-editor.js b/public/svg-edit/editor/svg-editor.js index 798e8fa9..74e7a52e 100644 --- a/public/svg-edit/editor/svg-editor.js +++ b/public/svg-edit/editor/svg-editor.js @@ -45,7 +45,7 @@ imgPath: 'images/', langPath: 'locale/', extPath: 'extensions/', - extensions: ['ext-arrows.js', 'ext-connector.js', 'ext-itex.js'], + extensions: ['ext-arrows.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-itex.js'], initTool: 'select', wireframe: false }, @@ -59,6 +59,7 @@ 'layerHasThatName':"Layer already has that name", 'QmoveElemsToLayer':"Move selected elements to layer '%s'?", 'QwantToClear':'Do you want to clear the drawing?\nThis will also erase your undo history!', + 'QwantToOpen':'Do you want to open a new file?\nThis will also erase your undo history!', 'QerrorsRevertToSource':'There were parsing errors in your SVG source.\nRevert back to original SVG source?', 'QignoreSourceChanges':'Ignore changes made to SVG source?', 'featNotSupported':'Feature not supported', @@ -143,6 +144,7 @@ svgCanvas.open = opts.open; } if(opts.save) { + show_save_warning = false; svgCanvas.bind("saved", opts.save); } } @@ -190,10 +192,19 @@ } })(); + var extFunc = function() { + $.each(curConfig.extensions, function() { + $.getScript(curConfig.extPath + this); + }); + } + // Load extensions - $.each(curConfig.extensions, function() { - $.getScript(curConfig.extPath + this); - }); + // Bit of a hack to run extensions in local Opera + if(window.opera && document.location.protocol === 'file:') { + setTimeout(extFunc, 1000); + } else { + extFunc(); + } $.svgIcons(curConfig.imgPath + 'svg_edit_icons.svg', { w:24, h:24, @@ -361,7 +372,8 @@ modKey = "", //(isMac ? "meta+" : "ctrl+"); path = svgCanvas.pathActions, default_img_url = curConfig.imgPath + "logo.png", - workarea = $("#workarea"); + workarea = $("#workarea"), + show_save_warning = false; // This sets up alternative dialog boxes. They mostly work the same way as // their UI counterparts, expect instead of returning the result, a callback @@ -388,7 +400,7 @@ if(type == 'prompt') { var input = $('').prependTo(btn_holder); input.val(defText || ''); - input.bind('keydown', {combi:'return'}, function() {ok.click();}); + input.bind('keydown', 'return', function() {ok.click();}); } box.show(); @@ -445,6 +457,8 @@ var strokePaint = new $.jGraduate.Paint({solidColor: curConfig.initStroke.color}); var saveHandler = function(window,svg) { + show_save_warning = false; + // by default, we add the XML prolog back, systems integrating SVG-edit (wikis, CMSs) // can just provide their own custom save handler and might not want the XML prolog svg = "\n" + svg; @@ -525,6 +539,8 @@ selectedElement = elem; } } + + show_save_warning = true; // we update the contextual panel with potentially new // positional/sizing information (we DON'T want to update the @@ -607,7 +623,7 @@ $(this).mouseup(func); if(opts.key) { - $(document).bind('keydown', {combi: opts.key+'', disableInInput:true}, func); + $(document).bind('keydown', opts.key+'', func); } }); @@ -878,7 +894,7 @@ }); } if(btn.key) { - $(document).bind('keydown', {combi: btn.key, disableInInput: true}, func); + $(document).bind('keydown', btn.key, func); if(btn.title) button.attr("title", btn.title + ' ['+btn.key+']'); } } else { @@ -999,6 +1015,8 @@ $('#stroke_width').val(selectedElement.getAttribute("stroke-width")||1); $('#stroke_style').val(selectedElement.getAttribute("stroke-dasharray")||"none"); + $('#stroke_linejoin').val(selectedElement.getAttribute("stroke-linejoin")||"miter"); + $('#stroke_linecap').val(selectedElement.getAttribute("stroke-linecap")||"butt"); } // All elements including image and group have opacity @@ -1270,9 +1288,20 @@ } $('#stroke_style').change(function(){ - svgCanvas.setStrokeStyle(this.options[this.selectedIndex].value); + svgCanvas.setStrokeAttr('stroke-dasharray', $(this).val()); operaRepaint(); }); + + $('#stroke_linejoin').change(function(){ + svgCanvas.setStrokeAttr('stroke-linejoin', $(this).val()); + operaRepaint(); + }); + + $('#stroke_linecap').change(function(){ + svgCanvas.setStrokeAttr('stroke-linecap', $(this).val()); + operaRepaint(); + }); + // Lose focus for select elements when changed (Allows keyboard shortcuts to work better) $('select').change(function(){$(this).blur();}); @@ -1383,6 +1412,14 @@ updateToolButtonState(); }); + $("#toggle_stroke_tools").toggle(function() { + $(".stroke_tool").css('display','table-cell'); + $(this).text('<<'); + }, function() { + $(".stroke_tool").css('display','none'); + $(this).text('>>'); + }); + // This is a common function used when a tool has been clicked (chosen) // It does several common things: // - removes the tool_button_current class from whatever tool currently has it @@ -1401,6 +1438,44 @@ return true; }; + (function() { + var last_x = null, last_y = null, w_area = workarea[0], + panning = false, keypan = false; + + $('#svgcanvas').bind('mousemove mouseup', function(evt) { + if(panning === false) return; + + w_area.scrollLeft -= (evt.clientX - last_x); + w_area.scrollTop -= (evt.clientY - last_y); + + last_x = evt.clientX; + last_y = evt.clientY; + + if(evt.type === 'mouseup') panning = false; + return false; + }).mousedown(function(evt) { + if(evt.button === 1 || keypan === true) { + panning = true; + last_x = evt.clientX; + last_y = evt.clientY; + return false; + } + }); + + $(window).mouseup(function() { + panning = false; + }); + + $(document).bind('keydown', 'space', function(evt) { + svgCanvas.spaceKey = keypan = true; + evt.preventDefault(); + }).bind('keyup', 'space', function(evt) { + evt.preventDefault(); + svgCanvas.spaceKey = keypan = false; + }); + }()); + + (function() { var button = $('#main_icon'); var overlay = $('#main_icon span'); @@ -2022,6 +2097,7 @@ ".tool_button,\ .push_button,\ .tool_button_current,\ + .push_button_pressed,\ .disabled,\ .tools_flyout .tool_button": { 'width': {s: '16px', l: '32px', xl: '48px'}, @@ -2047,11 +2123,11 @@ "div#workarea": { 'left': {s: '27px', l: '46px', xl: '65px'}, 'top': {s: '50px', l: '88px', xl: '125px'}, - 'bottom': {s: '55px', l: '70px', xl: '77px'} + 'bottom': {s: '55px', l: '98px', xl: '145px'} }, "#tools_bottom": { 'left': {s: '27px', l: '46px', xl: '65px'}, - 'height': {s: '58px', l: '70px', xl: '77px'} + 'height': {s: '58px', l: '98px', xl: '145px'} }, "#color_tools": { 'border-spacing': {s: '0 1px'} @@ -2060,7 +2136,8 @@ 'height': {s: '20px'} }, "#tool_opacity": { - 'top': {s: '1px'} + 'top': {s: '1px'}, + 'height': {s: 'auto', l:'auto', xl:'auto'} }, "#tools_top input, #tools_bottom input": { 'margin-top': {s: '2px', l: '4px', xl: '5px'}, @@ -2888,7 +2965,7 @@ keyval += ''; $.each(keyval.split('/'), function(i, key) { - $(document).bind('keydown', {combi: key, disableInInput: disInInp}, function(e) { + $(document).bind('keydown', key, function(e) { fn(); if(pd) { e.preventDefault(); @@ -2917,7 +2994,7 @@ // Misc additional actions // Make "return" keypress trigger the change event - $('.attr_changer, #image_url').bind('keydown', {combi:'return'}, + $('.attr_changer, #image_url').bind('keydown', 'return', function(evt) {$(this).change();evt.preventDefault();} ); @@ -2994,20 +3071,44 @@ $('#group_opacity').SpinButton({ step: 5, min: 0, max: 100, callback: changeOpacity }); $('#zoom').SpinButton({ min: 0.001, max: 10000, step: 50, stepfunc: stepZoom, callback: changeZoom }); + window.onbeforeunload = function() { + // Suppress warning if page is empty + if(svgCanvas.getHistoryPosition() === 0) { + show_save_warning = false; + } + + // show_save_warning is set to "false" when the page is saved. + if(!curConfig.no_save_warning && show_save_warning) { + // Browser already asks question about closing the page + return "There are unsaved changes."; + } + }; + // use HTML5 File API: http://www.w3.org/TR/FileAPI/ // if browser has HTML5 File API support, then we will show the open menu item // and provide a file input to click. When that change event fires, it will // get the text contents of the file and send it to the canvas if (window.FileReader) { var inp = $('').change(function() { + var f = this; + var openFile = function(ok) { + if(!ok) return; + svgCanvas.clear(); + if(f.files.length==1) { + var reader = new FileReader(); + reader.onloadend = function(e) { + svgCanvas.setSvgString(e.target.result); + updateCanvas(); + }; + reader.readAsText(f.files[0]); + } + } + $('#main_menu').hide(); - if(this.files.length==1) { - var reader = new FileReader(); - reader.onloadend = function(e) { - svgCanvas.setSvgString(e.target.result); - updateCanvas(); - }; - reader.readAsText(this.files[0]); + if(svgCanvas.getHistoryPosition() === 0) { + openFile(true); + } else { + $.confirm(uiStrings.QwantToOpen, openFile); } }); $("#tool_open").show().prepend(inp); @@ -3092,7 +3193,7 @@ updateCanvas(true); // }); - // var revnums = "svg-editor.js ($Rev: 1470 $) "; + // var revnums = "svg-editor.js ($Rev: 1498 $) "; // revnums += svgCanvas.getVersion(); // $('#copyright')[0].setAttribute("title", revnums); diff --git a/public/svg-edit/editor/svgcanvas.js b/public/svg-edit/editor/svgcanvas.js index bbfae279..5330f444 100644 --- a/public/svg-edit/editor/svgcanvas.js +++ b/public/svg-edit/editor/svgcanvas.js @@ -97,8 +97,8 @@ var isOpera = !!window.opera, "defs": [], "desc": [], "ellipse": ["class", "clip-path", "clip-rule", "cx", "cy", "fill", "fill-opacity", "fill-rule", "filter", "id", "mask", "opacity", "requiredFeatures", "rx", "ry", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform"], - "feGaussianBlur": ["class", "id", "requiredFeatures", "stdDeviation"], - "filter": ["class", "filterRes", "filterUnits", "height", "id", "primitiveUnits", "requiredFeatures", "width", "x", "xlink:href", "y"], + "feGaussianBlur": ["class", "color-interpolation-filters", "id", "requiredFeatures", "stdDeviation"], + "filter": ["class", "color-interpolation-filters", "filterRes", "filterUnits", "height", "id", "primitiveUnits", "requiredFeatures", "width", "x", "xlink:href", "y"], "foreignObject": ["class", "font-size", "height", "id", "opacity", "requiredFeatures", "style", "transform", "width", "x", "y"], "g": ["class", "clip-path", "clip-rule", "id", "display", "fill", "fill-opacity", "fill-rule", "filter", "mask", "opacity", "requiredFeatures", "stroke", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-width", "style", "systemLanguage", "transform"], "image": ["class", "clip-path", "clip-rule", "filter", "height", "id", "mask", "opacity", "requiredFeatures", "style", "systemLanguage", "transform", "width", "x", "xlink:href", "xlink:title", "y"], @@ -1143,6 +1143,8 @@ function BatchCommand(text) { 'opacity':1, 'stroke':'none', 'stroke-dasharray':'none', + 'stroke-linejoin':'miter', + 'stroke-linecap':'butt', 'stroke-opacity':1, 'stroke-width':1, 'rx':0, @@ -1171,6 +1173,20 @@ function BatchCommand(text) { current_layer.appendChild(shape); } } + if(data.curStyles) { + assignAttributes(shape, { + "fill": cur_shape.fill, + "stroke": cur_shape.stroke, + "stroke-width": cur_shape.stroke_width, + "stroke-dasharray": cur_shape.stroke_dasharray, + "stroke-linejoin": cur_shape.stroke_linejoin, + "stroke-linecap": cur_shape.stroke_linecap, + "stroke-opacity": cur_shape.stroke_opacity, + "fill-opacity": cur_shape.fill_opacity, + "opacity": cur_shape.opacity / 2, + "style": "pointer-events:inherit" + }, 100); + } assignAttributes(shape, data.attr, 100); cleanupElement(shape); return shape; @@ -1211,7 +1227,9 @@ function BatchCommand(text) { stroke_paint: null, stroke_opacity: curConfig.initStroke.opacity, stroke_width: curConfig.initStroke.width, - stroke_style: 'none', + stroke_dasharray: 'none', + stroke_linejoin: 'miter', + stroke_linecap: 'butt', opacity: curConfig.initOpacity } }; @@ -1320,6 +1338,10 @@ function BatchCommand(text) { undoStack.push(cmd); undoStackPointer = undoStack.length; }; + + this.getHistoryPosition = function() { + return undoStackPointer; + }; // private functions var getId = function() { @@ -1953,7 +1975,7 @@ function BatchCommand(text) { break; case 9: // relative quad (q) case 8: // absolute quad (Q) - dstr += seg.x + "," + seg.y + " " + seg.x1 + "," + seg.y1 + " "; + dstr += seg.x1 + "," + seg.y1 + " " + seg.x + "," + seg.y + " "; break; case 11: // relative elliptical arc (a) case 10: // absolute elliptical arc (A) @@ -1962,7 +1984,7 @@ function BatchCommand(text) { break; case 17: // relative smooth cubic (s) case 16: // absolute smooth cubic (S) - dstr += seg.x + "," + seg.y + " " + seg.x2 + "," + seg.y2 + " "; + dstr += seg.x2 + "," + seg.y2 + " " + seg.x + "," + seg.y + " "; break; } } @@ -2130,12 +2152,14 @@ function BatchCommand(text) { var angle = canvas.getRotationAngle(child); var old_start_transform = start_transform; + var childxforms = []; start_transform = child.getAttribute("transform"); if(angle || hasMatrixTransform(childTlist)) { var e2t = svgroot.createSVGTransform(); e2t.setMatrix(matrixMultiply(tm, sm, tmn, m)); childTlist.clear(); - childTlist.appendItem(e2t,0); + childTlist.appendItem(e2t); + childxforms.push(e2t); } // if not rotated or skewed, push the [T][S][-T] down to the child else { @@ -2144,6 +2168,7 @@ function BatchCommand(text) { // slide the [T][S][-T] from the front to the back // [T][S][-T][M] = [M][T2][S2][-T2] + // (only bringing [-T] to the right of [M]) // [T][S][-T][M] = [T][S][M][-T2] // [-T2] = [M_inv][-T][M] var t2n = matrixMultiply(m.inverse(), tmn, m); @@ -2165,8 +2190,28 @@ function BatchCommand(text) { childTlist.appendItem(translateBack); childTlist.appendItem(scale); childTlist.appendItem(translateOrigin); + childxforms.push(translateBack); + childxforms.push(scale); + childxforms.push(translateOrigin); + logMatrix(translateBack.matrix); + logMatrix(scale.matrix); } // not rotated batchCmd.addSubCommand( recalculateDimensions(child) ); + // TODO: If any have this group as a parent and are + // referencing this child, then we need to impose a reverse + // scale on it so that when it won't get double-translated +// var uses = selected.getElementsByTagNameNS(svgns, "use"); +// var href = "#"+child.id; +// var u = uses.length; +// while (u--) { +// var useElem = uses.item(u); +// if(href == useElem.getAttributeNS(xlinkns, "href")) { +// var usexlate = svgroot.createSVGTransform(); +// usexlate.setTranslate(-tx,-ty); +// canvas.getTransformList(useElem).insertItemBefore(usexlate,0); +// batchCmd.addSubCommand( recalculateDimensions(useElem) ); +// } +// } start_transform = old_start_transform; } // element } // for each child @@ -2216,6 +2261,21 @@ function BatchCommand(text) { newxlate.setTranslate(tx,ty); childTlist.insertItemBefore(newxlate, 0); batchCmd.addSubCommand( recalculateDimensions(child) ); + // If any have this group as a parent and are + // referencing this child, then impose a reverse translate on it + // so that when it won't get double-translated + var uses = selected.getElementsByTagNameNS(svgns, "use"); + var href = "#"+child.id; + var u = uses.length; + while (u--) { + var useElem = uses.item(u); + if(href == useElem.getAttributeNS(xlinkns, "href")) { + var usexlate = svgroot.createSVGTransform(); + usexlate.setTranslate(-tx,-ty); + canvas.getTransformList(useElem).insertItemBefore(usexlate,0); + batchCmd.addSubCommand( recalculateDimensions(useElem) ); + } + } start_transform = old_start_transform; } } @@ -2810,6 +2870,7 @@ function BatchCommand(text) { // and do nothing else var mouseDown = function(evt) { + if(evt.button === 1 || canvas.spaceKey) return; root_sctm = svgcontent.getScreenCTM().inverse(); var pt = transformPoint( evt.pageX, evt.pageY, root_sctm ), mouse_x = pt.x * current_zoom, @@ -2964,17 +3025,13 @@ function BatchCommand(text) { var stroke_w = cur_shape.stroke_width == 0?1:cur_shape.stroke_width; addSvgElementFromJson({ "element": "polyline", + "curStyles": true, "attr": { "points": d_attr, "id": getNextId(), "fill": "none", - "stroke": cur_shape.stroke, - "stroke-width": stroke_w, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, - "stroke-linecap": "round", - "stroke-linejoin": "round", "opacity": cur_shape.opacity / 2, + "stroke-linecap": "round", "style": "pointer-events:none" } }); @@ -3011,20 +3068,14 @@ function BatchCommand(text) { start_y = y; addSvgElementFromJson({ "element": "rect", + "curStyles": true, "attr": { "x": x, "y": y, "width": 0, "height": 0, "id": getNextId(), - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + "opacity": cur_shape.opacity / 2 } }); break; @@ -3033,6 +3084,7 @@ function BatchCommand(text) { var stroke_w = cur_shape.stroke_width == 0?1:cur_shape.stroke_width; addSvgElementFromJson({ "element": "line", + "curStyles": true, "attr": { "x1": x, "y1": y, @@ -3041,7 +3093,9 @@ function BatchCommand(text) { "id": getNextId(), "stroke": cur_shape.stroke, "stroke-width": stroke_w, - "stroke-dasharray": cur_shape.stroke_style, + "stroke-dasharray": cur_shape.stroke_dasharray, + "stroke-linejoin": cur_shape.stroke_linejoin, + "stroke-linecap": cur_shape.stroke_linecap, "stroke-opacity": cur_shape.stroke_opacity, "fill": "none", "opacity": cur_shape.opacity / 2, @@ -3053,19 +3107,13 @@ function BatchCommand(text) { started = true; addSvgElementFromJson({ "element": "circle", + "curStyles": true, "attr": { "cx": x, "cy": y, "r": 0, "id": getNextId(), - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + "opacity": cur_shape.opacity / 2 } }); break; @@ -3073,20 +3121,14 @@ function BatchCommand(text) { started = true; addSvgElementFromJson({ "element": "ellipse", + "curStyles": true, "attr": { "cx": x, "cy": y, "rx": 0, "ry": 0, "id": getNextId(), - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + "opacity": cur_shape.opacity / 2 } }); break; @@ -3094,22 +3136,16 @@ function BatchCommand(text) { started = true; var newText = addSvgElementFromJson({ "element": "text", + "curStyles": true, "attr": { "x": x, "y": y, "id": getNextId(), "fill": cur_text.fill, - "stroke": cur_shape.stroke, "stroke-width": cur_text.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - // fix for bug where text elements were always 50% opacity - "opacity": cur_shape.opacity, "font-size": cur_text.font_size, "font-family": cur_text.font_family, "text-anchor": "middle", - "style": "pointer-events:inherit", "xml:space": "preserve" } }); @@ -3155,6 +3191,7 @@ function BatchCommand(text) { var mouseMove = function(evt) { if (!started) return; + if(evt.button === 1 || canvas.spaceKey) return; var selected = selectedElements[0], pt = transformPoint( evt.pageX, evt.pageY, root_sctm ), mouse_x = pt.x * current_zoom, @@ -3452,6 +3489,7 @@ function BatchCommand(text) { var mouseUp = function(evt) { + if(evt.button === 1) return; var tempJustSelected = justSelected; justSelected = null; if (!started) return; @@ -3486,7 +3524,9 @@ function BatchCommand(text) { cur_properties.stroke = selected.getAttribute("stroke"); cur_properties.stroke_opacity = selected.getAttribute("stroke-opacity"); cur_properties.stroke_width = selected.getAttribute("stroke-width"); - cur_properties.stroke_style = selected.getAttribute("stroke-dasharray"); + cur_properties.stroke_dasharray = selected.getAttribute("stroke-dasharray"); + cur_properties.stroke_linejoin = selected.getAttribute("stroke-linejoin"); + cur_properties.stroke_linecap = selected.getAttribute("stroke-linecap"); } if (selected.tagName == "text") { cur_text.font_size = selected.getAttribute("font-size"); @@ -3577,20 +3617,13 @@ function BatchCommand(text) { (freehand.maxy - freehand.miny) > 0) { element = addSvgElementFromJson({ "element": "ellipse", + "curStyles": true, "attr": { "cx": (freehand.minx + freehand.maxx) / 2, "cy": (freehand.miny + freehand.maxy) / 2, "rx": (freehand.maxx - freehand.minx) / 2, "ry": (freehand.maxy - freehand.miny) / 2, - "id": getId(), - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "opacity": cur_shape.opacity, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "style": "pointer-events:inherit" + "id": getId() } }); call("changed",[element]); @@ -3602,20 +3635,13 @@ function BatchCommand(text) { (freehand.maxy - freehand.miny) > 0) { element = addSvgElementFromJson({ "element": "rect", + "curStyles": true, "attr": { "x": freehand.minx, "y": freehand.miny, "width": (freehand.maxx - freehand.minx), "height": (freehand.maxy - freehand.miny), - "id": getId(), - "fill": cur_shape.fill, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "opacity": cur_shape.opacity, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "style": "pointer-events:inherit" + "id": getId() } }); call("changed",[element]); @@ -4589,19 +4615,13 @@ function BatchCommand(text) { // create new path element element = addSvgElementFromJson({ "element": "path", - "attr": { - "id": getId(), - "d": d, - "fill": "none", - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "opacity": cur_shape.opacity, - "stroke-opacity": cur_shape.stroke_opacity, - "fill-opacity": cur_shape.fill_opacity, - "style": "pointer-events:inherit" - } - }); + "curStyles": true, + "attr": { + "id": getId(), + "d": d, + "fill": "none" + } + }); call("changed",[element]); } return element; @@ -4856,17 +4876,12 @@ function BatchCommand(text) { d_attr = "M" + x + "," + y + " "; addSvgElementFromJson({ "element": "path", + "curStyles": true, "attr": { "d": d_attr, "id": getNextId(), - "fill": cur_shape.fill, - "fill-opacity": cur_shape.fill_opacity, - "stroke": cur_shape.stroke, - "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, - "stroke-opacity": cur_shape.stroke_opacity, "opacity": cur_shape.opacity / 2, - "style": "pointer-events:inherit" + } }); // set stretchy line to first point @@ -5582,7 +5597,9 @@ function BatchCommand(text) { "fill-opacity": cur_shape.fill_opacity, "stroke": cur_shape.stroke, "stroke-width": cur_shape.stroke_width, - "stroke-dasharray": cur_shape.stroke_style, + "stroke-dasharray": cur_shape.stroke_dasharray, + "stroke-linejoin": cur_shape.stroke_linejoin, + "stroke-linecap": cur_shape.stroke_linecap, "stroke-opacity": cur_shape.stroke_opacity, "opacity": cur_shape.opacity, "visibility":"hidden" @@ -5819,6 +5836,10 @@ function BatchCommand(text) { if (extensions["Arrows"]) call("unsetarrownonce") ; } else { randomize_ids = true; + if (!svgcontent.getAttributeNS(se_ns, 'nonce')) { + svgcontent.setAttributeNS(se_ns, 'se:nonce', nonce); + if (extensions["Arrows"]) call("setarrownonce", nonce) ; + } } } @@ -5876,6 +5897,53 @@ function BatchCommand(text) { canvas.embedImage(val); }); + // convert gradients with userSpaceOnUse to objectBoundingBox + $(svgcontent).find('linearGradient, radialGradient').each(function() { + var grad = this; + if($(grad).attr('gradientUnits') === 'userSpaceOnUse') { + // TODO: Support more than one element with this ref by duplicating parent grad + var elems = $(svgcontent).find('[fill=url(#' + grad.id + ')],[stroke=url(#' + grad.id + ')]'); + if(!elems.length) return; + + // get object's bounding box + var bb = elems[0].getBBox(); + + if(grad.tagName === 'linearGradient') { + var g_coords = $(grad).attr(['x1', 'y1', 'x2', 'y2']); + + $(grad).attr({ + x1: (g_coords.x1 - bb.x) / bb.width, + y1: (g_coords.y1 - bb.y) / bb.height, + x2: (g_coords.x2 - bb.x) / bb.width, + y2: (g_coords.y1 - bb.y) / bb.height + }); + + grad.removeAttribute('gradientUnits'); + } else { + // Note: radialGradient elements cannot be easily converted + // because userSpaceOnUse will keep circular gradients, while + // objectBoundingBox will x/y scale the gradient according to + // its bbox. + + // For now we'll do nothing, though we should probably have + // the gradient be updated as the element is moved, as + // inkscape/illustrator do. + +// var g_coords = $(grad).attr(['cx', 'cy', 'r']); +// +// $(grad).attr({ +// cx: (g_coords.cx - bb.x) / bb.width, +// cy: (g_coords.cy - bb.y) / bb.height, +// r: g_coords.r +// }); +// +// grad.removeAttribute('gradientUnits'); + } + + + } + }); + // Fix XML for Opera/Win/Non-EN if(!support.goodDecimals) { canvas.fixOperaXML(svgcontent, newDoc.documentElement); @@ -6985,12 +7053,8 @@ function BatchCommand(text) { } }; - this.getStrokeStyle = function() { - return cur_shape.stroke_style; - }; - - this.setStrokeStyle = function(val) { - cur_shape.stroke_style = val; + this.setStrokeAttr = function(attr, val) { + cur_shape[attr.replace('-','_')] = val; var elems = []; var i = selectedElements.length; while (i--) { @@ -7003,10 +7067,10 @@ function BatchCommand(text) { } } if (elems.length > 0) { - this.changeSelectedAttribute("stroke-dasharray", val, elems); + this.changeSelectedAttribute(attr, val, elems); } }; - + this.getOpacity = function() { return cur_shape.opacity; }; @@ -8239,7 +8303,7 @@ function BatchCommand(text) { // Function: getVersion // Returns a string which describes the revision number of SvgCanvas. this.getVersion = function() { - return "svgcanvas.js ($Rev: 1470 $)"; + return "svgcanvas.js ($Rev: 1498 $)"; }; this.setUiStrings = function(strs) { diff --git a/public/svg-edit/editor/svgicons/jquery.svgicons.js b/public/svg-edit/editor/svgicons/jquery.svgicons.js index 4ead0a9c..f12b6917 100644 --- a/public/svg-edit/editor/svgicons/jquery.svgicons.js +++ b/public/svg-edit/editor/svgicons/jquery.svgicons.js @@ -293,6 +293,17 @@ $(function() { var svgroot = svgdoc.createElementNS(svgns, "svg"); svgroot.setAttributeNS(svgns, 'viewBox', [0,0,icon_w,icon_h].join(' ')); + // Make flexible by converting width/height to viewBox + var w = svg.getAttribute('width'); + var h = svg.getAttribute('height'); + svg.removeAttribute('width'); + svg.removeAttribute('height'); + + var vb = svg.getAttribute('viewBox'); + if(!vb) { + svg.setAttribute('viewBox', [0,0,w,h].join(' ')); + } + $(svgroot).attr({ "xmlns": svgns, "width": icon_w,