META-INF.resources.richfaces-utils.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of richfaces-core-impl Show documentation
Show all versions of richfaces-core-impl Show documentation
The RichFaces Core Implementation.
// RichFaces.utils
// RichFaces.utils.cache
(function ($, rf) {
rf.utils = rf.utils || {};
rf.utils.Cache = function (key, items, values, useCache) {
this.key = key.toLowerCase();
this.cache = {};
this.cache[this.key] = items || [];
this.originalValues = typeof values == "function" ? values(items) : values || this.cache[this.key];
this.values = processValues(this.originalValues);
this.useCache = useCache || checkValuesPrefix.call(this);
};
var processValues = function (values) {
var processedValues = [];
for (var i = 0; i 0) {
this.cache[key] = newCache;
if (newCache.length==1) {
this.lastKey = key;
}
}
}
return newCache;
};
var getItemValue = function (item) {
return this.originalValues[this.cache[this.key].index(item)];
};
var isCached = function (key) {
key = key.toLowerCase();
return this.cache[key] || this.useCache && key.indexOf(this.key)==0;
};
$.extend(rf.utils.Cache.prototype, (function () {
return {
getItems: getItems,
getItemValue: getItemValue,
isCached: isCached
};
})());
})(jQuery, RichFaces);