|
|
@ -1530,16 +1530,23 @@ public class HtmlHelper {
|
|
|
|
|
|
|
|
|
|
|
|
static void setViewport(Document document, boolean overview) {
|
|
|
|
static void setViewport(Document document, boolean overview) {
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
|
|
|
|
// https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag
|
|
|
|
Elements meta = document.head().select("meta").select("[name=viewport]");
|
|
|
|
Elements meta = document.select("meta").select("[name=viewport]");
|
|
|
|
|
|
|
|
// Note that the browser will recognize meta elements in the body too
|
|
|
|
if (overview) // fit width
|
|
|
|
if (overview) // fit width
|
|
|
|
meta.remove();
|
|
|
|
meta.remove();
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
if (meta.size() == 1) {
|
|
|
|
if (meta.size() == 1) {
|
|
|
|
String content = meta.attr("content")
|
|
|
|
String content = meta.attr("content");
|
|
|
|
.toLowerCase()
|
|
|
|
String[] param = content.split("[;,]");
|
|
|
|
.replace(" ", "")
|
|
|
|
for (int i = 0; i < param.length; i++) {
|
|
|
|
.replace("user-scalable=no", "user-scalable=yes");
|
|
|
|
String[] kv = param[i].split("=");
|
|
|
|
meta.attr("content", content);
|
|
|
|
if (kv.length == 2 &&
|
|
|
|
|
|
|
|
"user-scalable".equals(kv[0].replace(" ", ""))) {
|
|
|
|
|
|
|
|
kv[1] = "yes";
|
|
|
|
|
|
|
|
param[i] = TextUtils.join("=", kv);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
meta.attr("content", TextUtils.join(", ", param));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
meta.remove();
|
|
|
|
meta.remove();
|
|
|
|
document.head().prependElement("meta")
|
|
|
|
document.head().prependElement("meta")
|
|
|
|