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.2 to 0.3.3

83

jquery.page-it.js

@@ -25,3 +25,2 @@ (function ($, window, document, undefined) {

var metaSchema = {

@@ -46,4 +45,2 @@ size: null,

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

@@ -54,2 +51,4 @@ /**

ajax: {
url: '', // @TODO: move it inside ajax key
method: 'get', // @TODO: move it inside ajax key
cache: false,

@@ -59,5 +58,5 @@ global: true,

/**
* @var {HTMLElement} contentView : if you define this, you will have auto page content updates
* @var {HTMLElement} target : if you define this, you will have auto page content updates
*/
contentView: null,
target: null,
/**

@@ -107,3 +106,3 @@ * @var {object}

// Pagination Methods
$.extend(window[pluginName].prototype, {
Object.assign(window[pluginName].prototype, {

@@ -122,5 +121,5 @@ /**

/**
* @param {intger} pageIndex
* @param {intger} page
**/
to: function (pageIndex) {
to: function (page) {

@@ -132,3 +131,3 @@ if (this.requesting === true) {

if (!pageIndex || (this.meta.last && pageIndex > this.meta.last)) {
if (!page || (this.meta.last && page > this.meta.last)) {
this.trigger('page.load.skipped', {});

@@ -140,7 +139,7 @@ this.trigger('page.load.last', {});

// if index is a string like 'next' or 'prev', it will be translated by calling it's manager
if (typeof pageIndex === 'string' && pageIndex === 'next' || pageIndex === 'prev') {
return this[pageIndex]();
if (typeof page === 'string' && page === 'next' || page === 'prev') {
return this[page]();
}
if (!this.settings.cache || !this.pages[pageIndex]) {
if (!this.settings.cache || !this.pages[page]) {

@@ -150,8 +149,8 @@ /*

* so the programer can replace it.
* Auto set the pageIndex that will be requested.
* Auto set the page that will be requested.
*/
this.requestData = { pageIndex: pageIndex };
this.requestData = { page: page };
// user can moddify the requestData here, before the AJAX call.
this.trigger('page.load.before', this.requestData);
this.trigger('page.load.before', this);

@@ -165,4 +164,4 @@ var that = this;

global: this.settings.ajax.global,
url: this.settings.url,
method: this.settings.method,
url: this.settings.ajax.url,
method: this.settings.ajax.method,
data: this.requestData,

@@ -179,5 +178,5 @@ dataType: this.settings.dataType,

that.pages[pageIndex] = data.content;
that.pages[page] = data.content;
that.setCurrent(pageIndex);
that.setCurrent(page);

@@ -221,12 +220,12 @@ if (data.meta) {

if (this.pages[pageIndex].content) {
if (this.pages[page].content) {
this.fillContainer(this.pages[pageIndex].content);
this.fillContainer(this.pages[page].content);
this.trigger('page.load.loaded', this.pages[pageIndex]);
this.trigger('page.load.cache', this.pages[pageIndex]);
this.trigger('page.load.loaded', this.pages[page]);
this.trigger('page.load.cache', this.pages[page]);
} else {
this.trigger('page.load.empty', this.pages[pageIndex]);
this.trigger('page.load.empty', this.pages[page]);

@@ -241,9 +240,11 @@ }

/**
* Se tem um container de conteúdo definido e a resposta é em HTML, insere o conteúdo nele
* Se tem um container de conteúdo definido e a resposta é em HTML, insere o conteúdo nele.
*
* @param {string} data : The HTML data to be inserted in the view.
*/
fillContainer: function fillContainer(data) {
if (!!this.settings.contentView) {
if (!!this.settings.target) {
if ($(this.settings.contentView).html(data.content)) {
if ($(this.settings.target).html(data)) {
// plugin .trigger method

@@ -261,3 +262,3 @@ this.trigger('page.load.autoupdated', data);

* Calls .to() with page number meta.first as parameter.
**/
*/
first: function () {

@@ -294,4 +295,6 @@ this.trigger('page.first', this.meta.first);

* Register callbacks for the received event name.
*
* @param {string} eventName
* @param {function} fn
*
* @return {object}

@@ -320,4 +323,6 @@ **/

* Removes callbacks for the received event name.
*
* @param {string} eventName
* @param {function} fn
*
* @return {object}

@@ -346,4 +351,6 @@ **/

* Event handler, can call any registered event.
*
* @param {string} eventName
* @param {undefined} arguments
*
* @example this.trigger('event'[, data, response, etc]);

@@ -369,7 +376,25 @@ **/

/**
* @param {object} meta
*/
setMeta: function (meta) {
// meta is not multilevel
$.extend(this.meta, meta);
Object.assign(this.meta, meta);
},
/**
* A function that accepts a callback to update the request data.
* Everytime the pagination makes a request,
* this function will be used to get its new data.
*
* @param {object} requestData
*/
setRequestData: function (requestData) {
// by default, request data is not multilevel
Object.assign(this.requestData, requestData);
},
/**
* @param {int} current
*/
setCurrent: function (current) {

@@ -376,0 +401,0 @@ this.meta.current = current;

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

!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);
(function(t,e,a,i){var r="pageIt",s={log:function(){console.log(r+": "+arguments[0],Array.prototype.slice.call(arguments,1))},info:function(){console.info(r+": "+arguments[0],Array.prototype.slice.call(arguments,1))},warn:function(){console.warn(r+": "+arguments[0],Array.prototype.slice.call(arguments,1))},error:function(){console.error(r+": "+arguments[0],Array.prototype.slice.call(arguments,1))}};if(!t)return s.error("Não foi possível reconhecer o jQuery, inicialização cancelada!"),!1;var n={size:null,first:1,prev:null,current:null,next:null,last:null,total:null},o={autoStart:!1,cache:!0,dataType:"json",ajax:{url:"",method:"get",cache:!1,global:!0},target:null,meta:n};return e[r]=function(e){return this.settings=t.extend(!0,{},o,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()},Object.assign(e[r].prototype,{init:function(){this.trigger("ready"),this.settings.autoStart&&this.to(this.meta.current)},to:function(e){if(this.requesting===!0)return s.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={page:e},this.trigger("page.load.before",this);var a=this;this.requesting=!0,t.ajax({cache:this.settings.ajax.cache,global:this.settings.ajax.global,url:this.settings.ajax.url,method:this.settings.ajax.method,data:this.requestData,dataType:this.settings.dataType,success:function(t,i,r){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){s.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.target?t(this.settings.target).html(e)&&this.trigger("page.load.autoupdated",e):s.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 s.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 s.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(t){Object.assign(this.meta,t)},setRequestData:function(t){Object.assign(this.requestData,t)},setCurrent:function(t){this.meta.current=t,this.meta.prev=t-1,this.meta.next=t+1}}),e[r]})(window.jQuery||!1,window,document);
{
"name": "jquery.page-it",
"version": "0.3.2",
"version": "0.3.3",
"description": "Lib for building paginations.",

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

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