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.
46 lines
997 B
46 lines
997 B
(function () {
|
|
|
|
// How many days before forgetting that we hid a given post
|
|
// (Otherwise the cookie will balloon in size)
|
|
var EXPIRY = 7;
|
|
|
|
var Hidden = new Kioku('hide', EXPIRY);
|
|
|
|
oneeSama.hook('menuOptions', function (info) {
|
|
if (!info.model)
|
|
return; // can't hide drafts
|
|
if (postForm && postForm.model.id == info.model.id)
|
|
return; // can't hide own post
|
|
info.options.push('Hide');
|
|
});
|
|
|
|
menuHandlers.Hide = function (model, $post) {
|
|
Hidden.write(model.id, Hidden.now());
|
|
model.set('hide', true);
|
|
Backbone.trigger('hide', model); // bit of a hack...
|
|
};
|
|
|
|
/* Options menu clear control */
|
|
|
|
var $clear = $('<input>', {
|
|
type: 'button',
|
|
val: 'Clear hidden',
|
|
css: {display: 'block', 'margin-top': '1em'},
|
|
click: function () {
|
|
Hidden.purge_all();
|
|
$clear.hide();
|
|
},
|
|
});
|
|
|
|
oneeSama.hook('initOptions', function ($opts) {
|
|
$opts.append($clear);
|
|
});
|
|
|
|
oneeSama.hook('renderOptions', function ($opts) {
|
|
$clear.toggle(!_.isEmpty(Hidden.read_all()));
|
|
});
|
|
|
|
Hidden.purge_expired_soon();
|
|
|
|
})();
|