vendor/assets/javascripts/groundworkcss/groundwork.all.js in groundworkcss-rails-0.2.5 vs vendor/assets/javascripts/groundworkcss/groundwork.all.js in groundworkcss-rails-0.2.6

- old
+ new

@@ -1,13 +1,7 @@ // Generated by CoffeeScript 1.6.1 -/* -------------------------------------------- - Begin groundwork.coffee --------------------------------------------- -*/ - - /* * * GroundworkCSS JS by Gary Hepting - https://github.com/groundworkcss/groundwork * * Open source under the BSD License. @@ -15,285 +9,311 @@ * Copyright © 2013 Gary Hepting. All rights reserved. * */ +/* -------------------------------------------- + Begin jquery.modals.coffee +-------------------------------------------- +*/ + + +/* + * + * jQuery Modals by Gary Hepting + * https://github.com/ghepting/modal + * +*/ + + (function() { var equalizeColumns, limitPaginationItems; - $(document).ready(function() { - var delay, dropdown, menu, navitem; - equalizeColumns(); - delay = ''; - navitem = $('nav > ul > li'); - navitem.find('>a').on({ - focus: function(e) { - $('nav > ul > li').removeClass('on'); - return $('nav > ul > li > ul').hide(); - } + (function($) { + var elems, modals; + if ($('div#iframeModal').length < 1) { + $('body').append('<div class="iframe modal" id="iframeModal"><iframe marginheight="0" marginwidth="0" frameborder="0"></iframe></div>'); + $('div#iframeModal').prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>'); + } + $('a.modal').each(function() { + $(this).attr('data-url', $(this).attr('href')); + return $(this).attr('href', '#iframeModal'); }); - menu = $('nav > ul > li.menu'); - menu.on({ - mouseenter: function(e) { - if ($(window).width() > 768) { - clearTimeout(delay); - $('nav > ul > li').removeClass('on'); - $('nav > ul > li > ul').hide(); - return $(this).addClass('on'); + $('a.modal').on("click", function(e) { + $('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0" width="100%" height="100%" src="' + $(this).attr('data-url') + '"></iframe>'); + e.preventDefault(); + return false; + }); + elems = []; + $.fn.modal = function() { + this.each(function() { + var $this; + $(this).not('#iframeModal').wrapInner('<div class="modal-content"></div>'); + $(this).prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>').appendTo('body'); + $this = $(this); + return $('[href=#' + $(this).attr('id') + ']').on("click", function(e) { + modals.open($(this).attr('href'), $(this).hasClass('fullscreen')); + e.preventDefault(); + return false; + }); + }); + $('div.modal .close').on("click", function() { + return modals.close(); + }); + return $('div.modal .fullscreen').on("click", function() { + return modals.fullscreen($(this).parent('div.modal')); + }); + }; + modals = (function() { + var close, fullscreen, open; + $('body').addClass('modal-ready'); + if ($("#overlay").length < 1) { + $('body').append('<div id="overlay"></div>'); + } + $('#overlay, div.modal .close').bind("click", function(e) { + return close(); + }); + open = function(elem, fullscreen) { + $(window).bind("keydown", function(e) { + var keyCode; + keyCode = (e.which ? e.which : e.keyCode); + if (keyCode === 27) { + return close(); + } + }); + $(elem).addClass("active"); + if (!$(elem).hasClass('iframe')) { + $(elem).css({ + width: 'auto', + height: 'auto' + }); + $(elem).css({ + height: $(elem).outerHeight() + }); } - }, - mouseleave: function(e) { - if ($(window).width() > 768) { - return delay = setTimeout((function() { - $('nav > ul > li').removeClass('on'); - return $('nav > ul > li > ul').hide(); - }), 350); + $(elem).css({ + top: '50%', + left: '50%', + 'margin-top': ($(elem).outerHeight() / -2) + 'px', + 'margin-left': ($(elem).outerWidth() / -2) + 'px' + }); + setTimeout(function() { + return $('body').addClass("modal-active"); + }, 0); + setTimeout(function() { + return $('body').removeClass('modal-ready'); + }, 400); + if (fullscreen) { + modals.fullscreen(elem); } - }, - click: function(e) { - var $this; - if ($(window).width() < 768) { - if ($(e.target).parent('li.menu').size() > 0) { - $this = $(this); - $(this).children('ul').slideToggle(300, function() { - return $this.toggleClass('on'); + }; + close = function() { + var modal; + modal = $('div.modal.active'); + $(window).unbind("keydown"); + $('body').removeClass("modal-active").addClass('modal-ready'); + if (modal.hasClass('iframe')) { + $('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0"></iframe>'); + modal.css({ + width: '80%', + height: '80%' + }); + } else { + modal.css({ + width: 'auto', + height: 'auto' + }); + } + modal.css({ + top: '10%', + left: '10%', + 'max-width': '80%', + 'max-height': '80%', + 'margin-top': 0, + 'margin-left': 0 + }); + modal.removeClass("active").removeClass("fullscreen"); + $('i.fullscreen', modal).removeClass('icon-resize-small').addClass('icon-resize-full'); + }; + fullscreen = function(elem) { + if ($('div.modal.active').hasClass('fullscreen')) { + $('div.modal i.fullscreen').removeClass('icon-resize-small').addClass('icon-resize-full'); + if ($('div.modal.active').hasClass('iframe')) { + $('div.modal.active').css({ + width: '80%', + height: '80%' }); - e.preventDefault(); - return false; + } else { + $('div.modal.active').css({ + width: 'auto', + height: 'auto' + }); + $('div.modal.active').css({ + height: $('div.modal.active').outerHeight() + }); } - } - }, - tap: function(e) { - var $this; - if ($(e.target).parent('li.menu').size() > 0) { - $this = $(this); - $(this).children('ul').slideToggle(300, function() { - return $this.toggleClass('on'); + $('div.modal.active').removeClass('fullscreen').css({ + 'max-width': '80%', + 'max-height': '80%' }); - e.preventDefault(); - return false; + $('div.modal.active').delay(100).css({ + top: '50%', + left: '50%', + 'margin-top': ($('div.modal.active').outerHeight() / -2) + 'px', + 'margin-left': ($('div.modal.active').outerWidth() / -2) + 'px' + }); + } else { + $('div.modal i.fullscreen').addClass('icon-resize-small').removeClass('icon-resize-full'); + $('div.modal.active').addClass('fullscreen').css({ + top: 0, + left: 0, + 'margin-top': 0, + 'margin-left': 0, + width: '100%', + height: '100%', + 'max-width': '100%', + 'max-height': '100%' + }); } - } - }); - menu.find('>a').on({ - focus: function() { - return $(this).parent('li.menu').trigger('mouseenter'); - } - }); - menu.find('li:last-child > a').on({ - blur: function() { - return $(this).closest('li.menu').trigger('mouseleave'); - } - }); - dropdown = $('.dropdown'); - dropdown.on({ - focus: function() { - return $(this).addClass('on'); - } - }); - dropdown.find('li:last-child a').on({ - blur: function() { - return dropdown.filter('.on').removeClass('on'); - } - }); - $('body').on('click', function(e) { - if ($(e.target).hasClass('dropdown')) { - $(e.target).toggleClass('on'); - } else { - if (dropdown.filter('.on').length) { - dropdown.filter('.on').removeClass('on'); + }; + return { + open: open, + close: close, + fullscreen: fullscreen + }; + })(); + return $(window).resize(function() { + return $('div.modal.active').each(function() { + if (!$(this).hasClass('fullscreen')) { + $(this).removeClass('active').css({ + top: '50%', + left: '50%', + 'margin-top': ($(this).outerHeight() / -2) + 'px', + 'margin-left': ($(this).outerWidth() / -2) + 'px' + }).addClass('active'); + if (!$(this).hasClass('iframe')) { + $(this).css({ + height: 'auto' + }); + return $(this).css({ + height: $(this).outerHeight() + }); + } } - } - if (navitem.filter('.menu.on').length) { - return navitem.filter('.menu.on').removeClass('on'); - } + }); }); - limitPaginationItems(); - $('.pagination ul > li:not(.next, .prev) a').on('click', (function(e) { - $('.pagination ul > li:not(.next, .prev)').removeClass('active'); - $(this).parent('li').addClass('active'); - if ($(this).parent('li').hasClass('first')) { - $('.pagination ul > li.prev').addClass('disabled'); - } else { - $('.pagination ul > li.prev').removeClass('disabled'); - } - if ($(this).parent('li').hasClass('last')) { - $('.pagination ul > li.next').addClass('disabled'); - } else { - $('.pagination ul > li.next').removeClass('disabled'); - } - limitPaginationItems(); - e.preventDefault(); - return false; - })); - $('.pagination ul > li.prev:not(.disabled)').on('click', (function(e) { - var el; - $('.pagination ul > li.next').removeClass('disabled'); - el = $('.pagination ul > li.active'); - if (!el.hasClass('first')) { - el.removeClass('active'); - el.prev().addClass('active'); - limitPaginationItems(); - } - if ($('.pagination ul > li.active').hasClass('first')) { - $(this).addClass('disabled'); - } - e.preventDefault(); - return false; - })); - $('.pagination ul > li.next:not(.disabled)').on('click', (function(e) { - var el; - $('.pagination ul > li.prev').removeClass('disabled'); - el = $('.pagination ul > li.active'); - if (!el.hasClass('last')) { - el.removeClass('active'); - el.next().addClass('active'); - limitPaginationItems(); - } - if ($('.pagination ul > li.active').hasClass('last')) { - $(this).addClass('disabled'); - } - e.preventDefault(); - return false; - })); - $('.pagination ul > li.disabled a').on('click', (function(e) { - e.preventDefault(); - return false; - })); - $('.error input, .error textarea, \ - .invalid input, .invalid textarea, \ - input.error, textarea.error, \ - input.invalid, textarea.invalid').on({ - click: function() { - $(this).focus(); - return $(this).select(); - } - }); - $('span.select select').each(function() { - if ($(this).children('option').first().val() === '' && $(this).children('option').first().attr('selected')) { - return $(this).addClass('unselected'); - } else { - return $(this).removeClass('unselected'); - } - }); - $('span.select select').on({ - change: function() { - if ($(this).children('option').first().val() === '' && $(this).children('option').first().attr('selected')) { - return $(this).addClass('unselected'); - } else { - return $(this).removeClass('unselected'); + })(jQuery); + + /* -------------------------------------------- + Begin jquery.responsiveTables.coffee + -------------------------------------------- + */ + + + /* + * + * jQuery ResponsiveTables by Gary Hepting - https://github.com/ghepting/responsiveTables + * + * Open source under the BSD License. + * + * Copyright © 2013 Gary Hepting. All rights reserved. + * + */ + + + (function($) { + var elems; + elems = []; + $.fn.responsiveTable = function(options) { + var settings; + settings = { + compressor: options.compressor || 10, + minSize: options.minSize || Number.NEGATIVE_INFINITY, + maxSize: options.maxSize || Number.POSITIVE_INFINITY, + padding: 2, + height: "auto", + adjust_parents: true + }; + return this.each(function() { + var columns, elem, fontSize, rows; + elem = $(this); + elem.attr('data-compression', settings.compressor); + elem.attr('data-min', settings.minSize); + elem.attr('data-max', settings.maxSize); + elem.attr('data-padding', settings.padding); + columns = $("tr", elem).first().children("th, td").length; + rows = $("tr", elem).length; + if (settings.height !== "auto") { + $this.css("height", settings.height); + if (settings.adjust_parents) { + $this.parents().each(function() { + return $(this).css("height", "100%"); + }); + } } - } - }); - $('.tabs > ul > li > a[href^=#]').on('click', function(e) { - var tabs; - if (!$(this).hasClass('disabled')) { - tabs = $(this).parents('.tabs'); - tabs.find('> ul li a').removeClass('active'); - $(this).addClass('active'); - tabs.children('div').removeClass('active'); - tabs.children($(this).attr('href')).addClass('active'); - } - e.preventDefault(); - return false; - }); - $('.responsive').not('table').each(function(index, object) { - var compression, max, min; - compression = 10; - min = 10; - max = 200; - compression = parseFloat($(this).attr('data-compression') || compression); - min = parseFloat($(this).attr('data-min') || min); - max = parseFloat($(this).attr('data-max') || max); - return $(object).responsiveText({ - compressor: compression, - minSize: min, - maxSize: max + $("tr th, tr td", elem).css("width", Math.floor(100 / columns) + "%"); + $("tr th, tr td", elem).css("height", Math.floor(100 / rows) + "%"); + fontSize = Math.floor(Math.max(Math.min(elem.width() / settings.compressor, parseFloat(settings.maxSize)), parseFloat(settings.minSize))); + $("tr th, tr td", elem).css("font-size", fontSize + "px"); + return elems.push(elem); }); - }); - $('table.responsive').each(function(index, object) { - var compression, max, min, padding; - compression = 30; - min = 8; - max = 13; - padding = 0; - compression = parseFloat($(this).attr('data-compression') || compression); - min = parseFloat($(this).attr('data-min') || min); - max = parseFloat($(this).attr('data-max') || max); - padding = parseFloat($(this).attr('data-padding') || padding); - return $(object).responsiveTable({ - compressor: compression, - minSize: min, - maxSize: max, - padding: padding + }; + return $(window).on("resize", function() { + return $(elems).each(function() { + var elem, fontSize; + elem = $(this); + fontSize = Math.floor(Math.max(Math.min(elem.width() / (elem.attr('data-compression')), parseFloat(elem.attr('data-max'))), parseFloat(elem.attr('data-min')))); + return $("tr th, tr td", elem).css("font-size", fontSize + "px"); }); }); - $('.tooltip[title]').tooltip(); - return $('div.modal').modal(); - }); + })(jQuery); - $(window).resize(function() { - limitPaginationItems(); - return equalizeColumns(); - }); + /* -------------------------------------------- + Begin jquery.responsiveText.coffee + -------------------------------------------- + */ - limitPaginationItems = function() { - return $('.pagination ul').each(function() { - var pagination, visibleItemsWidth, visibleSpace, _results; - pagination = $(this); - visibleSpace = pagination.outerWidth() - pagination.children('li.prev').outerWidth() - pagination.children('li.next').outerWidth(); - pagination.children('li').not('.prev, .next, .active').hide(); - visibleItemsWidth = 0; - pagination.children('li:visible').each(function() { - return visibleItemsWidth += $(this).outerWidth(); - }); - _results = []; - while ((visibleItemsWidth + 29) < visibleSpace) { - pagination.children('li:visible').not('.next').last().next().show(); - visibleItemsWidth = 0; - pagination.children('li:visible').each(function() { - return visibleItemsWidth += $(this).outerWidth(); - }); - if ((visibleItemsWidth + 29) <= visibleSpace) { - pagination.children('li:visible').not('.prev').first().prev().show(); - visibleItemsWidth = 0; - pagination.children('li:visible').each(function() { - return visibleItemsWidth += $(this).outerWidth(); - }); - } - visibleItemsWidth = 0; - _results.push(pagination.children('li:visible').each(function() { - return visibleItemsWidth += $(this).outerWidth(); - })); - } - return _results; - }); - }; - equalizeColumns = function() { - return $('.row.equalize').each(function() { - var $row, collapsed, tallest; - $row = $(this); - tallest = 0; - collapsed = false; - $(this).children('*').each(function(i) { - $(this).css('min-height', '0'); - collapsed = $(this).outerWidth() === $row.outerWidth(); - if (!collapsed) { - if (!$(this).hasClass('equal')) { - $(this).addClass('equal'); - } - if ($(this).outerHeight() > tallest) { - return tallest = $(this).outerHeight(); - } - } + /* + * + * jQuery ResponsiveText by Gary Hepting - https://github.com/ghepting/responsiveText + * + * Open source under the BSD License. + * + * Copyright © 2013 Gary Hepting. All rights reserved. + * + */ + + + (function($) { + var elems; + elems = []; + $.fn.responsiveText = function(options) { + var settings; + settings = { + compressor: options.compressor || 10, + minSize: options.minSize || Number.NEGATIVE_INFINITY, + maxSize: options.maxSize || Number.POSITIVE_INFINITY + }; + return this.each(function() { + var elem; + elem = $(this); + elem.attr('data-compression', settings.compressor); + elem.attr('data-min', settings.minSize); + elem.attr('data-max', settings.maxSize); + elem.css("font-size", Math.floor(Math.max(Math.min(elem.width() / settings.compressor, parseFloat(settings.maxSize)), parseFloat(settings.minSize)))); + return elems.push(elem); }); - if (!collapsed) { - return $(this).children('*').css('min-height', tallest); - } + }; + return $(window).on("resize", function() { + return $(elems).each(function() { + var elem; + elem = $(this); + return elem.css("font-size", Math.floor(Math.max(Math.min(elem.width() / (elem.attr('data-compression')), parseFloat(elem.attr('data-max'))), parseFloat(elem.attr('data-min'))))); + }); }); - }; + })(jQuery); /* -------------------------------------------- Begin jquery.tooltip.coffee -------------------------------------------- */ @@ -425,306 +445,431 @@ }); }; })(jQuery); /* -------------------------------------------- - Begin jquery.responsiveText.coffee + Begin disabled.coffee -------------------------------------------- */ - /* - * - * jQuery ResponsiveText by Gary Hepting - https://github.com/ghepting/responsiveText - * - * Open source under the BSD License. - * - * Copyright © 2013 Gary Hepting. All rights reserved. - * + $(function() { + $('.disabled').each(function() { + $(this).attr('tabindex', '-1'); + $(this).find('a').attr('tabindex', '-1'); + return $(this).find('input, select, textarea').addClass('disabled').attr('tabindex', '-1').attr('readonly', 'readyonly'); + }); + $('body').on('click', '.disabled, .disabled *', function(e) { + e.preventDefault(); + return false; + }); + }); + + /* -------------------------------------------- + Begin equalizeColumns.coffee + -------------------------------------------- */ - (function($) { - var elems; - elems = []; - $.fn.responsiveText = function(options) { - var settings; - settings = { - compressor: options.compressor || 10, - minSize: options.minSize || Number.NEGATIVE_INFINITY, - maxSize: options.maxSize || Number.POSITIVE_INFINITY - }; - return this.each(function() { - var elem; - elem = $(this); - elem.attr('data-compression', settings.compressor); - elem.attr('data-min', settings.minSize); - elem.attr('data-max', settings.maxSize); - elem.css("font-size", Math.floor(Math.max(Math.min(elem.width() / settings.compressor, parseFloat(settings.maxSize)), parseFloat(settings.minSize)))); - return elems.push(elem); + $(function() { + return equalizeColumns(); + }); + + $(window).resize(function() { + return equalizeColumns(); + }); + + equalizeColumns = function() { + return $('.row.equalize').each(function() { + var $row, collapsed, tallest; + $row = $(this); + tallest = 0; + collapsed = false; + $(this).children('*').each(function(i) { + $(this).css('min-height', '1px'); + collapsed = $(this).outerWidth() === $row.outerWidth(); + if (!collapsed) { + if (!$(this).hasClass('equal')) { + $(this).addClass('equal'); + } + if ($(this).outerHeight() > tallest) { + return tallest = $(this).outerHeight(); + } + } }); - }; - return $(window).on("resize", function() { - return $(elems).each(function() { - var elem; - elem = $(this); - return elem.css("font-size", Math.floor(Math.max(Math.min(elem.width() / (elem.attr('data-compression')), parseFloat(elem.attr('data-max'))), parseFloat(elem.attr('data-min'))))); - }); + if (!collapsed) { + return $(this).children('*').css('min-height', tallest); + } }); - })(jQuery); + }; /* -------------------------------------------- - Begin jquery.responsiveTables.coffee + Begin forms.coffee -------------------------------------------- */ - /* - * - * jQuery ResponsiveTables by Gary Hepting - https://github.com/ghepting/responsiveTables - * - * Open source under the BSD License. - * - * Copyright © 2013 Gary Hepting. All rights reserved. - * + $(function() { + $('body').on('click', '\ + .error input, \ + .error textarea, \ + .invalid input, \ + .invalid textarea, \ + input.error, \ + textarea.error, \ + input.invalid, \ + textarea.invalid', function(e) { + return $(this).focus().select(); + }); + $('span.select select').each(function() { + if ($(this).children('option').first().val() === '' && $(this).children('option').first().attr('selected')) { + return $(this).addClass('unselected'); + } else { + return $(this).removeClass('unselected'); + } + }); + $('body').on('change', 'span.select select', function(e) { + if ($(this).children('option').first().val() === '' && $(this).children('option').first().attr('selected')) { + return $(this).addClass('unselected'); + } else { + return $(this).removeClass('unselected'); + } + }); + }); + + /* -------------------------------------------- + Begin menus.coffee + -------------------------------------------- */ - (function($) { - var elems; - elems = []; - $.fn.responsiveTable = function(options) { - var settings; - settings = { - compressor: options.compressor || 10, - minSize: options.minSize || Number.NEGATIVE_INFINITY, - maxSize: options.maxSize || Number.POSITIVE_INFINITY, - padding: 2, - height: "auto", - adjust_parents: true - }; - return this.each(function() { - var columns, elem, fontSize, rows; - elem = $(this); - elem.attr('data-compression', settings.compressor); - elem.attr('data-min', settings.minSize); - elem.attr('data-max', settings.maxSize); - elem.attr('data-padding', settings.padding); - columns = $("tr", elem).first().children("th, td").length; - rows = $("tr", elem).length; - if (settings.height !== "auto") { - $this.css("height", settings.height); - if (settings.adjust_parents) { - $this.parents().each(function() { - return $(this).css("height", "100%"); - }); - } - } - $("tr th, tr td", elem).css("width", Math.floor(100 / columns) + "%"); - $("tr th, tr td", elem).css("height", Math.floor(100 / rows) + "%"); - fontSize = Math.floor(Math.max(Math.min(elem.width() / settings.compressor, parseFloat(settings.maxSize)), parseFloat(settings.minSize))); - $("tr th, tr td", elem).css("font-size", fontSize + "px"); - return elems.push(elem); - }); + $(function() { + var delay, openMenu, + _this = this; + delay = ''; + openMenu = function(target) { + return $(target).parent('li.menu').toggleClass('on'); }; - return $(window).on("resize", function() { - return $(elems).each(function() { - var elem, fontSize; - elem = $(this); - fontSize = Math.floor(Math.max(Math.min(elem.width() / (elem.attr('data-compression')), parseFloat(elem.attr('data-max'))), parseFloat(elem.attr('data-min')))); - return $("tr th, tr td", elem).css("font-size", fontSize + "px"); - }); + $('body').on('mouseenter', '.nav > ul > li.menu:not(.disabled)', function(e) { + if ($(window).width() >= 768) { + clearTimeout(delay); + $('.nav > ul > li.menu.on').removeClass('on'); + return $(this).addClass('on'); + } }); - })(jQuery); + $('body').on('mouseleave', '.nav > ul > li.menu:not(.disabled)', function(e) { + if ($(window).width() >= 768) { + return delay = setTimeout((function() { + return $('.nav > ul > li.menu.on').removeClass('on'); + }), 350); + } + }); + $('body').on('click', '.nav > ul > li.menu:not(.disabled) > a', function(e) { + if (Modernizr.touch || $(window).width() < 768) { + openMenu(e.target); + } else { + $('.nav > ul > li.menu.on').removeClass('on'); + $(e.target).parents('li.menu').addClass('on'); + } + e.preventDefault(); + return false; + }); + $('body').on('focus', '.nav > ul > li:not(.on) > a', function() { + return $('.nav > ul > li.menu.on').removeClass('on'); + }); + $('body').on('focus', '.nav > ul > li.menu > a', function(e) { + openMenu(e.target); + e.preventDefault(); + return false; + }); + $('body').on('click', function(e) { + if ($(e.target).hasClass('dropdown')) { + $(e.target).toggleClass('on'); + } else { + if ($('.dropdown').filter('.on').length) { + $('.dropdown').filter('.on').removeClass('on'); + } + } + if ($('.nav > ul > li').filter('.menu.on').length) { + return $('.nav > ul > li').filter('.menu.on').removeClass('on'); + } + }); + $('body').on('focus', '.dropdown', function(e) { + return $(this).addClass('on'); + }); + $('body').on('blur', '.dropdown li:last-child a', function(e) { + return $('.dropdown').filter('.on').removeClass('on'); + }); + $('.nav.menu').each(function() { + if (!$(this).attr('data-label')) { + $(this).attr('data-label', 'Menu'); + } + if (!($(this).find('.menu-toggle').length > 0)) { + return $(this).prepend('<a href="#" class="menu-toggle"><i class="icon-reorder"></i></a>'); + } + }); + $('body').on('click', '.nav.menu .menu-toggle', function(e) { + $(this).parent('.nav.menu').toggleClass('on'); + e.preventDefault(); + return false; + }); + $('body').on('focus', '.menu-toggle', function(e) { + return $(e.target).parent('.nav.menu').addClass('on'); + }); + $('body').on('blur', '.nav.menu > ul > li:last-child a', function(e) { + return $('.nav.menu').filter('.on').removeClass('on'); + }); + }); + $(window).on('resize', function() { + if ($('.nav > ul > li.menu.on').length > 1) { + return $('.nav > ul > li.menu.on').removeClass('on').first().addClass('on'); + } + }); + /* -------------------------------------------- - Begin jquery.modals.coffee + Begin modals.coffee -------------------------------------------- */ /* - * - * jQuery Modals by Gary Hepting - * https://github.com/ghepting/modal - * - * Based on Avgrund by Hakim El Hattab <3 - * + * Requires jquery.modals.js */ - (function($) { - var elems, modals; - if ($('div#iframeModal').length < 1) { - $('body').append('<div class="iframe modal" id="iframeModal"><iframe marginheight="0" marginwidth="0" frameborder="0"></iframe></div>'); - $('div#iframeModal').prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>'); - } - $('a.modal').each(function() { - $(this).attr('data-url', $(this).attr('href')); - return $(this).attr('href', '#iframeModal'); + $(function() { + return $('div.modal, div[role=dialog]').modal(); + }); + + /* -------------------------------------------- + Begin pagination.coffee + -------------------------------------------- + */ + + + $(function() { + limitPaginationItems(); + $('body').on('click', '.pagination ul > li:not(.next, .prev) a', function(e) { + $('.pagination ul > li:not(.next, .prev)').removeClass('active'); + $(this).parent('li').addClass('active'); + if ($(this).parent('li').hasClass('first')) { + $('.pagination ul > li.prev').addClass('disabled'); + } else { + $('.pagination ul > li.prev').removeClass('disabled'); + } + if ($(this).parent('li').hasClass('last')) { + $('.pagination ul > li.next').addClass('disabled'); + } else { + $('.pagination ul > li.next').removeClass('disabled'); + } + limitPaginationItems(); + e.preventDefault(); + return false; }); - $('a.modal').on("click", function(e) { - $('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0" width="100%" height="100%" src="' + $(this).attr('data-url') + '"></iframe>'); + $('body').on('click', '.pagination ul > li.prev:not(.disabled)', function(e) { + var el; + $('.pagination ul > li.next').removeClass('disabled'); + el = $('.pagination ul > li.active'); + if (!el.hasClass('first')) { + el.removeClass('active'); + el.prev().addClass('active'); + limitPaginationItems(); + } + if ($('.pagination ul > li.active').hasClass('first')) { + $(this).addClass('disabled'); + } e.preventDefault(); return false; }); - elems = []; - $.fn.modal = function() { - this.each(function() { - var $this; - $(this).not('#iframeModal').wrapInner('<div class="modal-content"></div>'); - $(this).prepend('<i class="close icon-remove"></i>').prepend('<i class="fullscreen icon-resize-full"></i>').appendTo('body'); - $this = $(this); - return $('[href=#' + $(this).attr('id') + ']').on("click", function(e) { - modals.open($(this).attr('href'), $(this).hasClass('fullscreen')); - e.preventDefault(); - return false; - }); - }); - $('div.modal .close').on("click", function() { - return modals.close(); - }); - return $('div.modal .fullscreen').on("click", function() { - return modals.fullscreen($(this).parent('div.modal')); - }); - }; - modals = (function() { - var close, fullscreen, open; - $('body').addClass('modal-ready'); - if ($("#overlay").length < 1) { - $('body').append('<div id="overlay"></div>'); + $('body').on('click', '.pagination ul > li.next:not(.disabled)', function(e) { + var el; + $('.pagination ul > li.prev').removeClass('disabled'); + el = $('.pagination ul > li.active'); + if (!el.hasClass('last')) { + el.removeClass('active'); + el.next().addClass('active'); + limitPaginationItems(); } - $('#overlay, div.modal .close').bind("click", function(e) { - return close(); + if ($('.pagination ul > li.active').hasClass('last')) { + $(this).addClass('disabled'); + } + e.preventDefault(); + return false; + }); + $('body').on('click', '.pagination ul > li.disabled a', function(e) { + e.preventDefault(); + return false; + }); + }); + + $(window).resize(function() { + return limitPaginationItems(); + }); + + limitPaginationItems = function() { + return $('.pagination ul').each(function() { + var pagination, totalItemsWidth, visibleItemsWidth, visibleSpace, _results; + pagination = $(this); + visibleSpace = pagination.outerWidth() - pagination.children('li.prev').outerWidth() - pagination.children('li.next').outerWidth(); + totalItemsWidth = 0; + pagination.children('li').each(function() { + return totalItemsWidth += $(this).outerWidth(); }); - open = function(elem, fullscreen) { - $(window).bind("keydown", function(e) { - var keyCode; - keyCode = (e.which ? e.which : e.keyCode); - if (keyCode === 27) { - return close(); - } + pagination.children('li').not('.prev, .next, .active').hide(); + visibleItemsWidth = 0; + pagination.children('li:visible').each(function() { + return visibleItemsWidth += $(this).outerWidth(); + }); + _results = []; + while ((visibleItemsWidth + 29) < visibleSpace && (visibleItemsWidth + 29) < totalItemsWidth) { + pagination.children('li:visible').not('.next').last().next().show(); + visibleItemsWidth = 0; + pagination.children('li:visible').each(function() { + return visibleItemsWidth += $(this).outerWidth(); }); - $(elem).addClass("active"); - if (!$(elem).hasClass('iframe')) { - $(elem).css({ - width: 'auto', - height: 'auto' + if ((visibleItemsWidth + 29) <= visibleSpace) { + pagination.children('li:visible').not('.prev').first().prev().show(); + visibleItemsWidth = 0; + pagination.children('li:visible').each(function() { + return visibleItemsWidth += $(this).outerWidth(); }); - $(elem).css({ - height: $(elem).outerHeight() - }); } - $(elem).css({ - top: '50%', - left: '50%', - 'margin-top': ($(elem).outerHeight() / -2) + 'px', - 'margin-left': ($(elem).outerWidth() / -2) + 'px' - }); - setTimeout(function() { - return $('body').addClass("modal-active"); - }, 0); - setTimeout(function() { - return $('body').removeClass('modal-ready'); - }, 400); - if (fullscreen) { - modals.fullscreen(elem); - } - }; - close = function() { - var modal; - modal = $('div.modal.active'); - $(window).unbind("keydown"); - $('body').removeClass("modal-active").addClass('modal-ready'); - if (modal.hasClass('iframe')) { - $('div#iframeModal iframe').replaceWith('<iframe marginheight="0" marginwidth="0" frameborder="0"></iframe>'); - modal.css({ - width: '80%', - height: '80%' - }); + visibleItemsWidth = 0; + _results.push(pagination.children('li:visible').each(function() { + return visibleItemsWidth += $(this).outerWidth(); + })); + } + return _results; + }); + }; + + /* -------------------------------------------- + Begin responsiveTables.coffee + -------------------------------------------- + */ + + + /* + * Requires jquery.responsiveText.js + */ + + + $(function() { + return $('table.responsive').each(function(index, object) { + var compression, max, min, padding; + compression = 30; + min = 8; + max = 13; + padding = 0; + compression = parseFloat($(this).attr('data-compression') || compression); + min = parseFloat($(this).attr('data-min') || min); + max = parseFloat($(this).attr('data-max') || max); + padding = parseFloat($(this).attr('data-padding') || padding); + return $(object).responsiveTable({ + compressor: compression, + minSize: min, + maxSize: max, + padding: padding + }); + }); + }); + + /* -------------------------------------------- + Begin responsiveText.coffee + -------------------------------------------- + */ + + + /* + * Requires jquery.responsiveText.js + */ + + + $(function() { + return $('.responsive').not('table').each(function(index, object) { + var compression, max, min; + compression = 10; + min = 10; + max = 200; + compression = parseFloat($(this).attr('data-compression') || compression); + min = parseFloat($(this).attr('data-min') || min); + max = parseFloat($(this).attr('data-max') || max); + return $(object).responsiveText({ + compressor: compression, + minSize: min, + maxSize: max + }); + }); + }); + + /* -------------------------------------------- + Begin tabs.coffee + -------------------------------------------- + */ + + + $(function() { + return $('body').on('click', '.tabs > ul li a[href^=#], [role=tab] a', function(e) { + var tabs; + if (!$(this).hasClass('disabled')) { + if ($(this).parents('[role=tabpanel]').length > 0) { + tabs = $(this).parents('[role=tabpanel]'); } else { - modal.css({ - width: 'auto', - height: 'auto' - }); + tabs = $(this).parents('.tabs'); } - modal.css({ - top: '10%', - left: '10%', - 'max-width': '80%', - 'max-height': '80%', - 'margin-top': 0, - 'margin-left': 0 - }); - modal.removeClass("active").removeClass("fullscreen"); - $('i.fullscreen', modal).removeClass('icon-resize-small').addClass('icon-resize-full'); - }; - fullscreen = function(elem) { - if ($('div.modal.active').hasClass('fullscreen')) { - $('div.modal i.fullscreen').removeClass('icon-resize-small').addClass('icon-resize-full'); - if ($('div.modal.active').hasClass('iframe')) { - $('div.modal.active').css({ - width: '80%', - height: '80%' - }); - } else { - $('div.modal.active').css({ - width: 'auto', - height: 'auto' - }); - $('div.modal.active').css({ - height: $('div.modal.active').outerHeight() - }); - } - $('div.modal.active').removeClass('fullscreen').css({ - 'max-width': '80%', - 'max-height': '80%' - }); - $('div.modal.active').delay(100).css({ - top: '50%', - left: '50%', - 'margin-top': ($('div.modal.active').outerHeight() / -2) + 'px', - 'margin-left': ($('div.modal.active').outerWidth() / -2) + 'px' - }); - } else { - $('div.modal i.fullscreen').addClass('icon-resize-small').removeClass('icon-resize-full'); - $('div.modal.active').addClass('fullscreen').css({ - top: 0, - left: 0, - 'margin-top': 0, - 'margin-left': 0, - width: '100%', - height: '100%', - 'max-width': '100%', - 'max-height': '100%' - }); - } - }; - return { - open: open, - close: close, - fullscreen: fullscreen - }; - })(); - return $(window).resize(function() { - return $('div.modal.active').each(function() { - if (!$(this).hasClass('fullscreen')) { - $(this).removeClass('active').css({ - top: '50%', - left: '50%', - 'margin-top': ($(this).outerHeight() / -2) + 'px', - 'margin-left': ($(this).outerWidth() / -2) + 'px' - }).addClass('active'); - if (!$(this).hasClass('iframe')) { - $(this).css({ - height: 'auto' - }); - return $(this).css({ - height: $(this).outerHeight() - }); - } - } - }); + tabs.find('> ul li a, [role=tab] a').removeClass('active'); + $(this).addClass('active'); + tabs.children('div, [role=tabpanel]').removeClass('active'); + tabs.children($(this).attr('href')).addClass('active'); + } + e.preventDefault(); + return false; }); - })(jQuery); + }); + + /* -------------------------------------------- + Begin tiles.coffee + -------------------------------------------- + */ + + + $(function() { + $('.tiles').each(function() { + $(this).find('.tile').attr('role', 'button'); + return $(this).find('.tile[data-value=' + $(this).find('input.value, select.value').val() + ']').addClass('active'); + }); + $('body').on('click', '.tiles .tile', function(e) { + var tiles; + if (!$(this).hasClass('disabled')) { + tiles = $(this).parents('.tiles'); + tiles.find('.tile').removeClass('active'); + tiles.find('input.value, select.value').val($(this).data('value')).change(); + $(this).addClass('active'); + } + e.preventDefault(); + return false; + }); + return $('body').on('change', '.tiles input.value, .tiles select.value', function(e) { + var tiles; + tiles = $(this).parents('.tiles'); + tiles.find('.tile').removeClass('active'); + return tiles.find('.tile[data-value=' + $(this).val() + ']').addClass('active'); + }); + }); + + /* -------------------------------------------- + Begin tooltips.coffee + -------------------------------------------- + */ + + + /* + * Requires jquery.tooltips.js + */ + + + $(function() { + return $('.tooltip[title]').tooltip(); + }); }).call(this);