Cleanup & travis (should break)

This commit is contained in:
Maxime Thirouin
2014-10-14 11:42:36 +02:00
parent 332cd4e876
commit 3bc67f245c
16 changed files with 104 additions and 101 deletions

View File

@@ -1,3 +1,5 @@
/* global HTMLCollection: true */
module.exports = function(els, fn, context) {
if (els instanceof HTMLCollection || els instanceof NodeList || els instanceof Array) {
return Array.prototype.forEach.call(els, fn, context)

View File

@@ -1,19 +1,19 @@
if (!Function.prototype.bind) {
Function.prototype.bind = function (oThis) {
Function.prototype.bind = function(oThis) {
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)
var fToBind = this
var fNOP = function () {}
var fBound = function () {
return fToBind.apply(this instanceof fNOP && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
var that = this
var Fnoop = function() {}
var fBound = function() {
return that.apply(this instanceof Fnoop && oThis ? this : oThis, aArgs.concat(Array.prototype.slice.call(arguments)))
}
fNOP.prototype = this.prototype
fBound.prototype = new fNOP()
Fnoop.prototype = this.prototype
fBound.prototype = new Fnoop()
return fBound
}

View File

@@ -54,23 +54,21 @@ var linkAction = function(el, event) {
}
module.exports = function(el) {
var instance = this
var that = this
on(el, "click", function(event) {
linkAction.call(instance, el, event)
linkAction.call(that, el, event)
})
on(el, "keyup", function(event) {
// Dont break browser special behavior on links (like page in new window)
if (event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
el.setAttribute(attrKey, "modifier")
return
}
if(event.keyCode == 13) {
linkAction.call(instance, el, event)
if (event.keyCode == 13) {
linkAction.call(that, el, event)
}
}.bind(this))
}

View File

@@ -3,5 +3,5 @@ var forEachEls = require("../foreach-els")
var parseElement = require("../parse-element")
module.exports = function(el) {
forEachEls(this.getElements(el), parseElement }, this)
forEachEls(this.getElements(el), parseElement, this)
}

View File

@@ -12,7 +12,7 @@ module.exports = function(location, callback) {
}
}
request.open("GET", location + (!/[?&]/.test(location) ? "?": "&") + (new Date().getTime()), true)
request.open("GET", location + (!/[?&]/.test(location) ? "?" : "&") + (new Date().getTime()), true)
request.setRequestHeader("X-Requested-With", "XMLHttpRequest")
request.send(null)
return request

View File

@@ -1,10 +1,15 @@
var on = require("./lib/events/on.js")
// var off = require("./lib/events/on.js")
// var trigger = require("./lib/events/trigger.js")
module.exports = {
outerHTML: function(oldEl, newEl, options) {
outerHTML: function(oldEl, newEl) {
oldEl.outerHTML = newEl.outerHTML
this.onSwitch()
},
innerHTML: function(oldEl, newEl, options) {
innerHTML: function(oldEl, newEl) {
oldEl.innerHTML = newEl.innerHTML
oldEl.className = newEl.className
this.onSwitch()
@@ -17,7 +22,7 @@ module.exports = {
var fragToAppend = document.createDocumentFragment()
// height transition are shitty on safari
// so commented for now (until I found something ?)
//var relevantHeight = 0
// var relevantHeight = 0
var animationEventNames = "animationend webkitAnimationEnd MSAnimationEnd oanimationend"
var animatedElsNumber = 0
var sexyAnimationEnd = function(e) {
@@ -50,7 +55,7 @@ module.exports = {
// this is to trigger some repaint (example: picturefill)
this.onSwitch()
//Pjax.trigger(window, "scroll")
// Pjax.trigger(window, "scroll")
}
}.bind(this)
@@ -79,7 +84,7 @@ module.exports = {
el.className += " " + switchOptions.classNames.remove + " " + (options.backward ? switchOptions.classNames.backward : switchOptions.classNames.forward)
}
animatedElsNumber++
Pjax.on(el, animationEventNames, sexyAnimationEnd, true)
on(el, animationEventNames, sexyAnimationEnd, true)
}
})
@@ -97,7 +102,7 @@ module.exports = {
elsToAdd.push(el)
fragToAppend.appendChild(el)
animatedElsNumber++
Pjax.on(el, animationEventNames, sexyAnimationEnd, true)
on(el, animationEventNames, sexyAnimationEnd, true)
}
})