init.js 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. Solarize by TEMPLATED
  3. templated.co @templatedco
  4. Released for free under the Creative Commons Attribution 3.0 license (templated.co/license)
  5. */
  6. (function($) {
  7. var themeCSSPath = $('script').last().data('theme-root') + '/css/';
  8. skel.init({
  9. reset: 'full',
  10. breakpoints: {
  11. global: { range: '*', href: themeCSSPath + 'style.css', containers: 1400, grid: { gutters: 50 } },
  12. wide: { range: '-1680', href: themeCSSPath + 'style-wide.css', containers: 1200, grid: { gutters: 40 } },
  13. normal: { range: '-1280', href: themeCSSPath + 'style-normal.css', containers: 960, lockViewport: true },
  14. narrow: { range: '-980', href: themeCSSPath + 'style-narrow.css', containers: '95%', grid: { gutters: 25 } },
  15. narrower: { range: '-840', href: themeCSSPath + 'style-narrower.css', grid: { collapse: true } },
  16. mobile: { range: '-640', href: themeCSSPath + 'style-mobile.css', containers: '90%', grid: { gutters: 15 } }
  17. }
  18. }, {
  19. layers: {
  20. layers: {
  21. navPanel: {
  22. animation: 'pushX',
  23. breakpoints: 'narrower',
  24. clickToClose: true,
  25. height: '100%',
  26. hidden: true,
  27. html: '<div data-action="navList" data-args="nav"></div>',
  28. orientation: 'vertical',
  29. position: 'top-left',
  30. side: 'left',
  31. width: 275
  32. },
  33. titleBar: {
  34. breakpoints: 'narrower',
  35. height: 44,
  36. html: '<span class="toggle" data-action="toggleLayer" data-args="navPanel"></span><span class="title" data-action="copyHTML" data-args="logo"></span>',
  37. position: 'top-left',
  38. side: 'top',
  39. width: '100%'
  40. }
  41. }
  42. }
  43. });
  44. $(function() {
  45. var $window = $(window),
  46. $body = $('body');
  47. // Disable animations/transitions until page has loaded.
  48. $body.addClass('loading');
  49. $window.on('load', function() {
  50. $body.removeClass('loading');
  51. });
  52. // Forms (IE<10).
  53. var $form = $('form');
  54. if ($form.length > 0) {
  55. $form.find('.form-button-submit')
  56. .on('click', function() {
  57. $(this).parents('form').submit();
  58. return false;
  59. });
  60. if (skel.vars.IEVersion < 10) {
  61. $.fn.n33_formerize=function(){var _fakes=new Array(),_form = $(this);_form.find('input[type=text],textarea').each(function() { var e = $(this); if (e.val() == '' || e.val() == e.attr('placeholder')) { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).blur(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } }).focus(function() { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) return; if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); _form.find('input[type=password]').each(function() { var e = $(this); var x = $($('<div>').append(e.clone()).remove().html().replace(/type="password"/i, 'type="text"').replace(/type=password/i, 'type=text')); if (e.attr('id') != '') x.attr('id', e.attr('id') + '_fakeformerizefield'); if (e.attr('name') != '') x.attr('name', e.attr('name') + '_fakeformerizefield'); x.addClass('formerize-placeholder').val(x.attr('placeholder')).insertAfter(e); if (e.val() == '') e.hide(); else x.hide(); e.blur(function(event) { event.preventDefault(); var e = $(this); var x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } }); x.focus(function(event) { event.preventDefault(); var x = $(this); var e = x.parent().find('input[name=' + x.attr('name').replace('_fakeformerizefield', '') + ']'); x.hide(); e.show().focus(); }); x.keypress(function(event) { event.preventDefault(); x.val(''); }); }); _form.submit(function() { $(this).find('input[type=text],input[type=password],textarea').each(function(event) { var e = $(this); if (e.attr('name').match(/_fakeformerizefield$/)) e.attr('name', ''); if (e.val() == e.attr('placeholder')) { e.removeClass('formerize-placeholder'); e.val(''); } }); }).bind("reset", function(event) { event.preventDefault(); $(this).find('select').val($('option:first').val()); $(this).find('input,textarea').each(function() { var e = $(this); var x; e.removeClass('formerize-placeholder'); switch (this.type) { case 'submit': case 'reset': break; case 'password': e.val(e.attr('defaultValue')); x = e.parent().find('input[name=' + e.attr('name') + '_fakeformerizefield]'); if (e.val() == '') { e.hide(); x.show(); } else { e.show(); x.hide(); } break; case 'checkbox': case 'radio': e.attr('checked', e.attr('defaultValue')); break; case 'text': case 'textarea': e.val(e.attr('defaultValue')); if (e.val() == '') { e.addClass('formerize-placeholder'); e.val(e.attr('placeholder')); } break; default: e.val(e.attr('defaultValue')); break; } }); window.setTimeout(function() { for (x in _fakes) _fakes[x].trigger('formerize_sync'); }, 10); }); return _form; };
  62. $form.n33_formerize();
  63. }
  64. }
  65. // Dropdowns.
  66. $('#nav > ul').dropotron({
  67. offsetY: -15,
  68. hoverDelay: 0
  69. });
  70. });
  71. })(jQuery);