]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/OStatus/js/ostatus.js
Debugging log fix.
[quix0rs-gnu-social.git] / plugins / OStatus / js / ostatus.js
1 /*
2  * StatusNet - a distributed open-source microblogging tool
3  * Copyright (C) 2010, StatusNet, Inc.
4  *
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.
9  *
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.
14  *
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/>.
17  *
18  * @category  OStatus UI interaction
19  * @package   StatusNet
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.
25  */
26
27 SN.U.DialogBox = {
28     Subscribe: function (a) {
29         var f = a.parent().find('.form_settings');
30         if (f.length > 0) {
31             f.show();
32         }
33         else {
34             $.ajax({
35                 type: 'GET',
36                 dataType: 'xml',
37                 url: a[0].href + ((a[0].href.match(/[\\?]/) === null)?'?':'&') + 'ajax=1',
38                 beforeSend: function (formData) {
39                     a.addClass('processing');
40                 },
41                 error: function (xhr, textStatus, errorThrown) {
42                     alert(errorThrown || textStatus);
43                 },
44                 success: function (data, textStatus, xhr) {
45                     if (typeof($('form', data)[0]) != 'undefined') {
46                         a.after(document._importNode($('form', data)[0], true));
47
48                         var form = a.parent().find('.form_settings');
49
50                         form
51                             .addClass('dialogbox')
52                             .append('<button class="close">&#215;</button>');
53
54                         form
55                             .find('.submit')
56                                 .addClass('submit_dialogbox')
57                                 .removeClass('submit')
58                                 .bind('click', function () {
59                                     form.addClass('processing');
60                                 });
61
62                         form.find('button.close').click(function (){
63                             form.hide();
64
65                             return false;
66                         });
67
68                         form.find('#profile').focus();
69                     }
70
71                     a.removeClass('processing');
72                 }
73             });
74         }
75     }
76 };
77
78 SN.Init.Subscribe = function () {
79     $(document).on('click',
80         '.entity_subscribe .entity_remote_subscribe, .entity_tag .entity_remote_tag',
81         function () { SN.U.DialogBox.Subscribe($(this)); return false; });
82 };
83
84 $(document).ready(function () {
85     SN.Init.Subscribe();
86
87     $('.form_remote_authorize').bind('submit', function () {
88             $(this).addClass(SN.C.S.Processing); return true;
89         });
90 });