Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
5 lars 1
$(document).ready(function() {
2
  var hash = window.location.hash.replace('#', '');
3
 
4
  if (hash && $('.' + hash).length) {
5
    var point = $('.' + hash).offset().top - 40;
6
 
7
    if (window.Zepto) {
8
      window.scrollTo(0, point);
9
    } else {
10
      $(window).scrollTop($('.' + hash).offset().top - 40);
11
    };
12
  };
13
 
14
  $('.skin dt').click(function() {
15
    $(this).siblings().removeClass('selected').end().prev('dd').andSelf().addClass('selected');
16
  });
17
 
18
  $('.arrows .top, .arrows .bottom, .features .self, .skins-info .self, .usage .self').click(function(event) {
19
    var target = $(this).data('to'),
20
      target_offset = $('.' + target).offset().top;
21
 
22
    event.preventDefault();
23
    window.location.hash = target;
24
 
25
    if (window.Zepto) {
26
      window.scrollTo(0, target_offset - 40);
27
    } else {
28
      $('html, body').stop().animate({scrollTop: target_offset - 40}, 600);
29
    };
30
  });
31
 
32
  $('.colors li').click(function() {
33
    var self = $(this);
34
 
35
    if (!self.hasClass('active')) {
36
      self.siblings().removeClass('active');
37
 
38
      var skin = self.closest('.skin'),
39
        color = self.attr('class') ? '-' + self.attr('class') : '',
40
        checkbox = skin.data('icheckbox'),
41
        radio = skin.data('iradio'),
42
        checkbox_default = 'icheckbox_minimal',
43
        radio_default = 'iradio_minimal';
44
 
45
      if (skin.hasClass('skin-square')) {
46
        checkbox_default = 'icheckbox_square', radio_default = 'iradio_square';
47
        checkbox == undefined && (checkbox = 'icheckbox_square-green', radio = 'iradio_square-green');
48
      };
49
 
50
      if (skin.hasClass('skin-flat')) {
51
        checkbox_default = 'icheckbox_flat', radio_default = 'iradio_flat';
52
        checkbox == undefined && (checkbox = 'icheckbox_flat-red', radio = 'iradio_flat-red');
53
      };
54
 
55
      if (skin.hasClass('skin-line')) {
56
        checkbox_default = 'icheckbox_line', radio_default = 'iradio_line';
57
        checkbox == undefined && (checkbox = 'icheckbox_line-blue', radio = 'iradio_line-blue');
58
      };
59
 
60
      checkbox == undefined && (checkbox = checkbox_default, radio = radio_default);
61
 
62
      skin.find('input, .skin-states .state').each(function() {
63
        var element = $(this).hasClass('state') ? $(this) : $(this).parent(),
64
          element_class = element.attr('class').replace(checkbox, checkbox_default + color).replace(radio, radio_default + color);
65
 
66
        element.attr('class', element_class);
67
      });
68
 
69
      skin.data('icheckbox', checkbox_default + color);
70
      skin.data('iradio', radio_default + color);
71
      self.addClass('active');
72
    };
73
  });
74
 
75
  $('.demo-methods dt .self').click(function() {
76
    var self = $(this),
77
      self_class = self.attr('class').replace('self ', '');
78
 
79
    switch (self_class) {
80
      case 'do-check':
81
        $('#input-1, #input-3').iCheck('check');
82
        break;
83
      case 'do-uncheck':
84
        $('#input-1, #input-3').iCheck('uncheck');
85
        break;
86
      case 'do-disable':
87
        $('#input-2, #input-4').iCheck('disable');
88
        break;
89
      case 'do-enable':
90
        $('#input-2, #input-4').iCheck('enable');
91
        break;
92
      case 'do-destroy':
93
        $('.demo-list input').iCheck('destroy');
94
        break;
95
      default:
96
        var text = self.hasClass('active') ? 'show code' : 'hide code';
97
 
98
        self.toggleClass('active').text(text);
99
 
100
        if (window.Zepto) {
101
          $(this).closest('dt').next().toggle();
102
        } else {
103
          $(this).closest('dt').next().slideToggle(200);
104
        };
105
 
106
        break;
107
    };
108
  });
109
});