forked from tombfix/patch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathform.SimpleTextForm.js
42 lines (36 loc) · 938 Bytes
/
form.SimpleTextForm.js
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
(function(){
var COMMANDS = {
'm' : Tumblr,
't' : Twitter,
'l' : Local,
}
var DEFAULT = Twitter;
registerSheet(<><![CDATA[
@namespace url(http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul);
@-moz-document url(chrome://tombloo/content/quickPostForm.xul) {
.window-regular #titlebar > hbox,
.window-regular #control {
display: none;
}
}
]]></>);
connect(grobal, 'form-open', function(win){
var ps = win.ps;
if(ps.type != 'regular')
return;
addElementClass(win.getElement('window'), 'window-' + ps.type);
win.FormPanel.prototype.post = function(){
var lines = this.descriptionBox.value.split('\n');
var command = lines.shift();
var poster = COMMANDS[command];
if(!poster){
poster = DEFAULT;
lines.unshift(command);
}
Tombloo.Service.post(update(ps, {
description : lines.join('\n')
}), poster);
signal(this, 'post');
};
});
})();