From ca70b406d5b2ffab67acd3d564d4f8f04204ae52 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:01:39 +0200 Subject: [PATCH 01/58] add jscs --- .jscsrc | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .jscsrc diff --git a/.jscsrc b/.jscsrc new file mode 100644 index 0000000..8423064 --- /dev/null +++ b/.jscsrc @@ -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 +} \ No newline at end of file From 05ac609c118506883837d27d4742c85a699c54e6 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:09:49 +0200 Subject: [PATCH 02/58] add instantiate checking --- test/tests.js | 191 ++++++++++++++++++++++++++------------------------ 1 file changed, 100 insertions(+), 91 deletions(-) diff --git a/test/tests.js b/test/tests.js index 319f2e2..4943cb1 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,11 +1,11 @@ -var assert = require("assert"); +var assert = require('assert'); -var Overlay = require("../src/Overlay/"); -var LoadingBar = require("../src/Overlay/LoadingBar.js"); -var Percentage = require("../src/Overlay/Percentage.js"); -var Image = require("../src/ImagePreloader/Image.js"); -var ImagePreloader = require("../src/ImagePreloader/"); -var QueryLoader = require("../src/QueryLoader.js"); +var Overlay = require('../src/Overlay/'); +var LoadingBar = require('../src/Overlay/LoadingBar.js'); +var Percentage = require('../src/Overlay/Percentage.js'); +var Image = require('../src/ImagePreloader/Image.js'); +var ImagePreloader = require('../src/ImagePreloader/'); +var QueryLoader = require('../src/QueryLoader.js'); describe('LoadingBar', function() { describe('#create()', function () { @@ -14,15 +14,15 @@ describe('LoadingBar', function() { it('should create an element for itself', function () { assert.notEqual(null, lb.element); - assert.notEqual("undefined", typeof lb.element); - assert.notEqual("undefined", typeof lb.element.tagName); - assert.equal("div", lb.element.tagName.toLowerCase()); - assert.equal(lb.className, lb.element.getAttribute("class")); + assert.notEqual('undefined', typeof lb.element); + assert.notEqual('undefined', typeof lb.element.tagName); + assert.equal('div', lb.element.tagName.toLowerCase()); + assert.equal(lb.className, lb.element.getAttribute('class')); }); it('should apply default styling', function () { - assert.equal("absolute", lb.element.style.position); - assert.equal(lb.barHeight + "px", lb.element.style.height); + assert.equal('absolute', lb.element.style.position); + assert.equal(lb.barHeight + 'px', lb.element.style.height); }); }); @@ -31,27 +31,27 @@ describe('LoadingBar', function() { var lb = new LoadingBar(); lb.create(); - assert.equal("0%", lb.element.style.width); + assert.equal('0%', lb.element.style.width); lb.updateProgress(10, 0); - assert.equal("10%", lb.element.style.width); + assert.equal('10%', lb.element.style.width); lb.updateProgress(50, 0); - assert.equal("50%", lb.element.style.width); + assert.equal('50%', lb.element.style.width); lb.updateProgress(100, 0); - assert.equal("100%", lb.element.style.width); + assert.equal('100%', lb.element.style.width); lb.updateProgress(-20, 0); - assert.equal("0%", lb.element.style.width); + assert.equal('0%', lb.element.style.width); lb.updateProgress(420, 0); - assert.equal("100%", lb.element.style.width); + assert.equal('100%', lb.element.style.width); }); it('should not break on floats', function () { @@ -60,11 +60,11 @@ describe('LoadingBar', function() { lb.updateProgress(10.6, 0); - assert.equal("10%", lb.element.style.width); + assert.equal('10%', lb.element.style.width); lb.updateProgress(50.456, 0); - assert.equal("50%", lb.element.style.width); + assert.equal('50%', lb.element.style.width); }); }); }); @@ -76,14 +76,14 @@ describe('Percentage', function() { it('should create an element for itself', function () { assert.notEqual(null, p.element); - assert.notEqual("undefined", typeof p.element); - assert.notEqual("undefined", typeof p.element.tagName); - assert.equal("div", p.element.tagName.toLowerCase()); - assert.equal(p.className, p.element.getAttribute("class")); + assert.notEqual('undefined', typeof p.element); + assert.notEqual('undefined', typeof p.element.tagName); + assert.equal('div', p.element.tagName.toLowerCase()); + assert.equal(p.className, p.element.getAttribute('class')); }); it('should apply default styling', function () { - assert.equal("absolute", p.element.style.position); + assert.equal('absolute', p.element.style.position); }); }); @@ -92,43 +92,43 @@ describe('Percentage', function() { p.create(); it('should update the progress and adjust the loading bar', function () { - assert.equal("0%", p.element.innerHTML); + assert.equal('0%', p.element.innerHTML); p.updateProgress(10, 0); - assert.equal("10%", p.element.innerHTML); + assert.equal('10%', p.element.innerHTML); p.updateProgress(50, 0); - assert.equal("50%", p.element.innerHTML); + assert.equal('50%', p.element.innerHTML); p.updateProgress(100, 0); - assert.equal("100%", p.element.innerHTML); + assert.equal('100%', p.element.innerHTML); p.updateProgress(-20, 0); - assert.equal("0%", p.element.innerHTML); + assert.equal('0%', p.element.innerHTML); p.updateProgress(420, 0); - assert.equal("100%", p.element.innerHTML); + assert.equal('100%', p.element.innerHTML); }); it('should not break on floats', function () { p.updateProgress(10.6, 0); - assert.equal("10%", p.element.innerHTML); + assert.equal('10%', p.element.innerHTML); p.updateProgress(50.456, 0); - assert.equal("50%", p.element.innerHTML); + assert.equal('50%', p.element.innerHTML); }); }); }); describe('Overlay', function() { - var fakeBody = document.createElement("body"); + var fakeBody = document.createElement('body'); describe('#create()', function () { var o = new Overlay(fakeBody); @@ -136,10 +136,10 @@ describe('Overlay', function() { it('should create an element for itself', function () { assert.notEqual(null, o.element); - assert.notEqual("undefined", typeof o.element); - assert.notEqual("undefined", typeof o.element.tagName); - assert.equal("div", o.element.tagName.toLowerCase()); - assert.equal(o.className, o.element.getAttribute("class")); + assert.notEqual('undefined', typeof o.element); + assert.notEqual('undefined', typeof o.element.tagName); + assert.equal('div', o.element.tagName.toLowerCase()); + assert.equal(o.className, o.element.getAttribute('class')); }); }); @@ -149,19 +149,19 @@ describe('Overlay', function() { it('should give the correct needed position of the overlay', function () { o.parentElement = fakeBody; - assert.equal("fixed", o.calculatePosition()); + assert.equal('fixed', o.calculatePosition()); - var fakeContainer = document.createElement("div"); - fakeContainer.style.position = "static"; + var fakeContainer = document.createElement('div'); + fakeContainer.style.position = 'static'; o.parentElement = fakeContainer; - assert.equal("absolute", o.calculatePosition()); - assert.equal("relative", o.parentElement.style.position); + assert.equal('absolute', o.calculatePosition()); + assert.equal('relative', o.parentElement.style.position); - o.parentElement.style.position = "absolute"; + o.parentElement.style.position = 'absolute'; - assert.equal("absolute", o.calculatePosition()); + assert.equal('absolute', o.calculatePosition()); }); }); @@ -177,13 +177,13 @@ describe('Overlay', function() { o.loadingBar.create(); it('should update the loading progress of both percentage and loadingbar', function () { - assert.equal("0%", o.percentage.element.innerHTML); - assert.equal("0%", o.loadingBar.element.style.width); + assert.equal('0%', o.percentage.element.innerHTML); + assert.equal('0%', o.loadingBar.element.style.width); o.updateProgress(10, 0); - assert.equal("10%", o.percentage.element.innerHTML); - assert.equal("10%", o.loadingBar.element.style.width); + assert.equal('10%', o.percentage.element.innerHTML); + assert.equal('10%', o.loadingBar.element.style.width); }); }); }); @@ -191,21 +191,21 @@ describe('Overlay', function() { describe('Image', function() { describe('#constructor()', function () { it('should create an image object with given src', function () { - var exampleImage = new Image("some/src"); + var exampleImage = new Image('some/src'); - assert.equal("some/src", exampleImage.src); + assert.equal('some/src', exampleImage.src); }); it('should create a dom object with given src', function () { - var exampleImage = new Image("some/src"); + var exampleImage = new Image('some/src'); - assert.notEqual(-1, exampleImage.element.src.indexOf("some/src")); + assert.notEqual(-1, exampleImage.element.src.indexOf('some/src')); }); }); describe('#preload()', function () { it('should callback when an image is loaded', function (done) { - var exampleImage = new Image("images/1.jpg"); + var exampleImage = new Image('images/1.jpg'); exampleImage.preload(done); }); @@ -213,6 +213,15 @@ describe('Image', function() { }); describe('QueryLoader', function() { + describe('#constructor', function () { + it('should be the same not matter how you instantiate', function () { + var qlNew = new QueryLoader(); + var qlFactory = QueryLoader(); + + assert.equal(qlNew, qlFactory); + }); + }); + describe('#createOverlay()', function () { var ql = new QueryLoader(); @@ -238,27 +247,27 @@ describe('QueryLoader', function() { var ql = new QueryLoader(); var destination = { - some: "thing", - is: "not", - right: "man" + some: 'thing', + is: 'not', + right: 'man' }; var source = { - some: "one", - right: "dude" + some: 'one', + right: 'dude' }; assert.deepEqual({ - "some": "one", - "is": "not", - "right": "dude" + 'some': 'one', + 'is': 'not', + 'right': 'dude' }, ql.extend(destination, source)); }); }); describe('#updateProgress()', function () { var called = false; - var ql = new QueryLoader(document.createElement("div"), { + var ql = new QueryLoader(document.createElement('div'), { onProgress: function (amount) { called = true; } @@ -273,40 +282,40 @@ describe('QueryLoader', function() { }); describe('ImagePreloader', function() { - "use strict"; + 'use strict'; describe('#getImageSrcs()', function () { var ip = new ImagePreloader(); - var fakeImagesContainer = document.createElement("div"); + var fakeImagesContainer = document.createElement('div'); - var img1 = document.createElement("img"); - img1.setAttribute("src", "fakeimg1.png"); + var img1 = document.createElement('img'); + img1.setAttribute('src', 'fakeimg1.png'); fakeImagesContainer.appendChild(img1); - var img2 = document.createElement("img"); - img2.setAttribute("src", "fakeimg2.png"); + var img2 = document.createElement('img'); + img2.setAttribute('src', 'fakeimg2.png'); fakeImagesContainer.appendChild(img2); - var img3 = document.createElement("section"); - img3.style.backgroundImage = "url(fakeimg3.png)"; + var img3 = document.createElement('section'); + img3.style.backgroundImage = 'url(fakeimg3.png)'; fakeImagesContainer.appendChild(img3); - var img4 = document.createElement("section"); - img4.style.backgroundImage = "linear-gradient(left, #fff, #eee)"; + var img4 = document.createElement('section'); + img4.style.backgroundImage = 'linear-gradient(left, #fff, #eee)'; fakeImagesContainer.appendChild(img4); - var img5 = document.createElement("section"); - img5.style.background = "url(fakeimg5.png)"; + var img5 = document.createElement('section'); + img5.style.background = 'url(fakeimg5.png)'; fakeImagesContainer.appendChild(img5); it('should get all images within the given element', function () { var images = ip.getImageSrcs(fakeImagesContainer); assert.equal(4, images.length); - assert.notEqual(-1, images[0].indexOf("fakeimg1.png")); - assert.notEqual(-1, images[1].indexOf("fakeimg2.png")); - assert.notEqual(-1, images[2].indexOf("fakeimg3.png")); - assert.notEqual(-1, images[3].indexOf("fakeimg5.png")); + assert.notEqual(-1, images[0].indexOf('fakeimg1.png')); + assert.notEqual(-1, images[1].indexOf('fakeimg2.png')); + assert.notEqual(-1, images[2].indexOf('fakeimg3.png')); + assert.notEqual(-1, images[3].indexOf('fakeimg5.png')); }); }); @@ -314,9 +323,9 @@ describe('ImagePreloader', function() { var ip = new ImagePreloader(); it('should check if given url has a gradient', function () { - assert.equal(false, ip.hasGradient("hasnogradienthere.png")); - assert.equal(false, ip.hasGradient("grasdfsadg")); - assert.equal(true, ip.hasGradient("linear-gradient(left, #fff, #fff)")); + assert.equal(false, ip.hasGradient('hasnogradienthere.png')); + assert.equal(false, ip.hasGradient('grasdfsadg')); + assert.equal(true, ip.hasGradient('linear-gradient(left, #fff, #fff)')); }); }); @@ -324,8 +333,8 @@ describe('ImagePreloader', function() { var ip = new ImagePreloader(); it('should strip the url() part from given src', function () { - assert.equal(-1, ip.stripUrl("url(this/path/file.png)").indexOf("url")); - assert.equal(-1, ip.stripUrl("file.png").indexOf("url")); + assert.equal(-1, ip.stripUrl('url(this/path/file.png)').indexOf('url')); + assert.equal(-1, ip.stripUrl('file.png').indexOf('url')); }); }); @@ -333,19 +342,19 @@ describe('ImagePreloader', function() { var ip = new ImagePreloader(); it('should check if given url is valid', function () { - assert.equal(false, ip.validUrl("")); - assert.equal(false, ip.validUrl("data:blablabla")); - assert.equal(true, ip.validUrl("/this/is/valid.png")); + assert.equal(false, ip.validUrl('')); + assert.equal(false, ip.validUrl('data:blablabla')); + assert.equal(true, ip.validUrl('/this/is/valid.png')); }); }); describe('#urlIsNew()', function () { var ip = new ImagePreloader(); - ip.sources = ["test.png", "something.png", "image.jpg"]; + ip.sources = ['test.png', 'something.png', 'image.jpg']; it('should check if given url is new in this.images', function () { - assert.equal(false, ip.urlIsNew("image.jpg")); - assert.equal(true, ip.urlIsNew("new.png")); + assert.equal(false, ip.urlIsNew('image.jpg')); + assert.equal(true, ip.urlIsNew('new.png')); }); }); }); \ No newline at end of file From fc7134723f8a2e4c969569e9c89ab27a62b329a3 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:14:41 +0200 Subject: [PATCH 03/58] fixed jscs --- test/tests.js | 476 +++++++++++++++++++++++++------------------------- 1 file changed, 238 insertions(+), 238 deletions(-) diff --git a/test/tests.js b/test/tests.js index 4943cb1..96d4036 100644 --- a/test/tests.js +++ b/test/tests.js @@ -8,353 +8,353 @@ var ImagePreloader = require('../src/ImagePreloader/'); var QueryLoader = require('../src/QueryLoader.js'); describe('LoadingBar', function() { - describe('#create()', function () { - var lb = new LoadingBar(); - lb.create(); - - it('should create an element for itself', function () { - assert.notEqual(null, lb.element); - assert.notEqual('undefined', typeof lb.element); - assert.notEqual('undefined', typeof lb.element.tagName); - assert.equal('div', lb.element.tagName.toLowerCase()); - assert.equal(lb.className, lb.element.getAttribute('class')); - }); - - it('should apply default styling', function () { - assert.equal('absolute', lb.element.style.position); - assert.equal(lb.barHeight + 'px', lb.element.style.height); - }); + describe('#create()', function() { + var lb = new LoadingBar(); + lb.create(); + + it('should create an element for itself', function() { + assert.notEqual(null, lb.element); + assert.notEqual('undefined', typeof lb.element); + assert.notEqual('undefined', typeof lb.element.tagName); + assert.equal('div', lb.element.tagName.toLowerCase()); + assert.equal(lb.className, lb.element.getAttribute('class')); }); - describe('#updateProgress()', function () { - it('should update the progress and adjust the loading bar', function () { - var lb = new LoadingBar(); - lb.create(); + it('should apply default styling', function() { + assert.equal('absolute', lb.element.style.position); + assert.equal(lb.barHeight + 'px', lb.element.style.height); + }); + }); + + describe('#updateProgress()', function() { + it('should update the progress and adjust the loading bar', function() { + var lb = new LoadingBar(); + lb.create(); - assert.equal('0%', lb.element.style.width); + assert.equal('0%', lb.element.style.width); - lb.updateProgress(10, 0); + lb.updateProgress(10, 0); - assert.equal('10%', lb.element.style.width); + assert.equal('10%', lb.element.style.width); - lb.updateProgress(50, 0); + lb.updateProgress(50, 0); - assert.equal('50%', lb.element.style.width); + assert.equal('50%', lb.element.style.width); - lb.updateProgress(100, 0); + lb.updateProgress(100, 0); - assert.equal('100%', lb.element.style.width); + assert.equal('100%', lb.element.style.width); - lb.updateProgress(-20, 0); + lb.updateProgress(-20, 0); - assert.equal('0%', lb.element.style.width); + assert.equal('0%', lb.element.style.width); - lb.updateProgress(420, 0); + lb.updateProgress(420, 0); - assert.equal('100%', lb.element.style.width); - }); + assert.equal('100%', lb.element.style.width); + }); - it('should not break on floats', function () { - var lb = new LoadingBar(); - lb.create(); + it('should not break on floats', function() { + var lb = new LoadingBar(); + lb.create(); - lb.updateProgress(10.6, 0); + lb.updateProgress(10.6, 0); - assert.equal('10%', lb.element.style.width); + assert.equal('10%', lb.element.style.width); - lb.updateProgress(50.456, 0); + lb.updateProgress(50.456, 0); - assert.equal('50%', lb.element.style.width); - }); + assert.equal('50%', lb.element.style.width); }); + }); }); describe('Percentage', function() { - describe('#create()', function () { - var p = new Percentage(); - p.create(); - - it('should create an element for itself', function () { - assert.notEqual(null, p.element); - assert.notEqual('undefined', typeof p.element); - assert.notEqual('undefined', typeof p.element.tagName); - assert.equal('div', p.element.tagName.toLowerCase()); - assert.equal(p.className, p.element.getAttribute('class')); - }); - - it('should apply default styling', function () { - assert.equal('absolute', p.element.style.position); - }); + describe('#create()', function() { + var p = new Percentage(); + p.create(); + + it('should create an element for itself', function() { + assert.notEqual(null, p.element); + assert.notEqual('undefined', typeof p.element); + assert.notEqual('undefined', typeof p.element.tagName); + assert.equal('div', p.element.tagName.toLowerCase()); + assert.equal(p.className, p.element.getAttribute('class')); + }); + + it('should apply default styling', function() { + assert.equal('absolute', p.element.style.position); }); + }); - describe('#updateProgress()', function () { - var p = new Percentage(); - p.create(); + describe('#updateProgress()', function() { + var p = new Percentage(); + p.create(); - it('should update the progress and adjust the loading bar', function () { - assert.equal('0%', p.element.innerHTML); + it('should update the progress and adjust the loading bar', function() { + assert.equal('0%', p.element.innerHTML); - p.updateProgress(10, 0); + p.updateProgress(10, 0); - assert.equal('10%', p.element.innerHTML); + assert.equal('10%', p.element.innerHTML); - p.updateProgress(50, 0); + p.updateProgress(50, 0); - assert.equal('50%', p.element.innerHTML); + assert.equal('50%', p.element.innerHTML); - p.updateProgress(100, 0); + p.updateProgress(100, 0); - assert.equal('100%', p.element.innerHTML); + assert.equal('100%', p.element.innerHTML); - p.updateProgress(-20, 0); + p.updateProgress(-20, 0); - assert.equal('0%', p.element.innerHTML); + assert.equal('0%', p.element.innerHTML); - p.updateProgress(420, 0); + p.updateProgress(420, 0); - assert.equal('100%', p.element.innerHTML); - }); + assert.equal('100%', p.element.innerHTML); + }); - it('should not break on floats', function () { - p.updateProgress(10.6, 0); + it('should not break on floats', function() { + p.updateProgress(10.6, 0); - assert.equal('10%', p.element.innerHTML); + assert.equal('10%', p.element.innerHTML); - p.updateProgress(50.456, 0); + p.updateProgress(50.456, 0); - assert.equal('50%', p.element.innerHTML); - }); + assert.equal('50%', p.element.innerHTML); }); + }); }); describe('Overlay', function() { - var fakeBody = document.createElement('body'); - - describe('#create()', function () { - var o = new Overlay(fakeBody); - o.create(); - - it('should create an element for itself', function () { - assert.notEqual(null, o.element); - assert.notEqual('undefined', typeof o.element); - assert.notEqual('undefined', typeof o.element.tagName); - assert.equal('div', o.element.tagName.toLowerCase()); - assert.equal(o.className, o.element.getAttribute('class')); - }); + var fakeBody = document.createElement('body'); + + describe('#create()', function() { + var o = new Overlay(fakeBody); + o.create(); + + it('should create an element for itself', function() { + assert.notEqual(null, o.element); + assert.notEqual('undefined', typeof o.element); + assert.notEqual('undefined', typeof o.element.tagName); + assert.equal('div', o.element.tagName.toLowerCase()); + assert.equal(o.className, o.element.getAttribute('class')); }); + }); - describe('#calculatePosition()', function () { - var o = new Overlay(); + describe('#calculatePosition()', function() { + var o = new Overlay(); - it('should give the correct needed position of the overlay', function () { - o.parentElement = fakeBody; + it('should give the correct needed position of the overlay', function() { + o.parentElement = fakeBody; - assert.equal('fixed', o.calculatePosition()); + assert.equal('fixed', o.calculatePosition()); - var fakeContainer = document.createElement('div'); - fakeContainer.style.position = 'static'; + var fakeContainer = document.createElement('div'); + fakeContainer.style.position = 'static'; - o.parentElement = fakeContainer; + o.parentElement = fakeContainer; - assert.equal('absolute', o.calculatePosition()); - assert.equal('relative', o.parentElement.style.position); + assert.equal('absolute', o.calculatePosition()); + assert.equal('relative', o.parentElement.style.position); - o.parentElement.style.position = 'absolute'; + o.parentElement.style.position = 'absolute'; - assert.equal('absolute', o.calculatePosition()); - }); + assert.equal('absolute', o.calculatePosition()); }); + }); - describe('#updateProgess()', function () { - var o = new Overlay(); - o.parentElement = fakeBody; - o.create(); + describe('#updateProgess()', function() { + var o = new Overlay(); + o.parentElement = fakeBody; + o.create(); - o.percentage = new Percentage(); - o.percentage.create(); + o.percentage = new Percentage(); + o.percentage.create(); - o.loadingBar = new LoadingBar(); - o.loadingBar.create(); + o.loadingBar = new LoadingBar(); + o.loadingBar.create(); - it('should update the loading progress of both percentage and loadingbar', function () { - assert.equal('0%', o.percentage.element.innerHTML); - assert.equal('0%', o.loadingBar.element.style.width); + it('should update the loading progress of both percentage and loadingbar', function() { + assert.equal('0%', o.percentage.element.innerHTML); + assert.equal('0%', o.loadingBar.element.style.width); - o.updateProgress(10, 0); + o.updateProgress(10, 0); - assert.equal('10%', o.percentage.element.innerHTML); - assert.equal('10%', o.loadingBar.element.style.width); - }); + assert.equal('10%', o.percentage.element.innerHTML); + assert.equal('10%', o.loadingBar.element.style.width); }); + }); }); describe('Image', function() { - describe('#constructor()', function () { - it('should create an image object with given src', function () { - var exampleImage = new Image('some/src'); + describe('#constructor()', function() { + it('should create an image object with given src', function() { + var exampleImage = new Image('some/src'); - assert.equal('some/src', exampleImage.src); - }); + assert.equal('some/src', exampleImage.src); + }); - it('should create a dom object with given src', function () { - var exampleImage = new Image('some/src'); + it('should create a dom object with given src', function() { + var exampleImage = new Image('some/src'); - assert.notEqual(-1, exampleImage.element.src.indexOf('some/src')); - }); + assert.notEqual(-1, exampleImage.element.src.indexOf('some/src')); }); + }); - describe('#preload()', function () { - it('should callback when an image is loaded', function (done) { - var exampleImage = new Image('images/1.jpg'); + describe('#preload()', function() { + it('should callback when an image is loaded', function(done) { + var exampleImage = new Image('images/1.jpg'); - exampleImage.preload(done); - }); + exampleImage.preload(done); }); + }); }); describe('QueryLoader', function() { - describe('#constructor', function () { - it('should be the same not matter how you instantiate', function () { - var qlNew = new QueryLoader(); - var qlFactory = QueryLoader(); + describe('#constructor', function() { + it('should be the same not matter how you instantiate', function() { + var qlNew = new QueryLoader(); + var qlFactory = QueryLoader(); - assert.equal(qlNew, qlFactory); - }); + assert.equal(qlNew, qlFactory); }); + }); - describe('#createOverlay()', function () { - var ql = new QueryLoader(); + describe('#createOverlay()', function() { + var ql = new QueryLoader(); - it('should create an overlay when called', function () { - ql.createOverlay(); + it('should create an overlay when called', function() { + ql.createOverlay(); - assert.equal(ql.overlay instanceof Overlay, true); - }); + assert.equal(ql.overlay instanceof Overlay, true); }); + }); - describe('#createPreloader()', function () { - var ql = new QueryLoader(); + describe('#createPreloader()', function() { + var ql = new QueryLoader(); - it('should create the preloader', function () { - ql.createPreloader(); + it('should create the preloader', function() { + ql.createPreloader(); - assert.equal(ql.preloader instanceof ImagePreloader, true); - }); + assert.equal(ql.preloader instanceof ImagePreloader, true); }); - - describe('#extend()', function () { - it('should merge two objects', function () { - var ql = new QueryLoader(); - - var destination = { - some: 'thing', - is: 'not', - right: 'man' - }; - - var source = { - some: 'one', - right: 'dude' - }; - - assert.deepEqual({ - 'some': 'one', - 'is': 'not', - 'right': 'dude' - }, ql.extend(destination, source)); - }); + }); + + describe('#extend()', function() { + it('should merge two objects', function() { + var ql = new QueryLoader(); + + var destination = { + some: 'thing', + is: 'not', + right: 'man', + }; + + var source = { + some: 'one', + right: 'dude', + }; + + assert.deepEqual({ + some: 'one', + is: 'not', + right: 'dude', + }, ql.extend(destination, source)); + }); + }); + + describe('#updateProgress()', function() { + var called = false; + var ql = new QueryLoader(document.createElement('div'), { + onProgress: function(amount) { + called = true; + }, }); - describe('#updateProgress()', function () { - var called = false; - var ql = new QueryLoader(document.createElement('div'), { - onProgress: function (amount) { - called = true; - } - }); - - it('should call the onProgress event', function () { - ql.updateProgress(); + it('should call the onProgress event', function() { + ql.updateProgress(); - assert.equal(called, true); - }); + assert.equal(called, true); }); + }); }); describe('ImagePreloader', function() { - 'use strict'; - describe('#getImageSrcs()', function () { - var ip = new ImagePreloader(); + 'use strict'; + describe('#getImageSrcs()', function() { + var ip = new ImagePreloader(); - var fakeImagesContainer = document.createElement('div'); + var fakeImagesContainer = document.createElement('div'); - var img1 = document.createElement('img'); - img1.setAttribute('src', 'fakeimg1.png'); - fakeImagesContainer.appendChild(img1); + var img1 = document.createElement('img'); + img1.setAttribute('src', 'fakeimg1.png'); + fakeImagesContainer.appendChild(img1); - var img2 = document.createElement('img'); - img2.setAttribute('src', 'fakeimg2.png'); - fakeImagesContainer.appendChild(img2); + var img2 = document.createElement('img'); + img2.setAttribute('src', 'fakeimg2.png'); + fakeImagesContainer.appendChild(img2); - var img3 = document.createElement('section'); - img3.style.backgroundImage = 'url(fakeimg3.png)'; - fakeImagesContainer.appendChild(img3); + var img3 = document.createElement('section'); + img3.style.backgroundImage = 'url(fakeimg3.png)'; + fakeImagesContainer.appendChild(img3); - var img4 = document.createElement('section'); - img4.style.backgroundImage = 'linear-gradient(left, #fff, #eee)'; - fakeImagesContainer.appendChild(img4); + var img4 = document.createElement('section'); + img4.style.backgroundImage = 'linear-gradient(left, #fff, #eee)'; + fakeImagesContainer.appendChild(img4); - var img5 = document.createElement('section'); - img5.style.background = 'url(fakeimg5.png)'; - fakeImagesContainer.appendChild(img5); + var img5 = document.createElement('section'); + img5.style.background = 'url(fakeimg5.png)'; + fakeImagesContainer.appendChild(img5); - it('should get all images within the given element', function () { - var images = ip.getImageSrcs(fakeImagesContainer); + it('should get all images within the given element', function() { + var images = ip.getImageSrcs(fakeImagesContainer); - assert.equal(4, images.length); - assert.notEqual(-1, images[0].indexOf('fakeimg1.png')); - assert.notEqual(-1, images[1].indexOf('fakeimg2.png')); - assert.notEqual(-1, images[2].indexOf('fakeimg3.png')); - assert.notEqual(-1, images[3].indexOf('fakeimg5.png')); - }); + assert.equal(4, images.length); + assert.notEqual(-1, images[0].indexOf('fakeimg1.png')); + assert.notEqual(-1, images[1].indexOf('fakeimg2.png')); + assert.notEqual(-1, images[2].indexOf('fakeimg3.png')); + assert.notEqual(-1, images[3].indexOf('fakeimg5.png')); }); + }); - describe('#hasGradient()', function () { - var ip = new ImagePreloader(); + describe('#hasGradient()', function() { + var ip = new ImagePreloader(); - it('should check if given url has a gradient', function () { - assert.equal(false, ip.hasGradient('hasnogradienthere.png')); - assert.equal(false, ip.hasGradient('grasdfsadg')); - assert.equal(true, ip.hasGradient('linear-gradient(left, #fff, #fff)')); - }); + it('should check if given url has a gradient', function() { + assert.equal(false, ip.hasGradient('hasnogradienthere.png')); + assert.equal(false, ip.hasGradient('grasdfsadg')); + assert.equal(true, ip.hasGradient('linear-gradient(left, #fff, #fff)')); }); + }); - describe('#stripUrl()', function () { - var ip = new ImagePreloader(); + describe('#stripUrl()', function() { + var ip = new ImagePreloader(); - it('should strip the url() part from given src', function () { - assert.equal(-1, ip.stripUrl('url(this/path/file.png)').indexOf('url')); - assert.equal(-1, ip.stripUrl('file.png').indexOf('url')); - }); + it('should strip the url() part from given src', function() { + assert.equal(-1, ip.stripUrl('url(this/path/file.png)').indexOf('url')); + assert.equal(-1, ip.stripUrl('file.png').indexOf('url')); }); + }); - describe('#validUrl()', function () { - var ip = new ImagePreloader(); + describe('#validUrl()', function() { + var ip = new ImagePreloader(); - it('should check if given url is valid', function () { - assert.equal(false, ip.validUrl('')); - assert.equal(false, ip.validUrl('data:blablabla')); - assert.equal(true, ip.validUrl('/this/is/valid.png')); - }); + it('should check if given url is valid', function() { + assert.equal(false, ip.validUrl('')); + assert.equal(false, ip.validUrl('data:blablabla')); + assert.equal(true, ip.validUrl('/this/is/valid.png')); }); + }); - describe('#urlIsNew()', function () { - var ip = new ImagePreloader(); - ip.sources = ['test.png', 'something.png', 'image.jpg']; + describe('#urlIsNew()', function() { + var ip = new ImagePreloader(); + ip.sources = ['test.png', 'something.png', 'image.jpg']; - it('should check if given url is new in this.images', function () { - assert.equal(false, ip.urlIsNew('image.jpg')); - assert.equal(true, ip.urlIsNew('new.png')); - }); + it('should check if given url is new in this.images', function() { + assert.equal(false, ip.urlIsNew('image.jpg')); + assert.equal(true, ip.urlIsNew('new.png')); }); + }); }); \ No newline at end of file From f962c81c5f6dc08a3c7814ef7754ac595687fff8 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:16:02 +0200 Subject: [PATCH 04/58] browser test script jscs --- test/browser/js/script.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/browser/js/script.js b/test/browser/js/script.js index d881731..fc887bb 100644 --- a/test/browser/js/script.js +++ b/test/browser/js/script.js @@ -1,11 +1,11 @@ window.addEventListener('DOMContentLoaded', function() { - "use strict"; - var ql = new QueryLoader2(document.querySelector("body"), { - barColor: "#efefef", - backgroundColor: "#111", - percentage: true, - barHeight: 1, - minimumTime: 200, - fadeOutTime: 1000 - }); -}); + 'use strict'; + var ql = QueryLoader2(document.querySelector('body'), { + barColor: '#efefef', + backgroundColor: '#111', + percentage: true, + barHeight: 1, + minimumTime: 200, + fadeOutTime: 1000, + }); +}); \ No newline at end of file From b8c5b25bd4e8b5989831fbcad265a819bbd44817 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:25:54 +0200 Subject: [PATCH 05/58] needs build before test --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 00d3fc0..f718a07 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ }, "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/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": { From 590cd3efe90706476a6b8226f30ae99dcca4b3f5 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:28:14 +0200 Subject: [PATCH 06/58] rename entry point to be more standard --- gulpfile.js | 2 +- src/{main.js => index.js} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/{main.js => index.js} (100%) diff --git a/gulpfile.js b/gulpfile.js index eea613c..381e6a4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,7 +17,7 @@ var pkg = require('./package.json'); gulp.task('browserify', function() { 'use strict'; - return browserify('./' + config.src + '/main.js') + return browserify('./' + config.src + '/index.js') .bundle() .on('error', function (err) { console.log(err.toString()); diff --git a/src/main.js b/src/index.js similarity index 100% rename from src/main.js rename to src/index.js From 33afbc7a63f99354b4de8c3ee2a0ded6e5dcca99 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:31:26 +0200 Subject: [PATCH 07/58] moved queryloader to own folder --- queryloader2.min.js | 2 +- src/{QueryLoader.js => QueryLoader/index.js} | 4 ++-- src/index.js | 2 +- test/tests.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename src/{QueryLoader.js => QueryLoader/index.js} (97%) diff --git a/queryloader2.min.js b/queryloader2.min.js index 93b211e..abd0809 100644 --- a/queryloader2.min.js +++ b/queryloader2.min.js @@ -12,4 +12,4 @@ * Version: 3.0.16 * Last update: 2015-07-20 */ -!function e(t,i,s){function n(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var u=i[o]={exports:{}};t[o][0].call(u.exports,function(e){var i=t[o][1][e];return n(i?i:e)},u,u.exports,e,t,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o0&&!e.match(/^(data:)/i)?!0:!1},i.prototype.urlIsNew=function(e){"use strict";return-1===this.sources.indexOf(e)},i.prototype.isIE=function(){"use strict";return navigator.userAgent.match(/msie/i)},i.prototype.isOpera=function(){"use strict";return navigator.userAgent.match(/Opera/i)},t.exports=i},{"./Image.js":1}],4:[function(e,t){function i(){"use strict";this.element=null,this.className="queryloader__overlay__bar",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},i.prototype.setStyling=function(){"use strict";this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},i.prototype.updateProgress=function(e,t){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),0!==t&&this.setTransitionTime(t),this.element.style.width=parseInt(e)+"%"},i.prototype.setTransitionTime=function(e){"use strict";this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"},t.exports=i},{}],5:[function(e,t){function i(){"use strict";this.element=null,this.idName="qlPercentage",this.className="queryloader__overlay__percentage",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},i.prototype.applyStyling=function(){"use strict";this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},i.prototype.updateProgress=function(e){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),this.element.innerHTML=parseInt(e)+"%"},t.exports=i},{}],6:[function(e,t){function i(e){"use strict";this.parentElement=e,this.idName="qLoverlay",this.percentageId="qlPercentage",this.className="queryloader__overlay",this.element=null,this.loadingBar=null,this.percentage=null,this.barColor="#ff0000",this.backgroundColor="#000",this.barHeight=1,this.fadeOutTime=300,this.showPercentage=!1}var s=e("./LoadingBar.js"),n=e("./Percentage.js");i.prototype.init=function(){"use strict";this.create(),this.loadingBar=new s,this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=new n,this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},i.prototype.create=function(){"use strict";this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},i.prototype.applyStyling=function(){"use strict";this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},i.prototype.calculatePosition=function(){"use strict";var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},i.prototype.updateProgress=function(e,t){"use strict";null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},i.prototype.remove=function(){"use strict";this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},i.prototype.canRemove=function(e){"use strict";return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild},t.exports=i},{"./LoadingBar.js":4,"./Percentage.js":5}],7:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),i=this,s=function(){},n=function(){return i.apply(this instanceof s&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return s.prototype=this.prototype,n.prototype=new s,n})},{}],8:[function(e,t){function i(e,t){"use strict";this.element=e,this.options=t,this.done=!1,this.maxTimeout=null,this.defaultOptions={onComplete:function(){},onProgress:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3},this.overlay=null,this.preloader=null,null!==e&&this.init()}var s=e("./ImagePreloader/"),n=e("./Overlay/");i.prototype.init=function(){"use strict";this.options=this.extend(this.defaultOptions,this.options),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},i.prototype.extend=function(e,t){"use strict";"undefined"==typeof e&&(e={});for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},i.prototype.startMaxTimeout=function(){"use strict";this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},i.prototype.createOverlay=function(){"use strict";this.overlay=new n(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},i.prototype.removeTempOverlay=function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},i.createTempOverlay=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)},i.prototype.createPreloader=function(){"use strict";this.preloader=new s(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},i.prototype.updateProgress=function(e,t){"use strict";var i=e/t*100;this.overlay.updateProgress(i,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(i,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},i.prototype.doneLoading=function(){"use strict";window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},i.prototype.destroy=function(){"use strict";this.overlay.remove(),this.options.onComplete()},t.exports=i},{"./ImagePreloader/":3,"./Overlay/":6}],9:[function(e,t){e("./Polyfills/");var i=e("./QueryLoader.js");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,i.createTempOverlay()},{"./Polyfills/":7,"./QueryLoader.js":8}]},{},[9]); \ No newline at end of file +!function e(t,i,s){function n(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var u=i[o]={exports:{}};t[o][0].call(u.exports,function(e){var i=t[o][1][e];return n(i?i:e)},u,u.exports,e,t,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o0&&!e.match(/^(data:)/i)?!0:!1},i.prototype.urlIsNew=function(e){"use strict";return-1===this.sources.indexOf(e)},i.prototype.isIE=function(){"use strict";return navigator.userAgent.match(/msie/i)},i.prototype.isOpera=function(){"use strict";return navigator.userAgent.match(/Opera/i)},t.exports=i},{"./Image.js":1}],4:[function(e,t){function i(){"use strict";this.element=null,this.className="queryloader__overlay__bar",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},i.prototype.setStyling=function(){"use strict";this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},i.prototype.updateProgress=function(e,t){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),0!==t&&this.setTransitionTime(t),this.element.style.width=parseInt(e)+"%"},i.prototype.setTransitionTime=function(e){"use strict";this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"},t.exports=i},{}],5:[function(e,t){function i(){"use strict";this.element=null,this.idName="qlPercentage",this.className="queryloader__overlay__percentage",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},i.prototype.applyStyling=function(){"use strict";this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},i.prototype.updateProgress=function(e){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),this.element.innerHTML=parseInt(e)+"%"},t.exports=i},{}],6:[function(e,t){function i(e){"use strict";this.parentElement=e,this.idName="qLoverlay",this.percentageId="qlPercentage",this.className="queryloader__overlay",this.element=null,this.loadingBar=null,this.percentage=null,this.barColor="#ff0000",this.backgroundColor="#000",this.barHeight=1,this.fadeOutTime=300,this.showPercentage=!1}var s=e("./LoadingBar.js"),n=e("./Percentage.js");i.prototype.init=function(){"use strict";this.create(),this.loadingBar=new s,this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=new n,this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},i.prototype.create=function(){"use strict";this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},i.prototype.applyStyling=function(){"use strict";this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},i.prototype.calculatePosition=function(){"use strict";var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},i.prototype.updateProgress=function(e,t){"use strict";null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},i.prototype.remove=function(){"use strict";this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},i.prototype.canRemove=function(e){"use strict";return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild},t.exports=i},{"./LoadingBar.js":4,"./Percentage.js":5}],7:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),i=this,s=function(){},n=function(){return i.apply(this instanceof s&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return s.prototype=this.prototype,n.prototype=new s,n})},{}],8:[function(e,t){function i(e,t){"use strict";this.element=e,this.options=t,this.done=!1,this.maxTimeout=null,this.defaultOptions={onComplete:function(){},onProgress:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3},this.overlay=null,this.preloader=null,null!==e&&this.init()}var s=e("./ImagePreloader/"),n=e("./Overlay/");i.prototype.init=function(){"use strict";this.options=this.extend(this.defaultOptions,this.options),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},i.prototype.extend=function(e,t){"use strict";"undefined"==typeof e&&(e={});for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},i.prototype.startMaxTimeout=function(){"use strict";this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},i.prototype.createOverlay=function(){"use strict";this.overlay=new n(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},i.prototype.removeTempOverlay=function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},i.createTempOverlay=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)},i.prototype.createPreloader=function(){"use strict";this.preloader=new s(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},i.prototype.updateProgress=function(e,t){"use strict";var i=e/t*100;this.overlay.updateProgress(i,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(i,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},i.prototype.doneLoading=function(){"use strict";window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},i.prototype.destroy=function(){"use strict";this.overlay.remove(),this.options.onComplete()},t.exports=i},{"./ImagePreloader/":3,"./Overlay/":6}],9:[function(e,t){e("./Polyfills/");var i=e("./index.js");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,i.createTempOverlay()},{"./Polyfills/":7,"./QueryLoader.js":8}]},{},[9]); \ No newline at end of file diff --git a/src/QueryLoader.js b/src/QueryLoader/index.js similarity index 97% rename from src/QueryLoader.js rename to src/QueryLoader/index.js index 0b1bfd1..020548c 100644 --- a/src/QueryLoader.js +++ b/src/QueryLoader/index.js @@ -1,5 +1,5 @@ -var ImagePreloader = require('./ImagePreloader/'); -var Overlay = require('./Overlay/'); +var ImagePreloader = require('./../ImagePreloader/index'); +var Overlay = require('./../Overlay/index'); function QueryLoader(element, options) { 'use strict'; diff --git a/src/index.js b/src/index.js index 95053f8..1042ae2 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,5 @@ require('./Polyfills/'); -var QueryLoader2 = require('./QueryLoader.js'); +var QueryLoader2 = require('./QueryLoader/'); //jquery and zepto if (window.jQuery || window.Zepto) { diff --git a/test/tests.js b/test/tests.js index 96d4036..d2355d2 100644 --- a/test/tests.js +++ b/test/tests.js @@ -5,7 +5,7 @@ var LoadingBar = require('../src/Overlay/LoadingBar.js'); var Percentage = require('../src/Overlay/Percentage.js'); var Image = require('../src/ImagePreloader/Image.js'); var ImagePreloader = require('../src/ImagePreloader/'); -var QueryLoader = require('../src/QueryLoader.js'); +var QueryLoader = require('../src/QueryLoader/'); describe('LoadingBar', function() { describe('#create()', function() { From f974638b74bc99491e4e3efb15e001a05ef200ed Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:33:03 +0200 Subject: [PATCH 08/58] use factory instantiate for loading bar --- test/tests.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/tests.js b/test/tests.js index d2355d2..c1cc32e 100644 --- a/test/tests.js +++ b/test/tests.js @@ -9,7 +9,7 @@ var QueryLoader = require('../src/QueryLoader/'); describe('LoadingBar', function() { describe('#create()', function() { - var lb = new LoadingBar(); + var lb = LoadingBar(); lb.create(); it('should create an element for itself', function() { @@ -28,7 +28,7 @@ describe('LoadingBar', function() { describe('#updateProgress()', function() { it('should update the progress and adjust the loading bar', function() { - var lb = new LoadingBar(); + var lb = LoadingBar(); lb.create(); assert.equal('0%', lb.element.style.width); @@ -55,7 +55,7 @@ describe('LoadingBar', function() { }); it('should not break on floats', function() { - var lb = new LoadingBar(); + var lb = LoadingBar(); lb.create(); lb.updateProgress(10.6, 0); @@ -173,7 +173,7 @@ describe('Overlay', function() { o.percentage = new Percentage(); o.percentage.create(); - o.loadingBar = new LoadingBar(); + o.loadingBar = LoadingBar(); o.loadingBar.create(); it('should update the loading progress of both percentage and loadingbar', function() { From f363ecf1e9426e4d54331bfd99a2f2424e4d6eef Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:34:03 +0200 Subject: [PATCH 09/58] reorder test includes --- test/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tests.js b/test/tests.js index c1cc32e..c24b243 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,11 +1,11 @@ var assert = require('assert'); -var Overlay = require('../src/Overlay/'); var LoadingBar = require('../src/Overlay/LoadingBar.js'); var Percentage = require('../src/Overlay/Percentage.js'); +var Overlay = require('../src/Overlay/'); var Image = require('../src/ImagePreloader/Image.js'); -var ImagePreloader = require('../src/ImagePreloader/'); var QueryLoader = require('../src/QueryLoader/'); +var ImagePreloader = require('../src/ImagePreloader/'); describe('LoadingBar', function() { describe('#create()', function() { From 9c0a7ed0244f896e5ef20ecfa751ff701f16ed94 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:36:39 +0200 Subject: [PATCH 10/58] factory for LoadingBar instead of constructor --- src/Overlay/LoadingBar.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Overlay/LoadingBar.js b/src/Overlay/LoadingBar.js index 1dcd898..c50fe5f 100644 --- a/src/Overlay/LoadingBar.js +++ b/src/Overlay/LoadingBar.js @@ -1,10 +1,7 @@ -function LoadingBar() { - 'use strict'; - this.element = null; - this.className = "queryloader__overlay__bar"; - this.barHeight = 1; - this.barColor = "#fff"; -} +'use strict'; +var LoadingBar = { + +}; /** * Creates the element for the loadingbar @@ -54,4 +51,13 @@ LoadingBar.prototype.setTransitionTime = function (ms) { this.element.style.Transition = "width " + ms + "ms"; }; -module.exports = LoadingBar; \ No newline at end of file +module.exports = function() { + var loadingBar = Object.create(LoadingBar); + + loadingBar.element = null; + loadingBar.className = 'queryloader__overlay__bar'; + loadingBar.barHeight = 1; + loadingBar.barColor = '#fff'; + + return loadingBar; +}; \ No newline at end of file From 3cf23a4d869c4a86b8e66c97fbd6a0249e4d4ba1 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:37:36 +0200 Subject: [PATCH 11/58] fix indents and quotes --- src/Overlay/LoadingBar.js | 60 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/src/Overlay/LoadingBar.js b/src/Overlay/LoadingBar.js index c50fe5f..41cd8ba 100644 --- a/src/Overlay/LoadingBar.js +++ b/src/Overlay/LoadingBar.js @@ -1,54 +1,52 @@ 'use strict'; -var LoadingBar = { - -}; +var LoadingBar = {}; /** * Creates the element for the loadingbar */ LoadingBar.prototype.create = function () { - 'use strict'; - this.element = document.createElement("div"); - this.element.setAttribute("class", this.className); - this.setStyling(); - this.updateProgress(0, 0); + 'use strict'; + this.element = document.createElement('div'); + this.element.setAttribute('class', this.className); + this.setStyling(); + this.updateProgress(0, 0); }; LoadingBar.prototype.setStyling = function () { - 'use strict'; + 'use strict'; - this.element.style.height = this.barHeight + "px"; - this.element.style.marginTop = "-" + (this.barHeight / 2) + "px"; - this.element.style.backgroundColor = this.barColor; - this.element.style.position = "absolute"; - this.element.style.top = "50%"; + this.element.style.height = this.barHeight + 'px'; + this.element.style.marginTop = '-' + (this.barHeight / 2) + 'px'; + this.element.style.backgroundColor = this.barColor; + this.element.style.position = 'absolute'; + this.element.style.top = '50%'; - this.setTransitionTime(100); + this.setTransitionTime(100); }; LoadingBar.prototype.updateProgress = function (percentage, time) { - 'use strict'; + 'use strict'; - if (parseInt(percentage) < 0) { - percentage = 0; - } else if (parseInt(percentage) > 100) { - percentage = 100; - } + if (parseInt(percentage) < 0) { + percentage = 0; + } else if (parseInt(percentage) > 100) { + percentage = 100; + } - if (time !== 0) { - this.setTransitionTime(time); - } + if (time !== 0) { + this.setTransitionTime(time); + } - this.element.style.width = parseInt(percentage) + "%"; + this.element.style.width = parseInt(percentage) + '%'; }; LoadingBar.prototype.setTransitionTime = function (ms) { - "use strict"; - this.element.style.WebkitTransition = "width " + ms + "ms"; - this.element.style.MozTransition = "width " + ms + "ms"; - this.element.style.OTransition = "width " + ms + "ms"; - this.element.style.MsTransition = "width " + ms + "ms"; - this.element.style.Transition = "width " + ms + "ms"; + 'use strict'; + this.element.style.WebkitTransition = 'width ' + ms + 'ms'; + this.element.style.MozTransition = 'width ' + ms + 'ms'; + this.element.style.OTransition = 'width ' + ms + 'ms'; + this.element.style.MsTransition = 'width ' + ms + 'ms'; + this.element.style.Transition = 'width ' + ms + 'ms'; }; module.exports = function() { From 4335fd7f6b9faa4bd6233588fef0a620f0a811f8 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:40:42 +0200 Subject: [PATCH 12/58] move functions to loadingbar object --- src/Overlay/LoadingBar.js | 90 ++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 48 deletions(-) diff --git a/src/Overlay/LoadingBar.js b/src/Overlay/LoadingBar.js index 41cd8ba..23e74a8 100644 --- a/src/Overlay/LoadingBar.js +++ b/src/Overlay/LoadingBar.js @@ -1,52 +1,46 @@ 'use strict'; -var LoadingBar = {}; - -/** - * Creates the element for the loadingbar - */ -LoadingBar.prototype.create = function () { - 'use strict'; - this.element = document.createElement('div'); - this.element.setAttribute('class', this.className); - this.setStyling(); - this.updateProgress(0, 0); -}; - -LoadingBar.prototype.setStyling = function () { - 'use strict'; - - this.element.style.height = this.barHeight + 'px'; - this.element.style.marginTop = '-' + (this.barHeight / 2) + 'px'; - this.element.style.backgroundColor = this.barColor; - this.element.style.position = 'absolute'; - this.element.style.top = '50%'; - - this.setTransitionTime(100); -}; - -LoadingBar.prototype.updateProgress = function (percentage, time) { - 'use strict'; - - if (parseInt(percentage) < 0) { - percentage = 0; - } else if (parseInt(percentage) > 100) { - percentage = 100; - } - - if (time !== 0) { - this.setTransitionTime(time); - } - - this.element.style.width = parseInt(percentage) + '%'; -}; - -LoadingBar.prototype.setTransitionTime = function (ms) { - 'use strict'; - this.element.style.WebkitTransition = 'width ' + ms + 'ms'; - this.element.style.MozTransition = 'width ' + ms + 'ms'; - this.element.style.OTransition = 'width ' + ms + 'ms'; - this.element.style.MsTransition = 'width ' + ms + 'ms'; - this.element.style.Transition = 'width ' + ms + 'ms'; +var LoadingBar = { + /** + * Creates the element for the loading bar + */ + create: function() { + this.element = document.createElement('div'); + this.element.setAttribute('class', this.className); + this.setStyling(); + this.updateProgress(0, 0); + }, + + setStyling: function() { + this.element.style.height = this.barHeight + 'px'; + this.element.style.marginTop = '-' + (this.barHeight / 2) + 'px'; + this.element.style.backgroundColor = this.barColor; + this.element.style.position = 'absolute'; + this.element.style.top = '50%'; + + this.setTransitionTime(100); + }, + + updateProgress: function(percentage, time) { + if (parseInt(percentage) < 0) { + percentage = 0; + } else if (parseInt(percentage) > 100) { + percentage = 100; + } + + if (time !== 0) { + this.setTransitionTime(time); + } + + this.element.style.width = parseInt(percentage) + '%'; + }, + + setTransitionTime: function(ms) { + this.element.style.WebkitTransition = 'width ' + ms + 'ms'; + this.element.style.MozTransition = 'width ' + ms + 'ms'; + this.element.style.OTransition = 'width ' + ms + 'ms'; + this.element.style.MsTransition = 'width ' + ms + 'ms'; + this.element.style.Transition = 'width ' + ms + 'ms'; + }, }; module.exports = function() { From d4da1a6ebb07fcb6a9805df268a4b545c2326dc6 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:44:05 +0200 Subject: [PATCH 13/58] redone loading bar --- src/Overlay/LoadingBar.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Overlay/LoadingBar.js b/src/Overlay/LoadingBar.js index 23e74a8..87894ea 100644 --- a/src/Overlay/LoadingBar.js +++ b/src/Overlay/LoadingBar.js @@ -20,18 +20,26 @@ var LoadingBar = { this.setTransitionTime(100); }, - updateProgress: function(percentage, time) { + parsePercentage: function(percentage) { if (parseInt(percentage) < 0) { - percentage = 0; - } else if (parseInt(percentage) > 100) { - percentage = 100; + return 0; + } + + if (parseInt(percentage) > 100) { + return 100; } + return parseInt(percentage); + }, + + updateProgress: function(percentage, time) { if (time !== 0) { this.setTransitionTime(time); } - this.element.style.width = parseInt(percentage) + '%'; + percentage = this.parsePercentage(percentage); + + this.element.style.width = percentage + '%'; }, setTransitionTime: function(ms) { From ebd6b3cda7c6f68f565f9e7a8f8864effa6081d7 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:45:21 +0200 Subject: [PATCH 14/58] rewrote percentage creations --- test/tests.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests.js b/test/tests.js index c24b243..2eef1d9 100644 --- a/test/tests.js +++ b/test/tests.js @@ -71,7 +71,7 @@ describe('LoadingBar', function() { describe('Percentage', function() { describe('#create()', function() { - var p = new Percentage(); + var p = Percentage(); p.create(); it('should create an element for itself', function() { @@ -88,7 +88,7 @@ describe('Percentage', function() { }); describe('#updateProgress()', function() { - var p = new Percentage(); + var p = Percentage(); p.create(); it('should update the progress and adjust the loading bar', function() { @@ -170,7 +170,7 @@ describe('Overlay', function() { o.parentElement = fakeBody; o.create(); - o.percentage = new Percentage(); + o.percentage = Percentage(); o.percentage.create(); o.loadingBar = LoadingBar(); From 1a88607341a39b37289fc5c509e5ca585d6383af Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:45:58 +0200 Subject: [PATCH 15/58] fix indents and quotes in percentage --- src/Overlay/Percentage.js | 58 +++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/Overlay/Percentage.js b/src/Overlay/Percentage.js index 0b9d49e..aeaf46f 100644 --- a/src/Overlay/Percentage.js +++ b/src/Overlay/Percentage.js @@ -1,44 +1,44 @@ function Percentage() { - 'use strict'; - this.element = null; - this.idName = "qlPercentage"; - this.className = "queryloader__overlay__percentage"; - this.barHeight = 1; - this.barColor = "#fff"; + 'use strict'; + this.element = null; + this.idName = 'qlPercentage'; + this.className = 'queryloader__overlay__percentage'; + this.barHeight = 1; + this.barColor = '#fff'; } Percentage.prototype.create = function () { - 'use strict'; - this.element = document.createElement("div"); - this.element.setAttribute("class", this.className); - this.element.setAttribute("id", this.idName); - this.applyStyling(); - this.updateProgress(0, 0); + 'use strict'; + this.element = document.createElement('div'); + this.element.setAttribute('class', this.className); + this.element.setAttribute('id', this.idName); + this.applyStyling(); + this.updateProgress(0, 0); }; Percentage.prototype.applyStyling = function () { - 'use strict'; - this.element.style.height = "40px"; - this.element.style.width = "100%"; - this.element.style.position = "absolute"; - this.element.style.fontSize = "3em"; - this.element.style.top = "50%"; - this.element.style.left = "0"; - this.element.style.marginTop = "-" + (59 + this.barHeight) + "px"; - this.element.style.textAlign = "center"; - this.element.style.color = this.barColor; + 'use strict'; + this.element.style.height = '40px'; + this.element.style.width = '100%'; + this.element.style.position = 'absolute'; + this.element.style.fontSize = '3em'; + this.element.style.top = '50%'; + this.element.style.left = '0'; + this.element.style.marginTop = '-' + (59 + this.barHeight) + 'px'; + this.element.style.textAlign = 'center'; + this.element.style.color = this.barColor; }; Percentage.prototype.updateProgress = function (percentage, time) { - 'use strict'; + 'use strict'; - if (parseInt(percentage) < 0) { - percentage = 0; - } else if (parseInt(percentage) > 100) { - percentage = 100; - } + if (parseInt(percentage) < 0) { + percentage = 0; + } else if (parseInt(percentage) > 100) { + percentage = 100; + } - this.element.innerHTML = parseInt(percentage) + "%"; + this.element.innerHTML = parseInt(percentage) + '%'; }; module.exports = Percentage; \ No newline at end of file From 705f8f40dd419d0e7a53e52ae1fcff52cf150731 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:47:19 +0200 Subject: [PATCH 16/58] percentage to factory creation --- src/Overlay/Percentage.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Overlay/Percentage.js b/src/Overlay/Percentage.js index aeaf46f..3b53c5e 100644 --- a/src/Overlay/Percentage.js +++ b/src/Overlay/Percentage.js @@ -1,11 +1,5 @@ -function Percentage() { - 'use strict'; - this.element = null; - this.idName = 'qlPercentage'; - this.className = 'queryloader__overlay__percentage'; - this.barHeight = 1; - this.barColor = '#fff'; -} +'use strict'; +var Percentage = {}; Percentage.prototype.create = function () { 'use strict'; @@ -41,4 +35,14 @@ Percentage.prototype.updateProgress = function (percentage, time) { this.element.innerHTML = parseInt(percentage) + '%'; }; -module.exports = Percentage; \ No newline at end of file +module.exports = function() { + var percentage = Object.create(Percentage); + + percentage.element = null; + percentage.idName = 'qlPercentage'; + percentage.className = 'queryloader__overlay__percentage'; + percentage.barHeight = 1; + percentage.barColor = '#fff'; + + return percentage; +}; \ No newline at end of file From 7605bd85f39d8af5a09ba18110912fc0ec40cc6d Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:52:48 +0200 Subject: [PATCH 17/58] use percentage parse module --- src/Overlay/Percentage.js | 62 ++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 34 deletions(-) diff --git a/src/Overlay/Percentage.js b/src/Overlay/Percentage.js index 3b53c5e..e6f3b4b 100644 --- a/src/Overlay/Percentage.js +++ b/src/Overlay/Percentage.js @@ -1,38 +1,32 @@ 'use strict'; -var Percentage = {}; - -Percentage.prototype.create = function () { - 'use strict'; - this.element = document.createElement('div'); - this.element.setAttribute('class', this.className); - this.element.setAttribute('id', this.idName); - this.applyStyling(); - this.updateProgress(0, 0); -}; - -Percentage.prototype.applyStyling = function () { - 'use strict'; - this.element.style.height = '40px'; - this.element.style.width = '100%'; - this.element.style.position = 'absolute'; - this.element.style.fontSize = '3em'; - this.element.style.top = '50%'; - this.element.style.left = '0'; - this.element.style.marginTop = '-' + (59 + this.barHeight) + 'px'; - this.element.style.textAlign = 'center'; - this.element.style.color = this.barColor; -}; - -Percentage.prototype.updateProgress = function (percentage, time) { - 'use strict'; - - if (parseInt(percentage) < 0) { - percentage = 0; - } else if (parseInt(percentage) > 100) { - percentage = 100; - } - - this.element.innerHTML = parseInt(percentage) + '%'; +var PercentageParser = require('./PercentageParser'); + +var Percentage = { + create: function() { + this.element = document.createElement('div'); + this.element.setAttribute('class', this.className); + this.element.setAttribute('id', this.idName); + this.applyStyling(); + this.updateProgress(0, 0); + }, + + applyStyling: function() { + this.element.style.height = '40px'; + this.element.style.width = '100%'; + this.element.style.position = 'absolute'; + this.element.style.fontSize = '3em'; + this.element.style.top = '50%'; + this.element.style.left = '0'; + this.element.style.marginTop = '-' + (59 + this.barHeight) + 'px'; + this.element.style.textAlign = 'center'; + this.element.style.color = this.barColor; + }, + + updateProgress: function(percentage, time) { + percentage = PercentageParser(percentage); + + this.element.innerHTML = percentage + '%'; + }, }; module.exports = function() { From 231bcb97b97563ad82e5916650404cde5434bd61 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Wed, 14 Oct 2015 16:53:01 +0200 Subject: [PATCH 18/58] use percentage parser in loading bar --- src/Overlay/LoadingBar.js | 16 +++------------- src/Overlay/PercentageParser.js | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-) create mode 100644 src/Overlay/PercentageParser.js diff --git a/src/Overlay/LoadingBar.js b/src/Overlay/LoadingBar.js index 87894ea..8f7f53a 100644 --- a/src/Overlay/LoadingBar.js +++ b/src/Overlay/LoadingBar.js @@ -1,4 +1,6 @@ 'use strict'; +var PercentageParser = require('./PercentageParser'); + var LoadingBar = { /** * Creates the element for the loading bar @@ -20,24 +22,12 @@ var LoadingBar = { this.setTransitionTime(100); }, - parsePercentage: function(percentage) { - if (parseInt(percentage) < 0) { - return 0; - } - - if (parseInt(percentage) > 100) { - return 100; - } - - return parseInt(percentage); - }, - updateProgress: function(percentage, time) { if (time !== 0) { this.setTransitionTime(time); } - percentage = this.parsePercentage(percentage); + percentage = PercentageParser(percentage); this.element.style.width = percentage + '%'; }, diff --git a/src/Overlay/PercentageParser.js b/src/Overlay/PercentageParser.js new file mode 100644 index 0000000..93dded0 --- /dev/null +++ b/src/Overlay/PercentageParser.js @@ -0,0 +1,14 @@ +'use strict'; +function parsePercentage(percentage) { + if (parseInt(percentage) < 0) { + return 0; + } + + if (parseInt(percentage) > 100) { + return 100; + } + + return parseInt(percentage); +} + +module.exports = parsePercentage; \ No newline at end of file From 73f1c1d629a22021c3b59c7384c430da27ddb443 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 08:58:02 +0200 Subject: [PATCH 19/58] add percentage parser tests --- test/tests.js | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/tests.js b/test/tests.js index 2eef1d9..0d2ceb2 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,5 +1,6 @@ var assert = require('assert'); +var PercentageParser = require('../src/Overlay/PercentageParser'); var LoadingBar = require('../src/Overlay/LoadingBar.js'); var Percentage = require('../src/Overlay/Percentage.js'); var Overlay = require('../src/Overlay/'); @@ -7,6 +8,30 @@ var Image = require('../src/ImagePreloader/Image.js'); var QueryLoader = require('../src/QueryLoader/'); var ImagePreloader = require('../src/ImagePreloader/'); +describe('PercentageParser', function() { + it('should round given percentages below zero to zero', function() { + assert.equal(PercentageParser(-100), 0); + assert.equal(PercentageParser(-10), 0); + assert.equal(PercentageParser(-1), 0); + assert.equal(PercentageParser(0), 0); + }); + + it('should round given percentages above 100 to 100', function() { + assert.equal(PercentageParser(1000), 100); + assert.equal(PercentageParser(100), 100); + assert.equal(PercentageParser(101), 100); + }); + + it('should round decimals to round numbers', function() { + assert.equal(PercentageParser(1.5), 1); + assert.equal(PercentageParser(1.6), 1); + assert.equal(PercentageParser(2.1), 2); + assert.equal(PercentageParser(2), 2); + assert.equal(PercentageParser('2'), 2); + assert.equal(PercentageParser('2.2'), 2); + }); +}); + describe('LoadingBar', function() { describe('#create()', function() { var lb = LoadingBar(); From 874233781fc98a691d7596e5ff34191419102397 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 08:59:11 +0200 Subject: [PATCH 20/58] cleaner includes --- test/tests.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/tests.js b/test/tests.js index 0d2ceb2..8e78731 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,12 +1,12 @@ var assert = require('assert'); var PercentageParser = require('../src/Overlay/PercentageParser'); -var LoadingBar = require('../src/Overlay/LoadingBar.js'); -var Percentage = require('../src/Overlay/Percentage.js'); -var Overlay = require('../src/Overlay/'); -var Image = require('../src/ImagePreloader/Image.js'); -var QueryLoader = require('../src/QueryLoader/'); -var ImagePreloader = require('../src/ImagePreloader/'); +var LoadingBar = require('../src/Overlay/LoadingBar'); +var Percentage = require('../src/Overlay/Percentage'); +var Overlay = require('../src/Overlay'); +var Image = require('../src/ImagePreloader/Image'); +var QueryLoader = require('../src/QueryLoader'); +var ImagePreloader = require('../src/ImagePreloader'); describe('PercentageParser', function() { it('should round given percentages below zero to zero', function() { From 6ededd4c76de364591da5504f0d0d46edf93d3c2 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 09:00:44 +0200 Subject: [PATCH 21/58] format tests --- test/tests.js | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/test/tests.js b/test/tests.js index 8e78731..86df35a 100644 --- a/test/tests.js +++ b/test/tests.js @@ -59,23 +59,18 @@ describe('LoadingBar', function() { assert.equal('0%', lb.element.style.width); lb.updateProgress(10, 0); - assert.equal('10%', lb.element.style.width); lb.updateProgress(50, 0); - assert.equal('50%', lb.element.style.width); lb.updateProgress(100, 0); - assert.equal('100%', lb.element.style.width); lb.updateProgress(-20, 0); - assert.equal('0%', lb.element.style.width); lb.updateProgress(420, 0); - assert.equal('100%', lb.element.style.width); }); @@ -84,11 +79,9 @@ describe('LoadingBar', function() { lb.create(); lb.updateProgress(10.6, 0); - assert.equal('10%', lb.element.style.width); lb.updateProgress(50.456, 0); - assert.equal('50%', lb.element.style.width); }); }); @@ -120,33 +113,26 @@ describe('Percentage', function() { assert.equal('0%', p.element.innerHTML); p.updateProgress(10, 0); - assert.equal('10%', p.element.innerHTML); p.updateProgress(50, 0); - assert.equal('50%', p.element.innerHTML); p.updateProgress(100, 0); - assert.equal('100%', p.element.innerHTML); p.updateProgress(-20, 0); - assert.equal('0%', p.element.innerHTML); p.updateProgress(420, 0); - assert.equal('100%', p.element.innerHTML); }); it('should not break on floats', function() { p.updateProgress(10.6, 0); - assert.equal('10%', p.element.innerHTML); p.updateProgress(50.456, 0); - assert.equal('50%', p.element.innerHTML); }); }); From 2fe9b4f6aa5a179ab7f156e3a3d4eeb79f5a91c0 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:41:11 +0200 Subject: [PATCH 22/58] change overlay call to being a factory --- test/tests.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests.js b/test/tests.js index 86df35a..a4735f4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -142,7 +142,7 @@ describe('Overlay', function() { var fakeBody = document.createElement('body'); describe('#create()', function() { - var o = new Overlay(fakeBody); + var o = Overlay(fakeBody); o.create(); it('should create an element for itself', function() { @@ -155,7 +155,7 @@ describe('Overlay', function() { }); describe('#calculatePosition()', function() { - var o = new Overlay(); + var o = Overlay(); it('should give the correct needed position of the overlay', function() { o.parentElement = fakeBody; @@ -177,7 +177,7 @@ describe('Overlay', function() { }); describe('#updateProgess()', function() { - var o = new Overlay(); + var o = Overlay(); o.parentElement = fakeBody; o.create(); From 73d11dabea27df7ab88f409975a74489184facf0 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:41:46 +0200 Subject: [PATCH 23/58] change require path of loading bar and percentage --- src/Overlay/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Overlay/index.js b/src/Overlay/index.js index e071b4d..a0845fc 100644 --- a/src/Overlay/index.js +++ b/src/Overlay/index.js @@ -1,5 +1,5 @@ -var LoadingBar = require('./LoadingBar.js'); -var Percentage = require('./Percentage.js'); +var LoadingBar = require('./LoadingBar'); +var Percentage = require('./Percentage'); function Overlay(parentElement) { 'use strict'; From f20f6766245cce854bd04bfeebede156c61fe76b Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:42:46 +0200 Subject: [PATCH 24/58] create factory module --- src/Overlay/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Overlay/index.js b/src/Overlay/index.js index a0845fc..30d052e 100644 --- a/src/Overlay/index.js +++ b/src/Overlay/index.js @@ -1,8 +1,8 @@ +'use strict'; var LoadingBar = require('./LoadingBar'); var Percentage = require('./Percentage'); function Overlay(parentElement) { - 'use strict'; this.parentElement = parentElement; this.idName = "qLoverlay"; this.percentageId = "qlPercentage"; @@ -103,4 +103,6 @@ Overlay.prototype.canRemove = function(element) { return (element.parentNode && typeof element.parentNode.removeChild !== 'undefined'); }; -module.exports = Overlay; \ No newline at end of file +module.exports = function(parentElement) { + +}; \ No newline at end of file From 1156a42bd3d19dac4540cd24e5fb28832cdf39a3 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:43:09 +0200 Subject: [PATCH 25/58] reformatted --- src/Overlay/index.js | 148 +++++++++++++++++++++---------------------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/src/Overlay/index.js b/src/Overlay/index.js index 30d052e..9f75ea8 100644 --- a/src/Overlay/index.js +++ b/src/Overlay/index.js @@ -3,103 +3,103 @@ var LoadingBar = require('./LoadingBar'); var Percentage = require('./Percentage'); function Overlay(parentElement) { - this.parentElement = parentElement; - this.idName = "qLoverlay"; - this.percentageId = "qlPercentage"; - this.className = "queryloader__overlay"; - this.element = null; - this.loadingBar = null; - this.percentage = null; - this.barColor = "#ff0000"; - this.backgroundColor = "#000"; - this.barHeight = 1; - this.fadeOutTime = 300; - this.showPercentage = false; + this.parentElement = parentElement; + this.idName = 'qLoverlay'; + this.percentageId = 'qlPercentage'; + this.className = 'queryloader__overlay'; + this.element = null; + this.loadingBar = null; + this.percentage = null; + this.barColor = '#ff0000'; + this.backgroundColor = '#000'; + this.barHeight = 1; + this.fadeOutTime = 300; + this.showPercentage = false; } Overlay.prototype.init = function () { - "use strict"; - this.create(); - - this.loadingBar = new LoadingBar(); - this.loadingBar.barHeight = this.barHeight; - this.loadingBar.barColor = this.barColor; - this.loadingBar.create(); - this.element.appendChild(this.loadingBar.element); - - if (this.showPercentage) { - this.percentage = new Percentage(); - this.percentage.barColor = this.barColor; - this.percentage.idName = this.percentageId; - this.percentage.create(); - this.element.appendChild(this.percentage.element); - } - - this.parentElement.appendChild(this.element); + 'use strict'; + this.create(); + + this.loadingBar = new LoadingBar(); + this.loadingBar.barHeight = this.barHeight; + this.loadingBar.barColor = this.barColor; + this.loadingBar.create(); + this.element.appendChild(this.loadingBar.element); + + if (this.showPercentage) { + this.percentage = new Percentage(); + this.percentage.barColor = this.barColor; + this.percentage.idName = this.percentageId; + this.percentage.create(); + this.element.appendChild(this.percentage.element); + } + + this.parentElement.appendChild(this.element); }; Overlay.prototype.create = function () { - 'use strict'; - this.element = (document.querySelector("#" + this.idName) || document.createElement("div")); - this.element.setAttribute("class", this.className); - this.element.setAttribute("id", this.idName); - this.applyStyling(); + 'use strict'; + this.element = (document.querySelector('#' + this.idName) || document.createElement('div')); + this.element.setAttribute('class', this.className); + this.element.setAttribute('id', this.idName); + this.applyStyling(); }; Overlay.prototype.applyStyling = function () { - 'use strict'; - //determine postion of overlay and set parent position - this.element.style.position = this.calculatePosition(); - this.element.style.width = "100%"; - this.element.style.height = "100%"; - this.element.style.backgroundColor = this.backgroundColor; - this.element.style.backgroundPosition = "fixed"; - this.element.style.zIndex = 666999; //very HIGH - this.element.style.top = "0"; - this.element.style.left = "0"; - - this.element.style.WebkitTransition = "opacity " + this.fadeOutTime + "ms"; - this.element.style.MozTransition = "opacity " + this.fadeOutTime + "ms"; - this.element.style.OTransition = "opacity " + this.fadeOutTime + "ms"; - this.element.style.MsTransition = "opacity " + this.fadeOutTime + "ms"; - this.element.style.Transition = "opacity " + this.fadeOutTime + "ms"; + 'use strict'; + //determine postion of overlay and set parent position + this.element.style.position = this.calculatePosition(); + this.element.style.width = '100%'; + this.element.style.height = '100%'; + this.element.style.backgroundColor = this.backgroundColor; + this.element.style.backgroundPosition = 'fixed'; + this.element.style.zIndex = 666999; //very HIGH + this.element.style.top = '0'; + this.element.style.left = '0'; + + this.element.style.WebkitTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.MozTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.OTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.MsTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.Transition = 'opacity ' + this.fadeOutTime + 'ms'; }; Overlay.prototype.calculatePosition = function () { - 'use strict'; - var overlayPosition = "absolute"; - - if (this.parentElement.tagName.toLowerCase() === "body") { - overlayPosition = "fixed"; - } else { - if (this.parentElement.style.position !== "fixed" || this.parentElement.style.position !== "absolute" ) { - this.parentElement.style.position = "relative"; - } + 'use strict'; + var overlayPosition = 'absolute'; + + if (this.parentElement.tagName.toLowerCase() === 'body') { + overlayPosition = 'fixed'; + } else { + if (this.parentElement.style.position !== 'fixed' || this.parentElement.style.position !== 'absolute' ) { + this.parentElement.style.position = 'relative'; } + } - return overlayPosition; + return overlayPosition; }; Overlay.prototype.updateProgress = function (percentage, time) { - "use strict"; - if (this.loadingBar !== null) { - this.loadingBar.updateProgress(percentage, time); - } - - if (this.percentage !== null) { - this.percentage.updateProgress(percentage, time); - } + 'use strict'; + if (this.loadingBar !== null) { + this.loadingBar.updateProgress(percentage, time); + } + + if (this.percentage !== null) { + this.percentage.updateProgress(percentage, time); + } }; Overlay.prototype.remove = function () { - "use strict"; - if (this.canRemove(this.element)) { - this.element.parentNode.removeChild(this.element); - } + 'use strict'; + if (this.canRemove(this.element)) { + this.element.parentNode.removeChild(this.element); + } }; Overlay.prototype.canRemove = function(element) { - "use strict"; + 'use strict'; return (element.parentNode && typeof element.parentNode.removeChild !== 'undefined'); }; From 379683cb4d68ae868fe44f7b08bf99fd38868c17 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:56:40 +0200 Subject: [PATCH 26/58] rewritten overlay --- src/Overlay/index.js | 181 +++++++++++++++++++++---------------------- 1 file changed, 88 insertions(+), 93 deletions(-) diff --git a/src/Overlay/index.js b/src/Overlay/index.js index 9f75ea8..0b9add5 100644 --- a/src/Overlay/index.js +++ b/src/Overlay/index.js @@ -2,107 +2,102 @@ var LoadingBar = require('./LoadingBar'); var Percentage = require('./Percentage'); -function Overlay(parentElement) { - this.parentElement = parentElement; - this.idName = 'qLoverlay'; - this.percentageId = 'qlPercentage'; - this.className = 'queryloader__overlay'; - this.element = null; - this.loadingBar = null; - this.percentage = null; - this.barColor = '#ff0000'; - this.backgroundColor = '#000'; - this.barHeight = 1; - this.fadeOutTime = 300; - this.showPercentage = false; -} - -Overlay.prototype.init = function () { - 'use strict'; - this.create(); - - this.loadingBar = new LoadingBar(); - this.loadingBar.barHeight = this.barHeight; - this.loadingBar.barColor = this.barColor; - this.loadingBar.create(); - this.element.appendChild(this.loadingBar.element); - - if (this.showPercentage) { - this.percentage = new Percentage(); - this.percentage.barColor = this.barColor; - this.percentage.idName = this.percentageId; - this.percentage.create(); - this.element.appendChild(this.percentage.element); - } - - this.parentElement.appendChild(this.element); -}; - -Overlay.prototype.create = function () { - 'use strict'; - this.element = (document.querySelector('#' + this.idName) || document.createElement('div')); - this.element.setAttribute('class', this.className); - this.element.setAttribute('id', this.idName); - this.applyStyling(); -}; - -Overlay.prototype.applyStyling = function () { - 'use strict'; - //determine postion of overlay and set parent position - this.element.style.position = this.calculatePosition(); - this.element.style.width = '100%'; - this.element.style.height = '100%'; - this.element.style.backgroundColor = this.backgroundColor; - this.element.style.backgroundPosition = 'fixed'; - this.element.style.zIndex = 666999; //very HIGH - this.element.style.top = '0'; - this.element.style.left = '0'; - - this.element.style.WebkitTransition = 'opacity ' + this.fadeOutTime + 'ms'; - this.element.style.MozTransition = 'opacity ' + this.fadeOutTime + 'ms'; - this.element.style.OTransition = 'opacity ' + this.fadeOutTime + 'ms'; - this.element.style.MsTransition = 'opacity ' + this.fadeOutTime + 'ms'; - this.element.style.Transition = 'opacity ' + this.fadeOutTime + 'ms'; -}; - -Overlay.prototype.calculatePosition = function () { - 'use strict'; - var overlayPosition = 'absolute'; +var Overlay = { + init: function() { + this.create(); + + this.loadingBar = LoadingBar(); + this.loadingBar.barHeight = this.barHeight; + this.loadingBar.barColor = this.barColor; + this.loadingBar.create(); + this.element.appendChild(this.loadingBar.element); + + if (this.showPercentage) { + this.percentage = Percentage(); + this.percentage.barColor = this.barColor; + this.percentage.idName = this.percentageId; + this.percentage.create(); + this.element.appendChild(this.percentage.element); + } - if (this.parentElement.tagName.toLowerCase() === 'body') { - overlayPosition = 'fixed'; - } else { - if (this.parentElement.style.position !== 'fixed' || this.parentElement.style.position !== 'absolute' ) { - this.parentElement.style.position = 'relative'; + this.parentElement.appendChild(this.element); + }, + + create: function() { + this.element = (document.querySelector('#' + this.idName) || document.createElement('div')); + this.element.setAttribute('class', this.className); + this.element.setAttribute('id', this.idName); + this.applyStyling(); + }, + + applyStyling: function() { + //determine postion of overlay and set parent position + this.element.style.position = this.calculatePosition(); + this.element.style.width = '100%'; + this.element.style.height = '100%'; + this.element.style.backgroundColor = this.backgroundColor; + this.element.style.backgroundPosition = 'fixed'; + this.element.style.zIndex = 666999; //very HIGH + this.element.style.top = '0'; + this.element.style.left = '0'; + + this.element.style.WebkitTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.MozTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.OTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.MsTransition = 'opacity ' + this.fadeOutTime + 'ms'; + this.element.style.Transition = 'opacity ' + this.fadeOutTime + 'ms'; + }, + + calculatePosition: function() { + var overlayPosition = 'absolute'; + + if (this.parentElement.tagName.toLowerCase() === 'body') { + overlayPosition = 'fixed'; + } else { + if (this.parentElement.style.position !== 'fixed' || this.parentElement.style.position !== 'absolute') { + this.parentElement.style.position = 'relative'; + } } - } - return overlayPosition; -}; + return overlayPosition; + }, -Overlay.prototype.updateProgress = function (percentage, time) { - 'use strict'; - if (this.loadingBar !== null) { - this.loadingBar.updateProgress(percentage, time); - } + updateProgress: function(percentage, time) { + if (this.loadingBar !== null) { + this.loadingBar.updateProgress(percentage, time); + } - if (this.percentage !== null) { - this.percentage.updateProgress(percentage, time); - } -}; + if (this.percentage !== null) { + this.percentage.updateProgress(percentage, time); + } + }, -Overlay.prototype.remove = function () { - 'use strict'; - if (this.canRemove(this.element)) { - this.element.parentNode.removeChild(this.element); - } -}; + remove: function() { + if (this.canRemove(this.element)) { + this.element.parentNode.removeChild(this.element); + } + }, -Overlay.prototype.canRemove = function(element) { - 'use strict'; - return (element.parentNode && typeof element.parentNode.removeChild !== 'undefined'); + canRemove: function(element) { + return (element.parentNode && typeof element.parentNode.removeChild !== 'undefined'); + }, }; module.exports = function(parentElement) { - + var overlay = Object.create(Overlay); + + overlay.parentElement = parentElement; + overlay.idName = 'qLoverlay'; + overlay.percentageId = 'qlPercentage'; + overlay.className = 'queryloader__overlay'; + overlay.element = null; + overlay.loadingBar = null; + overlay.percentage = null; + overlay.barColor = '#ff0000'; + overlay.backgroundColor = '#000'; + overlay.barHeight = 1; + overlay.fadeOutTime = 300; + overlay.showPercentage = false; + + return overlay; }; \ No newline at end of file From cf3cd9217b038629a08c6572e19918bc7cad2e5a Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 11:59:41 +0200 Subject: [PATCH 27/58] reformat bind polyfil --- src/Polyfills/index.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/Polyfills/index.js b/src/Polyfills/index.js index e938ce6..aa205a9 100644 --- a/src/Polyfills/index.js +++ b/src/Polyfills/index.js @@ -1,25 +1,26 @@ if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - "use strict"; - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 - // internal IsCallable function - throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); - } + Function.prototype.bind = function (oThis) { + 'use strict'; + if (typeof this !== 'function') { + // closest thing possible to the ECMAScript 5 + // internal IsCallable function + throw new TypeError('Function.prototype.bind - what is trying to be bound is not callable'); + } - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function () {}, - fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis - ? this - : oThis, - aArgs.concat(Array.prototype.slice.call(arguments))); - }; + var aArgs = Array.prototype.slice.call(arguments, 1); + var _this = this; + var FNOP = function() {}; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); + var fBound = function() { + return _this.apply(this instanceof FNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; - return fBound; - }; + FNOP.prototype = this.prototype; + fBound.prototype = new FNOP(); + + return fBound; + }; } \ No newline at end of file From b321c5adf29f2b2bde27285b36bc21262ba8f495 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 12:49:32 +0200 Subject: [PATCH 28/58] object create polyfill --- src/Polyfills/index.js | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/Polyfills/index.js b/src/Polyfills/index.js index aa205a9..4fe12a9 100644 --- a/src/Polyfills/index.js +++ b/src/Polyfills/index.js @@ -23,4 +23,48 @@ if (!Function.prototype.bind) { return fBound; }; +} + +if (typeof Object.create != 'function') { + // Production steps of ECMA-262, Edition 5, 15.2.3.5 + // Reference: http://es5.github.io/#x15.2.3.5 + Object.create = (function() { + // To save on memory, use a shared constructor + function Temp() {} + + // make a safe reference to Object.prototype.hasOwnProperty + var hasOwn = Object.prototype.hasOwnProperty; + + return function(O) { + // 1. If Type(O) is not Object or Null throw a TypeError exception. + if (typeof O != 'object') { + throw TypeError('Object prototype may only be an Object or null'); + } + + // 2. Let obj be the result of creating a new object as if by the + // expression new Object() where Object is the standard built-in + // constructor with that name + // 3. Set the [[Prototype]] internal property of obj to O. + Temp.prototype = O; + var obj = new Temp(); + Temp.prototype = null; // Let's not keep a stray reference to O... + + // 4. If the argument Properties is present and not undefined, add + // own properties to obj as if by calling the standard built-in + // function Object.defineProperties with arguments obj and + // Properties. + if (arguments.length > 1) { + // Object.defineProperties does ToObject on its first argument. + var Properties = Object(arguments[1]); + for (var prop in Properties) { + if (hasOwn.call(Properties, prop)) { + obj[prop] = Properties[prop]; + } + } + } + + // 5. Return obj + return obj; + }; + })(); } \ No newline at end of file From 76a5aec785f2bdce8a0685d7edc8ef1f23dddee0 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:04:00 +0200 Subject: [PATCH 29/58] change image create to factory --- test/tests.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/tests.js b/test/tests.js index a4735f4..e577281 100644 --- a/test/tests.js +++ b/test/tests.js @@ -202,13 +202,13 @@ describe('Overlay', function() { describe('Image', function() { describe('#constructor()', function() { it('should create an image object with given src', function() { - var exampleImage = new Image('some/src'); + var exampleImage = Image('some/src'); assert.equal('some/src', exampleImage.src); }); it('should create a dom object with given src', function() { - var exampleImage = new Image('some/src'); + var exampleImage = Image('some/src'); assert.notEqual(-1, exampleImage.element.src.indexOf('some/src')); }); @@ -216,7 +216,7 @@ describe('Image', function() { describe('#preload()', function() { it('should callback when an image is loaded', function(done) { - var exampleImage = new Image('images/1.jpg'); + var exampleImage = Image('images/1.jpg'); exampleImage.preload(done); }); From eb24ddee83e6e46dee6236736ed08dca1e47e04f Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:04:51 +0200 Subject: [PATCH 30/58] formatting of Image --- src/ImagePreloader/Image.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/ImagePreloader/Image.js b/src/ImagePreloader/Image.js index 1315c7a..6a79e41 100644 --- a/src/ImagePreloader/Image.js +++ b/src/ImagePreloader/Image.js @@ -1,26 +1,26 @@ var ImageLoaded = require('./ImageLoaded.js'); function Image(src) { - 'use strict'; - this.src = src; - this.element = null; + 'use strict'; + this.src = src; + this.element = null; - if (typeof src !== "undefined") { - this.create(); - } + if (typeof src !== 'undefined') { + this.create(); + } } Image.prototype.create = function () { - 'use strict'; - this.element = document.createElement("img"); - this.element.setAttribute("src", this.src); + 'use strict'; + this.element = document.createElement('img'); + this.element.setAttribute('src', this.src); }; -Image.prototype.preload = function (cb) { - 'use strict'; - ImageLoaded(this.element, function(err, alreadyLoaded) { - cb(err, alreadyLoaded); - }); +Image.prototype.preload = function(cb) { + 'use strict'; + ImageLoaded(this.element, function(err, alreadyLoaded) { + cb(err, alreadyLoaded); + }); }; module.exports = Image; \ No newline at end of file From a3911486a6f49820204a07d78c1390c86421bf17 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:14:19 +0200 Subject: [PATCH 31/58] image to module --- src/ImagePreloader/Image.js | 42 +++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/src/ImagePreloader/Image.js b/src/ImagePreloader/Image.js index 6a79e41..5d37293 100644 --- a/src/ImagePreloader/Image.js +++ b/src/ImagePreloader/Image.js @@ -1,26 +1,28 @@ +'use strict'; var ImageLoaded = require('./ImageLoaded.js'); -function Image(src) { - 'use strict'; - this.src = src; - this.element = null; +var Image = { + create: function() { + this.element = document.createElement('img'); + this.element.setAttribute('src', this.src); + }, - if (typeof src !== 'undefined') { - this.create(); - } -} - -Image.prototype.create = function () { - 'use strict'; - this.element = document.createElement('img'); - this.element.setAttribute('src', this.src); + preload: function(cb) { + ImageLoaded(this.element, function(err, alreadyLoaded) { + cb(err, alreadyLoaded); + }); + }, }; -Image.prototype.preload = function(cb) { - 'use strict'; - ImageLoaded(this.element, function(err, alreadyLoaded) { - cb(err, alreadyLoaded); - }); -}; +module.exports = function(src) { + var image = Object.create(Image); + + image.src = src; + image.element = null; + + if (typeof src !== 'undefined') { + image.create(); + } -module.exports = Image; \ No newline at end of file + return image; +}; \ No newline at end of file From 9611d6976b9d961375d3508636c1613e001c3bb1 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:15:38 +0200 Subject: [PATCH 32/58] formatted image loaded --- src/ImagePreloader/ImageLoaded.js | 61 ++++++++++++++++--------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/ImagePreloader/ImageLoaded.js b/src/ImagePreloader/ImageLoaded.js index 2184f7d..e8027fc 100644 --- a/src/ImagePreloader/ImageLoaded.js +++ b/src/ImagePreloader/ImageLoaded.js @@ -3,46 +3,47 @@ * MIT License. by Paul Irish et al. */ -var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==' +'use strict'; +var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; function loaded(image, callback) { - "use strict"; - var src; + var src; - if (!image.nodeName) { - return callback(new Error('First argument must be an image element')); - } + if (!image.nodeName) { + return callback(new Error('First argument must be an image element')); + } - if (image.nodeName.toLowerCase() !== 'img') { - return callback(new Error('Element supplied is not an image')); - } - if (image.src && image.complete && image.naturalWidth !== undefined) { - return callback(null, true); - } + if (image.nodeName.toLowerCase() !== 'img') { + return callback(new Error('Element supplied is not an image')); + } - function bindEvent(element, event, attach, cb) { - if (!element.addEventListener) { - element[(attach ? 'attachEvent' : 'detachEvent')]('on' + event, cb); - } else { - element[(attach ? 'addEventListener' : 'removeEventListener')](event, cb); - } + if (image.src && image.complete && image.naturalWidth !== undefined) { + return callback(null, true); + } + + function bindEvent(element, event, attach, cb) { + if (!element.addEventListener) { + element[(attach ? 'attachEvent' : 'detachEvent')]('on' + event, cb); + } else { + element[(attach ? 'addEventListener' : 'removeEventListener')](event, cb); } + } - function onload() { - bindEvent(image, 'load', false, onload); - bindEvent(image, 'error', false, onload); + function onload() { + bindEvent(image, 'load', false, onload); + bindEvent(image, 'error', false, onload); - callback(null, false); - } + callback(null, false); + } - bindEvent(image, 'load', true, onload); - bindEvent(image, 'error', true, onload); + bindEvent(image, 'load', true, onload); + bindEvent(image, 'error', true, onload); - if (image.readyState || image.complete) { - src = image.src; - image.src = BLANK; - image.src = src; - } + if (image.readyState || image.complete) { + src = image.src; + image.src = BLANK; + image.src = src; + } } module.exports = loaded; \ No newline at end of file From 55124652bc28559a2241689a9e0b0ce1998795f4 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:17:08 +0200 Subject: [PATCH 33/58] remove new from QL --- test/tests.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/tests.js b/test/tests.js index e577281..ef73fd4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -234,7 +234,7 @@ describe('QueryLoader', function() { }); describe('#createOverlay()', function() { - var ql = new QueryLoader(); + var ql = QueryLoader(); it('should create an overlay when called', function() { ql.createOverlay(); @@ -244,7 +244,7 @@ describe('QueryLoader', function() { }); describe('#createPreloader()', function() { - var ql = new QueryLoader(); + var ql = QueryLoader(); it('should create the preloader', function() { ql.createPreloader(); @@ -255,7 +255,7 @@ describe('QueryLoader', function() { describe('#extend()', function() { it('should merge two objects', function() { - var ql = new QueryLoader(); + var ql = QueryLoader(); var destination = { some: 'thing', @@ -278,7 +278,7 @@ describe('QueryLoader', function() { describe('#updateProgress()', function() { var called = false; - var ql = new QueryLoader(document.createElement('div'), { + var ql = QueryLoader(document.createElement('div'), { onProgress: function(amount) { called = true; }, @@ -295,7 +295,7 @@ describe('QueryLoader', function() { describe('ImagePreloader', function() { 'use strict'; describe('#getImageSrcs()', function() { - var ip = new ImagePreloader(); + var ip = ImagePreloader(); var fakeImagesContainer = document.createElement('div'); @@ -331,7 +331,7 @@ describe('ImagePreloader', function() { }); describe('#hasGradient()', function() { - var ip = new ImagePreloader(); + var ip = ImagePreloader(); it('should check if given url has a gradient', function() { assert.equal(false, ip.hasGradient('hasnogradienthere.png')); @@ -341,7 +341,7 @@ describe('ImagePreloader', function() { }); describe('#stripUrl()', function() { - var ip = new ImagePreloader(); + var ip = ImagePreloader(); it('should strip the url() part from given src', function() { assert.equal(-1, ip.stripUrl('url(this/path/file.png)').indexOf('url')); @@ -350,7 +350,7 @@ describe('ImagePreloader', function() { }); describe('#validUrl()', function() { - var ip = new ImagePreloader(); + var ip = ImagePreloader(); it('should check if given url is valid', function() { assert.equal(false, ip.validUrl('')); @@ -360,7 +360,7 @@ describe('ImagePreloader', function() { }); describe('#urlIsNew()', function() { - var ip = new ImagePreloader(); + var ip = ImagePreloader(); ip.sources = ['test.png', 'something.png', 'image.jpg']; it('should check if given url is new in this.images', function() { From 44a7f7dd9cd9ad1efcf25a8f9d1b59842eaf3a72 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:29:19 +0200 Subject: [PATCH 34/58] rewrite to module --- src/QueryLoader/index.js | 188 +++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 95 deletions(-) diff --git a/src/QueryLoader/index.js b/src/QueryLoader/index.js index 020548c..149cdfc 100644 --- a/src/QueryLoader/index.js +++ b/src/QueryLoader/index.js @@ -1,72 +1,38 @@ +'use strict'; var ImagePreloader = require('./../ImagePreloader/index'); var Overlay = require('./../Overlay/index'); -function QueryLoader(element, options) { - 'use strict'; - this.element = element; - this.options = options; - this.done = false; - this.maxTimeout = null; - - //The default options - this.defaultOptions = { - onComplete: function() {}, - onProgress: function() {}, - backgroundColor: "#000", - barColor: "#fff", - overlayId: 'qLoverlay', - percentageId: 'qLpercentage', - barHeight: 1, - percentage: false, - deepSearch: true, - minimumTime: 300, - maxTime: 10000, - fadeOutTime: 1000 - }; - - //children - this.overlay = null; - this.preloader = null; - - if (element !== null) { - this.init(); - } -} - -QueryLoader.prototype.init = function () { - 'use strict'; +var QueryLoader = { + init: function() { this.options = this.extend(this.defaultOptions, this.options); - if (typeof this.element !== "undefined") { - this.createOverlay(); - this.removeTempOverlay(); - this.createPreloader(); - this.startMaxTimeout(); + if (typeof this.element !== 'undefined') { + this.createOverlay(); + this.removeTempOverlay(); + this.createPreloader(); + this.startMaxTimeout(); } -}; + }, -QueryLoader.prototype.extend = function (base, adding) { - 'use strict'; - if (typeof base === "undefined") { - base = {}; + extend: function(base, adding) { + if (typeof base === 'undefined') { + base = {}; } for (var property in adding) { - if (adding.hasOwnProperty(property)) { - base[property] = adding[property]; - } + if (adding.hasOwnProperty(property)) { + base[property] = adding[property]; + } } return base; -}; + }, -QueryLoader.prototype.startMaxTimeout = function () { - "use strict"; + startMaxTimeout: function() { this.maxTimeout = window.setTimeout(this.doneLoading.bind(this), this.options.maxTime); -}; + }, -QueryLoader.prototype.createOverlay = function () { - 'use strict'; + createOverlay: function() { this.overlay = new Overlay(this.element); this.overlay.idName = this.options.overlayId; this.overlay.percentageId = this.options.percentageId; @@ -76,77 +42,109 @@ QueryLoader.prototype.createOverlay = function () { this.overlay.showPercentage = this.options.percentage; this.overlay.fadeOutTime = this.options.fadeOutTime; - if (typeof this.element !== "undefined") { - this.overlay.init(); + if (typeof this.element !== 'undefined') { + this.overlay.init(); } -}; + }, -QueryLoader.prototype.removeTempOverlay = function () { + removeTempOverlay: function() { window.setTimeout(function () { - var tempOverlay = document.getElementById("qLtempOverlay"); - if (tempOverlay && tempOverlay.parentNode) { - tempOverlay.parentNode.removeChild(tempOverlay); - } + var tempOverlay = document.getElementById('qLtempOverlay'); + if (tempOverlay && tempOverlay.parentNode) { + tempOverlay.parentNode.removeChild(tempOverlay); + } }, 0); -}; + }, -QueryLoader.createTempOverlay = function () { + createTempOverlay: function () { var timeout = window.setInterval(function() { - if (typeof document.getElementsByTagName('body')[0] !== "undefined") { - var tempOverlay = document.createElement("div"); - tempOverlay.style.position = "fixed"; - tempOverlay.style.width = "100%"; - tempOverlay.style.height = "100%"; - tempOverlay.style.zIndex = "9999"; - tempOverlay.style.backgroundColor = "#000"; - tempOverlay.style.left = "0"; - tempOverlay.style.top = "0"; - tempOverlay.setAttribute("id", "qLtempOverlay"); - document.getElementsByTagName('body')[0].appendChild(tempOverlay); - - window.clearInterval(timeout); - } + if (typeof document.getElementsByTagName('body')[0] !== 'undefined') { + var tempOverlay = document.createElement('div'); + tempOverlay.style.position = 'fixed'; + tempOverlay.style.width = '100%'; + tempOverlay.style.height = '100%'; + tempOverlay.style.zIndex = '9999'; + tempOverlay.style.backgroundColor = '#000'; + tempOverlay.style.left = '0'; + tempOverlay.style.top = '0'; + tempOverlay.setAttribute('id', 'qLtempOverlay'); + document.getElementsByTagName('body')[0].appendChild(tempOverlay); + + window.clearInterval(timeout); + } }, 1); -}; + }, -QueryLoader.prototype.createPreloader = function () { - 'use strict'; - this.preloader = new ImagePreloader(this); + createPreloader: function() { + this.preloader = ImagePreloader(this); this.preloader.deepSearch = this.options.deepSearch; window.setTimeout(function () { this.preloader.findAndPreload(this.element); }.bind(this), 100); -}; + }, -QueryLoader.prototype.updateProgress = function (done, total) { - "use strict"; + updateProgress: function(done, total) { var percentage = ((done / total) * 100); this.overlay.updateProgress(percentage, this.options.minimumTime); - if (typeof this.options.onProgress === "function") { - this.options.onProgress(percentage, done, total); + if (typeof this.options.onProgress === 'function') { + this.options.onProgress(percentage, done, total); } if (done === total && this.done === false) { - window.clearTimeout(this.maxTimeout); - window.setTimeout(this.doneLoading.bind(this), this.options.minimumTime); + window.clearTimeout(this.maxTimeout); + window.setTimeout(this.doneLoading.bind(this), this.options.minimumTime); } -}; + }, -QueryLoader.prototype.doneLoading = function () { - "use strict"; + doneLoading: function () { window.clearTimeout(this.maxTimeout); this.done = true; this.overlay.element.style.opacity = 0; window.setTimeout(this.destroy.bind(this), this.options.fadeOutTime); -}; + }, -QueryLoader.prototype.destroy = function () { - "use strict"; + destroy: function () { this.overlay.remove(); this.options.onComplete(); + } }; -module.exports = QueryLoader; \ No newline at end of file +module.exports = function(element, options) { + var queryLoader = Object.create(QueryLoader2); + + queryLoader.element = element; + queryLoader.options = options; + queryLoader.done = false; + queryLoader.maxTimeout = null; + + var voidFunc = function() {}; + + //The default options + queryLoader.defaultOptions = { + onComplete: voidFunc, + onProgress: voidFunc, + backgroundColor: '#000', + barColor: '#fff', + overlayId: 'qLoverlay', + percentageId: 'qLpercentage', + barHeight: 1, + percentage: false, + deepSearch: true, + minimumTime: 300, + maxTime: 10000, + fadeOutTime: 1000, + }; + + //children + queryLoader.overlay = null; + queryLoader.preloader = null; + + if (element !== null) { + queryLoader.init(); + } + + return queryLoader; +}; \ No newline at end of file From 02266f660dfdccf1ad4517d860d184d93a6c1d1a Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:35:21 +0200 Subject: [PATCH 35/58] decouple temp overlay --- src/QueryLoader/TempOverlay.js | 19 ++++++++++++++++++ src/QueryLoader/index.js | 27 ++++---------------------- src/index.js | 35 +++++++++++++++++----------------- 3 files changed, 41 insertions(+), 40 deletions(-) create mode 100644 src/QueryLoader/TempOverlay.js diff --git a/src/QueryLoader/TempOverlay.js b/src/QueryLoader/TempOverlay.js new file mode 100644 index 0000000..6d0a62a --- /dev/null +++ b/src/QueryLoader/TempOverlay.js @@ -0,0 +1,19 @@ +'use strict'; +module.exports = function() { + var timeout = window.setInterval(function() { + if (typeof document.getElementsByTagName('body')[0] !== 'undefined') { + var tempOverlay = document.createElement('div'); + tempOverlay.style.position = 'fixed'; + tempOverlay.style.width = '100%'; + tempOverlay.style.height = '100%'; + tempOverlay.style.zIndex = '9999'; + tempOverlay.style.backgroundColor = '#000'; + tempOverlay.style.left = '0'; + tempOverlay.style.top = '0'; + tempOverlay.setAttribute('id', 'qLtempOverlay'); + document.getElementsByTagName('body')[0].appendChild(tempOverlay); + + window.clearInterval(timeout); + } + }, 1); +}; \ No newline at end of file diff --git a/src/QueryLoader/index.js b/src/QueryLoader/index.js index 149cdfc..bc9ead5 100644 --- a/src/QueryLoader/index.js +++ b/src/QueryLoader/index.js @@ -48,7 +48,7 @@ var QueryLoader = { }, removeTempOverlay: function() { - window.setTimeout(function () { + window.setTimeout(function() { var tempOverlay = document.getElementById('qLtempOverlay'); if (tempOverlay && tempOverlay.parentNode) { tempOverlay.parentNode.removeChild(tempOverlay); @@ -56,30 +56,11 @@ var QueryLoader = { }, 0); }, - createTempOverlay: function () { - var timeout = window.setInterval(function() { - if (typeof document.getElementsByTagName('body')[0] !== 'undefined') { - var tempOverlay = document.createElement('div'); - tempOverlay.style.position = 'fixed'; - tempOverlay.style.width = '100%'; - tempOverlay.style.height = '100%'; - tempOverlay.style.zIndex = '9999'; - tempOverlay.style.backgroundColor = '#000'; - tempOverlay.style.left = '0'; - tempOverlay.style.top = '0'; - tempOverlay.setAttribute('id', 'qLtempOverlay'); - document.getElementsByTagName('body')[0].appendChild(tempOverlay); - - window.clearInterval(timeout); - } - }, 1); - }, - createPreloader: function() { this.preloader = ImagePreloader(this); this.preloader.deepSearch = this.options.deepSearch; - window.setTimeout(function () { this.preloader.findAndPreload(this.element); }.bind(this), 100); + window.setTimeout(function() { this.preloader.findAndPreload(this.element); }.bind(this), 100); }, updateProgress: function(done, total) { @@ -96,7 +77,7 @@ var QueryLoader = { } }, - doneLoading: function () { + doneLoading: function() { window.clearTimeout(this.maxTimeout); this.done = true; @@ -105,7 +86,7 @@ var QueryLoader = { window.setTimeout(this.destroy.bind(this), this.options.fadeOutTime); }, - destroy: function () { + destroy: function() { this.overlay.remove(); this.options.onComplete(); diff --git a/src/index.js b/src/index.js index 1042ae2..0f98075 100644 --- a/src/index.js +++ b/src/index.js @@ -1,30 +1,31 @@ -require('./Polyfills/'); -var QueryLoader2 = require('./QueryLoader/'); +require('./Polyfills'); +var QueryLoader2 = require('./QueryLoader'); +var TempOverlay = require('./QueryLoader/TempOverlay'); //jquery and zepto if (window.jQuery || window.Zepto) { - (function ($) { - 'use strict'; - $.fn.queryLoader2 = function(options){ - return this.each(function() { - (new QueryLoader2(this, options)); - }); - }; - })(window.jQuery || window.Zepto); + (function($) { + 'use strict'; + $.fn.queryLoader2 = function(options){ + return this.each(function() { + (new QueryLoader2(this, options)); + }); + }; + })(window.jQuery || window.Zepto); } // component -if (typeof(module) !== 'undefined') { - module.exports = QueryLoader2; +if (typeof module !== 'undefined') { + module.exports = QueryLoader2; } // requirejs support if (typeof define === 'function' && define.amd) { - define([], function () { - 'use strict'; - return QueryLoader2; - }); + define([], function() { + 'use strict'; + return QueryLoader2; + }); } window.QueryLoader2 = QueryLoader2; -QueryLoader2.createTempOverlay(); \ No newline at end of file +TempOverlay(); \ No newline at end of file From 3e541a2c8cb8d1921234e01285fae9c5f2f2ba40 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:36:24 +0200 Subject: [PATCH 36/58] create from correct object --- src/QueryLoader/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/QueryLoader/index.js b/src/QueryLoader/index.js index bc9ead5..ebcbb1c 100644 --- a/src/QueryLoader/index.js +++ b/src/QueryLoader/index.js @@ -90,11 +90,11 @@ var QueryLoader = { this.overlay.remove(); this.options.onComplete(); - } + }, }; module.exports = function(element, options) { - var queryLoader = Object.create(QueryLoader2); + var queryLoader = Object.create(QueryLoader); queryLoader.element = element; queryLoader.options = options; From 9497a4559870bd44d634b4d9ba51fd527ebaa26a Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:43:04 +0200 Subject: [PATCH 37/58] set options --- queryloader2.min.js | 4 ++-- src/QueryLoader/index.js | 49 ++++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/queryloader2.min.js b/queryloader2.min.js index abd0809..679a0b0 100644 --- a/queryloader2.min.js +++ b/queryloader2.min.js @@ -10,6 +10,6 @@ * http://www.opensource.org/licenses/mit-license.php * * Version: 3.0.16 - * Last update: 2015-07-20 + * Last update: 2015-10-15 */ -!function e(t,i,s){function n(o,a){if(!i[o]){if(!t[o]){var l="function"==typeof require&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);throw new Error("Cannot find module '"+o+"'")}var u=i[o]={exports:{}};t[o][0].call(u.exports,function(e){var i=t[o][1][e];return n(i?i:e)},u,u.exports,e,t,i,s)}return i[o].exports}for(var r="function"==typeof require&&require,o=0;o0&&!e.match(/^(data:)/i)?!0:!1},i.prototype.urlIsNew=function(e){"use strict";return-1===this.sources.indexOf(e)},i.prototype.isIE=function(){"use strict";return navigator.userAgent.match(/msie/i)},i.prototype.isOpera=function(){"use strict";return navigator.userAgent.match(/Opera/i)},t.exports=i},{"./Image.js":1}],4:[function(e,t){function i(){"use strict";this.element=null,this.className="queryloader__overlay__bar",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},i.prototype.setStyling=function(){"use strict";this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},i.prototype.updateProgress=function(e,t){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),0!==t&&this.setTransitionTime(t),this.element.style.width=parseInt(e)+"%"},i.prototype.setTransitionTime=function(e){"use strict";this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"},t.exports=i},{}],5:[function(e,t){function i(){"use strict";this.element=null,this.idName="qlPercentage",this.className="queryloader__overlay__percentage",this.barHeight=1,this.barColor="#fff"}i.prototype.create=function(){"use strict";this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},i.prototype.applyStyling=function(){"use strict";this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},i.prototype.updateProgress=function(e){"use strict";parseInt(e)<0?e=0:parseInt(e)>100&&(e=100),this.element.innerHTML=parseInt(e)+"%"},t.exports=i},{}],6:[function(e,t){function i(e){"use strict";this.parentElement=e,this.idName="qLoverlay",this.percentageId="qlPercentage",this.className="queryloader__overlay",this.element=null,this.loadingBar=null,this.percentage=null,this.barColor="#ff0000",this.backgroundColor="#000",this.barHeight=1,this.fadeOutTime=300,this.showPercentage=!1}var s=e("./LoadingBar.js"),n=e("./Percentage.js");i.prototype.init=function(){"use strict";this.create(),this.loadingBar=new s,this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=new n,this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},i.prototype.create=function(){"use strict";this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},i.prototype.applyStyling=function(){"use strict";this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},i.prototype.calculatePosition=function(){"use strict";var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},i.prototype.updateProgress=function(e,t){"use strict";null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},i.prototype.remove=function(){"use strict";this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},i.prototype.canRemove=function(e){"use strict";return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild},t.exports=i},{"./LoadingBar.js":4,"./Percentage.js":5}],7:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),i=this,s=function(){},n=function(){return i.apply(this instanceof s&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return s.prototype=this.prototype,n.prototype=new s,n})},{}],8:[function(e,t){function i(e,t){"use strict";this.element=e,this.options=t,this.done=!1,this.maxTimeout=null,this.defaultOptions={onComplete:function(){},onProgress:function(){},backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3},this.overlay=null,this.preloader=null,null!==e&&this.init()}var s=e("./ImagePreloader/"),n=e("./Overlay/");i.prototype.init=function(){"use strict";this.options=this.extend(this.defaultOptions,this.options),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},i.prototype.extend=function(e,t){"use strict";"undefined"==typeof e&&(e={});for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},i.prototype.startMaxTimeout=function(){"use strict";this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},i.prototype.createOverlay=function(){"use strict";this.overlay=new n(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},i.prototype.removeTempOverlay=function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},i.createTempOverlay=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)},i.prototype.createPreloader=function(){"use strict";this.preloader=new s(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},i.prototype.updateProgress=function(e,t){"use strict";var i=e/t*100;this.overlay.updateProgress(i,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(i,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},i.prototype.doneLoading=function(){"use strict";window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},i.prototype.destroy=function(){"use strict";this.overlay.remove(),this.options.onComplete()},t.exports=i},{"./ImagePreloader/":3,"./Overlay/":6}],9:[function(e,t){e("./Polyfills/");var i=e("./index.js");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,i.createTempOverlay()},{"./Polyfills/":7,"./QueryLoader.js":8}]},{},[9]); \ No newline at end of file +!function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=i[s]={exports:{}};t[s][0].call(u.exports,function(e){var i=t[s][1][e];return r(i?i:e)},u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},i.prototype.urlIsNew=function(e){"use strict";return-1===this.sources.indexOf(e)},i.prototype.isIE=function(){"use strict";return navigator.userAgent.match(/msie/i)},i.prototype.isOpera=function(){"use strict";return navigator.userAgent.match(/Opera/i)},t.exports=i},{"./Image.js":1}],4:[function(e,t){"use strict";var i=e("./PercentageParser"),n={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=i(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(n);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var i=e("./PercentageParser"),n={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=i(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(n);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function i(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=i},{}],7:[function(e,t){"use strict";var i=e("./LoadingBar"),n=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=i(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=n(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),i=this,n=function(){},r=function(){return i.apply(this instanceof n&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,r.prototype=new n,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(i){if("object"!=typeof i)throw TypeError("Object prototype may only be an Object or null");e.prototype=i;var n=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(n[o]=r[o])}return n}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var i=e("./../ImagePreloader/index"),n=e("./../Overlay/index"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new n(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=i(this),console.log(this.options),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var i=e/t*100;this.overlay.updateProgress(i,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(i,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var i=Object.create(r);if(i.element=e,i.options={},i.done=!1,i.maxTimeout=null,i.overlay=null,i.preloader=null,null!==e){var n=function(){};i.init(t,{onComplete:n,onProgress:n,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return i}},{"./../ImagePreloader/index":3,"./../Overlay/index":7}],11:[function(e,t){e("./Polyfills");var i=e("./QueryLoader"),n=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,n()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file diff --git a/src/QueryLoader/index.js b/src/QueryLoader/index.js index ebcbb1c..0ab3c82 100644 --- a/src/QueryLoader/index.js +++ b/src/QueryLoader/index.js @@ -1,10 +1,10 @@ 'use strict'; -var ImagePreloader = require('./../ImagePreloader/index'); -var Overlay = require('./../Overlay/index'); +var ImagePreloader = require('./../ImagePreloader'); +var Overlay = require('./../Overlay'); var QueryLoader = { - init: function() { - this.options = this.extend(this.defaultOptions, this.options); + init: function(options, defaultOptions) { + this.options = this.extend(defaultOptions, options); if (typeof this.element !== 'undefined') { this.createOverlay(); @@ -60,7 +60,9 @@ var QueryLoader = { this.preloader = ImagePreloader(this); this.preloader.deepSearch = this.options.deepSearch; - window.setTimeout(function() { this.preloader.findAndPreload(this.element); }.bind(this), 100); + window.setTimeout(function() { + this.preloader.findAndPreload(this.element); + }.bind(this), 100); }, updateProgress: function(done, total) { @@ -97,34 +99,31 @@ module.exports = function(element, options) { var queryLoader = Object.create(QueryLoader); queryLoader.element = element; - queryLoader.options = options; + queryLoader.options = {}; queryLoader.done = false; queryLoader.maxTimeout = null; - var voidFunc = function() {}; - - //The default options - queryLoader.defaultOptions = { - onComplete: voidFunc, - onProgress: voidFunc, - backgroundColor: '#000', - barColor: '#fff', - overlayId: 'qLoverlay', - percentageId: 'qLpercentage', - barHeight: 1, - percentage: false, - deepSearch: true, - minimumTime: 300, - maxTime: 10000, - fadeOutTime: 1000, - }; - //children queryLoader.overlay = null; queryLoader.preloader = null; if (element !== null) { - queryLoader.init(); + var voidFunc = function() {}; + + queryLoader.init(options, { + onComplete: voidFunc, + onProgress: voidFunc, + backgroundColor: '#000', + barColor: '#fff', + overlayId: 'qLoverlay', + percentageId: 'qLpercentage', + barHeight: 1, + percentage: false, + deepSearch: true, + minimumTime: 300, + maxTime: 10000, + fadeOutTime: 1000, + }); } return queryLoader; From f92f74c93a4cd03f2f9caee6ff790e4c6a6aa3e9 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:50:48 +0200 Subject: [PATCH 38/58] ImagePreloader to module --- src/ImagePreloader/index.js | 176 +++++++++++++++++------------------- 1 file changed, 84 insertions(+), 92 deletions(-) diff --git a/src/ImagePreloader/index.js b/src/ImagePreloader/index.js index a07b018..96cc368 100644 --- a/src/ImagePreloader/index.js +++ b/src/ImagePreloader/index.js @@ -1,149 +1,141 @@ +'use strict'; var Image = require('./Image.js'); -function ImagePreloader(parent) { - "use strict"; - this.parent = parent; +var ImagePreloader = { + getImageSrcs: function(element) { this.sources = []; - this.images = []; - this.loaded = 0; - this.deepSearch = true; -} -ImagePreloader.prototype.getImageSrcs = function (element) { - "use strict"; - this.sources = []; - - if (typeof element !== "undefined") { - this.findImageInElement(element); + if (typeof element !== 'undefined') { + this.findImageInElement(element); - if (this.deepSearch === true) { - var elements = element.querySelectorAll("*"); - for (var i = 0; i < elements.length; i++) { - if (elements[i].tagName !== "SCRIPT") { - this.findImageInElement(elements[i]); - } - } + if (this.deepSearch === true) { + var elements = element.querySelectorAll('*'); + for (var i = 0; i < elements.length; i++) { + if (elements[i].tagName !== 'SCRIPT') { + this.findImageInElement(elements[i]); + } } + } } return this.sources; -}; + }, -ImagePreloader.prototype.findAndPreload = function (element) { - "use strict"; - if (typeof element === "undefined") { - return; + findAndPreload: function(element) { + if (typeof element === 'undefined') { + return; } this.sources = this.getImageSrcs(element); for (var i = 0; i < this.sources.length; i++) { - var image = new Image(this.sources[i]); - image.preload(this.imageLoaded.bind(this)); - this.images.push(image); + var image = new Image(this.sources[i]); + image.preload(this.imageLoaded.bind(this)); + this.images.push(image); } -}; + }, -ImagePreloader.prototype.imageLoaded = function () { - "use strict"; + imageLoaded: function() { this.loaded++; this.updateProgress(); -}; + }, -ImagePreloader.prototype.updateProgress = function () { - "use strict"; + updateProgress: function() { this.parent.updateProgress(this.loaded, this.sources.length); -}; + }, -ImagePreloader.prototype.findImageInElement = function (element) { - "use strict"; + findImageInElement: function(element) { var urlType = this.determineUrlAndType(element); //skip if gradient if (!this.hasGradient(urlType.url)) { - //remove unwanted chars - urlType.url = this.stripUrl(urlType.url); + //remove unwanted chars + urlType.url = this.stripUrl(urlType.url); - //split urls - var urls = urlType.url.split(", "); + //split urls + var urls = urlType.url.split(', '); - for (var i = 0; i < urls.length; i++) { - if (this.validUrl(urls[i]) && this.urlIsNew(urls[i])) { - var extra = ""; + for (var i = 0; i < urls.length; i++) { + if (this.validUrl(urls[i]) && this.urlIsNew(urls[i])) { + var extra = ''; - if (this.isIE() || this.isOpera()){ - //filthy always no cache for IE, sorry peeps! - extra = "?rand=" + Math.random(); - } + if (this.isIE() || this.isOpera()) { + //filthy always no cache for IE, sorry peeps! + extra = '?rand=' + Math.random(); + } - //add image to found list - this.sources.push(urls[i] + extra); - } + //add image to found list + this.sources.push(urls[i] + extra); } + } } -}; + }, -ImagePreloader.prototype.determineUrlAndType = function (element) { - "use strict"; - var url = ""; - var type = "normal"; + determineUrlAndType: function(element) { + var url = ''; + var type = 'normal'; var style = element.currentStyle || window.getComputedStyle(element, null); - if ((typeof style.backgroundImage !== "undefined" && style.backgroundImage !== "" && style.backgroundImage !== "none") - || (typeof element.style.backgroundImage !== "undefined" && element.style.backgroundImage !== "" && element.style.backgroundImage !== "none") + if ((typeof style.backgroundImage !== 'undefined' && style.backgroundImage !== '' && style.backgroundImage !== 'none') + || (typeof element.style.backgroundImage !== 'undefined' && element.style.backgroundImage !== '' && element.style.backgroundImage !== 'none') ) { - //if object has background image - url = (style.backgroundImage || element.style.backgroundImage); - type = "background"; - } else if (typeof(element.getAttribute("src")) !== "undefined" && element.nodeName.toLowerCase() === "img") { - //if is img and has src - url = element.getAttribute("src"); + //if object has background image + url = (style.backgroundImage || element.style.backgroundImage); + type = 'background'; + } else if (typeof element.getAttribute('src') !== 'undefined' && element.nodeName.toLowerCase() === 'img') { + //if is img and has src + url = element.getAttribute('src'); } return { - url: url, - type: type + url: url, + type: type, }; -}; + }, -ImagePreloader.prototype.hasGradient = function (url) { - "use strict"; - return (url && typeof url.indexOf !== "undefined" ? url.indexOf("gradient(") !== -1 : false ); -}; + hasGradient: function(url) { + return (url && typeof url.indexOf !== 'undefined' ? url.indexOf('gradient(') !== -1 : false); + }, -ImagePreloader.prototype.stripUrl = function (url) { - "use strict"; - url = url.replace(/url\(\"/g, ""); - url = url.replace(/url\(/g, ""); - url = url.replace(/\"\)/g, ""); - url = url.replace(/\)/g, ""); + stripUrl: function(url) { + url = url.replace(/url\(\'/g, ''); + url = url.replace(/url\(/g, ''); + url = url.replace(/\'\)/g, ''); + url = url.replace(/\)/g, ''); return url; -}; + }, -ImagePreloader.prototype.validUrl = function (url) { - "use strict"; + validUrl: function(url) { if (url.length > 0 && !url.match(/^(data:)/i)) { - return true; + return true; } else { - return false; + return false; } -}; + }, -ImagePreloader.prototype.urlIsNew = function (url) { - "use strict"; + urlIsNew: function(url) { return this.sources.indexOf(url) === -1; -}; + }, -ImagePreloader.prototype.isIE = function () { - "use strict"; + isIE: function() { return navigator.userAgent.match(/msie/i); -}; + }, -ImagePreloader.prototype.isOpera = function () { - "use strict"; + isOpera: function() { return navigator.userAgent.match(/Opera/i); + }, }; -module.exports = ImagePreloader; \ No newline at end of file +module.exports = function(parent) { + var imagePreloader = Object.create(ImagePreloader); + + imagePreloader.parent = parent; + imagePreloader.sources = []; + imagePreloader.images = []; + imagePreloader.loaded = 0; + imagePreloader.deepSearch = true; + + return imagePreloader; +}; \ No newline at end of file From cb4e691402567c07322169f2754272fc9a04d3a4 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 13:58:15 +0200 Subject: [PATCH 39/58] use json to compare objects --- test/tests.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/tests.js b/test/tests.js index ef73fd4..027c68d 100644 --- a/test/tests.js +++ b/test/tests.js @@ -229,7 +229,7 @@ describe('QueryLoader', function() { var qlNew = new QueryLoader(); var qlFactory = QueryLoader(); - assert.equal(qlNew, qlFactory); + assert.equal(JSON.stringify(qlNew), JSON.stringify(qlFactory)); }); }); From b76a50428158b2550aaa15d63609bcac261d3528 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 14:18:03 +0200 Subject: [PATCH 40/58] change tests to correctly check --- test/tests.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/tests.js b/test/tests.js index 027c68d..4970991 100644 --- a/test/tests.js +++ b/test/tests.js @@ -239,7 +239,7 @@ describe('QueryLoader', function() { it('should create an overlay when called', function() { ql.createOverlay(); - assert.equal(ql.overlay instanceof Overlay, true); + assert.notEqual(ql.overlay, null); }); }); @@ -249,7 +249,7 @@ describe('QueryLoader', function() { it('should create the preloader', function() { ql.createPreloader(); - assert.equal(ql.preloader instanceof ImagePreloader, true); + assert.notEqual(ql.preloader, null); }); }); From 7b923a7b83e0b71bca180c1e4d0de6662a85a64c Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 14:18:46 +0200 Subject: [PATCH 41/58] build compiled --- queryloader2.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queryloader2.min.js b/queryloader2.min.js index 679a0b0..dd5cfcd 100644 --- a/queryloader2.min.js +++ b/queryloader2.min.js @@ -12,4 +12,4 @@ * Version: 3.0.16 * Last update: 2015-10-15 */ -!function e(t,i,n){function r(s,a){if(!i[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=i[s]={exports:{}};t[s][0].call(u.exports,function(e){var i=t[s][1][e];return r(i?i:e)},u,u.exports,e,t,i,n)}return i[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},i.prototype.urlIsNew=function(e){"use strict";return-1===this.sources.indexOf(e)},i.prototype.isIE=function(){"use strict";return navigator.userAgent.match(/msie/i)},i.prototype.isOpera=function(){"use strict";return navigator.userAgent.match(/Opera/i)},t.exports=i},{"./Image.js":1}],4:[function(e,t){"use strict";var i=e("./PercentageParser"),n={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=i(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(n);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var i=e("./PercentageParser"),n={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=i(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(n);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function i(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=i},{}],7:[function(e,t){"use strict";var i=e("./LoadingBar"),n=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=i(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=n(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),i=this,n=function(){},r=function(){return i.apply(this instanceof n&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,r.prototype=new n,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(i){if("object"!=typeof i)throw TypeError("Object prototype may only be an Object or null");e.prototype=i;var n=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(n[o]=r[o])}return n}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var i=e("./../ImagePreloader/index"),n=e("./../Overlay/index"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new n(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=i(this),console.log(this.options),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var i=e/t*100;this.overlay.updateProgress(i,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(i,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var i=Object.create(r);if(i.element=e,i.options={},i.done=!1,i.maxTimeout=null,i.overlay=null,i.preloader=null,null!==e){var n=function(){};i.init(t,{onComplete:n,onProgress:n,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return i}},{"./../ImagePreloader/index":3,"./../Overlay/index":7}],11:[function(e,t){e("./Polyfills");var i=e("./QueryLoader"),n=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,n()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file +!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n?n:e)},u,u.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},urlIsNew:function(e){return-1===this.sources.indexOf(e)},isIE:function(){return navigator.userAgent.match(/msie/i)},isOpera:function(){return navigator.userAgent.match(/Opera/i)}};t.exports=function(e){var t=Object.create(i);return t.parent=e,t.sources=[],t.images=[],t.loaded=0,t.deepSearch=!0,t}},{"./Image.js":1}],4:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=n(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=n(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function n(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=n},{}],7:[function(e,t){"use strict";var n=e("./LoadingBar"),i=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=n(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=i(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},r=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,r.prototype=new i,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(n){if("object"!=typeof n)throw TypeError("Object prototype may only be an Object or null");e.prototype=n;var i=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(i[o]=r[o])}return i}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var n=e("./../ImagePreloader"),i=e("./../Overlay"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new i(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=n(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var n=e/t*100;this.overlay.updateProgress(n,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(n,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var n=Object.create(r);if(n.element=e,n.options={},n.done=!1,n.maxTimeout=null,n.overlay=null,n.preloader=null,null!==e){var i=function(){};n.init(t,{onComplete:i,onProgress:i,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return n}},{"./../ImagePreloader":3,"./../Overlay":7}],11:[function(e,t){e("./Polyfills");var n=e("./QueryLoader"),i=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new n(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=n),"function"==typeof define&&define.amd&&define([],function(){"use strict";return n}),window.QueryLoader2=n,i()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file From d8ac65d48b663257c9539a36efbe2c996849dfcd Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 14:27:41 +0200 Subject: [PATCH 42/58] formatted gulp --- gulpfile.js | 132 +++++++++++++++++++++++++--------------------------- 1 file changed, 64 insertions(+), 68 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 381e6a4..ee38af4 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -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 + '/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})); + 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)); }); \ No newline at end of file From 8ea1ba6bf1736fa20e9d8a87154786c47a6802fd Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 14:32:19 +0200 Subject: [PATCH 43/58] update browser0sync --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f718a07..5b17b16 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "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", + "browser-sync": "^2.9.11", "browserify": "^4.2.3", "gulp": "^3.8.6", "gulp-header": "^1.0.5", From 54f1ed17f09dfef466dc429c3479d57e2f088f4f Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 14:57:48 +0200 Subject: [PATCH 44/58] update browserify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5b17b16..9dfbe0f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "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": "^2.9.11", - "browserify": "^4.2.3", + "browserify": "^11.2.0", "gulp": "^3.8.6", "gulp-header": "^1.0.5", "gulp-mocha-phantomjs": "^0.3.0", From b624030353000a589872ffa79d9a83d77149781f Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:01:19 +0200 Subject: [PATCH 45/58] update gulp --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dfbe0f..0c7ecd6 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dependencies": { "browser-sync": "^2.9.11", "browserify": "^11.2.0", - "gulp": "^3.8.6", + "gulp": "^3.9.0", "gulp-header": "^1.0.5", "gulp-mocha-phantomjs": "^0.3.0", "gulp-rename": "^1.2.0", From 56c05015691f71e1b0f4b9a91d0d6524915332f4 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:01:29 +0200 Subject: [PATCH 46/58] remove new from bootstrap --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 0f98075..bd67839 100644 --- a/src/index.js +++ b/src/index.js @@ -8,7 +8,7 @@ if (window.jQuery || window.Zepto) { 'use strict'; $.fn.queryLoader2 = function(options){ return this.each(function() { - (new QueryLoader2(this, options)); + (QueryLoader2(this, options)); }); }; })(window.jQuery || window.Zepto); From 80b88960607ad81c89e58109362ab56e5a252f75 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:03:01 +0200 Subject: [PATCH 47/58] new build --- queryloader2.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/queryloader2.min.js b/queryloader2.min.js index dd5cfcd..b8de731 100644 --- a/queryloader2.min.js +++ b/queryloader2.min.js @@ -12,4 +12,4 @@ * Version: 3.0.16 * Last update: 2015-10-15 */ -!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var u=n[s]={exports:{}};t[s][0].call(u.exports,function(e){var n=t[s][1][e];return r(n?n:e)},u,u.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},urlIsNew:function(e){return-1===this.sources.indexOf(e)},isIE:function(){return navigator.userAgent.match(/msie/i)},isOpera:function(){return navigator.userAgent.match(/Opera/i)}};t.exports=function(e){var t=Object.create(i);return t.parent=e,t.sources=[],t.images=[],t.loaded=0,t.deepSearch=!0,t}},{"./Image.js":1}],4:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=n(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=n(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function n(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=n},{}],7:[function(e,t){"use strict";var n=e("./LoadingBar"),i=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=n(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=i(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},r=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,r.prototype=new i,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(n){if("object"!=typeof n)throw TypeError("Object prototype may only be an Object or null");e.prototype=n;var i=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(i[o]=r[o])}return i}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var n=e("./../ImagePreloader"),i=e("./../Overlay"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new i(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=n(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var n=e/t*100;this.overlay.updateProgress(n,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(n,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var n=Object.create(r);if(n.element=e,n.options={},n.done=!1,n.maxTimeout=null,n.overlay=null,n.preloader=null,null!==e){var i=function(){};n.init(t,{onComplete:i,onProgress:i,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return n}},{"./../ImagePreloader":3,"./../Overlay":7}],11:[function(e,t){e("./Polyfills");var n=e("./QueryLoader"),i=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){new n(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=n),"function"==typeof define&&define.amd&&define([],function(){"use strict";return n}),window.QueryLoader2=n,i()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file +!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return r(n?n:e)},c,c.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},urlIsNew:function(e){return-1===this.sources.indexOf(e)},isIE:function(){return navigator.userAgent.match(/msie/i)},isOpera:function(){return navigator.userAgent.match(/Opera/i)}};t.exports=function(e){var t=Object.create(i);return t.parent=e,t.sources=[],t.images=[],t.loaded=0,t.deepSearch=!0,t}},{"./Image.js":1}],4:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=n(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=n(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function n(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=n},{}],7:[function(e,t){"use strict";var n=e("./LoadingBar"),i=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=n(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=i(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},r=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,r.prototype=new i,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(n){if("object"!=typeof n)throw TypeError("Object prototype may only be an Object or null");e.prototype=n;var i=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(i[o]=r[o])}return i}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var n=e("./../ImagePreloader"),i=e("./../Overlay"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new i(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=n(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var n=e/t*100;this.overlay.updateProgress(n,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(n,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var n=Object.create(r);if(n.element=e,n.options={},n.done=!1,n.maxTimeout=null,n.overlay=null,n.preloader=null,null!==e){var i=function(){};n.init(t,{onComplete:i,onProgress:i,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return n}},{"./../ImagePreloader":3,"./../Overlay":7}],11:[function(e,t){e("./Polyfills");var n=e("./QueryLoader"),i=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){n(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=n),"function"==typeof define&&define.amd&&define([],function(){"use strict";return n}),window.QueryLoader2=n,i()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file From f31b4ea68cf72475d9fcd5f8d0a91df21c3583db Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:10:30 +0200 Subject: [PATCH 48/58] rename Image --- package.json | 16 ++++++++-------- src/ImagePreloader/Image.js | 4 ++-- src/ImagePreloader/index.js | 4 ++-- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 0c7ecd6..2c839e6 100644 --- a/package.json +++ b/package.json @@ -7,14 +7,14 @@ "browser-sync": "^2.9.11", "browserify": "^11.2.0", "gulp": "^3.9.0", - "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" + "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", + "mocha": "^2.3.3", + "mocha-phantomjs": "^4.0.1", + "vinyl-source-stream": "^1.1.0" }, "repository": { "type": "git", diff --git a/src/ImagePreloader/Image.js b/src/ImagePreloader/Image.js index 5d37293..28d0d2e 100644 --- a/src/ImagePreloader/Image.js +++ b/src/ImagePreloader/Image.js @@ -1,7 +1,7 @@ 'use strict'; var ImageLoaded = require('./ImageLoaded.js'); -var Image = { +var QueryLoaderImage = { create: function() { this.element = document.createElement('img'); this.element.setAttribute('src', this.src); @@ -15,7 +15,7 @@ var Image = { }; module.exports = function(src) { - var image = Object.create(Image); + var image = Object.create(QueryLoaderImage); image.src = src; image.element = null; diff --git a/src/ImagePreloader/index.js b/src/ImagePreloader/index.js index 96cc368..fc59244 100644 --- a/src/ImagePreloader/index.js +++ b/src/ImagePreloader/index.js @@ -1,5 +1,5 @@ 'use strict'; -var Image = require('./Image.js'); +var QueryLoaderImage = require('./Image.js'); var ImagePreloader = { getImageSrcs: function(element) { @@ -29,7 +29,7 @@ var ImagePreloader = { this.sources = this.getImageSrcs(element); for (var i = 0; i < this.sources.length; i++) { - var image = new Image(this.sources[i]); + var image = QueryLoaderImage(this.sources[i]); image.preload(this.imageLoaded.bind(this)); this.images.push(image); } From c560de65e1efda991feb5ed640842d1e2fa570f6 Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:11:05 +0200 Subject: [PATCH 49/58] remove new from Create overlay --- src/QueryLoader/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/QueryLoader/index.js b/src/QueryLoader/index.js index 0ab3c82..dde2f20 100644 --- a/src/QueryLoader/index.js +++ b/src/QueryLoader/index.js @@ -33,7 +33,7 @@ var QueryLoader = { }, createOverlay: function() { - this.overlay = new Overlay(this.element); + this.overlay = Overlay(this.element); this.overlay.idName = this.options.overlayId; this.overlay.percentageId = this.options.percentageId; this.overlay.backgroundColor = this.options.backgroundColor; From 05dbee9bcce9cc6cfdbd0d5ada44c2c5cfa6318e Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:13:19 +0200 Subject: [PATCH 50/58] version bump --- bower.json | 2 +- package.json | 2 +- queryloader2.min.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index ed0a6a3..b584753 100644 --- a/bower.json +++ b/bower.json @@ -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 " diff --git a/package.json b/package.json index 2c839e6..68b34d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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": { diff --git a/queryloader2.min.js b/queryloader2.min.js index b8de731..86c8b9c 100644 --- a/queryloader2.min.js +++ b/queryloader2.min.js @@ -9,7 +9,7 @@ * Licensed under the MIT license: * http://www.opensource.org/licenses/mit-license.php * - * Version: 3.0.16 + * Version: 3.1.0 * Last update: 2015-10-15 */ -!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return r(n?n:e)},c,c.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},urlIsNew:function(e){return-1===this.sources.indexOf(e)},isIE:function(){return navigator.userAgent.match(/msie/i)},isOpera:function(){return navigator.userAgent.match(/Opera/i)}};t.exports=function(e){var t=Object.create(i);return t.parent=e,t.sources=[],t.images=[],t.loaded=0,t.deepSearch=!0,t}},{"./Image.js":1}],4:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=n(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t){"use strict";var n=e("./PercentageParser"),i={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e){e=n(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(i);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t){"use strict";function n(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=n},{}],7:[function(e,t){"use strict";var n=e("./LoadingBar"),i=e("./Percentage"),r={init:function(){this.create(),this.loadingBar=n(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=i(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(r);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},r=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,r.prototype=new i,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(n){if("object"!=typeof n)throw TypeError("Object prototype may only be an Object or null");e.prototype=n;var i=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(i[o]=r[o])}return i}}())},{}],9:[function(e,t){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t){"use strict";var n=e("./../ImagePreloader"),i=e("./../Overlay"),r={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=new i(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=n(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var n=e/t*100;this.overlay.updateProgress(n,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(n,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var n=Object.create(r);if(n.element=e,n.options={},n.done=!1,n.maxTimeout=null,n.overlay=null,n.preloader=null,null!==e){var i=function(){};n.init(t,{onComplete:i,onProgress:i,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return n}},{"./../ImagePreloader":3,"./../Overlay":7}],11:[function(e,t){e("./Polyfills");var n=e("./QueryLoader"),i=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){n(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=n),"function"==typeof define&&define.amd&&define([],function(){"use strict";return n}),window.QueryLoader2=n,i()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file +!function e(t,n,i){function r(s,a){if(!n[s]){if(!t[s]){var l="function"==typeof require&&require;if(!a&&l)return l(s,!0);if(o)return o(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return r(n?n:e)},c,c.exports,e,t,n,i)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s0&&!e.match(/^(data:)/i)?!0:!1},urlIsNew:function(e){return-1===this.sources.indexOf(e)},isIE:function(){return navigator.userAgent.match(/msie/i)},isOpera:function(){return navigator.userAgent.match(/Opera/i)}};t.exports=function(e){var t=Object.create(r);return t.parent=e,t.sources=[],t.images=[],t.loaded=0,t.deepSearch=!0,t}},{"./Image.js":1}],4:[function(e,t,n){"use strict";var i=e("./PercentageParser"),r={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.setStyling(),this.updateProgress(0,0)},setStyling:function(){this.element.style.height=this.barHeight+"px",this.element.style.marginTop="-"+this.barHeight/2+"px",this.element.style.backgroundColor=this.barColor,this.element.style.position="absolute",this.element.style.top="50%",this.setTransitionTime(100)},updateProgress:function(e,t){0!==t&&this.setTransitionTime(t),e=i(e),this.element.style.width=e+"%"},setTransitionTime:function(e){this.element.style.WebkitTransition="width "+e+"ms",this.element.style.MozTransition="width "+e+"ms",this.element.style.OTransition="width "+e+"ms",this.element.style.MsTransition="width "+e+"ms",this.element.style.Transition="width "+e+"ms"}};t.exports=function(){var e=Object.create(r);return e.element=null,e.className="queryloader__overlay__bar",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],5:[function(e,t,n){"use strict";var i=e("./PercentageParser"),r={create:function(){this.element=document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling(),this.updateProgress(0,0)},applyStyling:function(){this.element.style.height="40px",this.element.style.width="100%",this.element.style.position="absolute",this.element.style.fontSize="3em",this.element.style.top="50%",this.element.style.left="0",this.element.style.marginTop="-"+(59+this.barHeight)+"px",this.element.style.textAlign="center",this.element.style.color=this.barColor},updateProgress:function(e,t){e=i(e),this.element.innerHTML=e+"%"}};t.exports=function(){var e=Object.create(r);return e.element=null,e.idName="qlPercentage",e.className="queryloader__overlay__percentage",e.barHeight=1,e.barColor="#fff",e}},{"./PercentageParser":6}],6:[function(e,t,n){"use strict";function i(e){return parseInt(e)<0?0:parseInt(e)>100?100:parseInt(e)}t.exports=i},{}],7:[function(e,t,n){"use strict";var i=e("./LoadingBar"),r=e("./Percentage"),o={init:function(){this.create(),this.loadingBar=i(),this.loadingBar.barHeight=this.barHeight,this.loadingBar.barColor=this.barColor,this.loadingBar.create(),this.element.appendChild(this.loadingBar.element),this.showPercentage&&(this.percentage=r(),this.percentage.barColor=this.barColor,this.percentage.idName=this.percentageId,this.percentage.create(),this.element.appendChild(this.percentage.element)),this.parentElement.appendChild(this.element)},create:function(){this.element=document.querySelector("#"+this.idName)||document.createElement("div"),this.element.setAttribute("class",this.className),this.element.setAttribute("id",this.idName),this.applyStyling()},applyStyling:function(){this.element.style.position=this.calculatePosition(),this.element.style.width="100%",this.element.style.height="100%",this.element.style.backgroundColor=this.backgroundColor,this.element.style.backgroundPosition="fixed",this.element.style.zIndex=666999,this.element.style.top="0",this.element.style.left="0",this.element.style.WebkitTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MozTransition="opacity "+this.fadeOutTime+"ms",this.element.style.OTransition="opacity "+this.fadeOutTime+"ms",this.element.style.MsTransition="opacity "+this.fadeOutTime+"ms",this.element.style.Transition="opacity "+this.fadeOutTime+"ms"},calculatePosition:function(){var e="absolute";return"body"===this.parentElement.tagName.toLowerCase()?e="fixed":("fixed"!==this.parentElement.style.position||"absolute"!==this.parentElement.style.position)&&(this.parentElement.style.position="relative"),e},updateProgress:function(e,t){null!==this.loadingBar&&this.loadingBar.updateProgress(e,t),null!==this.percentage&&this.percentage.updateProgress(e,t)},remove:function(){this.canRemove(this.element)&&this.element.parentNode.removeChild(this.element)},canRemove:function(e){return e.parentNode&&"undefined"!=typeof e.parentNode.removeChild}};t.exports=function(e){var t=Object.create(o);return t.parentElement=e,t.idName="qLoverlay",t.percentageId="qlPercentage",t.className="queryloader__overlay",t.element=null,t.loadingBar=null,t.percentage=null,t.barColor="#ff0000",t.backgroundColor="#000",t.barHeight=1,t.fadeOutTime=300,t.showPercentage=!1,t}},{"./LoadingBar":4,"./Percentage":5}],8:[function(e,t,n){Function.prototype.bind||(Function.prototype.bind=function(e){"use strict";if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var t=Array.prototype.slice.call(arguments,1),n=this,i=function(){},r=function(){return n.apply(this instanceof i&&e?this:e,t.concat(Array.prototype.slice.call(arguments)))};return i.prototype=this.prototype,r.prototype=new i,r}),"function"!=typeof Object.create&&(Object.create=function(){function e(){}var t=Object.prototype.hasOwnProperty;return function(n){if("object"!=typeof n)throw TypeError("Object prototype may only be an Object or null");e.prototype=n;var i=new e;if(e.prototype=null,arguments.length>1){var r=Object(arguments[1]);for(var o in r)t.call(r,o)&&(i[o]=r[o])}return i}}())},{}],9:[function(e,t,n){"use strict";t.exports=function(){var e=window.setInterval(function(){if("undefined"!=typeof document.getElementsByTagName("body")[0]){var t=document.createElement("div");t.style.position="fixed",t.style.width="100%",t.style.height="100%",t.style.zIndex="9999",t.style.backgroundColor="#000",t.style.left="0",t.style.top="0",t.setAttribute("id","qLtempOverlay"),document.getElementsByTagName("body")[0].appendChild(t),window.clearInterval(e)}},1)}},{}],10:[function(e,t,n){"use strict";var i=e("./../ImagePreloader"),r=e("./../Overlay"),o={init:function(e,t){this.options=this.extend(t,e),"undefined"!=typeof this.element&&(this.createOverlay(),this.removeTempOverlay(),this.createPreloader(),this.startMaxTimeout())},extend:function(e,t){"undefined"==typeof e&&(e={});for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},startMaxTimeout:function(){this.maxTimeout=window.setTimeout(this.doneLoading.bind(this),this.options.maxTime)},createOverlay:function(){this.overlay=r(this.element),this.overlay.idName=this.options.overlayId,this.overlay.percentageId=this.options.percentageId,this.overlay.backgroundColor=this.options.backgroundColor,this.overlay.barHeight=this.options.barHeight,this.overlay.barColor=this.options.barColor,this.overlay.showPercentage=this.options.percentage,this.overlay.fadeOutTime=this.options.fadeOutTime,"undefined"!=typeof this.element&&this.overlay.init()},removeTempOverlay:function(){window.setTimeout(function(){var e=document.getElementById("qLtempOverlay");e&&e.parentNode&&e.parentNode.removeChild(e)},0)},createPreloader:function(){this.preloader=i(this),this.preloader.deepSearch=this.options.deepSearch,window.setTimeout(function(){this.preloader.findAndPreload(this.element)}.bind(this),100)},updateProgress:function(e,t){var n=e/t*100;this.overlay.updateProgress(n,this.options.minimumTime),"function"==typeof this.options.onProgress&&this.options.onProgress(n,e,t),e===t&&this.done===!1&&(window.clearTimeout(this.maxTimeout),window.setTimeout(this.doneLoading.bind(this),this.options.minimumTime))},doneLoading:function(){window.clearTimeout(this.maxTimeout),this.done=!0,this.overlay.element.style.opacity=0,window.setTimeout(this.destroy.bind(this),this.options.fadeOutTime)},destroy:function(){this.overlay.remove(),this.options.onComplete()}};t.exports=function(e,t){var n=Object.create(o);if(n.element=e,n.options={},n.done=!1,n.maxTimeout=null,n.overlay=null,n.preloader=null,null!==e){var i=function(){};n.init(t,{onComplete:i,onProgress:i,backgroundColor:"#000",barColor:"#fff",overlayId:"qLoverlay",percentageId:"qLpercentage",barHeight:1,percentage:!1,deepSearch:!0,minimumTime:300,maxTime:1e4,fadeOutTime:1e3})}return n}},{"./../ImagePreloader":3,"./../Overlay":7}],11:[function(e,t,n){e("./Polyfills");var i=e("./QueryLoader"),r=e("./QueryLoader/TempOverlay");(window.jQuery||window.Zepto)&&!function(e){"use strict";e.fn.queryLoader2=function(e){return this.each(function(){i(this,e)})}}(window.jQuery||window.Zepto),"undefined"!=typeof t&&(t.exports=i),"function"==typeof define&&define.amd&&define([],function(){"use strict";return i}),window.QueryLoader2=i,r()},{"./Polyfills":8,"./QueryLoader":10,"./QueryLoader/TempOverlay":9}]},{},[11]); \ No newline at end of file From 6674504ce9050469dc278928d700b4d3dff6e49c Mon Sep 17 00:00:00 2001 From: Gaya Kessler Date: Thu, 15 Oct 2015 15:17:26 +0200 Subject: [PATCH 51/58] fix jquery file including --- test/browser/jquery-test.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/browser/jquery-test.html b/test/browser/jquery-test.html index 1a09b02..699ea77 100644 --- a/test/browser/jquery-test.html +++ b/test/browser/jquery-test.html @@ -5,10 +5,10 @@ - + - + + - +