New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

jquery.page-it

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery.page-it - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

95

jquery.page-it.js

@@ -1,2 +0,2 @@

(function($, window, document, undefined) {
(function ($, window, document, undefined) {

@@ -6,12 +6,12 @@ var pluginName = 'pageIt';

var logger = {
log: function() {
log: function () {
console.log(pluginName + ': ' + arguments[0], Array.prototype.slice.call(arguments, 1));
},
info: function() {
info: function () {
console.info(pluginName + ': ' + arguments[0], Array.prototype.slice.call(arguments, 1));
},
warn: function() {
warn: function () {
console.warn(pluginName + ': ' + arguments[0], Array.prototype.slice.call(arguments, 1));
},
error: function() {
error: function () {
console.error(pluginName + ': ' + arguments[0], Array.prototype.slice.call(arguments, 1));

@@ -39,5 +39,5 @@ },

/**
* @var {int?} The page where the plugin should start.
* @var {bool} If should auto start loading the current page or not.
*/
initPage: null,
autoStart: false,
/**

@@ -47,4 +47,4 @@ * @var {bool} cache : if should store loaded pages (and load'em from) in a local storage or not

cache: true,
url: '',
method: 'get',
url: '', // @TODO: move it inside ajax key
method: 'get', // @TODO: move it inside ajax key
dataType: 'json',

@@ -95,6 +95,7 @@ /**

this.meta = this.settings.meta;
this.meta.prev = this.settings.initPage - 1;
this.meta.current = this.settings.initPage;
this.meta.next = this.settings.initPage + 1;
if (this.meta.current) {
this.setCurrent(this.meta.current);
}
this.requestData = {};

@@ -111,8 +112,8 @@

**/
init: function() {
init: function () {
this.trigger('ready');
if (!!this.settings.initPage)
this.to(this.settings.initPage);
if (!!this.settings.autoStart)
this.to(this.meta.current);
},

@@ -123,3 +124,3 @@

**/
to: function(pageIndex) {
to: function (pageIndex) {

@@ -149,4 +150,3 @@ if (this.requesting === true) {

*/
this.requestData = {};
this.requestData.pageIndex = pageIndex;
this.requestData = { pageIndex: pageIndex };

@@ -167,3 +167,3 @@ // user can moddify the requestData here, before the AJAX call.

dataType: this.settings.dataType,
success: function(data, status, response) {
success: function (data, status, response) {

@@ -179,5 +179,3 @@ /*

that.meta.prev = pageIndex - 1;
that.meta.current = pageIndex;
that.meta.next = pageIndex + 1;
that.setCurrent(pageIndex);

@@ -201,3 +199,3 @@ if (data.meta) {

},
error: function(response) {
error: function (response) {
logger.error('Erro ao carregar página.');

@@ -208,3 +206,3 @@ console.log(response);

},
complete: function(response) {
complete: function (response) {

@@ -262,3 +260,3 @@ that.requesting = false;

**/
first: function() {
first: function () {
this.trigger('page.first', this.meta.first);

@@ -271,3 +269,3 @@ return this.to(this.meta.first);

**/
prev: function() {
prev: function () {
this.trigger('page.prev', this.meta.next);

@@ -280,3 +278,3 @@ return this.to(this.meta.prev);

**/
next: function() {
next: function () {
this.trigger('page.next', this.meta.next);

@@ -289,3 +287,3 @@ return this.to(this.meta.next);

**/
last: function() {
last: function () {
this.trigger('page.last', this.meta.last);

@@ -301,6 +299,6 @@ return this.to(this.meta.last);

**/
on: function(eventName, fn) {
on: function (eventName, fn) {
if (eventName.match(' ')) {
eventname.split(' ').forEach(function(eventName) {
eventname.split(' ').forEach(function (eventName) {
this.on(eventName, fn);

@@ -322,2 +320,27 @@ });

/**
* Removes callbacks for the received event name.
* @param {string} eventName
* @param {function} fn
* @return {object}
**/
off: function (eventName, fn) {
if (eventName.match(' ')) {
eventname.split(' ').forEach(function (eventName) {
this.off(eventName, fn);
});
} else {
if (!this.events[eventName]) {
logger.warn('Evento indisponível.');
throw new Error('Can\'t remove unrecognized event handler.');
}
this.events[eventName] = [];
}
return this;
},
/**
* Event handler, can call any registered event.

@@ -328,3 +351,3 @@ * @param {string} eventName

**/
trigger: function(eventName) {
trigger: function (eventName) {

@@ -336,3 +359,3 @@ if (this.events[eventName] && this.events[eventName].length) {

this.events[eventName].map(function(fnName) {
this.events[eventName].map(function (fnName) {

@@ -348,5 +371,11 @@ fnName.apply(that, Array.prototype.slice.call(args, 1)); // Array.prototype.slice will convert the arguments object

setMeta: function(meta) {
setMeta: function (meta) {
// meta is not multilevel
$.extend(this.meta, meta);
},
setCurrent: function (current) {
this.meta.current = current;
this.meta.prev = current - 1;
this.meta.next = current + 1;
}

@@ -353,0 +382,0 @@

@@ -1,8 +0,1 @@

(function(d,f,h,k){var e={log:function(){console.log("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},info:function(){console.info("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},warn:function(){console.warn("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},error:function(){console.error("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))}};if(!d)return e.error("N\u00e3o foi poss\u00edvel reconhecer o jQuery, inicializa\u00e7\u00e3o cancelada!"),
!1;var g={initPage:null,cache:!0,url:"",method:"get",dataType:"json",ajax:{cache:!1,global:!0},contentView:null,meta:{size:null,first:1,prev:null,current:null,next:null,last:null,total:null}};f.pageIt=function(a){this.settings=d.extend(!0,{},g,a);this.events={ready:[],"page.load.empty":[],"page.load.loaded":[],"page.load.autoupdated":[],"page.load.skipped":[],"page.load.first":[],"page.load.last":[],"page.load.error":[],"page.load.before":[],"page.load.after":[],"page.load.cache":[],"page.filled":[],
"page.first":[],"page.prev":[],"page.next":[],"page.last":[]};this.pages=[];this.requesting=!1;this.meta=this.settings.meta;this.meta.prev=this.settings.initPage-1;this.meta.current=this.settings.initPage;this.meta.next=this.settings.initPage+1;this.requestData={};return this.init()};d.extend(f.pageIt.prototype,{init:function(){this.trigger("ready");this.settings.initPage&&this.to(this.settings.initPage)},to:function(a){if(!0===this.requesting)return e.warn("Uma requisi\u00e7\u00e3o de p\u00e1gina j\u00e1 est\u00e1 em andamento, esta requisi\u00e7\u00e3o ser\u00e1 ignorada."),
!1;if(!a||this.meta.last&&a>this.meta.last)return this.trigger("page.load.skipped",{}),this.trigger("page.load.last",{}),!1;if("string"===typeof a&&"next"===a||"prev"===a)return this[a]();if(this.settings.cache&&this.pages[a])this.pages[a].content?(this.fillContainer(this.pages[a].content),this.trigger("page.load.loaded",this.pages[a]),this.trigger("page.load.cache",this.pages[a])):this.trigger("page.load.empty",this.pages[a]);else{this.requestData={};this.requestData.pageIndex=a;this.trigger("page.load.before",
this.requestData);var b=this;this.requesting=!0;d.ajax({cache:this.settings.ajax.cache,global:this.settings.ajax.global,url:this.settings.url,method:this.settings.method,data:this.requestData,dataType:this.settings.dataType,success:function(c,d,e){b.pages[a]=c.content;b.meta.prev=a-1;b.meta.current=a;b.meta.next=a+1;c.meta&&b.setMeta(c.meta);c.content?(b.trigger("page.load.loaded",c),b.fillContainer(c.content)):b.trigger("page.load.empty",c)},error:function(a){e.error("Erro ao carregar p\u00e1gina.");
console.log(a);b.trigger("page.load.error",a)},complete:function(a){b.requesting=!1;b.trigger("page.load.after",a);console.groupEnd()}})}return this},fillContainer:function(a){this.settings.contentView?d(this.settings.contentView).html(a.content)&&this.trigger("page.load.autoupdated",a):e.warn("No container set, no data will be auto inserted.")},first:function(){this.trigger("page.first",this.meta.first);return this.to(this.meta.first)},prev:function(){this.trigger("page.prev",this.meta.next);return this.to(this.meta.prev)},
next:function(){this.trigger("page.next",this.meta.next);return this.to(this.meta.next)},last:function(){this.trigger("page.last",this.meta.last);return this.to(this.meta.last)},on:function(a,b){if(a.match(" "))eventname.split(" ").forEach(function(a){this.on(a,b)});else{if(!this.events[a])throw e.warn("Evento indispon\u00edvel."),Error("Can't attach unrecognized event handler.");this.events[a].push(b)}return this},trigger:function(a){if(this.events[a]&&this.events[a].length){var b=this,c=arguments;
this.events[a].map(function(a){a.apply(b,Array.prototype.slice.call(c,1))})}return this},setMeta:function(a){d.extend(this.meta,a)}});return f.pageIt})(window.jQuery||!1,window,document);
!function(t,e,a,i){var n={log:function(){console.log("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},info:function(){console.info("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},warn:function(){console.warn("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))},error:function(){console.error("pageIt: "+arguments[0],Array.prototype.slice.call(arguments,1))}};if(!t)return n.error("Não foi possível reconhecer o jQuery, inicialização cancelada!"),!1;var r={size:null,first:1,prev:null,current:null,next:null,last:null,total:null},s={autoStart:!1,cache:!0,url:"",method:"get",dataType:"json",ajax:{cache:!1,global:!0},contentView:null,meta:r};e.pageIt=function(e){return this.settings=t.extend(!0,{},s,e),this.events={ready:[],"page.load.empty":[],"page.load.loaded":[],"page.load.autoupdated":[],"page.load.skipped":[],"page.load.first":[],"page.load.last":[],"page.load.error":[],"page.load.before":[],"page.load.after":[],"page.load.cache":[],"page.filled":[],"page.first":[],"page.prev":[],"page.next":[],"page.last":[]},this.pages=[],this.requesting=!1,this.meta=this.settings.meta,this.meta.current&&this.setCurrent(this.meta.current),this.requestData={},this.init()},t.extend(e.pageIt.prototype,{init:function(){this.trigger("ready"),this.settings.autoStart&&this.to(this.meta.current)},to:function(e){if(!0===this.requesting)return n.warn("Uma requisição de página já está em andamento, esta requisição será ignorada."),!1;if(!e||this.meta.last&&e>this.meta.last)return this.trigger("page.load.skipped",{}),this.trigger("page.load.last",{}),!1;if("string"==typeof e&&"next"===e||"prev"===e)return this[e]();if(this.settings.cache&&this.pages[e])this.pages[e].content?(this.fillContainer(this.pages[e].content),this.trigger("page.load.loaded",this.pages[e]),this.trigger("page.load.cache",this.pages[e])):this.trigger("page.load.empty",this.pages[e]);else{this.requestData={pageIndex:e},this.trigger("page.load.before",this.requestData);var a=this;this.requesting=!0,t.ajax({cache:this.settings.ajax.cache,global:this.settings.ajax.global,url:this.settings.url,method:this.settings.method,data:this.requestData,dataType:this.settings.dataType,success:function(t,i,n){a.pages[e]=t.content,a.setCurrent(e),t.meta&&a.setMeta(t.meta),t.content?(a.trigger("page.load.loaded",t),a.fillContainer(t.content)):a.trigger("page.load.empty",t)},error:function(t){n.error("Erro ao carregar página."),console.log(t),a.trigger("page.load.error",t)},complete:function(t){a.requesting=!1,a.trigger("page.load.after",t),console.groupEnd()}})}return this},fillContainer:function(e){this.settings.contentView?t(this.settings.contentView).html(e.content)&&this.trigger("page.load.autoupdated",e):n.warn("No container set, no data will be auto inserted.")},first:function(){return this.trigger("page.first",this.meta.first),this.to(this.meta.first)},prev:function(){return this.trigger("page.prev",this.meta.next),this.to(this.meta.prev)},next:function(){return this.trigger("page.next",this.meta.next),this.to(this.meta.next)},last:function(){return this.trigger("page.last",this.meta.last),this.to(this.meta.last)},on:function(t,e){if(t.match(" "))eventname.split(" ").forEach(function(t){this.on(t,e)});else{if(!this.events[t])throw n.warn("Evento indisponível."),new Error("Can't attach unrecognized event handler.");this.events[t].push(e)}return this},off:function(t,e){if(t.match(" "))eventname.split(" ").forEach(function(t){this.off(t,e)});else{if(!this.events[t])throw n.warn("Evento indisponível."),new Error("Can't remove unrecognized event handler.");this.events[t]=[]}return this},trigger:function(t){if(this.events[t]&&this.events[t].length){var e=this,a=arguments;this.events[t].map(function(t){t.apply(e,Array.prototype.slice.call(a,1))})}return this},setMeta:function(e){t.extend(this.meta,e)},setCurrent:function(t){this.meta.current=t,this.meta.prev=t-1,this.meta.next=t+1}}),e.pageIt}(window.jQuery||!1,window,document);
{
"name": "jquery.page-it",
"version": "0.3.1",
"version": "0.3.2",
"description": "Lib for building paginations.",

@@ -5,0 +5,0 @@ "main": "jquery.page-it.js",

@@ -33,29 +33,29 @@ # Page it!

{
/**
* @var {int?} The page where the plugin should start.
*/
initPage: null,
/**
* @var {bool} cache : if should store loaded pages (and load'em from) in a local storage or not
*/
cache: true,
url: '',
method: 'get',
dataType: 'json',
/**
* @var {object} jQuery.AJAX configuration options.
*/
ajax: {
cache: false,
global: true,
},
/**
* @var {HTMLElement} contentView : if you define this, you will have auto page content updates
*/
contentView: null,
/**
* @var {object}
*/
meta: metaSchema
/**
* @var {bool} If should auto start loading the current page or not.
*/
autoStart: false,
/**
* @var {bool} cache : if should store loaded pages (and load'em from) in a local storage or not
*/
cache: true,
url: '', // @TODO: move it inside ajax key
method: 'get', // @TODO: move it inside ajax key
dataType: 'json',
/**
* @var {object} jQuery.AJAX configuration options.
*/
ajax: {
cache: false,
global: true,
},
/**
* @var {HTMLElement} contentView : if you define this, you will have auto page content updates
*/
contentView: null,
/**
* @var {object}
*/
meta: metaSchema
}
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc