aboutsummaryrefslogtreecommitdiffstats
path: root/syte/static/js/components/links.js
blob: 0671f6a1364f68cc865bfedc98f7c6c069c9d363 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

function setupLinks() {

  $('a').click(function(e) {
      e.preventDefault();
      e.stopPropagation();

      var url = $.url(this.href.replace('/#!', ''));

      if (this.id == 'home-link' && window.location.pathname == '/') {
         $('#github-profile').remove();
         $('#dribbble-profile').remove();
         $('#twitter-profile').remove();
         $('#instagram-profile').remove();
         $('.modal-backdrop').remove();
         adjustSelection('home-link');
      }
      else if(this.id == 'instagram-link' && instagram_integration_enabled) {
         $('#github-profile').remove();
         $('#dribbble-profile').remove();
         $('#twitter-profile').remove();
         $('.modal-backdrop').remove();
         adjustSelection('instagram-link');

         setupInstagram(this);
      }
      else if (twitter_integration_enabled && (url.attr('host') == 'twitter.com' || url.attr('host') == 'www.twitter.com')) {

         $('#github-profile').remove();
         $('#dribbble-profile').remove();
         $('#instagram-profile').remove();
         $('.modal-backdrop').remove();
         adjustSelection('twitter-link');

         setupTwitter(url, this);
      }
      else if (github_integration_enabled && (url.attr('host') == 'github.com' || url.attr('host') == 'www.github.com')) {

        $('#twitter-profile').remove();
        $('#dribbble-profile').remove();
        $('#instagram-profile').remove();
        $('.modal-backdrop').remove();
        adjustSelection('github-link');

        setupGithub(url, this);
      }
      else if (dribbble_integration_enabled && (url.attr('host') == 'dribbble.com' || url.attr('host') == 'www.dribbble.com')) {

         $('#twitter-profile').remove();
         $('#github-profile').remove();
         $('#instagram-profile').remove();
         $('.modal-backdrop').remove();
         adjustSelection('dribbble-link');

         setupDribbble(url, this);
      }
      else {
         window.location = this.href;
      }
  });
}

function adjustSelection(el) {
  $('.main-nav').children('li').removeClass('sel');
  $('#' + el).parent().addClass('sel');
}