From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/controllers/elements/body-controller.js | 4 +- js/controllers/elements/element-controller.js | 8 +- js/controllers/elements/shapes-controller.js | 2 +- js/document/document-html.js | 10 +- js/document/models/html.js | 23 ---- js/document/templates/banner/index.html | 24 ++++- js/document/templates/html/index.html | 27 ++++- js/document/views/design.js | 30 +++++- js/helper-classes/3D/snap-manager.js | 14 +-- js/lib/NJUtils.js | 120 --------------------- js/mediators/drag-drop-mediator.js | 2 - js/mediators/element-mediator.js | 42 +------- js/models/element-model.js | 96 ++++++++++++++++- .../components-panel.reel/components-panel.js | 22 ---- js/tools/BrushTool.js | 1 - js/tools/EyedropperTool.js | 1 - js/tools/LineTool.js | 1 - js/tools/PenTool.js | 1 - js/tools/ShapeTool.js | 1 - js/tools/TagTool.js | 3 - 20 files changed, 184 insertions(+), 248 deletions(-) diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 7a3a66f5..9c427c62 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js @@ -71,7 +71,7 @@ exports.BodyController = Montage.create(ElementController, { getPerspectiveDist: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { + if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { return el.elementModel.props3D.perspectiveDist; } else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, true); @@ -83,7 +83,7 @@ exports.BodyController = Montage.create(ElementController, { getMatrix: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) + if(el.elementModel.props3D && el.elementModel.props3D.matrix3d) { return el.elementModel.props3D.matrix3d.slice(0); } diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 01e132d7..0223a6b5 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js @@ -36,7 +36,7 @@ exports.ElementController = Montage.create(Component, { // Remove the element from the DOM and clear the GLWord. removeElement: { value: function(el) { - if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { + if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { el.elementModel.shapeModel.GLWorld.clearTree(); } el.parentNode.removeChild(el); @@ -229,7 +229,7 @@ exports.ElementController = Montage.create(Component, { // Routines to get/set 3D properties get3DProperty: { value: function(el, prop) { - if(el.elementModel && el.elementModel.props3D) { + if(el.elementModel.props3D) { return el.elementModel.props3D[prop]; } } @@ -237,7 +237,7 @@ exports.ElementController = Montage.create(Component, { getMatrix: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) { + if(el.elementModel.props3D && el.elementModel.props3D.matrix3d) { return el.elementModel.props3D.matrix3d.slice(0); } else { var mat; @@ -257,7 +257,7 @@ exports.ElementController = Montage.create(Component, { getPerspectiveDist: { value: function(el) { - if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { + if(el.elementModel.props3D && el.elementModel.props3D.perspectiveDist) { return el.elementModel.props3D.perspectiveDist; } else { var dist = this.application.ninja.stylesController.getPerspectiveDistFromElement(el, false); diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 626dedb6..ae345489 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js @@ -133,7 +133,7 @@ exports.ShapesController = Montage.create(CanvasController, { canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); canvas.width = el.width; canvas.height = el.height; - canvas.elementModel = el.elementModel; + canvas._model = el.elementModel; this.toggleWebGlMode(canvas, value); this.application.ninja.elementMediator.replaceElement(canvas, el); break; diff --git a/js/document/document-html.js b/js/document/document-html.js index 33a41a8e..4a8d5d41 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js @@ -88,7 +88,7 @@ exports.HtmlDocument = Montage.create(Component, { //Adding observer to know when template is ready this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); this._observer.observe(this.model.views.design.document.head, {childList: true}); - }.bind(this), template); + }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); } else { //TODO: Identify default view (probably code) } @@ -101,10 +101,14 @@ exports.HtmlDocument = Montage.create(Component, { //Removing observer, only needed on initial load this._observer.disconnect(); this._observer = null; - //Making callback after view is loaded - this.loaded.callback.call(this.loaded.context, this); } }, + handleViewReady: { + value: function() { + //Making callback after view is loaded + this.loaded.callback.call(this.loaded.context, this); + } + }, //////////////////////////////////////////////////////////////////// // closeDocument: { diff --git a/js/document/models/html.js b/js/document/models/html.js index 9aa0d27e..a367f95f 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -62,33 +62,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { webGlHelper: { value: null }, - //////////////////////////////////////////////////////////////////// - // - userComponents: { - value: {} - }, //////////////////////////////////////////////////////////////////// // documentRoot: { value: null - }, - //////////////////////////////////////////////////////////////////// - //Add a reference to a component instance to the userComponents hash using the element UUID - setComponentInstance: { - value: function(instance, el) { - this.userComponents[el.uuid] = instance; - } - }, - //////////////////////////////////////////////////////////////////// - //Returns the component instance obj from the element - getComponentFromElement: { - value: function(el) { - if(el) { - if(el.uuid) return this.userComponents[el.uuid]; - } else { - return null; - } - } } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index f1ee3d98..08a998e5 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html @@ -74,9 +74,27 @@ diff --git a/js/document/templates/html/index.html b/js/document/templates/html/index.html index 70187900..c74a7251 100755 --- a/js/document/templates/html/index.html +++ b/js/document/templates/html/index.html @@ -57,13 +57,32 @@ .nj-element-highlight { outline: 4px solid #ff0000; - } + } diff --git a/js/document/views/design.js b/js/document/views/design.js index f7fbf3c5..0e42dcc2 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -7,7 +7,8 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot //////////////////////////////////////////////////////////////////////// // var Montage = require("montage/core/core").Montage, - BaseDocumentView = require("js/document/views/base").BaseDocumentView; + BaseDocumentView = require("js/document/views/base").BaseDocumentView, + ElementModel = require("js/models/element-model"); //////////////////////////////////////////////////////////////////////// // exports.DesignDocumentView = Montage.create(BaseDocumentView, { @@ -21,6 +22,11 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { _callback: { value: null }, + //////////////////////////////////////////////////////////////////// + // + _viewCallback: { + value: null + }, //////////////////////////////////////////////////////////////////// // _template: { @@ -104,12 +110,13 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //////////////////////////////////////////////////////////////////// // render: { - value: function (callback, template) { + value: function (callback, template, viewCallback) { //TODO: Remove, this is a temp patch for webRequest API gate this.application.ninja.documentController.redirectRequests = false; //Storing callback for dispatch ready this._callback = callback; this._template = template; + this._viewCallback = viewCallback; //Adding listener to know when template is loaded to then load user content this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), false); //TODO: Add source parameter and root (optional) @@ -264,6 +271,10 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { } } } + + // Assign the modelGenerator reference from the template to our own modelGenerator + this.document.modelGenerator = ElementModel.modelGenerator; + //Checking for script tags then parsing check for montage and webgl if (scripttags.length > 0) { //Checking and initializing webGL @@ -272,6 +283,9 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { this.initMontage(scripttags); } else { //Else there is not data to parse + if(this._viewCallback) { + this._viewCallback.viewCallback.call(this._viewCallback.context); + } } //TODO: Verify appropiate location for this operation if (this._template && this._template.type === 'banner') { @@ -287,8 +301,9 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { for (var n in orgNodes) { if (orgNodes[n].getAttribute) orgNodes[n].setAttribute('data-ninja-node', 'true'); } - //Initiliazing document model - document.application.njUtils.makeElementModel(this.model.documentRoot, "Body", "body"); + + + //Makign callback if specified if (this._callback) this._callback(); } @@ -395,6 +410,7 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { // initMontage: { value: function (scripttags) { + var self = this; // this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { //Initializing template with user's seriliazation @@ -406,6 +422,12 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { //Forcing draw on components template._deserializer._objects[c].needsDraw = true; } + + // Now call the view callback + if(self._viewCallback) { + self._viewCallback.viewCallback.call(self._viewCallback.context); + } + }); }.bind(this), false); } diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index e3756f32..a8b6e739 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -481,10 +481,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { { var snapRec = this._elementCache[i]; var elt = snapRec.getElement(); - if (elt.elementModel) - elt.elementModel.isIn2DSnapCache = false; - else - console.log( "element in the 2D cache does not have an elementModel" ); + elt.elementModel.isIn2DSnapCache = false; + } this._elementCache = null; @@ -541,10 +539,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { snapRec.init( elt ); this._elementCache.push( snapRec ); - if (!elt.elementModel) - { - NJUtils.makeModelFromElement(elt); - } elt.elementModel.isIn2DSnapCache = true; } else if (elt.elementModel) @@ -613,10 +607,6 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { snapRec.init( elt ); this._elementCache.push( snapRec ); - if (!elt.elementModel) - { - NJUtils.makeModelFromElement(elt); - } elt.elementModel.isIn2DSnapCache = true; } else if (elt.elementModel) diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 7dd4c9e8..0dec6345 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js @@ -90,30 +90,6 @@ exports.NJUtils = Montage.create(Component, { } }, - createModel: { - value: function(el) { - el.elementModel = Montage.create(ElementModel).initialize(el); - } - }, - - createModelWithShape: { - value: function(el, selection) { - el.elementModel = Montage.create(ElementModel).initialize(el, true, selection); - } - }, - - createModelWithSelection: { - value: function(el, selection) { - el.elementModel = Montage.create(ElementModel).initialize(el, false, selection); - } - }, - - createModelForComponent: { - value: function(el, selection) { - el.elementModel = Montage.create(ElementModel).initialize(el, false, selection, true); - } - }, - // TODO: Find a better place for this method stylesFromDraw: { value: function(element, width, height, drawData, pos) { @@ -166,102 +142,6 @@ exports.NJUtils = Montage.create(Component, { } }, - ///// Element Model creation for existing elements - ///// TODO: find a different place for this function - makeElementModel: { - value: function(el, selection, controller, isShape) { - var p3d = Montage.create(Properties3D); - - var shapeProps = null; - var pi = controller + "Pi"; - - if(isShape) { - shapeProps = Montage.create(ShapeModel); - } - - if(el.controller) { - - var componentInfo = Montage.getInfoForObject(el.controller); - var componentName = componentInfo.objectName.toLowerCase(); - - controller = "component"; - isShape = false; - - switch(componentName) { - case "feedreader": - selection = "Feed Reader"; - pi = "FeedReaderPi"; - break; - case "map": - selection = "Map"; - pi = "MapPi"; - break; - case "youtubechannel": - selection = "Youtube Channel"; - pi = "YoutubeChannelPi"; - break; - case "picasacarousel": - selection = "Picasa Carousel"; - pi = "PicasaCarouselPi"; - break; - } - } - - el.elementModel = Montage.create(ElementModel, { - type: { value: el.nodeName}, - selection: { value: selection}, - controller: { value: ControllerFactory.getController(controller)}, - pi: { value: pi}, - props3D: { value: p3d}, - shapeModel: { value: shapeProps}, - isShape: { value: isShape} - }); - - - } - }, - - ///// Element Model creation for existing elements based on element type. - ///// TODO: Selection and model should be based on the element type - makeModelFromElement: { - value: function(el) { - var selection = "div", - controller = "block", - isShape = false; - switch(el.nodeName.toLowerCase()) - { - case "div": - break; - case "img": - selection = "image"; - controller = "image"; - break; - case "video": - selection = "video"; - controller = "video"; - break; - case "canvas": - isShape = el.getAttribute("data-RDGE-id"); - if(isShape) { - // TODO - Need more info about the shape - selection = "canvas"; - controller = "shape"; - isShape = true; - } else { - selection = "canvas"; - controller = "canvas"; - } - break; - case "shape": - break; - } - this.makeElementModel(el, selection, controller, isShape); - if(el.elementModel && el.elementModel.props3D) { - el.elementModel.props3D.init(el, (selection === "Stage")); - } - } - }, - ///// Removes all child nodes and returns node ///// Accepts a single node, or an array of dom nodes empty : { diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index 59086ef6..14bdb0eb 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js @@ -115,12 +115,10 @@ exports.DragDropMediator = Montage.create(Component, { // if (e.currentTarget.fileType.indexOf('svg') !== -1) { element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper - NJUtils.createModelWithSelection(element, "SVG"); element.type = 'image/svg+xml'; element.src = url+'/'+fileName; } else { element = NJUtils.make('image', null, this.application.ninja.currentDocument); - NJUtils.createModel(element); element.src = url+'/'+fileName; } //Adding element once it is loaded diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 1d5e9ade..cecb4392 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -29,15 +29,12 @@ exports.ElementMediator = Montage.create(Component, { if(Array.isArray(elements)) { elements.forEach(function(element) { ElementController.addElement(element, rules); - if(element.elementModel && element.elementModel.props3D) { - element.elementModel.props3D.init(element, false); - } + element.elementModel.props3D.init(element, false); }); } else { ElementController.addElement(elements, rules); - if(elements.elementModel && elements.elementModel.props3D) { - elements.elementModel.props3D.init(elements, false); - } + elements.elementModel.props3D.init(elements, false); + } if(this.addDelegate && typeof (this.addDelegate['onAddElements']) === "function") { @@ -102,11 +99,6 @@ exports.ElementMediator = Montage.create(Component, { getProperty: { value: function(el, prop, valueMutator) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Div", "block"); - } - if(valueMutator && typeof valueMutator === "function") { return valueMutator(el.elementModel.controller["getProperty"](el, prop)); } else { @@ -117,22 +109,12 @@ exports.ElementMediator = Montage.create(Component, { getShapeProperty: { value: function(el, prop) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Canvas", "block", true); - } - return el.elementModel.controller["getShapeProperty"](el, prop); } }, setShapeProperty: { value: function(el, prop, value) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Canvas", "block", true); - } - return el.elementModel.controller["setShapeProperty"](el, prop, value); } }, @@ -297,9 +279,6 @@ exports.ElementMediator = Montage.create(Component, { // Routines to get/set color getColor: { value: function(el, isFill, borderSide) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getColor"](el, isFill, borderSide); } }, @@ -374,9 +353,6 @@ exports.ElementMediator = Montage.create(Component, { getStroke: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeElementModel(el, "Div", "block"); - } return el.elementModel.controller["getStroke"](el); } }, @@ -452,18 +428,12 @@ exports.ElementMediator = Montage.create(Component, { // Routines to get/set 3D properties get3DProperty: { value: function(el, prop) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["get3DProperty"](el, prop); } }, get3DProperties: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } // var mat = this.getMatrix(el); // var dist = this.getPerspectiveDist(el); var mat = el.elementModel.controller["getMatrix"](el); @@ -474,18 +444,12 @@ exports.ElementMediator = Montage.create(Component, { getMatrix: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getMatrix"](el); } }, getPerspectiveDist: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getPerspectiveDist"](el); } }, diff --git a/js/models/element-model.js b/js/models/element-model.js index 966158e4..ea25e5b1 100755 --- a/js/models/element-model.js +++ b/js/models/element-model.js @@ -10,7 +10,101 @@ var Montage = require("montage/core/core").Montage, ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory, PiData = require("js/data/pi/pi-data").PiData; -exports.ElementModel = Montage.create(Montage, { +var modelGenerator = exports.modelGenerator = function() { + var info = getInfoForElement(this); + + Object.defineProperty(this, "_model", { + configurable: true, + enumerable: false, + writable: true, + value: Montage.create(elmo, { + type: { value: info.type}, + selection: { value: info.selection}, + controller: { value: info.controller}, + pi: { value: info.pi}, + props3D: { value: info.props3d}, + shapeModel: { value: info.shapeModel}, + isShape: { value: info.isShape} + }) + }); + + if(this._model.selection === "body") { + this._model.props3D.init(this, true); + } else { + this._model.props3D.init(this, false); + } + + return this._model; +}; + +var getInfoForElement = function(el) { + var elementName, controller, pi, shapeModel = null, isShape = false, isComponent = false; + + elementName = el.nodeName.toLowerCase(); + controller = elementNameToController(elementName); + pi = elementNameToPi(elementName); + + // Element is a shape + if(el.getAttribute("data-RDGE-id")) { + controller = "shape"; + shapeModel = Montage.create(ShapeModel); + isShape = true; + } + + // TODO: Add this in case there is no controller for the component + /* + if(el.getAttribute("data-montage-id")) { + elementName = null; + this.isComponent = true; + } + */ + + // Element is a component + if(el.controller) { + var componentInfo = Montage.getInfoForObject(el.controller); + var componentName = componentInfo.objectName;//.toLowerCase(); + + controller = "component"; + elementName = componentName; + pi = elementNameToPi(componentName.replace(/\s+/g, '')); + isComponent = true; + } + + return { + type: el.nodeName, + selection: elementName, + controller: ControllerFactory.getController(controller), + pi: pi, + props3d: Montage.create(Properties3D), + shapeModel: shapeModel, + isShape: isShape, + isComponent: isComponent + } +}; + +var elementNameToController = function(name) { + if(name === "div" || name === "custom") { + return "block"; + } else if(name === "img") { + return "image"; + } else { + return name; + } +}; + +var elementNameToPi = function(name) { + if(!name) return null; + + var piString = name + "Pi"; + + if(!PiData.hasOwnProperty(piString)) { + piString = "blockPi"; + } + + return piString; +}; + +var elmo = exports.ElementModel = Montage.create(Montage, { key: { value: "_model_"}, type: { value: null }, // Tag type that was created diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 0b453c4a..e6b7a6e3 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -292,8 +292,6 @@ exports.ComponentsPanel = Montage.create(Component, { } } -// that.application.ninja.currentDocument.model.setComponentInstance(instance, element); - //that.application.ninja.elementMediator.addElements(element, styles); ElementController.addElement(element, styles); }); @@ -303,11 +301,6 @@ exports.ComponentsPanel = Montage.create(Component, { componentInstanceOnFirstDraw: { value: function(instance) { - // Temporary hack until the element model rework goes into place - // TODO: Remove this once we have the element model define property code in place. - if(!instance.element.elementModel) { - this.application.njUtils.makeModelFromElement(instance.element); - } this.application.ninja.elementMediator.addElements(instance.element); } }, @@ -319,75 +312,60 @@ exports.ComponentsPanel = Montage.create(Component, { switch(name) { case "anchor": el = document.application.njUtils.make("a", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Anchor"); el.setAttribute("href", "http://www.motorola.com"); el.innerHTML = "link"; break; case "button": el = document.application.njUtils.make(name, null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Button"); el.setAttribute("type", "button"); el.innerHTML = "Button"; break; case "checkbox": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Checkbox"); el.setAttribute("type", "checkbox"); break; case "imageComponent": el = document.application.njUtils.make("image", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Image"); el.setAttribute("width", 200); el.setAttribute("height", 200); break; case "numberInput": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Number Input"); el.setAttribute("type", "number"); break; case "select": el = document.application.njUtils.make("select", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "SelectInput"); break; case "radioButton": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Radio Button"); el.setAttribute("type", "radio"); break; case "rangeInput": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Range Input"); el.setAttribute("type", "range"); break; case "textfield": el = document.application.njUtils.make("input", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Textfield"); el.setAttribute("type", "text"); break; case "textarea": el = document.application.njUtils.make("textarea", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Textarea"); break; case "toggleButton": el = document.application.njUtils.make("button", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Toggle Button"); el.innerHTML = "Off"; break; case "map": el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Map"); break; case "feedreader": el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Feed Reader"); break; case "picasa-carousel": el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Picasa Carousel"); break; case "youtube-channel": el = document.application.njUtils.make("div", null, this.application.ninja.currentDocument); - document.application.njUtils.createModelForComponent(el, "Youtube Channel"); break; } diff --git a/js/tools/BrushTool.js b/js/tools/BrushTool.js index 0be378fd..f7c8ea1e 100644 --- a/js/tools/BrushTool.js +++ b/js/tools/BrushTool.js @@ -376,7 +376,6 @@ exports.BrushTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); - document.application.njUtils.createModelWithShape(newCanvas, "Brushstroke"); var styles = document.application.njUtils.stylesFromDraw(newCanvas, w, h, {midPt: midPt, planeMat: planeMat}); this.application.ninja.elementMediator.addElements(newCanvas, styles, false); diff --git a/js/tools/EyedropperTool.js b/js/tools/EyedropperTool.js index 6678e498..6a56004d 100755 --- a/js/tools/EyedropperTool.js +++ b/js/tools/EyedropperTool.js @@ -376,7 +376,6 @@ exports.EyedropperTool = Montage.create(toolBase, { if(worldData) { this._webGlDataCanvas = njModule.NJUtils.make("canvas", {"data-RDGE-id": njModule.NJUtils.generateRandom()}, this.application.ninja.currentDocument); - njModule.NJUtils.createModelWithShape(this._webGlDataCanvas, "Canvas"); this._applyElementStyles(elt, this._webGlDataCanvas, ["display", "position", "width", "height", "-webkit-transform", "-webkit-transform-style"]); this._webGlDataCanvas.style.left = eltCoords[0] + "px"; diff --git a/js/tools/LineTool.js b/js/tools/LineTool.js index b2b48383..56d03e81 100755 --- a/js/tools/LineTool.js +++ b/js/tools/LineTool.js @@ -78,7 +78,6 @@ exports.LineTool = Montage.create(ShapeTool, { } canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); - document.application.njUtils.createModelWithShape(canvas, "Line"); var styles = document.application.njUtils.stylesFromDraw(canvas, w, h, drawData); this.application.ninja.elementMediator.addElements(canvas, styles); diff --git a/js/tools/PenTool.js b/js/tools/PenTool.js index 3813123a..24436352 100755 --- a/js/tools/PenTool.js +++ b/js/tools/PenTool.js @@ -564,7 +564,6 @@ exports.PenTool = Montage.create(ShapeTool, { if (!canvas) { var newCanvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); - document.application.njUtils.createModelWithShape(newCanvas, "Subpath"); var styles = document.application.njUtils.stylesFromDraw(newCanvas, parseInt(w), parseInt(h), {midPt: midPt, planeMat: planeMat}); this.application.ninja.elementMediator.addElements(newCanvas, styles, false); diff --git a/js/tools/ShapeTool.js b/js/tools/ShapeTool.js index 367ab78d..6956aea8 100755 --- a/js/tools/ShapeTool.js +++ b/js/tools/ShapeTool.js @@ -60,7 +60,6 @@ exports.ShapeTool = Montage.create(DrawingTool, { if(drawData) { if(!this._useExistingCanvas()) { canvas = document.application.njUtils.make("canvas", {"data-RDGE-id": NJUtils.generateRandom()}, this.application.ninja.currentDocument); - document.application.njUtils.createModelWithShape(canvas); var styles = document.application.njUtils.stylesFromDraw(canvas, ~~drawData.width, ~~drawData.height, drawData); this.application.ninja.elementMediator.addElements(canvas, styles); diff --git a/js/tools/TagTool.js b/js/tools/TagTool.js index 5520fa89..d56566cf 100755 --- a/js/tools/TagTool.js +++ b/js/tools/TagTool.js @@ -86,9 +86,6 @@ exports.TagTool = Montage.create(DrawingTool, { element = document.application.njUtils.make(this.options.selectedElement, null, this.application.ninja.currentDocument); } - // Create the model - document.application.njUtils.createModel(element); - // Create the styles styles = document.application.njUtils.stylesFromDraw(element, ~~drawData.width, ~~drawData.height, drawData); -- cgit v1.2.3