Browse Source

direct tokens in fb.ui.fbIntl

Herbert Vojčík 13 years ago
parent
commit
46a5d4bf5b
1 changed files with 11 additions and 2 deletions
  1. 11 2
      lib-app/facebook-ext.js

+ 11 - 2
lib-app/facebook-ext.js

@@ -36,6 +36,8 @@ fb.requireLogin = function (perms) {
     }
 };
 
+import("lib-support/useful");
+
 /** Place for convenience extension functions for UI */
 fb.ui = {
   /**
@@ -74,7 +76,7 @@ fb.ui = {
   fbIntl: function fbIntl (element) {
     var result = FB_INTL({desc: element.desc});
 
-    result.push(element.body);
+    var body = [element.body];
 
     var tokens = element.tokens ? element.tokens.split(",") : [],
       tokenFuns = fbIntl.tokens;
@@ -87,8 +89,15 @@ fb.ui = {
 
     tokens.forEach(function (token) {
       var f = tokenFuns[token];
-      if (f) { result.push(FB_INTL_TOKEN({name:token}, f(token, element))); }
+      if (f) {
+        if (f.direct) {
+          splitReplace(body, "{"+token+"}", f(token, element)); 
+        } else {
+          result.push(FB_INTL_TOKEN({name:token}, f(token, element)));
+        }
+      }
     });
+    result.unshift.apply(result, body);
 
     return result;
   },