-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoptions.js
More file actions
158 lines (135 loc) · 4.95 KB
/
Copy pathoptions.js
File metadata and controls
158 lines (135 loc) · 4.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Generated by CoffeeScript 1.6.3
(function() {
var $resetButton, $stickerModal, $stickers, $version, checkboxOptions, i, id, imgs, pudu, saveSelectedStickers, setSelectedStickerEffect, stickers;
pudu = window.pudu;
stickers = pudu.stickers;
$stickers = $('#pudu-stickers');
$stickerModal = $('#pudu-sticker-modal');
$resetButton = $('#pudu-options-reset');
$version = $('#pudu-version');
$version.text('v' + chrome.app.getDetails().version);
$resetButton.on('click', function() {
return pudu.clearLocalStorage(function() {
return pudu.setLocalStorage(pudu.defaultSetting, function() {
return window.location.href = window.location.href;
});
});
});
checkboxOptions = function(optionSelector, optionName) {
pudu.getLocalStorage(function(items) {
var opts;
if (items[optionName] === void 0) {
opts = {};
opts[optionName] = true;
pudu.setLocalStorage(opts);
}
if (items[optionName] === void 0 || items[optionName] === true) {
return $(optionSelector).attr('checked', 'checked');
}
});
return $(optionSelector).on('change', function() {
var checked, opts;
checked = $(this).is(':checked');
opts = {};
if (checked) {
opts[optionName] = true;
} else {
opts[optionName] = false;
}
return pudu.setLocalStorage(opts);
});
};
checkboxOptions('#pudu-options-signature', 'hideSignature');
checkboxOptions('#pudu-options-comment-number', 'hideCommentNumber');
setSelectedStickerEffect = function() {
var $checked;
$('.sticker-box').removeClass('checked');
$checked = $('.sticker-checkbox:checked');
$checked.parents('.sticker-box').addClass('checked');
return pudu.getLocalStorage(function(items) {
var i, id, _i, _ref, _results;
_results = [];
for (i = _i = _ref = items.selectedStickers.length; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) {
id = items.selectedStickers[i];
_results.push($stickers.prepend($("#" + id).parent()));
}
return _results;
});
};
saveSelectedStickers = function() {
var c, selectedStickers;
selectedStickers = (function() {
var _i, _len, _ref, _results;
_ref = $('.sticker-checkbox:checked');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
c = _ref[_i];
_results.push($(c).data('id'));
}
return _results;
})();
pudu.setLocalStorage({
selectedStickers: selectedStickers
});
return setSelectedStickerEffect();
};
i = 1;
for (id in stickers) {
imgs = stickers[id];
if (id !== 'sticker5') {
$stickers.append("<li> <div id='" + id + "' data-name='" + pudu.stickersName[id] + "' class='thumbnail sticker-box'> <img class='sticker-image' data-id='" + id + "' src='" + (pudu.stickerButton(id)) + "' title='Click to preview' /> <center><small>" + pudu.stickersName[id] + "</small></center> <div class='sticker-checkbox-wrap'> <input class='sticker-checkbox' type='checkbox' data-id='" + id + "' name='select' /> </div> </div> </li>");
}
}
pudu.getLocalStorage(function(items) {
var _i, _len, _ref;
_ref = items.selectedStickers;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
id = _ref[_i];
$("#" + id + " .sticker-checkbox").attr('checked', true);
}
return setSelectedStickerEffect();
});
$('#pudu-stickers-filter').on('keyup', function() {
var q;
q = $(this).val().trim().toLowerCase();
return $('.sticker-box:not(.checked)').each(function() {
if ($(this).data('name').toLowerCase().indexOf(q) === -1) {
return $(this).parent().hide();
} else {
return $(this).parent().show();
}
});
});
$('body').on('click', '.sticker-checkbox', function() {
return saveSelectedStickers();
});
$('body').on('click', '.sticker-image', function() {
var img;
id = $(this).data('id');
imgs = stickers[id];
$stickerModal.find('.btn-success').data('id', id);
$stickerModal.find('h3').html("<img src='" + (pudu.stickerButton(id)) + "' /> " + pudu.stickersName[id]);
$stickerModal.find('.thumbnails').empty().html(((function() {
var _i, _len, _results;
_results = [];
for (_i = 0, _len = imgs.length; _i < _len; _i++) {
img = imgs[_i];
_results.push("<li><img class='thumbnail' src='" + (pudu.stickerKey(id, img)) + "' width='75' /></li>");
}
return _results;
})()).join(''));
return $stickerModal.modal('show');
});
$stickerModal.on('shown', function() {
return $('.modal-body', this).scrollTop(0);
});
$stickerModal.find('.btn-success').on('click', function() {
id = $(this).data('id');
$("#" + id + " .sticker-checkbox").attr('checked', true);
saveSelectedStickers();
return $stickerModal.modal('hide');
});
}).call(this);
/*
//@ sourceMappingURL=options.map
*/