From a5246480e623f80d72e7da22925c8424639effea Mon Sep 17 00:00:00 2001 From: connors Date: Wed, 11 Sep 2013 14:58:52 -0700 Subject: [PATCH] Compiling the js with grunt. --- Gruntfile.js | 28 +++++++++++++---- dist/ratchet.js | 84 ++++++++----------------------------------------- package.json | 3 +- 3 files changed, 37 insertions(+), 78 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index be2364f..5232725 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -6,7 +6,7 @@ module.exports = function(grunt) { // Metadata. meta: { - srcPath: 'lib/sass/', + srcPath: 'lib/', distPath: 'dist/' }, @@ -19,7 +19,23 @@ module.exports = function(grunt) { '* Designed and built by @connors, @dhg, and @fat.\n' + '* =====================================================\n' + '*/\n', - + + concat: { + options: { + banner: '<%= banner %><%= jqueryCheck %>' + }, + ratchet: { + src: [ + '<%= meta.srcPath %>js/modals.js', + '<%= meta.srcPath %>js/popover.js', + '<%= meta.srcPath %>js/push.js', + '<%= meta.srcPath %>js/segmented-controllers.js', + '<%= meta.srcPath %>js/sliders.js', + '<%= meta.srcPath %>js/toggles.js' + ], + dest: '<%= meta.distPath %><%= pkg.name %>.js' + } + }, sass: { options: { @@ -27,7 +43,7 @@ module.exports = function(grunt) { }, dist: { files: { - '<%= meta.distPath %>ratchet.css': '<%= meta.srcPath %>ratchet.scss' + '<%= meta.distPath %><%= pkg.name %>.css': '<%= meta.srcPath %>sass/ratchet.scss' } } }, @@ -43,12 +59,12 @@ module.exports = function(grunt) { }); // Load the plugin that provides the "uglify" task. - //grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-sass'); grunt.loadNpmTasks('grunt-contrib-watch'); + grunt.loadNpmTasks('grunt-contrib-concat'); // Default task(s). - //grunt.registerTask('default', ['uglify']); - grunt.registerTask('default', ['sass']); + grunt.registerTask('default', ['sass', 'concat']); + grunt.registerTask('build', ['sass', 'concat']); }; \ No newline at end of file diff --git a/dist/ratchet.js b/dist/ratchet.js index f4006b4..1f5c5d1 100644 --- a/dist/ratchet.js +++ b/dist/ratchet.js @@ -1,11 +1,12 @@ -/** - * ================================== - * Ratchet v1.0.2 - * Licensed under The MIT License - * http://opensource.org/licenses/MIT - * ================================== - */ - +/* +* ===================================================== +* Ratchet v2.0.0 +* Copyright 2013 Connor Sears, Dave Gamache, and Jacob Thornton +* Licensed under http://www.opensource.org/licenses/MIT +* +* Designed and built by @connors, @dhg, and @fat. +* ===================================================== +*/ /* ---------------------------------- * MODAL v1.0.0 * Licensed under The MIT License @@ -30,68 +31,6 @@ var modal = getModal(event); if (modal) modal.classList.toggle('active'); }); -}();/* ---------------------------------- - * POPOVER v1.0.0 - * Licensed under The MIT License - * http://opensource.org/licenses/MIT - * ---------------------------------- */ - -!function () { - - var popover; - - var findPopovers = function (target) { - var i, popovers = document.querySelectorAll('a'); - for (; target && target !== document; target = target.parentNode) { - for (i = popovers.length; i--;) { if (popovers[i] === target) return target; } - } - }; - - var onPopoverHidden = function () { - document.body.removeChild(backdrop); - popover.style.display = 'none'; - popover.removeEventListener('webkitTransitionEnd', onPopoverHidden); - } - - var backdrop = function () { - var element = document.createElement('div'); - - element.classList.add('backdrop'); - - element.addEventListener('touchend', function () { - popover.addEventListener('webkitTransitionEnd', onPopoverHidden); - popover.classList.remove('visible'); - }); - - return element; - }(); - - var getPopover = function (e) { - var anchor = findPopovers(e.target); - - if (!anchor || !anchor.hash) return; - - popover = document.querySelector(anchor.hash); - - if (!popover || !popover.classList.contains('popover')) return; - - return popover; - } - - window.addEventListener('touchend', function (e) { - var popover = getPopover(e); - - if (!popover) return; - - popover.style.display = 'block'; - popover.offsetHeight; - popover.classList.add('visible'); - - popover.parentNode.appendChild(backdrop); - }); - - window.addEventListener('click', function (e) { if (getPopover(e)) e.preventDefault(); }); - }(); /* ---------------------------------- * PUSH v1.0.0 @@ -511,6 +450,7 @@ window.addEventListener('popstate', popstate); }(); + /* ---------------------------------- * TABS v1.0.0 * Licensed under The MIT License @@ -557,7 +497,8 @@ }); window.addEventListener('click', function (e) { if (getTarget(e.target)) e.preventDefault(); }); -}();/* ---------------------------------- +}(); +/* ---------------------------------- * SLIDER v1.0.1 * Licensed under The MIT License * Adapted from Brad Birdsall's swipe @@ -671,6 +612,7 @@ window.addEventListener('touchend', onTouchEnd); }(); + /* ---------------------------------- * TOGGLE v1.0.0 * Licensed under The MIT License diff --git a/package.json b/package.json index c0a8042..59f4079 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "grunt-contrib-nodeunit": "~0.2.0", "grunt-contrib-uglify": "~0.2.2", "grunt-contrib-sass": "~0.5.0", - "grunt-contrib-watch": "~0.5.3" + "grunt-contrib-watch": "~0.5.3", + "grunt-contrib-concat": "~0.3.0" }, "keywords": [ "ratchet",