2 * StatusNet - a distributed open-source microblogging tool
3 * Copyright (C) 2010, StatusNet, Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 * @category OStatus UI interaction
20 * @author Sarven Capadisli <csarven@status.net>
21 * @copyright 2010 StatusNet, Inc.
22 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
23 * @link http://status.net/
24 * @note Everything in here should eventually migrate over to /js/util.js's SN.
27 SN.Init.OStatusCookie = function() {
28 if (SN.U.StatusNetInstance.Get() === null) {
29 SN.U.StatusNetInstance.Set({RemoteProfile: null});
34 Subscribe: function(a) {
35 var f = a.parent().find('.form_settings');
43 url: a[0].href + ((a[0].href.match(/[\\?]/) === null)?'?':'&') + 'ajax=1',
44 beforeSend: function(formData) {
45 a.addClass('processing');
47 error: function (xhr, textStatus, errorThrown) {
48 alert(errorThrown || textStatus);
50 success: function(data, textStatus, xhr) {
51 if (typeof($('form', data)[0]) != 'undefined') {
52 a.after(document._importNode($('form', data)[0], true));
54 var form = a.parent().find('.form_settings');
57 .addClass('dialogbox')
58 .append('<button class="close">×</button>');
62 .addClass('submit_dialogbox')
63 .removeClass('submit')
64 .bind('click', function() {
65 form.addClass('processing');
68 form.find('button.close').click(function(){
74 form.find('#profile').focus();
76 if (form.attr('id') == 'form_ostatus_connect') {
77 SN.Init.OStatusCookie();
78 form.find('#profile').val(SN.U.StatusNetInstance.Get().RemoteProfile);
80 form.find("[type=submit]").bind('click', function() {
81 SN.U.StatusNetInstance.Set({RemoteProfile: form.find('#profile').val()});
87 a.removeClass('processing');
94 SN.Init.Subscribe = function() {
95 $('.entity_subscribe .entity_remote_subscribe').live('click', function() { SN.U.DialogBox.Subscribe($(this)); return false; });
98 $(document).ready(function() {
101 $('.form_remote_authorize').bind('submit', function() { $(this).addClass(SN.C.S.Processing); return true; });