From: helge Date: Tue, 19 Jul 2005 10:00:40 +0000 (+0000) Subject: added ability to have per-page JavaScript files in the frame X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=333d179284559df606f36c1b1b9f32d95ce27a7c;p=scalable-opengroupware.org added ability to have per-page JavaScript files in the frame git-svn-id: http://svn.opengroupware.org/SOGo/trunk@820 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Common/ChangeLog b/SOGo/UI/Common/ChangeLog index cd790764..ce634f96 100644 --- a/SOGo/UI/Common/ChangeLog +++ b/SOGo/UI/Common/ChangeLog @@ -1,3 +1,8 @@ +2005-07-19 Helge Hess + + * UIxPageFrame.m: added ability to auto-load per-page JavaScript files + if appropriate resources are available (v0.9.45) + 2005-07-18 Helge Hess * moved all images and CSS to WebServerResources (v0.9.44) diff --git a/SOGo/UI/Common/UIxPageFrame.m b/SOGo/UI/Common/UIxPageFrame.m index b3a96731..a5811b0a 100644 --- a/SOGo/UI/Common/UIxPageFrame.m +++ b/SOGo/UI/Common/UIxPageFrame.m @@ -99,4 +99,47 @@ 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 */ diff --git a/SOGo/UI/Common/Version b/SOGo/UI/Common/Version index c7672363..def68eed 100644 --- a/SOGo/UI/Common/Version +++ b/SOGo/UI/Common/Version @@ -1,5 +1,5 @@ # Version file -SUBMINOR_VERSION:=44 +SUBMINOR_VERSION:=45 # v0.9.28 requires NGExtensions v4.5.136 diff --git a/SOGo/UI/Templates/UIxPageFrame.wox b/SOGo/UI/Templates/UIxPageFrame.wox index 2758fe42..be185262 100644 --- a/SOGo/UI/Templates/UIxPageFrame.wox +++ b/SOGo/UI/Templates/UIxPageFrame.wox @@ -12,10 +12,16 @@ + + + + + +