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

jquery.preload

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jquery.preload - npm Package Compare versions

Comparing version 1.0.9 to 1.1.0

CHANGELOG.md

2

bower.json
{
"name": "jquery.preload",
"version": "1.0.9",
"version": "1.1.0",
"description": "Multi-functional image preloader plugin for jQuery",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/flesler/jquery.preload",

@@ -8,3 +8,3 @@ /**

* @author Ariel Flesler
* @version 1.0.9
* @version 1.1.0
*

@@ -59,3 +59,3 @@ * @id jQuery.preload

return settings.base + source + settings.ext;
var url = source.src || source.href; // save the original source
var url = settings.srcAttribute ? $(source).attr(settings.srcAttribute) : source.src || source.href; // save the original source
if( typeof settings.placeholder == 'string' && source.src ) // Placeholder Mode, if it's an image, set it.

@@ -147,2 +147,3 @@ source.src = settings.placeholder;

/*
srcAttribute: null, // allow to define attribute to get url from
enforceCache: false, // If true, the plugin will save a copy of the images in $.preload.cache

@@ -149,0 +150,0 @@ find:null, // Rollover mode: a string or regex for the replacement

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

* @author Ariel Flesler
* @version 1.0.9
* @version 1.1.0
*/
;(function($){var j=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},j.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null});var g={loaded:0,failed:0,next:0,done:0,total:f.length};if(!g.total)return finish();var h=$(Array(d.threshold+1).join('<img/>')).load(handler).on('error',handler).bind('abort',handler).each(fetch);function handler(e){g.element=this;g.found=e.type=='load';g.image=this.src;g.index=this.index;var a=g.original=c[this.index];g[g.found?'loaded':'failed']++;g.done++;if(d.enforceCache)j.cache.push($('<img/>').attr('src',g.image)[0]);if(d.placeholder&&a.src)a.src=g.found?g.image:d.notFound||a.src;if(d.onComplete)d.onComplete(g);if(g.done<g.total)fetch(0,this);else{if(h&&h.unbind)h.unbind('load').unbind('error').unbind('abort');h=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&g.next&&g.next%j.gap==0&&!b){setTimeout(function(){fetch(i,a,true)},0);return false}if(g.next==g.total)return false;a.index=g.next;a.src=f[g.next++];if(d.onRequest){g.index=a.index;g.element=a;g.image=a.src;g.original=c[g.next-1];d.onRequest(g)}};function finish(){if(d.onFinish)d.onFinish(g)}};j.gap=14;j.cache=[];j.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){j(this,a);return this}})(jQuery);
;(function($){var j=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},j.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=d.srcAttribute?$(a).attr(d.srcAttribute):a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null});var g={loaded:0,failed:0,next:0,done:0,total:f.length};if(!g.total)return finish();var h=$(Array(d.threshold+1).join('<img/>')).load(handler).on('error',handler).bind('abort',handler).each(fetch);function handler(e){g.element=this;g.found=e.type=='load';g.image=this.src;g.index=this.index;var a=g.original=c[this.index];g[g.found?'loaded':'failed']++;g.done++;if(d.enforceCache)j.cache.push($('<img/>').attr('src',g.image)[0]);if(d.placeholder&&a.src)a.src=g.found?g.image:d.notFound||a.src;if(d.onComplete)d.onComplete(g);if(g.done<g.total)fetch(0,this);else{if(h&&h.unbind)h.unbind('load').unbind('error').unbind('abort');h=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&g.next&&g.next%j.gap==0&&!b){setTimeout(function(){fetch(i,a,true)},0);return false}if(g.next==g.total)return false;a.index=g.next;a.src=f[g.next++];if(d.onRequest){g.index=a.index;g.element=a;g.image=a.src;g.original=c[g.next-1];d.onRequest(g)}};function finish(){if(d.onFinish)d.onFinish(g)}};j.gap=14;j.cache=[];j.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){j(this,a);return this}})(jQuery);
{
"name": "jquery.preload",
"version": "1.0.9",
"version": "1.1.0",
"description": "Multi-functional image preloader plugin for jQuery",

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

@@ -9,3 +9,3 @@ {

],
"version": "1.0.9",
"version": "1.1.0",
"author": {

@@ -12,0 +12,0 @@ "name": "Ariel Flesler",

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

# jQuery.Preload 1.0
# jQuery.Preload
## Description
This is an advanced multi-functional preloader, that has 4 modes integrated.
Each mode suits a different, common situation.
## Demo

@@ -7,7 +12,18 @@

## Description
## Installation
This is an advanced multi-functional preloader, that has 4 modes integrated.
Each mode suits a different, common situation.
The plugin requires jQuery 1.8 or higher and [jquery.scrollTo](https://github.com/flesler/jquery.scrollTo).
Via [bower](https://github.com/flesler/jquery.preload/blob/master/bower.json):
```bash
bower install jquery.preload
```
Via [npm](https://www.npmjs.com/package/jquery.preload):
```bash
npm install jquery.preload
```
Manually: You can download the latest stable version from the [releases page](https://github.com/flesler/jquery.preload/releases).
## Modes / Settings

@@ -17,12 +33,13 @@

- URL: Preload a JS array of static URLs. Related settings:
- URL: Preload a JS array of static URLs. Related settings:
+ `base`: This string is prepended to each URL in the array.
+ `ext`: This string is appended to the end of each URL in the array.
- Rollover: Preload based on DOM images, slightly modifying their src. Can be used for rollovers, or for image-thumb. Related settings:
- Rollover: Preload based on DOM images, slightly modifying their src. Can be used for rollovers, or for image-thumb. Related settings:
+ `find`: String or regex that matches part of the srcs.
+ `replace`: Replacement to the matched part, to generate the alternate URL.
- Placeholder: Take regular images and set a placeholder image while they load. Show each original image when fully loaded. Allows sequential loading with a threshold. Related settings:
+ `placeholder`: URL of the temporal image shown while loading.
+ `notFound`: Optional image to show if a given image failed to load.
- Link: Preload the images that appear in the href of the given links. Related settings: `none`.
- Placeholder: Take regular images and set a placeholder image while they load. Show each original image when fully loaded. Allows sequential loading with a threshold. Related settings:
+ `placeholder`: URL of the temporal image shown while loading.
+ `notFound`: Optional image to show if a given image failed to load.
- Link: Preload the images that appear in the href of the given links. Related settings:
+ `srcAttribute`: You can specify an attribute where the URL will be present in the DOM elements, otherwise `elem.src || elem.href` is used

@@ -38,21 +55,21 @@ Since 1.0.6, you can combine these 2 modes, for another common use.

The plugin also provides 3 callbacks to interact with the image URLs during the preloading process. The callbacks get a hash of data, with details of the related image and global information.
The callbacks are:
The callbacks are:
- `onRequest`: Called when requesting a new image.
- `onComplete`: Called when a request is complete(loaded or failed).
- `onFinish`: Called when all images are fully preloaded.
- `onRequest`: Called when requesting a new image.
- `onComplete`: Called when a request is complete(loaded or failed).
- `onFinish`: Called when all images are fully preloaded.
## Data received by callbacks
The hash of data received by the callbacks, contains the following information:
The hash of data received by the callbacks, contains the following information:
- `loaded`: how many images were preloaded successfully.
- `failed`: how many images failed the preloading.
- `next`: 0-based index of the next image to preload.
- `done`: amount of preloaded images ( loaded + failed ).
- `found`: whether the last image could be preloaded or not.
- `total`: amount of images to preload overall.
- `image`: URL of the related image.
- `original`: The original source related to this image.
- `loaded`: how many images were preloaded successfully.
- `failed`: how many images failed the preloading.
- `next`: 0-based index of the next image to preload.
- `done`: amount of preloaded images ( loaded + failed ).
- `found`: whether the last image could be preloaded or not.
- `total`: amount of images to preload overall.
- `image`: URL of the related image.
- `original`: The original source related to this image.
Note that `threshold` and the callbacks, are not related to any mode, and can be useful for any of them.

Sorry, the diff of this file is not supported yet

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