Guest User

Untitled

a guest
Jan 20th, 2015
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.41 KB | None | 0 0
  1. /*
  2. Astral by HTML5 UP
  3. html5up.net | @n33co
  4. Free for personal and commercial use under the CCA 3.0 license (html5up.net/license)
  5. */
  6. function showhide()
  7. {
  8. var div = document.getElementById("codebox");
  9. if (div.style.display !== "none") {
  10. div.style.display = "none";
  11. }
  12. else {
  13. div.style.display = "block";
  14. }
  15. }
  16.  
  17.  
  18. (function($) {
  19.  
  20. /*********************************************************************************/
  21. /* Settings */
  22. /*********************************************************************************/
  23.  
  24.  
  25. var settings = {
  26.  
  27. // Speed to resize panel.
  28. resizeSpeed: 600,
  29.  
  30. // Speed to fade in/out.
  31. fadeSpeed: 300,
  32.  
  33. // Size factor.
  34. sizeFactor: 11.5,
  35.  
  36. // Minimum point size.
  37. sizeMin: 15,
  38.  
  39. // Maximum point size.
  40. sizeMax: 20
  41.  
  42. };
  43.  
  44. /*********************************************************************************/
  45. /* skel */
  46. /*********************************************************************************/
  47.  
  48. skel.init({
  49. reset: 'full',
  50. pollOnce: true,
  51. breakpoints: {
  52. 'global': { range: '*', href: 'css/style.css' },
  53. 'desktop': { range: '737-', href: 'css/style-desktop.css', containers: 1200, grid: { gutters: 25 }, viewport: { width: 1080, scalable: false } },
  54. 'mobile': { range: '-736', href: 'css/style-mobile.css', containers: '100%!', grid: { collapse: true, gutters: 15 }, viewport: { scalable: false } }
  55. }
  56. });
  57.  
  58. /*********************************************************************************/
  59. /* Main */
  60. /*********************************************************************************/
  61.  
  62.  
  63. var $window = $(window);
  64.  
  65. $window.on('load', function() {
  66.  
  67. var $body = $('body'),
  68. $main = $('#main'),
  69. $panels = $main.find('.panel'),
  70. $hbw = $('html,body,window'),
  71. $footer = $('#footer'),
  72. $wrapper = $('#wrapper'),
  73. $nav = $('#nav'), $nav_links = $nav.find('a'),
  74. $jumplinks = $('.jumplink'),
  75. $form = $('form'),
  76. panels = [],
  77. activePanelId = null,
  78. firstPanelId = null,
  79. isLocked = false,
  80. hash = window.location.hash.substring(1);
  81.  
  82. if (skel.vars.isTouch) {
  83.  
  84. settings.fadeSpeed = 0;
  85. settings.resizeSpeed = 0;
  86. $nav_links.find('span').remove();
  87.  
  88. }
  89.  
  90. if (skel.isActive('desktop')) {
  91.  
  92. // Body.
  93. $body._resize = function() {
  94. var factor = ($window.width() * $window.height()) / (1440 * 900);
  95. $body.css('font-size', Math.min(Math.max(Math.floor(factor * settings.sizeFactor), settings.sizeMin), settings.sizeMax) + 'pt');
  96. $main.height(panels[activePanelId].outerHeight());
  97. $body._reposition();
  98. };
  99.  
  100. $body._reposition = function() {
  101. if (skel.vars.isTouch && (window.orientation == 0 || window.orientation == 180))
  102. $wrapper.css('padding-top', Math.max((($window.height() - (panels[activePanelId].outerHeight() + $footer.outerHeight())) / 2) - $nav.height(), 30) + 'px');
  103. else
  104. $wrapper.css('padding-top', ((($window.height() - panels[firstPanelId].height()) / 2) - $nav.height()) + 'px');
  105. };
  106. ////test
  107. // document.getElementById('bodyresize').onclick = function()
  108.  
  109. // document.getElementById('bodyresize').onclick = function()
  110.  
  111. document.getElementById('bodyresize').onclick = function()
  112. {
  113. showhide();
  114. var factor = ($window.width() * $window.height()) / (1440 * 900);
  115. $body.css('font-size', Math.min(Math.max(Math.floor(factor * settings.sizeFactor), settings.sizeMin), settings.sizeMax) + 'pt');
  116. $main.height(panels[activePanelId].outerHeight());
  117. $body._reposition2();
  118. };
  119.  
  120. $body._reposition2 = function() {
  121. if (skel.vars.isTouch && (window.orientation == 0 || window.orientation == 180))
  122. $wrapper.css('padding-top', Math.max((($window.height() - (panels[activePanelId].outerHeight() + $footer.outerHeight())) / 2) - $nav.height(), 30) + 'px');
  123. else
  124. $wrapper.css('padding-top', ((($window.height() - panels[firstPanelId].height()) / 2) - $nav.height()) + 'px');
  125. };
  126.  
  127.  
  128. ////test
  129.  
  130.  
  131.  
  132. // Panels.
  133.  
  134.  
  135. $panels.each(function(i) {
  136. var t = $(this), id = t.attr('id');
  137.  
  138. panels[id] = t;
  139.  
  140. if (i == 0) {
  141.  
  142. firstPanelId = id;
  143. activePanelId = id;
  144.  
  145. }
  146. else
  147. t.hide();
  148.  
  149. t._activate = function(instant) {
  150.  
  151. // Check lock state and determine whether we're already at the target.
  152. if (isLocked
  153. || activePanelId == id)
  154. return false;
  155.  
  156. // Lock.
  157. isLocked = true;
  158.  
  159. // Change nav link (if it exists).
  160. $nav_links.removeClass('active');
  161. $nav_links.filter('[href="#' + id + '"]').addClass('active');
  162.  
  163. // Change hash.
  164. if (i == 0)
  165. window.location.hash = '#';
  166. else
  167. window.location.hash = '#' + id;
  168.  
  169. // Add bottom padding.
  170. var x = parseInt($wrapper.css('padding-top')) +
  171. panels[id].outerHeight() +
  172. $nav.outerHeight() +
  173. $footer.outerHeight();
  174.  
  175. if (x > $window.height())
  176. $wrapper.addClass('tall');
  177. else
  178. $wrapper.removeClass('tall');
  179.  
  180. // Fade out active panel.
  181. $footer.fadeTo(settings.fadeSpeed, 0.0001);
  182. panels[activePanelId].fadeOut(instant ? 0 : settings.fadeSpeed, function() {
  183.  
  184. // Set new active.
  185. activePanelId = id;
  186.  
  187. // Force scroll to top.
  188. $hbw.animate({
  189. scrollTop: 0
  190. }, settings.resizeSpeed, 'swing');
  191.  
  192. // Reposition.
  193. $body._reposition();
  194.  
  195. // Resize main to height of new panel.
  196. $main.animate({
  197. height: panels[activePanelId].outerHeight()
  198. }, instant ? 0 : settings.resizeSpeed, 'swing', function() {
  199.  
  200. // Fade in new active panel.
  201. $footer.fadeTo(instant ? 0 : settings.fadeSpeed, 1.0);
  202. panels[activePanelId].fadeIn(instant ? 0 : settings.fadeSpeed, function() {
  203.  
  204. // Unlock.
  205. isLocked = false;
  206.  
  207. });
  208. });
  209.  
  210. });
  211.  
  212. };
  213.  
  214. });
  215.  
  216. // Nav + Jumplinks.
  217. $nav_links.add($jumplinks).click(function(e) {
  218. var t = $(this), href = t.attr('href'), id;
  219.  
  220. if (href.substring(0,1) == '#') {
  221.  
  222. e.preventDefault();
  223. e.stopPropagation();
  224.  
  225. id = href.substring(1);
  226.  
  227. if (id in panels)
  228. panels[id]._activate();
  229.  
  230. }
  231.  
  232. });
  233.  
  234. // Window.
  235. $window
  236. .resize(function() {
  237.  
  238. if (!isLocked)
  239. $body._resize();
  240.  
  241. });
  242.  
  243. if (skel.vars.IEVersion < 9)
  244. $window
  245. .on('resize', function() {
  246. $wrapper.css('min-height', $window.height());
  247. });
  248.  
  249. // Forms (IE<10).
  250. if ($form.length > 0) {
  251.  
  252. if (skel.vars.IEVersion < 10) {
  253. $.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; };
  254. $form.n33_formerize();
  255. }
  256.  
  257. }
  258.  
  259. // CSS polyfills (IE<9).
  260. if (skel.vars.IEVersion < 9)
  261. $(':last-child').addClass('last-child');
  262.  
  263. // Init.
  264. $window
  265. .trigger('resize');
  266.  
  267. if (hash && hash in panels)
  268. panels[hash]._activate(true);
  269.  
  270. $wrapper.fadeTo(400, 1.0);
  271.  
  272. }
  273.  
  274. });
  275.  
  276. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment