From 41643d1f61dcc1ef82eedc6bb7a69d05aadbd464 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 12 Mar 2013 11:18:32 +0800 Subject: [PATCH] tinyscrollbar pagination fixed --- app/assets/javascripts/orbitdesktop.js | 155 ++++++++++++------ .../personal_journal/db/seeds.rb | 6 +- 2 files changed, 105 insertions(+), 56 deletions(-) diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index f766802fa..3bf5f91e8 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -50,6 +50,8 @@ var orbitDesktop = function(dom){ this.sectionList; this.data_method; this.gridvar = null; + this.lastlink= null; + this.tinyscrollbar = null; this.initialize = function(){ var theme = o.theme; @@ -281,59 +283,105 @@ var orbitDesktop = function(dom){ }) }; + this.layout_data = function(h){ - var $e = $("
"); - $e.html(h); - var column_container = $e.find("div.overview"); - var layout = column_container.attr("content-layout"), base_width = parseInt(column_container.attr("base-width")), no_of_entries,temp_div = $("
"),total_columns=0; - switch (layout){ - case "simple": - total_columns++; - temp_div.append(column_container.html()); - break; - case "datalist": - no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4); - var height_percentage = 100/no_of_entries; - var entries = column_container.find("li[item=true]"),x = 0; - entries.each(function(i,li){ - if(x == 0){ - column = $("
"); + $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 = $("
"); + switch (layout){ + case "simple": + total_columns++; + temp_div.append(column_container.html()); + var entries = []; + break; + case "datalist": + no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4); + var height_percentage = 100/no_of_entries; + var entries = column_container.find("li[item=true]"),x = 0; + entries.each(function(i,li){ + if(x == 0){ + column = $("
'); $("div[container=true]").find("div.tinycanvas").prepend('
'); - $("div[container=true] div.overview").html(temp_div.html()); - if(isNaN(base_width)){ - o.tinyscrollbar_ext({ - main : ".tinycanvas", - }) - }else{ - o.tinyscrollbar_ext({ - main : ".tinycanvas", - fill : base_width * total_columns - }) + var f = o.layout_data.generate_layout_html(h) + $("div[container=true] div.overview").html(f.markup); + var settings = {main : ".tinycanvas"}; + var tsettings = {}; + if(f.width){ + settings.fill = f.width; } + if(pagination_variable){ + 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){ 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); @@ -387,6 +435,7 @@ var orbitDesktop = function(dom){ if(!customload)customload=false; var target = dom.attr("id"); var url = dom.attr("href"); + o.lastlink = url; o.data_method = dom.attr("callback-method"); if(o.currenthtml!=target){ if(o.desktopData[o.currentface] == "undefined") @@ -442,6 +491,7 @@ var orbitDesktop = function(dom){ this.sub_menu_item = function(dom,data){ var sub_data_method = dom.attr('callback-method'); if(sub_data_method){ + o.lastlink = dom.attr("href"); $.ajax({ url : dom.attr("href"), type : "get", @@ -1384,14 +1434,14 @@ var orbitDesktop = function(dom){ //tinysettings : tinyscrollbar settings if(typeof target.main == "undefined"){ - o.notify('tinyscrollbar: target undefined','imp',2); + o.notify('Tinyscrollbar: target undefined','imp',2); return; }else{ 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; if( typeof target.fill == 'string' ){ @@ -1400,20 +1450,17 @@ var orbitDesktop = function(dom){ // baseWidth = $(target.fill).eq(1).outerWidth(true); // target.main.find('.overview').width( baseWidth * count); } else if( typeof target.fill == 'number' ){ - target.main.find('.overview').width( target.fill ); } else if( typeof target.fill == 'undefined' ){ } else { - o.notify('tinyscrollbar: setting width failed','imp',2); + o.notify('Tinyscrollbar: setting width failed','imp',2); } if(target.height){ target.main.height(target.height); } - target.main - .tinyscrollbar( tinysettings ) - .find('.scrollbar'); + o.tinyscrollbar = target.main.tinyscrollbar( settings ); }; this.simple_drop_down = function(){ // simple dropdown menu diff --git a/vendor/built_in_modules/personal_journal/db/seeds.rb b/vendor/built_in_modules/personal_journal/db/seeds.rb index c9de3f1cd..ceb5035a7 100644 --- a/vendor/built_in_modules/personal_journal/db/seeds.rb +++ b/vendor/built_in_modules/personal_journal/db/seeds.rb @@ -13,8 +13,10 @@ end FactoryGirl.create(:journal_co_author_relation) end -50.times do - FactoryGirl.create(:writing_journal) +4.times do + 50.times do + FactoryGirl.create(:writing_journal) + end end 50.times do