<commit_before>dojo.provide("sketchSpaceDesigner.designer.editor");

dojo.require("sketchSpaceDesigner.utils");
dojo.require("sketchSpaceDesigner.designer.modes");
dojo.require("sketchSpaceDesigner.designer.bbox");
dojo.require("sketchSpaceDesigner.designer.selection");
dojo.require("sketchSpaceDesigner.designer.widgets");
dojo.require("dojox.gfx");
dojo.require("dojox.gfx.move");
dojo.require("dojox.gfx.utils");
dojo.require("dojox.gfx.matrix");
dojo.require("dojox.uuid.generateRandomUuid");
dojo.require("dojo.parser");
dojo.require("dojox.layout.TableContainer");
dojo.require("dijit.layout.ContentPane");

dojo.declare("sketchSpaceDesigner.designer.editor.Editor", [], {
 constructor: function (container, userId, ui, viewOnly) {
    this.container = container;

    this.userId = userId;
    this.ui = ui;

    this.surface = dojox.gfx.createSurface(this.container, 1, 1);
    this.resize();
    this.surface_transform = this.surface.createGroup();
    
    this.viewUpdatedHandle = dojo.connect(this.surface_transform, "setTransform", this, function () { this.viewUpdated(); });

    this.images = {};
    this.currentImage = undefined;
    this.currentSharedImage = undefined;
    this.selection = new sketchSpaceDesigner.designer.selection.Selection(this);

    dojo.connect(this.container, "ondragstart",   dojo, "stopEvent");
    dojo.connect(this.container, "onselectstart", dojo, "stopEvent");

    this.options = {};
    this.setOptions({
      doStroke: true,
      doFill: false,
      stroke: {"type":"stroke","color":{"r":0,"g":255,"b":0,"a":1},"style":"solid","width":2,"cap":"butt","join":4},
      fill: {"r":255,"g":0,"b":0,"a":1},
      showAuthorshipColors: true,
      shareCurrentImage: true
    });

    this.modeStack = [];
    if (viewOnly)
      this.pushMode(new sketchSpaceDesigner.designer.modes.Zoom());
    else
      this.pushMode(new sketchSpaceDesigner.designer.modes.Select());

    dojo.connect(container.window, "onresize", this, "resize");
  },

  resize: function () {
    this.surface_size = {width: $(this.container).width(), height: $(this.container).height()};
    this.surface.setDimensions(this.surface_size.width, this.surface_size.height);
    return $(this.container).width() > 1 && $(this.container).height() > 1;
  },

  setOptions: function (options, onlyDefault) {
    sketchSpaceDesigner.utils.setObject(this.options, options, onlyDefault);
    this.updateAuthorshipColor();
    this.selectSharedImage();
  },

  setOptionsByPath: function (options) {
    this.setOptions(sketchSpaceDesigner.utils.objectFromPaths(options));
  },

  getOptionByPath: function (path) {
    return sketchSpaceDesigner.utils.getObjectByPath(this.options, path);
  },
<commit_msg>Bug workaround for IE<commit_after>dojo.provide("sketchSpaceDesigner.designer.editor");

dojo.require("sketchSpaceDesigner.utils");
dojo.require("sketchSpaceDesigner.designer.modes");
dojo.require("sketchSpaceDesigner.designer.bbox");
dojo.require("sketchSpaceDesigner.designer.selection");
dojo.require("sketchSpaceDesigner.designer.widgets");
dojo.require("dojox.gfx");
dojo.require("dojox.gfx.move");
dojo.require("dojox.gfx.utils");
dojo.require("dojox.gfx.matrix");
dojo.require("dojox.uuid.generateRandomUuid");
dojo.require("dojo.parser");
dojo.require("dojox.layout.TableContainer");
dojo.require("dijit.layout.ContentPane");

dojo.declare("sketchSpaceDesigner.designer.editor.Editor", [], {
 constructor: function (container, userId, ui, viewOnly) {
    this.container = container;

    this.userId = userId;
    this.ui = ui;

    this.surface = dojox.gfx.createSurface(this.container, 1, 1);
    this.resize();
    this.surface_transform = this.surface.createGroup();
    
    this.viewUpdatedHandle = dojo.connect(this.surface_transform, "setTransform", this, function () { this.viewUpdated(); });

    this.images = {};
    this.currentImage = undefined;
    this.currentSharedImage = undefined;
    this.selection = new sketchSpaceDesigner.designer.selection.Selection(this);

    dojo.connect(this.container, "ondragstart",   dojo, "stopEvent");
    dojo.connect(this.container, "onselectstart", dojo, "stopEvent");

    this.options = {};
    this.setOptions({
      doStroke: true,
      doFill: false,
      stroke: {"type":"stroke","color":{"r":0,"g":255,"b":0,"a":1},"style":"solid","width":2,"cap":"butt","join":4},
      fill: {"r":255,"g":0,"b":0,"a":1},
      showAuthorshipColors: true,
      shareCurrentImage: true
    });

    this.modeStack = [];
    if (viewOnly)
      this.pushMode(new sketchSpaceDesigner.designer.modes.Zoom());
    else
      this.pushMode(new sketchSpaceDesigner.designer.modes.Select());

    dojo.connect(container.window, "onresize", this, "resize");
  },

  resize: function () {
    /* IE + dojo workaround */
    $(this.container).removeAttr("style");

    this.surface_size = {width: $(this.container).width(), height: $(this.container).height()};
    this.surface.setDimensions(this.surface_size.width, this.surface_size.height);
    return $(this.container).width() > 1 && $(this.container).height() > 1;
  },

  setOptions: function (options, onlyDefault) {
    sketchSpaceDesigner.utils.setObject(this.options, options, onlyDefault);
    this.updateAuthorshipColor();
    this.selectSharedImage();
  },

  setOptionsByPath: function (options) {
    this.setOptions(sketchSpaceDesigner.utils.objectFromPaths(options));
  },

  getOptionByPath: function (path) {
    return sketchSpaceDesigner.utils.getObjectByPath(this.options, path);
  },

{'fraction_non_alphanumeric': 0.16820568531595148, 'fraction_numerical': 0.006518196632265073, 'mean_word_length': 4.876595744680851, 'pattern_counts': {'":': 28, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '537138', 'n_tokens_mistral': 1811, 'n_tokens_neox': 1772, 'n_words': 237}