application.js 2.06 KB
Newer Older
Jacob Thornton's avatar
Jacob Thornton committed
1
$(document).ready(function(){
2

Jacob Thornton's avatar
Jacob Thornton committed
3
4
5
  // Dropdown example for topbar nav
  // ===============================

6
  $('body').dropdown() // catch any dropdowns on the page
7

Jacob Thornton's avatar
Jacob Thornton committed
8

9
  // table sort example
Jacob Thornton's avatar
Jacob Thornton committed
10
11
  // ==================

12
  $("#sortTableExample").tablesorter( { sortList: [[ 1, 0 ]] } )
13

Jacob Thornton's avatar
Jacob Thornton committed
14
15
16
17

  // add on logic
  // ============

18
  $('.add-on :checkbox').click(function () {
19
    if ($(this).attr('checked')) {
20
      $(this).parents('.add-on').addClass('active')
21
    } else {
22
      $(this).parents('.add-on').removeClass('active')
23
    }
24
  })
Jacob Thornton's avatar
Jacob Thornton committed
25

Jacob Thornton's avatar
Jacob Thornton committed
26

27
  // Disable certain links in docs
Jacob Thornton's avatar
Jacob Thornton committed
28
29
  // =============================

30
31
32
  $('ul.tabs a, ul.pills a, .pagination a, .well .btn, .actions .btn, .alert-message .btn, a.close').click(function (e) {
    e.preventDefault()
  })
33

34
  // Copy code blocks in docs
35
  $(".copy-code").focus(function () {
Jacob Thornton's avatar
Jacob Thornton committed
36
37
38
    var el = this;
    // push select to event loop for chrome :{o
    setTimeout(function () { $(el).select(); }, 1);
39
40
41
  });


42
43
  // POSITION STATIC TWIPSIES
  // ========================
44

Jacob Thornton's avatar
Jacob Thornton committed
45
46
47
48
  $('.twipsies.well a').each(function () {
    var type = this.title
      , $anchor = $(this)
      , $twipsy = $('.twipsy.' + type)
49

Jacob Thornton's avatar
Jacob Thornton committed
50
51
52
53
      , twipsy = {
          width: $twipsy.width() + 10
        , height: $twipsy.height() + 10
        }
54

Jacob Thornton's avatar
Jacob Thornton committed
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
      , anchor = {
          position: $anchor.position()
        , width: $anchor.width()
        , height: $anchor.height()
        }

      , offset = {
          above: {
            top: anchor.position.top - twipsy.height
          , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2)
          }
        , below: {
            top: anchor.position.top + anchor.height
          , left: anchor.position.left + (anchor.width/2) - (twipsy.width/2)
          }
        , left: {
            top: anchor.position.top + (anchor.height/2) - (twipsy.height/2)
          , left: anchor.position.left - twipsy.width - 5
          }
        , right: {
            top: anchor.position.top + (anchor.height/2) - (twipsy.height/2)
          , left: anchor.position.left + anchor.width + 5
          }
78
79
      }

Jacob Thornton's avatar
Jacob Thornton committed
80
81
    $twipsy.css(offset[type])
  });
82

83
});