app/assets/javascripts/settings.js   A
last analyzed

Complexity

Total Complexity 7
Complexity/F 1.75

Size

Lines of Code 25
Function Count 4

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 7
eloc 16
mnd 3
bc 3
fnc 4
bpm 0.75
cpm 1.75
noi 0
1
// BigBlueButton open source conferencing system - http://www.bigbluebutton.org/.
2
//
3
// Copyright (c) 2018 BigBlueButton Inc. and by respective authors (see below).
4
//
5
// This program is free software; you can redistribute it and/or modify it under the
6
// terms of the GNU Lesser General Public License as published by the Free Software
7
// Foundation; either version 3.0 of the License, or (at your option) any later
8
// version.
9
//
10
// BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY
11
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12
// PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
13
//
14
// You should have received a copy of the GNU Lesser General Public License along
15
// with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
16
17
// Handle changing of settings tabs.
18
$(document).on('turbolinks:load', function(){
19
  var controller = $("body").data('controller');
20
  var action = $("body").data('action');
21
22
  // Only run on the settings page.
23
  if ((controller == "users" && action == "edit") || (controller == "users" && action == "update")){
24
    var settingsButtons = $('.setting-btn');
25
    var settingsViews = $('.setting-view');
26
27
    settingsButtons.each(function(i, btn) {
28
      if(!$(btn).hasClass("active")){ $(settingsViews[i]).hide(); }
29
      $(btn).click(function(){
30
        $(btn).addClass("active");
31
        settingsViews.each(function(i, view){
32
          if($(view).attr("id") == $(btn).attr("id")){
33
            $(view).show();
34
          } else {
35
            $(settingsButtons[i]).removeClass("active");
36
            $(view).hide();
37
          }
38
        });
39
      });
40
    });
41
  }
42
});
43