From 3987b73569e58843f2a91c0c6c4e4132f51ac247 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 21 Mar 2012 17:13:56 -0700 Subject: Do not set webkit-transform styles on elements unless 3d is used on them. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index d62fa1f8..eac0ca54 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -90,9 +90,12 @@ exports.ElementMediator = Montage.create(NJComponent, { _addElement: { value: function(el, rules, noEvent) { ElementController.addElement(el, rules); - var p3d = this.get3DProperties(el); - if(p3d) { - el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); +// var p3d = this.get3DProperties(el); +// if(p3d) { +// el.elementModel.controller["set3DProperties"](el, [p3d], 0, true); +// } + if(el.elementModel && el.elementModel.props3D) { + el.elementModel.props3D.init(el, false); } if(!noEvent) { this.application.ninja.documentController.activeDocument.needsSave = true; -- cgit v1.2.3 From 2557f463c1cfe2d0dd8ea187c184755bd141dab4 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 10:38:44 -0700 Subject: IKNINJA-1302 : For File>New and File>SaveAll dialogs, 'ESC' key now triggers Cancel button and 'Enter' key now triggers OK button. For File picker, the 'ESC' now triggers the Cancel button. Signed-off-by: Ananya Sen Conflicts: js/io/ui/new-file-dialog/new-file-workflow-controller.js Signed-off-by: Ananya Sen --- js/mediators/keyboard-mediator.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 65dd34cd..63dcfa88 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -246,6 +246,35 @@ exports.KeyboardMediator = Montage.create(Component, { return; } + // check for ENTER key + if((evt.keyCode == Keyboard.ENTER) && !(evt.ctrlKey || evt.metaKey)) { + //new file + if((this.application.ninja.newFileController.newFileOptionsNav !== null) + && !this.application.ninja.newFileController.newFileOptionsNav.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.newFileOptionsNav.handleOkButtonAction(); + } + //save as + if((this.application.ninja.newFileController.saveAsDialog !== null) + && !this.application.ninja.newFileController.saveAsDialog.okButton.hasAttribute("disabled")){ + + this.application.ninja.newFileController.saveAsDialog.handleOkButtonAction(); + } + return; + } + //ESC key + if(evt.keyCode === Keyboard.ESCAPE){ + if(this.application.ninja.filePickerController.pickerNavChoices !== null){ + this.application.ninja.filePickerController.pickerNavChoices.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.newFileOptionsNav !== null){ + this.application.ninja.newFileController.newFileOptionsNav.handleCancelButtonAction(); + } + if(this.application.ninja.newFileController.saveAsDialog !== null){ + this.application.ninja.newFileController.saveAsDialog.handleCancelButtonAction(); + } + return; + } } }, -- cgit v1.2.3 From bead8ce9e292f030a4b2fba6ad7fd38fb4fe5199 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Thu, 22 Mar 2012 11:16:39 -0700 Subject: IKNINJA-758 - The rotation value of the stage is not updated in the properties panel. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index eac0ca54..a2440fb4 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -673,17 +673,17 @@ exports.ElementMediator = Montage.create(NJComponent, { }, setMatrix: { - value: function(el, mat, isChanging) { + value: function(el, mat, isChanging, source) { var dist = el.elementModel.controller["getPerspectiveDist"](el); el.elementModel.controller["set3DProperties"](el, [{mat:mat, dist:dist}], 0, !isChanging); if(isChanging) { - NJevent("elementChanging", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); + NJevent("elementChanging", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } else { - NJevent("elementChange", {type : "setMatrix", source: null, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); + NJevent("elementChange", {type : "setMatrix", source: source, data: {"els": [el], "prop": "matrix", "value": mat}, redraw: null}); } } }, -- cgit v1.2.3 From 80ceeffeb3dd3227008714b8b56383f9556ff409 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Thu, 22 Mar 2012 14:49:17 -0700 Subject: KNINJA-1302 : refactored fixed as per request Signed-off-by: Ananya Sen --- js/mediators/keyboard-mediator.js | 31 ------------------------------- 1 file changed, 31 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/keyboard-mediator.js b/js/mediators/keyboard-mediator.js index 63dcfa88..fc0d0f6a 100755 --- a/js/mediators/keyboard-mediator.js +++ b/js/mediators/keyboard-mediator.js @@ -245,37 +245,6 @@ exports.KeyboardMediator = Montage.create(Component, { //menuViewManagerModule.MenuViewManager.closeMenu("mainMenuBar"); return; } - - // check for ENTER key - if((evt.keyCode == Keyboard.ENTER) && !(evt.ctrlKey || evt.metaKey)) { - //new file - if((this.application.ninja.newFileController.newFileOptionsNav !== null) - && !this.application.ninja.newFileController.newFileOptionsNav.okButton.hasAttribute("disabled")){ - - this.application.ninja.newFileController.newFileOptionsNav.handleOkButtonAction(); - } - //save as - if((this.application.ninja.newFileController.saveAsDialog !== null) - && !this.application.ninja.newFileController.saveAsDialog.okButton.hasAttribute("disabled")){ - - this.application.ninja.newFileController.saveAsDialog.handleOkButtonAction(); - } - return; - } - //ESC key - if(evt.keyCode === Keyboard.ESCAPE){ - if(this.application.ninja.filePickerController.pickerNavChoices !== null){ - this.application.ninja.filePickerController.pickerNavChoices.handleCancelButtonAction(); - } - if(this.application.ninja.newFileController.newFileOptionsNav !== null){ - this.application.ninja.newFileController.newFileOptionsNav.handleCancelButtonAction(); - } - if(this.application.ninja.newFileController.saveAsDialog !== null){ - this.application.ninja.newFileController.saveAsDialog.handleCancelButtonAction(); - } - return; - } - } }, -- cgit v1.2.3 From 350d290d5fd0903289d55a7f4a6e643040e3d65e Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 3 Apr 2012 10:56:53 -0700 Subject: IKNinja-1375 - After WebGL conversion from PI, Selection tool gets deactivated or becomes non-functional to the shape. Need to set elementModel.isIn2DSnapCache to false when replacing element. Signed-off-by: Nivesh Rajbhandari --- js/mediators/element-mediator.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/mediators') diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index d62fa1f8..3eeab9c4 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -132,6 +132,7 @@ exports.ElementMediator = Montage.create(NJComponent, { value: function(el, el2) { el2.elementModel = el.elementModel; this.application.ninja.currentDocument.documentRoot.replaceChild(el2, el); + el2.elementModel.isIn2DSnapCache = false; } }, -- cgit v1.2.3 From d5d4dcac78ebf8ba3163a8c7055d783b6397a435 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 12:55:54 -0700 Subject: Namespaced the canvas runtime file and updated all dependencies --- js/mediators/io-mediator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 1efbb8bb..82bb31c4 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -440,7 +440,7 @@ window.addEventListener('load', loadWebGL, false);\n\ function loadWebGL (e) {\n\ window.removeEventListener('load', loadWebGL, false);\n\ //Calling method to initialize all webGL/canvas(es)\n\ - initWebGl("+rootElement+", '"+rdgeDirName+"/');\n\ + NinjaCvsRt.initWebGl(" + rootElement + ", '" + rdgeDirName + "/');\n\ }\ "; //TODO: This data should be saved to a JSON file eventually -- cgit v1.2.3 From 7433f0bfbc3a7ea44320550ed2c1d90dc5e6f170 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Tue, 3 Apr 2012 16:27:01 -0700 Subject: Removed the dependence on an "assets" directory for the RDGE runtime. Now Ninja does not need to create duplicate files when it sets up the users Ninja Projects directory for RDGE support. --- js/mediators/io-mediator.js | 1094 +++++++++++++++++++++---------------------- 1 file changed, 543 insertions(+), 551 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 82bb31c4..057a849d 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -14,427 +14,419 @@ var Montage = require("montage/core/core").Montage, //////////////////////////////////////////////////////////////////////// // exports.IoMediator = Montage.create(Component, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { - enumerable: false, + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { + enumerable: false, value: false }, - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // - deserializedFromTemplate: { - enumerable: false, - value: function () { - // - } - }, - //////////////////////////////////////////////////////////////////// + deserializedFromTemplate: { + enumerable: false, + value: function () { + // + } + }, + //////////////////////////////////////////////////////////////////// // fio: { - enumerable: false, - value: FileIo + enumerable: false, + value: FileIo }, //////////////////////////////////////////////////////////////////// // pio: { - enumerable: false, - value: ProjectIo + enumerable: false, + value: ProjectIo }, //////////////////////////////////////////////////////////////////// // getAppTemplatesUrlRegEx: { - enumerable: false, - value: function () { - var regex = new RegExp(chrome.extension.getURL('js/document/templates/montage-html').replace(/\//gi, '\\\/'), 'gi'); - return regex; - } + enumerable: false, + value: function () { + var regex = new RegExp(chrome.extension.getURL('js/document/templates/montage-html').replace(/\//gi, '\\\/'), 'gi'); + return regex; + } }, - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// // fileNew: { - enumerable: false, - value: function (file, template, callback) { - //Loading template from template URL - var xhr = new XMLHttpRequest(), result; - xhr.open("GET", template, false); + enumerable: false, + value: function (file, template, callback) { + //Loading template from template URL + var xhr = new XMLHttpRequest(), result; + xhr.open("GET", template, false); xhr.send(); - if (xhr.readyState === 4) { - //Making call to create file, checking for return code - switch (this.fio.newFile({uri: file, contents: xhr.response})) { - case 201: - result = {status: 201, success: true, uri: file}; - break; - case 204: - result = {status: 204, success: false, uri: file}; - break; - case 400: - result = {status: 400, success: false, uri: file}; - break; - default: - result = {status: 500, success: false, uri: file}; - break; - } - } else { - result = {status: 500, success: false, uri: file}; - } - //Sending result to callback if requested for handling - if (callback) callback(result); - //Codes - // 204: File exists | 400: File exists - // 201: File succesfully created | 500: Unknown (Probably cloud API not running) - } + if (xhr.readyState === 4) { + //Making call to create file, checking for return code + switch (this.fio.newFile({ uri: file, contents: xhr.response })) { + case 201: + result = { status: 201, success: true, uri: file }; + break; + case 204: + result = { status: 204, success: false, uri: file }; + break; + case 400: + result = { status: 400, success: false, uri: file }; + break; + default: + result = { status: 500, success: false, uri: file }; + break; + } + } else { + result = { status: 500, success: false, uri: file }; + } + //Sending result to callback if requested for handling + if (callback) callback(result); + //Codes + // 204: File exists | 400: File exists + // 201: File succesfully created | 500: Unknown (Probably cloud API not running) + } }, //////////////////////////////////////////////////////////////////// // fileOpen: { - enumerable: false, - value: function (file, callback) { - //Reading file (Ninja doesn't really open a file, all in browser memory) - var read = this.fio.readFile({uri: file}), result; - //Checking for status - switch(read.status) { - case 204: - //Creating and formatting result object for callbak - result = read.file.details; - result.root = read.file.details.uri.replace(read.file.details.name, ""); - //Checking for type of content to returns - if (result.extension !== 'html' && result.extension !== 'htm') { - //Simple string - result.content = read.file.content; - } else { - //Object to be used by Ninja Template - result.content = this.parseHtmlToNinjaTemplate(read.file.content); - } - //Status of call - result.status = read.status; - //Calling back with result - if (callback) callback(result); - break; - case 404: - //File does not exists - if (callback) callback({status: read.status}); - break; - default: - //Unknown - if (callback) callback({status: 500}); - break; - } - /* - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - //Return Object Description - Object.status (Always presents for handling) - 204: File exists (Success) - 404: File does not exists (Failure) - 500: Unknown (Probably cloud API not running) + enumerable: false, + value: function (file, callback) { + //Reading file (Ninja doesn't really open a file, all in browser memory) + var read = this.fio.readFile({ uri: file }), result; + //Checking for status + switch (read.status) { + case 204: + //Creating and formatting result object for callbak + result = read.file.details; + result.root = read.file.details.uri.replace(read.file.details.name, ""); + //Checking for type of content to returns + if (result.extension !== 'html' && result.extension !== 'htm') { + //Simple string + result.content = read.file.content; + } else { + //Object to be used by Ninja Template + result.content = this.parseHtmlToNinjaTemplate(read.file.content); + } + //Status of call + result.status = read.status; + //Calling back with result + if (callback) callback(result); + break; + case 404: + //File does not exists + if (callback) callback({ status: read.status }); + break; + default: + //Unknown + if (callback) callback({ status: 500 }); + break; + } + /* + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + //Return Object Description + Object.status (Always presents for handling) + 204: File exists (Success) + 404: File does not exists (Failure) + 500: Unknown (Probably cloud API not running) - (Below only present if succesfull 204) + (Below only present if succesfull 204) - Object.content - Object.extension - Object.name - Object.uri - Object.creationDate - Object.modifiedDate - Object.readOnly - Object.size - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - */ - } + Object.content + Object.extension + Object.name + Object.uri + Object.creationDate + Object.modifiedDate + Object.readOnly + Object.size + //////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////// + */ + } }, //////////////////////////////////////////////////////////////////// // fileSave: { - enumerable: false, - value: function (file, callback) { - // - var contents, save; - // - switch (file.mode) { - case 'html': - - - //TODO: Add check for Monatage library to copy - - //Getting content from function to properly handle saving assets (as in external if flagged) - contents = this.parseNinjaTemplateToHtml(file); - break; - default: - contents = file.content; - break; - } - //Making call to save file - save = this.fio.saveFile({uri: file.document.uri, contents: contents}); + enumerable: false, + value: function (file, callback) { + // + var contents, save; + // + switch (file.mode) { + case 'html': + + + //TODO: Add check for Monatage library to copy + + //Getting content from function to properly handle saving assets (as in external if flagged) + contents = this.parseNinjaTemplateToHtml(file); + break; + default: + contents = file.content; + break; + } + //Making call to save file + save = this.fio.saveFile({ uri: file.document.uri, contents: contents }); //Checking for callback if (callback) callback(save); - } + } }, //////////////////////////////////////////////////////////////////// // fileSaveAs: { - enumerable: false, - value: function (copyTo, copyFrom, callback) { - //TODO: Implement Save As functionality - } + enumerable: false, + value: function (copyTo, copyFrom, callback) { + //TODO: Implement Save As functionality + } }, //////////////////////////////////////////////////////////////////// // fileDelete: { - enumerable: false, - value: function (file, callback) { - //TODO: Implement Delete functionality - } + enumerable: false, + value: function (file, callback) { + //TODO: Implement Delete functionality + } }, //////////////////////////////////////////////////////////////////// // parseHtmlToNinjaTemplate: { - enumerable: false, - value: function (html) { - //Creating temp object to mimic HTML - var doc = window.document.implementation.createHTMLDocument(), template; - //Setting content to temp - doc.getElementsByTagName('html')[0].innerHTML = html; - //Creating return object - return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; - } + enumerable: false, + value: function (html) { + //Creating temp object to mimic HTML + var doc = window.document.implementation.createHTMLDocument(), template; + //Setting content to temp + doc.getElementsByTagName('html')[0].innerHTML = html; + //Creating return object + return { head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc }; + } }, //////////////////////////////////////////////////////////////////// //TODO: Expand to allow more templates, clean up variables parseNinjaTemplateToHtml: { - enumerable: false, - value: function (template) { - var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl+escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); - regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); - //Injecting head and body into old document - template.document.content.document.head.innerHTML = template.head.replace(regexRootUrl, ''); - template.document.content.document.body.innerHTML = template.body.replace(regexRootUrl, ''); - //Getting all CSS (style or link) tags - var styletags = template.document.content.document.getElementsByTagName('style'), + enumerable: false, + value: function (template) { + var regexRootUrl, rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])); + regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); + //Injecting head and body into old document + template.document.content.document.head.innerHTML = template.head.replace(regexRootUrl, ''); + template.document.content.document.body.innerHTML = template.body.replace(regexRootUrl, ''); + //Getting all CSS (style or link) tags + var styletags = template.document.content.document.getElementsByTagName('style'), linktags = template.document.content.document.getElementsByTagName('link'), toremovetags = []; - //Getting styles tags to be removed from document - if (styletags.length) { - for (var j=0; j only | css =