xyc
2025-02-21 664db98c9e8595ce4dd636a27f480e3a08b81ff5
web/public/SVGOrigin/Method-Draw-master/editor/lib/jquery-draginput.js
@@ -39,12 +39,12 @@
    var isTouch = svgedit.browser.isTouch();
    var completed = true //for mousewheel
    var $cursor = (area && this.dragCfg.cursor)
      ? $("<div class='draginput_cursor' />").appendTo($label)
      ? $("<div class='draginput_cursor' />").appendTo($label)
      : false
    $input.attr("readonly", "readonly")
    if ($cursor && !isNaN(this.dragCfg.start)) $cursor.css("top", (this.dragCfg.start*-1)/scale+cursorHeight)
    //this is where all the magic happens
    //this is where all the magic happens
    this.adjustValue = function(i, completed){
      var v;
      i = parseFloat(i);
@@ -62,9 +62,9 @@
      $label.attr("data-value", v)
      if ($.isFunction(this.dragCfg.callback)) this.dragCfg.callback(this, completed)
    };
    $label.toggleClass("draginput", $label.is("label"))
    // when the mouse is down and moving
    this.move = function(e, oy, val) {
      if (isTouch) {
@@ -80,7 +80,7 @@
      var fixed = (step < 1) ? 1 : 0
      this.adjustValue(val.toFixed(fixed))  //no undo true
    };
    //when the mouse is released
    this.stop = function() {
      var selectedElems = canvas.getSelectedElems();
@@ -95,13 +95,13 @@
      }
      this.adjustValue(0, completed)
    }
    this.updateCursor = function(){
      var value = parseFloat(this.value);
      var pos = (value*-1)/scale+cursorHeight;
      $cursor.css("top", pos);
    }
    this.launch = function(e) {
      var selectedElems = canvas.getSelectedElems();
      if (isTouch) e = e.originalEvent.touches[0];
@@ -114,39 +114,39 @@
      $(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.blur();
      this.launch(e);
    })
    .bind("dblclick taphold", function(e) {
      this.removeAttribute("readonly", "readonly");
      this.focus();
      this.select();
    })
    .keydown(function(e){
      // Respond to up/down arrow keys.
      switch(e.keyCode){
        case 13: this.adjustValue(0); this.blur();  break; // Enter
      }
    })
    .focus(function(e){
      if (this.getAttribute("readonly") === "readonly") this.blur()
    })
    .blur(function(e){
      this.setAttribute("readonly", "readonly")
    })
    .bind("mousewheel", function(e, delta, deltaX, deltaY){
      var selectedElems = canvas.getSelectedElems();
      if (completed) canvas.undoMgr.beginUndoableChange(attr, selectedElems)
@@ -155,18 +155,18 @@
      window.undoTimeout = setTimeout(function(){
        wheel_input.stop()
      },200)
      var wheel_input = this;
      if (deltaY > 0)
        this.adjustValue(this.dragCfg.step);
      else if (deltaY < 0)
        this.adjustValue(-this.dragCfg.step);
      e.preventDefault();
    })
  });
};
// public function