全屏功能开发:
1 定义web模板 t-name=”WebFullScreen”,预置全屏和退出全屏的a标签,退出全屏默认隐藏
<?xml version="1.0" encoding="UTF-8" ?>
<template xml:space="preserve" >
<t t-name="WebFullScreen">
<li>
<a class="full_screen" href="#">全屏</a>
</li>
<li><a style="display:none" class="not_full_screen" href="#">退出全屏</a></li>
</t>
</template>
2 通过js加载模块,并注册到系统工具栏
FullScreenMenu.prototype.sequence = 0; # 排序位置
SystrayMenu.Items.push(FullScreenMenu);
3 通过点击事件触发方法
odoo.define('web_full_screen.FullScreen', function (require) {
"use strict";
var Widget = require('web.Widget');
var SystrayMenu = require('web.SystrayMenu');
var FullScreenMenu = Widget.extend({
template: 'WebFullScreen',
events: {
'click .not_full_screen': '_onNotFullScreen',
'click .full_screen': '_onFullScreen',
},
_onNotFullScreen: function () {
var de = document;
if(de.exitFullScreen) {
de.exitFullScreen();
} else if(de.mozCancelFullScreen) {
de.mozCancelFullScreen();
} else if(de.webkitExitFullscreen) {
de.webkitExitFullscreen();
} else if(de.msExitFullscreen) {
de.msExitFullscreen();
}
var $full_screen = document.getElementsByClassName('full_screen')[0]
var $not_full_screen = document.getElementsByClassName('not_full_screen')[0]
this.do_notify("退出网页版全屏.");
$not_full_screen.style.display = 'none';
$full_screen.style.display = 'block';
},
_onFullScreen: function () {
var de = document.documentElement;
if (de.requestFullscreen) {
de.requestFullscreen();
} else if (de.mozRequestFullScreen) {
de.mozRequestFullScreen();
} else if (de.webkitRequestFullScreen) {
de.webkitRequestFullScreen();
} else if (de.msRequestFullscreen) {
de.msRequestFullscreen();
}
var $full_screen = document.getElementsByClassName('full_screen')[0]
var $not_full_screen = document.getElementsByClassName('not_full_screen')[0]
$not_full_screen.style.display = 'block';
$full_screen.style.display = 'none';
this.do_notify("进入网页版全屏.");
},
});
FullScreenMenu.prototype.sequence = 0; // force UserMenu to be the right-most item in the systray
SystrayMenu.Items.push(FullScreenMenu);
return FullScreenMenu;
});