From 8b44f930f38d70098da5793bd795400eb088a052 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 1 Apr 2013 18:00:47 +0800 Subject: [PATCH] widget and gridster fixes --- Gemfile.lock | 19 +----- app/assets/javascripts/orbitdesktop.js | 62 ++++++++++++++----- app/controllers/desktop_controller.rb | 55 +++++++++------- app/models/desktop/tile.rb | 2 + config/mongoid.yml | 2 +- .../desktop/journal_pages_controller.rb | 6 +- 6 files changed, 89 insertions(+), 57 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b104ef3ec..e8f070d7d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,6 @@ GEM execjs coffee-script-source (1.4.0) columnize (0.3.6) - curb (0.8.3) database_cleaner (0.9.1) debug_inspector (0.0.2) debugger (1.2.4) @@ -128,13 +127,6 @@ GEM multi_json (>= 1.3) rack-oauth2 (>= 0.14.4) tzinfo - feedzirra (0.0.24) - activesupport (>= 2.3.8) - builder (>= 2.1.2) - curb (>= 0.2.3) - loofah (>= 0.3.1) - nokogiri (> 0.0.0) - sax-machine (>= 0.0.12) ffi (1.4.0) haml (3.1.8) highline (1.6.15) @@ -149,8 +141,6 @@ GEM jquery-rails railties (>= 3.1.0) json (1.7.7) - loofah (1.2.1) - nokogiri (>= 1.4.4) mail (2.4.4) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -285,10 +275,8 @@ GEM railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) - sax-machine (0.1.0) - nokogiri (> 0.0.0) - select2-rails (3.3.0) - sass-rails (~> 3.2) + select2-rails (3.3.1) + sass-rails (>= 3.2) thor (~> 0.14) selenium-webdriver (2.30.0) childprocess (>= 0.2.5) @@ -368,7 +356,6 @@ DEPENDENCIES factory_girl_rails faker fb_graph - feedzirra impressionist! jquery-rails (= 2.1.4) jquery-ui-rails @@ -400,7 +387,7 @@ DEPENDENCIES rspec-rails (~> 2.0) rubyzip sass-rails - select2-rails + select2-rails (= 3.3.1) shoulda-matchers simplecov sinatra diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index f56314834..7ab2a07ce 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -378,8 +378,8 @@ var orbitDesktop = function(dom){ }; this.layout_data = function(h){ - var $e; - var column_container,layout, base_width, total_width, gutter, no_of_entries = 0, pagination_link, pagination_variable; + var $e; + var column_container,layout, base_width , no_of_entries = 0, pagination_link , pagination_variable, gutter, total_width; o.paging = true; gutter = (!isNaN(gutter)) ? gutter : 12; this.layout_data.generate_layout_html = function(l){ @@ -393,6 +393,7 @@ var orbitDesktop = function(dom){ case "simple": total_columns++; temp_div.append(column_container.html()); + total_width = "auto"; break; case "datalist": no_of_entries = (typeof column_container.attr("per-column") != "undefined"? parseInt(column_container.attr("per-column")) : 4); @@ -409,6 +410,10 @@ var orbitDesktop = function(dom){ x++; if(x == no_of_entries){ x = 0; + temp_div.append(column); + } + }) + if(x != 0){ temp_div.append(column); } } @@ -418,17 +423,16 @@ var orbitDesktop = function(dom){ entries = column_container.find("div[column=true]"),x = 0,column; if(entries.length!=0){ entries.each(function(i,ul){ - column = $("
'); var $ul = $(''); $.each(tiles,function(i,tile){ - if(row >= 4){ - row = 1; - col++; - } var shape = tile.shape.split(" "); - x = parseInt(shape[0].substr(1,1)); - y = parseInt(shape[1].substr(1,1)); + // if(tile.title == "Weather")console.log("Big - row : " + tile.row + ", col : "+ tile.column); + // if(tile.title == "Google Scholar")console.log("Scholar - row : " + tile.row + ", col : "+ tile.column); + + // if(total_x % 2 != 0) + // row = row - y; + // if(i == 7)tile.row = null; + if(tile.row){ + row = tile.row; + col = tile.column; + x = parseInt(shape[0].substr(1,1)); + y = parseInt(shape[1].substr(1,1)); + }else{ + console.log(row + " : " + col); + x = parseInt(shape[0].substr(1,1)); + if(total_x % 2 == 0){ + row = row + y; + }else if(x == 1){ + col++; + } + y = parseInt(shape[1].substr(1,1)); + total_x = total_x + ( x * y ); + prev_y = y; + if(total_x > 8){ + row = 1; + total_x = 0; + col++; + } + } var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)]; var op = opacity[Math.floor(Math.random()*opacity.length)]; var f = (tile.fullsize?"fullsize":null); @@ -839,7 +869,7 @@ var orbitDesktop = function(dom){ else $li = $('
  • Loading

    '+tile.title+'

  • '); - row = row + y; + $ul.append($li); }) diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index e61de791e..0af956217 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -141,7 +141,9 @@ class DesktopController< ApplicationController link = "http://www.wikibooks.org" end end - gr << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"title"=>title,"fullsize"=>fullsize,"link"=>link} + gr << {"id"=>tile.id,"data_category"=>tile.data_category,"data_content"=>data_content,"js"=>jsfile,"css"=>cssfile,"shape"=>shape,"position"=>tile.position,"row"=>tile.row,"column"=>tile.column, "title"=>title,"fullsize"=>fullsize,"link"=>link} + + end # gr << a end @@ -194,29 +196,36 @@ class DesktopController< ApplicationController end def newpositions - @newpositions = params["newpos"] - @section = Section.find(params["sectionid"]) - @groupids = params["groupids"] - @groups = @section.groups - z = 0 - @newpositions.each do |grp| - x = 1 - grp.each do |tileid| - if x != 1 - y = 1 - tileid.each do |id| - @tile = Tile.find(id) - @tile.update_attributes({:position => y}) - if @tile.group_id != @groupids[z] - @tile.update_attributes({:group_id => @groupids[z]}) - end - y = y + 1 - end - z = z + 1 - end - x = x + 1 - end + @newpositions = params[:newpositions] + + @newpositions.each do |t| + @this_tile = t.last + @tile = Tile.find(@this_tile['id']) + @tile.update_attributes({:row => @this_tile['row'],:column => @this_tile['col']}) end + # @newpositions = params["newpos"] + # @section = Section.find(params["sectionid"]) + # @groupids = params["groupids"] + # @groups = @section.groups + # z = 0 + # @newpositions.each do |grp| + # x = 1 + # grp.each do |tileid| + # if x != 1 + # y = 1 + # tileid.each do |id| + # @tile = Tile.find(id) + # @tile.update_attributes({:position => y}) + # if @tile.group_id != @groupids[z] + # @tile.update_attributes({:group_id => @groupids[z]}) + # end + # y = y + 1 + # end + # z = z + 1 + # end + # x = x + 1 + # end + # end b = Array.new b << {"success"=>"true"} render :json=>b.to_json diff --git a/app/models/desktop/tile.rb b/app/models/desktop/tile.rb index 1da1dedc8..13748a046 100644 --- a/app/models/desktop/tile.rb +++ b/app/models/desktop/tile.rb @@ -5,6 +5,8 @@ class Tile field :data_category field :data_content field :position, type: Integer + field :row, type: Integer + field :column, type: Integer field :shape field :fullsize, type: Boolean field :title diff --git a/config/mongoid.yml b/config/mongoid.yml index ac9bf5577..2fa55a361 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -1,5 +1,5 @@ defaults: &defaults - host: 192.168.1.105 + host: localhost # slaves: # - host: slave1.local port: 27017 diff --git a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb index 04b437d85..a6009ea66 100644 --- a/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb +++ b/vendor/built_in_modules/personal_journal/app/controllers/panel/personal_journal/desktop/journal_pages_controller.rb @@ -7,8 +7,12 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr page ||= 1 @per_column = 5 - if @view_by == "abstract" + + case @view_by + when "abstract" @per_column = 1 + when "file" + @per_column = 2 end if @view_by.nil?