furatto 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/furatto.gemspec +21 -0
- data/lib/furatto.rb +16 -0
- data/lib/furatto/engine.rb +6 -0
- data/lib/furatto/version.rb +3 -0
- data/vendor/assets/fonts/fontawesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.svg +399 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/fontawesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/meteocons-webfont.eot +0 -0
- data/vendor/assets/fonts/meteocons-webfont.svg +81 -0
- data/vendor/assets/fonts/meteocons-webfont.ttf +0 -0
- data/vendor/assets/fonts/meteocons-webfont.woff +0 -0
- data/vendor/assets/images/icheck/aero.png +0 -0
- data/vendor/assets/images/icheck/aero@2x.png +0 -0
- data/vendor/assets/images/icheck/blue.png +0 -0
- data/vendor/assets/images/icheck/blue@2x.png +0 -0
- data/vendor/assets/images/icheck/flat.png +0 -0
- data/vendor/assets/images/icheck/flat@2x.png +0 -0
- data/vendor/assets/images/icheck/green.png +0 -0
- data/vendor/assets/images/icheck/green@2x.png +0 -0
- data/vendor/assets/images/icheck/grey.png +0 -0
- data/vendor/assets/images/icheck/grey@2x.png +0 -0
- data/vendor/assets/images/icheck/orange.png +0 -0
- data/vendor/assets/images/icheck/orange@2x.png +0 -0
- data/vendor/assets/images/icheck/pink.png +0 -0
- data/vendor/assets/images/icheck/pink@2x.png +0 -0
- data/vendor/assets/images/icheck/purple.png +0 -0
- data/vendor/assets/images/icheck/purple@2x.png +0 -0
- data/vendor/assets/images/icheck/red.png +0 -0
- data/vendor/assets/images/icheck/red@2x.png +0 -0
- data/vendor/assets/images/icheck/yellow.png +0 -0
- data/vendor/assets/images/icheck/yellow@2x.png +0 -0
- data/vendor/assets/images/icons/customize-icon150.png +0 -0
- data/vendor/assets/images/icons/flexible-icon.png +0 -0
- data/vendor/assets/images/icons/github-128-black.png +0 -0
- data/vendor/assets/images/icons/iphone-icon150.png +0 -0
- data/vendor/assets/images/icons/lock-icon128.png +0 -0
- data/vendor/assets/images/icons/rocket-icon128.png +0 -0
- data/vendor/assets/images/icons/rocket-icon150.png +0 -0
- data/vendor/assets/images/icons/screen-icon.png +0 -0
- data/vendor/assets/images/icons/screens-icon.png +0 -0
- data/vendor/assets/images/icons/screens2-icon.png +0 -0
- data/vendor/assets/images/next.png +0 -0
- data/vendor/assets/images/previous.png +0 -0
- data/vendor/assets/images/themes.gif +0 -0
- data/vendor/assets/images/toggle.png +0 -0
- data/vendor/assets/javascripts/dropdown.js +169 -0
- data/vendor/assets/javascripts/furatto.js +15 -0
- data/vendor/assets/javascripts/jpanel.js +547 -0
- data/vendor/assets/javascripts/jquery.avgrund.js +127 -0
- data/vendor/assets/javascripts/jquery.dropkick-1.0.0.js +400 -0
- data/vendor/assets/javascripts/jquery.icheck.js +462 -0
- data/vendor/assets/javascripts/jquery.tagsinput.js +354 -0
- data/vendor/assets/javascripts/jquery.toolbar.js +242 -0
- data/vendor/assets/javascripts/legacy.js +140 -0
- data/vendor/assets/javascripts/picker.date.js +957 -0
- data/vendor/assets/javascripts/picker.js +785 -0
- data/vendor/assets/javascripts/picker.time.js +651 -0
- data/vendor/assets/javascripts/rainbow-custom.min.js +13 -0
- data/vendor/assets/javascripts/responsive-tables.js +67 -0
- data/vendor/assets/javascripts/responsiveslides.js +391 -0
- data/vendor/assets/javascripts/tooltip.js +353 -0
- data/vendor/assets/stylesheets/furatto.scss +101 -0
- data/vendor/assets/stylesheets/furatto/_alerts.scss +81 -0
- data/vendor/assets/stylesheets/furatto/_base.scss +187 -0
- data/vendor/assets/stylesheets/furatto/_buttons.scss +100 -0
- data/vendor/assets/stylesheets/furatto/_code.scss +66 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.date.scss +266 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.scss +158 -0
- data/vendor/assets/stylesheets/furatto/_date_picker.time.scss +122 -0
- data/vendor/assets/stylesheets/furatto/_dropdown.scss +261 -0
- data/vendor/assets/stylesheets/furatto/_font-awesome-ie7.scss +1953 -0
- data/vendor/assets/stylesheets/furatto/_fonts.scss +614 -0
- data/vendor/assets/stylesheets/furatto/_footer.scss +44 -0
- data/vendor/assets/stylesheets/furatto/_forms.scss +290 -0
- data/vendor/assets/stylesheets/furatto/_grid.scss +56 -0
- data/vendor/assets/stylesheets/furatto/_images.scss +44 -0
- data/vendor/assets/stylesheets/furatto/_labels.scss +43 -0
- data/vendor/assets/stylesheets/furatto/_layout.scss +0 -0
- data/vendor/assets/stylesheets/furatto/_left_navbar.scss +100 -0
- data/vendor/assets/stylesheets/furatto/_mixins.scss +283 -0
- data/vendor/assets/stylesheets/furatto/_modal.scss +103 -0
- data/vendor/assets/stylesheets/furatto/_nav.scss +106 -0
- data/vendor/assets/stylesheets/furatto/_navbar.scss +187 -0
- data/vendor/assets/stylesheets/furatto/_pagination.scss +158 -0
- data/vendor/assets/stylesheets/furatto/_responsive-1200px-min.scss +21 -0
- data/vendor/assets/stylesheets/furatto/_responsive-767px-max.scss +82 -0
- data/vendor/assets/stylesheets/furatto/_responsive-768px-979px.scss +23 -0
- data/vendor/assets/stylesheets/furatto/_responsive_navbar.scss +184 -0
- data/vendor/assets/stylesheets/furatto/_responsive_tables.scss +28 -0
- data/vendor/assets/stylesheets/furatto/_responsiveslides.scss +202 -0
- data/vendor/assets/stylesheets/furatto/_select.scss +191 -0
- data/vendor/assets/stylesheets/furatto/_tables.scss +90 -0
- data/vendor/assets/stylesheets/furatto/_tags.scss +107 -0
- data/vendor/assets/stylesheets/furatto/_toolbars.scss +116 -0
- data/vendor/assets/stylesheets/furatto/_tooltips.scss +143 -0
- data/vendor/assets/stylesheets/furatto/_typography.scss +266 -0
- data/vendor/assets/stylesheets/furatto/_variables.scss +628 -0
- data/vendor/assets/stylesheets/furatto/_vrt_navbar.scss +61 -0
- data/vendor/assets/stylesheets/furatto/icheck/_aero.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_all.scss +20 -0
- data/vendor/assets/stylesheets/furatto/icheck/_blue.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_flat.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_green.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_grey.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_orange.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_pink.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_purple.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_red.scss +64 -0
- data/vendor/assets/stylesheets/furatto/icheck/_yellow.scss +64 -0
- data/vendor/assets/stylesheets/normalize.scss +403 -0
- metadata +162 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
/**
|
2
|
+
* jQuery Avgrund Popin Plugin
|
3
|
+
* http://github.com/voronianski/jquery.avgrund.js/
|
4
|
+
*
|
5
|
+
* (c) 2012-2013 http://pixelhunter.me/
|
6
|
+
* MIT licensed
|
7
|
+
*/
|
8
|
+
|
9
|
+
(function ($) {
|
10
|
+
$.fn.avgrund = function (options) {
|
11
|
+
var defaults = {
|
12
|
+
width: 380, // max = 640
|
13
|
+
height: 280, // max = 350
|
14
|
+
showClose: false,
|
15
|
+
showCloseText: '',
|
16
|
+
closeByEscape: true,
|
17
|
+
closeByDocument: true,
|
18
|
+
holderClass: '',
|
19
|
+
overlayClass: '',
|
20
|
+
enableStackAnimation: false,
|
21
|
+
onBlurContainer: '',
|
22
|
+
openOnEvent: true,
|
23
|
+
setEvent: 'click',
|
24
|
+
onLoad: false,
|
25
|
+
onUnload: false,
|
26
|
+
template: '<p>This is test popin content!</p>'
|
27
|
+
};
|
28
|
+
|
29
|
+
options = $.extend(defaults, options);
|
30
|
+
|
31
|
+
return this.each(function() {
|
32
|
+
var self = $(this),
|
33
|
+
body = $('body'),
|
34
|
+
maxWidth = options.width > 640 ? 640 : options.width,
|
35
|
+
maxHeight = options.height > 350 ? 350 : options.height,
|
36
|
+
template = typeof options.template === 'function' ? options.template(self) : options.template;
|
37
|
+
|
38
|
+
body.addClass('avgrund-ready');
|
39
|
+
body.append('<div class="avgrund-overlay ' + options.overlayClass + '"></div>');
|
40
|
+
|
41
|
+
if (options.onBlurContainer !== '') {
|
42
|
+
$(options.onBlurContainer).addClass('avgrund-blur');
|
43
|
+
}
|
44
|
+
|
45
|
+
function onDocumentKeyup (e) {
|
46
|
+
if (options.closeByEscape) {
|
47
|
+
if (e.keyCode === 27) {
|
48
|
+
deactivate();
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
function onDocumentClick (e) {
|
54
|
+
if (options.closeByDocument) {
|
55
|
+
if ($(e.target).is('.avgrund-overlay, .avgrund-close')) {
|
56
|
+
e.preventDefault();
|
57
|
+
deactivate();
|
58
|
+
}
|
59
|
+
} else {
|
60
|
+
if ($(e.target).is('.avgrund-close')) {
|
61
|
+
e.preventDefault();
|
62
|
+
deactivate();
|
63
|
+
}
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
function activate () {
|
68
|
+
if (typeof options.onLoad === 'function') {
|
69
|
+
options.onLoad(self);
|
70
|
+
}
|
71
|
+
|
72
|
+
setTimeout(function() {
|
73
|
+
body.addClass('avgrund-active');
|
74
|
+
}, 100);
|
75
|
+
|
76
|
+
body.append('<div class="avgrund-popin ' + options.holderClass + '">' + template + '</div>');
|
77
|
+
|
78
|
+
$('.avgrund-popin').css({
|
79
|
+
'width': maxWidth + 'px',
|
80
|
+
'height': maxHeight + 'px',
|
81
|
+
'margin-left': '-' + (maxWidth / 2 + 10) + 'px',
|
82
|
+
'margin-top': '-' + (maxHeight / 2 + 10) + 'px'
|
83
|
+
});
|
84
|
+
|
85
|
+
if (options.showClose) {
|
86
|
+
$('.avgrund-popin').append('<a href="#" class="avgrund-close">' + options.showCloseText + '</a>');
|
87
|
+
}
|
88
|
+
|
89
|
+
if (options.enableStackAnimation) {
|
90
|
+
$('.avgrund-popin').addClass('stack');
|
91
|
+
}
|
92
|
+
|
93
|
+
body.bind('keyup', onDocumentKeyup);
|
94
|
+
body.bind('click', onDocumentClick);
|
95
|
+
}
|
96
|
+
|
97
|
+
function deactivate () {
|
98
|
+
body.unbind('keyup', onDocumentKeyup);
|
99
|
+
body.unbind('click', onDocumentClick);
|
100
|
+
|
101
|
+
body.removeClass('avgrund-active');
|
102
|
+
|
103
|
+
setTimeout(function() {
|
104
|
+
$('.avgrund-popin').remove();
|
105
|
+
}, 500);
|
106
|
+
|
107
|
+
if (typeof options.onUnload === 'function') {
|
108
|
+
options.onUnload(self);
|
109
|
+
}
|
110
|
+
}
|
111
|
+
|
112
|
+
if (options.openOnEvent) {
|
113
|
+
self.bind(options.setEvent, function (e) {
|
114
|
+
e.stopPropagation();
|
115
|
+
|
116
|
+
if ($(e.target).is('a')) {
|
117
|
+
e.preventDefault();
|
118
|
+
}
|
119
|
+
|
120
|
+
activate();
|
121
|
+
});
|
122
|
+
} else {
|
123
|
+
activate();
|
124
|
+
}
|
125
|
+
});
|
126
|
+
};
|
127
|
+
})(jQuery);
|
@@ -0,0 +1,400 @@
|
|
1
|
+
/**
|
2
|
+
* DropKick
|
3
|
+
*
|
4
|
+
* Highly customizable <select> lists
|
5
|
+
* https://github.com/JamieLottering/DropKick
|
6
|
+
*
|
7
|
+
* © 2011 Jamie Lottering <http://github.com/JamieLottering>
|
8
|
+
* <http://twitter.com/JamieLottering>
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
(function ($, window, document) {
|
12
|
+
|
13
|
+
document.documentElement.className = document.documentElement.className + ' dk_fouc';
|
14
|
+
|
15
|
+
var
|
16
|
+
// Public methods exposed to $.fn.dropkick()
|
17
|
+
methods = {},
|
18
|
+
|
19
|
+
// Cache every <select> element that gets dropkicked
|
20
|
+
lists = [],
|
21
|
+
|
22
|
+
// Convenience keys for keyboard navigation
|
23
|
+
keyMap = {
|
24
|
+
'left' : 37,
|
25
|
+
'up' : 38,
|
26
|
+
'right' : 39,
|
27
|
+
'down' : 40,
|
28
|
+
'enter' : 13
|
29
|
+
},
|
30
|
+
|
31
|
+
// HTML template for the dropdowns
|
32
|
+
dropdownTemplate = [
|
33
|
+
'<div class="dk_container {{ classname }}" id="dk_container_{{ id }}" tabindex="{{ tabindex }}">',
|
34
|
+
'<a class="dk_toggle">',
|
35
|
+
'<span class="dk_label">{{ label }}</span>',
|
36
|
+
'<span class="select-icon"></span>',
|
37
|
+
'</a>',
|
38
|
+
'<div class="dk_options">',
|
39
|
+
'<ul class="dk_options_inner">',
|
40
|
+
'</ul>',
|
41
|
+
'</div>',
|
42
|
+
'</div>'
|
43
|
+
].join(''),
|
44
|
+
|
45
|
+
// HTML template for dropdown options
|
46
|
+
optionTemplate = '<li class="{{ current }}"><a data-dk-dropdown-value="{{ value }}">{{ text }}</a></li>',
|
47
|
+
|
48
|
+
// Some nice default values
|
49
|
+
defaults = {
|
50
|
+
startSpeed : 100, // I recommend a high value here, I feel it makes the changes less noticeable to the user
|
51
|
+
theme : false,
|
52
|
+
change : false
|
53
|
+
},
|
54
|
+
|
55
|
+
// Make sure we only bind keydown on the document once
|
56
|
+
keysBound = false
|
57
|
+
;
|
58
|
+
|
59
|
+
// Called by using $('foo').dropkick();
|
60
|
+
methods.init = function (settings) {
|
61
|
+
settings = $.extend({}, defaults, settings);
|
62
|
+
|
63
|
+
return this.each(function () {
|
64
|
+
var
|
65
|
+
// The current <select> element
|
66
|
+
$select = $(this),
|
67
|
+
|
68
|
+
// Store a reference to the originally selected <option> element
|
69
|
+
$original = $select.find(':selected').first(),
|
70
|
+
|
71
|
+
// Save all of the <option> elements
|
72
|
+
$options = $select.find('option'),
|
73
|
+
|
74
|
+
// We store lots of great stuff using jQuery data
|
75
|
+
data = $select.data('dropkick') || {},
|
76
|
+
|
77
|
+
// This gets applied to the 'dk_container' element
|
78
|
+
id = $select.attr('id') || $select.attr('name'),
|
79
|
+
|
80
|
+
// This gets updated to be equal to the longest <option> element
|
81
|
+
width = settings.width || $select.outerWidth(),
|
82
|
+
|
83
|
+
// Check if we have a tabindex set or not
|
84
|
+
tabindex = $select.attr('tabindex') ? $select.attr('tabindex') : '',
|
85
|
+
|
86
|
+
// Check if we have a class name set or not
|
87
|
+
classname = $select.attr('class') ? $select.attr('class') : '',
|
88
|
+
|
89
|
+
// The completed dk_container element
|
90
|
+
$dk = false,
|
91
|
+
|
92
|
+
theme
|
93
|
+
;
|
94
|
+
|
95
|
+
// Dont do anything if we've already setup dropkick on this element
|
96
|
+
if (data.id) {
|
97
|
+
return $select;
|
98
|
+
} else {
|
99
|
+
data.settings = settings;
|
100
|
+
data.tabindex = tabindex;
|
101
|
+
data.classname = classname;
|
102
|
+
data.id = id;
|
103
|
+
data.$original = $original;
|
104
|
+
data.$select = $select;
|
105
|
+
data.value = _notBlank($select.val()) || _notBlank($original.attr('value'));
|
106
|
+
data.label = $original.text();
|
107
|
+
data.options = $options;
|
108
|
+
}
|
109
|
+
|
110
|
+
// Build the dropdown HTML
|
111
|
+
$dk = _build(dropdownTemplate, data);
|
112
|
+
|
113
|
+
// Make the dropdown fixed width if desired
|
114
|
+
$dk.find('.dk_toggle').css({
|
115
|
+
// Disable inline width since it should fill all available parrent space
|
116
|
+
// 'width' : width + 'px'
|
117
|
+
});
|
118
|
+
|
119
|
+
// Hide the <select> list and place our new one in front of it
|
120
|
+
$select.before($dk);
|
121
|
+
|
122
|
+
// Update the reference to $dk
|
123
|
+
$dk = $('#dk_container_' + id).addClass('dk_shown');
|
124
|
+
|
125
|
+
// Save the current theme
|
126
|
+
theme = settings.theme ? settings.theme : 'default';
|
127
|
+
$dk.addClass('dk_theme_' + theme);
|
128
|
+
data.theme = theme;
|
129
|
+
|
130
|
+
// Save the updated $dk reference into our data object
|
131
|
+
data.$dk = $dk;
|
132
|
+
|
133
|
+
// Save the dropkick data onto the <select> element
|
134
|
+
$select.data('dropkick', data);
|
135
|
+
|
136
|
+
// Do the same for the dropdown, but add a few helpers
|
137
|
+
$dk.data('dropkick', data);
|
138
|
+
|
139
|
+
lists[lists.length] = $select;
|
140
|
+
|
141
|
+
// Focus events
|
142
|
+
$dk.bind('focus.dropkick', function (e) {
|
143
|
+
$dk.addClass('dk_focus');
|
144
|
+
}).bind('blur.dropkick', function (e) {
|
145
|
+
$dk.removeClass('dk_open dk_focus');
|
146
|
+
});
|
147
|
+
|
148
|
+
setTimeout(function () {
|
149
|
+
$select.hide();
|
150
|
+
}, 0);
|
151
|
+
});
|
152
|
+
};
|
153
|
+
|
154
|
+
// Allows dynamic theme changes
|
155
|
+
methods.theme = function (newTheme) {
|
156
|
+
var
|
157
|
+
$select = $(this),
|
158
|
+
list = $select.data('dropkick'),
|
159
|
+
$dk = list.$dk,
|
160
|
+
oldtheme = 'dk_theme_' + list.theme
|
161
|
+
;
|
162
|
+
|
163
|
+
$dk.removeClass(oldtheme).addClass('dk_theme_' + newTheme);
|
164
|
+
|
165
|
+
list.theme = newTheme;
|
166
|
+
};
|
167
|
+
|
168
|
+
// Reset all <selects and dropdowns in our lists array
|
169
|
+
methods.reset = function () {
|
170
|
+
for (var i = 0, l = lists.length; i < l; i++) {
|
171
|
+
var
|
172
|
+
listData = lists[i].data('dropkick'),
|
173
|
+
$dk = listData.$dk,
|
174
|
+
$current = $dk.find('li').first()
|
175
|
+
;
|
176
|
+
|
177
|
+
$dk.find('.dk_label').text(listData.label);
|
178
|
+
$dk.find('.dk_options_inner').animate({ scrollTop: 0 }, 0);
|
179
|
+
|
180
|
+
_setCurrent($current, $dk);
|
181
|
+
_updateFields($current, $dk, true);
|
182
|
+
}
|
183
|
+
};
|
184
|
+
|
185
|
+
// Expose the plugin
|
186
|
+
$.fn.dropkick = function (method) {
|
187
|
+
if (methods[method]) {
|
188
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
189
|
+
} else if (typeof method === 'object' || ! method) {
|
190
|
+
return methods.init.apply(this, arguments);
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
// private
|
195
|
+
function _handleKeyBoardNav(e, $dk) {
|
196
|
+
var
|
197
|
+
code = e.keyCode,
|
198
|
+
data = $dk.data('dropkick'),
|
199
|
+
options = $dk.find('.dk_options'),
|
200
|
+
open = $dk.hasClass('dk_open'),
|
201
|
+
current = $dk.find('.dk_option_current'),
|
202
|
+
first = options.find('li').first(),
|
203
|
+
last = options.find('li').last(),
|
204
|
+
next,
|
205
|
+
prev
|
206
|
+
;
|
207
|
+
|
208
|
+
switch (code) {
|
209
|
+
case keyMap.enter:
|
210
|
+
if (open) {
|
211
|
+
_updateFields(current.find('a'), $dk);
|
212
|
+
_closeDropdown($dk);
|
213
|
+
} else {
|
214
|
+
_openDropdown($dk);
|
215
|
+
}
|
216
|
+
e.preventDefault();
|
217
|
+
break;
|
218
|
+
|
219
|
+
case keyMap.up:
|
220
|
+
prev = current.prev('li');
|
221
|
+
if (open) {
|
222
|
+
if (prev.length) {
|
223
|
+
_setCurrent(prev, $dk);
|
224
|
+
} else {
|
225
|
+
_setCurrent(last, $dk);
|
226
|
+
}
|
227
|
+
} else {
|
228
|
+
_openDropdown($dk);
|
229
|
+
}
|
230
|
+
e.preventDefault();
|
231
|
+
break;
|
232
|
+
|
233
|
+
case keyMap.down:
|
234
|
+
if (open) {
|
235
|
+
next = current.next('li').first();
|
236
|
+
if (next.length) {
|
237
|
+
_setCurrent(next, $dk);
|
238
|
+
} else {
|
239
|
+
_setCurrent(first, $dk);
|
240
|
+
}
|
241
|
+
} else {
|
242
|
+
_openDropdown($dk);
|
243
|
+
}
|
244
|
+
e.preventDefault();
|
245
|
+
break;
|
246
|
+
|
247
|
+
default:
|
248
|
+
break;
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
// Update the <select> value, and the dropdown label
|
253
|
+
function _updateFields(option, $dk, reset) {
|
254
|
+
var value, label, data;
|
255
|
+
|
256
|
+
value = option.attr('data-dk-dropdown-value');
|
257
|
+
label = option.text();
|
258
|
+
data = $dk.data('dropkick');
|
259
|
+
|
260
|
+
$select = data.$select;
|
261
|
+
$select.val(value);
|
262
|
+
|
263
|
+
$dk.find('.dk_label').text(label);
|
264
|
+
|
265
|
+
reset = reset || false;
|
266
|
+
|
267
|
+
if (data.settings.change && !reset) {
|
268
|
+
data.settings.change.call($select, value, label);
|
269
|
+
}
|
270
|
+
}
|
271
|
+
|
272
|
+
// Set the currently selected option
|
273
|
+
function _setCurrent($current, $dk) {
|
274
|
+
$dk.find('.dk_option_current').removeClass('dk_option_current');
|
275
|
+
$current.addClass('dk_option_current');
|
276
|
+
|
277
|
+
_setScrollPos($dk, $current);
|
278
|
+
}
|
279
|
+
|
280
|
+
function _setScrollPos($dk, anchor) {
|
281
|
+
var height = anchor.prevAll('li').outerHeight() * anchor.prevAll('li').length;
|
282
|
+
$dk.find('.dk_options_inner').animate({ scrollTop: height + 'px' }, 0);
|
283
|
+
}
|
284
|
+
|
285
|
+
// Close a dropdown
|
286
|
+
function _closeDropdown($dk) {
|
287
|
+
$dk.removeClass('dk_open');
|
288
|
+
}
|
289
|
+
|
290
|
+
// Open a dropdown
|
291
|
+
function _openDropdown($dk) {
|
292
|
+
var data = $dk.data('dropkick');
|
293
|
+
$dk.find('.dk_options').css({ top : $dk.find('.dk_toggle').outerHeight() - 1 });
|
294
|
+
$dk.toggleClass('dk_open');
|
295
|
+
|
296
|
+
}
|
297
|
+
|
298
|
+
/**
|
299
|
+
* Turn the dropdownTemplate into a jQuery object and fill in the variables.
|
300
|
+
*/
|
301
|
+
function _build (tpl, view) {
|
302
|
+
var
|
303
|
+
// Template for the dropdown
|
304
|
+
template = tpl,
|
305
|
+
// Holder of the dropdowns options
|
306
|
+
options = [],
|
307
|
+
$dk
|
308
|
+
;
|
309
|
+
|
310
|
+
template = template.replace('{{ id }}', view.id);
|
311
|
+
template = template.replace('{{ label }}', view.label);
|
312
|
+
template = template.replace('{{ tabindex }}', view.tabindex);
|
313
|
+
template = template.replace('{{ classname }}', view.classname);
|
314
|
+
|
315
|
+
if (view.options && view.options.length) {
|
316
|
+
for (var i = 0, l = view.options.length; i < l; i++) {
|
317
|
+
var
|
318
|
+
$option = $(view.options[i]),
|
319
|
+
current = 'dk_option_current',
|
320
|
+
oTemplate = optionTemplate
|
321
|
+
;
|
322
|
+
|
323
|
+
oTemplate = oTemplate.replace('{{ value }}', $option.val());
|
324
|
+
oTemplate = oTemplate.replace('{{ current }}', (_notBlank($option.val()) === view.value) ? current : '');
|
325
|
+
oTemplate = oTemplate.replace('{{ text }}', $option.text());
|
326
|
+
|
327
|
+
options[options.length] = oTemplate;
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
$dk = $(template);
|
332
|
+
$dk.find('.dk_options_inner').html(options.join(''));
|
333
|
+
|
334
|
+
return $dk;
|
335
|
+
}
|
336
|
+
|
337
|
+
function _notBlank(text) {
|
338
|
+
return ($.trim(text).length > 0) ? text : false;
|
339
|
+
}
|
340
|
+
|
341
|
+
$(function () {
|
342
|
+
|
343
|
+
// Handle click events on the dropdown toggler
|
344
|
+
$(document).on('click', '.dk_toggle', function (e) {
|
345
|
+
var $dk = $(this).parents('.dk_container').first();
|
346
|
+
|
347
|
+
_openDropdown($dk);
|
348
|
+
|
349
|
+
if ("ontouchstart" in window) {
|
350
|
+
$dk.addClass('dk_touch');
|
351
|
+
$dk.find('.dk_options_inner').addClass('scrollable vertical');
|
352
|
+
}
|
353
|
+
|
354
|
+
e.preventDefault();
|
355
|
+
return false;
|
356
|
+
});
|
357
|
+
|
358
|
+
// Handle click events on individual dropdown options
|
359
|
+
$(document).on('click', '.dk_options a', function (e) {
|
360
|
+
var
|
361
|
+
$option = $(this),
|
362
|
+
$dk = $option.parents('.dk_container').first(),
|
363
|
+
data = $dk.data('dropkick')
|
364
|
+
;
|
365
|
+
|
366
|
+
_closeDropdown($dk);
|
367
|
+
_updateFields($option, $dk);
|
368
|
+
_setCurrent($option.parent(), $dk);
|
369
|
+
|
370
|
+
e.preventDefault();
|
371
|
+
return false;
|
372
|
+
});
|
373
|
+
|
374
|
+
// Setup keyboard nav
|
375
|
+
$(document).bind('keydown.dk_nav', function (e) {
|
376
|
+
var
|
377
|
+
// Look for an open dropdown...
|
378
|
+
$open = $('.dk_container.dk_open'),
|
379
|
+
|
380
|
+
// Look for a focused dropdown
|
381
|
+
$focused = $('.dk_container.dk_focus'),
|
382
|
+
|
383
|
+
// Will be either $open, $focused, or null
|
384
|
+
$dk = null
|
385
|
+
;
|
386
|
+
|
387
|
+
// If we have an open dropdown, key events should get sent to that one
|
388
|
+
if ($open.length) {
|
389
|
+
$dk = $open;
|
390
|
+
} else if ($focused.length && !$open.length) {
|
391
|
+
// But if we have no open dropdowns, use the focused dropdown instead
|
392
|
+
$dk = $focused;
|
393
|
+
}
|
394
|
+
|
395
|
+
if ($dk) {
|
396
|
+
_handleKeyBoardNav(e, $dk);
|
397
|
+
}
|
398
|
+
});
|
399
|
+
});
|
400
|
+
})(jQuery, window, document);
|