aboutsummaryrefslogtreecommitdiffstats
path: root/97suifang-front/assets/js/new_delete_index.js
blob: 8fc46e88abd10d3ae67608374a1ff0fd7b461967 (plain)
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
var select_letter = '';
var select_index_obj = null;
$(document).ready(function(){
	$(".index_type").each(function(){
		if($(this).hasClass("selected")){
			select_index_obj = $(this);
			return false;
		}
	});
	$(".index_type").hover(
		function(){
			$(this).addClass("selected");
		},
		function(){
			if(!$(this).is(select_index_obj)){
				$(this).removeClass("selected");
			}
		}
	);
	
	/************************ 登录控件交互 Start ********************************/
	$(".drop-down-area").bind("click", function(){
		var drop_down_menu = $(".drop-down-menu");
		if(drop_down_menu.hasClass("open")){
			drop_down_menu.removeClass("open");
		}else{
			drop_down_menu.addClass("open");
		}
		return false;
	});
	$("body").bind("click", function(){
		$(".drop-down-menu").removeClass("open");
	});
	/************************ 登录控件交互 Start ********************************/
	
	
	$("#search_btn").bind("click", function(){
		var kw = $("#search_kw").val();
		window.location.href = '?kw='+kw;
		return false;
	});
	$(".left>.index_line, .index_letter_container>.index_lines>.index_line").each(function(){
		classHover($(this), "add");
	});
	$(".right>.index_line").each(function(){
		classHover($(this), "minus");
	});
	$(".add>.icon").live("click", function(){
		var add_icon = $(this);
		var index_id = add_icon.closest(".index_line").attr("index_id");
		var date = new Date();
		var time = date.getTime();
		$.ajax({
			type: 'get',
			url: '../ajax/act_index',
			data: 'index_id='+index_id+'&act=add'+'&time='+time,
			success: function(data){
				if(data == 'success'){
					var obj = add_icon.parent();
					var objClone = obj.clone();
					objClone.removeClass("add")
					objClone.children(".index_category").remove();
					$(".right").append(objClone);
					classHover(objClone, "minus");
				}
			}
		});
		
		return false;
	});
	$(".minus>.icon").live("click", function(){
		var minus_icon = $(this);
		var index_id = minus_icon.closest(".index_line").attr("index_id");
		var date = new Date();
		var time = date.getTime();
		$.ajax({
			type: 'get',
			url: '../ajax/act_index',
			data: 'index_id='+index_id+'&act=minus'+'&time='+time,
			success: function(data){
				var obj = minus_icon.parent();
				obj.remove();
			}
		});
		
		return false;
	});
	$(".all_condition>.index_all_letter>div").bind("click", function(){
		$(".letter_selected").removeClass("letter_selected");
		$(this).addClass("letter_selected");
		var container = $(".index_letter_container");
		var letterClass = $(this).text();
		var scrollTo = $("."+letterClass);
		container.scrollTop(scrollTo.offset().top - container.offset().top + container.scrollTop());
		select_letter = letterClass;
		return false;
	});
	$(".all_condition>.index_all_letter>div").hover(
		function(){
			$(this).addClass("letter_selected");
		},
		function(){
			if(select_letter != $(this).text()){
				$(this).removeClass("letter_selected");
			}
		}
	);
	$("#submitIndexBtn").bind("click", function(){
		var commit_index = '';
		$(".right>.index_line").each(function(){
			commit_index += $(this).attr("index_id")+',';
		});
		$("#commit_index").val(commit_index);
		$("#index_form").submit();
		return false;
	});
});
function classHover(obj, c){
	obj.hover(
		function(){
			$(this).addClass(c);
		},
		function(){
			$(this).removeClass(c);
		}
	);
}