From 075252ad893452df446566f01d0b26eeab08be3d Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Wed, 15 Feb 2012 23:07:00 -0800 Subject: Setting up webGL library copy on save --- js/document/html-document.js | 36 ++++++++---------------------------- js/io/system/coreioapi.js | 20 +++----------------- js/io/system/ninjalibrary.js | 25 ++++++++++++++++++++++--- js/mediators/io-mediator.js | 12 ++++++++++++ 4 files changed, 45 insertions(+), 48 deletions(-) (limited to 'js') diff --git a/js/document/html-document.js b/js/document/html-document.js index bf9bba76..ad5417a9 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -12,7 +12,7 @@ var Montage = require("montage/core/core").Montage, //////////////////////////////////////////////////////////////////////// // exports.HTMLDocument = Montage.create(TextDocument, { - // PRIVATE MEMBERS + _selectionExclude: { value: null, enumerable: false }, _htmlTemplateUrl: { value: "user-document-templates/montage-application-cloud/index.html", enumerable: false}, _iframe: { value: null, enumerable: false }, @@ -41,7 +41,6 @@ exports.HTMLDocument = Montage.create(TextDocument, { _zoomFactor: { value: 100, enumerable: false }, - // PUBLIC MEMBERS cssLoadInterval: { value: null, enumerable: false }, _savedLeftScroll: {value:null}, @@ -53,9 +52,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { value:null }, - /* - * PUBLIC API - */ + // GETTERS / SETTERS @@ -231,9 +228,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, - - //****************************************// - // PUBLIC METHODS + //////////////////////////////////////////////////////////////////// @@ -357,19 +352,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { return this._window.getElement(x,y); } }, - - /* - // Private - _loadDocument: { - value: function(uri) { - // Load the document into the Iframe - this.iframe.src = uri; - this.iframe.addEventListener("load", this, true); - } - }, -*/ - - + + //////////////////////////////////////////////////////////////////// // @@ -475,11 +459,7 @@ exports.HTMLDocument = Montage.create(TextDocument, { } } }, - - /** - * public method - * - */ + //////////////////////////////////////////////////////////////////// // save: { @@ -487,12 +467,12 @@ exports.HTMLDocument = Montage.create(TextDocument, { value: function () { //TODO: Add code view logic and also styles for HTML if (this.currentView === 'design') { - return {mode: 'html', document: this._userDocument, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; + return {mode: 'html', document: this._userDocument, webgl: this.glData, style: this._styles, head: this._templateDocument.head.innerHTML, body: this._templateDocument.body.innerHTML}; } else if (this.currentView === "code"){ //TODO: Would this get call when we are in code of HTML? } else { //Error - } + } } } //////////////////////////////////////////////////////////////////// diff --git a/js/io/system/coreioapi.js b/js/io/system/coreioapi.js index 507804fd..a75b59bb 100755 --- a/js/io/system/coreioapi.js +++ b/js/io/system/coreioapi.js @@ -40,6 +40,7 @@ exports.CoreIoApi = Montage.create(Component, { //////////////////////////////////////////////////////////// //Instance of ninja library this.ninjaLibrary = NinjaLibrary; + this.ninjaLibrary.coreApi = this; //Getting reference of chrome file system API this.chromeFileSystem = ChromeApi; //Sending size in MBs for file system storage @@ -62,6 +63,7 @@ exports.CoreIoApi = Montage.create(Component, { this.chromeFileSystem.removeEventListener('ready', this, false); //Listening for library to be copied event (builds list) this.chromeFileSystem.addEventListener('library', this, false); + //TODO: Add sync loading screen logic (Add screen here) } }, //////////////////////////////////////////////////////////////////// @@ -86,23 +88,7 @@ exports.CoreIoApi = Montage.create(Component, { console.log('Ninja Local Library: Ready'); //Removing events this.ninjaLibrary.removeEventListener('sync', this, false); - this.ninjaLibrary.coreApi = this; - //TODO: Add sync loading screen logic - - //TODO: Remove test - //this.ninjaLibrary.copyLibToCloud('Users/kgq387/Desktop/Ninja Cloud/Disk', 'montage0.6.0'); - //this.ninjaLibrary.deleteLibraries(); - /* -window.hack = function (name, type) { - this.application.ninja.ioMediator.fileNew('Users/kgq387/Desktop/Ninja Cloud/Disk/'+name+'.'+type, '/js/io/templates/files/'+type+'.txt', function (status) {console.log(status)}); - }.bind(this); -*/ - /* -window.hack = function (path) { - // - this.application.ninja.ioMediator.fileOpen('Users/kgq387/Desktop/Ninja Cloud/Disk/'+path, function (result) {console.log(result)}); - }.bind(this); -*/ + //TODO: Add sync loading screen logic (Remove screen here) } }, //////////////////////////////////////////////////////////////////// diff --git a/js/io/system/ninjalibrary.js b/js/io/system/ninjalibrary.js index fc943323..8c58883a 100644 --- a/js/io/system/ninjalibrary.js +++ b/js/io/system/ninjalibrary.js @@ -51,6 +51,23 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { }, //////////////////////////////////////////////////////////////////// // + _libs: { + enumerable: false, + value: null + }, + //////////////////////////////////////////////////////////////////// + // + libs: { + enumerable: false, + get: function() { + return this._libs; + }, + set: function(value) { + this._libs = value; + } + }, + //////////////////////////////////////////////////////////////////// + // _libsToSync: { enumerable: false, value: 0 @@ -67,14 +84,14 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { enumerable: false, value: function (path, libName) { // - if(this.coreApi.directoryExists({uri: '/'+path+'/'+libName+'/'}).status === 404) { + if(this.coreApi.directoryExists({uri: path+libName}).status === 404) { this.chromeApi.directoryContents(this.chromeApi.fileSystem.root, function (contents) { for (var i in contents) { if (libName === contents[i].name) { //Getting contents of library to be copied this.chromeApi.directoryContents(contents[i], function (lib) { //Creating directory structure from subfolders - this.copyDirectoryToCloud(path, contents[i], '/'+path, function (status) {console.log(status)}); + this.copyDirectoryToCloud(path, contents[i], path, function (status) {console.log(status)}); }.bind(this)); break; } @@ -99,7 +116,7 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { dir = folder.name; } // - if (!this.coreApi.createDirectory({uri: '/'+dir+'/'})) { + if (!this.coreApi.createDirectory({uri: dir})) { //Error occured while creating folders return; } @@ -140,6 +157,8 @@ exports.NinjaLibrary = Montage.create(Object.prototype, { //Parsing json libraries libs = JSON.parse(xhr.response); // + this.libs = libs.libraries; + // if (chromeLibs.length > 0) { // for (i=0; chromeLibs[i]; i++) { diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js index 2008e40f..e9958ec3 100644 --- a/js/mediators/io-mediator.js +++ b/js/mediators/io-mediator.js @@ -86,6 +86,7 @@ exports.IoMediator = Montage.create(Component, { 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 @@ -191,6 +192,17 @@ exports.IoMediator = Montage.create(Component, { // template.document.content.document.body.innerHTML = template.body; template.document.content.document.head.innerHTML = template.head; + // + if (template.webgl.length > 0) { + for (var i in this.application.ninja.coreIoApi.ninjaLibrary.libs) { + if (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'Assets' || this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name === 'RDGE') { + this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(template.document.root, (this.application.ninja.coreIoApi.ninjaLibrary.libs[i].name+this.application.ninja.coreIoApi.ninjaLibrary.libs[i].version).toLowerCase()); + } + } + + //this.application.ninja.coreIoApi.ninjaLibrary.copyLibToCloud(path, libname); + //console.log(this.application.ninja.coreIoApi.ninjaLibrary.libs); + } //TODO: Remove temp fix for styles if (template.style) { template.document.content.document.head.getElementsByTagName('style')[0].innerHTML = this.getCssFromRules(template.style.cssRules); -- cgit v1.2.3