groundworkcss-rails 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/helpers/breadcrumbs_helper.rb~ +5 -0
- data/app/helpers/flash_block_helper.rb~ +18 -0
- data/app/helpers/flash_helper.rb~ +21 -0
- data/app/helpers/groundwork_flash_helper.rb~ +21 -0
- data/app/helpers/modal_helper.rb~ +42 -0
- data/app/helpers/social_glyph_helper.rb~ +12 -0
- data/lib/generators/groundworkcss/install/install_generator.rb~ +44 -0
- data/lib/generators/groundworkcss/install/templates/application.css.scss~ +8 -0
- data/lib/generators/groundworkcss/install/templates/application.css~ +7 -0
- data/lib/generators/groundworkcss/install/templates/application.js~ +10 -0
- data/lib/generators/groundworkcss/install/templates/groundwork-and-overrides.scss~ +12 -0
- data/lib/generators/groundworkcss/install/templates/groundwork-overrides.scss~ +7 -0
- data/lib/generators/groundworkcss/install/templates/groundwork.coffee~ +0 -0
- data/lib/generators/groundworkcss/install/templates/groundwork.js~ +1 -0
- data/lib/generators/groundworkcss/layout/layout_generator.rb~ +1 -1
- data/lib/generators/groundworkcss/layout/templates/_header.html.erb~ +24 -0
- data/lib/generators/groundworkcss/layout/templates/_sidebar.html.erb~ +18 -0
- data/lib/generators/groundworkcss/layout/templates/layout.html.erb~ +44 -0
- data/lib/groundworkcss/rails/bootstrap.rb~ +2 -0
- data/lib/groundworkcss/rails/engine.rb~ +30 -0
- data/lib/groundworkcss/rails/version.rb +1 -1
- data/lib/groundworkcss/rails/version.rb~ +1 -1
- data/lib/twitter-bootstrap-rails.rb~ +10 -0
- data/vendor/assets/javascripts/groundwork.js~ +8 -0
- data/vendor/assets/javascripts/groundworkcss/groundwork.js +24 -217
- data/vendor/assets/javascripts/groundworkcss/groundwork.js~ +7 -0
- data/vendor/assets/javascripts/groundworkcss/plugins/jquery.modals.js +1 -1
- data/vendor/assets/javascripts/groundworkcss/plugins/jquery.popover.js +1 -1
- data/vendor/assets/javascripts/groundworkcss/plugins/jquery.responsiveTables.js +1 -1
- data/vendor/assets/javascripts/groundworkcss/plugins/jquery.responsiveText.js +1 -1
- data/vendor/assets/javascripts/groundworkcss/plugins/jquery.tooltip.js +24 -10
- data/vendor/assets/stylesheets/groundworkcss-scss/_buttons.scss +3 -0
- data/vendor/assets/stylesheets/groundworkcss-scss/_classes.scss +149 -0
- data/vendor/assets/stylesheets/groundworkcss-scss/_font-awesome.scss~ +534 -0
- data/vendor/assets/stylesheets/groundworkcss-scss/_grid.scss +46 -366
- data/vendor/assets/stylesheets/groundworkcss-scss/_layout.scss +11 -11
- data/vendor/assets/stylesheets/groundworkcss-scss/_mixins.scss +9 -0
- data/vendor/assets/stylesheets/groundworkcss-scss/_responsive.scss +4 -106
- data/vendor/assets/stylesheets/groundworkcss-scss/_social-icons.scss~ +92 -0
- data/vendor/assets/stylesheets/groundworkcss-scss/_tooltips.scss +5 -5
- data/vendor/assets/stylesheets/groundworkcss-scss/_typography.scss +48 -43
- data/vendor/assets/stylesheets/groundworkcss-scss/_variables.scss +47 -46
- data/vendor/assets/stylesheets/groundworkcss-scss/groundwork.scss +3 -0
- metadata +318 -299
- data/vendor/assets/javascripts/groundworkcss/coffee/groundwork.coffee +0 -207
- data/vendor/assets/javascripts/groundworkcss/coffee/plugins/jquery.modals.coffee +0 -162
- data/vendor/assets/javascripts/groundworkcss/coffee/plugins/jquery.popover.coffee +0 -198
- data/vendor/assets/javascripts/groundworkcss/coffee/plugins/jquery.responsiveTables.coffee +0 -56
- data/vendor/assets/javascripts/groundworkcss/coffee/plugins/jquery.responsiveText.coffee +0 -32
- data/vendor/assets/javascripts/groundworkcss/coffee/plugins/jquery.tooltip.coffee +0 -121
@@ -1,207 +0,0 @@
|
|
1
|
-
###
|
2
|
-
*
|
3
|
-
* GroundworkCSS JS by Gary Hepting - https://github.com/groundworkcss/groundwork
|
4
|
-
*
|
5
|
-
* Open source under the BSD License.
|
6
|
-
*
|
7
|
-
* Copyright © 2013 Gary Hepting. All rights reserved.
|
8
|
-
*
|
9
|
-
###
|
10
|
-
|
11
|
-
$(document).ready ->
|
12
|
-
|
13
|
-
# navigation menus
|
14
|
-
delay = ''
|
15
|
-
$('nav > ul > li.menu').on
|
16
|
-
mouseenter: (e) ->
|
17
|
-
if $(window).width() > 768
|
18
|
-
clearTimeout(delay)
|
19
|
-
$('nav > ul > li').removeClass('on')
|
20
|
-
$('nav > ul > li > ul').hide()
|
21
|
-
$(this).addClass('on')
|
22
|
-
mouseleave: (e) ->
|
23
|
-
if $(window).width() > 768
|
24
|
-
delay = setTimeout (->
|
25
|
-
$('nav > ul > li').removeClass('on')
|
26
|
-
$('nav > ul > li > ul').hide()
|
27
|
-
), 350
|
28
|
-
click: (e) ->
|
29
|
-
if $(window).width() < 768
|
30
|
-
if $(e.target).parent('li.menu').size() > 0
|
31
|
-
$this = $(this)
|
32
|
-
$(this).children('ul').slideToggle 300, ->
|
33
|
-
$this.toggleClass('on')
|
34
|
-
e.preventDefault()
|
35
|
-
return false
|
36
|
-
tap: (e) ->
|
37
|
-
if $(e.target).parent('li.menu').size() > 0
|
38
|
-
$this = $(this)
|
39
|
-
$(this).children('ul').slideToggle 300, ->
|
40
|
-
$this.toggleClass('on')
|
41
|
-
e.preventDefault()
|
42
|
-
return false
|
43
|
-
|
44
|
-
# dynamically adjust pagination items
|
45
|
-
limitPaginationItems()
|
46
|
-
# change active page
|
47
|
-
$('.pagination ul > li:not(.next, .prev) a').on 'click', ( (e) ->
|
48
|
-
$('.pagination ul > li:not(.next, .prev)').removeClass('active')
|
49
|
-
$(this).parent('li').addClass('active')
|
50
|
-
# toggle previous button state
|
51
|
-
if $(this).parent('li').hasClass('first')
|
52
|
-
$('.pagination ul > li.prev').addClass('disabled')
|
53
|
-
else
|
54
|
-
$('.pagination ul > li.prev').removeClass('disabled')
|
55
|
-
# toggle next button state
|
56
|
-
if $(this).parent('li').hasClass('last')
|
57
|
-
$('.pagination ul > li.next').addClass('disabled')
|
58
|
-
else
|
59
|
-
$('.pagination ul > li.next').removeClass('disabled')
|
60
|
-
# adjust pagination
|
61
|
-
limitPaginationItems()
|
62
|
-
e.preventDefault()
|
63
|
-
false
|
64
|
-
)
|
65
|
-
# handle previous pagination button
|
66
|
-
$('.pagination ul > li.prev:not(.disabled)').on 'click', ( (e) ->
|
67
|
-
# enable next button
|
68
|
-
$('.pagination ul > li.next').removeClass('disabled')
|
69
|
-
el = $('.pagination ul > li.active')
|
70
|
-
if !el.hasClass('first')
|
71
|
-
# set previous page active
|
72
|
-
el.removeClass('active')
|
73
|
-
el.prev().addClass('active')
|
74
|
-
# adjust pagination
|
75
|
-
limitPaginationItems()
|
76
|
-
# disable previous button if at first page
|
77
|
-
if $('.pagination ul > li.active').hasClass('first')
|
78
|
-
$(this).addClass('disabled')
|
79
|
-
e.preventDefault()
|
80
|
-
false
|
81
|
-
)
|
82
|
-
# handle next pagination button
|
83
|
-
$('.pagination ul > li.next:not(.disabled)').on 'click', ( (e) ->
|
84
|
-
# enable previous button
|
85
|
-
$('.pagination ul > li.prev').removeClass('disabled')
|
86
|
-
el = $('.pagination ul > li.active')
|
87
|
-
if !el.hasClass('last')
|
88
|
-
# set next page active
|
89
|
-
el.removeClass('active')
|
90
|
-
el.next().addClass('active')
|
91
|
-
# adjust pagination
|
92
|
-
limitPaginationItems()
|
93
|
-
# disable next button if at last page
|
94
|
-
if $('.pagination ul > li.active').hasClass('last')
|
95
|
-
$(this).addClass('disabled')
|
96
|
-
e.preventDefault()
|
97
|
-
false
|
98
|
-
)
|
99
|
-
# disable page jump for disabled pagination links
|
100
|
-
$('.pagination ul > li.disabled a').on 'click', ( (e) ->
|
101
|
-
e.preventDefault()
|
102
|
-
false
|
103
|
-
)
|
104
|
-
|
105
|
-
# select all text on invalid input field entries
|
106
|
-
$('.error input, .error textarea,
|
107
|
-
.invalid input, .invalid textarea,
|
108
|
-
input.error, textarea.error,
|
109
|
-
input.invalid, textarea.invalid').on
|
110
|
-
click: ->
|
111
|
-
$(this).focus()
|
112
|
-
$(this).select()
|
113
|
-
|
114
|
-
# polyfill select box placeholders
|
115
|
-
$('span.select select').each ->
|
116
|
-
if $(this).children('option').first().val() == '' and $(this).children('option').first().attr('selected')
|
117
|
-
$(this).addClass('unselected')
|
118
|
-
else
|
119
|
-
$(this).removeClass('unselected')
|
120
|
-
$('span.select select').on
|
121
|
-
change: ->
|
122
|
-
if $(this).children('option').first().val() == '' and $(this).children('option').first().attr('selected')
|
123
|
-
$(this).addClass('unselected')
|
124
|
-
else
|
125
|
-
$(this).removeClass('unselected')
|
126
|
-
|
127
|
-
# tabs
|
128
|
-
$('.tabs > ul > li > a').not('.disabled').click (e) ->
|
129
|
-
tabs = $(this).parents('.tabs')
|
130
|
-
tabs.find('> ul li a').removeClass('active')
|
131
|
-
$(this).addClass('active')
|
132
|
-
tabs.children('div').removeClass('active')
|
133
|
-
tabs.children($(this).attr('href')).addClass('active')
|
134
|
-
e.preventDefault()
|
135
|
-
return false
|
136
|
-
|
137
|
-
# responsive headings
|
138
|
-
$('.responsive').not('table').each (index, object) ->
|
139
|
-
compression = 10
|
140
|
-
min = 10
|
141
|
-
max = 200
|
142
|
-
compression = parseFloat $(this).attr('data-compression') || compression
|
143
|
-
min = parseFloat $(this).attr('data-min') || min
|
144
|
-
max = parseFloat $(this).attr('data-max') || max
|
145
|
-
$(object).responsiveText
|
146
|
-
compressor: compression,
|
147
|
-
minSize: min,
|
148
|
-
maxSize: max
|
149
|
-
|
150
|
-
# responsive tables
|
151
|
-
$('table.responsive').each (index, object) ->
|
152
|
-
compression = 30
|
153
|
-
min = 8
|
154
|
-
max = 13
|
155
|
-
padding = 0
|
156
|
-
compression = parseFloat $(this).attr('data-compression') || compression
|
157
|
-
min = parseFloat $(this).attr('data-min') || min
|
158
|
-
max = parseFloat $(this).attr('data-max') || max
|
159
|
-
padding = parseFloat $(this).attr('data-padding') || padding
|
160
|
-
$(object).responsiveTable
|
161
|
-
compressor: compression,
|
162
|
-
minSize: min,
|
163
|
-
maxSize: max,
|
164
|
-
padding: padding
|
165
|
-
|
166
|
-
# tooltips
|
167
|
-
$('.tooltip[title]').tooltip()
|
168
|
-
|
169
|
-
# modals
|
170
|
-
$('div.modal').modal()
|
171
|
-
|
172
|
-
|
173
|
-
$(window).load ->
|
174
|
-
$('.slider').orbit()
|
175
|
-
|
176
|
-
$(window).resize ->
|
177
|
-
limitPaginationItems()
|
178
|
-
|
179
|
-
# responsive pagination
|
180
|
-
limitPaginationItems = ->
|
181
|
-
#process pagination lists
|
182
|
-
$('.pagination ul').each ->
|
183
|
-
pagination = $(this)
|
184
|
-
# pagination dimensions
|
185
|
-
visibleSpace = pagination.outerWidth() - pagination.children('li.prev').outerWidth() - pagination.children('li.next').outerWidth()
|
186
|
-
# hide pages that don't fit
|
187
|
-
pagination.children('li').not('.prev, .next, .active').hide()
|
188
|
-
visibleItemsWidth = 0
|
189
|
-
pagination.children('li:visible').each ->
|
190
|
-
visibleItemsWidth += $(this).outerWidth()
|
191
|
-
# loop
|
192
|
-
while (visibleItemsWidth + 29) < visibleSpace
|
193
|
-
# show the next page number
|
194
|
-
pagination.children('li:visible').not('.next').last().next().show()
|
195
|
-
visibleItemsWidth = 0
|
196
|
-
pagination.children('li:visible').each ->
|
197
|
-
visibleItemsWidth += $(this).outerWidth()
|
198
|
-
if (visibleItemsWidth + 29) <= visibleSpace
|
199
|
-
# show the previous page number
|
200
|
-
pagination.children('li:visible').not('.prev').first().prev().show()
|
201
|
-
visibleItemsWidth = 0
|
202
|
-
pagination.children('li:visible').each ->
|
203
|
-
visibleItemsWidth += $(this).outerWidth()
|
204
|
-
# recalculate visibleItemsWidth
|
205
|
-
visibleItemsWidth = 0
|
206
|
-
pagination.children('li:visible').each ->
|
207
|
-
visibleItemsWidth += $(this).outerWidth()
|
@@ -1,162 +0,0 @@
|
|
1
|
-
###
|
2
|
-
*
|
3
|
-
* jQuery Modals by Gary Hepting
|
4
|
-
* https://github.com/ghepting/modal
|
5
|
-
*
|
6
|
-
* Based on Avgrund by Hakim El Hattab <3
|
7
|
-
*
|
8
|
-
###
|
9
|
-
|
10
|
-
(($) ->
|
11
|
-
|
12
|
-
# setup iframe modal
|
13
|
-
if $('div#iframeModal').length < 1
|
14
|
-
$('body').append('<div class="iframe modal" id="iframeModal"><iframe marginheight="0" marginwidth="0" frameborder="0"></iframe></div>')
|
15
|
-
$('div#iframeModal').prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>')
|
16
|
-
$('a.modal').each ->
|
17
|
-
$(this).attr('data-url',$(this).attr('href'))
|
18
|
-
$(this).attr('href','#iframeModal')
|
19
|
-
# bind external modal links to iframe modal
|
20
|
-
$('a.modal').on "click", (e) ->
|
21
|
-
$('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0" width="100%" height="100%" src="'+$(this).attr('data-url')+'"></iframe>')
|
22
|
-
e.preventDefault()
|
23
|
-
false
|
24
|
-
|
25
|
-
elems = []
|
26
|
-
$.fn.modal = ->
|
27
|
-
|
28
|
-
@each ->
|
29
|
-
$(this).not('#iframeModal').wrapInner('<div class="modal-content"></div>')
|
30
|
-
$(this).prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>').appendTo('body')
|
31
|
-
# bind each modal link to a modal
|
32
|
-
$('[href=#'+$(this).attr('id')+']').on "click", (e) ->
|
33
|
-
modals.open($(this).attr('href'))
|
34
|
-
e.preventDefault()
|
35
|
-
return false
|
36
|
-
|
37
|
-
# close button
|
38
|
-
$('div.modal .close').on "click", ->
|
39
|
-
modals.close()
|
40
|
-
# fullscreen button
|
41
|
-
$('div.modal .fullscreen').on "click", ->
|
42
|
-
modals.fullscreen($(this).parent('div.modal'))
|
43
|
-
|
44
|
-
modals = (->
|
45
|
-
|
46
|
-
# ready state
|
47
|
-
$('html').addClass('modal-ready')
|
48
|
-
|
49
|
-
# create overlay
|
50
|
-
if $("#overlay").length < 1
|
51
|
-
$('body').append('<div id="overlay"></div>')
|
52
|
-
|
53
|
-
# bind overlay to close
|
54
|
-
$('#overlay, div.modal .close').bind "click", (e) ->
|
55
|
-
close()
|
56
|
-
|
57
|
-
open = (elem) ->
|
58
|
-
# bind esc key
|
59
|
-
$(window).bind "keydown", (e) ->
|
60
|
-
keyCode = (if (e.which) then e.which else e.keyCode)
|
61
|
-
if keyCode is 27
|
62
|
-
close()
|
63
|
-
$(elem).addClass("active")
|
64
|
-
unless $(elem).hasClass('iframe')
|
65
|
-
$(elem).css
|
66
|
-
width: 'auto',
|
67
|
-
height: 'auto'
|
68
|
-
$(elem).css
|
69
|
-
height: $(elem).outerHeight(),
|
70
|
-
$(elem).css
|
71
|
-
top: '50%',
|
72
|
-
left: '50%',
|
73
|
-
'margin-top': ($(elem).outerHeight() / -2) + 'px',
|
74
|
-
'margin-left': ($(elem).outerWidth() / -2) + 'px'
|
75
|
-
setTimeout ->
|
76
|
-
$('html').addClass("modal-active")
|
77
|
-
, 0
|
78
|
-
setTimeout ->
|
79
|
-
$('html').removeClass('modal-ready')
|
80
|
-
, 400
|
81
|
-
return
|
82
|
-
|
83
|
-
close = ->
|
84
|
-
modal = $('div.modal.active')
|
85
|
-
$(window).unbind "keydown"
|
86
|
-
$('html').removeClass("modal-active").addClass('modal-ready')
|
87
|
-
if modal.hasClass('iframe')
|
88
|
-
$('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0"></iframe>')
|
89
|
-
modal.css
|
90
|
-
width: '80%',
|
91
|
-
height: '80%'
|
92
|
-
else
|
93
|
-
modal.css
|
94
|
-
width: 'auto',
|
95
|
-
height: 'auto'
|
96
|
-
modal.css
|
97
|
-
top: '10%',
|
98
|
-
left: '10%',
|
99
|
-
'max-width': '80%',
|
100
|
-
'max-height': '80%',
|
101
|
-
'margin-top': 0,
|
102
|
-
'margin-left': 0
|
103
|
-
modal.removeClass("active").removeClass("fullscreen")
|
104
|
-
$('i.fullscreen', modal).removeClass('icon-resize-small').addClass('icon-resize-full')
|
105
|
-
return
|
106
|
-
|
107
|
-
fullscreen = (elem) ->
|
108
|
-
if $('div.modal.active').hasClass('fullscreen')
|
109
|
-
$('div.modal i.fullscreen').removeClass('icon-resize-small').addClass('icon-resize-full')
|
110
|
-
if $('div.modal.active').hasClass('iframe')
|
111
|
-
$('div.modal.active').css
|
112
|
-
width: '80%',
|
113
|
-
height: '80%'
|
114
|
-
else
|
115
|
-
$('div.modal.active').css
|
116
|
-
width: 'auto',
|
117
|
-
height: 'auto'
|
118
|
-
$('div.modal.active').css
|
119
|
-
height: $('div.modal.active').outerHeight()
|
120
|
-
$('div.modal.active').removeClass('fullscreen').css
|
121
|
-
'max-width': '80%',
|
122
|
-
'max-height': '80%'
|
123
|
-
$('div.modal.active').delay(100).css
|
124
|
-
top: '50%',
|
125
|
-
left: '50%',
|
126
|
-
'margin-top': ($('div.modal.active').outerHeight() / -2) + 'px',
|
127
|
-
'margin-left': ($('div.modal.active').outerWidth() / -2) + 'px'
|
128
|
-
else
|
129
|
-
$('div.modal i.fullscreen').addClass('icon-resize-small').removeClass('icon-resize-full')
|
130
|
-
$('div.modal.active').addClass('fullscreen').css
|
131
|
-
top: 0,
|
132
|
-
left: 0,
|
133
|
-
'margin-top': 0,
|
134
|
-
'margin-left': 0,
|
135
|
-
width: '100%',
|
136
|
-
height: '100%',
|
137
|
-
'max-width': '100%',
|
138
|
-
'max-height': '100%'
|
139
|
-
return
|
140
|
-
|
141
|
-
open: open
|
142
|
-
close: close
|
143
|
-
fullscreen: fullscreen
|
144
|
-
)()
|
145
|
-
|
146
|
-
$(window).resize ->
|
147
|
-
$('div.modal.active').each ->
|
148
|
-
unless $(this).hasClass('fullscreen')
|
149
|
-
$(this).removeClass('active').css(
|
150
|
-
top: '50%',
|
151
|
-
left: '50%',
|
152
|
-
'margin-top': ($(this).outerHeight() / -2) + 'px',
|
153
|
-
'margin-left': ($(this).outerWidth() / -2) + 'px'
|
154
|
-
).addClass('active')
|
155
|
-
unless $(this).hasClass('iframe')
|
156
|
-
$(this).css
|
157
|
-
height: 'auto'
|
158
|
-
$(this).css
|
159
|
-
height: $(this).outerHeight()
|
160
|
-
|
161
|
-
|
162
|
-
) jQuery
|
@@ -1,198 +0,0 @@
|
|
1
|
-
###
|
2
|
-
*
|
3
|
-
* jQuery Popovers by Gary Hepting - https://github.com/ghepting/jquery-popovers
|
4
|
-
*
|
5
|
-
* Open source under the BSD License.
|
6
|
-
*
|
7
|
-
* Copyright © 2013 Gary Hepting. All rights reserved.
|
8
|
-
*
|
9
|
-
###
|
10
|
-
|
11
|
-
(($) ->
|
12
|
-
$.fn.popover = (options) ->
|
13
|
-
defaults =
|
14
|
-
hover: false # show popovers on hover
|
15
|
-
click: true # show popovers on click
|
16
|
-
resize: true # resize popovers on window resize/orientation change
|
17
|
-
scroll: true # reposition popovers on scroll
|
18
|
-
topOffset: 0 # top offset (accomodate for fixed navigation, etc.)
|
19
|
-
delay: 500 # delay before hiding (ms)
|
20
|
-
speed: 100 # animation speed (ms)
|
21
|
-
|
22
|
-
options = $.extend(defaults, options)
|
23
|
-
|
24
|
-
popover = $('#popover') # popover element
|
25
|
-
delayHide = '' # delay
|
26
|
-
delayAdjust = '' # delay
|
27
|
-
trigger = '' # trigger element
|
28
|
-
|
29
|
-
# get element position relative to the viewport
|
30
|
-
getElementPosition = (el) ->
|
31
|
-
offset = el.offset()
|
32
|
-
win = $(window)
|
33
|
-
top: top = offset.top - win.scrollTop()
|
34
|
-
left: left = offset.left - win.scrollLeft()
|
35
|
-
bottom: bottom = win.height() - top - el.outerHeight()
|
36
|
-
right: right = win.width() - left - el.outerWidth()
|
37
|
-
|
38
|
-
resetPopover = (resize) ->
|
39
|
-
popover.css
|
40
|
-
top: 'auto'
|
41
|
-
right: 'auto'
|
42
|
-
bottom: 'auto'
|
43
|
-
left: 'auto'
|
44
|
-
if resize
|
45
|
-
popover.css
|
46
|
-
width: 'auto'
|
47
|
-
popover.removeClass('top')
|
48
|
-
popover.removeClass('right')
|
49
|
-
popover.removeClass('bottom')
|
50
|
-
popover.removeClass('left')
|
51
|
-
|
52
|
-
setPosition = (trigger, skipAnimation, resize) ->
|
53
|
-
if trigger
|
54
|
-
if resize
|
55
|
-
resetPopover(true)
|
56
|
-
else
|
57
|
-
resetPopover()
|
58
|
-
# get trigger element coordinates
|
59
|
-
coords = getElementPosition(trigger)
|
60
|
-
# popover dimensions
|
61
|
-
if popover.outerWidth() > ($(window).width() - 20)
|
62
|
-
popover.css('width',$(window).width() - 20)
|
63
|
-
# adjust max width of popover
|
64
|
-
popover.css('max-width',
|
65
|
-
Math.min(
|
66
|
-
($(window).width()-parseInt($('body').css('padding-left'))-parseInt($('body').css('padding-right'))),
|
67
|
-
parseInt(popover.css('max-width'))
|
68
|
-
)
|
69
|
-
)
|
70
|
-
width = popover.outerWidth()
|
71
|
-
height = popover.outerHeight()
|
72
|
-
# horizontal positioning
|
73
|
-
attrs = {}
|
74
|
-
if coords.left <= coords.right # default position
|
75
|
-
popover.addClass('left')
|
76
|
-
attrs.left = coords.left
|
77
|
-
else # pin from right side
|
78
|
-
popover.addClass('right')
|
79
|
-
attrs.right = coords.right
|
80
|
-
# veritcal positioning
|
81
|
-
if (coords.top-options.topOffset) > (height+20) # top positioned popover
|
82
|
-
popover.addClass('top')
|
83
|
-
attrs.top = trigger.offset().top - height - 20
|
84
|
-
else # bottom positioned popover
|
85
|
-
popover.addClass('bottom')
|
86
|
-
attrs.top = trigger.offset().top + 15
|
87
|
-
popover.css attrs
|
88
|
-
# compensate for adjustment normally made by animation in init_popover()
|
89
|
-
if skipAnimation
|
90
|
-
popover.css
|
91
|
-
top: '+=10'
|
92
|
-
|
93
|
-
closePopover = ->
|
94
|
-
$('.popover-trigger').removeClass('popover-trigger')
|
95
|
-
popover.removeClass('sticky').remove()
|
96
|
-
|
97
|
-
showPopover = (e) ->
|
98
|
-
trigger = $(e.target) # trigger element
|
99
|
-
if !trigger.hasClass('popover-trigger')
|
100
|
-
closePopover() # close popover
|
101
|
-
trigger.addClass('popover-trigger')
|
102
|
-
# set popover content
|
103
|
-
tip = $('#'+trigger.attr('data-content')).html()
|
104
|
-
popover = $("<div id=\"popover\"></div>") # create popover DOM element
|
105
|
-
return false if not tip or tip is ""
|
106
|
-
# remove title to avoid overlapping default tooltips
|
107
|
-
trigger.removeAttr "title"
|
108
|
-
# add popover element to DOM
|
109
|
-
popover.css("opacity", 0).html(tip).appendTo "body"
|
110
|
-
# initialize popover
|
111
|
-
setPosition(trigger)
|
112
|
-
popover.animate
|
113
|
-
top: "+=10"
|
114
|
-
opacity: 1
|
115
|
-
, options.speed
|
116
|
-
|
117
|
-
# popover click
|
118
|
-
popover.bind "click", (e) ->
|
119
|
-
if(e.target.tagName != 'a')
|
120
|
-
popover.addClass('sticky')
|
121
|
-
e.stopPropagation()
|
122
|
-
e.preventDefault()
|
123
|
-
false
|
124
|
-
|
125
|
-
# close button click
|
126
|
-
popover.find('.close').bind "click", (e) ->
|
127
|
-
$('.popover-trigger').removeClass('popover-trigger')
|
128
|
-
popover.removeClass('sticky').remove()
|
129
|
-
e.stopPropagation()
|
130
|
-
e.preventDefault()
|
131
|
-
false
|
132
|
-
|
133
|
-
# hover into the popover
|
134
|
-
popover.bind
|
135
|
-
mouseenter: ->
|
136
|
-
# cancel closing popover
|
137
|
-
clearTimeout(delayHide)
|
138
|
-
mouseleave: ->
|
139
|
-
if(!popover.hasClass('sticky'))
|
140
|
-
# close popover on a delay if it's not sticky
|
141
|
-
delayHide = setTimeout (->
|
142
|
-
$('.popover-trigger').removeClass('popover-trigger')
|
143
|
-
popover.removeClass('sticky').remove()
|
144
|
-
), 500
|
145
|
-
|
146
|
-
|
147
|
-
@each ->
|
148
|
-
$this = $(this)
|
149
|
-
|
150
|
-
if options.hover
|
151
|
-
# hover on trigger element
|
152
|
-
$this.bind
|
153
|
-
mouseenter: (e) ->
|
154
|
-
trigger = $(e.target)
|
155
|
-
clearTimeout(delayHide) # cancel delayed close
|
156
|
-
if(!$this.hasClass('popover-trigger') && !popover.hasClass('sticky'))
|
157
|
-
showPopover(e) # show popover
|
158
|
-
mouseleave: ->
|
159
|
-
if(!popover.hasClass('sticky'))
|
160
|
-
# delay closing popover
|
161
|
-
delayHide = setTimeout ->
|
162
|
-
closePopover() #close popover
|
163
|
-
, options.delay
|
164
|
-
|
165
|
-
if options.click
|
166
|
-
# click trigger element
|
167
|
-
$this.bind "click", (e) ->
|
168
|
-
trigger = $(e.target)
|
169
|
-
if(!trigger.hasClass('popover-trigger'))
|
170
|
-
closePopover() #close popover
|
171
|
-
showPopover(e) # show popover
|
172
|
-
popover.addClass('sticky') # make popover sticky
|
173
|
-
e.preventDefault()
|
174
|
-
e.stopPropagation()
|
175
|
-
false
|
176
|
-
|
177
|
-
if options.resize
|
178
|
-
# handle viewport resize
|
179
|
-
$(window).resize ->
|
180
|
-
clearTimeout(delayAdjust) # cancel delayed adjustment
|
181
|
-
# attempt to wait until user finishes resizing the window
|
182
|
-
delayAdjust = setTimeout ->
|
183
|
-
setPosition(trigger, true, true)
|
184
|
-
, 100
|
185
|
-
|
186
|
-
if options.scroll
|
187
|
-
# handle window scroll
|
188
|
-
$(window).scroll ->
|
189
|
-
setPosition(trigger, true)
|
190
|
-
|
191
|
-
# close popover on body click
|
192
|
-
$('html, body').bind "click", (e) ->
|
193
|
-
$('.popover-trigger').removeClass('popover-trigger')
|
194
|
-
popover.removeClass('sticky').remove()
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
) jQuery
|