+2005-07-19 Helge Hess <helge.hess@opengroupware.org>
+
+ * UIxPageFrame.m: added ability to auto-load per-page JavaScript files
+ if appropriate resources are available (v0.9.45)
+
2005-07-18 Helge Hess <helge.hess@opengroupware.org>
* moved all images and CSS to WebServerResources (v0.9.44)
return [self relativePathToUserFolderSubPath:@"Mail/"];
}
+/* page based JavaScript */
+
+- (WOResourceManager *)pageResourceManager {
+ WOResourceManager *rm;
+
+ if ((rm = [[[self context] page] resourceManager]) == nil)
+ rm = [[WOApplication application] resourceManager];
+ return rm;
+}
+
+- (NSString *)pageJavaScriptURL {
+ static NSMutableDictionary *pageToURL = nil;
+ WOResourceManager *rm;
+ WOComponent *page;
+ NSString *jsname;
+ NSString *url;
+
+ page = [[self context] page];
+ jsname = [page name];
+ if ((url = [pageToURL objectForKey:jsname]) != nil)
+ return [url isNotNull] ? url : nil;
+
+ if (pageToURL == nil)
+ pageToURL = [[NSMutableDictionary alloc] initWithCapacity:32];
+
+ rm = [self pageResourceManager];
+ jsname = [jsname stringByAppendingString:@".js"];
+
+ url = [rm urlForResourceNamed:jsname
+ inFramework:
+ [[NSBundle bundleForClass:[page class]] bundlePath]
+ languages:nil
+ request:[[self context] request]];
+
+ /* cache */
+ [pageToURL setObject:(url ? url : (id)[NSNull null]) forKey:[page name]];
+ return url;
+}
+
+- (BOOL)hasPageSpecificJavaScript {
+ return [[self pageJavaScriptURL] length] > 0 ? YES : NO;
+}
+
@end /* UIxPageFrame */
<meta name="description" content="SOGo Web Interface"/>
<meta name="author" content="SKYRIX Software AG"/>
<meta name="robots" content="stop"/>
+
<link type="text/css" rel="stylesheet" rsrc:href="uix.css"/>
<link type="text/css" rel="stylesheet" rsrc:href="calendar.css"/>
<link href="mailto:hh@skyrix.com" rev="made"/>
+
<script rsrc:src="generic.js"> <!-- space required --></script>
+
+ <var:if condition="hasPageSpecificJavaScript">
+ <script var:src="pageJavaScriptURL"> <!-- space required --></script>
+ </var:if>
</head>
<body>