|
@@ -3,7 +3,7 @@
|
|
|
// Copyright (c) 2009, 2010, Herbert Vojčík
|
|
|
// Licensed by MIT license (http://www.opensource.org/licenses/mit-license.php)
|
|
|
|
|
|
-import("facebook", "storage");
|
|
|
+import("facebook", "storage", "lib-support/useful");
|
|
|
|
|
|
// TODO new FBML tags
|
|
|
importTags(this, [
|
|
@@ -38,25 +38,57 @@ fb.requireLogin = function (perms) {
|
|
|
|
|
|
/** Place for convenience extension functions for UI */
|
|
|
fb.ui = {
|
|
|
-/**
|
|
|
- * Creates tabs according to items parameter.
|
|
|
- * If actual url matches one of them, it is selected.
|
|
|
- * Next example renders tabs for .../callback/profile, .../callback/invite and .../callback/play.
|
|
|
- @example
|
|
|
- print(fb.ui.tabs("profile_Profile", "invite_Invite friends", "play_Play!"));
|
|
|
- */
|
|
|
- tabs: function (items) {
|
|
|
- var menu = FB_TABS();
|
|
|
- var lastSegment = request.path.split("/").pop();
|
|
|
- items.forEach (function (item) {
|
|
|
- var split = item.split("_");
|
|
|
- menu.push(FB_TAB_ITEM({
|
|
|
- href: split[0],
|
|
|
- title: split[1],
|
|
|
- selected: lastSegment === split[0]
|
|
|
- }));
|
|
|
- });
|
|
|
- return menu;
|
|
|
+ /**
|
|
|
+ * Creates tabs according to items parameter.
|
|
|
+ * If actual url matches one of them, it is selected.
|
|
|
+ * Next example renders tabs for .../callback/profile, .../callback/invite and .../callback/play.
|
|
|
+ @example
|
|
|
+ print(fb.ui.tabs("profile_Profile", "invite_Invite friends", "play_Play!"));
|
|
|
+ */
|
|
|
+ tabs: function (items) {
|
|
|
+ var menu = FB_TABS();
|
|
|
+ var lastSegment = request.path.split("/").pop();
|
|
|
+ items.forEach (function (item) {
|
|
|
+ var split = item.split("_");
|
|
|
+ menu.push(FB_TAB_ITEM({
|
|
|
+ href: split[0],
|
|
|
+ title: split[1],
|
|
|
+ selected: lastSegment === split[0]
|
|
|
+ }));
|
|
|
+ });
|
|
|
+ return menu;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * Creates FB_INTL from supplied element.
|
|
|
+ * Element should have desc (description),
|
|
|
+ * body (text that may contain {tokens}),
|
|
|
+ * tokens (comma-separated list of token names
|
|
|
+ * to be inserted as FB_INTL_TOKEN, optional)
|
|
|
+ * and multiline (if defined, contains delimiter
|
|
|
+ * that is replaced with BR()s, optional).
|
|
|
+ * fbIntl.tokens contains functions that populate token bodies,
|
|
|
+ * you should populate it if you want to have FB_INTL_TOKENs inserted.
|
|
|
+ * If replacer function does not exist, the token is not inserted
|
|
|
+ * and no warning or error is raised.
|
|
|
+ */
|
|
|
+ fbIntl: function (element) {
|
|
|
+ var fbIntl = FB_INTL({desc: element.desc});
|
|
|
+ if (!element.multiline && !element.tokens) {
|
|
|
+ fbIntl.push(element.body);
|
|
|
+ return fbIntl;
|
|
|
}
|
|
|
+ var parts = [ element.body ];
|
|
|
+ if (element.multiline) { parts = splitReplace(parts, element.multiline, BR()); }
|
|
|
+ if (element.tokens) {
|
|
|
+ element.tokens.split(",").forEach(function (token) {
|
|
|
+ var f = fbIntl.tokens[token];
|
|
|
+ if (f) { parts.push(FB_INTL_TOKEN({name:token}, f(token, element))); }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ fbIntl.push.apply(fbIntl, parts);
|
|
|
+ return fbIntl;
|
|
|
+ },
|
|
|
};
|
|
|
|
|
|
+fb.ui.fbIntl.tokens = {};
|
|
|
+
|