[Yulup-commits] rev 23940 - in
public/yulup/src/trunk/yulup/src/chrome/content: . editor/widgets
andi at wyona.com
andi at wyona.com
Fri Apr 20 23:35:27 CEST 2007
Author: andi
Date: 2007-04-20 23:35:26 +0200 (Fri, 20 Apr 2007)
New Revision: 23940
Modified:
public/yulup/src/trunk/yulup/src/chrome/content/common.js
public/yulup/src/trunk/yulup/src/chrome/content/editor/widgets/widgetparams.js
Log:
Infrastructure for making URIs relative added.
Modified: public/yulup/src/trunk/yulup/src/chrome/content/common.js
===================================================================
--- public/yulup/src/trunk/yulup/src/chrome/content/common.js 2007-04-20 20:58:21 UTC (rev 23939)
+++ public/yulup/src/trunk/yulup/src/chrome/content/common.js 2007-04-20 21:35:26 UTC (rev 23940)
@@ -464,6 +464,25 @@
};
+const YulupURIServices = {
+ /**
+ * Tries to create a relative URI from two absolute URIS.
+ *
+ * @param {nsIURI} aURI the URI to make relative
+ * @param {nsIURI} aBaseURI the URI against which aURI should be made relative
+ * @return {String} returns a relative URI or null, if creation failed
+ */
+ makeRelative: function (aURI, aBaseURI) {
+ /* DEBUG */ dump("Yulup:common.js:YulupURIServices.makeRelative() invoked\n");
+
+ /* DEBUG */ YulupDebug.ASSERT(aURI != null);
+ /* DEBUG */ YulupDebug.ASSERT(aBaseURI != null);
+
+ return null;
+ }
+};
+
+
/**
* YulupMessageProxy constructor. Instantiates a new object of
* type YulupMessageProxy.
Modified: public/yulup/src/trunk/yulup/src/chrome/content/editor/widgets/widgetparams.js
===================================================================
--- public/yulup/src/trunk/yulup/src/chrome/content/editor/widgets/widgetparams.js 2007-04-20 20:58:21 UTC (rev 23939)
+++ public/yulup/src/trunk/yulup/src/chrome/content/editor/widgets/widgetparams.js 2007-04-20 21:35:26 UTC (rev 23940)
@@ -34,13 +34,13 @@
var WidgetDialog = {
__fragmentAttributes: null,
__sitetreeURI : null,
+ __editorController : null,
__topWindow : null,
uiYulupEditorWidgetInsertOnDialogLoadHandler: function() {
var widget = null;
var widgetAction = null;
var nsResolver = null;
- var editorController = null;
var widgetRows = null;
var label = null;
var elem = null;
@@ -51,14 +51,14 @@
/* DEBUG */ dump("Yulup:widgetparams.js:WidgetDialog.uiYulupEditorWidgetInsertOnDialogLoadHandler() invoked\n");
- widget = window.arguments[1];
- widgetAction = window.arguments[2]
- nsResolver = window.arguments[3];
- editorController = window.arguments[4];
- this.__topWindow = window.arguments[5];
+ widget = window.arguments[1];
+ widgetAction = window.arguments[2]
+ nsResolver = window.arguments[3];
+ this.__editorController = window.arguments[4];
+ this.__topWindow = window.arguments[5];
- if (editorController.editorParams.navigation && editorController.editorParams.navigation.sitetree) {
- this.__sitetreeURI = editorController.editorParams.navigation.sitetree.uri;
+ if (this.__editorController.editorParams.navigation && this.__editorController.editorParams.navigation.sitetree) {
+ this.__sitetreeURI = this.__editorController.editorParams.navigation.sitetree.uri;
}
WidgetDialog.__fragmentAttributes = widgetAction.parameters;
@@ -247,7 +247,10 @@
},
doSelectCommandProxy: function (aAction, aFieldID) {
- var value = null;
+ var value = null;
+ var documentURI = null;
+ var uri = null;
+ var relURI = null;
switch (aAction) {
case 0:
@@ -259,7 +262,23 @@
default:
}
- if (value)
+ if (value) {
+ try {
+ // try to make the returned URI relative to the document URI
+ documentURI = this.__editorController.document.loadURI;
+
+ if (documentURI) {
+ uri = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService).newURI(value, null, null);
+
+ if (relURI = YulupURIServices.makeRelative(uri, documentURI))
+ value = relURI;
+ }
+ } catch (exception) {
+ /* DEBUG */ YulupDebug.dumpExceptionToConsole("Yulup:widgetparams.js:WidgetDialog.doSelectCommandProxy", exception);
+ /* DEBUG */ Components.utils.reportError(exception);
+ }
+
document.getElementById(aFieldID).setAttribute("value", value);
+ }
}
};
More information about the Yulup-commits
mailing list