Skip to content

Commit b50ef95

Browse files
committed
1.0rc1 - see changelog
1 parent c262b66 commit b50ef95

14 files changed

+1023
-796
lines changed

CHANGELOG.md

+14
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
## master ##
44

5+
## 1.0rc1 ##
6+
7+
### NEW ###
8+
* Added a wrapper for imgcache that supports Promises (qimgcache.js)
9+
* Helpers, DomHelpers and Private classes are now available publicly via ImgCache.helpers, ImgCache.domHelpers and ImgCache.private respectively. Those are not just plain public because you generally shouldn't need them, though they're now accessible.
10+
11+
### FIXED ###
12+
* Fixed issue on iOS devices (#93)
13+
14+
### IMPROVED ###
15+
* Replaced tabs with whitespaces throughout the code and examples
16+
* Readme: added a Troubleshooting section to help you solve the most common issues
17+
* Readme: added links to angular wrappers for imgcache
18+
* Reviewed examples
519

620
## 0.7.6 ##
721

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Apache License
22

3-
Copyright 2012-2014 (c) Christophe BENOIT - [Wobis](http://www.wobis.fr)
3+
Copyright 2012-2015 (c) Christophe BENOIT - [Wobis](http://www.wobis.fr)
44

55
*Version 2.0, January 2004*
66

README.md

+79-25
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ Using cached images
106106
Once an image is stored in the cache, you can replace the file displayed in an img element by the cached one:
107107

108108
```javascript
109-
target = $('img#profile');
110-
ImgCache.cacheFile(target.attr('src'), function(){
111-
ImgCache.useCachedFile(target, function(){
109+
var target = $('img#profile');
110+
ImgCache.cacheFile(target.attr('src'), function () {
111+
ImgCache.useCachedFile(target, function () {
112112
alert('now using local copy');
113113
}, function(){
114114
alert('could not load from cache');
@@ -119,13 +119,13 @@ ImgCache.cacheFile(target.attr('src'), function(){
119119
To check if a file is stored locally:
120120

121121
```javascript
122-
ImgCache.isCached(target.attr('src'), function(path, success){
123-
if(success){
122+
ImgCache.isCached(target.attr('src'), function(path, success) {
123+
if (success) {
124124
// already cached
125125
ImgCache.useCachedFile(target);
126126
} else {
127127
// not there, need to cache the image
128-
ImgCache.cacheFile(target.attr('src'), function(){
128+
ImgCache.cacheFile(target.attr('src'), function () {
129129
ImgCache.useCachedFile(target);
130130
});
131131
}
@@ -135,7 +135,7 @@ ImgCache.isCached(target.attr('src'), function(path, success){
135135
When you no longer want to use the locally cached file:
136136

137137
```javascript
138-
target = $('img#profile');
138+
var target = $('img#profile');
139139
ImgCache.useOnlineFile(target);
140140
```
141141

@@ -146,7 +146,7 @@ To remove all cached files, clear the local cache folder:
146146
```javascript
147147
ImgCache.clearCache(function(){
148148
// continue cleanup...
149-
}, function(){
149+
}, function () {
150150
// something went wrong
151151
});
152152
```
@@ -155,21 +155,27 @@ There is currently no way to invalidate single images from the cache.
155155

156156
High level API
157157
--------------
158-
* ImgCache.init() *initialises the local cache*
159-
* ImgCache.cacheFile() *writes a copy of a file into the local cache*
160-
* ImgCache.isCached() *checks if a the given image exists in the cache - does not check if the latest version of that file is cached*
161-
* ImgCache.getCachedFile() *returns the cached file*
162-
* ImgCache.getCachedFileURL() *returns the URL of the cached version of a file*
163-
* ImgCache.useCachedFile() *replaces the img src with the cached version*
164-
* ImgCache.useCachedFileWithSource() *similar to useCachedFile but with the image source url as extra parameter*
165-
* ImgCache.useOnlineFile() *replaces back the img src with the original (online) version*
166-
* ImgCache.clearCache() *clears the local cache folder*
167-
* ImgCache.isBackgroundCached() *checks if a the given element background image exists in the cache - does not check if the latest version of that file is cached*
168-
* ImgCache.cacheBackground() *caches the background image of an element*
169-
* ImgCache.useCachedBackground() *replaces the background image source of the given element with the cached version*
170-
* ImgCache.useBackgroundOnlineFile() *replaces back a background image with the original (online) version*
171-
* ImgCache.removeFile() *removes a given file from the cache*
172-
* ImgCache.getCurrentSize() *returns the current size of the ImgCache cache in bytes -- this is not an asynchronous method *
158+
* ImgCache.**init**() *-- initialises the local cache*
159+
* ImgCache.**cacheFile**() *-- writes a copy of a file into the local cache*
160+
* ImgCache.**isCached**() *-- checks if a the given image exists in the cache - does not check if the latest version of that file is cached*
161+
* ImgCache.**getCachedFile**() *-- returns the cached file*
162+
* ImgCache.**getCachedFileURL**() *-- returns the URL of the cached version of a file*
163+
* ImgCache.**useCachedFile**() *-- replaces the img src with the cached version*
164+
* ImgCache.**useCachedFileWithSource**() *-- similar to useCachedFile but with the image source url as extra parameter*
165+
* ImgCache.**useOnlineFile**() *-- replaces back the img src with the original (online) version // synchronous method*
166+
* ImgCache.**clearCache**() *-- clears the local cache folder*
167+
* ImgCache.**isBackgroundCached**() *-- checks if a the given element background image exists in the cache - does not check if the latest version of that file is cached*
168+
* ImgCache.**cacheBackground**() *-- caches the background image of an element*
169+
* ImgCache.**useCachedBackground**() *-- replaces the background image source of the given element with the cached version*
170+
* ImgCache.**useBackgroundOnlineFile**() *-- replaces back a background image with the original (online) version*
171+
* ImgCache.**removeFile**() *-- removes a given file from the cache*
172+
* ImgCache.**getCurrentSize**() *-- returns the current size of the ImgCache cache in bytes // synchronous method *
173+
174+
Private methods are accessible through:
175+
176+
* ImgCache.helpers *-- general helper methods*
177+
* ImgCache.domHelpers *-- DOM manipulation helper functions*
178+
* ImgCache.private *-- private methods*
173179

174180
Options
175181
-------
@@ -181,22 +187,70 @@ Overridable methods
181187
* The hash method used by default in ImgCache is SHA-1. It was chosen for its near absence of collision. Though it might slow things down if you have a large number of files to cache (see #81). You can plug-in your own method by overriding ImgCache.overridables.hash.
182188
* If logging is enabled, ImgCache output some log entries in the console by default. You can override ImgCache.overridables.log in order to change this behaviour.
183189

190+
Promises
191+
--------
192+
Include also [qimgcache.js](js/qimgcache.js) in your html files to be able to use its [Q Promises](https://github.com/kriskowal/q) interface if you don't like callbacks and prefer to use the simpler then/fail/progress methods.
193+
194+
This wrapper also makes sure the init method is always called first, so you SHOULDN'T call this method yourself when using this wrapper.
195+
196+
Check out the [sample code](examples/promises.html).
197+
184198
Unit tests
185199
----------
186-
Open index.html and click 'Start unit tests' to launch unit tests.
200+
Open ```index.html``` and click 'Start unit tests' to launch unit tests.
187201

188202
Code samples
189203
------------
190-
See html files in the `examples/` folder.
204+
Open ```index.html``` to check out several examples.
191205

192206
Release Notes
193207
-------------
194208
See [CHANGELOG](CHANGELOG.md) for the complete release notes.
195209

210+
Troubleshooting
211+
---------------
212+
213+
Make sure you first read carefully this documentation. If you are still having issues follow this checklist:
214+
215+
* Set debug ON (```ImgCache.options.debug = true;```) and follow the output within the console carefully.
216+
* Is init the first method of ImgCache to be called? (check out the console with debug ON to make sure of that)
217+
* Add alert/console.log calls throughout your code to see what gets called and what doesn't.
218+
* Am I running the latest version of ImgCache? If not, try with the latest version or look into the [changelog](CHANGELOG.md) for fixes related to your problem in newer releases.
219+
220+
If using Cordova/Phonegap, make sure you read [this documentation](CORDOVA.md) first, then double check the following:
221+
222+
* Are all the required plugins activated ? (config.xml)
223+
* Are the correct permissions set? (config.xml)
224+
* Is my code running AFTER the "deviceready" event is launched?
225+
226+
If you are still stuck, look for a similar problem within existing issues.
227+
228+
If you cannot find any, open an issue with a description of your problem, a simpler version of your code if you can.
229+
230+
Whenever you post an issue it's IMPORTANT you add the following details to get a quicker answer:
231+
232+
* ImgCache version
233+
* Options used
234+
* JS frameworks used with it (jQuery / Angular / Ionic ..)
235+
* Environment : Chrome or Cordova
236+
* If Cordova is used:
237+
* Its version
238+
* The version of the plugins
239+
* The target OS (iOS / Android..)
240+
* The target OS version (e.g: iOS 8.1)
241+
242+
196243
Known issues
197244
------------
198245
See [KNOWN_ISSUES](KNOWN_ISSUES.md) for a list of known issues.
199246

247+
See also
248+
--------
249+
Wrappers for AngularJS:
250+
251+
* [angular-imgcache.js](https://github.com/jBenes/angular-imgcache.js)
252+
* [ngImgCache](https://github.com/sunsus/ngImgCache/)
253+
200254
License
201255
-------
202256
Copyright 2012-2015 (c) Christophe BENOIT - [Wobis](http://www.wobis.fr)

TODO.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# TODO
22

33
* Find a solution for cache invalidation when online in case an image has changed since last cached version
4+
5+
46
* When Chrome finally supports canvas.toBlob(), possibly replace download method with new one that draws an Image into a canvas and then retrieves its content using the toBlob() method -- or use [canvas-toBlob.js] (https://github.com/eligrey/canvas-toBlob.js)
5-
* Looks like Cordova supports Blob download now, just like Chrome - add an option to use this method instead of the previous FileTransfer.download
7+
8+
9+
* It looks like Cordova supports Blob download now, just like Chrome - add an option to use this method instead of the previous FileTransfer.download

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "imgcache.js",
3-
"version": "0.7.6",
3+
"version": "1.0rc1",
44
"homepage": "https://github.com/chrisben/imgcache.js",
55
"authors": [
66
{

0 commit comments

Comments
 (0)