Skip to content

Commit

Permalink
iScroll 5 beta 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Spinelli committed May 24, 2013
0 parents commit 8af643a
Show file tree
Hide file tree
Showing 67 changed files with 11,048 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
node_modules
3 changes: 3 additions & 0 deletions .nodemonignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/build/*
/dist/*
/demos/*
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Contributing to iScroll

All contributions are welcome but to enforce the openess of this script I have to ask all contributors to sign a Contributor License Agreement. I'm sorry about this but it's the only way to keep the script free and Open Source.

If you are an individual, please sign the following form:
http://cubiq.org/iscroll/cla/individual.html

If you are a company or an entity please sing the following form:
http://cubiq.org/iscroll/cla/individual.html

Thanks!
Matteo Spinelli
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2008-2013 Matteo Spinelli, http://cubiq.org/

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.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# iScroll 5 beta 1

Documentation soon to come. In the meantime please reference to the examples in the demos directory.

## Build system (for developers only)

iScroll comes with a custom build system. The required nodejs packages are included in the package.json. To build all main releases just do:

./build.js dist

The compiled scripts will be saved in the /build and /dist directories.
143 changes: 143 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
#!/usr/bin/env node

var pkg = require('./package.json');
var fs = require('fs');
var hint = require("jshint").JSHINT;
var uglify = require('uglify-js');

var banner = '/*! iScroll v' + pkg.version + ' ~ (c) 2008-' + (new Date().getFullYear()) + ' Matteo Spinelli ~ http://cubiq.org/license */\n';

var releases = {
// Main releases
lite: {
files: ['default/_animate.js', 'default/handleEvent.js']
},

iscroll: {
files: [
'indicator/_initIndicators.js',
'wheel/wheel.js',
'snap/snap.js',
'keys/keys.js',
'default/_animate.js',
'default/handleEvent.js',
'indicator/indicator.js'
],
postProcessing: [ 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json' ]
},

probe: {
files: [
'indicator/_initIndicators.js',
'wheel/wheel.js',
'snap/snap.js',
'keys/keys.js',
'probe/_animate.js',
'default/handleEvent.js',
'indicator/indicator.js'
],
postProcessing: [ 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json', 'probe/build.json' ]
},

zoom: {
files: [
'indicator/_initIndicators.js',
'zoom/zoom.js',
'wheel/wheel.js',
'snap/snap.js',
'keys/keys.js',
'default/_animate.js',
'zoom/handleEvent.js',
'indicator/indicator.js'
],
postProcessing: [ 'zoom/build.json', 'indicator/build.json', 'wheel/build.json', 'snap/build.json', 'keys/build.json' ]
}

// Additional releases TBD
};

var args = process.argv.slice(2);

if ( !args.length ) {
args = ['iscroll'];
}

if ( args[0] == 'dist' ) {
args = ['lite', 'iscroll', 'zoom', 'probe'];
}

// Get the list of files
args.forEach(function (release) {
if ( !(release in releases) ) {
console.log('Unrecognized release: ' + release);
return;
}

console.log('Building release: ' + release);
build(release);
});

function build (release) {
var out = '';
var value = '';

var fileList = ['open.js', 'utils.js', 'core.js'];

fileList = fileList.concat(releases[release].files);

fileList.push('close.js');

// Concatenate files
out = banner + fileList.map(function (filePath) {
return fs.readFileSync('src/' + filePath, 'utf-8');
}).join('');

// Update version
out = out.replace('/* VERSION */', pkg.version);

// Post processing
if ( releases[release].postProcessing ) {
releases[release].postProcessing.forEach(function (file) {
var postProcessing = require('./src/' + file);

// Insert point
for ( var i in postProcessing.insert ) {
value = postProcessing.insert[i].substr(postProcessing.insert[i].length-3) == '.js' ?
fs.readFileSync('src/' + postProcessing.insert[i]) :
postProcessing.insert[i];

out = out.replace('// INSERT POINT: ' + i, value + '\n\n// INSERT POINT: ' + i );
}

// Replace
for ( i in postProcessing.replace ) {
value = postProcessing.replace[i].substr(postProcessing.replace[i].length-3) == '.js' ?
fs.readFileSync('src/' + postProcessing.replace[i]) :
postProcessing.replace[i];

var regex = new RegExp('\\/\\* REPLACE START: ' + i + ' \\*\\/[\\s\\S]*\\/\\* REPLACE END: ' + i + ' \\*\\/');
out = out.replace(regex, '/* REPLACE START: ' + i + ' */' + value + '/* REPLACE END: ' + i + ' */');
}
});
}

// Write build file
var buildFile = './build/iscroll' + (release != 'iscroll' ? '-' + release : '') + '.js';
fs.writeFileSync(buildFile, out);

// JSHint
if ( !hint(out) ) {
var lines = out.split('\n');
hint.errors.forEach(function (err) {
console.log('\033[31m[' + err.code + ']\033[0m ' + err.line + ':' + err.character + '\t- ' + err.reason);
console.log('\033[33m' + lines[err.line-1].replace(/\t/g, ' ') + '\033[0m\n');
});

process.exit();
}

// Write dist file
var distFile = buildFile.replace('/build/', '/dist/').replace('.js', '-min.js');
out = uglify.minify(out, { fromString: true });
fs.writeFileSync(distFile, banner + out.code);
}
Loading

0 comments on commit 8af643a

Please sign in to comment.