function fgPanel() {
|
this.panel = $('.fg-panel');
|
this.content = this.panel.find('.fg-panel-content');
|
this.btn = this.panel.find('.fg-panel-btn');
|
}
|
|
fgPanel.prototype.show = function() {
|
// 初始化面板高度
|
var srn = $.mobile.getScreenHeight(); // 屏幕的高度
|
|
// 生成面板左侧的遮罩层
|
var mask = $('<div class="fg-panel-mask" onclick="panel.hide();"></div>');
|
mask.css({
|
'height': srn + 'px'
|
});
|
// 判断panel所在的页面是否展示
|
if(this.panel.parent().hasClass('ui-page-active')) {
|
$('div[data-role="page"]').append(mask);
|
|
// 定义面板的高度并显示面板
|
this.panel.height(srn - 16);
|
this.content.height(srn - 96);
|
this.panel.animate({'right': 0},500);
|
}
|
|
}
|
fgPanel.prototype.hide = function(isTop) {
|
if(isTop != undefined || isTop == true) {
|
$(document).scrollTop(0);
|
}
|
$('.fg-panel-mask').remove();
|
this.panel.animate({'right': '-80%'},500);
|
}
|
var panel = new fgPanel();
|
|
// 当横屏和竖屏切换时更改面板的高度
|
$(window).on("orientationchange",function(){
|
setTimeout(function() {
|
var srnWidth = $(window).width();
|
var posR = panel.panel.offset().left;
|
if(srnWidth > posR) {
|
panel.show();
|
}
|
}, 200);
|
});
|