NavHeader_wev8.js
2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
define(['mUtil', "Component", "mApi/popup"],function(mUtil, Component, popup) {
var NavHeader = function(options) {
Component.super(this, options);
this.type = "NavHeader";
this.tpl = this.type + "_html";
this.css = this.type + "_css";
var vm = this.viewModel = {
title: "", // 标题
smallTitle: "", // 小标题
btns: [], // 按钮组
isFixedTop: false, // 是否固定在顶部
click: mUtil.back // 标题单击事件
};
this.mounted = function(){
var that = this;
var $page = this.$container,
$abbr = this.$el,
$comp = $abbr.children(".wev-comp-" + vm.compType);
// 单击事件绑定
$('.wev-navheader-title', $comp).click(function(){
mUtil.eval(vm.click, that.pageid);
});
// 按钮单击事件
$comp.on("click", ".btn", function(e){
var index = $(this).index(),
btn = vm.btns[index];
if(btn && btn.click){
mUtil.eval(btn.click, that.pageid);
} else if(btn && btn.menu){
var openStyle = btn.menu.openStyle || '1';
var showWay = btn.menu.showWay || '1';
var settings = $.extend(btn.menu, {mec_id: that.id, btn_id: btn.btn_id, pageid: that.pageid});
if(openStyle == '1' && showWay == '1'){
popup.footerMenu(settings);
} else if(openStyle == '1' && showWay == '2'){
popup.footerMenu($.extend(settings, {layout: 'panel'}));
} else {
popup.dropDownMenu(settings, $(this));
}
e.stopPropagation();
}
});
if(!vm.isFixedTop) return;
// 固定导航头顶部
this.$once("moveComponent", function(){
var $header = $page.children(".page-header");
var $content = $page.children(".page-content");
if (!$header.length) {
$header = $("<div class='page-header'></div>");
$content.before($header);
}
if (!$abbr.parent().hasClass("page-header")) {
$abbr.find("script").remove();
$header.append($abbr);
}
if($header.height()){
$header.attr("header-height", $header.height());
$content.css("top", $header.height() + "px");
}else{
if($header.attr("header-height")){
$content.css("top", $header.attr("header-height") + "px");
}else{
$content.css("top", "0px");
}
}
});
};
};
return Component.init(NavHeader);
});