widget and gridster fixes
This commit is contained in:
parent
0781779ac0
commit
bc0477a5ed
19
Gemfile.lock
19
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
|
||||
|
|
|
@ -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);
|
||||
|
@ -411,7 +412,10 @@ var orbitDesktop = function(dom){
|
|||
x = 0;
|
||||
temp_div.append(column);
|
||||
}
|
||||
});
|
||||
})
|
||||
if(x != 0){
|
||||
temp_div.append(column);
|
||||
}
|
||||
}
|
||||
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
|
||||
break;
|
||||
|
@ -419,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 = $("<div class='column type_column' style='width:"+base_width+"px;margin-right:"+gutter+"px;padding-right:"+gutter+"px;'></div");
|
||||
column = $("<div class='column type_column' style='width:"+base_width+"px;margin-right:"+gutter+"px;padding-right:"+gutter+"px;'></div");
|
||||
total_columns++;
|
||||
column.append(ul);
|
||||
x++;
|
||||
temp_div.append(column);
|
||||
});
|
||||
})
|
||||
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
|
||||
}
|
||||
total_width = (!isNaN(base_width)) ? (base_width + gutter*2 +1) * total_columns : null;
|
||||
break;
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
// total_width = (!isNaN(base_width) ? ( base_width + 12 ) * total_columns : null);
|
||||
|
@ -716,7 +719,8 @@ var orbitDesktop = function(dom){
|
|||
.gridster({
|
||||
widget_margins: [6, 6],
|
||||
widget_base_dimensions: [120, 120],
|
||||
// avoid_overlapped_widgets: true,
|
||||
// avoid_overlapped_widgets: true,
|
||||
serialize_params: function($w, wgd) { return { col: wgd.col, row: wgd.row, id: $w.data("id") } },
|
||||
draggable : {
|
||||
start : function(event, ui){
|
||||
dragged.addClass("noClick");
|
||||
|
@ -769,6 +773,9 @@ var orbitDesktop = function(dom){
|
|||
})
|
||||
|
||||
}
|
||||
var newpos = o.gridvar.serialize();
|
||||
console.log(newpos);
|
||||
$.post("/desktop/newpositions",{"newpositions":newpos});
|
||||
}
|
||||
}
|
||||
}).data('gridster');
|
||||
|
@ -815,32 +822,54 @@ var orbitDesktop = function(dom){
|
|||
var loadTiles = function(id){ //This will load tiles for a specific desktop .. id of section has to be passed here to load tiles
|
||||
$("div#desktop div#group_wrapper").empty();
|
||||
$.getJSON("/desktop/getgroups",{sectionid:id},function(tiles){
|
||||
tiles.sort(o.sortJSON("position",true,parseInt));
|
||||
// tiles.sort(o.sortJSON("position",true,parseInt));
|
||||
var tilecolors = o.themesettings.tilecolor;
|
||||
var totaltiles_in_a_row = 4;
|
||||
var opacity = ["op07","op08","op09",""];
|
||||
var row = 1,col = 1,x = 1,y = 1;
|
||||
var row = 0,col = 1,x = 1,y = 1,total_x = 0,prev_y = 0;
|
||||
var $group = $('<div class="grid gridster"></div>');
|
||||
var $ul = $('<ul style="margin: -6px 0 0 -6px;"></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);
|
||||
|
||||
if(tile.data_category == "app")
|
||||
$li = $('<li data-id="'+tile.id+'" class="app" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-title="'+tile.title+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'"><span class="tile '+tilecolor+' '+op+'"></span><a href="'+tile.data_content+'" class="appicon" onclick="return false;" data-url="'+tile.link+'"><img src="'+o.iconPath+tile.data_content+'.png" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
else
|
||||
$li = $('<li data-id="'+tile.id+'" class="widget '+f+'" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"><div class="thmtxt o-loading"><i class="icon-spinning icon-spinner"></i> Loading</div></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
else
|
||||
$li = $('<li data-id="'+tile.id+'" class="widget '+f+'" data-row="'+row+'" data-col="'+col+'" data-sizex="'+x+'" data-sizey="'+y+'" data-category="'+tile.data_category+'" data-content="'+tile.data_content+'" js-link="'+tile.js[0].url+'" css-link="'+tile.css.url+'"><span class="tile '+tilecolor+' '+op+'"></span><div class="appholder"><div class="thmtxt all-loading"><i class="icon-spinner icon-spin"></i> Loading </div></div><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||
|
||||
row = row + y;
|
||||
|
||||
|
||||
$ul.append($li);
|
||||
})
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -6,13 +6,13 @@ class Panel::PersonalJournal::Desktop::JournalPagesController < ApplicationContr
|
|||
page = params[:page]
|
||||
page ||= 1
|
||||
|
||||
@per_column = 5
|
||||
|
||||
case @view_by
|
||||
when "abstract"
|
||||
@per_column = 1
|
||||
when "file"
|
||||
@per_column = 2
|
||||
else
|
||||
@per_column = 4
|
||||
end
|
||||
|
||||
if @view_by.nil?
|
||||
|
|
Loading…
Reference in New Issue