From 7619906dd3ff9098af796bd9099cf6f6400eaf5d Mon Sep 17 00:00:00 2001 From: Mark MacKay Date: Mon, 23 Jul 2012 21:30:12 -0500 Subject: [PATCH] changes everywhere --- Makefile | 6 +- editor/draginput.js | 97 + editor/dragupload.js | 11 + editor/history.js | 6 +- editor/images/drag.png | Bin 0 -> 403 bytes editor/images/dragging.png | Bin 0 -> 385 bytes editor/images/svg_edit_icons.svg | 35 +- editor/jacked.js | 2149 +++++++++++++++++++++ editor/jgraduate/jquery.jgraduate.js | 8 +- editor/jquery-draginput.js | 202 ++ editor/requestanimationframe.js | 24 + editor/select.js | 45 +- editor/spinbtn/JQuerySpinBtn.css | 13 +- editor/spinbtn/spinner.svg | 1 + editor/svg-editor.css | 600 +++--- editor/svg-editor.html | 608 ++---- editor/svg-editor.js | 1354 +++---------- editor/svgcanvas.js | 236 ++- editor/svgedit.compiled.css | 111 +- editor/svgedit.compiled.js | 1346 +++++++------ editor/temp.css | 614 +++--- method-draw/draginput.js | 97 + method-draw/dragupload.js | 11 + method-draw/history.js | 6 +- method-draw/images/drag.png | Bin 0 -> 403 bytes method-draw/images/dragging.png | Bin 0 -> 385 bytes method-draw/images/svg_edit_icons.svg | 35 +- method-draw/index.html | 2 +- method-draw/jacked.js | 2149 +++++++++++++++++++++ method-draw/jgraduate/jquery.jgraduate.js | 8 +- method-draw/jquery-draginput.js | 202 ++ method-draw/requestanimationframe.js | 24 + method-draw/select.js | 45 +- method-draw/spinbtn/JQuerySpinBtn.css | 13 +- method-draw/spinbtn/spinner.svg | 1 + method-draw/svg-editor.css | 600 +++--- method-draw/svg-editor.html | 608 ++---- method-draw/svg-editor.js | 1354 +++---------- method-draw/svgcanvas.js | 236 ++- method-draw/svgedit.compiled.css | 111 +- method-draw/svgedit.compiled.js | 1346 +++++++------ method-draw/temp.css | 614 +++--- 42 files changed, 8998 insertions(+), 5930 deletions(-) create mode 100644 editor/draginput.js create mode 100644 editor/dragupload.js create mode 100644 editor/images/drag.png create mode 100644 editor/images/dragging.png create mode 100644 editor/jacked.js create mode 100644 editor/jquery-draginput.js create mode 100644 editor/requestanimationframe.js create mode 100644 editor/spinbtn/spinner.svg create mode 100644 method-draw/draginput.js create mode 100644 method-draw/dragupload.js create mode 100644 method-draw/images/drag.png create mode 100644 method-draw/images/dragging.png create mode 100644 method-draw/jacked.js create mode 100644 method-draw/jquery-draginput.js create mode 100644 method-draw/requestanimationframe.js create mode 100644 method-draw/spinbtn/spinner.svg 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 0000000000000000000000000000000000000000..3b00748c1a30489c19dff47619fb0c1579253a25 GIT binary patch literal 403 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3HQmSQK*5Dp-y;YjHK@;M7UB8wRq zxP?HN@zUM8KR`jz64!_l=c3falFa-(g^BSU>dqn8US)&LdAfD{Dhry*8`hYSQ-?H5mxYhaWB zp~M#p7c|F8uv~PW&*&su6?{aTuehvEWnRkDl)3ZoTidd?J!}-1zFo?RqeZ|?kj1fY zi_5d%rY(M+tvQJkbU*j)zsj&SEOX+_V$B8n?IU(G^hXaKA8oJL7w&dvh31X3 z4;-JrVVAqXpnm1?HV5&Awi}wxJFgd+c|%nCcuCngOWX5nR)sti`)VKjdeN(`G8?93 owwi7bmKNmw(DN#O#X;_Sr3;q!CX`*T0s5Q4)78&qol`;+0L#FgdH?_b literal 0 HcmV?d00001 diff --git a/editor/images/dragging.png b/editor/images/dragging.png new file mode 100644 index 0000000000000000000000000000000000000000..9376a1ca981dc73738af54fbda260175525d0724 GIT binary patch literal 385 zcmeAS@N?(olHy`uVBq!ia0vp^!XV7S1|*9D%+3HQmSQK*5Dp-y;YjHK@;M7UB8wRq zxP?HN@zUM8KR`jz64!_l=c3falFa-(g^BSU>dqn8US)&LdAfD{Dhr4p`Bd9NrQg^P8JrNiOdh*{yzLp%{Y1Wtz5TX*%E1OFQVCU zo}HScn6R_{{&Xq#jKmc)+Lv}VT#I&#V7vEd@kt96N%ij=c(!O?n`<)pW02RUby~9+ z?G44QzbZA82y diff --git a/editor/jacked.js b/editor/jacked.js new file mode 100644 index 0000000..d888a93 --- /dev/null +++ b/editor/jacked.js @@ -0,0 +1,2149 @@ +// © CodingJack www.codingjack.com +// License: http://creativecommons.org/licenses/by-sa/3.0/ +// www.codingjack.com/playground/jacked/ +// 16kb minified: www.codingjack.com/playground/jacked/js/codingjack/Jacked.min.js + +;(function() { + + var compute = window.getComputedStyle ? document.defaultView.getComputedStyle : null, + request = timeline("Request", "AnimationFrame"), + cancel = timeline("Cancel", "AnimationFrame"), + temp = document.createElement("span").style, + agent = navigator.userAgent.toLowerCase(), + defaultEase = "Quint.easeOut", + defaultDuration = 500, + speeds = getSpeed(), + dictionary = [], + css = getCSS(), + engineRunning, + transformProp, + length = 0, + skeleton, + timeout, + element, + browser, + useCSS, + moved, + timer, + trans, + run, + leg, + rip, + itm, + clrs, + mobile, + gotcha, + colors, + borColor, + accelerate, + comma = /,/g, + reg = /[A-Z]/g, + regP = /{props}/, + regE = /{easing}/, + regT = / cj-tween/g, + regD = /{duration}/, + trim = /^\s+|\s+$/g, + positions = /(right|bottom|center)/, + + // credit: http://www.bitstorm.org/jquery/color-animation/ + color2 = /#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])/, + color1 = /#([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})/, + + // true = use CSS3 above all else when available, false = use requestAnimationFrame with Timer fallback + // combining browsers + mobile devices is not currently supported (i.e. all Android browsers will be passed the "android" parameter) + // Microsoft added for the future, will fallback to request/timer for now + defaults = {ios: false, android: false, winMobile: false, firefox: false, chrome: false, safari: false, opera: false, ie: false}, + + // set timer speed and check for IE + intervalSpeed = speeds[0], + version = speeds[1], + isIE = version !== 0 && version < 9; + + // if css3 transitions are supported + if(css) { + + var pre = css[1], sheet = document.createElement("style"); + transformProp = getTransform(); + mobile = getMobile(); + + sheet.type = "text/css"; + sheet.innerHTML = ".cj-tween{" + pre + "-property:none !important;}"; + document.getElementsByTagName("head")[0].appendChild(sheet); + + skeleton = pre + "-property:{props};" + pre + "-duration:{duration}s;" + pre + "-timing-function:cubic-bezier({easing});"; + browser = !mobile ? css[2] : mobile; + borColor = /(chrome|opera)/.test(browser); + + // force hardware acceleration in safari and ios. + accelerate = browser === "safari" || browser === "ios"; + css = css[0]; + + setDefaults(); + + } + + if(!isIE) { + + element = HTMLElement; + + clrs = /(#|rgb)/; + gotcha = /(auto|inherit|rgb|%|#)/; + + } + // IE8 + else if(version === 8) { + + element = Element; + + // support for commonly named colors in IE8 + clrs = /(#|rgb|red|blue|green|black|white|yellow|pink|gray|grey|orange|purple)/; + gotcha = /(auto|inherit|rgb|%|#|red|blue|green|black|white|yellow|pink|gray|grey|orange|purple)/; + colors = { + + red: "#F00", + blue: "#00F", + green: "#0F0", + black: "#000", + white: "#FFF", + yellow: "#FF0", + pink: "#FFC0CB", + gray: "#808080", + grey: "#808080", + orange: "#FFA500", + purple: "#800080" + + }; + + } + // Bounce for < IE8 + else { + + return; + + } + + // extend the DOM Element + element.prototype.jacked = function(to, sets) { + + Jacked.tween(this, to, sets); + + } + + element.prototype.fadeInJacked = function(sets) { + + Jacked.fadeIn(this, sets); + + } + + element.prototype.fadeOutJacked = function(sets) { + + Jacked.fadeOut(this, sets); + + } + + element.prototype.transformJacked = function(to, sets, fallback) { + + Jacked.transform(this, to, sets, fallback); + + } + + element.prototype.percentageJacked = function(to, sets) { + + Jacked.percentage(this, to, sets); + + } + + element.prototype.stopJacked = function(complete, callback) { + + Jacked.stopTween(this, complete, callback); + + } + + // extend Array if necessary + if(!Array.prototype.indexOf) { + + Array.prototype.indexOf = function($this) { + + var i = this.length; + + while(i--) { + + if(this[i] === $this) return i; + + } + + return -1; + + } + + } + + // credit https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date/now + if(!Date.now) { + + Date.now = function now() { + + return +(new Date); + + } + + } + + // static methods + this.Jacked = { + + ready: function(callback) { + + window.onload = callback; + + }, + + setEngines: function(settings) { + + for(var prop in settings) { + + if(defaults.hasOwnProperty(prop)) defaults[prop] = settings[prop]; + + } + + setDefaults(); + + }, + + tween: function(obj, to, settings) { + + if(obj.cj) obj.cj.stop(); + if(!settings) settings = {}; + + if(!settings.mode) { + + if(!css || !useCSS) { + + new CJ(obj, to, settings); + + } + else { + + new CJcss(obj, to, settings); + + } + + } + else if(settings.mode === "timeline" || !css) { + + new CJ(obj, to, settings); + + } + else { + + new CJcss(obj, to, settings); + + } + + }, + + fadeIn: function(obj, settings) { + + if(!settings) settings = {}; + settings.fadeIn = true; + + Jacked.tween(obj, {opacity: 1}, settings); + + }, + + fadeOut: function(obj, settings) { + + if(!settings) settings = {}; + settings.fadeOut = true; + + Jacked.tween(obj, {opacity: 0}, settings); + + }, + + percentage: function(obj, to, settings) { + + if(obj.cj) obj.cj.stop(); + if(!("from" in to) || !("to" in to)) return; + if(!settings) settings = {}; + + var mode = settings.mode; + + if(!mode) { + + if(css && useCSS) { + + percCSS(obj, to, settings); + + } + else { + + new CJpercentage(obj, to, settings); + + } + + return; + + } + + if(mode === "css3" && css) { + + percCSS(obj, to, settings); + return; + + } + + new CJpercentage(obj, to, settings); + + }, + + special: function(obj, settings) { + + if(obj.cj) obj.cj.stop(); + + new CJspecial(obj, settings); + + }, + + transform: function(obj, to, settings, fallback) { + + if(obj.cj) obj.cj.stop(); + + if(css && transformProp) { + + if(!settings) settings = {}; + settings.mode = "css3"; + + if("transform" in to) { + + to[transformProp] = to.transform; + delete to.transform; + + } + + new Jacked.tween(obj, to, settings); + + } + else if(fallback) { + + new Jacked.tween(obj, fallback, settings); + + } + + }, + + stopTween: function(obj, complete, callback) { + + var itm = obj.cj; + if(!itm) return; + + if(!itm.isCSS) { + + itm.stop(complete, callback); + + } + else { + + itm.stop(callback); + + } + + }, + + stopAll: function(complete) { + + (cancel) ? cancel(engine) : clearInterval(timer); + + var i = dictionary.length, itm; + length = 0; + + while(i--) { + + itm = dictionary[i]; + + if(!itm.isCSS) { + + itm.stop(complete, false, true, true); + + } + else { + + itm.stop(false, true); + + } + + } + + dictionary = []; + engineRunning = false; + itm = trans = null; + + }, + + setEase: function(easing) { + + var ar = easing.toLowerCase().split("."); + + if(ar.length < 2) return; + if(!PennerEasing[ar[0]]) return; + if(!PennerEasing[ar[0]][ar[1]]) return; + + defaultEase = easing; + + }, + + setDuration: function(num) { + + if(isNaN(num)) return; + + defaultDuration = num; + + }, + + getMobile: function() { + + return mobile; + + }, + + getIE: function() { + + return isIE; + + }, + + getBrowser: function() { + + return browser; + + }, + + getEngine: function() { + + return engineRunning; + + } + + } + + // ticker used for JS animations + function engine() { + + run = false; + leg = length; + + while(leg--) { + + itm = dictionary[leg]; + + if(!itm) break; + if(itm.isCss) continue; + + if(itm.cycle()) { + + run = true; + + } + else { + + itm.stop(false, itm.complete, false, true); + + } + + } + + if(request) { + + if(run) { + + request(engine); + + } + else { + + cancel(engine); + itm = trans = null + + } + + } + else { + + if(run) { + + if(!engineRunning) timer = setInterval(engine, intervalSpeed); + + } + else { + + clearInterval(timer); + itm = trans = null + + } + + } + + engineRunning = run; + + } + + // default JS transition + this.CJ = function(obj, to, sets) { + + length = dictionary.length; + + var $this = obj.cj = dictionary[length++] = this; + + this.runner = function(force) { + + $this.obj = obj; + $this.complete = sets.callback; + $this.completeParams = sets.callbackParams; + + if(force === true) { + + $this.transitions = []; + return; + + } + + var key, + i = 0, + tweens = [], + style = obj.style; + duration = sets.duration || defaultDuration, + easing = (sets.ease || defaultEase).toLowerCase().split("."); + easing = PennerEasing[easing[0]][easing[1]]; + + style.visibility = "visible"; + + if(sets.fadeIn) { + + style.display = sets.display || "block"; + style.opacity = 0; + + } + + if(isIE && "opacity" in to && !obj.filters.length) { + + style.filter = "progid:DXImageTransform.Microsoft.Alpha(opacity=" + (sets.fadeIn ? 0 : 100) + ")"; + + } + + if(to.borderColor && !borColor) { + + var clr = to.borderColor; + + to.borderTopColor = clr; + to.borderRightColor = clr; + to.borderBottomColor = clr; + to.borderLeftColor = clr; + + delete to.borderColor; + + } + + for(key in to) { + + if(key !== "backgroundPosition") { + + tweens[i++] = $this.animate(obj, key, to[key], duration, easing); + + } + else { + + tweens[i++] = $this.bgPosition(obj, key, to[key], duration, easing); + + } + + } + + $this.transitions = tweens; + (engineRunning) ? setTimeout(checkEngine, 10) : engine(); + + } + + if(sets.fadeOut) { + + obj.cjFadeOut = true; + + } + else if(sets.fadeIn) { + + obj.cjFadeIn = true; + + } + + if(sets.duration === 0) { + + this.runner(true); + this.stop(); + return; + + } + + if(!sets.delay) { + + this.runner(); + + } + else { + + this.delayed = setTimeout(this.runner, sets.delay); + + } + + } + + // cycles through all JS animations every frame/interval + CJ.prototype.cycle = function() { + + trans = this.transitions; + if(!trans) return true; + + rip = trans.length; + moved = false; + + while(rip--) { + + if(trans[rip]()) moved = true; + + } + + return moved; + + } + + // each JS animation runs through this function + CJ.prototype.animate = function(obj, prop, value, duration, ease) { + + var tick, style, val, opacity = prop === "opacity", passed = true; + + if(!opacity || !isIE) { + + style = obj.style; + val = style[prop]; + + tick = (val !== "") ? val : compute ? compute(obj, null)[prop] : obj.currentStyle[prop]; + + } + else { + + style = obj.filters.item("DXImageTransform.Microsoft.Alpha"); + prop = "Opacity"; + tick = style[prop]; + value *= 100; + + } + + if(!gotcha.test(tick)) { + + tick = parseFloat(tick); + + } + else { + + if(!clrs.test(tick)) { + + tick = 0; + + } + else { + + if(value.search("rgb") === -1) { + + if(isIE && tick in colors) tick = colors[tick]; + return this.color(obj, prop, tick, value, duration, ease); + + } + else { + + passed = false; + + } + + } + + } + + var px = !opacity ? "px" : 0, + constant = value - tick, + range = tick < value, + then = Date.now(), + begin = tick, + timed = 0, + finish, + pTick, + now, + px; + + finish = value + px; + + if(!opacity || isIE) { + + (range) ? value -= 0.25 : value += 0.25; + + } + else { + + (range) ? value -= .025 : value += .025; + + } + + function trans() { + + now = Date.now(); + timed += now - then; + tick = ease(timed, begin, constant, duration); + then = now; + + if(!opacity || isIE) { + + tick = range ? (tick + 0.5) | 0 : (tick - 0.5) | 0; + + } + else { + + tick = tick.toFixed(2); + + } + + if(tick === pTick) return true; + + if(range) { + + if(tick >= value) { + + style[prop] = finish; + return false; + + } + + } + else { + + if(tick <= value) { + + style[prop] = finish; + return false; + + } + + } + + pTick = tick; + style[prop] = tick + px; + + return true; + + } + + function cancelled() { + + return false; + + } + + if(passed) { + + trans.stored = [prop, finish]; + return trans; + + } + else { + + cancelled.stored = [prop, finish]; + return cancelled; + + } + + + } + + + // color transitions + CJ.prototype.color = function(obj, prop, tick, value, duration, ease) { + + var pound = value.search("#") !== -1 ? "" : "#", + finish = pound + value, + then = Date.now(), + style = obj.style, + passed = false, + starts = [], + ends = [], + timed = 0, + i = -1, + now, + clr, + st; + + if(tick.search("rgb") !== -1) { + + i = -1; + starts = tick.split("(")[1].split(")")[0].split(","); + while(++i < 3) starts[i] = parseInt(starts[i]); + + } + else { + + starts = getColor(tick); + + } + + ends = getColor(value); + i = -1; + + while(++i < 3) { + + if(starts[i] !== ends[i]) passed = true; + + } + + function trans() { + + now = Date.now(); + timed += now - then; + then = now; + + tick = ease(timed, 0, 1, duration); + + if(tick < 0.99) { + + i = -1; + st = "rgb("; + + while(++i < 3) { + + clr = starts[i]; + st += (clr + tick * (ends[i] - clr)) | 0; + if(i < 2) st += ","; + + } + + style[prop] = st + ")"; + return true; + + } + else { + + style[prop] = finish; + return false; + + } + + } + + function cancelled() { + + return false; + + } + + if(passed) { + + trans.stored = [prop, finish]; + return trans; + + } + else { + + cancelled.stored = [prop, finish]; + return cancelled; + + } + + } + + + // animates bgPosition + CJ.prototype.bgPosition = function(obj, prop, value, duration, ease) { + + var style = obj.style, + val = style[prop], + then = Date.now(), + passed = true, + ie = isIE, + timed = 0, + finalX, + finalY, + finish, + passed, + prevX, + prevY, + style, + hasX, + hasY, + difX, + difY, + tick, + now, + xx, + yy, + x, + y; + + if(!ie) { + + tick = (val !== "") ? val.split(" ") : compute(obj, null)["backgroundPosition"].split(" "); + + x = tick[0]; + y = tick[1]; + + } + else { + + x = obj.currentStyle.backgroundPositionX; + y = obj.currentStyle.backgroundPositionY; + + if(positions.test(x) || positions.test(y)) passed = false; + + if(x === "left") x = 0; + if(y === "top") y = 0; + + } + + if(x.search("%") !== -1) { + + if(x !== "0%") passed = false; + + } + + if(y.search("%") !== -1) { + + if(y !== "0%") passed = false; + + } + + x = parseInt(x); + y = parseInt(y); + + if(value.hasOwnProperty("x")) { + + xx = value.x; + hasX = true; + + } + else { + + xx = x; + hasX = false; + + } + + if(value.hasOwnProperty("y")) { + + yy = value.y; + hasY = true; + + } + else { + + yy = y; + hasY = false; + + } + + hasX = hasX && x !== xx; + hasY = hasY && y !== yy; + if(!hasX && !hasY) passed = false; + + difX = xx - x; + difY = yy - y; + finalX = xx + "px"; + finalY = yy + "px"; + finish = !ie ? finalX + " " + finalY : [finalX, finalY]; + + function trans() { + + now = Date.now(); + timed += now - then; + then = now; + + tick = ease(timed, 0, 1, duration); + + if(tick < 0.99) { + + if(hasX) { + + xx = ((x + (difX * tick)) + 0.5) | 0; + + } + + if(hasY) { + + yy = ((y + (difY * tick)) + 0.5) | 0; + + } + + if(xx === prevX && yy === prevY) return true; + + prevX = xx; + prevY = yy; + + if(!ie) { + + style.backgroundPosition = xx + "px" + " " + yy + "px"; + + } + else { + + style.backgroundPositionX = xx + "px"; + style.backgroundPositionY = yy + "px"; + + } + + return true; + + } + else { + + if(!ie) { + + style[prop] = finish; + + } + else { + + style.backgroundPositionX = finalX; + style.backgroundPositionY = finalY; + + } + + return false; + + } + + } + + function cancelled() { + + return false; + + } + + if(passed) { + + trans.stored = [prop, finish]; + return trans; + + } + else { + + cancelled.stored = [prop, finish]; + return cancelled; + + } + + } + + // stops JS animations + CJ.prototype.stop = function(complete, callback, popped) { + + var element = this.obj; + + if(!element) { + + clearTimeout(this.delayed); + + this.runner(true); + this.stop(complete, callback); + + return; + + } + + delete element.cj; + + if(complete) { + + var group = this.transitions, i = group.length, ar, prop; + + while(i--) { + + ar = group[i].stored; + prop = ar[0]; + + if(!isIE) { + + element.style[prop] = ar[1]; + + } + else { + + switch(prop) { + + case "Opacity": + + element.filters.item("DXImageTransform.Microsoft.Alpha").Opacity = ar[1] * 100; + + break; + + case "backgroundPosition": + + var style = element.style; + style.backgroundPositionX = ar[1][0]; + style.backgroundPositionY = ar[1][1]; + + break; + + default: + + element.style[prop] = ar[1]; + + // end default + + } + + } + + } + + } + + checkElement(element); + if(callback) callback = this.complete; + if(!popped) popTween(this, element, callback, this.completeParams); + + } + + + // CSS3 Transitions + this.CJcss = function(obj, to, sets) { + + length = dictionary.length; + + var $this = obj.cj = dictionary[length++] = this, + style = obj.style, transform = transformProp in to; + + this.isCss = true; + this.storage = obj; + this.complete = sets.callback; + this.completeParams = sets.callbackParams; + + this.runner = function() { + + if(!sets.cssStep) { + + $this.step(); + + } + else { + + style.visibility = "visible"; + $this.stepped = setTimeout($this.step, 30); + + } + + } + + this.step = function(added) { + + $this.obj = obj; + + if(added === true) { + + $this.moves = ""; + return; + + } + + var j, + key, + str, + cur, + orig, + bgPos, + i = 0, + finder, + moving, + replaced, + values = [], + tweens = [], + current = obj.getAttribute("style") || "", + duration = sets.duration || defaultDuration, + easing = (sets.ease || defaultEase).toLowerCase().split("."); + + for(key in to) { + + str = key; + finder = str.match(reg); + + if(finder) { + + j = finder.length; + + while(j--) { + + cur = finder[j]; + str = str.replace(new RegExp(cur, "g"), "-" + cur.toLowerCase()); + + } + + } + + cur = orig = to[key]; + bgPos = key === "backgroundPosition"; + + if(!gotcha.test(cur) && key !== "opacity" && !bgPos && !transform) { + + cur += "px;"; + + } + else if(!bgPos) { + + cur += ";"; + + } + else { + + var x = orig.x, y = orig.y, isX = isNaN(x), isY = isNaN(y); + + if(!isX && !isY) { + + x += "px"; + y += "px"; + + } + else { + + var val = style.backgroundPosition, + tick = (val !== "") ? val.split(" ") : compute(obj, null)["backgroundPosition"].split(" "); + + (!isX) ? x += "px" : x = tick[0]; + (!isY) ? y += "px" : y = tick[1]; + + } + + cur = x + " " + y + ";"; + + } + + values[i] = str + ":" + cur; + tweens[i++] = str; + + if(!current) continue; + finder = current.search(str); + + if(finder !== -1) { + + total = current.length - 1; + j = finder - 1; + + while(++j < total) { + + if(current[j] === ";") break; + + } + + current = current.split(current.substring(finder, j + 1)).join(""); + + } + + } + + $this.moves = moving = skeleton.replace(regP, tweens.toString()).replace(regD, (duration * .001).toFixed(2)).replace(regE, CeaserEasing[easing[0]][easing[1]]); + + replaced = values.toString(); + if(!transform) replaced = replaced.replace(comma, ""); + + obj.className = obj.className.replace(regT, ""); + obj.addEventListener(css, cssEnded, false); + obj.setAttribute("style", current.replace(trim, "") + moving + replaced); + + } + + if(!sets.fadeIn) { + + if(sets.fadeOut) obj.cjFadeOut = true; + + } + else { + + obj.cjFadeIn = true; + style.display = sets.display || "block"; + style.opacity = 0; + + } + + if(sets.duration === 0) { + + this.runner(true); + this.stop(); + return; + + } + + if(!sets.cssStep) style.visibility = "visible"; + + if(accelerate && !transform) { + + style["webkitTransform"] = "translate3d(0, 0, 0)"; + style["webkitBackfaceVisibility"] = "hidden"; + style["webkitPerspective"] = 1000; + + } + + if(!sets.delay) { + + this.delayed = setTimeout(this.runner, 30); + + } + else { + + this.delayed = setTimeout(this.runner, sets.delay > 30 ? sets.delay : 30); + + } + + } + + // stops a CSS3 Transition + CJcss.prototype.stop = function(callback, popped) { + + var element = this.obj, st; + if(callback) callback = this.complete; + + if(!element) { + + clearTimeout(this.delayed); + clearTimeout(this.stepped); + + checkElement(this.storage); + if(!popped) popTween(this, element, callback, this.completeParams); + + return; + + } + + delete element.cj; + + element.removeEventListener(css, cssEnded, false); + element.className += " cj-tween"; + element.setAttribute("style", element.getAttribute("style").split(this.moves).join(";").split(";;").join(";")); + + checkElement(element); + if(!popped) popTween(this, element, callback, this.completeParams); + + } + + // special call for animating percentages + this.CJpercentage = function(obj, to, sets) { + + length = dictionary.length; + + var $this = obj.cj = dictionary[length++] = this; + + this.obj = obj; + this.complete = sets.callback; + this.completeParams = sets.callbackParams; + + this.runner = function() { + + var key, + i = 0, + ar = [], + prop, begin, end, + newbs = to["to"], + from = to["from"], + duration = sets.duration || defaultDuration, + easing = (sets.ease || defaultEase).toLowerCase().split("."); + easing = PennerEasing[easing[0]][easing[1]]; + + for(prop in from) { + + end = parseInt(newbs[prop], 10); + begin = parseInt(from[prop], 10); + + ar[i++] = [end > begin, prop, end, begin]; + + } + + obj.style.visibility = "visible"; + $this.transitions = $this.animate(obj, ar, duration, easing); + (engineRunning) ? setTimeout(checkEngine, 10) : engine(); + + } + + if(sets.duration === 0) { + + this.stop(); + return; + + } + + if(!sets.delay) { + + this.runner(); + + } + else { + + this.delayed = setTimeout(this.runner, sets.delay); + + } + + } + + CJpercentage.prototype.cycle = function() { + + return this.transitions(); + + } + + // animate percentages + CJpercentage.prototype.animate = function(obj, to, duration, ease) { + + var tick, timed = 0, then = Date.now(), now, i, style = obj.style, leg = to.length, itm, begin; + + return function(force) { + + now = Date.now(); + timed += now - then; + then = now; + + tick = ease(timed, 0, 1, duration); + i = leg; + + if(tick < 0.99 && !force) { + + while(i--) { + + itm = to[i]; + begin = itm[3]; + + if(itm[0]) { + + style[itm[1]] = (begin + ((itm[2] - begin) * tick)) + "%"; + + } + else { + + style[itm[1]] = (begin - ((begin - itm[2]) * tick)) + "%"; + + } + + } + + return true; + + } + else { + + while(i--) { + + itm = to[i]; + style[itm[1]] = itm[2] + "%"; + + } + + return false; + + } + + } + + } + + // stop a percentage animation + CJpercentage.prototype.stop = function(complete, callback, popped) { + + if("delayed" in this) clearTimeout(this.delayed); + var element = this.obj; + + delete element.cj; + if(complete && this.transitions) this.transitions(true); + + if(callback) callback = this.complete; + if(!popped) popTween(this, element, callback, this.completeParams); + + } + + // extends Jacked + this.CJspecial = function(obj, sets) { + + if(!sets || !sets.callback) return; + + length = dictionary.length; + dictionary[length++] = obj.cj = this; + + var callback = this.complete = sets.callback, + easing = sets.ease || defaultEase; + easing = easing.toLowerCase().split("."); + easing = PennerEasing[easing[0]][easing[1]]; + + this.obj = obj; + this.transitions = this.numbers(obj, sets.duration || defaultDuration, easing, callback); + + (engineRunning) ? setTimeout(checkEngine, 10) : engine(); + + } + + // extender cycle + CJspecial.prototype.cycle = function() { + + return this.transitions(); + + } + + // extender step + CJspecial.prototype.numbers = function(obj, duration, ease, callback) { + + var tick, timed = 0, then = Date.now(), now; + + return function() { + + now = Date.now(); + timed += now - then; + then = now; + + tick = ease(timed, 0, 1, duration); + + if(tick < 0.99) { + + callback(obj, tick); + return true; + + } + else { + + return false; + + } + + } + + } + + // stop extender + CJspecial.prototype.stop = function(complete, callback, popped, finished) { + + var obj = this.obj; + + if(!obj) return; + delete obj.cj; + + if(!popped) popTween(this); + if(complete || finished) this.complete(obj, 1, callback); + + } + + // if CSS3 fadeIn/fadeOut gets aborted, restore the properties + function checkElement(element) { + + if(element.cjFadeIn) { + + delete element.cjFadeIn; + element.style.opacity = 1; + element.style.visibility = "visible"; + + } + else if(element.cjFadeOut) { + + delete element.cjFadeOut; + element.style.display = "none"; + + } + + } + + // checks to make sure the timeline engine starts + function checkEngine() { + + if(!engineRunning) engine(); + + } + + // removes the tween from memory when finished + function popTween($this, element, callback, params) { + + dictionary.splice(dictionary.indexOf($this), 1); + length = dictionary.length; + + if(callback) callback(element, params); + + } + + // CSS3 onEnded event + function cssEnded(event) { + + event.stopPropagation(); + + var $this = this.cj; + + if($this) $this.stop($this.complete); + + } + + // transform a CSS3 percentage call to a regular tween + function percCSS(obj, to, settings) { + + var newTo = {}, prop, goTo = to["to"]; + + for(prop in goTo) newTo[prop] = goTo[prop]; + + Jacked.tween(obj, newTo, settings); + + } + + // checks for requestAnimstionFrame support + function timeline(req, st) { + + return this["webkit" + req + st] || this["moz" + req + st] || this["o" + req + st] || this[req + st] || null; + + } + + // parse hex color + // credit: http://www.bitstorm.org/jquery/color-animation/ + function getColor(color) { + + var matched; + + if(matched = color1.exec(color)) { + + return [parseInt(matched[1], 16), parseInt(matched[2], 16), parseInt(matched[3], 16), 1]; + + } + else if(matched = color2.exec(color)) { + + return [parseInt(matched[1], 16) * 17, parseInt(matched[2], 16) * 17, parseInt(matched[3], 16) * 17, 1]; + + } + + } + + // IE9 uses a fast timer, legacy IE uses a slow timer + function getSpeed() { + + var point = agent.search("msie"); + + if(point === -1) { + + return [33.3, 0]; + + } + else { + + var ver = parseInt(agent.substr(point + 4, point + 5)), speed = ver >= 9 ? 16.6 : 33.3; + + return [speed, ver]; + + } + + } + + // sets the default tween behaviour (CSS3, timeline, timer) + function setDefaults() { + + for(var prop in defaults) { + + if(prop === browser) { + + useCSS = defaults[prop]; + break; + + } + + } + + } + + // tests for mobile support + function getMobile() { + + if(!"ontouchend" in document) { + + return null; + + } + else { + + if(agent.search("iphone") !== -1 || agent.search("ipad") !== -1) { + + return "ios"; + + } + else if(agent.search("android") !== -1) { + + return "android"; + + } + else if(agent.search("msie") !== -1) { + + return "winMobile"; + + } + + return null; + + } + + } + + // tests for CSS3 Transition support + function getCSS() { + + if("WebkitTransition" in temp) { + + return ["webkitTransitionEnd", "-webkit-transition", agent.search("chrome") !== -1 ? "chrome" : "safari"]; + + } + else if("MozTransition" in temp) { + + return ["transitionend", "-moz-transition", "firefox"]; + + } + else if("OTransition" in temp) { + + return ["oTransitionEnd", "-o-transition", "opera"]; + + } + else if("MSTransition" in temp) { + + return ["msTransitionEnd", "-ms-transition", "ie"]; + + } + else if("transition" in temp) { + + return ["transitionEnd", "transition", null]; + + } + + return null; + + } + + // tests for CSS3 transform support + function getTransform() { + + if("WebkitTransform" in temp) { + + return "WebkitTransform"; + + } + else if("MozTransform" in temp) { + + return "MozTransform"; + + } + else if("OTransform" in temp) { + + return "OTransform"; + + } + else if("msTransform" in temp) { + + return "msTransform"; + + } + else if("transform" in temp) { + + return "transform"; + + } + + return null; + + } + + + /* + TERMS OF USE - EASING EQUATIONS + + Open source under the BSD License. + + Copyright © 2001 Robert Penner + All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + var PennerEasing = { + + linear: { + + easenone: function(t, b, c, d) { + + return c * t / d + b; + + }, + + easein: function(t, b, c, d) { + + return c * t / d + b; + + }, + + easeout: function(t, b, c, d) { + + return c * t / d + b; + + }, + + easeinout: function(t, b, c, d) { + + return c * t / d + b; + + } + + }, + + quint: { + + easeout: function (t, b, c, d) { + + return c * ((t = t / d - 1) * t * t * t * t + 1) + b; + + }, + + easein: function(t, b, c, d) { + + return c * (t /= d) * t * t * t * t + b; + + }, + + easeinout: function(t, b, c, d) { + + return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t * t + b : c / 2 * ((t -= 2) * t * t * t * t + 2) + b; + + } + + }, + + quad: { + + easein: function (t, b, c, d) { + + return c * (t /= d) * t + b; + + }, + + easeout: function (t, b, c, d) { + + return -c * (t /= d) * (t - 2) + b; + + }, + + easeinout: function (t, b, c, d) { + + return ((t /= d / 2) < 1) ? c / 2 * t * t + b : -c / 2 * ((--t) * (t - 2) - 1) + b; + + } + + }, + + quart: { + + easein: function(t, b, c, d) { + + return c * (t /= d) * t * t * t + b; + + }, + + easeout: function(t, b, c, d) { + + return -c * ((t = t / d - 1) * t * t * t - 1) + b; + + }, + + easeinout: function(t, b, c, d) { + + return ((t /= d / 2) < 1) ? c / 2 * t * t * t * t + b : -c / 2 * ((t -= 2) * t * t * t - 2) + b; + + } + + }, + + cubic: { + + easein: function(t, b, c, d) { + + return c * (t /= d) * t * t + b; + + }, + + easeout: function(t, b, c, d) { + + return c * ((t = t / d - 1) * t * t + 1) + b; + + }, + + easeinout: function(t, b, c, d) { + + return ((t /= d / 2) < 1) ? c / 2 * t * t * t + b : c / 2 * ((t -= 2) * t * t + 2) + b; + + } + + }, + + circ: { + + easein: function(t, b, c, d) { + + return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b; + + }, + + easeout: function(t, b, c, d) { + + return c * Math.sqrt(1 - (t = t / d - 1) * t) + b; + + }, + + easeinout: function(t, b, c, d) { + + return ((t /= d / 2) < 1) ? -c / 2 * (Math.sqrt(1 - t * t) - 1) + b : c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b; + + } + + }, + + sine: { + + easein: function(t, b, c, d) { + + return -c * Math.cos(t / d * (Math.PI / 2)) + c + b; + + }, + + easeout: function(t, b, c, d) { + + return c * Math.sin(t / d * (Math.PI / 2)) + b; + + }, + + easeinout: function(t, b, c, d) { + + return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b; + + } + + }, + + expo: { + + easein: function(t, b, c, d) { + + return (t === 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b; + + }, + + easeout: function(t, b, c, d) { + + return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b; + + }, + + easeinout: function(t, b, c, d) { + + if(t === 0) return b; + if(t === d) return b + c; + if((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b; + + return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b; + + } + + } + + }, + + // credit: http://matthewlein.com/ceaser/ + + CeaserEasing = { + + linear: { + + easenone: "0.250, 0.250, 0.750, 0.750", + easein: "0.420, 0.000, 1.000, 1.000", + easeout: "0.000, 0.000, 0.580, 1.000", + easeinout: "0.420, 0.000, 0.580, 1.000" + + }, + + quint: { + + easein: "0.755, 0.050, 0.855, 0.060", + easeout: "0.230, 1.000, 0.320, 1.000", + easeinout: "0.860, 0.000, 0.070, 1.000" + + }, + + quad: { + + easein: "0.550, 0.085, 0.680, 0.530", + easeout: "0.250, 0.460, 0.450, 0.940", + easeinout: "0.455, 0.030, 0.515, 0.955" + + }, + + quart: { + + easein: "0.895, 0.030, 0.685, 0.220", + easeout: "0.165, 0.840, 0.440, 1.000", + easeinout: "0.770, 0.000, 0.175, 1.000" + + }, + + cubic: { + + easein: "0.550, 0.055, 0.675, 0.190", + easeout: "0.215, 0.610, 0.355, 1.000", + easeinout: "0.645, 0.045, 0.355, 1.000" + + }, + + circ: { + + easein: "0.600, 0.040, 0.980, 0.335", + easeout: "0.075, 0.820, 0.165, 1.000", + easeinout: "0.785, 0.135, 0.150, 0.860" + + }, + + sine: { + + easein: "0.470, 0.000, 0.745, 0.715", + easeout: "0.390, 0.575, 0.565, 1.000", + easeinout: "0.445, 0.050, 0.550, 0.950" + + }, + + expo: { + + easein: "0.950, 0.050, 0.795, 0.035", + easeout: "0.190, 1.000, 0.220, 1.000", + easeinout: "1.000, 0.000, 0.000, 1.000" + + } + + }; + + element = speeds = temp = null; + + +})(window); + + +// the jQuery plugin +if(typeof jQuery !== "undefined") { + + (function($) { + + $.fn.jacked = function(to, settings) { + + return this.each(createJack, [to, settings]); + + } + + $.fn.fadeInJacked = function(settings) { + + return this.each(showJack, [settings]); + + } + + $.fn.fadeOutJacked = function(settings) { + + return this.each(hideJack, [settings]); + + } + + $.fn.transformJacked = function(to, settings, fallback) { + + return this.each(transformJack, [to, settings, fallback]); + + } + + $.fn.percentageJacked = function(to, settings) { + + return this.each(percentageJack, [to, settings]); + + } + + $.fn.stopJacked = function(complete, callback) { + + return this.each(stopJack, [complete, callback]); + + } + + $.fn.stopJackedSet = function(complete) { + + return this.each(stopSet, [complete]); + + } + + function createJack(to, sets) { + + Jacked.tween(this, to, sets); + + } + + function showJack(sets) { + + Jacked.fadeIn(this, sets); + + } + + function hideJack(sets) { + + Jacked.fadeOut(this, sets); + + } + + function transformJack(to, sets, fallback) { + + Jacked.transform(this, to, sets, fallback); + + } + + function percentageJack(to, sets) { + + Jacked.percentage(this, to, sets); + + } + + function stopJack(complete, callback) { + + Jacked.stopTween(this, complete, callback); + + } + + function stopSet(complete) { + + recursiveStop($(this), complete); + + } + + function recursiveStop($this, complete) { + + $this.children().each(stopItem, [complete]); + + } + + function stopItem(complete) { + + Jacked.stopTween(this, complete); + recursiveStop($(this), complete); + + } + + })(jQuery); + +} + + + + + + + + + + + + + + diff --git a/editor/jgraduate/jquery.jgraduate.js b/editor/jgraduate/jquery.jgraduate.js index 4ef2aca..916ec1c 100644 --- a/editor/jgraduate/jquery.jgraduate.js +++ b/editor/jgraduate/jquery.jgraduate.js @@ -709,7 +709,7 @@ jQuery.fn.jGraduate = trans_img.setAttributeNS(ns.xlink, 'xlink:href', bg_image); - $(stopMakerSVG).click(function(evt) { + $(stopMakerSVG).on("click touchstart", function(evt) { stop_offset = stopMakerDiv.offset(); var target = evt.target; if(target.tagName === 'path') return; @@ -837,13 +837,13 @@ jQuery.fn.jGraduate = }); // bind GUI elements - $('#'+id+'_jGraduate_Ok').bind('click', function() { + $('#'+id+'_jGraduate_Ok').bind('click touchstart', function() { $this.paint.type = curType; $this.paint[curType] = curGradient.cloneNode(true);; $this.paint.solidColor = null; okClicked(); }); - $('#'+id+'_jGraduate_Cancel').bind('click', function(paint) { + $('#'+id+'_jGraduate_Cancel').bind('click touchstart', function(paint) { cancelClicked(); }); @@ -1112,7 +1112,7 @@ jQuery.fn.jGraduate = var tabs = $(idref + ' .jGraduate_tabs li'); - tabs.click(function() { + tabs.on("click touchstart", function() { tabs.removeClass('jGraduate_tab_current'); $(this).addClass('jGraduate_tab_current'); $(idref + " > div").hide(); diff --git a/editor/jquery-draginput.js b/editor/jquery-draginput.js new file mode 100644 index 0000000..88e8764 --- /dev/null +++ b/editor/jquery-draginput.js @@ -0,0 +1,202 @@ +// Mark MacKay http://method.ac MIT License + + +$.fn.dragInput = function(cfg){ + return this.each(function(){ + + this.repeating = false; + // Apply specified options or defaults: + // (Ought to refactor this some day to use $.extend() instead) + this.dragCfg = { + min: cfg && !isNaN(parseFloat(cfg.min)) ? Number(cfg.min) : null, // Fixes bug with min:0 + max: cfg && !isNaN(parseFloat(cfg.max)) ? Number(cfg.max) : null, + step: cfg && cfg.step ? Number(cfg.step) : 1, + stepfunc: cfg && cfg.stepfunc ? cfg.stepfunc : false, + page: cfg && cfg.page ? Number(cfg.page) : 10, + reset: cfg && cfg.reset ? cfg.reset : this.value, + delay: cfg && cfg.delay ? Number(cfg.delay) : 500, + interval: cfg && cfg.interval ? Number(cfg.interval) : 100, + height: 70, + cursor: cfg && cfg.cursor ? Boolean(cfg.cursor) : false, + start: cfg && cfg.start ? Number(cfg.start) : 0, + _btn_width: 20, + _direction: null, + _delay: null, + _repeat: null, + callback: cfg && cfg.callback ? cfg.callback : null + }; + // if a smallStep isn't supplied, use half the regular step + this.dragCfg.smallStep = cfg && cfg.smallStep ? cfg.smallStep : this.dragCfg.step/2; + + var $label = $(this).parent(); + var $input = $(this); + var cursorHeight = this.dragCfg.height; + var min = this.dragCfg.min; + var max = this.dragCfg.max + var step = this.dragCfg.step + var area = (max - min > 0) ? (max - min) / step : 200; + var scale = area/cursorHeight * step; + var lastY = 0; + var attr = this.getAttribute("data-attr"); + var canvas = svgEditor.canvas + var selectedElems = canvas.getSelectedElems(); + var isTouch = svgedit.browser.isTouch(); + var $cursor = (area && this.dragCfg.cursor) + ? $("
").appendTo($label) + : false + if ($cursor && this.dragCfg.start) $cursor.css("top", (this.dragCfg.start*-1)/scale+cursorHeight) + //this is where all the magic happens + this.adjustValue = function(i, noUndo){ + var v; + if(isNaN(this.value)) { + v = this.dragCfg.reset; + } else if($.isFunction(this.dragCfg.stepfunc)) { + v = this.dragCfg.stepfunc(this, i); + } else { + // weirdest javascript bug ever: 5.1 + 0.1 = 5.199999999 + v = Number((Number(this.value) + Number(i)).toFixed(5)); + } + if (max !== null) v = Math.min(v, max); + if (min !== null) v = Math.max(v, min); + if ($cursor) this.updateCursor(v); + this.value = v; + $label.attr("data-value", v) + if ($.isFunction(this.dragCfg.callback)) this.dragCfg.callback(this, noUndo) + }; + + $label.toggleClass("draginput", $label.is("label")) + + // when the mouse is down and moving + this.move = function(e, oy, val) { + if (isTouch) { + e = e.originalEvent.touches[0] + } + // just got started let's save for undo purposes + if (lastY === 0) { + lastY = oy; + } + var deltaY = (e.pageY - lastY) *-1 + lastY = e.pageY; + val = deltaY * scale + var fixed = (step < 1) ? 1 : 0 + this.adjustValue(val.toFixed(fixed)) //no undo true + }; + + //when the mouse is released + this.stop = function() { + $('body').removeClass('dragging'); + $label.removeClass("active") + $(window).unbind("mousemove.draginput touchmove.draginput mouseup.draginput touchend.draginput"); + lastY = 0; + if (selectedElems[0]) { + var batchCmd = canvas.undoMgr.finishUndoableChange(); + if (!batchCmd.isEmpty()) canvas.undoMgr.addCommandToHistory(batchCmd); + } + this.adjustValue(0) + } + + this.updateCursor = function(){ + var value = parseFloat(this.value) + var pos = (value*-1)/scale+cursorHeight + $(this).next(".draginput_cursor").css("top", pos) + } + + this.start = function(e) { + if (isTouch) e = e.originalEvent.touches[0] + var oy = e.pageY; + var val = this.value; + var el = this; + canvas.undoMgr.beginUndoableChange(attr, selectedElems) + $('body').addClass('dragging'); + $label.addClass('active'); + $(window).bind("mousemove.draginput touchmove.draginput", function(e){el.move(e, oy, parseFloat(val))}) + $(window).bind("mouseup.draginput touchend.draginput", function(e){el.stop()}) + } + + $(this) + .attr("readonly", "readonly") + .attr("data-scale", scale) + .attr("data-domain", cursorHeight) + .attr("data-cursor", ($cursor != false)) + + .bind("mousedown touchstart", function(e){this.start(e);}) + + .bind("dblclick taphold", function(e) { + this.removeAttribute("readonly", "readonly"); + this.focus(); + this.select(); + }) + + .blur(function(e){ + this.setAttribute("readonly", "readonly"); + this.adjustValue(0) + }) + + .keydown(function(e){ + // Respond to up/down arrow keys. + switch(e.keyCode){ + case 13: this.blur(); break; // Enter + case 38: this.adjustValue(this.dragCfg.step); break; // Up + case 40: this.adjustValue(-this.dragCfg.step); break; // Down + case 33: this.adjustValue(this.dragCfg.page); break; // PageUp + case 34: this.adjustValue(-this.dragCfg.page); break; // PageDown + } + }) + + /* + http://unixpapa.com/js/key.html describes the current state-of-affairs for + key repeat events: + - Safari 3.1 changed their model so that keydown is reliably repeated going forward + - Firefox and Opera still only repeat the keypress event, not the keydown + */ + .keypress(function(e){ + if (this.repeating) { + // Respond to up/down arrow keys. + switch(e.keyCode){ + case 38: this.adjustValue(this.dragCfg.step); break; // Up + case 40: this.adjustValue(-this.dragCfg.step); break; // Down + case 33: this.adjustValue(this.dragCfg.page); break; // PageUp + case 34: this.adjustValue(-this.dragCfg.page); break; // PageDown + } + } + // we always ignore the first keypress event (use the keydown instead) + else { + this.repeating = true; + } + }) + + // clear the 'repeating' flag + .keyup(function(e) { + this.repeating = false; + switch(e.keyCode){ + case 38: // Up + case 40: // Down + case 33: // PageUp + case 34: // PageDown + case 13: this.adjustValue(0); break; // Enter/Return + } + }) + + .bind("mousewheel", function(e, delta, deltaX, deltaY){ + if (deltaY > 0) + this.adjustValue(this.dragCfg.step, true); + else if (deltaY < 0) + this.adjustValue(-this.dragCfg.step, true); + e.preventDefault(); + }) + + }); + + +}; + +// public function +$.fn.dragInput.updateCursor = function(el){ + var value = parseFloat(el.value); + var scale = parseFloat(el.getAttribute("data-scale")); + var domain = parseFloat(el.getAttribute("data-domain")); + var pos = ((value*-1)/scale+domain) + "px"; + var cursor = el.nextElementSibling + if (cursor) cursor.style.top = pos; +} + diff --git a/editor/requestanimationframe.js b/editor/requestanimationframe.js new file mode 100644 index 0000000..5716203 --- /dev/null +++ b/editor/requestanimationframe.js @@ -0,0 +1,24 @@ +(function() { + var lastTime = 0; + var vendors = ['ms', 'moz', 'webkit', 'o']; + for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { + window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; + window.cancelAnimationFrame = + window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; + } + + if (!window.requestAnimationFrame) + window.requestAnimationFrame = function(callback, element) { + var currTime = new Date().getTime(); + var timeToCall = Math.max(0, 16 - (currTime - lastTime)); + var id = window.setTimeout(function() { callback(currTime + timeToCall); }, + timeToCall); + lastTime = currTime + timeToCall; + return id; + }; + + if (!window.cancelAnimationFrame) + window.cancelAnimationFrame = function(id) { + clearTimeout(id); + }; +}()); diff --git a/editor/select.js b/editor/select.js index f2dac42..4332285 100644 --- a/editor/select.js +++ b/editor/select.js @@ -61,6 +61,10 @@ svgedit.select.Selector = function(id, elem) { } }) ); + + if (svgedit.browser.isTouch()) { + this.selectorRect.setAttribute("stroke-opacity", 0); + } // this holds a reference to the grip coordinates for this selector this.gripCoords = { @@ -228,17 +232,24 @@ svgedit.select.Selector.prototype.resize = function() { var xform = angle ? 'rotate(' + [angle,cx,cy].join(',') + ')' : ''; this.selectorGroup.setAttribute('transform', xform); - nbax -= 3.5; - nbay -= 3.5; + + if(svgedit.browser.isTouch()) { + nbax -= 15.75; + nbay -= 15.75; + } + else { + nbax -= 4; + nbay -= 4; + } this.gripCoords = { - 'nw': [nbax, nbay], - 'ne': [nbax+nbaw, nbay], - 'sw': [nbax, nbay+nbah], - 'se': [nbax+nbaw, nbay+nbah], - 'n': [nbax + (nbaw)/2, nbay], - 'w': [nbax, nbay + (nbah)/2], - 'e': [nbax + nbaw, nbay + (nbah)/2], - 's': [nbax + (nbaw)/2, nbay + nbah] + 'nw': [nbax, nbay].map(Math.round), + 'ne': [nbax+nbaw, nbay].map(Math.round), + 'sw': [nbax, nbay+nbah].map(Math.round), + 'se': [nbax+nbaw, nbay+nbah].map(Math.round), + 'n': [nbax + (nbaw)/2, nbay].map(Math.round), + 'w': [nbax, nbay + (nbah)/2].map(Math.round), + 'e': [nbax + nbaw, nbay + (nbah)/2].map(Math.round), + 's': [nbax + (nbaw)/2, nbay + nbah].map(Math.round) }; for(var dir in this.gripCoords) { @@ -351,15 +362,21 @@ svgedit.select.SelectorManager.prototype.initGroup = function() { 'element': 'rect', 'attr': { 'id': ('selectorGrip_resize_' + dir), - 'width': 7, - 'height': 7, + 'width': 8, + 'height': 8, 'fill': "#4F80FF", - 'stroke': "transparent", - 'stroke-width': 2, + 'stroke': "rgba(0,0,0,0)", + 'stroke-width': 1, 'style': ('cursor:' + dir + '-resize'), 'pointer-events': 'all' } }); + if (svgedit.browser.isTouch()) { + + grip.setAttribute("width", 30.5) + grip.setAttribute("height", 30.5) + grip.setAttribute("fill-opacity", 0.3) + } $.data(grip, 'dir', dir); $.data(grip, 'type', 'resize'); diff --git a/editor/spinbtn/JQuerySpinBtn.css b/editor/spinbtn/JQuerySpinBtn.css index 7a279a0..8849d06 100644 --- a/editor/spinbtn/JQuerySpinBtn.css +++ b/editor/spinbtn/JQuerySpinBtn.css @@ -23,19 +23,16 @@ */ INPUT.spin-button { - /* explicitly put padding for top/bottom/left in here so that Opera displays it better */ - padding: 2px 20px 2px 2px; - background-repeat:no-repeat; /* Warning: Img may disappear in Firefox if you use 'background-attachment:fixed' ! */ - background-position:100% 0%; - background-image:url('spinbtn_updn.png'); - background-color:white; /* Needed for Opera */ + + background: transparent url('spinner.svg') right top no-repeat; + background-size: 17px 54px; } INPUT.spin-button.up { /* Change button img when mouse is over the UP-arrow */ cursor:pointer; - background-position:100% -18px; /* 18px matches height of 2 visible buttons */ + background-position:100% -20px; /* 18px matches height of 2 visible buttons */ } INPUT.spin-button.down { /* Change button img when mouse is over the DOWN-arrow */ cursor:pointer; - background-position:100% -36px; /* 36px matches height of 2x2 visible buttons */ + background-position:100% -40px; /* 36px matches height of 2x2 visible buttons */ } diff --git a/editor/spinbtn/spinner.svg b/editor/spinbtn/spinner.svg new file mode 100644 index 0000000..a4e5635 --- /dev/null +++ b/editor/spinbtn/spinner.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/editor/svg-editor.css b/editor/svg-editor.css index aff8673..244e7ac 100644 --- a/editor/svg-editor.css +++ b/editor/svg-editor.css @@ -54,10 +54,6 @@ html, body { border-bottom: 1px solid #808080; } -#svg_editor select { - margin-top: 4px; -} - #svg_editor #svgroot { -moz-user-select: none; -webkit-user-select: none; @@ -92,6 +88,12 @@ html, body { vertical-align: top; } +.touch #svg_editor .menu_title { + padding: 7px 17px; + height: 26px; + line-height: 26px; +} + #svg_editor .menu .menu_title:hover { background: rgba(255,255,255,0.1); } @@ -113,6 +115,10 @@ html, body { box-shadow: 0 0 20px rgba(0,0,0,0.8); } +.touch #svg_editor .menu_list { + top: 38px; +} + #svg_editor #menu_bar.active .menu.open .menu_title { background: white; color: #333; @@ -212,7 +218,7 @@ html, body { height: 15px; top: 30px; left: 66px; - right: 200px; + right: 175px; border-top: solid #444 1px; border-right: solid #444 1px; } @@ -277,6 +283,11 @@ html, body { float: left; } +.touch #svg_editor div#palette_holder { + height: 40px; + margin-top: 0; +} + #svg_editor div#palette_holder #palette .palette_item:first-child { background: #fff; } @@ -286,30 +297,55 @@ html, body { } -#tool_stroke select { - margin-top: 0; -} - -#svg_editor #color_tools, #color_canvas_tools { +#svg_editor #color_tools { position: relative; width: 48px; height: 48px; margin: 6px 6px 0 6px; } -#svg_editor #color_tools #tool_fill, #tool_canvas { +.touch #svg_editor #color_tools { + width: auto; + height: auto; +} + +#tool_fill { position: absolute; top: 0; left: 0; z-index: 1; } +.touch #tool_fill { + position: static; + width: 36px; + height: 36px; + margin-bottom: 10px; +} + + #tool_fill.active, #tool_stroke.active { z-index: 2; } +#tool_stroke { + top: 14px; + left: 14px; +} + +.touch #tool_fill.active, .touch #tool_stroke.active { + outline: 4px solid #09f; +} + #tool_fill, #tool_stroke, #tool_canvas { box-shadow: 0 0 0 1px #2f2f2c; + position: absolute; +} + +.touch #tool_fill, .touch #tool_stroke, .touch #tool_canvas { + position: relative; + top: 0; + left: 0; } #color_canvas_tools { @@ -317,13 +353,31 @@ html, body { cursor: pointer; } -#tool_fill .color_block, #tool_canvas .color_block { +#tool_fill .color_block { width: 24px; height: 24px; overflow: hidden; border: solid #ccc 1px; } +.touch #svg_editor #tool_eyedropper { + margin-top: 6px; +} + +.touch #tool_fill .color_block { + width: 36px; + height: 36px; +} + +.touch #tool_fill .color_block svg { + width: 36px !important; + height: 36px !important; +} + +.touch #svg_editor #tool_switch { + display: none; +} + #svg_editor #path_node_panel .tool_button { color: #999; border: solid #3F3F3C 1px; @@ -369,6 +423,10 @@ html, body { left: 0; } +.touch #svg_editor #color_tools #tool_fill .color_block > div { + position: relative; +} + #svg_editor #color_tools #tool_fill .color_block #fill_bg, #svg_editor #color_tools #tool_stroke .color_block #stroke_bg { position: absolute; top: 1px; @@ -378,10 +436,17 @@ html, body { background: #fff; } -#tool_stroke { - position: absolute; - top: 12px; - left: 12px; +.touch #svg_editor #color_tools #tool_fill .color_block #fill_bg, .touch #svg_editor #color_tools #tool_stroke .color_block #stroke_bg { + width: 36px; + height: 36px; + right: auto; + bottom: auto; +} + +.touch #tool_stroke { + position: relative; + top: 0; + left: 0; z-index: 0; } @@ -397,6 +462,15 @@ html, body { box-shadow: 0 0 0 1px #000; } +.touch #stroke_color:after { + height: 14px; + left: 10px; + position: absolute; + top: 10px; + width: 14px; + +} + #svg_editor #color_tools #tool_switch { cursor: pointer; opacity: 0.7; @@ -423,19 +497,29 @@ html, body { border: solid #ccc 1px; } +.touch #svg_editor #color_tools #tool_stroke .color_block { + width: 36px; + height: 36px; +} + #svg_editor #color_tools #tool_stroke .color_block > div { position: absolute; bottom: 0; right: 0; } +.touch #svg_editor #color_tools #tool_stroke .color_block > div { + position: relative; +} + + #svg_editor #color_tools .icon_label { padding: 0; width: 24px; height: 100%; cursor: pointer; - + position: absolute; } #svg_editor #zoomLabel { @@ -450,7 +534,7 @@ html, body { #svg_editor div#palette { float: left; - width: 672px; + width: 810px; height: 16px; } @@ -460,157 +544,14 @@ html, body { top: 30px; left: 50px; bottom: 40px; - right: 200px; + right: 175px; background-color: #444; overflow: auto; text-align: center; } -#svg_editor #sidepanels { - display: none; - position:absolute; - top: 75px; - bottom: 60px; - right: 0px; - width: 2px; - padding: 10px; - border-left: none; - z-index: 10; -} - -#svg_editor #layerpanel { - display: inline-block; - position:absolute; - top: 1px; - bottom: 0px; - right: 0px; - width: 0px; - overflow: auto; - margin: 0px; - -moz-user-select: none; - -webkit-user-select: none; - -} - -#svg_editor #sidepanel_handle { - display: inline-block; - position: absolute; - background-color: #D0D0D0; - font-weight: bold; - left: 0px; - top: 40%; - width: 1em; - padding: 5px 1px 5px 5px; - margin-left: 3px; - cursor: pointer; - border-radius: 5px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - -moz-user-select: none; - -webkit-user-select: none; -} - -#svg_editor #sidepanel_handle:hover { - font-weight: bold; -} - -#svg_editor #sidepanel_handle * { - cursor: pointer; - -moz-user-select: none; - -webkit-user-select: none; -} -#svg_editor #layerbuttons { - margin: 0px; - padding: 0px; - padding-left: 2px; - padding-right: 2px; - width: 125px; - height: 20px; - border-right: 1px solid #FFFFFF; - border-bottom: 1px solid #FFFFFF; - border-left: 1px solid #808080; - border-top: 1px solid #808080; - overflow: hidden; -} - -#svg_editor .layer_button { - width: 14px; - height: 14px; - padding: 1px; - border-left: 1px solid #FFFFFF; - border-top: 1px solid #FFFFFF; - border-right: 1px solid #808080; - border-bottom: 1px solid #808080; - cursor: pointer; - float: left; - margin-right: 3px; -} - -#svg_editor .layer_button:last-child { - margin-right: 0; -} - -#svg_editor .layer_buttonpressed { - width: 14px; - height: 14px; - padding: 1px; - border-right: 1px solid #FFFFFF; - border-bottom: 1px solid #FFFFFF; - border-left: 1px solid #808080; - border-top: 1px solid #808080; - cursor: pointer; -} - -#svg_editor #layerlist { - margin: 1px; - padding: 0px; - width: 127px; - border-collapse: collapse; - border: 1px solid #808080; - background-color: #FFFFFF; -} - -#svg_editor #layerlist tr.layer { - background-color: #FFFFFF; - margin: 0px; - padding: 0px; -} -#svg_editor #layerlist tr.layersel { - border: 1px solid #808080; - background-color: #CCCCCC; -} - -#svg_editor #layerlist td.layervis { - width: 22px; - cursor:pointer; -} -#svg_editor #layerlist td.layerinvis { - background-image: none; - cursor:pointer; -} - -#svg_editor #layerlist td.layervis * { - display: block; -} - -#svg_editor #layerlist td.layerinvis * { - display: none; -} - -#svg_editor #layerlist td.layername { - cursor: pointer; -} - -#svg_editor #layerlist tr.layersel td.layername { - font-weight: bold; -} - -#svg_editor #selLayerLabel { - white-space: nowrap; -} - -#svg_editor #selLayerNames { - display: block; +.touch #svg_editor div#workarea { + top: 40px; } #svg_editor div.palette_item { @@ -619,6 +560,14 @@ html, body { float: left; } +.touch #svg_editor div.palette_item { + height: 30px; + border-top: solid #2f2f2c 5px; + border-bottom: solid #2f2f2c 5px; + width: 30px; + float: left; +} + #svg_editor .menu .menu_list { display: none; position: absolute; @@ -662,12 +611,16 @@ html, body { #svg_editor #tools_top { position: absolute; - width: 170px; - right: 2px; - top: 10px; + width: 160px; + right: 0; + top: 30px; border-bottom: none; overflow: visible; - padding: 0 10px; + padding: 0 0 0 10px; +} + +.touch #svg_editor #tools_top { + top: 40px; } #svg_editor label { @@ -706,29 +659,6 @@ div#font-selector .font-item:hover { background-color: #eee; } -#svg_editor #tools_top label:before, -#svg_editor #tools_top label:after { - content:""; - display:table; -} - -#svg_editor #tools_top label:after { - clear:both; -} - - -#svg_editor #tools_top label span, #svg_editor #tools_top label select { - display: block; - width: 80px; - float: left; - line-height: 185% -} - -#svg_editor #tools_top label span.tuco { - width: 100%; - float: none; -} - #svg_editor #tools_top #marker_panel * { float: left; } @@ -769,38 +699,11 @@ div#font-selector .font-item:hover { } - -#svg_editor input[type=text], #svg_editor input[type=number] { - border: solid #3f3f3c 1px; - background-color: transparent; - color: #09f; - display: block; - float: left; - font-size: 13px; - padding: 2px 5px; - width: 70px; - -webkit-appearance: none; - border-radius: 2px; - margin: 0; - -webkit-touch-callout: text; - -webkit-user-select: text; - -khtml-user-select: text; - -moz-user-select: text; - -ms-user-select: text; - user-select: text; -} - #svg_editor #color_picker input[type=text], #color_picker #svg_editor input[type=number] { width: 30px; background: #fff; } -input[type=number]::-webkit-inner-spin-button, -input[type=number]::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; -} - #svg_editor .dropdown_set input[type=text], #svg_editor .dropdown_set input[type=number] { width: 50px; } @@ -827,19 +730,6 @@ box-shadow: inset 0 3px 10px rgba(255, 255, 255, 0.1), #svg_editor input[type=submit]:hover, #svg_editor button:hover {background: #2F84C1;} #svg_editor input[type=submit]:active, #svg_editor button:active {padding: 6px 10px 4px 10px; box-shadow: inset 0 2px 2px rgba(0,0,0,0.2); border-bottom: solid rgba(255,255,255,0.1) 1px;} -#svg_editor input[type=text]:focus, #svg_editor input[type=number]:focus { - border: solid rgba(0, 120, 255, 0.3) 1px; - outline: none; -} - - -#svg_editor input[readonly=readonly], #svg_editor input[readonly=readonly]:focus { - background: transparent; - color: #fff; - border: none; - outline: none; -} - #svg_editor #tools_left { position: absolute; @@ -1137,11 +1027,6 @@ span.zoom_tool img { color: #fff; } -#svg_editor #tool_font_size { - clear:both; - padding-top: 8px; -} - #text { position: absolute; left: -9999px; @@ -1228,41 +1113,13 @@ span.zoom_tool img { width: 3.2em; } -#svg_editor .stroke_tool .dropdown button { - margin-top: 0; -} - -#svg_editor .stroke_tool div div { - -moz-user-select: none; - -webkit-user-select: none; - width: 20px; - height: 20px; - margin: 0; - padding: 1px; - background: rgba(255,255,255,0.3); -} - -#svg_editor #tools_bottom .stroke_tool .dropdown button { - background-color:#555; - margin-top: 0; -} - #svg_editor #tools_top h4 { color: #fff; font-weight: normal; margin: 0; - padding: 20px 0 5px 0; + padding: 0 0 10px 0; } -.stroke_tool > div { - width: 42px; -} - -.stroke_tool > div > * { - float: left; -} - - #tools_top .dropdown .icon_label { border: 1px solid transparent; /* margin-top: 3px;*/ @@ -1343,8 +1200,6 @@ span.zoom_tool img { -webkit-border-radius: 0; } -#svg_editor #tool_stroke label input { margin-top: 0;} - #svg_editor #copyright { text-align: right; padding-right: .3em; @@ -1913,6 +1768,10 @@ span.zoom_tool img { cursor: url(images/rotate.png) 12 12, auto; } +#workarea.select text, #workarea.multiselect text { + cursor: default; +} + #workarea.n-resize * {cursor: n-resize !important;} #workarea.e-resize * {cursor: e-resize !important;} #workarea.w-resize * {cursor: w-resize !important;} @@ -1923,7 +1782,9 @@ span.zoom_tool img { #workarea.nw-resize * {cursor: nw-resize !important;} #workarea.sw-resize * {cursor: sw-resize !important;} - +#workarea.copy { + cursor: copy; +} #workarea.zoom { cursor: crosshair; @@ -1981,4 +1842,205 @@ span.zoom_tool img { display: none; position: absolute; z-index: 20; -} \ No newline at end of file +} + +#svg_editor .draginput { + background: #3f3f3c; + border-radius: 3px; + -webkit-font-smoothing: antialiased; + width: 70px; + height: 70px; + display: block; + position: relative; + float: left; + margin: 0 5px 5px 0; + overflow: hidden; +} + +#svg_editor .draginput .caret { + border: solid transparent 5px; + border-top-color: #999; + position: absolute; + width: 0; + height: 0; + right: 5px; + margin-top: -2px; + top: 50%; +} + +#svg_editor .draginput label { + margin: 28px 10px 0 5px; + font-size: 11px; + +} + +#svg_editor .draginput label#resolution_label { + font: 12px/110% sans-serif; + color: white; + font-weight: bold; + position: absolute; + left: auto; + right: 10px; + z-index: 0; + text-align: right; +} + +#svg_editor .draginput label#resolution_label .pull { + position: relative; + left: -15px; +} + +#svg_editor .draginput label#resolution_label span { + right: -13px; + left: auto; + font-size: 16px; + top: 2px; + font-weight: bold; + color: white; +} + +.touch #svg_editor .draginput.active:after { + content: attr(data-value); + display: block; + position: absolute; + background: #3f3f3c; + top: 0; + width: 40px; + left: -50px; + padding: 3px 5px; + color: #fff; +} + +#svg_editor .draginput input { + border: none; + background: transparent; + font: 24px/normal sans-serif; + text-align: center; + color: #4F80FF; + padding: 30px 0 16px; + width: 100%; + height: 24px; + position: relative; + z-index: 2; + cursor: url(images/drag.png), move; + cursor: -webkit-drag; + cursor: -moz-drag; +} + +#svg_editor .draginput input:active { + cursor: url(images/dragging.png), move; + cursor: -webkit-dragging; + cursor: -moz-dragging; +} + +#svg_editor .draginput span { + font: 11px/130% sans-serif; + color: #ccc; + display: block; + position: absolute; + top: 5px; + left: 5px; + text-align: left; +} + +#svg_editor .draginput.error { + background: #900; +} + +#svg_editor .draginput.error input { + color: #fff; +} + +#svg_editor .draginput.stroke_tool { + text-align: center; +} + +#svg_editor .draginput select { + -webkit-appearance: none; + opacity: 0; + display: block; + position: absolute; + height: 100%; + width: 100%; + margin: 0; + z-index: 1; +} + +#svg_editor .draginput#segment_type select { + font-size: 11px; + margin-top: 40px; + width: 70px; +} + + +.draginput_cursor{ + position: absolute; + top: 50%; + width: 100%; + border-top: solid rgba(50,100,200,0.25) 3px; + margin-top: -2px; + z-index: 0; +} + +#svg_editor .draginput input[readonly=readonly] { + -webkit-appearance: none; + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + + +body.dragging * { + cursor: url(images/dragging.png), move; + cursor: -webkit-drag; + cursor: -moz-drag; +} + +body.drag * { + cursor: url(images/dragging.png), move; + cursor: -webkit-dragging; + cursor: -moz-dragging; +} + +#svg_editor input[readonly=readonly]:focus { + box-shadow: none; +} + +#color_canvas_tools { + background: #fff url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMAQMAAABsu86kAAAAA3NCSVQICAjb4U/gAAAABlBMVEXu7u7///8o06qaAAAACXBIWXMAAAsSAAALEgHS3X78AAAAFXRFWHRDcmVhdGlvbiBUaW1lADcvMjIvMTL7FNdCAAAAHHRFWHRTb2Z0d2FyZQBBZG9iZSBGaXJld29ya3MgQ1M1cbXjNgAAABFJREFUCJljYP7AgIb+MKAhAM8/C5vWL6zSAAAAAElFTkSuQmCC) top left repeat; + width: 60px; + height: 40px; + margin: 23px 5px 5px 5px; + position: relative; +} + +#color_canvas_tools svg { + display: block; +} + +#tool_angle_indicator { + width: 50px; + height: 50px; + border-radius: 50px; + border: solid rgba(50,100,200,0.25) 3px; + position: absolute; + bottom: 2px; + left: 7px; +} + +#tool_angle_indicator_cursor { + width: 4px; + height: 25px; + border-top: solid #4F80FF 3px; + position: absolute; + margin: -3px 0 0 25px; + -webkit-transform-origin: 50% 0; + -moz-transform-origin: 50% 0; + -o-transform-origin: 50% 0; + -ms-transform-origin: 50% 0; + transform-origin: 50% 0; +} + diff --git a/editor/svg-editor.html b/editor/svg-editor.html index 714cf77..a67d378 100644 --- a/editor/svg-editor.html +++ b/editor/svg-editor.html @@ -27,8 +27,7 @@ - - + @@ -44,13 +43,15 @@ - + - + + + @@ -95,37 +96,10 @@ $(function(){
-
-
-

Layers

-
-
-
-
-
-
-
-
- - - - - - -
Layer 1
- Move elements to: - -
-
L a y e r s
-
- - - - -
-
+
-
-

Canvas

- - -
- +

Canvas

+ + + + - -
-

Rectangle

-
- - -
-
-
-

Path

+
+

Path

+ +
-
+

Image

-
+ + -
-
- - -
-
-
- - -
-
- -
-
- -
+

Ellipse

-
- - -
-
- - -
+ + + +
-
+

Line

-
- - -
-
- - -
+ + + +
-
+

Text

- + +
- +
-
B
-
i
+
B
+
i
-
-
+
-
-
- +
+
-
+

Group

+ +
-
-