Skip to content

Commit

Permalink
API Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kpdecker committed Feb 3, 2011
1 parent 77fa488 commit b257147
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion user-image-cache.js
Expand Up @@ -53,6 +53,9 @@ var UserImageCache;
NOT_FOUND: "not_found",
UNKNOWN_TYPE: "unknown_type",

/**
* Determines if local file reads are possible in the current execution environment.
*/
isLocalSupported: function() {
try {
return !!window.FileReader;
Expand All @@ -61,14 +64,44 @@ var UserImageCache;
}
},

getCurEntry: function() { return curEntry && curEntry.entryId; },
/**
* Retrieves the entry id for the current entry, if one is defined.
* This value may be passed to the load method to reload the image
* if it is still cached.
*/
getEntryId: function() { return curEntry && curEntry.entryId; },

/**
* Retrieves the display name for the current entry, if one is defined.
*/
getDisplayName: function() { return curEntry && curEntry.displayName; },

/**
* Retrieves the src URI for the current entry, if one is defined.
*/
getSrc: function() { return curEntry && curEntry.src },

/**
* Sets the element that images will be loaded into.
*/
setEl: function(el) {
image = el;
},

/**
* Loads a given image.
*
* @param file may be one of:
* - File object (if supported)
* - Image URI
* - Entry ID returned by getEntryId for a previous image
*
* @param onError(error) optional callback that is executed if the image can not be loaded
* Errors include:
* - UserImageCache.NOT_FOUND : Unable to lookup cached image element.
* - UserImageCache.UNKNOWN_TYPE : File is unknown type
* - Result of FileReader.error
*/
load: function(file, onError) {
// the file from the session store if that is the case
if (typeof file === "string") {
Expand Down

0 comments on commit b257147

Please sign in to comment.