support sending to multiple targets

This commit is contained in:
Myk Melez 2008-11-26 21:59:03 -08:00
Родитель 2b064531ce
Коммит 74510976ca
3 изменённых файлов: 28 добавлений и 4 удалений

Просмотреть файл

@ -67,22 +67,40 @@ let WriteForm = {
},
get _stringBundle() {
dump('document.getElementById("snowlWriteBundle"): ' + document.getElementById("snowlWriteBundle") + "\n");
delete this._stringBundle;
return this._stringBundle = document.getElementById("snowlWriteBundle");
},
get _targetMenu() {
delete this._targetMenu;
return this._targetMenu = document.getElementById("targetMenu");
},
// FIXME: if there is more than one target, let the user choose which one to use.
_target: null,
get _target() {
return this._targetMenu.selectedItem.target;
},
init: function() {
this._target = SnowlService.targets[0];
for each (let target in SnowlService.targets) {
let targetItem = this._targetMenu.appendItem(target.name);
targetItem.target = target;
}
// FIXME: reselect the last target through which the user sent a message.
this._targetMenu.selectedIndex = 0;
// Set the initial state of the length counter and send button.
this.onInputMessage();
},
onSelectTarget: function() {
// Update the length counter and the Send button's state.
this.onInputMessage();
},
onInputMessage: function() {
// FIXME: accommodate targets that don't have a maximum message length.
// Update the counter to reflect how many characters the user can still type.
this._writeCounter.value =
this._target.maxMessageLength - this._writeTextbox.value.length;
@ -97,6 +115,7 @@ dump('document.getElementById("snowlWriteBundle"): ' + document.getElementById("
this._sendButton.label = this._stringBundle.getString("sendButton.label.sending");
this._sendButton.disabled = true;
this._writeTextbox.disabled = true;
this._targetMenu.disabled = true;
let content = this._writeTextbox.value;
let callback = function() { WriteForm.onMessageSent() };
@ -116,6 +135,8 @@ dump('document.getElementById("snowlWriteBundle"): ' + document.getElementById("
this._sendButton.label = this._stringBundle.getString("sendButton.label");
this._sendButton.disabled = false;
this._writeTextbox.disabled = false;
this._targetMenu.disabled = false;
this._targetMenu.removeAllItems();
this._writeTextbox.value = "";
this._target = null;

Просмотреть файл

@ -50,6 +50,9 @@
</stringbundleset>
<vbox id="writeForm">
<menulist id="targetMenu" oncommand="WriteForm.onSelectTarget()">
<menupopup/>
</menulist>
<textbox id="writeTextbox" multiline="true" rows="3" oninput="WriteForm.onInputMessage()"/>
<hbox>
<description id="writeCounter"/>

Просмотреть файл

@ -67,7 +67,7 @@ const MACHINE_URI = URI.get("https://twitter.com");
const HUMAN_URI = URI.get("http://twitter.com/home");
function SnowlTwitter(aID, aName, aMachineURI, aHumanURI, aUsername, aLastRefreshed, aImportance) {
SnowlSource.init.call(this, aID, NAME, MACHINE_URI, HUMAN_URI, aUsername, aLastRefreshed, aImportance);
SnowlSource.init.call(this, aID, aName, MACHINE_URI, HUMAN_URI, aUsername, aLastRefreshed, aImportance);
SnowlTarget.init.call(this);
}