mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
drafts.js: Create initialize() function.
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
global.stub_out_jquery();
|
set_global('$', global.make_zjquery());
|
||||||
|
set_global('window', {});
|
||||||
|
|
||||||
add_dependencies({
|
add_dependencies({
|
||||||
localstorage: 'js/localstorage',
|
localstorage: 'js/localstorage',
|
||||||
@@ -128,3 +129,21 @@ var draft_2 = {
|
|||||||
stub_draft({});
|
stub_draft({});
|
||||||
assert.equal(drafts.snapshot_message(), undefined);
|
assert.equal(drafts.snapshot_message(), undefined);
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
(function test_initialize() {
|
||||||
|
var message_content = $("#new_message_content");
|
||||||
|
message_content.focusout = function (f) {
|
||||||
|
assert.equal(f, drafts.update_draft);
|
||||||
|
f();
|
||||||
|
};
|
||||||
|
|
||||||
|
global.window.addEventListener = function (event_name, f) {
|
||||||
|
assert.equal(event_name, "beforeunload");
|
||||||
|
var called = false;
|
||||||
|
drafts.update_draft = function () { called = true; };
|
||||||
|
f();
|
||||||
|
assert(called);
|
||||||
|
};
|
||||||
|
|
||||||
|
drafts.initialize();
|
||||||
|
}());
|
||||||
|
|||||||
@@ -383,14 +383,13 @@ exports.launch = function () {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$(function () {
|
exports.initialize = function () {
|
||||||
|
|
||||||
window.addEventListener("beforeunload", function () {
|
window.addEventListener("beforeunload", function () {
|
||||||
exports.update_draft();
|
exports.update_draft();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#new_message_content").focusout(exports.update_draft);
|
$("#new_message_content").focusout(exports.update_draft);
|
||||||
});
|
};
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
|
|
||||||
|
|||||||
@@ -259,6 +259,7 @@ $(function () {
|
|||||||
reactions.initialize();
|
reactions.initialize();
|
||||||
compose_fade.initialize();
|
compose_fade.initialize();
|
||||||
stream_list.initialize();
|
stream_list.initialize();
|
||||||
|
drafts.initialize();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user