日期:2014-05-16 浏览次数:20395 次
var viewBasic = {
container:"#data-box",
options:{
option:null,
product_type:'pc',
list_type:'harvesting',
resource_type:'tmr',
Period_time:null
},
scroll:function(scrollId){
return new iScroll(scrollId, {snap: 'li',momentum: false,hScroll:true,hScrollbar: false,vScrollbar: false });
}
};
function tickerPage(){
this.url = '';
this.columns=['AUTO','LIFE'];
this.players=[null,null];
this.scrolls=[null,null];
};
tickerPage.prototype = viewBasic;
tickerPage.prototype.afterEnd = function(){
this.tickerDataDemo();
/*初始化 滚动条 */
var o = this;
setTimeout(function(){
for(var i=0; i< o.columns.length; i++){
o.scrolls[i] = o.scroll('listScroller_'+i);
}
},300);
};
tickerPage.prototype.tickerDataDemo = function(){
var o = this,str = "";
str +=' <div id="data-list">';
for(var i=0; i< o.columns.length; i++){
str +=' <div class="data-list-item">';
str +=' <div class="data-list-bar">';
str +=' <label>'+o.columns[i]+'</label>';
str +=' </div>';
str +=' <div class="data-list-content">';
str +=' <div class="wrapper" id="listScroller_'+i+'">';
str +='<div class="scroller"><ul></ul></div>';
str +=' </div>';
str +=' </div>';
str +=' </div>';
}
str +=' </div>';
$(this.container).html(str);
/* 模拟数据 begin*/
var dom = new Array;
for(var j=0; j<20; j++){
dom.pushu( "<li>test example ...</li>")
}
/* 模拟数据 end*/
for(var i=0; i<2; i++){
o.addItems(i,dom)
}
}
tickerPage.prototype.addItems = function(i,dom){
var o = this,target = $("#listScroller_"+i+" > .scroller:first");
var elms = "",w = target.width();
for(var n=0; n<dom.length; n++){
elms += dom[n];
}
/*
1:向前填充数据
2:修改上下错落样式 --> 修改容器宽度
3:滚动条移动到第一个元素
*/
$("ul:first",target).prepend(elms);
o.setItemsPadding(target);
var unitWidth = $("li",target).length == 0 ? 0:$("li:first",target).width();
var wrapperWidth = w + unitWidth * dom.length;
target.width(wrapperWidth);
if(o.scrolls[i]){
o.scrolls[i].refresh;
o.scrolls[i].scrollToElement('li:nth-child(1)',800);
}
}
var view =&n