Publication started

This commit is contained in:
Harry Bomrah 2012-04-24 16:45:26 +08:00
parent 670ec2a40e
commit a298cbd5f6
8 changed files with 206 additions and 105 deletions

View File

@ -1,5 +1,9 @@
// JavaScript Document // JavaScript Document
//harry //harry
//Inititialize function will initialize desktop
$.extend($.expr[':'], { $.extend($.expr[':'], {
'containsi': function (elem, i, match, array) { 'containsi': function (elem, i, match, array) {
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
@ -25,7 +29,7 @@ var orbitDesktop = function(dom){
this.transitionTime = 500; this.transitionTime = 500;
this.currenthtml = "desktop.html"; this.currenthtml = "desktop.html";
this.currentface = "home"; this.currentface = "home";
this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":""}; this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":""};
this.tp = ""; this.tp = "";
this.sectionList; this.sectionList;
this.initialize = function(){ this.initialize = function(){
@ -43,7 +47,7 @@ var orbitDesktop = function(dom){
loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper); loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper);
}else{loadTheme();} }else{loadTheme();}
}) })
var loadTheme = function(customtheme,customwallpaper){ var loadTheme = function(customtheme,customwallpaper){ //This function will load the theme from database
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
o.themesettings = eval(ts); o.themesettings = eval(ts);
$('head').append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css)); $('head').append( $('<link rel="stylesheet" id="dyn_css" type="text/css" />').attr('href', "/"+o.themefolder+"/"+theme+"/css/"+ts.css));
@ -55,7 +59,7 @@ var orbitDesktop = function(dom){
}) })
} }
}; };
this.changeTheme = function(theme){ this.changeTheme = function(theme){ // this function is used for changing theme
o.theme = theme; o.theme = theme;
$.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){
o.themesettings = eval(ts); o.themesettings = eval(ts);
@ -64,9 +68,8 @@ var orbitDesktop = function(dom){
o.loadWallpaper(); o.loadWallpaper();
o.loadIconCache(); o.loadIconCache();
}) })
}; };
this.bindDesktopEvents = function(){ this.bindDesktopEvents = function(){ //this function will bind the global handlers to thd desktop, for example doc
$("a#d_app_manager").click(function(){ $("a#d_app_manager").click(function(){
var target = $(this).attr("href"); var target = $(this).attr("href");
if(o.currenthtml!=target){ if(o.currenthtml!=target){
@ -94,6 +97,15 @@ var orbitDesktop = function(dom){
}); });
} }
}); });
$("#d_journal_p").click(function(){
var target = $(this).attr("href");
if(o.currenthtml!=target){
o.desktopData[o.currentface] = $(o.contentHolder).html();
$("#content").hide("drop",o.transitionTime,function(){
o.initializeJournalPapers(target);
});
}
});
$("a#d_settings").click(function(){ $("a#d_settings").click(function(){
var target = $(this).attr("href"); var target = $(this).attr("href");
if(o.currenthtml!=target){ if(o.currenthtml!=target){
@ -117,7 +129,8 @@ var orbitDesktop = function(dom){
$fn_des.stop(true, true).fadeOut(); $fn_des.stop(true, true).fadeOut();
}); });
}; };
this.initializeDesktop = function(target){
this.initializeDesktop = function(target){ //this is for initializing main desktops that are sections and tiles
if(!target)target = "desktop"; if(!target)target = "desktop";
o.currenthtml = target; o.currenthtml = target;
o.currentface = "home"; o.currentface = "home";
@ -125,7 +138,7 @@ var orbitDesktop = function(dom){
var extraspace = 300; var extraspace = 300;
var currentElement, elementParent, targetParent, tempElement, widthcheck; var currentElement, elementParent, targetParent, tempElement, widthcheck;
widthcheck = false; widthcheck = false;
var bindHandlers = function(){ var bindHandlers = function(){ // this function will bind all the handlers in the desktop
var groupWrapperWidth = 0; var groupWrapperWidth = 0;
var groupWrapperHeight = 0; var groupWrapperHeight = 0;
$('div#desktop div.group').width(528); $('div#desktop div.group').width(528);
@ -202,8 +215,7 @@ 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
var loadTiles = function(id){
$("div#desktop div#group_wrapper").empty(); $("div#desktop div#group_wrapper").empty();
$.getJSON("/desktop/getgroups",{sectionid:id},function(groups){ $.getJSON("/desktop/getgroups",{sectionid:id},function(groups){
var tilecolors = o.themesettings.tilecolor; var tilecolors = o.themesettings.tilecolor;
@ -228,7 +240,7 @@ var orbitDesktop = function(dom){
o.initializeWidgets(); o.initializeWidgets();
}) })
} }
var loadSectionList = function(){ var loadSectionList = function(){ //This will load the section list from the db
$.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){ $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){
o.sectionList = eval(sectionlist); o.sectionList = eval(sectionlist);
$.each(sectionlist,function(i,section){ $.each(sectionlist,function(i,section){
@ -242,8 +254,7 @@ var orbitDesktop = function(dom){
bindSecondaryHandlers(); bindSecondaryHandlers();
}) })
} }
var bindSecondaryHandlers = function(){ //This is the secondary bind handler function which is used to bind events which are repeatative
var bindSecondaryHandlers = function(){
$("div#desktop ul#section_list li.section_name").click(function(){ $("div#desktop ul#section_list li.section_name").click(function(){
$("div#desktop li.section_name").show(); $("div#desktop li.section_name").show();
$(this).hide(); $(this).hide();
@ -275,16 +286,18 @@ var orbitDesktop = function(dom){
bindSecondaryHandlers(); bindSecondaryHandlers();
} }
}; };
this.tempFunc = function(th){ this.tempFunc = function(th){
o.confirm("What","","",function(reply){ o.confirm("What","","",function(reply){
alert(reply); alert(reply);
}) })
} };
this.initializeAppSearch = function(target){
this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization
o.currenthtml = target; o.currenthtml = target;
o.currentface = "apps_manager"; o.currentface = "apps_manager";
var searchArray,allApps; var searchArray,allApps;
var bindHandlers = function(){ var bindHandlers = function(){ // bind handler for app manager page
$("div#app_manager #group_wrapper").css("min-width",$(window).width()-100); $("div#app_manager #group_wrapper").css("min-width",$(window).width()-100);
$("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
@ -325,7 +338,7 @@ var orbitDesktop = function(dom){
.delay(1500) .delay(1500)
.addClass('op00', 500); .addClass('op00', 500);
} }
var loadApps = function(){ var loadApps = function(){ //this load apps for sorting and searching
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
$.each(appss,function(i,apps){ $.each(appss,function(i,apps){
$.each(apps,function(i,app){ $.each(apps,function(i,app){
@ -347,11 +360,11 @@ var orbitDesktop = function(dom){
bindHandlers(); bindHandlers();
} }
}; };
this.initializeSectionsManager = function(target){ this.initializeSectionsManager = function(target){ // this is init function for section manager
o.currenthtml = target; o.currenthtml = target;
o.currentface = "sections"; o.currentface = "sections";
var elementParent,element,slabel; var elementParent,element,slabel;
var bindHandlers = function(){ var bindHandlers = function(){ // this is bind handler for section manager page
var groupWrapperWidth = 0; var groupWrapperWidth = 0;
$("div#sections .group").width(400); $("div#sections .group").width(400);
$("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();}) $("div#sections .group").each(function(){groupWrapperWidth+=$(this).width();})
@ -408,7 +421,7 @@ var orbitDesktop = function(dom){
$sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');}); $sdm.hover(function(){$(this).addClass('thmc2');}, function(){$(this).removeClass('thmc2');});
} }
}; };
var loadApps = function(){ var loadApps = function(){ // this loads apps from db to in each sections
$.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){
var $group,$lii,$li; var $group,$lii,$li;
var z=0; var z=0;
@ -440,8 +453,6 @@ var orbitDesktop = function(dom){
} }
y++; y++;
}) })
bindHandlers(); bindHandlers();
}) })
} }
@ -455,10 +466,10 @@ var orbitDesktop = function(dom){
} }
}; };
this.initializeSettings = function(target){ this.initializeSettings = function(target){ //this is to initialize setting page
o.currenthtml = target; o.currenthtml = target;
o.currentface = "settings"; o.currentface = "settings";
var bindHandlers = function(){ var bindHandlers = function(){ // this is the bind handler function for setting page
$("div#settings ul#setting_left_nav li a").on({ $("div#settings ul#setting_left_nav li a").on({
click: function(){ click: function(){
if(!$(this).data("clicked")){ if(!$(this).data("clicked")){
@ -485,8 +496,8 @@ var orbitDesktop = function(dom){
}); });
} }
var sections = function(){ var sections = function(){ // this load section page in setting page
var bindHandlers = function(){ var bindHandlers = function(){ // binding handlers in section page
$('.tinycanvas').each(function(){ $('.tinycanvas').each(function(){
var h = $(this).parent().height(), var h = $(this).parent().height(),
sh = $(this).siblings('.s_tab').height(); sh = $(this).siblings('.s_tab').height();
@ -504,15 +515,10 @@ var orbitDesktop = function(dom){
desktopnm.push($(this).val()); desktopnm.push($(this).val());
}) })
$.post("/desktop/save_desktop_settings",{"save":"desktopnames","desktopid":o.desktopId,"desktopnms":desktopnm},function(result,status){ $.post("/desktop/save_desktop_settings",{"save":"desktopnames","desktopid":o.desktopId,"desktopnms":desktopnm},function(result,status){
if(status=="success"){
if(result[0].success=="true"){ if(result[0].success=="true"){
o.notify("Names Saved!!","success",2); o.notify("Names Saved!!","success",2);
} }else
else
o.notify("Name saving failed!!","imp",2); o.notify("Name saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
}) })
$.each(o.sectionList,function(i,sec){ $.each(o.sectionList,function(i,sec){
sec.name = desktopnm[i]; sec.name = desktopnm[i];
@ -529,24 +535,20 @@ var orbitDesktop = function(dom){
}) })
} }
var themes = function(){ var themes = function(){ // this opens themes page in setting page
var bindHandlers = function(){ var bindHandlers = function(){ // binding handlers in themes page
// live change theme // live change theme
$(".theme_list > .ssl_item").click(function(){ $(".theme_list > .ssl_item").click(function(){
o.changeTheme($(this).attr("id")); o.changeTheme($(this).attr("id"));
// $(".theme_list > li").removeClass('thmc1').data('clicked',null).find('.theme_name').removeClass('thmtxt'); // $(".theme_list > li").removeClass('thmc1').data('clicked',null).find('.theme_name').removeClass('thmtxt');
// $(this).addClass('thmc1').data('clicked',true).find('.theme_name').addClass('thmtxt'); // $(this).addClass('thmc1').data('clicked',true).find('.theme_name').addClass('thmtxt');
$.post("/desktop/save_desktop_settings",{"save":"theme","desktopid":o.desktopId,"theme":$(this).attr("id")},function(result,status){ $.post("/desktop/save_desktop_settings",{"save":"theme","desktopid":o.desktopId,"theme":$(this).attr("id")},function(result,status){
if(status=="success"){
if(result[0].success=="true"){ if(result[0].success=="true"){
o.notify("Theme Saved!!","success",2); o.notify("Theme Saved!!","success",2);
loadthmc(); loadthmc();
} else { } else {
o.notify("Theme saving failed!!","imp",2); o.notify("Theme saving failed!!","imp",2);
} }
}else{
o.notify("Connection problem!!","alert",2);
}
}); });
}); });
// single select // single select
@ -646,14 +648,10 @@ var orbitDesktop = function(dom){
$("head").find("#dyn_css").remove(); $("head").find("#dyn_css").remove();
$("head").append(dhtml); $("head").append(dhtml);
$.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){ $.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){
if(status=="success"){
if(result[0].success=="true") if(result[0].success=="true")
o.notify("Custom theme saved!!","success",2); o.notify("Custom theme saved!!","success",2);
else else
o.notify("Custom theme saving failed!!","imp",2); o.notify("Custom theme saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
}) })
} }
}) })
@ -664,7 +662,7 @@ var orbitDesktop = function(dom){
o.changeWallpaper(wallpapername); o.changeWallpaper(wallpapername);
}) })
} }
var loadthmc = function(){ var loadthmc = function(){ // a general function to load the themecolor in color selector
$('.color-picker').each(function(){ $('.color-picker').each(function(){
var cc = $(this).attr('for'), hex, color; var cc = $(this).attr('for'), hex, color;
switch(cc){ switch(cc){
@ -705,7 +703,66 @@ var orbitDesktop = function(dom){
}); });
}; };
this.loadWallpaper = function(wallpaper){ this.initializeJournalPapers = function(target){ // this init journal papers
o.currenthtml = target;
o.currentface = "journal_p";
var bindHandlers = function(){ // bind handler for journal paper
$("div#settings ul#setting_left_nav li a").on({
click: function(){
if(!$(this).data("clicked")){
var tfunc = $(this).attr("href");
switch(tfunc){
case "list":
list();
break;
case "addpaper":
addpaper();
break;
}
$("div#settings ul#setting_left_nav li a").removeClass('thmc1 thmtxt').data('clicked',null);
$(this).addClass('thmc1 thmtxt').data('clicked',true);
}
},
mouseenter: function(){
$(this).removeClass('admtxt').addClass('thmc1 thmtxt');
},
mouseleave: function(){
var t = $(this).data('clicked') ? '' : 'thmc1 thmtxt';
$(this).removeClass(t).addClass('admtxt');
}
});
}
var list = function(){ // to open list part in journal papers page
var bindHandlers = function(){ // to bind handlers for list page
}
$("div#settings div#panel_r").load("/desktop/journal_p_list",function(){
bindHandlers();
})
}
var addpaper = function(){ // to open add pages in journal papers page
var bindHandlers = function(){ // to bind handlers for add page
}
$("div#settings div#panel_r").load("/desktop/journal_p_add",function(){
bindHandlers();
})
}
if(!o.desktopData[o.currentface]){
$(o.contentHolder).empty().load("/desktop/"+target,function(){
bindHandlers();
list();
});
}else{
$(o.contentHolder).html(o.desktopData[o.currentface]);
bindHandlers();
}
};
this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper
if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper
var ww = $(window).width(); var ww = $(window).width();
var wh = $(window).height(); var wh = $(window).height();
@ -717,14 +774,14 @@ var orbitDesktop = function(dom){
$("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh}); $("div#bgover").css({"position":"fixed","top":"0px","left":"0px","z-index":"-1","width":ww,"height":wh});
}; };
this.loadIconCache = function(){ this.loadIconCache = function(){ // this function load or refresh icon cache for the theme
var imgs = $("ul.docklist img"); var imgs = $("ul.docklist img");
$.each(imgs,function(){ $.each(imgs,function(){
var setting_name = $(this).attr("id").replace("_icon",""); var setting_name = $(this).attr("id").replace("_icon","");
$(this).attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons[setting_name]) $(this).attr("src","/"+o.themefolder+"/"+o.theme+"/images/"+o.themesettings.icons[setting_name])
}) })
}; };
this.initializeWidgets = function(){ this.initializeWidgets = function(){ // this function will initialize all the widgets in the desktop
var elements = $("#group_wrapper li.element"); var elements = $("#group_wrapper li.element");
$.each(elements,function(){ $.each(elements,function(){
var widget = $(this); var widget = $(this);
@ -738,18 +795,14 @@ var orbitDesktop = function(dom){
}) })
}; };
this.saveWallpaper = function(wallpaper){ this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db
$.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result,status){ $.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result,status){
if(status=="success"){
if(result[0].success=="true") if(result[0].success=="true")
o.notify("Wallpaper saved!!","success",2); o.notify("Wallpaper saved!!","success",2);
else else
o.notify("Wallpaper saving failed!!","imp",2); o.notify("Wallpaper saving failed!!","imp",2);
}else{
o.notify("Connection problem!!","alert",2);
}
}) })
} };
o.initialize(); o.initialize();
} }

View File

@ -56,10 +56,10 @@ var orbitDesktopAPI = function(){
}; };
this.confirm = function(settings,callbackfn){ this.confirm = function(settings,callbackfn){
if(!settings.buttons)settings.buttons=["Ok","Cancel"]; if(!settings.buttons)settings.buttons=["Ok","Cancel"];
if(settings.highlighted!=1 || settings.highlighted!=2)settings.highlighted=2; if(settings.highlighted!=1 && settings.highlighted!=2)settings.highlighted=2;
if(!settings.message)settings.message = "Are you sure?" if(!settings.message)settings.message = "Are you sure?"
var $confirm = $("#orbitdiag"); var $confirm = $("#orbitdiag");
$confirm.find(".diag_action a").addClass("admbg admtxt"); $confirm.find(".diag_action a").removeClass("thmc1 thmtxt").addClass("admbg admtxt");
$confirm.find(".diag_message").text(settings.message); $confirm.find(".diag_message").text(settings.message);
if(settings.highlighted == 1) if(settings.highlighted == 1)
$confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt"); $confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
@ -78,7 +78,7 @@ var orbitDesktopAPI = function(){
callbackfn.call(this,false); callbackfn.call(this,false);
}); });
$confirm.show(); $confirm.show();
} };
}; };
orbitDesktopAPI.prototype.notifyImgPath = "temp"; orbitDesktopAPI.prototype.notifyImgPath = "temp";
orbitDesktopAPI.prototype.wallpaperPath = "temp"; orbitDesktopAPI.prototype.wallpaperPath = "temp";

View File

@ -36,6 +36,17 @@ class DesktopController< ApplicationController
render "desktop/settings/sections", :layout => false render "desktop/settings/sections", :layout => false
end end
def journal_p
render :layout => false
end
def journal_p_list
render "desktop/journal_pages/list", :layout => false
end
def journal_p_add
render "desktop/journal_pages/add", :layout => false
end
#ajax data load.... #ajax data load....
def save_desktop_settings def save_desktop_settings

View File

@ -79,10 +79,10 @@
<div class="tile op07"></div> <div class="tile op07"></div>
<div class="diag_holder"> <div class="diag_holder">
<div class="diag_holder_inner"> <div class="diag_holder_inner">
<div class="diag_message">Continue anyway?</div> <div class="diag_message"></div>
<div class="diag_action"> <div class="diag_action">
<a href="" id="diag_confirm" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;">Yes</a> <a href="" id="diag_confirm" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;"></a>
<a href="" id="diag_cancel" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;">Cancel</a> <a href="" id="diag_cancel" class="diag_btn admbg admtxt w1 hh2 hp" onclick="return false;"></a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -0,0 +1,32 @@
<div id="journal_p">
<div id="settings">
<div id="content">
<div id="header" class="hh3">
<div class="dtitle w2 hh3 hp">
<span class="thmtxth">Journal Pages</span>
</div>
</div>
<div id="holder">
<div id="panel_l" class="ph">
<div class="s_menu sm_v">
<ul id='setting_left_nav'>
<li><a href="list" class="hh2 w2 hp active thmc1 thmtxt" onclick='return false;'>List</a></li>
<li><a href="addpaper" class="admtxt hh2 w2 hp" onclick='return false;'>Add/Edit</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Journals</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Co-Authors</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Tags &amp; Keywords</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Analysis</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Import</a></li>
<li><a href="" class="admtxt hh2 w2 hp" onclick='return false;'>Export</a></li>
</ul>
</div>
</div>
<div id="panel_r" class="ph pw admbg hp">
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1 @@
This is add page

View File

@ -0,0 +1 @@
This is list page

View File

@ -114,6 +114,9 @@ Orbit::Application.routes.draw do
match '/desktop/settingsections/'=>'desktop#settingsections' match '/desktop/settingsections/'=>'desktop#settingsections'
match '/desktop/getapplist/'=>'desktop#getapplist' match '/desktop/getapplist/'=>'desktop#getapplist'
match '/desktop/newpositions/'=>'desktop#newpositions' match '/desktop/newpositions/'=>'desktop#newpositions'
match '/desktop/journal_p/'=>'desktop#journal_p'
match '/desktop/journal_p_list/'=>'desktop#journal_p_list'
match '/desktop/journal_p_add/'=>'desktop#journal_p_add'
match '/desktop/temp_func/'=>'desktop#temp_func' match '/desktop/temp_func/'=>'desktop#temp_func'
match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request| match '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|