Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12345
  1. // -- Sammy.js -- /plugins/sammy.cache.js
  2. // http://sammyjs.org
  3. // Version: 0.7.6
  4. // Built: 2014-08-26 10:45:30 +0300
  5. (function(factory){if(typeof define==="function"&&define.amd){define(["jquery","sammy"],factory)}else{(window.Sammy=window.Sammy||{}).MemoryCacheProxy=factory(window.jQuery,window.Sammy)}})(function($,Sammy){Sammy.MemoryCacheProxy=function(initial){this._cache=initial||{}};$.extend(Sammy.MemoryCacheProxy.prototype,{exists:function(name){return typeof this._cache[name]!="undefined"},set:function(name,value){return this._cache[name]=value},get:function(name){return this._cache[name]},clear:function(name){delete this._cache[name]}});Sammy.DataCacheProxy=function(initial,$element){initial=initial||{};this.$element=$element;$.each(initial,function(key,value){$element.data("cache."+key,value)})};$.extend(Sammy.DataCacheProxy.prototype,{exists:function(name){return typeof this.$element.data("cache."+name)!="undefined"},set:function(name,value){return this.$element.data("cache."+name,value)},get:function(name){return this.$element.data("cache."+name)},clear:function(name){this.$element.removeData("cache."+name)}});Sammy.Cache=function(app,proxy){app.log("**WARNING:** This version of Sammy.Cache has been deprecated in favor of using the version in Sammy.Storage and will be removed in 1.0");if(proxy=="data"){this.cache_proxy=new Sammy.DataCacheProxy({},this.$element())}else{this.cache_proxy=new Sammy.MemoryCacheProxy({})}app.cache_partials=true;$.extend(app,{cache:function(name,value){if(typeof value=="undefined"){return this.cache_proxy.get(name)}else if($.isFunction(value)&&!this.cache_proxy.exists(name)){return this.cache_proxy.set(name,value.apply(this))}else{return this.cache_proxy.set(name,value)}},clearCache:function(name){return this.cache_proxy.clear(name)}});app.helpers({cache:function(name,value){return this.app.cache(name,value)}})};return Sammy.MemoryCacheProxy});