Permalink
Browse files

added Ti javascript property to get the current script relative path …

…to Ressources.
  • Loading branch information...
1 parent 4066332 commit 15190196305ab2b3d8d184e17c70d2ed043f78e6 @farfromrefug farfromrefug committed Nov 5, 2012
Showing with 16 additions and 0 deletions.
  1. +7 −0 android/runtime/common/src/js/titanium.js
  2. +9 −0 iphone/Classes/TopTiModule.m
@@ -76,6 +76,13 @@ function TitaniumWrapper(context) {
this.Android = new AndroidWrapper(context);
this.UI = new UIWrapper(context, this.Android);
+ Object.defineProperty(this, "ressourcesRelativePath", {
+ get: function() {
+ var value = context.sourceUrl.replace("app://", "");
+ return value;
+ }
+ });
+
var scopeVars = new kroll.ScopeVars({
sourceUrl: sourceUrl,
module: context.module,
@@ -61,6 +61,15 @@ -(void)include:(NSArray*)jsfiles
[context setCurrentURL:oldUrl];
}
+-(id)ressourcesRelativePath
+{
+ id<TiEvaluator> context = [self executionContext];
+ NSURL * oldUrl = [context currentURL];
+ NSURL * rootURL = (oldUrl != nil)?oldUrl:[self _baseURL];
+ NSString * result = [[rootURL absoluteString] stringByReplacingOccurrencesOfString:[[self _baseURL] absoluteString] withString:@""];
+ return result;
+}
+
#ifdef DEBUG
// an internal include that works with absolute URLs (debug mode only)
-(void)includeAbsolute:(NSArray*)jsfiles

2 comments on commit 1519019

@jhaynie

should be resourcesRelativePath -- not ressourcesRelativePath (mispelling)

@farfromrefug

you are right :d, fixing it right now.
thanks a lot

Please sign in to comment.