Sha256: 377ee9979acff1f41205c1518ef94595136ba6404c4e6a9dd568c9951352a9aa

Contents?: true

Size: 1.34 KB

Versions: 82

Compression:

Stored size: 1.34 KB

Contents

/*
 * Storage for jQuery Collapse
 * --
 * source: http://github.com/danielstocks/jQuery-Collapse/
 * site: http://webcloud.se/jQuery-Collapse
 *
 * @author Daniel Stocks (http://webcloud.se)
 * Copyright 2013, Daniel Stocks
 * Released under the MIT, BSD, and GPL Licenses.
 */

(function($) {

  var STORAGE_KEY = "jQuery-Collapse";

  function Storage(id) {
    var DB;
    try {
      DB = window.localStorage || $.fn.collapse.cookieStorage;
    } catch(e) {
      DB = false;
    }
    return DB ? new _Storage(id, DB) : false;
  }
  function _Storage(id, DB) {
    this.id = id;
    this.db = DB;
    this.data = [];
  }
  _Storage.prototype = {
    write: function(position, state) {
      var _this = this;
      _this.data[position] = state ? 1 : 0;
      // Pad out data array with zero values
      $.each(_this.data, function(i) {
        if(typeof _this.data[i] == 'undefined') {
          _this.data[i] = 0;
        }
      });
      var obj = this._getDataObject();
      obj[this.id] = this.data;
      this.db.setItem(STORAGE_KEY, JSON.stringify(obj));
    },
    read: function() {
      var obj = this._getDataObject();
      return obj[this.id] || [];
    },
    _getDataObject: function() {
      var string = this.db.getItem(STORAGE_KEY);
      return string ? JSON.parse(string) : {};
    }
  };

  jQueryCollapseStorage = Storage;

})(jQuery);

Version data entries

82 entries across 82 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.6.3 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.6.2 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.6.1 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.6 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.19 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.18 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.17 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.16 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.15 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.14 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.13 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.12 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.11 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.10 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.9 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.8 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.7 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.6 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.5 app/assets/javascripts/jquery.collapse_storage.js
trusty-festivity-extension-2.5.4 app/assets/javascripts/jquery.collapse_storage.js