diff --git a/Makefile b/Makefile index 16b4519..d7968c4 100644 --- a/Makefile +++ b/Makefile @@ -11,8 +11,7 @@ JS_FILES=\ js-hotkeys/jquery.hotkeys.min.js \ jquerybbq/jquery.bbq.min.js \ svgicons/jquery.svgicons.js \ - jgraduate/jquery.jgraduate.min.js \ - spinbtn/JQuerySpinBtn.min.js \ + jgraduate/jquery.jgraduate.js \ touch.js \ contextmenu/jquery.contextmenu.js \ browser.js \ @@ -27,8 +26,8 @@ JS_FILES=\ path.js \ svgcanvas.js \ svg-editor.js \ + jquery-draginput.js \ contextmenu.js \ - locale/locale.js \ jquery-ui/jquery-ui-1.8.17.custom.min.js \ jgraduate/jpicker.min.js \ mousewheel.js \ @@ -36,6 +35,7 @@ JS_FILES=\ extensions/ext-markers.js \ extensions/ext-grid.js \ extensions/ext-shapes.js \ + requestanimationframe.js CSS_FILES=\ fonts.css \ diff --git a/editor/draginput.js b/editor/draginput.js new file mode 100644 index 0000000..64d7c03 --- /dev/null +++ b/editor/draginput.js @@ -0,0 +1,97 @@ +/* 2012 Mark MacKay, MIT License*/ + +(function() { + var $; + $ = jQuery; + $.fn.extend({ + dragInput: function(options) { + + var settings = { + decimals: 0, + dragArea: 100, + moveCallback: function(){}, + cursorColor: "#c00" + }; + + settings = $.extend(settings, options); + var input = $(this).find('input').first(); + var dragInput = $(this) + var cursor = $("
").appendTo(dragInput); + // initial values + var min = input.attr("data-min") || 0; + var max = input.attr("data-max") || 100; + var step = input.attr("data-step") || 1; + var val = input.attr("value") || 0; + var dragArea = settings.dragArea; + var cursorArea = dragInput.height(); + dragInput.attr("readonly", "readonly") + var change = function(){ + cursor.css("top", (input.attr("value")*-1) * (cursorArea/(max-min)) + cursorArea) + }; + + change(); + + var start = function(event) { + $('body').addClass('grabbing') + var oy = event.pageY; + var val = parseFloat(input.attr('value')); + var el_oy = dragInput.offset().top; + //updates on move and end + $(window).bind("mousemove.dragInput touchmove.dragInput", function(e) {move(e, oy, val, el_oy)}); + $(window).bind("mouseup.dragInput touchend.dragInput", end); + }; + + + var move = function(e, oy, val, el_oy) { + var y = e.pageY; + var range = (max-min) / dragArea + var dy = (y - oy)*-1 + val/range; + val = range * dy + if (val > max) { + var offset = (val*-1) * (cursorArea/(max-min)) + cursorArea; + if (offset > -30) { dragInput.css({"-webkit-transform": "translate(0,"+ (offset) +"px)"})} + else {dragInput.addClass("rubberband")} + val = max; + } + if (val < min) { + var offset = (val*-1) * (cursorArea/(max-min)); + if (offset > 30) {dragInput.addClass("rubberband")} + else {dragInput.css({"-webkit-transform": "translate(0,"+ (offset) +"px)"})} + val = min; + } + cursor.css("top", (val*-1) * (cursorArea/(max-min)) + cursorArea) + input.attr("value", parseFloat(Math.round(val * 100) / 100).toFixed(settings.decimals)); + settings.moveCallback(); + }; + + var dblclick = function() { + dragInput.unbind("mousedown.dragInput touchstart.dragInput"); + input.removeAttr('readonly'); + input.focus() + input.select() + }; + + var relock = function() { + input.attr('readonly', 'readonly'); + dragInput.bind("mousedown.dragInput touchstart.dragInput", start); + } + + var end = function() { + $(window).unbind("mousemove.dragInput touchmove.dragInput"); + $(window).unbind("mouseup.dragInput touchend.dragInput"); + dragInput.removeClass("rubberband").removeAttr("style") + $('body').removeClass('grabbing'); + }; + + + return this.each(function() { + $(this).bind("mousedown.dragInput touchstart.dragInput", start); + $(this).bind("dblclick.dragInput tapHold.dragInput", dblclick); + input.bind("blur.dragInput", relock); + input.bind("keypress.dragInput", function(e){if (e.keyCode == 13) input.trigger("blur.dragInput")}); + input.bind("change.dragInput", function(){change()}) + + }); + } + }); +}).call(this); diff --git a/editor/dragupload.js b/editor/dragupload.js new file mode 100644 index 0000000..0ee0dff --- /dev/null +++ b/editor/dragupload.js @@ -0,0 +1,11 @@ +window.onload = function () { + document.querySelector('body').addEventListener('drop', function(e) { + e.preventDefault(); + var reader = new FileReader(); + reader.onload = function(evt) { + //document.querySelector('img').src = evt.target.result; + }; + + reader.readAsDataURL(e.dataTransfer.files[0]); + }, false); +} \ No newline at end of file diff --git a/editor/history.js b/editor/history.js index 4767876..3ea41f9 100644 --- a/editor/history.js +++ b/editor/history.js @@ -343,12 +343,12 @@ svgedit.history.ChangeElementCommand.prototype.unapply = function(handler) { if(!bChangedTransform) { var angle = svgedit.utilities.getRotationAngle(this.elem); if (angle) { - var bbox = elem.getBBox(); + var bbox = this.elem.getBBox(); var cx = bbox.x + bbox.width/2, cy = bbox.y + bbox.height/2; var rotate = ["rotate(", angle, " ", cx, ",", cy, ")"].join(''); - if (rotate != elem.getAttribute("transform")) { - elem.setAttribute("transform", rotate); + if (rotate != this.elem.getAttribute("transform")) { + this.elem.setAttribute("transform", rotate); } } } diff --git a/editor/images/drag.png b/editor/images/drag.png new file mode 100644 index 0000000..3b00748 Binary files /dev/null and b/editor/images/drag.png differ diff --git a/editor/images/dragging.png b/editor/images/dragging.png new file mode 100644 index 0000000..9376a1c Binary files /dev/null and b/editor/images/dragging.png differ diff --git a/editor/images/svg_edit_icons.svg b/editor/images/svg_edit_icons.svg index 2815533..deb2c62 100644 --- a/editor/images/svg_edit_icons.svg +++ b/editor/images/svg_edit_icons.svg @@ -2,37 +2,10 @@- | Layer 1 | -