Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move code to [deprecated] branch and update readme

  • Loading branch information...
commit 95663268ae6a3fd6227c07f01d1c1dbb6cfad04a 1 parent f9bec84
Øyvind Sean Kinsey oyvindkinsey authored
Showing with 1 addition and 16,976 deletions.
  1. +0 −7 .gitignore
  2. +0 −92 all.js.php
  3. +0 −41 changelog.md
  4. +0 −141 console/console.css
  5. +0 −140 console/console.js
  6. +0 −147 console/index.html
  7. +0 −84 examples/dojo/login.html
  8. +0 −83 examples/jquery/login.html
  9. +0 −84 examples/mootools/login.html
  10. +0 −84 examples/prototype/login.html
  11. +0 −84 examples/yui2/login.html
  12. +1 −0  readme.md
  13. +0 −128 src/common/anim.js
  14. +0 −152 src/common/array.js
  15. +0 −300 src/common/dom.js
  16. +0 −46 src/common/obj.js
  17. +0 −110 src/common/string.js
  18. +0 −142 src/common/type.js
  19. +0 −170 src/compat/ui.js
  20. +0 −59 src/compat/xfbml.js
  21. +0 −388 src/core/api.js
  22. +0 −492 src/core/auth.js
  23. +0 −233 src/core/canvas.js
  24. +0 −237 src/core/content.js
  25. +0 −135 src/core/cookie.js
  26. +0 −300 src/core/dialog.js
  27. +0 −180 src/core/event.js
  28. +0 −188 src/core/flash.js
  29. +0 −180 src/core/init.js
  30. +0 −73 src/core/insights.js
  31. +0 −156 src/core/intl.js
  32. +0 −79 src/core/json.js
  33. +0 −206 src/core/prelude.js
  34. +0 −77 src/core/qs.js
  35. +0 −543 src/core/ui.js
  36. +0 −88 src/core/ui_methods.js
  37. +0 −289 src/core/xd.js
  38. +0 −55 src/css/base.css
  39. +0 −193 src/css/button.css
  40. +0 −113 src/css/connect_bar_widget.css
  41. +0 −151 src/css/dialog.css
  42. +0 −29 src/css/edge_comment_widget.css
  43. +0 −62 src/css/iframe_widget.css
  44. +0 −113 src/css/share_button.css
  45. +0 −48 src/css/social_bar_widget.css
  46. +0 −342 src/data/data.js
  47. +0 −194 src/data/query.js
  48. +0 −99 src/data/waitable.js
  49. +0 −35 src/meta/all.js
  50. +0 −45 src/strings/en_US.js
  51. +0 −479 src/third-party/json2.js
  52. +0 −125 src/xfbml/button_element.js
  53. +0 −77 src/xfbml/edge_comment_widget.js
  54. +0 −274 src/xfbml/edge_widget.js
  55. +0 −137 src/xfbml/element.js
  56. +0 −101 src/xfbml/helper.js
  57. +0 −364 src/xfbml/iframe_widget.js
  58. +0 −71 src/xfbml/tags/activity.js
  59. +0 −53 src/xfbml/tags/add_profile_tab.js
  60. +0 −53 src/xfbml/tags/bookmark.js
  61. +0 −120 src/xfbml/tags/comments.js
  62. +0 −263 src/xfbml/tags/connect_bar.js
  63. +0 −91 src/xfbml/tags/facepile.js
  64. +0 −92 src/xfbml/tags/fan.js
  65. +0 −28 src/xfbml/tags/friendpile.js
  66. +0 −38 src/xfbml/tags/like.js
  67. +0 −97 src/xfbml/tags/likebox.js
  68. +0 −66 src/xfbml/tags/live_stream.js
  69. +0 −50 src/xfbml/tags/login.js
  70. +0 −97 src/xfbml/tags/loginbutton.js
  71. +0 −268 src/xfbml/tags/name.js
  72. +0 −150 src/xfbml/tags/profilepic.js
  73. +0 −71 src/xfbml/tags/recommendations.js
  74. +0 −79 src/xfbml/tags/serverfbml.js
  75. +0 −169 src/xfbml/tags/sharebutton.js
  76. +0 −204 src/xfbml/tags/social_bar.js
  77. +0 −299 src/xfbml/xfbml.js
  78. +0 −8 tests/channel.html
  79. +0 −123 tests/data_test.html
  80. +0 −196 tests/index.html
  81. +0 −42 tests/js/add_friend.js
  82. +0 −186 tests/js/api.js
  83. +0 −130 tests/js/array.js
  84. +0 −276 tests/js/auth.js
  85. +0 −102 tests/js/auth_events.js
  86. +0 −185 tests/js/canvas.js
  87. +0 −40 tests/js/cleanup.js
  88. +0 −156 tests/js/content.js
  89. +0 −93 tests/js/cookie.js
  90. +0 −236 tests/js/data.js
  91. +0 −81 tests/js/debug_logs.js
  92. +0 −181 tests/js/dialog.js
  93. +0 −97 tests/js/dom.js
  94. +0 −91 tests/js/edge_widget.js
  95. +0 −191 tests/js/event.js
  96. +0 −49 tests/js/flash.js
  97. +0 −62 tests/js/helper.js
  98. +0 −99 tests/js/initialize.js
  99. +0 −36 tests/js/insights.js
  100. +0 −34 tests/js/json.js
  101. +0 −96 tests/js/prelude.js
  102. +0 −113 tests/js/publish.js
  103. +0 −94 tests/js/qs.js
  104. +0 −55 tests/js/revoke.js
  105. +0 −41 tests/js/share.js
  106. +0 −51 tests/js/string.js
  107. +0 −81 tests/js/type.js
  108. +0 −279 tests/js/uiserver.js
  109. +0 −38 tests/js/waitable.js
  110. +0 −192 tests/js/xd.js
  111. +0 −126 tests/js/xfbml.js
  112. +0 −208 tests/js/xfbmltags.js
  113. +0 −37 tests/js/xfbmltags_with_session.js
  114. +0 −90 tests/js/xfbmltest.js
  115. +0 −122 tests/qunit.css
  116. +0 −1,045 tests/qunit.js
  117. +0 −99 tests/slowwatir.rb
  118. +0 −149 tests/tests.rb
  119. +0 −33 tests/xfbml_test.html
