Skip to content

Commit

Permalink
Added the ability to set additional cookie options
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitrij Denissenko committed Oct 7, 2008
1 parent d6f0997 commit d68fdfc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/javascript/plexigrid.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/stylesheets/plexigrid.css
Expand Up @@ -27,7 +27,7 @@
.plexigrid-body tr.plexigrid-odd td {background:#f7f7f7;border-bottom:1px solid #f7f7f7;}
.plexigrid-body tr.plexigrid-odd td.plexigrid-sorted {background:#e3e3e3;border-bottom:1px solid #e3e3e3;}
.plexigrid-body tr:hover td, .plexigrid-body tr.plexigrid-totals:hover td, .plexigrid-body tr:hover td.plexigrid-sorted, .plexigrid-body tr.hover td, .plexigrid-body tr.hover td.plexigrid-sorted {background:#d9ebf5;border-left:1px solid #eef8ff;border-bottom:1px dotted #a8d8eb;}
.plexigrid-body tr.plexigrid-totals td {background:#ddd;border-top:1px solid #999;border-left:1px solid #eee;border-right:1px solid #bbb;border-bottom:0;font-weight:bold;}
.plexigrid-body tr.plexigrid-totals td {background:#ddd;border-top:1px solid #bbb;border-left:1px solid #eee;border-right:1px solid #bbb;border-bottom:0;font-weight:bold;}
.plexigrid-body tr.plexigrid-selected td.plexigrid-sorted, .plexigrid-body tr.plexigrid-selected td {background:#d5effc url(../images/plexigrid/hl.png) repeat-x top;border-right:1px solid #d2e3ec;border-left:1px solid #eef8ff;border-bottom:1px solid #a8d8eb;}
.plexigrid-drags, .plexigrid-drags div {float:left;position:absolute;}
.plexigrid-drags {z-index:10;overflow:visible;}
Expand Down
14 changes: 9 additions & 5 deletions src/javascript/plexigrid.js
Expand Up @@ -111,6 +111,7 @@ var PlexiGrid = {
allowColumnsResize: true, // allow to resize columns

cookieName: '__PlexiGrid__', // Name of the cookie
cookieOptions: {}, // Cookie options, e.g. { 'expires': 'Fri, 01 Jan 2010 08:00:00 GMT', 'domain': 'mydomain.com' }
storeStyle: false, // Store style in cookie
applyStyle: false, // Apply style from cookie
styleName: 'default', // Name of the style
Expand Down Expand Up @@ -193,9 +194,12 @@ PlexiGrid.Grid = Class.create({

if (!this.cookie[this.options.styleName]) this.cookie[this.options.styleName] = {};
this.cookie[this.options.styleName][key] = value;
try {
document.cookie = this.options.cookieName + "=" + escape(Object.toJSON(this.cookie));
} catch(e) {}
try {
var options = $H(this.options.cookieOptions).map(function(pair) {
return pair.key + '=' + pair.value;
}).join(';');
document.cookie = this.options.cookieName + "=" + escape(Object.toJSON(this.cookie)) + (options.blank() ? '' : ';' + options);
} catch(e) {}
},

findCells: function(name) {
Expand Down Expand Up @@ -290,8 +294,8 @@ PlexiGrid.Grid = Class.create({
_readCookie: function() {
if (!this.options.applyStyle) return;

var cookies = document.cookie.match(this.options.cookieName + '=(.*?)(;|$)');
if (cookies) this.cookie = (unescape(cookies[1])).evalJSON();
var cookies = document.cookie.match(this.options.cookieName + '=(.*?)(;|$)');
if (cookies) this.cookie = (unescape(cookies[1])).evalJSON();

var style = this.cookie[this.options.styleName];
if (style) this.applyStyle(style, this.table.down('thead'));
Expand Down
2 changes: 1 addition & 1 deletion src/stylesheets/plexigrid.css
Expand Up @@ -138,7 +138,7 @@

.plexigrid-body tr.plexigrid-totals td {
background: #ddd;
border-top: 1px solid #999;
border-top: 1px solid #bbb;
border-left: 1px solid #eee;
border-right: 1px solid #bbb;
border-bottom: 0;
Expand Down

0 comments on commit d68fdfc

Please sign in to comment.