Skip to content

Commit

Permalink
Merge pull request #148 from Gaya/module-based
Browse files Browse the repository at this point in the history
Go object based instead of relying on constructors
  • Loading branch information
Gaya committed Oct 15, 2015
2 parents 54c8d9a + 3c090b4 commit 183e0c0
Show file tree
Hide file tree
Showing 24 changed files with 1,011 additions and 855 deletions.
76 changes: 76 additions & 0 deletions .jscsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"esnext": true,
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInAnonymousFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"disallowSpacesInFunctionDeclaration": {
"beforeOpeningRoundBrace": true
},
"disallowEmptyBlocks": true,
"disallowSpacesInCallExpression": true,
"disallowSpacesInsideArrayBrackets": true,
"disallowSpacesInsideParentheses": true,
"disallowQuotedKeysInObjects": true,
"disallowSpaceAfterObjectKeys": true,
"disallowSpaceAfterPrefixUnaryOperators": true,
"disallowSpaceBeforePostfixUnaryOperators": true,
"disallowSpaceBeforeBinaryOperators": [
","
],
"disallowMixedSpacesAndTabs": true,
"disallowTrailingWhitespace": true,
"requireTrailingComma": { "ignoreSingleLine": true },
"disallowSpaceBeforeComma": true,
"requireSpaceAfterComma": true,
"disallowYodaConditions": true,
"disallowKeywords": [ "with" ],
"disallowKeywordsOnNewLine": ["else"],
"disallowMultipleLineBreaks": true,
"disallowMultipleLineStrings": true,
"disallowMultipleVarDecl": true,
"disallowSpaceBeforeSemicolon": true,
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": true,
"requireBlocksOnNewline": 1,
"requireCommaBeforeLineBreak": true,
"requireSpaceBeforeBinaryOperators": true,
"requireSpaceAfterBinaryOperators": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireLineFeedAtFileEnd": true,
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"requireSpacesInForStatement": true,
"requireSpaceBetweenArguments": true,
"requireCurlyBraces": [
"do"
],
"requireSpaceAfterKeywords": [
"if",
"else",
"for",
"while",
"do",
"switch",
"case",
"return",
"try",
"catch",
"typeof"
],
"requirePaddingNewLinesBeforeLineComments": {
"allExcept": "firstAfterCurly"
},
"requirePaddingNewLinesAfterBlocks": true,
"requireSemicolons": true,
"safeContextKeyword": "_this",
"validateLineBreaks": "LF",
"validateQuoteMarks": "'",
"validateIndentation": 2
}
21 changes: 21 additions & 0 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"bitwise" : true,
"curly" : true,
"eqeqeq" : true,
"forin" : true,
"immed" : true,
"latedef" : "nofunc",
"maxparams" : 4,
"newcap" : false,
"noarg" : true,
"noempty" : true,
"nonew" : true,
"undef" : true,
"unused" : true,
"node" : true,
"browser" : true,
"jquery" : true,
"globals" : {
"define" : false
}
}
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ node_js:
- "node"
- "0.12"
- "0.11"
- "0.10"
- "iojs"
notifications:
email: false
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
QueryLoader2
==============
QueryLoader2 is a better version of the old script posted in 2009. It serves the main purpose of preloading the images on your website by showing an overlay and a loading bar. It automatically fetches all your images and background images and preloads them before showing the webpage.
QueryLoader2 serves the main purpose of pre-loading the images on your website by showing an overlay and a loading bar. It automatically fetches all your images and background images and pre-loads them before showing the web page.

