alone.js 2.19 KB
/**
 * 单线路调度
 */

var _alone = (function(){
	//暂时用文字判断上下行
	var upCode = '上行'
		,downCode = '下行';
	
	var aloneObject = {
		init: function(){
			_data.queryRealSchedule(lineCodes, function(schList){
				for(var lineCode in schList){
					//按上下行拆分数据
					var rs = splitDir(schList[lineCode])
						,htmlStr = template('alone_main_temp', {up: rs.up, down: rs.down});
					
					$('#tab_line_' + lineCode).append(htmlStr).find('._body')
					//滚动条	
					.slimscroll({
							height: 'calc(100% - 80px)',
							alwaysVisible: true
					});
					
					//底部svg
					_data.queryStationRoute(lineCode , 'lineSvg' + lineCode , drawSvg.init);
				}
				//绑定右键菜单事件
				_menu.bindClickMenu();
				
				$('.console-log .log-item-list').slimscroll({
					height: '100%'
				})
				//托管Question
				$('#tgQuestion').popover({
					content: template('tg_question_info_temp', {}),
					html: true,
					placement: 'left',
					trigger: 'hover',
					container: '.portlet-fullscreen'
				});
				
				//备注POPOVER
				$('.remarks-popover').popover({trigger: 'hover',container: '.portlet-fullscreen',placement:'bottom'});
			});
			
			//$('.tab-pane.aloneline')
			/*_data.queryStationRoute('10904' , 'lineSvg10904' , drawSvg.init);
			*/
		},
		//刷新班次
		refreshSchedule: function(schedule){
			//xlBm
			var tr = $('tr[data-id='+schedule.id+']', '#tab_line_' + schedule.xlBm)[0]
				,cells = tr.cells, name;
			
			$.each(cells, function(i, cell){
				name = $(cell).data('name');
				if(name == 'remarks'){
					var link = $(cell).find('a');
					if(link.length == 0){
						$(cell).append('<a class="remarks-popover" href="javascript:;" data-toggle="popover" data-content="'+schedule[name]+'" >备注</a>')
					}
					else{
						link.attr('data-content', schedule[name]);
					}
				}
				else{
					$(cell).text(schedule[name]);
				}
			});
		}
	}
	
	function splitDir(list){
		var rs = {up: [], down: []};
		$.each(list, function(){
			if(this.xlDir == upCode)
				rs.up.push(this);
			else
				rs.down.push(this);
		});
		
		return rs;
	}
	
	return aloneObject;
})();