Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
compose: Add support for full size compose box.
This commit makes a working toggler in compose_actions that adds the compose-fullscreen class to the compose that removes the max-height from the compose textarea and adds flex elements above so that the height automatically adjust with the device height. This results in making the compose box full screen sized. The compose_height.js maintains the state of the height of the compose box. Also, when the compose box is closed, the compose box is reset to it's default behaviour and original height. So, everytime user need not toggle off the compose full size and only for specific message it is used. It also adds destroy autosize on compose_height state change. It destroys the autosize of textarea when the full screen sized compose box is toggled on. And everytime when it is turned off, it reinitialises the autosize. This also adds a condition in autosize_textarea to only autosize when composebox is not in full height state. Fixes #17660
- Loading branch information
Showing
7 changed files
with
181 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
|
||
const {strict: assert} = require("assert"); | ||
|
||
const autosize = require("autosize"); | ||
|
||
const {mock_cjs, zrequire} = require("../zjsunit/namespace"); | ||
const {run_test} = require("../zjsunit/test"); | ||
const $ = require("../zjsunit/zjquery"); | ||
|
||
mock_cjs("jquery", $); | ||
|
||
const compose_height = zrequire("compose_height"); | ||
|
||
run_test("test_compose_height_changes", (override) => { | ||
let autosize_destroyed = false; | ||
override(autosize, "destroy", () => { | ||
autosize_destroyed = true; | ||
}); | ||
|
||
compose_height.make_compose_box_full_size(); | ||
assert.ok($("#compose").hasClass("compose-fullscreen")); | ||
assert.ok(compose_height.is_full_size()); | ||
assert.ok(autosize_destroyed); | ||
|
||
compose_height.make_compose_box_original_size(); | ||
assert.ok(!$("#compose").hasClass("compose-fullscreen")); | ||
assert.ok(!compose_height.is_full_size()); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import autosize from "autosize"; | ||
import $ from "jquery"; | ||
|
||
let full_size_status = false; // true or false | ||
|
||
// Some functions to handle the state explicitely | ||
export function set_full_size(is_full) { | ||
full_size_status = is_full; | ||
} | ||
|
||
export function is_full_size() { | ||
return full_size_status; | ||
} | ||
|
||
export function make_compose_box_full_size() { | ||
set_full_size(true); | ||
|
||
// The autosize should be destroyed for the full size compose | ||
// box else it will interfare and shrink its size accordingly. | ||
autosize.destroy($("#compose-textarea")); | ||
|
||
$("#compose").addClass("compose-fullscreen"); | ||
|
||
$(".collapse_composebox_button").show(); | ||
$(".expand_composebox_button").hide(); | ||
} | ||
|
||
export function make_compose_box_original_size() { | ||
set_full_size(false); | ||
|
||
$("#compose").removeClass("compose-fullscreen"); | ||
|
||
// Again initialise the compose textarea as it was destroyed | ||
// when compose box was made full screen | ||
autosize($("#compose-textarea")); | ||
|
||
$(".collapse_composebox_button").hide(); | ||
$(".expand_composebox_button").show(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters