solved desktop conflict during cherry pick

This commit is contained in:
Harry Bomrah 2013-05-02 16:45:33 +08:00 committed by saurabhbhatia
parent 874819266d
commit 2d616ab7a8
9 changed files with 198 additions and 36 deletions

View File

@ -612,6 +612,7 @@ var orbitDesktop = function(dom){
} }
} }
this.sub_menu_item = function(dom,data){ this.sub_menu_item = function(dom,data){
console.log(dom)
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"); o.lastlink = dom.attr("href");
@ -819,6 +820,7 @@ var orbitDesktop = function(dom){
this.initializeAppManager = function(target,url,cache){ //this is application search ie is app manager initialization this.initializeAppManager = function(target,url,cache){ //this is application search ie is app manager initialization
var searchArray, allApps; var searchArray, allApps;
var bindHandlers = function(){ // bind handler for app manager page var bindHandlers = function(){ // bind handler for app manager page
// var gn = $('.g_col').length, // var gn = $('.g_col').length,
// gw = $('.g_col').outerWidth(true); // gw = $('.g_col').outerWidth(true);
@ -826,7 +828,12 @@ var orbitDesktop = function(dom){
// $("div#app_manager .group_search").css("width",$(window).width()-200); // $("div#app_manager .group_search").css("width",$(window).width()-200);
//for textbox search //for textbox search
var $elements = $("#app_manager .element"), var $elements = $("#app_manager .element"),
$result = $("#app_manager .search_result"); $result = $("#app_manager .search_result"),
$appinfo = $("#app_info"),
$apptitle = $("#app_info .app_info_name"),
$appicon = $("#app_info .app_info_icon")
$appinfolist = $("#app_info .app_info_list");
$("#app_manager #searchbox") $("#app_manager #searchbox")
.focus(function(){ .focus(function(){
$(this).val(""); $(this).val("");
@ -849,8 +856,8 @@ var orbitDesktop = function(dom){
if(i == 1){ if(i == 1){
$column = $('<div class="g_col g_col_w1"></div>'); $column = $('<div class="g_col g_col_w1"></div>');
} }
var $newelement = $('<div class="element w1 h1 thmc2">'+$(this).html()+'</div>'); $column.append($(this));
$column.append($newelement); $(this).show();
if(i == 4){ if(i == 4){
$result.append($column); $result.append($column);
i = 0; i = 0;
@ -859,6 +866,7 @@ var orbitDesktop = function(dom){
if(i != 0){ if(i != 0){
$result.append($column); $result.append($column);
} }
elementSetting();
} else { } else {
$result.text("No Result Found."); $result.text("No Result Found.");
} }
@ -877,11 +885,11 @@ var orbitDesktop = function(dom){
switch ($(this).attr("href")){ switch ($(this).attr("href")){
case "ascending": case "ascending":
$(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]"); $(this).attr("href","descending").find(".thmtxt").text("Alphabet [Z-A]");
allApps = $("div#app_manager .group_search .element").sort(sortAscending); allApps = $("div#app_manager .element").sort(sortAscending);
break; break;
case "descending": case "descending":
$(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]"); $(this).attr("href","ascending").find(".thmtxt").text("Alphabet [A-Z]");
allApps = $("#app_manager .group_search .element").sort(sortDescending); allApps = $("#app_manager .element").sort(sortDescending);
break; break;
} }
$("#app_manager #app_list").empty(); $("#app_manager #app_list").empty();
@ -897,25 +905,85 @@ var orbitDesktop = function(dom){
$('.g_col.col'+ colindex).append(app); $('.g_col.col'+ colindex).append(app);
} }
}); });
elementSetting();
return false; return false;
}); });
$(window).on('keydown', function(){
if($('#searchbox').val() == 'Search'){
$('#searchbox').focus(); var elementSetting = function(){// for element setting load
$(".element").click(function(){
$e = $(this);
$apptitle.text($e.data("title"));
$appicon.attr("src",$e.find("img").attr("src"));
$appinfolist.find("li:eq(2) div").text($e.data("version"));
var dt = new Date($e.data("update"));
$appinfolist.find("li:eq(3) div").text(dt.toUTCString());
$appinfolist.find("li:eq(4) div").text($e.data("author"));
var sections = elementSettingsData[$e.data("id")].sections;
var sectionids = new Array();
$.each(sections,function(i,sec){
sectionids.push(sec.id);
})
$appinfolist.find("li:eq(0)").empty();
$.each(o.sectionList,function(i,sec){
var present = $.inArray(sec._id,sectionids);
if(present == -1){
$sectionswitch = $('<label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_9 s_switch"><div class="s_switch_status" status-off="Off">Off</div><label class="s_switch_switcher admbg2"><input type="checkbox" data-widget="'+ $e.data("id") +'" data-section="'+ sec._id +'"><span class="s_switch_toggle"></span></label></div>');
}else{
$sectionswitch = $('<label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_9 s_switch"><div class="s_switch_status" status-on="On">On</div><label class="s_switch_switcher thmc2"><input type="checkbox" checked="checked" data-widget="'+ $e.data("id") +'" data-section="'+ sec._id +'"><span class="s_switch_toggle"></span></label></div>');
} }
$appinfolist.find("li:eq(0)").append($sectionswitch);
})
$appinfo.show();
o.simple_switch(function(dom){
var options = {
"status" : dom.is(":checked"),
"widget_id" : dom.data("widget"),
"section_id" : dom.data("section")
}
var sectionDetails = o.sectionList.filter(function(o){return(o._id == dom.data("section"))})[0];
$.ajax({
url : "/desktop/appactivation",
type : "post",
datatype : "json",
data : options,
success : function(data){
if(data.success == "true"){
elementSettingsData[$e.data("id")].sections.push({"id" : dom.data("section"),"name":sectionDetails.name});
if(dom.is(":checked"))
o.notify("Added to " + sectionDetails.name,"success");
else
o.notify("Removed from " + sectionDetails.name,"success");
}
}
})
}); });
o.appname_substr('#group_wrapper .element'); })
o.simple_switch();
} }
$appinfo.find("a.panel_close").click(function(){
$appinfo.hide();
return false;
})
elementSetting();
o.appname_substr('#group_wrapper .element');
}
var elementSettingsData = {};
var loadApps = function(){ //this load apps for sorting and searching var loadApps = function(){ //this load apps for sorting and searching
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ $('#app_list').empty();
$.getJSON("/desktop/getapplistforManager",{desktopid:o.desktopId},function(apps){
var count = 0, colindex = 0; var count = 0, colindex = 0;
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>'); $('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
$.each(appss,function(i,apps){
$.each(apps,function(i,app){ $.each(apps,function(i,app){
var $app; var $app;
count++; count++;
$app = $('<div class="element w1 h1 thmc2" data-category="'+app.data_category+'" data-content="'+app.data_content+'"><span class="tile thmc2"></span><a href="'+app._id+'" class="appicon"><img src="'+o.iconPath+app.data_content+'.png" alt="" onclick="return false;"></a><h1 class="appname thmtxt">'+app.title+'</h1></div>'); elementSettingsData[app.id] = {"sections" : app.sections};
$app = $('<div class="element w1 h1 hp vp thmc2" data-category="'+app.data_category+'" data-title="'+app.title+'" data-author="'+app.author+'" data-version="'+app.version+'" data-update="'+app.last_update+'" data-id="'+app.id+'" ><span class="tile thmc2"></span><a href="'+app.id+'" class="appicon"><img src="'+app.icon+'" alt="" onclick="return false;"></a><h1 class="appname thmtxt">'+app.title+'</h1></div>');
if( count > 4 ){ if( count > 4 ){
count = 1, colindex+=1; count = 1, colindex+=1;
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>'); $('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
@ -924,16 +992,14 @@ var orbitDesktop = function(dom){
$('.g_col.col'+ colindex).append($app); $('.g_col.col'+ colindex).append($app);
} }
}); });
});
bindHandlers(); bindHandlers();
}); });
} }
if(cache){ // if(cache){
bindHandlers(); // bindHandlers();
} else { // } else {
loadApps(); loadApps();
} // }
}; };
this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager
var elementParent,element,slabel; var elementParent,element,slabel;
@ -1579,7 +1645,8 @@ var orbitDesktop = function(dom){
}); });
}); });
}; };
this.simple_switch = function(){
this.simple_switch = function(func){
$('.s_switch').each(function(){ $('.s_switch').each(function(){
var $switcher = $(this).find('.s_switch_switcher'), var $switcher = $(this).find('.s_switch_switcher'),
$checkbox = $(this).find('input[type=checkbox]'), $checkbox = $(this).find('input[type=checkbox]'),
@ -1603,9 +1670,12 @@ var orbitDesktop = function(dom){
$status.text(status_off); $status.text(status_off);
break; break;
} }
if(typeof func == "function")
func.call(this,$(this));
}); });
}); });
}; };
this.single_select = function(){ this.single_select = function(){
// single select // single select
$('.ssl .ssl_item').each(function(){ $('.ssl .ssl_item').each(function(){

View File

@ -604,6 +604,7 @@ a.admtxt.admbg2:hover {
width: 420px; width: 420px;
height: 516px; height: 516px;
margin-right: 36px; } margin-right: 36px; }
#app_info .app_info_header { #app_info .app_info_header {
height: 120px; height: 120px;
margin: -12px -12px 12px -12px; margin: -12px -12px 12px -12px;

View File

@ -117,8 +117,8 @@ class DesktopController< ApplicationController
jsfile = [] jsfile = []
cssfile = "" cssfile = ""
shape = "w1 h1" shape = "w1 h1"
fullsize = false
link = "" link = ""
fullsize = false
if tile.data_category == "widget" if tile.data_category == "widget"
widge = DesktopWidget.find(tile.desktop_widget_id.to_s) widge = DesktopWidget.find(tile.desktop_widget_id.to_s)
# data_content = widge.widget_layout.file # data_content = widge.widget_layout.file
@ -128,9 +128,7 @@ class DesktopController< ApplicationController
shape = widge.shape shape = widge.shape
title = widge.name title = widge.name
# binding.pry # binding.pry
if not widge.fullsize.nil?
fullsize = widge.fullsize fullsize = widge.fullsize
end
else else
data_content = tile.data_content data_content = tile.data_content
title = tile.title title = tile.title
@ -195,6 +193,33 @@ class DesktopController< ApplicationController
render :json=>a.to_json render :json=>a.to_json
end end
def getapplistforManager
@dwss = DesktopWidget.all
@tiles = Array.new
desktop = Desktop.find(params['desktopid'])
sections = desktop.sections
sections.each do |section|
groups = section.groups
groups.each do |group|
@tiles += group.tiles
end
end
@validtiles = Array.new
@allWidgets = Array.new
@dwss.each do |dw|
@id = dw.id
@validtiles = @tiles.select{|t| t.desktop_widget_id == @id}
@sections = Array.new
@validtiles.each do |vt|
grp = Group.find(vt.group_id)
sec = Section.find(grp.section_id);
@sections << {"id"=>sec.id,"name"=>sec.name}
end
@allWidgets << {"id"=>dw.id, "data_category"=> "widget","title" => dw.name, "version" => dw.version, "author"=>dw.author, "last_update"=>dw.updated_at, "icon"=>dw.images.where(:name=>dw.icon).first.file.url, "sections" => @sections}
end
render :json=>@allWidgets.to_json
end
def newpositions def newpositions
@newpositions = params[:newpositions] @newpositions = params[:newpositions]
@ -237,4 +262,26 @@ class DesktopController< ApplicationController
render :xml=>feed render :xml=>feed
end end
def appactivation
@group = Section.find(params[:section_id]).groups.first
@widget = DesktopWidget.find(params[:widget_id])
status = params[:status]
case status
when "true"
tile = Tile.new(data_category: "widget", position: 8, desktop_widget_id: @widget.id)
@group.tiles+=[tile]
@group.save
when "false"
tile = @group.tiles.where("desktop_widget_id"=>@widget.id).first
if tile != nil
tile.destroy
end
end
b = Array.new
b = {"success"=>"true"}
render :json=>b.to_json
end
end end

View File

@ -4,6 +4,7 @@ class DesktopWidgetsController < OrbitBackendController
require 'zip/zip' require 'zip/zip'
def index def index
@desktopWidgets = DesktopWidget.all
end end
def upload def upload
@ -21,6 +22,19 @@ class DesktopWidgetsController < OrbitBackendController
temp_file.close temp_file.close
end end
end end
def edit
@dw = DesktopWidget.find(params[:id])
end
def update
@dw = DesktopWidget.find(params[:id])
if(params[:desktop_widget])
@imagefile = params[:desktop_widget][:image]
@dw.images.build(:file => @imagefile)
@dw.save
end
redirect_to action: "index"
end
def unzip_widget(file, zip_name) def unzip_widget(file, zip_name)
Zip::ZipFile.open(file) { |zip_file| Zip::ZipFile.open(file) { |zip_file|

View File

@ -6,8 +6,11 @@ class DesktopWidget
field :name field :name
field :author field :author
field :shape field :shape
field :fullsize, :type => Boolean field :fullsize, :type => Boolean, default: false
field :version, :type => String field :version, :type => String
field :text_color, :type => String, default: "#fff"
field :bg_color, :type => String, default: "#fff"
field :icon, default: "icon.png"
has_one :css_default, as: :css, :autosave => true, :dependent => :destroy has_one :css_default, as: :css, :autosave => true, :dependent => :destroy
has_one :widget_layout, :autosave => true, :dependent => :destroy has_one :widget_layout, :autosave => true, :dependent => :destroy

View File

@ -13,7 +13,7 @@
<div id="holder"> <div id="holder">
<div id="group_wrapper" class="overview" content-layout="simple"> <div id="group_wrapper" class="overview" content-layout="simple">
<div id="app_info" class="admbg vp hp"> <div id="app_info" class="admbg vp hp" style="display:none;">
<div class="app_info_header s_grid_row hp"> <div class="app_info_header s_grid_row hp">
<div class="s_grid s_grid_3"> <div class="s_grid s_grid_3">
<img class="app_info_icon" src="/assets/icons/wikibooks.png" alt=""> <img class="app_info_icon" src="/assets/icons/wikibooks.png" alt="">
@ -25,18 +25,18 @@
</div> </div>
<ul class="app_info_list"> <ul class="app_info_list">
<li class="s_grid_row"> <li class="s_grid_row">
<label class="s_grid s_grid_3">Activation</label> <!-- <label class="s_grid s_grid_3">Activation</label>
<div class="s_grid s_grid_9 s_switch"> <div class="s_grid s_grid_9 s_switch"> -->
<div class="s_switch_status" status-on="On" status-off="Off"></div> <!-- <div class="s_switch_status" status-on="On" status-off="Off"></div>
<label class="s_switch_switcher"> <label class="s_switch_switcher">
<input type="checkbox"> <input type="checkbox">
</label> </label> -->
</div> <!-- </div> -->
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">
<label class="s_grid s_grid_3">Description</label> <label class="s_grid s_grid_3">Description</label>
<div class="s_grid s_grid_9"> <div class="s_grid s_grid_9">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</div> </div>
</li> </li>
<li class="s_grid_row"> <li class="s_grid_row">

View File

@ -0,0 +1,16 @@
<div>
<%= @dw.name %>
<h4>Upload Widget image </h4>
<div class="main2">
<%= form_for @dw, :url => desktop_widget_path(@dw) do |f| %>
<p>
<%= f.file_field :image %>
</p>
<%= submit_tag %>
<% end %>
</div>
</div>

View File

@ -0,0 +1,10 @@
<div>
<ul>
<% @desktopWidgets.each do |dw| %>
<li> <%= dw.name %>
<%= link_to "Delete", desktop_widget_path(dw), :method=>"delete" %>
<%= link_to "Edit", edit_desktop_widget_path(dw) %>
</li>
<% end %>
</ul>
</div>

View File

@ -233,7 +233,7 @@ Orbit::Application.routes.draw do
match "/desktop/compatibility" => "desktop#compatibility" match "/desktop/compatibility" => "desktop#compatibility"
match "desktop" => "desktop#index" match "desktop" => "desktop#index"
match "/desktop/desktop" => "desktop#desktop" match "/desktop/desktop" => "desktop#desktop"
match '/desktop/desktop'=>'desktop#desktop' match '/desktop/appactivation'=>'desktop#appactivation'
match '/desktop/app_manager'=>'desktop#app_manager' match '/desktop/app_manager'=>'desktop#app_manager'
match '/desktop/allsections'=>'desktop#allsections' match '/desktop/allsections'=>'desktop#allsections'
match '/desktop/settings'=>'desktop#settings' match '/desktop/settings'=>'desktop#settings'
@ -244,6 +244,7 @@ Orbit::Application.routes.draw do
match '/desktop/themes/'=>'desktop#themes' match '/desktop/themes/'=>'desktop#themes'
match '/desktop/sections/'=>'desktop#sections' match '/desktop/sections/'=>'desktop#sections'
match '/desktop/getapplist/'=>'desktop#getapplist' match '/desktop/getapplist/'=>'desktop#getapplist'
match '/desktop/getapplistforManager/'=>'desktop#getapplistforManager'
match '/desktop/newpositions/'=>'desktop#newpositions' match '/desktop/newpositions/'=>'desktop#newpositions'
match '/desktop/connections/'=>'desktop#connections' match '/desktop/connections/'=>'desktop#connections'
match '/desktop/widget_layout' => 'desktop#widget_layout' match '/desktop/widget_layout' => 'desktop#widget_layout'