7 .gitignore
View
@@ -1,7 +0,0 @@
-/TODO
-/build/
-/docs/
-/index.html
-/jscoverage-report/
-/m.js
-/nginx.conf
92 all.js.php
View
@@ -1,92 +0,0 @@
-<?php
-//
-// Copyright Facebook Inc.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-$JS_FILES = array(
- 'src/third-party/json2.js',
-
- 'src/core/prelude.js',
- 'src/common/type.js',
-
- 'src/core/api.js',
- 'src/core/auth.js',
-
- 'src/core/canvas.js',
- 'src/core/content.js',
- 'src/core/cookie.js',
- 'src/core/dialog.js',
- 'src/core/event.js',
- 'src/core/flash.js',
- 'src/core/init.js',
- 'src/core/insights.js',
- 'src/core/intl.js',
- 'src/core/json.js',
- 'src/core/qs.js',
- 'src/core/ui.js',
- 'src/core/ui_methods.js',
- 'src/core/xd.js',
-
- 'src/compat/ui.js',
-
- 'src/common/array.js',
- 'src/common/dom.js',
- 'src/common/obj.js',
- 'src/common/string.js',
-
- 'src/data/waitable.js',
- 'src/data/query.js',
- 'src/data/data.js',
-
- 'src/xfbml/element.js',
- 'src/xfbml/xfbml.js',
- 'src/xfbml/helper.js',
- 'src/xfbml/iframe_widget.js',
- 'src/xfbml/button_element.js',
- 'src/xfbml/edge_widget.js',
-
- 'src/xfbml/tags/activity.js',
- 'src/xfbml/tags/comments.js',
- 'src/xfbml/tags/fan.js',
- 'src/xfbml/tags/like.js',
- 'src/xfbml/tags/live_stream.js',
- 'src/xfbml/tags/loginbutton.js',
- 'src/xfbml/tags/name.js',
- 'src/xfbml/tags/profilepic.js',
- 'src/xfbml/tags/recommendations.js',
- 'src/xfbml/tags/serverfbml.js',
- 'src/xfbml/tags/sharebutton.js',
-
- 'src/strings/en_US.js',
-);
-
-$CSS_FILES = array(
- 'src/css/dialog.css',
- 'src/css/button.css',
- 'src/css/share_button.css',
- 'src/css/base.css',
- 'src/css/iframe_widget.css',
-);
-
-foreach ($JS_FILES as $file) {
- echo file_get_contents($file);
-}
-
-$css = '';
-foreach ($CSS_FILES as $file) {
- $css .= file_get_contents($file);
-}
-// css URLs are relative to facebook domains
-$css = preg_replace('#url\(/#', 'url(http://static.ak.fbcdn.net/', $css);
-echo 'FB.Dom.addCssRules(' . json_encode($css) . ', ["pkg"])';
41 changelog.md
View
@@ -1,41 +0,0 @@
-Cookie Format
--------------
-
-*Date*: 20th November, 2009
-
-We were including the '=' sign in the cookie value which although works on many
-servers, is not actually valid accoring to [RFC2965][CookieRFC]. The correct
-way to include the '=' character is by having the cookie value be quoted.
-
-The result is that you will need to update your server side logic for parsing
-the Cookie to handle the quotes if needed.
-
-[CookieRFC]: http://www.faqs.org/rfcs/rfc2965.html
-
-Options for FB.login
--------------
-
-*Date*: 25th November, 2009
-
-We changed the signature for FB.login. It now takes a dictionary of
-options instead of just a permissions string. This will allow us to maintain
-backwards compatibility in the future if we expand the arguments.
-
-XFBML and Advanced Data layer
--------------
-
-*Date*: 18th December, 2009
-
-Alpha release for an implementation of [XFBML] and an [advanced data layer].
-
-[XFBML]: http://wiki.github.com/facebook/connect-js/xfbml
-[advanced data layer]: http://wiki.github.com/facebook/connect-js/data-layer
-
-Iframe Dialogs
--------------
-
-*Date*: 11th Match, 2010
-
-Support for iframe dialogs via [FB.ui()][FB.ui].
-
-[FB.ui]: http://developers.facebook.com/docs/?u=facebook.joey.FB.ui "UI Dialogs"
141 console/console.css
View
@@ -1,141 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.console.css
- */
-body {
- font-size: 12px;
- font-family: "Lucida Grande", Tahoma, Verdana, Arial, sans-serif;
-}
-a {
- color: #3B5998;
- text-decoration: none;
-}
-a:hover {
- text-decoration: underline;
-}
-
-#sidebar {
- float: right;
- font-family: "Calisto MT", Georgia, sans-serif;
- font-size: 16px;
- line-height: 1.2;
- background-color: #efefef;
- border: 2px solid #ddd;
- border-radius: 8px;
- -webkit-border-radius: 8px;
- -moz-border-radius: 8px;
- padding: 5px 20px;
- width: 450px;
- margin-left: 1em;
-}
-#sidebar ul {
- padding-left: 1.25em;
- margin-left: 0;
- clear: both;
- list-style-type: square;
-}
-#sidebar li {
- margin: 7px 0;
-}
-
-#controls {
- margin: 20px 0 20px 0;
- border-bottom: 1px solid #eee;
-}
-#controls > div {
- margin-left: 20px;
- margin-bottom: 30px;
-}
-#connected > div {
- margin-bottom: 30px;
-}
-.info {
- font-size: 13px;
- padding: 4px;
-}
-.info.yes {
- background-color: #fbfaf3;
- color: #36365a;
-}
-.info.no {
- background-color: #fef8f6;
- color: #cd0a0a;
-}
-#status {
- font-weight: bold;
- font-size: 15px;
- padding: 3px 6px;
-}
-#status.notConnected {
- background-color: #cc3f85;
- color: #fff;
-}
-#status.connected {
- background-color: #448805;
- color: #fff;
-}
-#info {
- margin-top: 12px;
- font-family: Monaco, Consolas, monospace;
-}
-#info th {
- text-align: left;
- padding-right: 20px;
-}
-
-#user-info {
- margin-left: 70px;
-}
-#user-name {
- font-size: 18px;
- font-weight: bold;
-}
-#user-pic {
- -moz-border-radius: 6px;
- -webkit-border-radius: 6px;
- border-radius: 6px;
- vertical-align: middle;
- margin-left: 5px;
- border: none;
- height: 50px;
- width: 50px;
-}
-#contents li {
- margin: 0;
- list-style-type: circle;
-}
-
-
-
-/**
- * Tag Browser
- */
-.tag-configurer {
- margin-bottom: 1em;
- width: 700px;
-}
-.tag-configurer textarea,
-.tag-configurer .preview {
- float: right;
- width: 400px;
-}
-.tag-configurer .attr {
- margin-top: 0.25em;
-}
-.tag-configurer .attr label {
- display: inline-block;
- width: 100px;
-}
140 console/console.js
View
@@ -1,140 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.console
- */
-$ = function(i) { return document.getElementById(i); };
-
-
-// publish something
-function publishExample() {
- var post = {
- message: 'This is some text',
- action_links: [
- { text:'custom action link', href:'http://github.com/facebook/connect-js'}
- ],
- user_message_prompt: 'Tell the world about Popups?'
- };
- FB.publish(post, function(published_post) {
- statusUpdate(
- 'sans-session-info',
- 'post was ' + (published_post ? '' : 'not ') + 'published.',
- published_post
- );
- });
-}
-
-function showUserInfo() {
- var userInfo = $('user-info');
- if (!FB.getSession()) {
- userInfo.style.visibility = 'hidden';
- } else {
- var params = {
- method: 'Fql.query',
- query: (
- 'SELECT ' +
- 'name,' +
- 'pic_square,' +
- 'profile_url ' +
- 'FROM ' +
- 'user ' +
- 'WHERE ' +
- 'uid=' + FB.getSession().uid
- )
- };
-
- FB.api(params, function(info) {
- if (info.error_code) {
- // bail
- return;
- }
-
- info = info[0];
-
- $('user-name').innerHTML = info.name;
- $('user-pic').src = info.pic_square;
- userInfo.href = info.profile_url;
- userInfo.style.visibility = 'visible';
- });
- }
-}
-
-function showSessionInfo() {
- var
- session = FB.getSession(),
- sessionInfo = $('info');
-
- if (!session) {
- sessionInfo.style.visibility = 'hidden';
- } else {
- var rows = [];
- for (var key in session) {
- rows.push('<th>' + key + '</th>' + '<td>' + session[key] + '</td>');
- }
- sessionInfo.style.visibility = 'visible';
- sessionInfo.innerHTML = (
- '<table>' +
- '<tr>' + rows.join('</tr><tr>') + '</tr>' +
- '</table>'
- );
- }
-}
-
-// handles a session (or lack thereof)
-function gotStatus(response) {
- showSessionInfo();
- showUserInfo();
-
- $('status').innerHTML = response.status;
- $('status').className = response.status;
-
- var input = $('integration').getElementsByTagName('input');
- for (var i=0, l=input.length; i<l; i++) {
- input[i].disabled = !response.session;
- }
-
- if (response.session) {
- $('bt-disconnect').disabled = $('bt-logout').disabled = false;
- $('bt-login').disabled = true;
- } else {
- $('bt-login').disabled = false;
- $('bt-disconnect').disabled = $('bt-logout').disabled = true;
- }
-}
-
-function gotPerms(response) {
- gotStatus(response);
- statusUpdate(
- 'perms-info',
- 'were ' + (response.perms ? '' : 'not ') + 'granted.',
- response.perms
- );
-}
-
-function statusUpdate(infoID, msg, yes) {
- var info = $(infoID);
- info.innerHTML = msg;
- info.className = 'info ' + (yes ? 'yes' : 'no');
- info.style.visibility = 'visible';
- window.setTimeout(function() { info.style.visibility = 'hidden'; }, 3000);
-}
-
-function friendAdded(added) {
- statusUpdate(
- 'integration-info',
- 'friend was ' + (added ? '' : 'not ') + 'added.',
- added
- );
-}
147 console/index.html
View
@@ -1,147 +0,0 @@
-<!doctype html>
-<html>
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <meta name="viewport"
- content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
- <meta name="keywords"
- content="javascript, facebook, connect, library, share, publish, stream, api, json, fql">
- <meta name="description"
- content="JavaScript library to use Facebook Connect on your site.">
- <title>Connect JavaScript - Console</title>
- <link type="text/css" rel="stylesheet" href="console.css">
- </head>
- <body>
- <div id="sidebar">
- <ul>
- <li><a href="/">Home</a></li>
- <li>
- JavaScript library to use Facebook Connect on your site.
- </li>
- <li>
- The source code is hosted on
- <a href="http://github.com/facebook/connect-js">GitHub</a>.
- </li>
- </ul>
- </div>
-
- <h1>Mμ Connect &mdash; Console</h1>
-
- <div id="controls">
- <div id="connect">
- <h2>Connect</h2>
-
- <input type="button"
- value="Status"
- onclick="FB.getLoginStatus(null, true)">
- <input type="button"
- value="Login"
- onclick="FB.login()"
- id="bt-login"
- disabled="disabled">
- <input type="button"
- value="Disconnect"
- onclick="FB.api({ method: 'Auth.revokeAuthorization' })"
- id="bt-disconnect"
- disabled="disabled">
- <input type="button"
- value="Logout"
- onclick="FB.logout()"
- id="bt-logout"
- disabled="disabled">
- </div>
-
- <div id="connected">
- <div id="permissions">
- <h2>Permissions <span class="info" id="perms-info"></span></h2>
-
- <input type="button"
- value="Read Stream"
- onclick="FB.login(gotPerms, {perms:'read_stream'})">
- <input type="button"
- value="Publish Stream"
- onclick="FB.login(gotPerms, {perms: 'publish_stream'})">
- <input type="button"
- value="Full Stream"
- onclick="FB.login(gotPerms, {perms: 'read_stream,publish_stream'})">
- <input type="button"
- value="Offline Access"
- onclick="FB.login(gotPerms, {perms: 'offline_access'})">
- <input type="button"
- value="Events"
- onclick="FB.login(gotPerms, {perms: 'create_event,rsvp_event'})">
- <input type="button"
- value="SMS"
- onclick="FB.login(gotPerms, {perms: 'sms'})">
- <input type="button"
- value="Bulk"
- onclick="FB.login(gotPerms, {perms: 'read_stream,offline_access,sms,create_event,rsvp_event'})">
- </div>
-
- <div id="integration">
- <h2>Integration <span class="info" id="integration-info"></span></h2>
-
- <input type="button"
- disabled="disabled"
- value="Add Friend"
- onclick="FB.addFriend('499029861', friendAdded)">
- </div>
- </div>
-
- <div id="sans-session">
- <h2>Sans Session <span class="info" id="sans-session-info"></span></h2>
-
- <input type="button" value="Publish" onclick="publishExample()">
- <input type="button" value="Share" onclick="FB.share()">
- </div>
- </div>
-
- <div>
- Status
- <span id="status"></span>
-
- <a id="user-info" style="visibility: hidden;">
- as
- <span id="user-name"></span>
- <img id="user-pic"
- src="http://static.ak.fbcdn.net/pics/t_silhouette.jpg"
- alt="User Picture">
- </a>
- </div>
- <div id="info"></div>
-
-
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script src="console.js"></script>
-
- <div id="fb-root"></div>
- <script>
- // monitor for any change
- FB.Event.subscribe('auth.sessionChange', gotStatus);
-
- // init
- FB.init({
- apiKey: '48f06bc570aaf9ed454699ec4fe416df',
- cookie: true
- });
-
- // fetch status from facebook
- FB.getLoginStatus();
- </script>
- </body>
-</html>
84 examples/dojo/login.html
View
@@ -1,84 +0,0 @@
-<!doctype html>
-<html xmlns:fb="http://www.facebook.com/2008/fbml">
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Connect JavaScript - Dojo Login Example</title>
- </head>
- <body>
- <h1>Connect JavaScript - Dojo Login Example</h1>
- <div>
- <button id="login">Login</button>
- <button id="logout">Logout</button>
- <button id="disconnect">Disconnect</button>
- </div>
- <div id="user-info"></div>
-
- <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.3.2/dojo/dojo.xd.js"></script>
-
- <div id="fb-root"></div>
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script>
- // initialize the library with the API key
- FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' });
-
- // fetch the status on load
- FB.getLoginStatus(handleSessionResponse);
-
- dojo.connect(dojo.byId('login'), 'click', function() {
- FB.login(handleSessionResponse);
- });
-
- dojo.connect(dojo.byId('logout'), 'click', function() {
- FB.logout(handleSessionResponse);
- });
-
- dojo.connect(dojo.byId('disconnect'), 'click', function() {
- FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
- clearDisplay();
- });
- });
-
- // no user, clear display
- function clearDisplay() {
- document.getElementById('user-info').innerHTML = '';
- }
-
- // handle a session response from any of the auth related calls
- function handleSessionResponse(response) {
- // if we dont have a session, just hide the user info
- if (!response.session) {
- clearDisplay();
- return;
- }
-
- // if we have a session, query for the user's profile picture and name
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
- },
- function(response) {
- var user = response[0];
- var userInfo = document.getElementById('user-info');
- userInfo.innerHTML = '<img src="' + user.pic + '">' + user.name;
- }
- );
- }
- </script>
- </body>
-</html>
83 examples/jquery/login.html
View
@@ -1,83 +0,0 @@
-<!doctype html>
-<html xmlns:fb="http://www.facebook.com/2008/fbml">
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Connect JavaScript - jQuery Login Example</title>
- </head>
- <body>
- <h1>Connect JavaScript - jQuery Login Example</h1>
- <div>
- <button id="login">Login</button>
- <button id="logout">Logout</button>
- <button id="disconnect">Disconnect</button>
- </div>
- <div id="user-info" style="display: none;"></div>
-
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
-
- <div id="fb-root"></div>
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script>
- // initialize the library with the API key
- FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' });
-
- // fetch the status on load
- FB.getLoginStatus(handleSessionResponse);
-
- $('#login').bind('click', function() {
- FB.login(handleSessionResponse);
- });
-
- $('#logout').bind('click', function() {
- FB.logout(handleSessionResponse);
- });
-
- $('#disconnect').bind('click', function() {
- FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
- clearDisplay();
- });
- });
-
- // no user, clear display
- function clearDisplay() {
- $('#user-info').hide('fast');
- }
-
- // handle a session response from any of the auth related calls
- function handleSessionResponse(response) {
- // if we dont have a session, just hide the user info
- if (!response.session) {
- clearDisplay();
- return;
- }
-
- // if we have a session, query for the user's profile picture and name
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
- },
- function(response) {
- var user = response[0];
- $('#user-info').html('<img src="' + user.pic + '">' + user.name).show('fast');
- }
- );
- }
- </script>
- </body>
-</html>
84 examples/mootools/login.html
View
@@ -1,84 +0,0 @@
-<!doctype html>
-<html xmlns:fb="http://www.facebook.com/2008/fbml">
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Connect JavaScript - MooTools Login Example</title>
- </head>
- <body>
- <h1>Connect JavaScript - MooTools Login Example</h1>
- <div>
- <button id="login">Login</button>
- <button id="logout">Logout</button>
- <button id="disconnect">Disconnect</button>
- </div>
- <div id="user-info"></div>
-
- <script src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.3/mootools-yui-compressed.js"></script>
-
- <div id="fb-root"></div>
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script>
- // initialize the library with the API key
- FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' });
-
- // fetch the status on load
- FB.getLoginStatus(handleSessionResponse);
-
- $('login').addEvent('click', function() {
- FB.login(handleSessionResponse);
- });
-
- $('logout').addEvent('click', function() {
- FB.logout(handleSessionResponse);
- });
-
- $('disconnect').addEvent('click', function() {
- FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
- clearDisplay();
- });
- });
-
- // no user, clear display
- function clearDisplay() {
- document.getElementById('user-info').innerHTML = '';
- }
-
- // handle a session response from any of the auth related calls
- function handleSessionResponse(response) {
- // if we dont have a session, just hide the user info
- if (!response.session) {
- clearDisplay();
- return;
- }
-
- // if we have a session, query for the user's profile picture and name
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
- },
- function(response) {
- var user = response[0];
- var userInfo = document.getElementById('user-info');
- userInfo.innerHTML = '<img src="' + user.pic + '">' + user.name;
- }
- );
- }
- </script>
- </body>
-</html>
84 examples/prototype/login.html
View
@@ -1,84 +0,0 @@
-<!doctype html>
-<html xmlns:fb="http://www.facebook.com/2008/fbml">
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Connect JavaScript - Prototype Login Example</title>
- </head>
- <body>
- <h1>Connect JavaScript - Prototype Login Example</h1>
- <div>
- <button id="login">Login</button>
- <button id="logout">Logout</button>
- <button id="disconnect">Disconnect</button>
- </div>
- <div id="user-info"></div>
-
- <script src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.1.0/prototype.js"></script>
-
- <div id="fb-root"></div>
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script>
- // initialize the library with the API key
- FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' });
-
- // fetch the status on load
- FB.getLoginStatus(handleSessionResponse);
-
- $('login').observe('click', function() {
- FB.login(handleSessionResponse);
- });
-
- $('logout').observe('click', function() {
- FB.logout(handleSessionResponse);
- });
-
- $('disconnect').observe('click', function() {
- FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
- clearDisplay();
- });
- });
-
- // no user, clear display
- function clearDisplay() {
- document.getElementById('user-info').innerHTML = '';
- }
-
- // handle a session response from any of the auth related calls
- function handleSessionResponse(response) {
- // if we dont have a session, just hide the user info
- if (!response.session) {
- clearDisplay();
- return;
- }
-
- // if we have a session, query for the user's profile picture and name
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
- },
- function(response) {
- var user = response[0];
- var userInfo = document.getElementById('user-info');
- userInfo.innerHTML = '<img src="' + user.pic + '">' + user.name;
- }
- );
- }
- </script>
- </body>
-</html>
84 examples/yui2/login.html
View
@@ -1,84 +0,0 @@
-<!doctype html>
-<html xmlns:fb="http://www.facebook.com/2008/fbml">
- <!--
- Copyright Facebook Inc.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
- <head>
- <meta http-equiv="content-type" content="text/html; charset=utf-8">
- <title>Connect JavaScript - YUI Login Example</title>
- </head>
- <body>
- <h1>Connect JavaScript - YUI Login Example</h1>
- <div>
- <button id="login">Login</button>
- <button id="logout">Logout</button>
- <button id="disconnect">Disconnect</button>
- </div>
- <div id="user-info"></div>
-
- <script src="http://yui.yahooapis.com/combo?2.7.0/build/yahoo/yahoo-min.js&2.7.0/build/event/event-min.js"></script>
-
- <div id="fb-root"></div>
- <script src="http://connect.facebook.net/en_US/all.js"></script>
- <script>
- // initialize the library with the API key
- FB.init({ apiKey: '48f06bc570aaf9ed454699ec4fe416df' });
-
- // fetch the status on load
- FB.getLoginStatus(handleSessionResponse);
-
- YAHOO.util.Event.addListener('login', 'click', function() {
- FB.login(handleSessionResponse);
- });
-
- YAHOO.util.Event.addListener('logout', 'click', function() {
- FB.logout(handleSessionResponse);
- });
-
- YAHOO.util.Event.addListener('disconnect', 'click', function() {
- FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
- clearDisplay();
- });
- });
-
- // no user, clear display
- function clearDisplay() {
- document.getElementById('user-info').innerHTML = '';
- }
-
- // handle a session response from any of the auth related calls
- function handleSessionResponse(response) {
- // if we dont have a session, just hide the user info
- if (!response.session) {
- clearDisplay();
- return;
- }
-
- // if we have a session, query for the user's profile picture and name
- FB.api(
- {
- method: 'fql.query',
- query: 'SELECT name, pic FROM profile WHERE id=' + FB.getSession().uid
- },
- function(response) {
- var user = response[0];
- var userInfo = document.getElementById('user-info');
- userInfo.innerHTML = '<img src="' + user.pic + '">' + user.name;
- }
- );
- }
- </script>
- </body>
-</html>
1  readme.md
View
@@ -8,6 +8,7 @@ representing http://connect.facebook.net/en_US/all.js, but will for now remain i
Please submit any issues using the Bug reporting tool at https://developers.facebook.com/bugs.
+To see the repository in its previously published state, please see the [deprecated](https://github.com/facebook/facebook-js-sdk/tree/deprecated) branch.
--------
--------
128 src/common/anim.js
View
@@ -1,128 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.anim
- * @layer basic
- * @requires fb.prelude fb.array fb.dom
- */
-
-/**
- * This provides helper methods related to basic animation.
- *
- * @class FB.Anim
- * @static
- * @private
- */
-FB.provide('Anim', {
- /**
- * Animate Transformable Element
- *
- * Note: only pixel, point, %, and opactity values are animate-able
- *
- * @param dom {DOMElement} the element to be animated
- * @param props {Object} an object with the properties of the animation
- * destination
- * @param duration {Number} the number of milliseconds over which the
- * animation should happen.
- * @param callback {Function} the callback function to call after the
- * animation is complete
- */
- ate: function(dom, props, duration, callback) {
- duration = !isNaN(parseFloat(duration)) && duration >= 0 ? duration : 750;
- var
- frame_speed = 40,
- from = {},
- to = {},
- begin = null,
- s = dom.style,
- timer = setInterval(FB.bind(function() {
- if (!begin) { begin = new Date().getTime(); }
- // percent done
- var pd = 1;
- if (duration != 0) {
- pd = Math.min((new Date().getTime() - begin) / duration, 1);
- }
- FB.Array.forEach(props, FB.bind(function(value, prop) {
- if (!from[prop]) { // parse from CSS
- var style = FB.Dom.getStyle(dom, prop);
- // check for can't animate this, bad prop for this browser
- if (!style) { return; }
- from[prop] = this._parseCSS(style);
- }
- if (!to[prop]) { // parse to CSS
- to[prop] = this._parseCSS(value.toString());
- }
- var next = ''; // the next value to set
- FB.Array.forEach(from[prop], function(pair, i) {
- /* check for user overide not animating this part via special symbol
- * , "?". This is best used for animating properties with multiple
- * parts, such as backgroundPositon, where you only want to animate
- * one part and not the other.
- *
- * e.g.
- * backgroundPosition: '8px 10px' => moves x and y to 8, 10
- * backgroundPosition: '? 4px' => moves y to 4 and leaves x alone
- * backgroundPosition: '7px ?' => moves x to 7 and leaves y alone
- */
- if (isNaN(to[prop][i].numPart) && to[prop][i].textPart == '?') {
- next = pair.numPart + pair.textPart;
- /* check for a non animate-able part
- * this includes colors (for now), positions, anything with out a #,
- * etc.
- */
- } else if (isNaN(pair.numPart)) {
- next = pair.textPart;
- // yay it's animate-able!
- } else {
- next +=
- (pair.numPart + // orig value
- Math.ceil((to[prop][i].numPart - pair.numPart) *
- Math.sin(Math.PI/2 * pd))) +
- to[prop][i].textPart + ' '; // text part and trailing space
- }
- });
- // update with new value
- FB.Dom.setStyle(dom, prop, next);
- }, this));
- if (pd == 1) { // are we done? clear the timer, call the callback
- clearInterval(timer);
- if (callback) { callback(dom); }
- }
- }, this), frame_speed);
- },
-
- /*
- * Parses a CSS statment into it's parts
- *
- * e.g. "1px solid black" =>
- * [[numPart: 1, textPart: 'px'],
- * [numPart: NaN, textPart: 'solid'],
- * [numPart: NaN, textPart: 'black']]
- * or
- * "5px 0% 2em none" =>
- * [[numPart: 5, textPart: 'px'],
- * [numPart: 0, textPart: '%'],
- * [numPart: 2, textPart: 'em'],
- * [numPart: NaN, textPart: 'none']]
- */
- _parseCSS: function(css) {
- var ret = [];
- FB.Array.forEach(css.split(' '), function(peice) {
- var num = parseInt(peice, 10);
- ret.push({numPart: num, textPart: peice.replace(num,'')});
- });
- return ret;
- }
-});
152 src/common/array.js
View
@@ -1,152 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.array
- * @layer basic
- * @requires fb.prelude
- */
-
-/**
- * Array related helper methods.
- *
- * @class FB.Array
- * @private
- * @static
- */
-FB.provide('Array', {
- /**
- * Get index of item inside an array. Return's -1 if element is not found.
- *
- * @param arr {Array} Array to look through.
- * @param item {Object} Item to locate.
- * @return {Number} Index of item.
- */
- indexOf: function (arr, item) {
- if (arr.indexOf) {
- return arr.indexOf(item);
- }
- var length = arr.length;
- if (length) {
- for (var index = 0; index < length; index++) {
- if (arr[index] === item) {
- return index;
- }
- }
- }
- return -1;
- },
-
- /**
- * Merge items from source into target, but only if they dont exist. Returns
- * the target array back.
- *
- * @param target {Array} Target array.
- * @param source {Array} Source array.
- * @return {Array} Merged array.
- */
- merge: function(target, source) {
- for (var i=0; i < source.length; i++) {
- if (FB.Array.indexOf(target, source[i]) < 0) {
- target.push(source[i]);
- }
- }
- return target;
- },
-
- /**
- * Create an new array from the given array and a filter function.
- *
- * @param arr {Array} Source array.
- * @param fn {Function} Filter callback function.
- * @return {Array} Filtered array.
- */
- filter: function(arr, fn) {
- var b = [];
- for (var i=0; i < arr.length; i++) {
- if (fn(arr[i])) {
- b.push(arr[i]);
- }
- }
- return b;
- },
-
- /**
- * Create an array from the keys in an object.
- *
- * Example: keys({'x': 2, 'y': 3'}) returns ['x', 'y']
- *
- * @param obj {Object} Source object.
- * @param proto {Boolean} Specify true to include inherited properties.
- * @return {Array} The array of keys.
- */
- keys: function(obj, proto) {
- var arr = [];
- for (var key in obj) {
- if (proto || obj.hasOwnProperty(key)) {
- arr.push(key);
- }
- }
- return arr;
- },
-
- /**
- * Create an array by performing transformation on the items in a source
- * array.
- *
- * @param arr {Array} Source array.
- * @param transform {Function} Transformation function.
- * @return {Array} The transformed array.
- */
- map: function(arr, transform) {
- var ret = [];
- for (var i=0; i < arr.length; i++) {
- ret.push(transform(arr[i]));
- }
- return ret;
- },
-
- /**
- * For looping through Arrays and Objects.
- *
- * @param {Object} item an Array or an Object
- * @param {Function} fn the callback function for iteration.
- * The function will be pass (value, [index/key], item) paramters
- * @param {Bool} proto indicate if properties from the prototype should
- * be included
- *
- */
- forEach: function(item, fn, proto) {
- if (!item) {
- return;
- }
-
- if (Object.prototype.toString.apply(item) === '[object Array]' ||
- (!(item instanceof Function) && typeof item.length == 'number')) {
- if (item.forEach) {
- item.forEach(fn);
- } else {
- for (var i=0, l=item.length; i<l; i++) {
- fn(item[i], i, item);
- }
- }
- } else {
- for (var key in item) {
- if (proto || item.hasOwnProperty(key)) {
- fn(item[key], key, item);
- }
- }
- }
- }
-});
300 src/common/dom.js
View
@@ -1,300 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.dom
- * @layer basic
- * @requires fb.prelude
- * fb.event
- * fb.string
- * fb.array
- */
-
-/**
- * This provides helper methods related to DOM.
- *
- * @class FB.Dom
- * @static
- * @private
- */
-FB.provide('Dom', {
- /**
- * Check if the element contains a class name.
- *
- * @param dom {DOMElement} the element
- * @param className {String} the class name
- * @return {Boolean}
- */
- containsCss: function(dom, className) {
- var cssClassWithSpace = ' ' + dom.className + ' ';
- return cssClassWithSpace.indexOf(' ' + className + ' ') >= 0;
- },
-
- /**
- * Add a class to a element.
- *
- * @param dom {DOMElement} the element
- * @param className {String} the class name
- */
- addCss: function(dom, className) {
- if (!FB.Dom.containsCss(dom, className)) {
- dom.className = dom.className + ' ' + className;
- }
- },
-
- /**
- * Remove a class from the element.
- *
- * @param dom {DOMElement} the element
- * @param className {String} the class name
- */
- removeCss: function(dom, className) {
- if (FB.Dom.containsCss(dom, className)) {
- dom.className = dom.className.replace(className, '');
- FB.Dom.removeCss(dom, className); // in case of repetition
- }
- },
-
- /**
- * Returns the computed style for the element
- *
- * note: requires browser specific names to be passed for specials
- * border-radius -> ('-moz-border-radius', 'border-radius')
- *
- * @param dom {DOMElement} the element
- * @param styleProp {String} the property name
- */
- getStyle: function (dom, styleProp) {
- var y = false, s = dom.style;
- if (styleProp == 'opacity') {
- if (s.opacity) { return s.opacity * 100; }
- if (s.MozOpacity) { return s.MozOpacity * 100; }
- if (s.KhtmlOpacity) { return s.KhtmlOpacity * 100; }
- if (s.filters) { return s.filters.alpha.opacity; }
- return 0; // TODO(alpjor) fix default opacity
- } else {
- if (dom.currentStyle) { // camelCase (e.g. 'marginTop')
- FB.Array.forEach(styleProp.match(/\-([a-z])/g), function(match) {
- styleProp = styleProp.replace(match, match.substr(1,1).toUpperCase());
- });
- y = dom.currentStyle[styleProp];
- } else { // dashes (e.g. 'margin-top')
- FB.Array.forEach(styleProp.match(/[A-Z]/g), function(match) {
- styleProp = styleProp.replace(match, '-'+ match.toLowerCase());
- });
- if (window.getComputedStyle) {
- y = document.defaultView
- .getComputedStyle(dom,null).getPropertyValue(styleProp);
- // special handling for IE
- // for some reason it doesn't return '0%' for defaults. so needed to
- // translate 'top' and 'left' into '0px'
- if (styleProp == 'background-position-y' ||
- styleProp == 'background-position-x') {
- if (y == 'top' || y == 'left') { y = '0px'; }
- }
- }
- }
- }
- return y;
- },
-
- /**
- * Sets the style for the element to value
- *
- * note: requires browser specific names to be passed for specials
- * border-radius -> ('-moz-border-radius', 'border-radius')
- *
- * @param dom {DOMElement} the element
- * @param styleProp {String} the property name
- * @param value {String} the css value to set this property to
- */
- setStyle: function(dom, styleProp, value) {
- var s = dom.style;
- if (styleProp == 'opacity') {
- if (value >= 100) { value = 99.999; } // fix for Mozilla < 1.5b2
- if (value < 0) { value = 0; }
- s.opacity = value/100;
- s.MozOpacity = value/100;
- s.KhtmlOpacity = value/100;
- if (s.filters) { s.filters.alpha.opacity = value; }
- } else { s[styleProp] = value; }
- },
-
- /**
- * Dynamically add a script tag.
- *
- * @param src {String} the url for the script
- */
- addScript: function(src) {
- var script = document.createElement('script');
- script.type = "text/javascript";
- script.src = src;
- return document.getElementsByTagName('HEAD')[0].appendChild(script);
- },
-
- /**
- * Add CSS rules using a <style> tag.
- *
- * @param styles {String} the styles
- * @param names {Array} the component names that the styles represent
- */
- addCssRules: function(styles, names) {
- if (!FB.Dom._cssRules) {
- FB.Dom._cssRules = {};
- }
-
- // note, we potentially re-include CSS if it comes with other CSS that we
- // have previously not included.
- var allIncluded = true;
- FB.Array.forEach(names, function(id) {
- if (!(id in FB.Dom._cssRules)) {
- allIncluded = false;
- FB.Dom._cssRules[id] = true;
- }
- });
-
- if (allIncluded) {
- return;
- }
-
-//#JSCOVERAGE_IF
- if (FB.Dom.getBrowserType() != 'ie') {
- var style = document.createElement('style');
- style.type = 'text/css';
- style.textContent = styles;
- document.getElementsByTagName('HEAD')[0].appendChild(style);
- } else {
- try {
- document.createStyleSheet().cssText = styles;
- } catch (exc) {
- // major problem on IE : You can only create 31 stylesheet objects with
- // this method. We will have to add the styles into an existing
- // stylesheet.
- if (document.styleSheets[0]) {
- document.styleSheets[0].cssText += styles;
- }
- }
- }
- },
-
- /**
- * Get browser type.
- *
- * @return string 'ie' | 'mozilla' |'safari' | 'other'
- */
- getBrowserType: function() {
- if (!FB.Dom._browserType) {
- var
- userAgent = window.navigator.userAgent.toLowerCase(),
- // list of known browser. NOTE: the order is important
- keys = ['msie', 'firefox', 'safari', 'gecko'],
- names = ['ie', 'mozilla', 'safari', 'mozilla'];
- for (var i = 0; i < keys.length; i++) {
- if (userAgent.indexOf(keys[i]) >= 0) {
- FB.Dom._browserType = names[i];
- break;
- }
- }
- }
- return FB.Dom._browserType;
- },
-
- /**
- * Get the viewport info. Contains size and scroll offsets.
- *
- * @returns {Object} with the width and height
- */
- getViewportInfo: function() {
- // W3C compliant, or fallback to body
- var root = (document.documentElement && document.compatMode == 'CSS1Compat')
- ? document.documentElement
- : document.body;
- return {
- scrollTop : root.scrollTop,
- scrollLeft : root.scrollLeft,
- width : self.innerWidth ? self.innerWidth : root.clientWidth,
- height : self.innerHeight ? self.innerHeight : root.clientHeight
- };
- },
-
- /**
- * Bind a function to be executed when the DOM is ready. It will be executed
- * immediately if the DOM is already ready.
- *
- * @param {Function} the function to invoke when ready
- */
- ready: function(fn) {
- if (FB.Dom._isReady) {
- fn();
- } else {
- FB.Event.subscribe('dom.ready', fn);
- }
- }
-});
-
-// NOTE: This code is self-executing. This is necessary in order to correctly
-// determine the ready status.
-(function() {
- // Handle when the DOM is ready
- function domReady() {
- FB.Dom._isReady = true;
- FB.Event.fire('dom.ready');
- FB.Event.clear('dom.ready');
- }
-
- // In case we're already ready.
- if (FB.Dom._isReady || document.readyState == 'complete') {
- return domReady();
- }
-
- // Good citizens.
- if (document.addEventListener) {
- document.addEventListener('DOMContentLoaded', domReady, false);
- // Bad citizens.
- } else if (document.attachEvent) {
- document.attachEvent('onreadystatechange', domReady);
- }
-
- // Bad citizens.
- // If IE is used and page is not in a frame, continuously check to see if
- // the document is ready
- if (FB.Dom.getBrowserType() == 'ie' && window === top) {
- (function() {
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll('left');
- } catch(error) {
- setTimeout(arguments.callee, 0);
- return;
- }
-
- // and execute any waiting functions
- domReady();
- })();
- }
-
- // Ultimate Fallback.
- var oldonload = window.onload;
- window.onload = function() {
- domReady();
- if (oldonload) {
- if (typeof oldonload == 'string') {
- eval(oldonload);
- } else {
- oldonload();
- }
- }
- };
-})();
46 src/common/obj.js
View
@@ -1,46 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.obj
- * @requires fb.type
- * fb.json
- * fb.event
- */
-
-/**
- * Base object type that support events.
- *
- * @class FB.Obj
- * @private
- */
-FB.Class('Obj', null,
- FB.copy({
- /**
- * Set property on an object and fire property changed event if changed.
- *
- * @param {String} Property name. A event with the same name
- * will be fire when the property is changed.
- * @param {Object} new value of the property
- * @private
- */
- setProperty: function(name, value) {
- // Check if property actually changed
- if (FB.JSON.stringify(value) != FB.JSON.stringify(this[name])) {
- this[name] = value;
- this.fire(name, value);
- }
- }
- }, FB.EventProvider)
-);
110 src/common/string.js
View
@@ -1,110 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.string
- * @layer basic
- * @requires fb.prelude
- *
- */
-
-/**
- * Utility function related to Strings.
- *
- * @class FB.String
- * @static
- * @private
- */
-FB.provide('String', {
- /**
- * Strip leading and trailing whitespace.
- *
- * @param s {String} the string to trim
- * @returns {String} the trimmed string
- */
- trim: function(s) {
- return s.replace(/^\s*|\s*$/g, '');
- },
-
- /**
- * Format a string.
- *
- * Example:
- * FB.String.format('{0}.facebook.com/{1}', 'www', 'login.php')
- * Returns:
- * 'www.facebook.com/login.php'
- *
- * Example:
- * FB.String.format('foo {0}, {1}, {0}', 'x', 'y')
- * Returns:
- * 'foo x, y, x'
- *
- * @static
- * @param format {String} the format specifier
- * @param arguments {...} placeholder arguments
- * @returns {String} the formatted string
- */
- format: function(format) {
- if (!FB.String.format._formatRE) {
- FB.String.format._formatRE = /(\{[^\}^\{]+\})/g;
- }
-
- var values = arguments;
-
- return format.replace(
- FB.String.format._formatRE,
- function(str, m) {
- var
- index = parseInt(m.substr(1), 10),
- value = values[index + 1];
- if (value === null || value === undefined) {
- return '';
- }
- return value.toString();
- }
- );
- },
-
- /**
- * Escape an string so that it can be embedded inside another string
- * as quoted string.
- *
- * @param value {String} string to quote
- * @return {String} an quoted string
- */
- quote: function(value) {
- var
- quotes = /["\\\x00-\x1f\x7f-\x9f]/g,
- subst = { // table of character substitutions
- '\b': '\\b',
- '\t': '\\t',
- '\n': '\\n',
- '\f': '\\f',
- '\r': '\\r',
- '"' : '\\"',
- '\\': '\\\\'
- };
-
- return quotes.test(value) ?
- '"' + value.replace(quotes, function (a) {
- var c = subst[a];
- if (c) {
- return c;
- }
- c = a.charCodeAt();
- return '\\u00' + Math.floor(c/16).toString(16) + (c % 16).toString(16);
- }) + '"' :
- '"' + value + '"';
- }
-});
142 src/common/type.js
View
@@ -1,142 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.type
- * @layer basic
- * @requires fb.prelude
- */
-
-// Provide Class/Type support.
-// TODO: As a temporary hack, this docblock is written as if it describes the
-// top level FB namespace. This is necessary because the current documentation
-// parser uses the description from this file for some reason.
-/**
- * The top level namespace exposed by the SDK. Look at the [readme on
- * **GitHub**][readme] for more information.
- *
- * [readme]: http://github.com/facebook/connect-js
- *
- * @class FB
- * @static
- */
-FB.provide('', {
- /**
- * Bind a function to a given context and arguments.
- *
- * @static
- * @access private
- * @param fn {Function} the function to bind
- * @param context {Object} object used as context for function execution
- * @param {...} arguments additional arguments to be bound to the function
- * @returns {Function} the bound function
- */
- bind: function() {
- var
- args = Array.prototype.slice.call(arguments),
- fn = args.shift(),
- context = args.shift();
- return function() {
- return fn.apply(
- context,
- args.concat(Array.prototype.slice.call(arguments))
- );
- };
- },
-
- /**
- * Create a new class.
- *
- * Note: I have to use 'Class' instead of 'class' because 'class' is
- * a reserved (but unused) keyword.
- *
- * @access private
- * @param name {string} class name
- * @param constructor {function} class constructor
- * @param proto {object} instance methods for class
- */
- Class: function(name, constructor, proto) {
- if (FB.CLASSES[name]) {
- return FB.CLASSES[name];
- }
-
- var newClass = constructor || function() {};
-
- newClass.prototype = proto;
- newClass.prototype.bind = function(fn) {
- return FB.bind(fn, this);
- };
-
- newClass.prototype.constructor = newClass;
- FB.create(name, newClass);
- FB.CLASSES[name] = newClass;
- return newClass;
- },
-
- /**
- * Create a subclass
- *
- * Note: To call base class constructor, use this._base(...).
- * If you override a method 'foo' but still want to call
- * the base class's method 'foo', use this._callBase('foo', ...)
- *
- * @access private
- * @param {string} name class name
- * @param {string} baseName,
- * @param {function} constructor class constructor
- * @param {object} proto instance methods for class
- */
- subclass: function(name, baseName, constructor, proto) {
- if (FB.CLASSES[name]) {
- return FB.CLASSES[name];
- }
- var base = FB.create(baseName);
- FB.copy(proto, base.prototype);
- proto._base = base;
- proto._callBase = function(method) {
- var args = Array.prototype.slice.call(arguments, 1);
- return base.prototype[method].apply(this, args);
- };
-
- return FB.Class(
- name,
- constructor ? constructor : function() {
- if (base.apply) {
- base.apply(this, arguments);
- }
- },
- proto
- );
- },
-
- CLASSES: {}
-});
-
-/**
- * @class FB.Type
- * @static
- * @private
- */
-FB.provide('Type', {
- isType: function(obj, type) {
- while (obj) {
- if (obj.constructor === type || obj === type) {
- return true;
- } else {
- obj = obj._base;
- }
- }
- return false;
- }
-});
170 src/compat/ui.js
View
@@ -1,170 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- *
- * @provides fb.compat.ui
- * @requires fb.prelude
- * fb.qs
- * fb.ui
- * fb.json
- */
-
-/**
- * NOTE: You should use FB.ui() instead.
- *
- * UI Calls.
- *
- * @class FB
- * @static
- * @access private
- */
-FB.provide('', {
- /**
- * NOTE: You should use FB.ui() instead.
- *
- * Sharing is the light weight way of distributing your content. As opposed
- * to the structured data explicitly given in the [FB.publish][publish] call,
- * with share you simply provide the URL.
- *
- * FB.share('http://github.com/facebook/connect-js');
- *
- * Calling [FB.share][share] without any arguments will share the current
- * page.
- *
- * This call can be used without requiring the user to sign in.
- *
- * [publish]: /docs/?u=facebook.jslib-alpha.FB.publish
- * [share]: /docs/?u=facebook.jslib-alpha.FB.share
- *
- * @access private
- * @param u {String} the url (defaults to current URL)
- */
- share: function(u) {
- FB.log('FB.share() has been deprecated. Please use FB.ui() instead.');
- FB.ui({
- display : 'popup',
- method : 'stream.share',
- u : u
- });
- },
-
- /**
- * NOTE: You should use FB.ui() instead.
- *
- * Publish a post to the stream.
- *
- * This is the main, fully featured distribution mechanism for you
- * to publish into the user's stream. It can be used, with or
- * without an API key. With an API key you can control the
- * Application Icon and get attribution. You must also do this if
- * you wish to use the callback to get notified of the `post_id`
- * and the `message` the user typed in the published post, or find
- * out if the user did not publish (clicked on the skipped button).
- *
- * Publishing is a powerful feature that allows you to submit rich
- * media and provide a integrated experience with control over your
- * stream post. You can guide the user by choosing the prompt,
- * and/or a default message which they may customize. In addition,
- * you may provide image, video, audio or flash based attachments
- * with along with their metadata. You also get the ability to
- * provide action links which show next to the "Like" and "Comment"
- * actions. All this together provides you full control over your
- * stream post. In addition, if you may also specify a target for
- * the story, such as another user or a page.
- *
- * A post may contain the following properties:
- *
- * Property | Type | Description
- * ------------------- | ------ | --------------------------------------
- * message | String | This allows prepopulating the message.
- * attachment | Object | An [[wiki:Attachment (Streams)]] object.
- * action_links | Array | An array of [[wiki:Action Links]].
- * actor_id | String | A actor profile/page id.
- * target_id | String | A target profile id.
- * user_message_prompt | String | Custom prompt message.
- *
- * The post and all the parameters are optional, so use what is best
- * for your specific case.
- *
- * Example:
- *
- * var post = {
- * message: 'getting educated about Facebook Connect',
- * attachment: {
- * name: 'Facebook Connect JavaScript SDK',
- * description: (
- * 'A JavaScript library that allows you to harness ' +
- * 'the power of Facebook, bringing the user\'s identity, ' +
- * 'social graph and distribution power to your site.'
- * ),
- * href: 'http://github.com/facebook/connect-js'
- * },
- * action_links: [
- * {
- * text: 'GitHub Repo',
- * href: 'http://github.com/facebook/connect-js'
- * }
- * ],
- * user_message_prompt: 'Share your thoughts about Facebook Connect'
- * };
- *
- * FB.publish(
- * post,
- * function(published_post) {
- * if (published_post) {
- * alert(
- * 'The post was successfully published. ' +
- * 'Post ID: ' + published_post.post_id +
- * '. Message: ' + published_post.message
- * );
- * } else {
- * alert('The post was not published.');
- * }
- * }
- * );
- *
- * @access private
- * @param post {Object} the post object
- * @param cb {Function} called with the result of the action
- */
- publish: function(post, cb) {
- FB.log('FB.publish() has been deprecated. Please use FB.ui() instead.');
- post = post || {};
- FB.ui(FB.copy({
- display : 'popup',
- method : 'stream.publish',
- preview : 1
- }, post || {}), cb);
- },
-
- /**
- * NOTE: You should use FB.ui() instead.
- *
- * Prompt the user to add the given id as a friend.
- *
- * @access private
- * @param id {String} the id of the target user
- * @param cb {Function} called with the result of the action
- */
- addFriend: function(id, cb) {
- FB.log('FB.addFriend() has been deprecated. Please use FB.ui() instead.');
- FB.ui({
- display : 'popup',
- id : id,
- method : 'friend.add'
- }, cb);
- }
-});
59 src/compat/xfbml.js
View
@@ -1,59 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- * @provides fb.compat.xfbml
- * @requires fb.prelude
- * fb.xfbml
- */
-
-/**
- * Methods for the rendering of [[wiki:XFBML]] tags.
- *
- * To render the tags, simply put the tags anywhere in your page, and then
- * call:
- *
- * FB.XFBML.parse();
- *
- * @class FB.XFBML
- * @static
- */
-FB.provide('XFBML', {
- /**
- * NOTE: This method is deprecated. You should instead set the innerHTML
- * yourself and call FB.XFBML.parse() on the DOMElement after.
- *
- * Dynamically set XFBML markup on a given DOM element. Use this
- * method if you want to set XFBML after the page has already loaded
- * (for example, in response to an Ajax request or API call).
- *
- * Example:
- * --------
- * Set the innerHTML of a dom element with id "container"
- * to some markup (fb:name + regular HTML) and render it
- *
- * FB.XFBML.set(FB.$('container'),
- * '<fb:name uid="4"></fb:name><div>Hello</div>');
- *
- * @access private
- * @param {DOMElement} dom DOM element
- * @param {String} markup XFBML markup. It may contain reguarl
- * HTML markup as well.
- */
- set: function(dom, markup, cb) {
- FB.log('FB.XFBML.set() has been deprecated.');
- dom.innerHTML = markup;
- FB.XFBML.parse(dom, cb);
- }
-});
388 src/core/api.js
View
@@ -1,388 +0,0 @@
-/**
- * Copyright Facebook Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- *
- *
- * Contains the public method ``FB.api`` and the internal implementation
- * ``FB.ApiServer``.
- *
- * @provides fb.api
- * @requires fb.prelude
- * fb.qs
- * fb.flash
- * fb.json
- */
-
-/**
- * API calls.
- *
- * @class FB
- * @static
- * @access private
- */
-FB.provide('', {
- /**
- * Make a API call to the [Graph API](/docs/api).
- *
- * Server-side calls are available via the JavaScript SDK that allow you to
- * build rich applications that can make API calls against the Facebook
- * servers directly from the user's browser. This can improve performance in
- * many scenarios, as compared to making all calls from your server. It can
- * also help reduce, or eliminate the need to proxy the requests thru your
- * own servers, freeing them to do other things.
- *
- * The range of APIs available covers virtually all facets of Facebook.
- * Public data such as [names][names] and [profile pictures][profilepic] are
- * available if you know the id of the user or object. Various parts of the
- * API are available depending on the [connect status and the
- * permissions](FB.login) the user has granted your application.
- *
- * Except the path, all arguments to this function are optional.
- *
- * Get the **f8 Page Object**:
- *
- * FB.api('/f8', function(response) {
- * alert(response.company_overview);
- * });
- *
- * If you have an [authenticated user](FB.login), get their **User Object**:
- *
- * FB.api('/me', function(response) {
- * alert(response.name);
- * });
- *
- * Get the 3 most recent **Post Objects** *Connected* to (in other words,
- * authored by) the *f8 Page Object*:
- *
- * FB.api('/f8/posts', { limit: 3 }, function(response) {
- * for (var i=0, l=response.length; i<l; i++) {
- * var post = response[i];
- * if (post.message) {
- * alert('Message: ' + post.message);
- * } else if (post.attachment && post.attachment.name) {
- * alert('Attachment: ' + post.attachment.name);
- * }
- * }
- * });
- *
- * If you have an [authenticated user](FB.login) with the
- * [publish_stream](/docs/authentication/permissions) permission, and want
- * to publish a new story to their feed:
- *
- * var body = 'Reading Connect JS documentation';
- * FB.api('/me/feed', 'post', { body: body }, function(response) {
- * if (!response || response.error) {
- * alert('Error occured');
- * } else {
- * alert('Post ID: ' + response);
- * }
- * });
- *
- * Or if you want a delete a previously published post:
- *
- * var postId = '1234567890';
- * FB.api(postId, 'delete', function(response) {
- * if (!response || response.error) {
- * alert('Error occured');
- * } else {
- * alert('Post was deleted');
- * }
- * });
- *
- *
- * ### Old REST API calls
- *
- * This method can also be used to invoke calls to the
- * [Old REST API](../rest/). The function signature for invoking REST API
- * calls is:
- *
- * FB.api(params, callback)
- *
- * For example, to invoke [links.getStats](../rest/links.getStats):
- *
- * FB.api(
- * {
- * method: 'links.getStats',
- * urls: 'facebook.com,developers.facebook.com'
- * },
- * function(response) {
- * alert(
- * 'Total: ' + (response[0].total_count + response[1].total_count));
- * }
- * );
- *
- * [names]: https://graph.facebook.com/naitik
- * [profilepic]: https://graph.facebook.com/naitik/picture
- *
- * @access public
- * @param path {String} the url path
- * @param method {String} the http method (default `"GET"`)
- * @param params {Object} the parameters for the query
- * @param cb {Function} the callback function to handle the response
- */
- api: function() {
- if (typeof arguments[0] === 'string') {
- FB.ApiServer.graph.apply(FB.ApiServer, arguments);
- } else {
- FB.ApiServer.rest.apply(FB.ApiServer, arguments);
- }
- }
-});
-
-/**
- * API call implementations.
- *
- * @class FB.ApiServer
- * @access private
- */
-FB.provide('ApiServer', {
- METHODS: ['get', 'post', 'delete', 'put'],
- _callbacks: {},
- _readOnlyCalls: {
- fql_query: true,
- fql_multiquery: true,
- friends_get: true,
- notifications_get: true,
- stream_get: true,
- users_getinfo: true
- },
-
- /**
- * Make a API call to Graph server. This is the **real** RESTful API.
- *
- * Except the path, all arguments to this function are optional. So any of
- * these are valid:
- *
- * FB.api('/me') // throw away the response
- * FB.api('/me', function(r) { console.log(r) })
- * FB.api('/me', { fields: 'email' }); // throw away response
- * FB.api('/me', { fields: 'email' }, function(r) { console.log(r) });
- * FB.api('/12345678', 'delete', function(r) { console.log(r) });
- * FB.api(
- * '/me/feed',
- * 'post',
- * { body: 'hi there' },
- * function(r) { console.log(r) }
- * );
- *
- * @access private
- * @param path {String} the url path
- * @param method {String} the http method
- * @param params {Object} the parameters for the query
- * @param cb {Function} the callback function to handle the response
- */
- graph: function() {
- var
- args = Array.prototype.slice.call(arguments),
- path = args.shift(),
- next = args.shift(),
- method,
- params,
- cb;
-
- while (next) {
- var type = typeof next;
- if (type === 'string' && !method) {
- method = next.toLowerCase();
- } else if (type === 'function' && !cb) {
- cb = next;
- } else if (type === 'object' && !params) {
- params = next;
- } else {
- FB.log('Invalid argument passed to FB.api(): ' + next);
- return;
- }
- next = args.shift();
- }
-
- method = method || 'get';
- params = params || {};
-
- // remove prefix slash if one is given, as it's already in the base url
- if (path[0] === '/') {
- path = path.substr(1);
- }
-
- if (FB.Array.indexOf(FB.ApiServer.METHODS, method) < 0) {
- FB.log('Invalid method passed to FB.api(): ' + method);
- return;
- }
-
- FB.ApiServer.oauthRequest('graph', path, method, params, cb);
- },