flatui-rails 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ //= require jquery.dropkick
2
+ //= require custom_checkbox_and_radio
3
+ //= require custom_radio
4
+ //= require jquery.tagsinput
5
+ //= require bootstrap-tooltip
6
+ //= require jquery.placeholder
7
+ //= require run_everything
@@ -0,0 +1,8 @@
1
+ /*
2
+ HTML5 Shiv v3.6.2pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
3
+ */
4
+ (function(l,f){function m(){var a=e.elements;return"string"==typeof a?a.split(" "):a}function i(a){var b=n[a[o]];b||(b={},h++,a[o]=h,n[h]=b);return b}function p(a,b,c){b||(b=f);if(g)return b.createElement(a);c||(c=i(b));b=c.cache[a]?c.cache[a].cloneNode():r.test(a)?(c.cache[a]=c.createElem(a)).cloneNode():c.createElem(a);return b.canHaveChildren&&!s.test(a)?c.frag.appendChild(b):b}function t(a,b){if(!b.cache)b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag();
5
+ a.createElement=function(c){return!e.shivMethods?b.createElem(c):p(c,a,b)};a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+m().join().replace(/\w+/g,function(a){b.createElem(a);b.frag.createElement(a);return'c("'+a+'")'})+");return n}")(e,b.frag)}function q(a){a||(a=f);var b=i(a);if(e.shivCSS&&!j&&!b.hasCSS){var c,d=a;c=d.createElement("p");d=d.getElementsByTagName("head")[0]||d.documentElement;c.innerHTML="x<style>article,aside,figcaption,figure,footer,header,hgroup,nav,section{display:block}mark{background:#FF0;color:#000}</style>";
6
+ c=d.insertBefore(c.lastChild,d.firstChild);b.hasCSS=!!c}g||t(a,b);return a}var k=l.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,r=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,j,o="_html5shiv",h=0,n={},g;(function(){try{var a=f.createElement("a");a.innerHTML="<xyz></xyz>";j="hidden"in a;var b;if(!(b=1==a.childNodes.length)){f.createElement("a");var c=f.createDocumentFragment();b="undefined"==typeof c.cloneNode||
7
+ "undefined"==typeof c.createDocumentFragment||"undefined"==typeof c.createElement}g=b}catch(d){g=j=!0}})();var e={elements:k.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",version:"3.6.2pre",shivCSS:!1!==k.shivCSS,supportsUnknownElements:g,shivMethods:!1!==k.shivMethods,type:"default",shivDocument:q,createElement:p,createDocumentFragment:function(a,b){a||(a=f);if(g)return a.createDocumentFragment();
8
+ for(var b=b||i(a),c=b.frag.cloneNode(),d=0,e=m(),h=e.length;d<h;d++)c.createElement(e[d]);return c}};l.html5=e;q(f)})(this,document);
@@ -0,0 +1,44 @@
1
+ /* Use this script if you need to support IE 7 and IE 6. */
2
+
3
+ window.onload = function() {
4
+ function addIcon(el, entity) {
5
+ var html = el.innerHTML;
6
+ el.innerHTML = '<span style="font-family: \'Flat-UI-Icons-16\'">' + entity + '</span>' + html;
7
+ }
8
+ var icons = {
9
+ 'fui-volume-16' : '&#xe000;',
10
+ 'fui-video-16' : '&#xe001;',
11
+ 'fui-time-16' : '&#xe002;',
12
+ 'fui-settings-16' : '&#xe003;',
13
+ 'fui-plus-16' : '&#xe004;',
14
+ 'fui-new-16' : '&#xe005;',
15
+ 'fui-menu-16' : '&#xe006;',
16
+ 'fui-man-16' : '&#xe007;',
17
+ 'fui-mail-16' : '&#xe008;',
18
+ 'fui-lock-16' : '&#xe009;',
19
+ 'fui-location-16' : '&#xe00a;',
20
+ 'fui-heart-16' : '&#xe00b;',
21
+ 'fui-eye-16' : '&#xe00c;',
22
+ 'fui-cross-16' : '&#xe00d;',
23
+ 'fui-cmd-16' : '&#xe00e;',
24
+ 'fui-checkround-16' : '&#xe00f;',
25
+ 'fui-checkmark-16' : '&#xe010;',
26
+ 'fui-camera-16' : '&#xe011;',
27
+ 'fui-calendar-16' : '&#xe012;',
28
+ 'fui-bubble-16' : '&#xe013;'
29
+ },
30
+ els = document.getElementsByTagName('*'),
31
+ i, attr, html, c, el;
32
+ for (i = 0; i < els.length; i += 1) {
33
+ el = els[i];
34
+ attr = el.getAttribute('data-icon');
35
+ if (attr) {
36
+ addIcon(el, attr);
37
+ }
38
+ c = el.className;
39
+ c = c.match(/fui-[^\s'"]+/);
40
+ if (c && icons[c[0]]) {
41
+ addIcon(el, icons[c[0]]);
42
+ }
43
+ }
44
+ };
@@ -0,0 +1,409 @@
1
+ /**
2
+ * DropKick
3
+ *
4
+ * Highly customizable <select> lists
5
+ * https://github.com/JamieLottering/DropKick
6
+ *
7
+ * &copy; 2011 Jamie Lottering <http://github.com/JamieLottering>
8
+ * <http://twitter.com/JamieLottering>
9
+ *
10
+ */
11
+ (function ($, window, document) {
12
+
13
+ var ie6 = false;
14
+
15
+ // Help prevent flashes of unstyled content
16
+ if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
17
+ ie6 = true;
18
+ } else {
19
+ document.documentElement.className = document.documentElement.className + ' dk_fouc';
20
+ }
21
+
22
+ var
23
+ // Public methods exposed to $.fn.dropkick()
24
+ methods = {},
25
+
26
+ // Cache every <select> element that gets dropkicked
27
+ lists = [],
28
+
29
+ // Convenience keys for keyboard navigation
30
+ keyMap = {
31
+ 'left' : 37,
32
+ 'up' : 38,
33
+ 'right' : 39,
34
+ 'down' : 40,
35
+ 'enter' : 13
36
+ },
37
+
38
+ // HTML template for the dropdowns
39
+ dropdownTemplate = [
40
+ '<div class="dk_container {{ classname }}" id="dk_container_{{ id }}" tabindex="{{ tabindex }}">',
41
+ '<a class="dk_toggle">',
42
+ '<span class="dk_label">{{ label }}</span>',
43
+ '<span class="select-icon"></span>',
44
+ '</a>',
45
+ '<div class="dk_options">',
46
+ '<ul class="dk_options_inner">',
47
+ '</ul>',
48
+ '</div>',
49
+ '</div>'
50
+ ].join(''),
51
+
52
+ // HTML template for dropdown options
53
+ optionTemplate = '<li class="{{ current }}"><a data-dk-dropdown-value="{{ value }}">{{ text }}</a></li>',
54
+
55
+ // Some nice default values
56
+ defaults = {
57
+ startSpeed : 100, // I recommend a high value here, I feel it makes the changes less noticeable to the user
58
+ theme : false,
59
+ change : false
60
+ },
61
+
62
+ // Make sure we only bind keydown on the document once
63
+ keysBound = false
64
+ ;
65
+
66
+ // Called by using $('foo').dropkick();
67
+ methods.init = function (settings) {
68
+ settings = $.extend({}, defaults, settings);
69
+
70
+ return this.each(function () {
71
+ var
72
+ // The current <select> element
73
+ $select = $(this),
74
+
75
+ // Store a reference to the originally selected <option> element
76
+ $original = $select.find(':selected').first(),
77
+
78
+ // Save all of the <option> elements
79
+ $options = $select.find('option'),
80
+
81
+ // We store lots of great stuff using jQuery data
82
+ data = $select.data('dropkick') || {},
83
+
84
+ // This gets applied to the 'dk_container' element
85
+ id = $select.attr('id') || $select.attr('name'),
86
+
87
+ // This gets updated to be equal to the longest <option> element
88
+ width = settings.width || $select.outerWidth(),
89
+
90
+ // Check if we have a tabindex set or not
91
+ tabindex = $select.attr('tabindex') ? $select.attr('tabindex') : '',
92
+
93
+ // Check if we have a class name set or not
94
+ classname = $select.attr('class') ? $select.attr('class') : '',
95
+
96
+ // The completed dk_container element
97
+ $dk = false,
98
+
99
+ theme
100
+ ;
101
+
102
+ // Dont do anything if we've already setup dropkick on this element
103
+ if (data.id) {
104
+ return $select;
105
+ } else {
106
+ data.settings = settings;
107
+ data.tabindex = tabindex;
108
+ data.classname = classname;
109
+ data.id = id;
110
+ data.$original = $original;
111
+ data.$select = $select;
112
+ data.value = _notBlank($select.val()) || _notBlank($original.attr('value'));
113
+ data.label = $original.text();
114
+ data.options = $options;
115
+ }
116
+
117
+ // Build the dropdown HTML
118
+ $dk = _build(dropdownTemplate, data);
119
+
120
+ // Make the dropdown fixed width if desired
121
+ $dk.find('.dk_toggle').css({
122
+ // Disable inline width since it should fill all available parrent space
123
+ // 'width' : width + 'px'
124
+ });
125
+
126
+ // Hide the <select> list and place our new one in front of it
127
+ $select.before($dk);
128
+
129
+ // Update the reference to $dk
130
+ $dk = $('#dk_container_' + id).addClass('dk_shown');
131
+
132
+ // Save the current theme
133
+ theme = settings.theme ? settings.theme : 'default';
134
+ $dk.addClass('dk_theme_' + theme);
135
+ data.theme = theme;
136
+
137
+ // Save the updated $dk reference into our data object
138
+ data.$dk = $dk;
139
+
140
+ // Save the dropkick data onto the <select> element
141
+ $select.data('dropkick', data);
142
+
143
+ // Do the same for the dropdown, but add a few helpers
144
+ $dk.data('dropkick', data);
145
+
146
+ lists[lists.length] = $select;
147
+
148
+ // Focus events
149
+ $dk.bind('focus.dropkick', function (e) {
150
+ $dk.addClass('dk_focus');
151
+ }).bind('blur.dropkick', function (e) {
152
+ $dk.removeClass('dk_open dk_focus');
153
+ });
154
+
155
+ setTimeout(function () {
156
+ $select.hide();
157
+ }, 0);
158
+ });
159
+ };
160
+
161
+ // Allows dynamic theme changes
162
+ methods.theme = function (newTheme) {
163
+ var
164
+ $select = $(this),
165
+ list = $select.data('dropkick'),
166
+ $dk = list.$dk,
167
+ oldtheme = 'dk_theme_' + list.theme
168
+ ;
169
+
170
+ $dk.removeClass(oldtheme).addClass('dk_theme_' + newTheme);
171
+
172
+ list.theme = newTheme;
173
+ };
174
+
175
+ // Reset all <selects and dropdowns in our lists array
176
+ methods.reset = function () {
177
+ for (var i = 0, l = lists.length; i < l; i++) {
178
+ var
179
+ listData = lists[i].data('dropkick'),
180
+ $dk = listData.$dk,
181
+ $current = $dk.find('li').first()
182
+ ;
183
+
184
+ $dk.find('.dk_label').text(listData.label);
185
+ $dk.find('.dk_options_inner').animate({ scrollTop: 0 }, 0);
186
+
187
+ _setCurrent($current, $dk);
188
+ _updateFields($current, $dk, true);
189
+ }
190
+ };
191
+
192
+ // Expose the plugin
193
+ $.fn.dropkick = function (method) {
194
+ if (!ie6) {
195
+ if (methods[method]) {
196
+ return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
197
+ } else if (typeof method === 'object' || ! method) {
198
+ return methods.init.apply(this, arguments);
199
+ }
200
+ }
201
+ };
202
+
203
+ // private
204
+ function _handleKeyBoardNav(e, $dk) {
205
+ var
206
+ code = e.keyCode,
207
+ data = $dk.data('dropkick'),
208
+ options = $dk.find('.dk_options'),
209
+ open = $dk.hasClass('dk_open'),
210
+ current = $dk.find('.dk_option_current'),
211
+ first = options.find('li').first(),
212
+ last = options.find('li').last(),
213
+ next,
214
+ prev
215
+ ;
216
+
217
+ switch (code) {
218
+ case keyMap.enter:
219
+ if (open) {
220
+ _updateFields(current.find('a'), $dk);
221
+ _closeDropdown($dk);
222
+ } else {
223
+ _openDropdown($dk);
224
+ }
225
+ e.preventDefault();
226
+ break;
227
+
228
+ case keyMap.up:
229
+ prev = current.prev('li');
230
+ if (open) {
231
+ if (prev.length) {
232
+ _setCurrent(prev, $dk);
233
+ } else {
234
+ _setCurrent(last, $dk);
235
+ }
236
+ } else {
237
+ _openDropdown($dk);
238
+ }
239
+ e.preventDefault();
240
+ break;
241
+
242
+ case keyMap.down:
243
+ if (open) {
244
+ next = current.next('li').first();
245
+ if (next.length) {
246
+ _setCurrent(next, $dk);
247
+ } else {
248
+ _setCurrent(first, $dk);
249
+ }
250
+ } else {
251
+ _openDropdown($dk);
252
+ }
253
+ e.preventDefault();
254
+ break;
255
+
256
+ default:
257
+ break;
258
+ }
259
+ }
260
+
261
+ // Update the <select> value, and the dropdown label
262
+ function _updateFields(option, $dk, reset) {
263
+ var value, label, data;
264
+
265
+ value = option.attr('data-dk-dropdown-value');
266
+ label = option.text();
267
+ data = $dk.data('dropkick');
268
+
269
+ $select = data.$select;
270
+ $select.val(value);
271
+
272
+ $dk.find('.dk_label').text(label);
273
+
274
+ reset = reset || false;
275
+
276
+ if (data.settings.change && !reset) {
277
+ data.settings.change.call($select, value, label);
278
+ }
279
+ }
280
+
281
+ // Set the currently selected option
282
+ function _setCurrent($current, $dk) {
283
+ $dk.find('.dk_option_current').removeClass('dk_option_current');
284
+ $current.addClass('dk_option_current');
285
+
286
+ _setScrollPos($dk, $current);
287
+ }
288
+
289
+ function _setScrollPos($dk, anchor) {
290
+ var height = anchor.prevAll('li').outerHeight() * anchor.prevAll('li').length;
291
+ $dk.find('.dk_options_inner').animate({ scrollTop: height + 'px' }, 0);
292
+ }
293
+
294
+ // Close a dropdown
295
+ function _closeDropdown($dk) {
296
+ $dk.removeClass('dk_open');
297
+ }
298
+
299
+ // Open a dropdown
300
+ function _openDropdown($dk) {
301
+ var data = $dk.data('dropkick');
302
+ $dk.find('.dk_options').css({ top : $dk.find('.dk_toggle').outerHeight() - 1 });
303
+ $dk.toggleClass('dk_open');
304
+
305
+ }
306
+
307
+ /**
308
+ * Turn the dropdownTemplate into a jQuery object and fill in the variables.
309
+ */
310
+ function _build (tpl, view) {
311
+ var
312
+ // Template for the dropdown
313
+ template = tpl,
314
+ // Holder of the dropdowns options
315
+ options = [],
316
+ $dk
317
+ ;
318
+
319
+ template = template.replace('{{ id }}', view.id);
320
+ template = template.replace('{{ label }}', view.label);
321
+ template = template.replace('{{ tabindex }}', view.tabindex);
322
+ template = template.replace('{{ classname }}', view.classname);
323
+
324
+ if (view.options && view.options.length) {
325
+ for (var i = 0, l = view.options.length; i < l; i++) {
326
+ var
327
+ $option = $(view.options[i]),
328
+ current = 'dk_option_current',
329
+ oTemplate = optionTemplate
330
+ ;
331
+
332
+ oTemplate = oTemplate.replace('{{ value }}', $option.val());
333
+ oTemplate = oTemplate.replace('{{ current }}', (_notBlank($option.val()) === view.value) ? current : '');
334
+ oTemplate = oTemplate.replace('{{ text }}', $option.text());
335
+
336
+ options[options.length] = oTemplate;
337
+ }
338
+ }
339
+
340
+ $dk = $(template);
341
+ $dk.find('.dk_options_inner').html(options.join(''));
342
+
343
+ return $dk;
344
+ }
345
+
346
+ function _notBlank(text) {
347
+ return ($.trim(text).length > 0) ? text : false;
348
+ }
349
+
350
+ $(function () {
351
+
352
+ // Handle click events on the dropdown toggler
353
+ $('.dk_toggle').live('click', function (e) {
354
+ var $dk = $(this).parents('.dk_container').first();
355
+
356
+ _openDropdown($dk);
357
+
358
+ if ("ontouchstart" in window) {
359
+ $dk.addClass('dk_touch');
360
+ $dk.find('.dk_options_inner').addClass('scrollable vertical');
361
+ }
362
+
363
+ e.preventDefault();
364
+ return false;
365
+ });
366
+
367
+ // Handle click events on individual dropdown options
368
+ $('.dk_options a').live(($.browser.msie ? 'mousedown' : 'click'), function (e) {
369
+ var
370
+ $option = $(this),
371
+ $dk = $option.parents('.dk_container').first(),
372
+ data = $dk.data('dropkick')
373
+ ;
374
+
375
+ _closeDropdown($dk);
376
+ _updateFields($option, $dk);
377
+ _setCurrent($option.parent(), $dk);
378
+
379
+ e.preventDefault();
380
+ return false;
381
+ });
382
+
383
+ // Setup keyboard nav
384
+ $(document).bind('keydown.dk_nav', function (e) {
385
+ var
386
+ // Look for an open dropdown...
387
+ $open = $('.dk_container.dk_open'),
388
+
389
+ // Look for a focused dropdown
390
+ $focused = $('.dk_container.dk_focus'),
391
+
392
+ // Will be either $open, $focused, or null
393
+ $dk = null
394
+ ;
395
+
396
+ // If we have an open dropdown, key events should get sent to that one
397
+ if ($open.length) {
398
+ $dk = $open;
399
+ } else if ($focused.length && !$open.length) {
400
+ // But if we have no open dropdowns, use the focused dropdown instead
401
+ $dk = $focused;
402
+ }
403
+
404
+ if ($dk) {
405
+ _handleKeyBoardNav(e, $dk);
406
+ }
407
+ });
408
+ });
409
+ })(jQuery, window, document);