Skip to content

Commit

Permalink
Add Grunt as a build tool, closes #84
Browse files Browse the repository at this point in the history
Size diff between current branch and master
     13000      (+115)  bin/javascripts/jquery.nanoscroller.js
      6623       (+71)  bin/javascripts/jquery.nanoscroller.min.js
      2130       (+55)  bin/javascripts/jquery.nanoscroller.min.js.gz
  • Loading branch information
Krister Kari committed Sep 1, 2012
1 parent 6302086 commit ec73fcc
Show file tree
Hide file tree
Showing 10 changed files with 228 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -39,3 +39,4 @@ Thumbs.db
publish.sh publish.sh


build/.sizecache.json build/.sizecache.json
node_modules
22 changes: 22 additions & 0 deletions LICENSE-MIT
@@ -0,0 +1,22 @@
Copyright (c) 2012 James Florentino

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
18 changes: 11 additions & 7 deletions README.md
Expand Up @@ -195,22 +195,26 @@ We are still working on doing a horizontal scrolling feature. If you're interest
To build nanoScroller from source you need the following libraries installed: To build nanoScroller from source you need the following libraries installed:


* Node.js and npm: [homepage / download](http://nodejs.org/) * Node.js and npm: [homepage / download](http://nodejs.org/)
* Coffeescript: [homepage](http://coffeescript.org/) | `npm install -g coffee-script` * Grunt: [homepage](http://gruntjs.com/) | `npm install -g grunt`


To allow the build process to convert the README file to HTML you also need: If you want to be able to build the README file to HTML you also need:


* Ruby (pre-installed in OS X): [homepage](http://www.ruby-lang.org/en/) | [download](http://www.ruby-lang.org/en/downloads/) * Ruby (pre-installed in OS X): [homepage](http://www.ruby-lang.org/en/) | [download](http://www.ruby-lang.org/en/downloads/)
* GCC: [homepage](http://gcc.gnu.org/) | [download for OS X](https://github.com/kennethreitz/osx-gcc-installer) * GCC: [homepage](http://gcc.gnu.org/) | [download for OS X](https://github.com/kennethreitz/osx-gcc-installer)
* Redcarpet: [homepage](https://github.com/tanoku/redcarpet) | `gem install redcarpet` (add `sudo` if needed) * Redcarpet: [homepage](https://github.com/tanoku/redcarpet) | `gem install redcarpet` (add `sudo` if needed)


#### How to build & contribute #### How to build & contribute


1. Make all JS changes in Coffeescript file(s), CSS changes in CSS file(s). 1. Make sure that you have [Grunt](http://gruntjs.com/) installed.
2. In terminal move to nanoscroller folder and run `cake build` 2. In terminal move to nanoscroller folder and run `npm install` to install all dependencies.
3. If you want to check how much the plugin size has changed compared to last build, run `cake size` * 3. Make all Javascript changes in Coffeescript file(s), CSS changes in CSS file(s).
4. Make sure that all changes are valid and open a pull request. 4. run `grunt` to build nanoScroller
5. Make sure that all changes are valid and open a pull request.


\* Uses `sizer.js` from [jQuery project](https://github.com/jquery/jquery/pull/511) #### How to run tests

1. You need to have [PhantomJS](http://phantomjs.org/) installed. On Mac OS X the easiest way is to install [Homebrew](http://mxcl.github.com/homebrew/) and run `brew install phantomjs`.
2. run `grunt test` in terminal


### Browser compatibility ### Browser compatibility


Expand Down
5 changes: 4 additions & 1 deletion bin/javascripts/jquery.nanoscroller.js
@@ -1,4 +1,7 @@
// Generated by CoffeeScript 1.3.3 /*! nanoScrollerJS - v0.6.9 - 2012-09-02
* http://jamesflorentino.github.com/nanoScrollerJS/
* Copyright (c) 2012 James Florentino; Licensed MIT */



(function($, window, document) { (function($, window, document) {
"use strict"; "use strict";
Expand Down
4 changes: 3 additions & 1 deletion bin/javascripts/jquery.nanoscroller.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 12 additions & 6 deletions bin/readme.html
Expand Up @@ -220,10 +220,10 @@ <h3>Development</h3>


<ul> <ul>
<li>Node.js and npm: <a href="http://nodejs.org/">homepage / download</a></li> <li>Node.js and npm: <a href="http://nodejs.org/">homepage / download</a></li>
<li>Coffeescript: <a href="http://coffeescript.org/">homepage</a> | <code>npm install -g coffee-script</code></li> <li>Grunt: <a href="http://gruntjs.com/">homepage</a> | <code>npm install -g grunt</code></li>
</ul> </ul>


<p>To allow the build process to convert the README file to HTML you also need:</p> <p>If you want to be able to build the README file to HTML you also need:</p>


<ul> <ul>
<li>Ruby (pre-installed in OS X): <a href="http://www.ruby-lang.org/en/">homepage</a> | <a href="http://www.ruby-lang.org/en/downloads/">download</a></li> <li>Ruby (pre-installed in OS X): <a href="http://www.ruby-lang.org/en/">homepage</a> | <a href="http://www.ruby-lang.org/en/downloads/">download</a></li>
Expand All @@ -234,13 +234,19 @@ <h3>Development</h3>
<h4>How to build &amp; contribute</h4> <h4>How to build &amp; contribute</h4>


<ol> <ol>
<li>Make all JS changes in Coffeescript file(s), CSS changes in CSS file(s).</li> <li>Make sure that you have <a href="http://gruntjs.com/">Grunt</a> installed.</li>
<li>In terminal move to nanoscroller folder and run <code>cake build</code></li> <li>In terminal move to nanoscroller folder and run <code>npm install</code> to install all dependencies.</li>
<li>If you want to check how much the plugin size has changed compared to last build, run <code>cake size</code> *</li> <li>Make all Javascript changes in Coffeescript file(s), CSS changes in CSS file(s).</li>
<li>run <code>grunt</code> to build nanoScroller</li>
<li>Make sure that all changes are valid and open a pull request.</li> <li>Make sure that all changes are valid and open a pull request.</li>
</ol> </ol>


<p>* Uses <code>sizer.js</code> from <a href="https://github.com/jquery/jquery/pull/511">jQuery project</a></p> <h4>How to run tests</h4>

<ol>
<li>You need to have <a href="http://phantomjs.org/">PhantomJS</a> installed. On Mac OS X the easiest way is to install <a href="http://mxcl.github.com/homebrew/">Homebrew</a> and run <code>brew install phantomjs</code>.</li>
<li>run <code>grunt test</code> in terminal</li>
</ol>


<h3>Browser compatibility</h3> <h3>Browser compatibility</h3>


Expand Down
128 changes: 128 additions & 0 deletions grunt.js
@@ -0,0 +1,128 @@
/*global module:false*/
module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-jasmine-task');
grunt.loadNpmTasks('grunt-coffee');
grunt.loadNpmTasks('grunt-css');
grunt.loadNpmTasks('grunt-closure-tools');
grunt.loadNpmTasks('grunt-sizediff');
grunt.loadNpmTasks('grunt-shell');

// Project configuration.
grunt.initConfig({
dirs: {
coffeeDir: 'coffeescripts',
jsDir: 'bin/javascripts',
cssDir: 'bin/css',
testDir: 'tests'
},
pkg: '<json:nanoscroller.jquery.json>',
meta: {
unmin: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' +
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */',
min: '/*! <%= pkg.title || pkg.name %> v<%= pkg.version %> ' +
'(c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */'
},
concat: {
unmin: {
src: ['<banner:meta.unmin>', '<file_strip_banner:bin/javascripts/<%= pkg.name %>.js>'],
dest: '<%= dirs.jsDir %>/<%= pkg.name %>.js'
},
min: {
src: ['<banner:meta.min>', '<file_strip_banner:bin/javascripts/<%= pkg.name %>.min.js>'],
dest: '<%= dirs.jsDir %>/<%= pkg.name %>.min.js'
}
},
csslint: {
all: {
src: '<%= dirs.cssDir %>/nanoscroller.css',
rules: {
'fallback-colors': false,
'known-properties': false,
'compatible-vendor-prefixes': false,
'adjoining-classes': false,
'empty-rules': true,
'zero-units': true,
ids: true,
important: true
}
}
},
coffee: {
nano: {
src: ['<%= dirs.coffeeDir %>/*.coffee'],
dest: '<%= dirs.jsDir %>',
options: {
bare: true
}
},
tests: {
src: ['<%= dirs.testDir %>/coffeescripts/*.coffee'],
dest: '<%= dirs.testDir %>/spec'
}
},
closureCompiler: {
all: {
closureCompiler: 'build/compiler.jar',
js: '<%= dirs.jsDir %>/<%= pkg.name %>.js',
output_file: '<%= dirs.jsDir %>/<%= pkg.name %>.min.js',
options: {
compilation_level: 'SIMPLE_OPTIMIZATIONS'
}
}
},
sizediff: {
all: {
files: [
'<%= dirs.jsDir %>/<%= pkg.name %>.js',
'<%= dirs.jsDir %>/<%= pkg.name %>.min.js'
]
}
},
jasmine: {
all: ['<%= dirs.testDir %>/SpecRunner.html']
},
lint: {
files: ['grunt.js']
},
watch: {
files: '<config:coffee.nano.src>',
tasks: 'default'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true,
browser: true
},
globals: {
jQuery: true
}
},
shell: {
redcarpet: {
command: 'redcarpet README.md > bin/readme.html',
stdout: true
}
}
});

grunt.registerTask('default', 'coffee:nano closureCompiler concat:unmin concat:min csslint lint sizediff');
grunt.registerTask('build', 'default');
grunt.registerTask('build:tests', 'coffee:tests');
grunt.registerTask('build:readme', 'shell:redcarpet');
grunt.registerTask('test', 'coffee:tests jasmine');
grunt.registerTask('size', 'sizediff');
};
29 changes: 29 additions & 0 deletions nanoscroller.jquery.json
@@ -0,0 +1,29 @@
{
"name": "jquery.nanoscroller",
"title": "nanoScrollerJS",
"description": "A jQuery plugin that offers a simplistic way of implementing Lion OS scrollbars.",
"version": "0.6.9",
"homepage": "http://jamesflorentino.github.com/nanoScrollerJS/",
"author": {
"name": "James Florentino",
"email": "j@jamesflorentino.com",
"url": "http://www.jamesflorentino.com"
},
"repository": {
"type": "git",
"url": "https://github.com/jamesflorentino/nanoScrollerJS.git"
},
"bugs": {
"url": "https://github.com/jamesflorentino/nanoScrollerJS/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://jamesflorentino.github.com/nanoScrollerJS//blob/master/LICENSE-MIT"
}
],
"dependencies": {
"jquery": ">= 1.6"
},
"keywords": []
}
18 changes: 18 additions & 0 deletions package.json
@@ -0,0 +1,18 @@
{
"name": "jquery-plugin",
"version": "0.0.0-ignored",
"engines": {
"node": ">= 0.6.0"
},
"dependencies": {
"grunt-css": ">= 0.2.1",
"grunt-coffee": ">= 0.0.6",
"grunt-jasmine-task": ">= 0.2.2",
"grunt-closure-tools": ">= 0.6.3",
"grunt-sizediff": ">= 0.2.1",
"grunt-shell": ">= 0.1.3"
},
"devDependencies": {
"grunt": "~0.3.14"
}
}
1 change: 0 additions & 1 deletion tests/spec/nano-spec.js
@@ -1,4 +1,3 @@
// Generated by CoffeeScript 1.3.3


describe("nanoScroller (with CSS: 'width: 200px, height 200px' set to .content)", function() { describe("nanoScroller (with CSS: 'width: 200px, height 200px' set to .content)", function() {
var $content, $nano, $pane, $slider, height, spyScrollend, spyScrolltop; var $content, $nano, $pane, $slider, height, spyScrollend, spyScrolltop;
Expand Down

0 comments on commit ec73fcc

Please sign in to comment.