New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

paged

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

paged - npm Package Compare versions

Comparing version
0.0.3
to
0.0.4
+1
-1
package.json
{
"name": "paged",
"version": "0.0.3",
"version": "0.0.4",
"description": "A paged/tabbed module for the browser",

@@ -5,0 +5,0 @@ "main": "paged.js",

@@ -16,2 +16,3 @@ module.exports = Paged

this.transitionSpeed = nofx ? 0 : 150
this.loop = true
}

@@ -44,2 +45,5 @@

// Do no work on invalid input
if (index < 0 || index >= this.sections.length) return
this.emit('change', index)

@@ -54,3 +58,3 @@

if (!nofx) {
if (this.transitionSpeed > 0 && !nofx) {

@@ -84,2 +88,32 @@ this.sections.not(section)

/*
* Convenience method for moving to the next section.
* Adds loop functionality if `this.loop` is true.
*/
Paged.prototype.next = function () {
if (this.current === this.sections.length - 1) {
if (this.loop) {
return this.goTo(0)
} else {
return
}
}
return this.goTo(this.current + 1)
}
/*
* Convenience method for moving to the previous section.
* Adds loop functionality if `this.loop` is true.
*/
Paged.prototype.prev = function () {
if (this.current === 0) {
if (this.loop) {
return this.goTo(this.sections.length - 1)
} else {
return
}
}
return this.goTo(this.current - 1)
}
/*
* Reset the viewport height

@@ -86,0 +120,0 @@ */

@@ -7,3 +7,3 @@ require('./test-env')

describe('modal', function () {
describe('paged', function () {

@@ -86,7 +86,89 @@ afterEach(function () {

})
paged.goTo(2, true)
})
it('should do no work on invalid input', function () {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.init()
paged.on('change', function (i) {
assert(false)
})
paged.goTo(10, true)
paged.goTo(-21, true)
paged.goTo(3, true)
})
})
describe('next()', function () {
it('should go to the next page', function (done) {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.init()
paged.on('change', function (i) {
assert.equal(i, 1)
done()
})
paged.next()
})
it('should loop back to the start if the loop option is set', function (done) {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.loop = true
paged.init()
paged.goTo(paged.sections.length - 1)
paged.on('change', function (i) {
assert.equal(i, 0)
done()
})
paged.next()
})
it('should not loop if loop options is set to false', function () {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.loop = false
paged.init()
paged.goTo(paged.sections.length - 1)
paged.on('change', function (i) {
assert(false)
})
paged.next()
})
})
describe('prev()', function () {
it('should go to the previous page', function (done) {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.init()
paged.goTo(2)
paged.on('change', function (i) {
assert.equal(i, 1)
done()
})
paged.prev()
})
it('should loop back to the end if the loop option is set', function (done) {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.loop = true
paged.init()
paged.on('change', function (i) {
assert.equal(i, paged.sections.length - 1)
done()
})
paged.prev()
})
it('should not loop if loop option is set to false', function () {
var paged = new Paged($('.js-tabbed-widget'), $('.js-tabs').children(), true)
paged.loop = false
paged.init()
paged.on('change', function (i) {
assert(false)
})
paged.prev()
})
})
})