[![Code Climate](https://codeclimate.com/github/Gaya/QueryLoader2/badges/gpa.svg)](https://codeclimate.com/github/Gaya/QueryLoader2)
[![Build Status](https://travis-ci.org/Gaya/queryloader2.svg?branch=master)](https://travis-ci.org/Gaya/queryloader2)
Expand All @@ -9,7 +9,7 @@ Compatibility
-------------
QueryLoader currently works in IE version 9+, Chrome, Safari and Firefox.

**No dependencies**, so **no** jQuery / Zepto / MooTools needed.
**No dependencies**, so **no** jQuery / Zepto / MooTools required.

Read the full post here: [http://blog.gaya.ninja/articles/queryloader2-preload-your-images-with-ease/](http://blog.gaya.ninja/articles/queryloader2-preload-your-images-with-ease/)

Expand All @@ -25,7 +25,7 @@ Create a QueryLoader2 object like this for example:

<script type="text/javascript">
window.addEventListener('DOMContentLoaded', function() {
new QueryLoader2(document.querySelector("body"), {
QueryLoader2(document.querySelector("body"), {
barColor: "#efefef",
backgroundColor: "#111",
percentage: true,
Expand All @@ -46,14 +46,14 @@ Use it in a node / browserify project:

var QueryLoader2 = require("queryloader2");

var loader = new QueryLoader2(document.querySelector("body"), {
barColor: "#efefef",
backgroundColor: "#111",
percentage: true,
barHeight: 1,
minimumTime: 200,
fadeOutTime: 1000
});
var loader = QueryLoader2(document.querySelector("body"), {
barColor: "#efefef",
backgroundColor: "#111",
percentage: true,
barHeight: 1,
minimumTime: 200,
fadeOutTime: 1000
});

jQuery usage
------------
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "QueryLoader2",
"version": "3.0.16",
"version": "3.1.0",
"homepage": "http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/",
"authors": [
"Gaya <[email protected]>"
Expand Down
132 changes: 64 additions & 68 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,86 +1,82 @@
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
mochaPhantomJS = require('gulp-mocha-phantomjs'),
browserSync = require('browser-sync'),
uglify = require('gulp-uglify'),
rename = require("gulp-rename"),
header = require("gulp-header");
'use strict';
var gulp = require('gulp');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var mochaPhantomJS = require('gulp-mocha-phantomjs');
var browserSync = require('browser-sync');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var header = require('gulp-header');

var config = {
src: 'src',
dist: 'dist',
build: '',
test: 'test'
src: 'src',
dist: 'dist',
build: '',
test: 'test',
};
var pkg = require('./package.json');

gulp.task('browserify', function() {
'use strict';
return browserify('./' + config.src + '/main.js')
.bundle()
.on('error', function (err) {
console.log(err.toString());
this.emit('end');
})
.pipe(source(pkg.name + '.js'))
.pipe(gulp.dest(config.dist))
.pipe(browserSync.reload({stream:true}));
return browserify('./' + config.src + '/index.js')
.bundle()
.on('error', function(err) {
console.log(err.toString());
this.emit('end');
})
.pipe(source(pkg.name + '.js'))
.pipe(gulp.dest(config.dist))
.pipe(browserSync.reload({stream:true}));
});

gulp.task('browserify-tests', function() {
'use strict';
return browserify('./' + config.test + '/tests.js')
.bundle()
.on('error', function (err) {
console.log(err.toString());
this.emit('end');
})
.pipe(source(pkg.name + '-tests.js'))
.pipe(gulp.dest(config.dist))
.pipe(browserSync.reload({stream:true}));
return browserify('./' + config.test + '/tests.js')
.bundle()
.on('error', function(err) {
console.log(err.toString());
this.emit('end');
})
.pipe(source(pkg.name + '-tests.js'))
.pipe(gulp.dest(config.dist))
.pipe(browserSync.reload({stream:true}));
});

gulp.task('browser-sync', function() {
'use strict';
browserSync({
server: {
baseDir: ["./" + config.test + "/browser/", "./"]
}
});
browserSync({
server: {
baseDir: ['./' + config.test + '/browser/', './'],
},
});
});

gulp.task('serve-test', ['browserify', 'browserify-tests'], function () {
'use strict';
gulp.start('browser-sync');
gulp.watch(config.test + "/*.js", ['browserify', 'browserify-tests']);
gulp.watch(config.src + "/**/*.js", ['browserify', 'browserify-tests']);
gulp.task('serve-test', ['browserify', 'browserify-tests'], function() {
gulp.start('browser-sync');
gulp.watch(config.test + '/*.js', ['browserify', 'browserify-tests']);
gulp.watch(config.src + '/**/*.js', ['browserify', 'browserify-tests']);
});

gulp.task('build', ['browserify'], function () {
"use strict";
var headerText =
"/*\n" +
" * QueryLoader2 - A simple script to create a preloader for images\n" +
" *\n" +
" * For instructions read the original post:\n" +
" * http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/\n" +
" *\n" +
" * Copyright (c) 2011 - Gaya Kessler\n" +
" *\n" +
" * Licensed under the MIT license:\n" +
" * http://www.opensource.org/licenses/mit-license.php\n" +
" *\n" +
" * Version: <%= version %>\n" +
" * Last update: <%= date %>\n" +
" */\n";
gulp.task('build', ['browserify'], function() {
var headerText =
'/*\n' +
' * QueryLoader2 - A simple script to create a preloader for images\n' +
' *\n' +
' * For instructions read the original post:\n' +
' * http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/\n' +
' *\n' +
' * Copyright (c) 2011 - Gaya Kessler\n' +
' *\n' +
' * Licensed under the MIT license:\n' +
' * http://www.opensource.org/licenses/mit-license.php\n' +
' *\n' +
' * Version: <%= version %>\n' +
' * Last update: <%= date %>\n' +
' */\n';

gulp.src(config.dist + '/' + pkg.name + '.js')
.pipe(uglify())
.pipe(rename(pkg.name + '.min.js'))
.pipe(header(headerText, {
version: pkg.version,
date: new Date().toJSON().slice(0,10)
}))
.pipe(gulp.dest(config.build));
gulp.src(config.dist + '/' + pkg.name + '.js')
.pipe(uglify())
.pipe(rename(pkg.name + '.min.js'))
.pipe(header(headerText, {
version: pkg.version,
date: new Date().toJSON().slice(0, 10),
}))
.pipe(gulp.dest(config.build));
});
27 changes: 14 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
{
"name": "queryloader2",
"version": "3.0.16",
"version": "3.1.0",
"homepage": "http://gaya.ninja",
"description": "QueryLoader2 serves the main purpose of preloading the images on your website by showing an overlay and a loading bar. It automatically fetches all your images and background images and preloads them before showing the webpage.",
"dependencies": {
"browser-sync": "^1.3.0",
"browserify": "^4.2.3",
"gulp": "^3.8.6",
"gulp-header": "^1.0.5",
"gulp-mocha-phantomjs": "^0.3.0",
"gulp-rename": "^1.2.0",
"gulp-uglify": "^0.3.1",
"gulp-watch": "^0.6.8",
"mocha": "^1.21.3",
"mocha-phantomjs": "^3.5.3",
"vinyl-source-stream": "^0.1.1"
"browser-sync": "^2.9.11",
"browserify": "^11.2.0",
"gulp": "^3.9.0",
"gulp-header": "^1.7.1",
"gulp-mocha-phantomjs": "^0.10.1",
"gulp-rename": "^1.2.2",
"gulp-uglify": "^1.4.2",
"gulp-watch": "^4.3.5",
"jscs": "^2.3.1",
"mocha": "^2.3.3",
"mocha-phantomjs": "^4.0.1",
"vinyl-source-stream": "^1.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/Gaya/QueryLoader2"
},
"scripts": {
"postinstall": "node ./node_modules/gulp/bin/gulp.js browserify && node ./node_modules/gulp/bin/gulp.js browserify-tests",
"test": "node ./node_modules/mocha-phantomjs/bin/mocha-phantomjs test/browser/index.html"
"test": "node ./node_modules/jscs/bin/jscs src && node ./node_modules/gulp/bin/gulp.js browserify && node ./node_modules/gulp/bin/gulp.js browserify-tests && node ./node_modules/mocha-phantomjs/bin/mocha-phantomjs test/browser/index.html"
},
"main": "./src/main.js",
"author": {
Expand Down
Loading

0 comments on commit 183e0c0

Please sign in to comment.