common.js
3.27 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
define(function( require, exports, module ) {
/*
引入包
*/
var _Base = require( 'base' ),
_Defval = require( 'defval' ),
//_Jselect = require( 'jselect' ),
_Scrollfixed = require( 'scrollfixed' ),
_Event = require( 'event' ),
_Qsearch = require( 'qsearch' ),
_Simpletree = require( 'simpleTree' );
require( 'validate' );
require('validate.extend');
require( 'mousewheel' );
require( 'fancybox' );
$(function(){
//图片延时加载
// $("body").find("img").each(function(){
// $(this).lazyload({
// effect : "fadeIn",
// skip_invisible : false
// });
// });
_Base.lazyload($("img"), 0);
//溢出页面加载loading
if( $( '#s-page-loading' ).length > 0 ){
$( '#s-page-loading' ).remove();
}
//文本框默认提示
$( 'input[defval], textarea[defval]' ).each(function() {
new _Defval( this , {
fontColor:'#ccc'
});
});
//文本框搜索下拉
if( $( '.search-bar input[type="text"]' ).length > 0 ){
$( '.search-bar input[type="text"]' ).each( function(){
new _Qsearch( this , {
form: $( this ).parents( '.search-bar').find( 'form' ),
submitLocked: false,
loading : '',
ajaxUrl : search_ajaxUrl,
searchBefore:function(){
$( '.cat li' ).click(function(){
$('.goods1').attr( 'name' , $( this ).find( 'span' ).text() );
});
return '&typekey='+$('.goods1').attr( 'name' );
}
});
});
}
//下拉列表模拟
if( $( '.s-select' ).length > 0 ){
$( '.s-select' ).each( function(){
new _Jselect( this , {} );
});
}
//表单验证
if( $( '.s-validate' ).length > 0 ){
require.async(['validate.extend'], function() {
$( '.s-validate' ).validate({});
});
}
//搜索框操作
//选择店铺商品
if ( $( ".search-bar" ).length > 0 ){
$(".cat p").click(function(){
$(".cat").addClass("choose");
return false;
});
//确认搜索分类选择
$(".cat li").live("click", function(){
$(".cat").removeClass("choose");
var text = $(this).find("span").html();
$(".cat p").html($(this).find("span").html());
$(".cat ul").html('');
if(text != "店铺"){
$(".cat ul").append('<li><span>产品</span></li><li class="more"><span>店铺</span></li>');
}else{
$(".cat ul").append('<li><span>店铺</span></li><li class="more"><span>产品</span></li>');
};
});
//搜索更多历史记录
$(".search-bar input").focus(function(){
$(this).parents().next().stop().slideDown(200);
});
$(".search-list a").live("click", function(){
$(".search-list").stop().slideUp(200);
$(".search-bar input").val($(this).html());
return false;
});
$(document).bind("click",function(e){
var target = $(e.target);
if(target.closest(".search-bar .cat").length == 0){
$(".search-bar .cat").removeClass("choose");
}
})
}
//多级列表
if ( $( ".menutree" ).length > 0 ){
$( '.menutree' ).each(function(){
new _Simpletree( this , {
handler: ">div",//操作对象
toggleClass: "title-selected",//class切换
showtarget: ".show-menu",//展示的子菜单对象
currentClass: ".on"//子菜单的选中状态
});
});
}
});
});