]> err.no Git - scalable-opengroupware.org/commitdiff
added ability to have per-page JavaScript files in the frame
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 10:00:40 +0000 (10:00 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Tue, 19 Jul 2005 10:00:40 +0000 (10:00 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@820 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/UI/Common/ChangeLog
SOGo/UI/Common/UIxPageFrame.m
SOGo/UI/Common/Version
SOGo/UI/Templates/UIxPageFrame.wox

index cd79076423a93a514d659930ab484b55d47481d2..ce634f964ccfec411efb00d790f8cb26a81339a8 100644 (file)
@@ -1,3 +1,8 @@
+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)
index b3a967316f82870a89d5d3920710f83eb95097bd..a5811b0af9a2e5bf9aa9e2a15d570ebd12789e75 100644 (file)
   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 */
index c76723636f6d3836baf4d29883aaad2565321336..def68eeddb5fb02e9d3aec8a8af1d0cd9fbd1441 100644 (file)
@@ -1,5 +1,5 @@
 # Version file
 
-SUBMINOR_VERSION:=44
+SUBMINOR_VERSION:=45
 
 # v0.9.28 requires NGExtensions v4.5.136
index 2758fe42d5239ef56fd6057b8ea94de0cf4d65f4..be1852629390f5339a955e400fae5aae62083236 100644 (file)
     <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>