flatui 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,28 @@
1
+ var toggleHandler = function(toggle) {
2
+ var toggle = toggle;
3
+ var radio = $(toggle).find("input");
4
+
5
+ var checkToggleState = function() {
6
+ if (radio.eq(0).is(":checked")) {
7
+ $(toggle).removeClass("toggle-off");
8
+ } else {
9
+ $(toggle).addClass("toggle-off");
10
+ }
11
+ };
12
+
13
+ checkToggleState();
14
+
15
+ radio.eq(0).click(function() {
16
+ $(toggle).toggleClass("toggle-off");
17
+ });
18
+
19
+ radio.eq(1).click(function() {
20
+ $(toggle).toggleClass("toggle-off");
21
+ });
22
+ };
23
+
24
+ $(document).ready(function() {
25
+ $(".toggle").each(function(index, toggle) {
26
+ toggleHandler(toggle);
27
+ });
28
+ });
@@ -0,0 +1,51 @@
1
+ // Some general UI pack related JS
2
+
3
+ $(function () {
4
+ // Custom selects
5
+ $("select").dropkick();
6
+ });
7
+
8
+ $(document).ready(function() {
9
+ // Todo list
10
+ $(".todo li").click(function() {
11
+ $(this).toggleClass("todo-done");
12
+ });
13
+
14
+ // Init tooltips
15
+ $("[data-toggle=tooltip]").tooltip("show");
16
+
17
+ // Init tags input
18
+ $("#tagsinput").tagsInput();
19
+
20
+ // Init jQuery UI slider
21
+ $("#slider").slider({
22
+ min: 1,
23
+ max: 5,
24
+ value: 2,
25
+ orientation: "horizontal",
26
+ range: "min",
27
+ });
28
+
29
+ // JS input/textarea placeholder
30
+ $("input, textarea").placeholder();
31
+
32
+ // Make pagination demo work
33
+ $(".pagination a").click(function() {
34
+ if (!$(this).parent().hasClass("previous") && !$(this).parent().hasClass("next")) {
35
+ $(this).parent().siblings("li").removeClass("active");
36
+ $(this).parent().addClass("active");
37
+ }
38
+ });
39
+
40
+ $(".btn-group a").click(function() {
41
+ $(this).siblings().removeClass("active");
42
+ $(this).addClass("active");
43
+ });
44
+
45
+ // Disable link click not scroll top
46
+ $("a[href='#']").click(function() {
47
+ return false
48
+ });
49
+
50
+ });
51
+
@@ -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,400 @@
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
+ 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);