]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
trac750 Javascript file for Facebook app
authorZach Copley <zach@controlyourself.ca>
Sun, 18 Jan 2009 06:12:47 +0000 (06:12 +0000)
committerZach Copley <zach@controlyourself.ca>
Sun, 18 Jan 2009 06:12:47 +0000 (06:12 +0000)
actions/facebooksettings.php
js/facebookapp.js [new file with mode: 0644]
lib/facebookaction.php
lib/facebookutil.php

index eafd911236ede7c88a08047292f4db600828f14b..372c40c28c7aa0c6a791e784c4443c894b49763c 100644 (file)
@@ -68,19 +68,18 @@ class FacebooksettingsAction extends FacebookAction
 
         $this->showHeader('Settings', $msg, $success);
 
-        common_element_start('fb:if-section-not-added', array('section' => 'profile'));
-        common_element('h2', null, _('Add an Identi.ca box to my profile'));
+        common_element('form', array('id' => 'redirect_form',
+                                     'style' => 'display: none;'));        
+                
         common_element_start('p');
-        common_element('fb:add-section-button', array('section' => 'profile'));
-        common_element_end('p');
-
-        common_element_end('fb:if-section-not-added');
-        common_element_start('p');
-        common_element_start('fb:prompt-permission', array('perms' => 'status_update'));
+        common_element_start('fb:prompt-permission', array('perms' => 'status_update',
+            'next_fbjs' => 'redirectSettings()'));
         common_element('h2', null, _('Allow Identi.ca to update my Facebook status'));
         common_element_end('fb:prompt-permission');
         common_element_end('p');
 
+
+
         if ($facebook->api_client->users_hasAppPermission('status_update')) {
 
             common_element_start('form', array('method' => 'post',
@@ -94,8 +93,6 @@ class FacebooksettingsAction extends FacebookAction
             common_checkbox('replysync', _('Send local "@" replies to Facebook.'),
                              ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true);
 
-            // function common_input($id, $label, $value=null,$instructions=null)
-
             $prefix = $facebook->api_client->data_getUserPreference(1);
             
 
diff --git a/js/facebookapp.js b/js/facebookapp.js
new file mode 100644 (file)
index 0000000..3f809e5
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Laconica - a distributed open-source microblogging tool
+ * Copyright (C) 2008, Controlez-Vous, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+// Psycho Facebook redirect hack, used because 'document.location'
+// simply does not work in FBJS
+function redirectSettings() {
+    form = document.getElementById('redirect_form');
+    form.setAction('settings.php');
+    form.submit();
+}
index 1bf026281e79af5697d1f5311a62cb28f0d5b1b3..a8f16b34a60a0f3c59d4cf82d4d98ce2413c23d3 100644 (file)
@@ -37,7 +37,11 @@ class FacebookAction extends Action
         
         common_element('link', array('rel' => 'stylesheet',
                                      'type' => 'text/css',
-                                     'href' => get_facebook_css()));
+                                     'href' => getFacebookCSS()));
+
+        common_element('script', array('type' => 'text/javascript',
+                                       'src' => getFacebookJS()),
+                                       ' ');
 
         common_element_start('a', array('class' => 'url home bookmark',
                                             'href' => common_local_url('public')));
@@ -58,6 +62,12 @@ class FacebookAction extends Action
 
         start_fbml();
 
+        common_element_start('fb:if-section-not-added', array('section' => 'profile'));
+        common_element_start('span', array('id' => 'add_to_profile'));
+        common_element('fb:add-section-button', array('section' => 'profile'));
+        common_element_end('span');
+        common_element_end('fb:if-section-not-added');
+
         $this->showLogo();
 
         common_element_start('dl', array("id" => 'site_nav_local_views'));
@@ -141,8 +151,7 @@ class FacebookAction extends Action
 
         common_element('link', array('rel' => 'stylesheet',
                                      'type' => 'text/css',
-                                     'href' => get_facebook_css()));
-
+                                     'href' => getFacebookCSS()));
 
         $this->showLogo();
                                  
index 532e9c9d74b1183486005dc50890682425b759ab..61469b3c64adbec5202f681240884fe28bac4e7d 100644 (file)
@@ -105,7 +105,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice)
     $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main);
 }
 
-function get_facebook_css()
+function getFacebookCSS()
 {    
     # Add a timestamp to the CSS file so Facebook cache wont ignore our changes
     $ts = filemtime(theme_file('facebookapp.css'));
@@ -113,6 +113,14 @@ function get_facebook_css()
     return $cssurl;
 }
 
+function getFacebookJS() {
+    
+    # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes
+    $ts = filemtime(INSTALLDIR.'/js/facebookapp.js');
+    $jsurl = common_path('js/facebookapp.js') . "?ts=$ts";   
+    return $jsurl;
+}
+
 
 class FacebookNoticeList extends NoticeList
 {