apps update -- app upload and activation
This commit is contained in:
parent
f2ada14b7a
commit
ed22a4d303
|
@ -38,6 +38,15 @@ var sortAscending = function(a, b) {
|
||||||
var sortDescending = function(a, b) {
|
var sortDescending = function(a, b) {
|
||||||
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
|
return $(a).find("h1").text() < $(b).find("h1").text() ? 1 : -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Array.prototype.indexOfObject = function(object){
|
||||||
|
for(i = 0;i < this.length; i++){
|
||||||
|
if(this[i] === object)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
jQuery.ajax = (function(_ajax){
|
jQuery.ajax = (function(_ajax){
|
||||||
|
|
||||||
var protocol = location.protocol,
|
var protocol = location.protocol,
|
||||||
|
@ -315,9 +324,7 @@ var orbitDesktop = function(dom){
|
||||||
$(window).resize(function(){
|
$(window).resize(function(){
|
||||||
// var ww = $(window).width();
|
// var ww = $(window).width();
|
||||||
// $("img#thmbackground").attr({"width":ww});
|
// $("img#thmbackground").attr({"width":ww});
|
||||||
// if( $('.tinycanvas').length > 0 ){
|
if( $('.tinycanvas').length > 0 ){ $('.tinycanvas').tinyscrollbar_update('relative'); }
|
||||||
$('.tinycanvas').tinyscrollbar_update('relative');
|
|
||||||
// }
|
|
||||||
if($(o.contentHolder).find("div.app_frame").length > 0){
|
if($(o.contentHolder).find("div.app_frame").length > 0){
|
||||||
$(o.contentHolder).find("div.app_frame").each(function(){
|
$(o.contentHolder).find("div.app_frame").each(function(){
|
||||||
var app_holder_height = $(this).height() - 72;
|
var app_holder_height = $(this).height() - 72;
|
||||||
|
@ -371,7 +378,7 @@ var orbitDesktop = function(dom){
|
||||||
var temp_div = $("<div></div>");
|
var temp_div = $("<div></div>");
|
||||||
var entries = [];
|
var entries = [];
|
||||||
switch (layout){
|
switch (layout){
|
||||||
case "simple":
|
case "simple":
|
||||||
total_columns++;
|
total_columns++;
|
||||||
temp_div.append(column_container.html());
|
temp_div.append(column_container.html());
|
||||||
total_width = "auto";
|
total_width = "auto";
|
||||||
|
@ -464,7 +471,6 @@ var orbitDesktop = function(dom){
|
||||||
o.simple_drop_down();
|
o.simple_drop_down();
|
||||||
o.autocomplete();
|
o.autocomplete();
|
||||||
o.use_select2();
|
o.use_select2();
|
||||||
o.check_simple_layout();
|
|
||||||
}
|
}
|
||||||
this.paging = true;
|
this.paging = true;
|
||||||
this.pagination = function(link,variable,page_no){
|
this.pagination = function(link,variable,page_no){
|
||||||
|
@ -759,7 +765,7 @@ var orbitDesktop = function(dom){
|
||||||
var f = (tile.fullsize?"fullsize":null);
|
var f = (tile.fullsize?"fullsize":null);
|
||||||
|
|
||||||
if(tile.data_category == "app"){
|
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>');
|
$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="'+tile.icon+'" alt="" ></a><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||||
} else {
|
} 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><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
$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><h1 class="appname thmtxt">'+tile.title+'</h1></li>');
|
||||||
}
|
}
|
||||||
|
@ -835,37 +841,26 @@ var orbitDesktop = function(dom){
|
||||||
var $elements = $("#app_manager .element"),
|
var $elements = $("#app_manager .element"),
|
||||||
$result = $("#app_manager .search_result"),
|
$result = $("#app_manager .search_result"),
|
||||||
$appinfo = $("#app_info"),
|
$appinfo = $("#app_info"),
|
||||||
$applist = $("#app_list"),
|
$apptitle = $("#app_info .app_info_name"),
|
||||||
$apptitle = $appinfo.find(".app_info_name"),
|
$appicon = $("#app_info .app_info_icon")
|
||||||
$appicon = $appinfo.find(".app_info_icon"),
|
$appinfolist = $("#app_info .app_info_list");
|
||||||
$appinfolist = $appinfo.find(".app_info_list"),
|
|
||||||
$canvas = $result.parents('.overview'),
|
|
||||||
current_width = $canvas.css('width');
|
|
||||||
|
|
||||||
$("#app_manager #searchbox")
|
$("#app_manager #searchbox")
|
||||||
.focus(function(){
|
.focus(function(){
|
||||||
$(this).val("");
|
$(this).val("");
|
||||||
})
|
})
|
||||||
.keyup(function(e){
|
.keyup(function(e){
|
||||||
var query = $(this).val();
|
if($(this).val()){
|
||||||
if(query){
|
$result.empty();
|
||||||
$appinfo.hide().attr('style','');
|
$elements.hide();
|
||||||
$result.empty().show();
|
|
||||||
$applist.hide();
|
|
||||||
|
|
||||||
// searchArray = $elements.filter(":containsi("+$(this).val()+")").clone(1,1);
|
|
||||||
// searchArray = $('#app_list').find('[data-title*="'+query+'"]').clone(1,1);
|
|
||||||
searchArray = $elements.filter(function(){
|
|
||||||
var matcher = new RegExp(query, "i");
|
|
||||||
return matcher.test( $(this).attr('data-title') );
|
|
||||||
}).clone(1,1);
|
|
||||||
|
|
||||||
|
searchArray = $elements.filter(":containsi("+$(this).val()+")");
|
||||||
if(searchArray.length > 0){
|
if(searchArray.length > 0){
|
||||||
// searchArray.each(function(){
|
// searchArray.each(function(){
|
||||||
// $(this).hide("fold","fast");
|
// $(this).hide("fold","fast");
|
||||||
// })
|
// })
|
||||||
// $("#app_manager #seperator").show();
|
// $("#app_manager #seperator").show();
|
||||||
var i = 0, c = 1; // c for numbers of columns
|
var i = 0;
|
||||||
var $column;
|
var $column;
|
||||||
searchArray.each(function(){
|
searchArray.each(function(){
|
||||||
i++;
|
i++;
|
||||||
|
@ -877,50 +872,23 @@ var orbitDesktop = function(dom){
|
||||||
if(i == 4){
|
if(i == 4){
|
||||||
$result.append($column);
|
$result.append($column);
|
||||||
i = 0;
|
i = 0;
|
||||||
c++;
|
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
if(i != 0){
|
if(i != 0){
|
||||||
$result.append($column);
|
$result.append($column);
|
||||||
c*=132;
|
|
||||||
searchArray
|
|
||||||
.eq(0)
|
|
||||||
.parents('.overview')
|
|
||||||
.animate({
|
|
||||||
'width': c
|
|
||||||
},0, function(){
|
|
||||||
$(this)
|
|
||||||
.parents('.tinycanvas')
|
|
||||||
.tinyscrollbar_update();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
elementSetting();
|
||||||
} else {
|
} else {
|
||||||
var $no_result = $('<div class="w2 h1 thmtxt thmc2 vp hp message"><span class="tile"></span>No result for <b></b></div>');
|
$result.text("No Result Found.");
|
||||||
$no_result
|
|
||||||
.find('b')
|
|
||||||
.text('"'+$(this).val()+'"')
|
|
||||||
.end()
|
|
||||||
.show()
|
|
||||||
.appendTo($result);
|
|
||||||
$canvas.animate({
|
|
||||||
'width':252
|
|
||||||
}, 0, function(){
|
|
||||||
$(this)
|
|
||||||
.parents('.tinycanvas')
|
|
||||||
.tinyscrollbar_update();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if( query == "" ) {
|
|
||||||
info_close();
|
} else {
|
||||||
$result.empty();
|
$result.empty();
|
||||||
$applist.show();
|
$elements.show();
|
||||||
$canvas.css('width',current_width);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.blur(function(){
|
.blur(function(){
|
||||||
if($(this).val()==""){
|
if($(this).val()=="") $(this).val("Search");
|
||||||
$(this).val("Search");
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//for Alphabet sorting
|
//for Alphabet sorting
|
||||||
|
@ -952,22 +920,16 @@ var orbitDesktop = function(dom){
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var elementSetting = function(){// for element setting load
|
var elementSetting = function(){// for element setting load
|
||||||
$elements.click(function(){
|
$(".element").click(function(){
|
||||||
var $e = $(this);
|
$e = $(this);
|
||||||
$apptitle.text($e.data("title"));
|
$apptitle.text($e.data("title"));
|
||||||
$appicon.attr("src",$e.find("img").attr("src"));
|
$appicon.attr("src",$e.find("img").attr("src"));
|
||||||
$appinfolist.find("[info=app_version]").text($e.data("version"));
|
$appinfolist.find("li:eq(2) div").text($e.data("version"));
|
||||||
var dt = new Date($e.data("update"));
|
var dt = new Date($e.data("update"));
|
||||||
$appinfolist.find("[info=app_last_update]").text(dt.toUTCString());
|
$appinfolist.find("li:eq(3) div").text(dt.toUTCString());
|
||||||
$appinfolist.find("[info=app_author]").text($e.data("author"));
|
$appinfolist.find("li:eq(4) div").text($e.data("author"));
|
||||||
$appinfo
|
|
||||||
.find(".app_info_header")
|
|
||||||
.css({
|
|
||||||
"background-color": $e.data("background"),
|
|
||||||
"color": $e.data("text-color")
|
|
||||||
});
|
|
||||||
var sections = elementSettingsData[$e.data("id")].sections;
|
var sections = elementSettingsData[$e.data("id")].sections;
|
||||||
|
|
||||||
var sectionids = new Array();
|
var sectionids = new Array();
|
||||||
|
@ -975,23 +937,24 @@ var orbitDesktop = function(dom){
|
||||||
sectionids.push(sec.id);
|
sectionids.push(sec.id);
|
||||||
})
|
})
|
||||||
|
|
||||||
$appinfolist.find("[info=app_section_activation]").empty();
|
$appinfolist.find("[info=section_activation]").empty();
|
||||||
$.each(o.sectionList,function(i,sec){
|
$.each(o.sectionList,function(i,sec){
|
||||||
|
|
||||||
var present = $.inArray(sec._id,sectionids);
|
var present = $.inArray(sec._id,sectionids);
|
||||||
if(present == -1){
|
if(present == -1){
|
||||||
$sectionswitch = $('<div class="s_grid_row s_switch"><label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-on="On" 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></div>');
|
$sectionswitch = $('<div class="s_grid_row"><label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-off="Off" status-on="On">Off</div><label class="s_switch_switcher admbg2"><input type="checkbox" data-widget="'+ $e.data("id") +'" data-section="'+ sec._id +'" data-type="'+$e.data("type")+'"><span class="s_switch_toggle"></span></label></div></div>');
|
||||||
}else{
|
}else{
|
||||||
$sectionswitch = $('<div class="s_grid_row s_switch"><label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-on="On" status-off="Off">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></div>');
|
$sectionswitch = $('<div class="s_grid_row"><label class="s_grid s_grid_3">'+ sec.name +'</label><div class="s_grid s_grid_6 s_switch"><div class="s_switch_status" status-on="On" status-off="Off">On</div><label class="s_switch_switcher thmc2"><input type="checkbox" checked="checked" data-widget="'+ $e.data("id") +'" data-section="'+ sec._id +'" data-type="'+$e.data("type")+'"><span class="s_switch_toggle"></span></label></div></div>');
|
||||||
}
|
}
|
||||||
$appinfolist.find("[info=app_section_activation]").append($sectionswitch);
|
$appinfolist.find("[info=section_activation]").append($sectionswitch);
|
||||||
});
|
})
|
||||||
info_open();
|
$appinfo.show();
|
||||||
o.simple_switch(function(dom){
|
o.simple_switch(function(dom){
|
||||||
var options = {
|
var options = {
|
||||||
"status" : dom.is(":checked"),
|
"status" : dom.is(":checked"),
|
||||||
"widget_id" : dom.data("widget"),
|
"id" : dom.data("widget"),
|
||||||
"section_id" : dom.data("section")
|
"section_id" : dom.data("section"),
|
||||||
|
"type" : dom.data("type")
|
||||||
}
|
}
|
||||||
var sectionDetails = o.sectionList.filter(function(o){return(o._id == dom.data("section"))})[0];
|
var sectionDetails = o.sectionList.filter(function(o){return(o._id == dom.data("section"))})[0];
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -1001,101 +964,49 @@ var orbitDesktop = function(dom){
|
||||||
data : options,
|
data : options,
|
||||||
success : function(data){
|
success : function(data){
|
||||||
if(data.success == "true"){
|
if(data.success == "true"){
|
||||||
elementSettingsData[$e.data("id")].sections.push({
|
if(dom.is(":checked")){ console.log("true");
|
||||||
"id" : dom.data("section"),
|
elementSettingsData[$e.data("id")].sections.push({"id" : dom.data("section"),"name":sectionDetails.name});
|
||||||
"name":sectionDetails.name
|
|
||||||
});
|
|
||||||
if(options.status)
|
|
||||||
o.notify("Added to " + sectionDetails.name,"success");
|
o.notify("Added to " + sectionDetails.name,"success");
|
||||||
else
|
}else{
|
||||||
|
var index = elementSettingsData[$e.data("id")].sections.indexOfObject(elementSettingsData[$e.data("id")].sections.filter(function(a){return a.id == dom.data("section")})[0]);
|
||||||
|
elementSettingsData[$e.data("id")].sections.splice(index,1);
|
||||||
o.notify("Removed from " + sectionDetails.name,"success");
|
o.notify("Removed from " + sectionDetails.name,"success");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
});
|
});
|
||||||
return false;
|
})
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$appinfo.find("a.panel_close").click(function(){
|
$appinfo.find("a.panel_close").click(function(){
|
||||||
info_close();
|
$appinfo.hide();
|
||||||
return false;
|
return false;
|
||||||
});
|
})
|
||||||
|
|
||||||
var info_open = function(){
|
|
||||||
if($appinfo.is(":hidden")){
|
|
||||||
$('.overview').stop().animate({'width': '+=480'},0 , function(){
|
|
||||||
$('.tinycanvas').tinyscrollbar_update();
|
|
||||||
});
|
|
||||||
$appinfo
|
|
||||||
.css({
|
|
||||||
'display': 'block',
|
|
||||||
'margin-left': -480
|
|
||||||
})
|
|
||||||
.delay(300)
|
|
||||||
.animate({
|
|
||||||
'margin-left': 0
|
|
||||||
}, 500, 'easeInOutQuint');
|
|
||||||
} else {
|
|
||||||
$('.tinycanvas').tinyscrollbar_update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var info_close = function(){
|
|
||||||
if( $appinfo.is(":visible") ){
|
|
||||||
$appinfo
|
|
||||||
.stop()
|
|
||||||
.animate({
|
|
||||||
'margin-left': -480
|
|
||||||
},500 , 'easeInOutQuint', function(){
|
|
||||||
$('.overview').animate({'width': '-=480'}, 0, function(){
|
|
||||||
$('.tinycanvas').tinyscrollbar_update();
|
|
||||||
});
|
|
||||||
$(this).attr("style","");
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('.tinycanvas').tinyscrollbar_update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$(window).on('keydown', function(){
|
|
||||||
if($('#searchbox').val() == 'Search'){
|
|
||||||
$('#searchbox').focus();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
elementSetting();
|
elementSetting();
|
||||||
o.appname_substr('#group_wrapper .element');
|
o.appname_substr('#group_wrapper .element');
|
||||||
o.check_simple_layout();
|
|
||||||
}
|
}
|
||||||
var elementSettingsData = {};
|
var elementSettingsData = {};
|
||||||
var loadApps = function(){ //this load apps for sorting and searching
|
var loadApps = function(){ //this load apps for sorting and searching
|
||||||
$('#app_info').attr('style','');
|
$('#app_list').empty();
|
||||||
$('.search_result').hide().text("");
|
|
||||||
$('#app_list').empty().show();
|
|
||||||
$.getJSON("/desktop/getapplistforManager",{desktopid:o.desktopId},function(apps){
|
$.getJSON("/desktop/getapplistforManager",{desktopid:o.desktopId},function(apps){
|
||||||
var count = 0,
|
var count = 0, colindex = 0;
|
||||||
colindex = 0,
|
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
|
||||||
apps_sum = apps.length,
|
$.each(apps,function(i,app){
|
||||||
col_sum;
|
var $app;
|
||||||
|
count++;
|
||||||
col_sum = (apps_sum - (apps_sum % 4)) / 4 + 1;
|
elementSettingsData[app.id] = {"sections" : app.sections};
|
||||||
|
o.t[app.id] = {"sections" : app.sections};
|
||||||
$('#app_list')
|
$app = $('<div class="element w1 h1 thmc2" data-type="'+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>');
|
||||||
.css('width',col_sum * 132)
|
if( count > 4 ){
|
||||||
.append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
|
count = 1, colindex+=1;
|
||||||
|
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
|
||||||
$.each(apps,function(i,app){
|
$('.g_col.col'+ colindex).append($app);
|
||||||
var $app;
|
} else {
|
||||||
count++;
|
$('.g_col.col'+ colindex).append($app);
|
||||||
elementSettingsData[app.id] = {"sections" : app.sections};
|
}
|
||||||
$app = $('<div class="element w1 h1 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+'" data-text-color="'+app.text_color+'" data-background="'+app.background+'" ><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 ){
|
|
||||||
count = 1, colindex+=1;
|
|
||||||
$('#app_list').append('<div class="g_col g_col_w1 col'+ colindex +'"/>');
|
|
||||||
$('.g_col.col'+ colindex).append($app);
|
|
||||||
} else {
|
|
||||||
$('.g_col.col'+ colindex).append($app);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
bindHandlers();
|
bindHandlers();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1105,6 +1016,7 @@ var orbitDesktop = function(dom){
|
||||||
loadApps();
|
loadApps();
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
|
this.t = {}
|
||||||
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;
|
||||||
var bindHandlers = function(){ // this is bind handler for section manager page
|
var bindHandlers = function(){ // this is bind handler for section manager page
|
||||||
|
@ -1715,25 +1627,6 @@ var orbitDesktop = function(dom){
|
||||||
|
|
||||||
o.tinyscrollbar = target.main.tinyscrollbar( settings );
|
o.tinyscrollbar = target.main.tinyscrollbar( settings );
|
||||||
};
|
};
|
||||||
this.check_simple_layout = function(){
|
|
||||||
// use for various width of columns inside canvas(.overview)
|
|
||||||
// only count width for visible element which has "s_column" class
|
|
||||||
// then set width to canvas
|
|
||||||
// ** not sure to update canvas here ( $.tinyscrollbar_update() )
|
|
||||||
var sw = 0,
|
|
||||||
$simple_layout = $('#content .overview[content-layout=simple]');
|
|
||||||
if($simple_layout.find(".s_column").length > 0){
|
|
||||||
$simple_layout.each(function(){
|
|
||||||
$(this).find(".s_column").filter(":visible").each(function(){
|
|
||||||
sw += $(this).outerWidth();
|
|
||||||
});
|
|
||||||
$simple_layout.css('width',sw);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
// if($simple_layout.find(".s_column").length > 0){
|
|
||||||
// $simple_layout.css('width',sw);
|
|
||||||
// }
|
|
||||||
};
|
|
||||||
this.simple_drop_down = function(){
|
this.simple_drop_down = function(){
|
||||||
// simple dropdown menu
|
// simple dropdown menu
|
||||||
var $sdm = $('.sdm');
|
var $sdm = $('.sdm');
|
||||||
|
@ -1781,7 +1674,7 @@ var orbitDesktop = function(dom){
|
||||||
ini = ($switcher.hasClass('admbg2')) ? null : $switcher.addClass('admbg2');
|
ini = ($switcher.hasClass('admbg2')) ? null : $switcher.addClass('admbg2');
|
||||||
ini = ($switcher.find('.s_switch_toggle').length < 1) ? $checkbox.after(toggle) : null;
|
ini = ($switcher.find('.s_switch_toggle').length < 1) ? $checkbox.after(toggle) : null;
|
||||||
set = ($checkbox.is(':checked')) ? $status.text(status_on) : $status.text(status_off);
|
set = ($checkbox.is(':checked')) ? $status.text(status_on) : $status.text(status_off);
|
||||||
$checkbox.change(function(){
|
$checkbox.unbind().change(function(){
|
||||||
var v = $(this).attr('checked');
|
var v = $(this).attr('checked');
|
||||||
switch (v) {
|
switch (v) {
|
||||||
case 'checked':
|
case 'checked':
|
||||||
|
@ -1793,9 +1686,8 @@ var orbitDesktop = function(dom){
|
||||||
$status.text(status_off);
|
$status.text(status_off);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(typeof func == "function"){
|
if(typeof func == "function")
|
||||||
func.call(this,$(this));
|
func.call(this,$(this));
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
class DesktopAppsController < OrbitBackendController
|
||||||
|
require "net/http"
|
||||||
|
require "uri"
|
||||||
|
require 'zip/zip'
|
||||||
|
|
||||||
|
def index
|
||||||
|
@desktopapps = DesktopApp.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def upload
|
||||||
|
if !params[:desktop_app].nil?
|
||||||
|
temp_file = Tempfile.new("temp_file");
|
||||||
|
original_file = params[:desktop_app][:package_file]
|
||||||
|
temp_file.write(original_file.read.force_encoding("UTF-8"))
|
||||||
|
temp_file.rewind
|
||||||
|
filename = File.basename(original_file.original_filename,".zip")
|
||||||
|
unzip_app(temp_file,filename)
|
||||||
|
temp_file.close
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def unzip_app(file, zip_name)
|
||||||
|
Zip::ZipFile.open(file) { |zip_file|
|
||||||
|
da = DesktopApp.new.from_json(zip_file.read("#{zip_name}/settings.json"))
|
||||||
|
Dir.mktmpdir('f_path') { |dir|
|
||||||
|
images_entries = []
|
||||||
|
zip_file.entries.each do |entry|
|
||||||
|
case (path = entry.to_s)
|
||||||
|
when /\A(#{zip_name})\/(images)\/.*((\.jpg)|(\.png)|(\.gif))\z/ #for img
|
||||||
|
images_entries << entry
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
images_entries.each do |image|
|
||||||
|
da.images.build(:file => get_temp_file(zip_file,dir,image))
|
||||||
|
end
|
||||||
|
}
|
||||||
|
da.save
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_temp_file(zip_file, dir, entry)
|
||||||
|
filename = File.basename(entry.to_s)
|
||||||
|
temp_file = File.new(dir + '/' + filename, 'w+')
|
||||||
|
temp_file.write (zip_file.read entry ).force_encoding('UTF-8')
|
||||||
|
temp_file
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -118,6 +118,7 @@ class DesktopController< ApplicationController
|
||||||
cssfile = ""
|
cssfile = ""
|
||||||
shape = "w1 h1"
|
shape = "w1 h1"
|
||||||
link = ""
|
link = ""
|
||||||
|
icon= ""
|
||||||
fullsize = false
|
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)
|
||||||
|
@ -127,19 +128,17 @@ class DesktopController< ApplicationController
|
||||||
cssfile = widge.css_default.file.as_json[:file]
|
cssfile = widge.css_default.file.as_json[:file]
|
||||||
shape = widge.shape
|
shape = widge.shape
|
||||||
title = widge.name
|
title = widge.name
|
||||||
|
icon = widge.images.where(:name => widge.icon).first.file.url
|
||||||
# binding.pry
|
# binding.pry
|
||||||
fullsize = widge.fullsize
|
fullsize = widge.fullsize
|
||||||
else
|
else
|
||||||
data_content = tile.data_content
|
app = DesktopApp.find(tile.desktop_app_id.to_s)
|
||||||
title = tile.title
|
title = app.name
|
||||||
case data_content
|
link = app.url
|
||||||
when "envocab"
|
icon = app.images.where(:name => app.icon).first.file.url
|
||||||
link = "http://www.english-vocabulary.eu/"
|
|
||||||
when "wikibooks"
|
|
||||||
link = "http://www.wikibooks.org"
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
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}
|
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,"icon"=>icon}
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -195,6 +194,7 @@ class DesktopController< ApplicationController
|
||||||
|
|
||||||
def getapplistforManager
|
def getapplistforManager
|
||||||
@dwss = DesktopWidget.all
|
@dwss = DesktopWidget.all
|
||||||
|
@dapps = DesktopApp.all
|
||||||
@tiles = Array.new
|
@tiles = Array.new
|
||||||
desktop = Desktop.find(params['desktopid'])
|
desktop = Desktop.find(params['desktopid'])
|
||||||
sections = desktop.sections
|
sections = desktop.sections
|
||||||
|
@ -217,6 +217,18 @@ class DesktopController< ApplicationController
|
||||||
end
|
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, "text_color" => dw.text_color, "background" => dw.bg_color, "sections" => @sections}
|
@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, "text_color" => dw.text_color, "background" => dw.bg_color, "sections" => @sections}
|
||||||
end
|
end
|
||||||
|
validtiles = Array.new
|
||||||
|
@dapps.each do |da|
|
||||||
|
@id = da.id
|
||||||
|
@validtiles = @tiles.select{|t| t.desktop_app_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"=>da.id, "data_category"=> "app","title" => da.name, "version" => da.version, "author"=>da.author, "last_update"=>da.updated_at, "icon"=>da.images.where(:name=>da.icon).first.file.url, "sections" => @sections}
|
||||||
|
end
|
||||||
render :json=>@allWidgets.to_json
|
render :json=>@allWidgets.to_json
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -264,18 +276,37 @@ class DesktopController< ApplicationController
|
||||||
|
|
||||||
def appactivation
|
def appactivation
|
||||||
@group = Section.find(params[:section_id]).groups.first
|
@group = Section.find(params[:section_id]).groups.first
|
||||||
@widget = DesktopWidget.find(params[:widget_id])
|
@type = params[:type]
|
||||||
status = params[:status]
|
if @type == "widget"
|
||||||
|
@widget = DesktopWidget.find(params[:id])
|
||||||
|
status = params[:status]
|
||||||
|
|
||||||
case status
|
case status
|
||||||
when "true"
|
when "true"
|
||||||
tile = Tile.new(data_category: "widget", position: 8, desktop_widget_id: @widget.id)
|
tile = Tile.new(data_category: "widget", position: 8, desktop_widget_id: @widget.id)
|
||||||
@group.tiles+=[tile]
|
@group.tiles+=[tile]
|
||||||
@group.save
|
@group.save
|
||||||
when "false"
|
when "false"
|
||||||
tile = @group.tiles.where("desktop_widget_id"=>@widget.id).first
|
tile = @group.tiles.where("desktop_widget_id"=>@widget.id).first
|
||||||
if tile != nil
|
if tile != nil
|
||||||
tile.destroy
|
tile.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if @type == "app"
|
||||||
|
@app = DesktopApp.find(params[:id])
|
||||||
|
status = params[:status]
|
||||||
|
case status
|
||||||
|
when "true"
|
||||||
|
tile = Tile.new(data_category: "app", position: 8, desktop_app_id: @app.id)
|
||||||
|
@group.tiles+=[tile]
|
||||||
|
@group.save
|
||||||
|
when "false"
|
||||||
|
tile = @group.tiles.where("desktop_app_id"=>@app.id).first
|
||||||
|
if tile != nil
|
||||||
|
tile.destroy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
class DesktopApp
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
|
||||||
|
field :name
|
||||||
|
field :author
|
||||||
|
field :shape
|
||||||
|
field :version, :type => String
|
||||||
|
field :text_color, :type => String, default: "#fff"
|
||||||
|
field :bg_color, :type => String, default: "#fff"
|
||||||
|
field :icon, default: "icon.png"
|
||||||
|
field :url
|
||||||
|
|
||||||
|
has_many :images, as: :imgs, :autosave => true, :dependent => :destroy
|
||||||
|
has_and_belongs_to_many :desktops, :autosave => true
|
||||||
|
has_many :tiles, :autosave => true
|
||||||
|
|
||||||
|
accepts_nested_attributes_for :images, :allow_destroy => true
|
||||||
|
|
||||||
|
end
|
|
@ -5,7 +5,7 @@ class DesktopWidget
|
||||||
|
|
||||||
field :name
|
field :name
|
||||||
field :author
|
field :author
|
||||||
field :shape
|
field :shape, default: "w1 h1"
|
||||||
field :fullsize, :type => Boolean, default: false
|
field :fullsize, :type => Boolean, default: false
|
||||||
field :version, :type => String
|
field :version, :type => String
|
||||||
field :text_color, :type => String, default: ""
|
field :text_color, :type => String, default: ""
|
||||||
|
|
|
@ -7,11 +7,11 @@ class Group
|
||||||
before_create :initialize_tile
|
before_create :initialize_tile
|
||||||
|
|
||||||
def initialize_tile
|
def initialize_tile
|
||||||
self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes")
|
# self.tiles.build(data_category: "app", data_content: "quotes", position: 5, shape: "w1 h1", title: "Quotes")
|
||||||
self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word")
|
# self.tiles.build(data_category: "app", data_content: "dailyenglish", position: 6, shape: "w1 h1", title: "Daily English Word")
|
||||||
widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id}
|
widgets = self.section.desktop.desktop_widgets.collect{|widget| widget.id}
|
||||||
for i in 0..3
|
widgets.each_with_index do |w,i|
|
||||||
self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: widgets[i])
|
self.tiles.build(data_category: "widget", position: i+1,desktop_widget_id: w)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,5 +13,6 @@ class Tile
|
||||||
|
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
belongs_to :desktop_widget
|
belongs_to :desktop_widget
|
||||||
|
belongs_to :desktop_app
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<div>
|
||||||
|
<ul>
|
||||||
|
<% @desktopapps.each do |da| %>
|
||||||
|
<li> <%= da.name %>
|
||||||
|
<%= link_to "Delete", desktop_app_path(da), :method=>"delete", :confirm=>"Are you sure?" %>
|
||||||
|
<%#= link_to "Edit", edit_desktop_app_path(da) %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<h4>Upload App Package </h4>
|
||||||
|
<div class="main2">
|
||||||
|
<%= form_tag '',:multipart => true,:action=>"post" do |f| %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<%= file_field :desktop_app,:package_file %>
|
||||||
|
</p>
|
||||||
|
<%= submit_tag %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
</div>
|
|
@ -2,7 +2,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<% @desktopWidgets.each do |dw| %>
|
<% @desktopWidgets.each do |dw| %>
|
||||||
<li> <%= dw.name %>
|
<li> <%= dw.name %>
|
||||||
<%= link_to "Delete", desktop_widget_path(dw), :method=>"delete" %>
|
<%= link_to "Delete", desktop_widget_path(dw), :method=>"delete", :confirm=>"Are you sure?" %>
|
||||||
<%= link_to "Edit", edit_desktop_widget_path(dw) %>
|
<%= link_to "Edit", edit_desktop_widget_path(dw) %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -230,6 +230,14 @@ Orbit::Application.routes.draw do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :desktop_apps do
|
||||||
|
collection do
|
||||||
|
get 'upload'
|
||||||
|
get 'delete'
|
||||||
|
post 'upload'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
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"
|
||||||
|
|
Loading…
Reference in New Issue