tinyscrollbar pagination fixed

This commit is contained in:
Harry Bomrah 2013-03-12 11:18:32 +08:00 committed by Matt K. Fu
parent aad4119892
commit 41643d1f61
2 changed files with 105 additions and 56 deletions

View File

@ -50,6 +50,8 @@ var orbitDesktop = function(dom){
this.sectionList; this.sectionList;
this.data_method; this.data_method;
this.gridvar = null; this.gridvar = null;
this.lastlink= null;
this.tinyscrollbar = null;
this.initialize = function(){ this.initialize = function(){
var theme = o.theme; var theme = o.theme;
@ -281,15 +283,22 @@ var orbitDesktop = function(dom){
}) })
}; };
this.layout_data = function(h){ this.layout_data = function(h){
var $e = $("<div></div>"); var $e;
$e.html(h); var column_container,layout, base_width , no_of_entries, pagination_link , pagination_variable;
var column_container = $e.find("div.overview"); o.paging = true;
var layout = column_container.attr("content-layout"), base_width = parseInt(column_container.attr("base-width")), no_of_entries,temp_div = $("<div></div>"),total_columns=0; this.layout_data.generate_layout_html = function(l){
$e = $("<div></div>");
$e.html(l);
column_container = $e.find("div.overview");
layout = column_container.attr("content-layout"), base_width = parseInt(column_container.attr("base-width")), no_of_entries,total_columns=0, pagination_link = column_container.attr("pagination-link"), pagination_variable = column_container.attr("pagination-var");
var temp_div = $("<div></div>");
switch (layout){ switch (layout){
case "simple": case "simple":
total_columns++; total_columns++;
temp_div.append(column_container.html()); temp_div.append(column_container.html());
var entries = [];
break; break;
case "datalist": case "datalist":
no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4); no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4);
@ -308,6 +317,9 @@ var orbitDesktop = function(dom){
temp_div.append(column); temp_div.append(column);
} }
}) })
if(x != 0){
temp_div.append(column);
}
break; break;
case "column": case "column":
var entries = column_container.find("div[column=true]"),x = 0,column; var entries = column_container.find("div[column=true]"),x = 0,column;
@ -320,20 +332,56 @@ var orbitDesktop = function(dom){
}) })
break; break;
} }
var w = (!isNaN(base_width) ? base_width * total_columns : null);
return {"markup":temp_div.html(),"width":w,"total":entries.length};
}
$("div[container=true]").html(h).find("div.overview").wrap('<div class="tinycanvas vp"><div class="viewport"></div></div>'); $("div[container=true]").html(h).find("div.overview").wrap('<div class="tinycanvas vp"><div class="viewport"></div></div>');
$("div[container=true]").find("div.tinycanvas").prepend('<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>'); $("div[container=true]").find("div.tinycanvas").prepend('<div class="scrollbar sb_h vp"><div class="track"><div class="thumb thmc2"><div class="end"></div></div></div></div>');
$("div[container=true] div.overview").html(temp_div.html()); var f = o.layout_data.generate_layout_html(h)
if(isNaN(base_width)){ $("div[container=true] div.overview").html(f.markup);
o.tinyscrollbar_ext({ var settings = {main : ".tinycanvas"};
main : ".tinycanvas", var tsettings = {};
}) if(f.width){
}else{ settings.fill = f.width;
o.tinyscrollbar_ext({ }
main : ".tinycanvas", if(pagination_variable){
fill : base_width * total_columns var page_no = 1;
}) tsettings.onMove = function(x){
if(x < 50){
if(!pagination_link)
pagination_link = o.lastlink;
if(o.paging){
page_no++;
o.paging = false;
o.pagination(pagination_link,pagination_variable,page_no);
} }
} }
}
}
o.tinyscrollbar_ext(settings,tsettings);
}
this.paging = true;
this.pagination = function(link,variable,page_no){
var retvalue = null;
$.ajax({
url : link + "?"+variable + "=" + page_no,
type : "get",
success : function(html){
var f = o.layout_data.generate_layout_html(html);
// console.log(f.total)
if(f.total > 0){
$("div[container=true] div.overview").append(f.markup);
if(f.width){
var w = $("div[container=true] div.overview").width();
$("div[container=true] div.overview").width(w+f.width);
}
o.tinyscrollbar.tinyscrollbar_update("relative");
o.paging = true;
}else{o.paging = false;}
}
})
}
this.insert_new_column = function(index){ this.insert_new_column = function(index){
var column_container = $("div[container=true] div.overview"),layout = column_container.attr("content-layout"),base_width = parseInt(column_container.attr("base-width")),column; var column_container = $("div[container=true] div.overview"),layout = column_container.attr("content-layout"),base_width = parseInt(column_container.attr("base-width")),column;
var i = (index == 0? 0 : index-1); var i = (index == 0? 0 : index-1);
@ -387,6 +435,7 @@ var orbitDesktop = function(dom){
if(!customload)customload=false; if(!customload)customload=false;
var target = dom.attr("id"); var target = dom.attr("id");
var url = dom.attr("href"); var url = dom.attr("href");
o.lastlink = url;
o.data_method = dom.attr("callback-method"); o.data_method = dom.attr("callback-method");
if(o.currenthtml!=target){ if(o.currenthtml!=target){
if(o.desktopData[o.currentface] == "undefined") if(o.desktopData[o.currentface] == "undefined")
@ -442,6 +491,7 @@ var orbitDesktop = function(dom){
this.sub_menu_item = function(dom,data){ this.sub_menu_item = function(dom,data){
var sub_data_method = dom.attr('callback-method'); var sub_data_method = dom.attr('callback-method');
if(sub_data_method){ if(sub_data_method){
o.lastlink = dom.attr("href");
$.ajax({ $.ajax({
url : dom.attr("href"), url : dom.attr("href"),
type : "get", type : "get",
@ -1384,14 +1434,14 @@ var orbitDesktop = function(dom){
//tinysettings : tinyscrollbar settings //tinysettings : tinyscrollbar settings
if(typeof target.main == "undefined"){ if(typeof target.main == "undefined"){
o.notify('tinyscrollbar: target undefined','imp',2); o.notify('Tinyscrollbar: target undefined','imp',2);
return; return;
}else{ }else{
target.main = $(target.main); target.main = $(target.main);
} }
//var target.fill = $
var tinysettings = ( typeof tinysettings == 'undefined' ) ? {"axis":"x"} : tinysettings ;
var settings = {"axis":"x"};
$.map(tinysettings,function(val,i){ settings[i] = val })
var count,baseWidth,fillArray,pxs; var count,baseWidth,fillArray,pxs;
if( typeof target.fill == 'string' ){ if( typeof target.fill == 'string' ){
@ -1400,20 +1450,17 @@ var orbitDesktop = function(dom){
// baseWidth = $(target.fill).eq(1).outerWidth(true); // baseWidth = $(target.fill).eq(1).outerWidth(true);
// target.main.find('.overview').width( baseWidth * count); // target.main.find('.overview').width( baseWidth * count);
} else if( typeof target.fill == 'number' ){ } else if( typeof target.fill == 'number' ){
target.main.find('.overview').width( target.fill ); target.main.find('.overview').width( target.fill );
} else if( typeof target.fill == 'undefined' ){ } else if( typeof target.fill == 'undefined' ){
} else { } else {
o.notify('tinyscrollbar: setting width failed','imp',2); o.notify('Tinyscrollbar: setting width failed','imp',2);
} }
if(target.height){ if(target.height){
target.main.height(target.height); target.main.height(target.height);
} }
target.main o.tinyscrollbar = target.main.tinyscrollbar( settings );
.tinyscrollbar( tinysettings )
.find('.scrollbar');
}; };
this.simple_drop_down = function(){ this.simple_drop_down = function(){
// simple dropdown menu // simple dropdown menu

View File

@ -13,9 +13,11 @@ end
FactoryGirl.create(:journal_co_author_relation) FactoryGirl.create(:journal_co_author_relation)
end end
4.times do
50.times do 50.times do
FactoryGirl.create(:writing_journal) FactoryGirl.create(:writing_journal)
end end
end
50.times do 50.times do
FactoryGirl.create(:journal_co_author) FactoryGirl.create(:journal_co_author)