From 578e08c9b4e038b1ec05833c337e5d5e2e9621ec Mon Sep 17 00:00:00 2001 From: Tobias Hintze Date: Fri, 12 Jul 2013 16:28:33 +0200 Subject: [PATCH] fighting pathes for amd/dojo loading --- js/office.js | 87 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/js/office.js b/js/office.js index 3c62309f..9ce31882 100644 --- a/js/office.js +++ b/js/office.js @@ -1,59 +1,72 @@ /*globals $,OC,fileDownloadPath,t,document,odf,webodfEditor,alert,require */ var officeMain = { + dojoConfig: { + locale: "C", + paths: { + "webodf/editor": "/owncloud/apps/office/js/editor", + "dijit": "/owncloud/apps/office/js/editor/dijit", + "dojox": "/owncloud/apps/office/js/editor/dojox", + "dojo": "/owncloud/apps/office/js/editor/dojo", + "resources": "/owncloud/apps/office/js/editor/resources" + } + }, onStartup: function() { - "use strict"; alert("ready A"); - require(["dojo/ready"], function(ready) { - ready(function(){alert("ready B!");}); + OC.addScript('office', 'webodf_bootstrap', function() { + require({}, ["dojo/ready"], function(ready) { + ready(function(){ + dojo.config = officeMain.dojoConfig; + alert("dojo loaded"); + require({}, ["webodf/editor/Editor"], function(Editor) { + alert("Editor loaded: "+Editor); + }); + }); + }); }); }, onView: function(dir, file) { "use strict"; - (function no_op() {return {no_op:function(){}};}()).no_op(function() { - OC.addScript('office', 'webodf').done(function() { - OC.addScript('office', 'webodf_bootstrap').done(function() { - OC.addScript('office', 'boot_editor').done(function() { - var doclocation = fileDownloadPath(dir, file); + OC.addScript('office', 'webodf').done(function() { + OC.addScript('office', 'boot_editor').done(function() { + var doclocation = fileDownloadPath(dir, file); - // fade out files menu and add odf menu - $('.documentslist').fadeOut('slow').promise().done(function() { - // odf action toolbar - var odfToolbarHtml = - '
' + - '
'; - $('#controls').append(odfToolbarHtml); - }); + // fade out files menu and add odf menu + $('.documentslist').fadeOut('slow').promise().done(function() { + // odf action toolbar + var odfToolbarHtml = + '
' + + '
'; + $('#controls').append(odfToolbarHtml); + }); - // fade out file list and show WebODF canvas - $('table').fadeOut('slow').promise().done(function() { - var odfelement, odfcanvas, canvashtml = ''; + // fade out file list and show WebODF canvas + $('table').fadeOut('slow').promise().done(function() { + var odfelement, odfcanvas, canvashtml = ''; - $('table').after(canvashtml); - // in case we are on the public sharing page we shall display the odf into the preview tag - // $('#preview').html(canvashtml); + $('table').after(canvashtml); + // in case we are on the public sharing page we shall display the odf into the preview tag + // $('#preview').html(canvashtml); - webodfEditor.boot( + webodfEditor.boot( { collaborative: 0, docUrl: doclocation, callback: function() { alert('live!'); } } - ); + ); - // odfelement = document.getElementById("odf-canvas"); - // odfcanvas = new odf.OdfCanvas(odfelement); - // odfcanvas.load(doclocation); - }); + // odfelement = document.getElementById("odf-canvas"); + // odfcanvas = new odf.OdfCanvas(odfelement); + // odfcanvas.load(doclocation); }); }); - }); }); }, onClose: function() {