~ubuntu-branches/ubuntu/saucy/mumble-django/saucy-proposed

« back to all changes in this revision

Viewing changes to pyweb/mumble/media/js/channelviewerplugins.js

  • Committer: Package Import Robot
  • Author(s): Michael Ziegler
  • Date: 2013-05-19 18:06:11 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20130519180611-flqpsk20fu2t6hq4
Tags: 2.9-1
* New upstream release.
* Drop DM-Upload-Allowed as it isn't used any longer.
* Update VCS-{SVN,Browser} tags.
* Update Django dependency to 1.5.
* Remove template patch for django-registration 0.8 (applied upstream).
* Remove the hunk that adds MessageMiddleware to settings.py (applied
  upstream).
* Disable the registration app for now (incompatible to Django 1.5).
* Remove dependency to python-simplejson.
* Adapt apache config to staticfiles change.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// kate: space-indent on; indent-width 4; replace-tabs on;
2
 
 
3
 
Ext.namespace('Ext.ux');
4
 
 
5
 
Ext.ux.MumbleUserEditor = Ext.extend( Ext.Component, {
6
 
    clickHandler: function( node, ev ){
7
 
        if( typeof node.attributes.userdata != "undefined" ){
8
 
            this.activate(node.attributes.userdata);
9
 
        }
10
 
    },
11
 
 
12
 
    init: function( tree ){
13
 
        this.tree = tree;
14
 
        tree.on("click", this.clickHandler, this);
15
 
    },
16
 
 
17
 
    activate: function( userdata ){
18
 
        if( !this.wnd ){
19
 
            this.userdata = userdata;
20
 
 
21
 
            tabitems = [{
22
 
                    xtype: "form",
23
 
                    border: false,
24
 
                    title: gettext("User comment"),
25
 
                    layout: 'fit',
26
 
                    items: [{
27
 
                        xtype: "htmleditor",
28
 
                        fieldLabel: 'x',
29
 
                        hideLabel: true,
30
 
                        name: "comment",
31
 
                        value: userdata.comment,
32
 
                    }],
33
 
                }, {
34
 
                    title: gettext("Avatar"),
35
 
                    scope: this,
36
 
                    listeners: {
37
 
                        afterrender: function( panel ){
38
 
                            Mumble.hasTexture( this.scope.serverid, this.scope.userdata.userid, function(provider, response){
39
 
                                if( response.result.has ){
40
 
                                    panel.el.dom.children[0].children[0].innerHTML = String.format(
41
 
                                        '<img src="{0}" alt="avatar" />', response.result.url
42
 
                                        );
43
 
                                }
44
 
                                else{
45
 
                                    panel.el.dom.children[0].children[0].innerHTML =
46
 
                                        gettext("This user does not have an Avatar.");
47
 
                                }
48
 
                            } );
49
 
                        }
50
 
                    },
51
 
                    html:  gettext("Loading..."),
52
 
                }, {
53
 
                    title: gettext("Infos"),
54
 
                    xtype: "form",
55
 
                    border: false,
56
 
                    items: [{
57
 
                        xtype: "checkbox",
58
 
                        fieldLabel: gettext("Authenticated"),
59
 
                        disabled: true,
60
 
                        name:  "a",
61
 
                        checked: (this.userdata.userid != -1)
62
 
                    }, {
63
 
                        xtype: "checkbox",
64
 
                        fieldLabel: gettext("Self-Deafened"),
65
 
                        disabled: true,
66
 
                        name:  "sd",
67
 
                        checked: this.userdata.selfDeaf
68
 
                    }, {
69
 
                        xtype: "checkbox",
70
 
                        fieldLabel: gettext("Deafened"),
71
 
                        disabled: true,
72
 
                        name:  "d",
73
 
                        checked: this.userdata.deaf
74
 
                    }, {
75
 
                        xtype: "checkbox",
76
 
                        fieldLabel: gettext("Self-Muted"),
77
 
                        disabled: true,
78
 
                        name:  "sm",
79
 
                        checked: this.userdata.selfMute
80
 
                    }, {
81
 
                        xtype: "checkbox",
82
 
                        fieldLabel: gettext("Muted"),
83
 
                        disabled: true,
84
 
                        name:  "m",
85
 
                        checked: this.userdata.mute
86
 
                    }, {
87
 
                        xtype: "checkbox",
88
 
                        fieldLabel: gettext("Suppressed"),
89
 
                        disabled: true,
90
 
                        name:  "s",
91
 
                        checked: this.userdata.suppress
92
 
                    }, {
93
 
                        xtype: "checkbox",
94
 
                        fieldLabel: gettext("Priority Speaker"),
95
 
                        disabled: true,
96
 
                        name:  "p",
97
 
                        checked: this.userdata.prioritySpeaker
98
 
                    }, {
99
 
                        xtype: "checkbox",
100
 
                        fieldLabel: gettext("Recording"),
101
 
                        disabled: true,
102
 
                        name:  "r",
103
 
                        checked: this.userdata.recording
104
 
                    }]
105
 
                }];
106
 
            if( this.is_admin ){
107
 
                tabitems.push({
108
 
                    xtype: "form",
109
 
                    border: false,
110
 
                    title: gettext("Administration"),
111
 
                    items: [{
112
 
                        xtype: "checkbox",
113
 
                        fieldLabel: gettext("Ban"),
114
 
                        name: "ban"
115
 
                    }, {
116
 
                        xtype: "numberfield",
117
 
                        fieldLabel: gettext("Ban duration"),
118
 
                        value: 3600,
119
 
                        name: "duration"
120
 
                    }, {
121
 
                        xtype: "label",
122
 
                        text:  gettext("Only if banning. Set to 0 for permanent ban, any other value for the ban duration in seconds."),
123
 
                        cls:   "form_hint_label",
124
 
                    }, {
125
 
                        xtype: "textfield",
126
 
                        fieldLabel: gettext("Reason"),
127
 
                        name:  "reason"
128
 
                    }],
129
 
                    fbar: [{
130
 
                        scope: this,
131
 
                        text: gettext("Kick"),
132
 
                        handler: function(btn){
133
 
                            f = btn.ownerCt.ownerCt.getForm().getValues();
134
 
                            Mumble.kickUser(
135
 
                                this.serverid, this.userdata.session, f.reason, (f.ban || false), parseInt(f.duration)
136
 
                                );
137
 
                        }
138
 
                    }, {
139
 
                        text: gettext("Mute"),
140
 
                        enableToggle: true,
141
 
                        scope: this,
142
 
                        ref:   '../mutebutton',
143
 
                        pressed: this.userdata.mute,
144
 
                        disabled: this.userdata.deaf,
145
 
                        toggleHandler: function(btn, state){
146
 
                            Mumble.muteUser(this.serverid, this.userdata.session, state);
147
 
                        }
148
 
                    }, {
149
 
                        text: gettext("Deafen"),
150
 
                        enableToggle: true,
151
 
                        scope: this,
152
 
                        ref:   '../deafenbutton',
153
 
                        pressed: this.userdata.deaf,
154
 
                        toggleHandler: function(btn, state){
155
 
                            Mumble.deafenUser(this.serverid, this.userdata.session, state);
156
 
                            if( state )
157
 
                                btn.refOwner.mutebutton.toggle(true, true);
158
 
                            btn.refOwner.mutebutton.setDisabled(state);
159
 
                        }
160
 
                    }],
161
 
                }, {
162
 
                    xtype: "form",
163
 
                    border: false,
164
 
                    title: gettext("Send message"),
165
 
                    layout: 'fit',
166
 
                    items: [{
167
 
                        xtype: "htmleditor",
168
 
                        fieldLabel: 'x',
169
 
                        hideLabel: true,
170
 
                        name: "message"
171
 
                    }],
172
 
                    fbar: [{
173
 
                        scope: this,
174
 
                        text: gettext("Send message"),
175
 
                        handler: function(btn){
176
 
                            f = btn.ownerCt.ownerCt.getForm().getValues();
177
 
                            Mumble.sendMessage(this.serverid, this.userdata.session, f.message, function(provider, response){
178
 
                                if( response.type == "exception" ){
179
 
                                    Ext.Msg.alert( gettext("Error"), response.message );
180
 
                                }
181
 
                                else{
182
 
                                    Ext.Msg.alert( gettext("Success"), gettext("Message sent successfully.") );
183
 
                                }
184
 
                            });
185
 
                        }
186
 
                    }]
187
 
                });
188
 
            }
189
 
 
190
 
            this.wnd = new Ext.Window({
191
 
                title: this.windowTitle || gettext("User details"),
192
 
                layout: 'fit',
193
 
                items: {
194
 
                    viewConfig:  { forceFit:  true },
195
 
                    xtype: "tabpanel",
196
 
                    activeTab: 0,
197
 
                    border: false,
198
 
                    items: tabitems,
199
 
                },
200
 
                width:  500,
201
 
                height: 300,
202
 
                scope: this,
203
 
                listeners: {
204
 
                    beforeclose: function(){
205
 
                        this.owner.wnd = null;
206
 
                    }
207
 
                },
208
 
            });
209
 
            this.wnd.owner = this;
210
 
        }
211
 
        if( !this.wnd.isVisible() ){
212
 
            this.wnd.show();
213
 
            mypos = this.tree.getPosition();
214
 
            mysize = this.tree.getSize();
215
 
            this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
216
 
        }
217
 
        else{
218
 
            this.wnd.close();
219
 
        }
220
 
    },
221
 
} );
222
 
 
223
 
Ext.ux.MumbleChannelEditor = Ext.extend( Ext.Component, {
224
 
    clickHandler: function( node, ev ){
225
 
        if( typeof node.attributes.chandata != "undefined" ){
226
 
            this.activate(node.attributes.chandata);
227
 
        }
228
 
    },
229
 
 
230
 
    init: function( tree ){
231
 
        this.tree = tree;
232
 
        tree.on("click", this.clickHandler, this);
233
 
    },
234
 
 
235
 
    activate: function( chandata ){
236
 
        if( !this.wnd ){
237
 
            this.chandata = chandata;
238
 
 
239
 
            tabitems = [{
240
 
                xtype: "form",
241
 
                border: false,
242
 
                title: gettext("Channel description"),
243
 
                defaults: { "anchor": "-20px" },
244
 
                layout: 'border',
245
 
                items: [{
246
 
                    xtype: "textfield",
247
 
                    fieldLabel: "x",
248
 
                    hideLabel: true,
249
 
                    name:  "name",
250
 
                    region: "north",
251
 
                    value: chandata.name
252
 
                }, {
253
 
                    xtype: "htmleditor",
254
 
                    fieldLabel: 'x',
255
 
                    hideLabel: true,
256
 
                    name: "description",
257
 
                    region: "center",
258
 
                    value: chandata.description
259
 
                }],
260
 
            }];
261
 
            if( this.is_admin ){
262
 
                Ext.apply( tabitems[0], {
263
 
                    fbar: [{
264
 
                        text: gettext('Add subchannel...'),
265
 
                        scope: this,
266
 
                        handler: function(btn){
267
 
                            Ext.Msg.prompt(gettext('Name'), gettext('Please enter the channel name:'), function(btn, text){
268
 
                                if (btn == 'ok'){
269
 
                                    Mumble.addChannel( this.serverid, text, this.chandata.id, function(provider, response){
270
 
                                        if( response.type == "exception" ){
271
 
                                            Ext.Msg.alert( gettext("Error"), response.message );
272
 
                                        }
273
 
                                    });
274
 
                                }
275
 
                            }, this);
276
 
                        }
277
 
                    }, {
278
 
                        scope: this,
279
 
                        text: gettext("Submit name/description"),
280
 
                        handler: function(btn){
281
 
                            f = btn.ownerCt.ownerCt.getForm().getValues();
282
 
                            Mumble.renameChannel(this.serverid, this.chandata.id, f.name, f.description, function(provider, response){
283
 
                                if( response.type == "exception" ){
284
 
                                    Ext.Msg.alert( gettext("Error"), response.message );
285
 
                                }
286
 
                            });
287
 
                        }
288
 
                    }, {
289
 
                        text: gettext('Delete channel'),
290
 
                        scope: this,
291
 
                        handler: function(btn){
292
 
                            Ext.Msg.confirm(
293
 
                                gettext('Confirm channel deletion'),
294
 
                                interpolate(gettext('Are you sure you want to delete channel %s?'), [this.chandata.name]),
295
 
                                function(btn){
296
 
                                    if( btn == 'yes' ){
297
 
                                        Mumble.removeChannel( this.serverid, this.chandata.id );
298
 
                                    }
299
 
                                }, this);
300
 
                        }
301
 
                    }]
302
 
                });
303
 
                tabitems.push({
304
 
                    xtype: "form",
305
 
                    border: false,
306
 
                    title: gettext("Send message"),
307
 
                    defaults: { "anchor": "-20px" },
308
 
                    items: [{
309
 
                        xtype: "checkbox",
310
 
                        fieldLabel: gettext('Cascade to subchannels'),
311
 
                        name: 'tree'
312
 
                    }, {
313
 
                        xtype: "htmleditor",
314
 
                        fieldLabel: 'x',
315
 
                        hideLabel: true,
316
 
                        name: "message"
317
 
                    }],
318
 
                    fbar: [{
319
 
                        scope: this,
320
 
                        text: gettext("Send message"),
321
 
                        handler: function(btn){
322
 
                            f = btn.ownerCt.ownerCt.getForm().getValues();
323
 
                            Mumble.sendMessageChannel(this.serverid, this.chandata.id,
324
 
                                (f.tree || false), f.message,
325
 
                                function(provider, response){
326
 
                                    if( response.type == "exception" ){
327
 
                                        Ext.Msg.alert( gettext("Error"), response.message );
328
 
                                    }
329
 
                                    else{
330
 
                                        Ext.Msg.alert( gettext("Success"), gettext("Message sent successfully.") );
331
 
                                    }
332
 
                                });
333
 
                        }
334
 
                    }]
335
 
                });
336
 
            }
337
 
 
338
 
            this.wnd = new Ext.Window({
339
 
                title: this.windowTitle || ( this.is_admin
340
 
                    ? interpolate( gettext("Channel %s (%s)"), [chandata.name, chandata.id] )
341
 
                    : interpolate( gettext("Channel %s"),      [chandata.name] ) ),
342
 
                layout: 'fit',
343
 
                items: [{
344
 
                    xtype: "tabpanel",
345
 
                    activeTab: 0,
346
 
                    items: tabitems
347
 
                }],
348
 
                width:  500,
349
 
                height: 300,
350
 
                scope: this,
351
 
                listeners: {
352
 
                    beforeclose: function(){
353
 
                        this.owner.wnd = null;
354
 
                    }
355
 
                },
356
 
            });
357
 
            this.wnd.owner = this;
358
 
        }
359
 
        if( !this.wnd.isVisible() ){
360
 
            this.wnd.show();
361
 
            mypos = this.tree.getPosition();
362
 
            mysize = this.tree.getSize();
363
 
            this.wnd.setPosition( mypos[0] + mysize.width - 50, mypos[1] + 50 );
364
 
        }
365
 
        else{
366
 
            this.wnd.close();
367
 
        }
368
 
    },
369
 
} );