From a298cbd5f6ded3eab621aebac43494765ff48fc8 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Tue, 24 Apr 2012 16:45:26 +0800 Subject: [PATCH] Publication started --- app/assets/javascripts/orbitdesktop.js | 251 +++++++++++------- app/assets/javascripts/orbitdesktopAPI.js | 6 +- app/controllers/desktop_controller.rb | 11 + app/views/desktop/index.html.erb | 6 +- app/views/desktop/journal_p.html.erb | 32 +++ app/views/desktop/journal_pages/add.html.erb | 1 + app/views/desktop/journal_pages/list.html.erb | 1 + config/routes.rb | 3 + 8 files changed, 206 insertions(+), 105 deletions(-) create mode 100644 app/views/desktop/journal_p.html.erb create mode 100644 app/views/desktop/journal_pages/add.html.erb create mode 100644 app/views/desktop/journal_pages/list.html.erb diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index dc431a55..ead5741f 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1,5 +1,9 @@ // JavaScript Document //harry +//Inititialize function will initialize desktop + + + $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; @@ -25,7 +29,7 @@ var orbitDesktop = function(dom){ this.transitionTime = 500; this.currenthtml = "desktop.html"; 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.sectionList; this.initialize = function(){ @@ -43,7 +47,7 @@ var orbitDesktop = function(dom){ loadTheme(desktopSettings.customtheme,desktopSettings.wallpaper); }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){ o.themesettings = eval(ts); $('head').append( $('').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; $.getJSON("/"+o.themefolder+"/"+theme+"/settings/"+theme+".json",function(ts){ o.themesettings = eval(ts); @@ -64,9 +68,8 @@ var orbitDesktop = function(dom){ o.loadWallpaper(); 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(){ var target = $(this).attr("href"); 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(){ var target = $(this).attr("href"); if(o.currenthtml!=target){ @@ -117,7 +129,8 @@ var orbitDesktop = function(dom){ $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"; o.currenthtml = target; o.currentface = "home"; @@ -125,7 +138,7 @@ var orbitDesktop = function(dom){ var extraspace = 300; var currentElement, elementParent, targetParent, tempElement, widthcheck; widthcheck = false; - var bindHandlers = function(){ + var bindHandlers = function(){ // this function will bind all the handlers in the desktop var groupWrapperWidth = 0; var groupWrapperHeight = 0; $('div#desktop div.group').width(528); @@ -201,49 +214,47 @@ 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(groups){ + var tilecolors = o.themesettings.tilecolor; + var opacity = ["op05","op06","op07","op08","op09"]; + $.each(groups,function(i,group){ + group.sort(o.sortJSON("position",true,parseInt)); + var $group = $('
'); + $.each(group,function(j,tile){ + var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)]; + var op = opacity[Math.floor(Math.random()*opacity.length)]; + if(j==0)$group.attr("id",tile.group_id); + + if(tile.data_category == "app") + $li = $('
  • '+tile.title+'

  • '); + else + $li = $('
  • '+tile.title+'

    Loading...
  • '); + $group.find("ul").append($li); + }) + $("div#desktop div#group_wrapper").append($group); + }) + bindHandlers(); + o.initializeWidgets(); + }) } - - var loadTiles = function(id){ - $("div#desktop div#group_wrapper").empty(); - $.getJSON("/desktop/getgroups",{sectionid:id},function(groups){ - var tilecolors = o.themesettings.tilecolor; - var opacity = ["op05","op06","op07","op08","op09"]; - $.each(groups,function(i,group){ - group.sort(o.sortJSON("position",true,parseInt)); - var $group = $('
    '); - $.each(group,function(j,tile){ - var tilecolor = tilecolors[Math.floor(Math.random()*tilecolors.length)]; - var op = opacity[Math.floor(Math.random()*opacity.length)]; - if(j==0)$group.attr("id",tile.group_id); - - if(tile.data_category == "app") - $li = $('
  • '+tile.title+'

  • '); - else - $li = $('
  • '+tile.title+'

    Loading...
  • '); - $group.find("ul").append($li); - }) - $("div#desktop div#group_wrapper").append($group); - }) - bindHandlers(); - o.initializeWidgets(); + var loadSectionList = function(){ //This will load the section list from the db + $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){ + o.sectionList = eval(sectionlist); + $.each(sectionlist,function(i,section){ + var tempstyle=""; + if(i==0){ + tempstyle = "style='display:none;'"; + $("div#desktop span#section_heading").text(section.name); + } + $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); }) - } - var loadSectionList = function(){ - $.getJSON("/desktop/getsectionlist",{desktopid:o.desktopId},function(sectionlist){ - o.sectionList = eval(sectionlist); - $.each(sectionlist,function(i,section){ - var tempstyle=""; - if(i==0){ - tempstyle = "style='display:none;'"; - $("div#desktop span#section_heading").text(section.name); - } - $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); - }) - bindSecondaryHandlers(); - }) - } - - var bindSecondaryHandlers = function(){ + bindSecondaryHandlers(); + }) + } + var bindSecondaryHandlers = function(){ //This is the secondary bind handler function which is used to bind events which are repeatative $("div#desktop ul#section_list li.section_name").click(function(){ $("div#desktop li.section_name").show(); $(this).hide(); @@ -275,16 +286,18 @@ var orbitDesktop = function(dom){ bindSecondaryHandlers(); } }; + this.tempFunc = function(th){ o.confirm("What","","",function(reply){ alert(reply); }) - } - this.initializeAppSearch = function(target){ + }; + + this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization o.currenthtml = target; o.currentface = "apps_manager"; 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_search").css("width",$(window).width()-200); //for textbox search @@ -325,7 +338,7 @@ var orbitDesktop = function(dom){ .delay(1500) .addClass('op00', 500); } - var loadApps = function(){ + var loadApps = function(){ //this load apps for sorting and searching $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ $.each(appss,function(i,apps){ $.each(apps,function(i,app){ @@ -347,11 +360,11 @@ var orbitDesktop = function(dom){ bindHandlers(); } }; - this.initializeSectionsManager = function(target){ + this.initializeSectionsManager = function(target){ // this is init function for section manager o.currenthtml = target; o.currentface = "sections"; var elementParent,element,slabel; - var bindHandlers = function(){ + var bindHandlers = function(){ // this is bind handler for section manager page var groupWrapperWidth = 0; $("div#sections .group").width(400); $("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');}); } }; - var loadApps = function(){ + var loadApps = function(){ // this loads apps from db to in each sections $.getJSON("/desktop/getapplist",{desktopid:o.desktopId},function(appss){ var $group,$lii,$li; var z=0; @@ -440,8 +453,6 @@ var orbitDesktop = function(dom){ } y++; }) - - 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.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({ click: function(){ if(!$(this).data("clicked")){ @@ -485,8 +496,8 @@ var orbitDesktop = function(dom){ }); } - var sections = function(){ - var bindHandlers = function(){ + var sections = function(){ // this load section page in setting page + var bindHandlers = function(){ // binding handlers in section page $('.tinycanvas').each(function(){ var h = $(this).parent().height(), sh = $(this).siblings('.s_tab').height(); @@ -504,15 +515,10 @@ var orbitDesktop = function(dom){ desktopnm.push($(this).val()); }) $.post("/desktop/save_desktop_settings",{"save":"desktopnames","desktopid":o.desktopId,"desktopnms":desktopnm},function(result,status){ - if(status=="success"){ - if(result[0].success=="true"){ - o.notify("Names Saved!!","success",2); - } - else - o.notify("Name saving failed!!","imp",2); - }else{ - o.notify("Connection problem!!","alert",2); - } + if(result[0].success=="true"){ + o.notify("Names Saved!!","success",2); + }else + o.notify("Name saving failed!!","imp",2); }) $.each(o.sectionList,function(i,sec){ sec.name = desktopnm[i]; @@ -529,23 +535,19 @@ var orbitDesktop = function(dom){ }) } - var themes = function(){ - var bindHandlers = function(){ + var themes = function(){ // this opens themes page in setting page + var bindHandlers = function(){ // binding handlers in themes page // live change theme $(".theme_list > .ssl_item").click(function(){ o.changeTheme($(this).attr("id")); // $(".theme_list > li").removeClass('thmc1').data('clicked',null).find('.theme_name').removeClass('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){ - if(status=="success"){ - if(result[0].success=="true"){ - o.notify("Theme Saved!!","success",2); - loadthmc(); - } else { - o.notify("Theme saving failed!!","imp",2); - } - }else{ - o.notify("Connection problem!!","alert",2); + if(result[0].success=="true"){ + o.notify("Theme Saved!!","success",2); + loadthmc(); + } else { + o.notify("Theme saving failed!!","imp",2); } }); }); @@ -646,14 +648,10 @@ var orbitDesktop = function(dom){ $("head").find("#dyn_css").remove(); $("head").append(dhtml); $.post("/desktop/save_desktop_settings",{"save":"customtheme","desktopid":o.desktopId,"theme":dhtml},function(result,status){ - if(status=="success"){ - if(result[0].success=="true") - o.notify("Custom theme saved!!","success",2); - else - o.notify("Custom theme saving failed!!","imp",2); - }else{ - o.notify("Connection problem!!","alert",2); - } + if(result[0].success=="true") + o.notify("Custom theme saved!!","success",2); + else + o.notify("Custom theme saving failed!!","imp",2); }) } }) @@ -664,7 +662,7 @@ var orbitDesktop = function(dom){ o.changeWallpaper(wallpapername); }) } - var loadthmc = function(){ + var loadthmc = function(){ // a general function to load the themecolor in color selector $('.color-picker').each(function(){ var cc = $(this).attr('for'), hex, color; 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 var ww = $(window).width(); 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}); }; - this.loadIconCache = function(){ + this.loadIconCache = function(){ // this function load or refresh icon cache for the theme var imgs = $("ul.docklist img"); $.each(imgs,function(){ var setting_name = $(this).attr("id").replace("_icon",""); $(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"); $.each(elements,function(){ 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){ - if(status=="success"){ if(result[0].success=="true") o.notify("Wallpaper saved!!","success",2); else o.notify("Wallpaper saving failed!!","imp",2); - }else{ - o.notify("Connection problem!!","alert",2); - } }) - } + }; o.initialize(); } diff --git a/app/assets/javascripts/orbitdesktopAPI.js b/app/assets/javascripts/orbitdesktopAPI.js index 03686a38..ef9eb09d 100644 --- a/app/assets/javascripts/orbitdesktopAPI.js +++ b/app/assets/javascripts/orbitdesktopAPI.js @@ -56,10 +56,10 @@ var orbitDesktopAPI = function(){ }; this.confirm = function(settings,callbackfn){ 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?" 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); if(settings.highlighted == 1) $confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt"); @@ -78,7 +78,7 @@ var orbitDesktopAPI = function(){ callbackfn.call(this,false); }); $confirm.show(); - } + }; }; orbitDesktopAPI.prototype.notifyImgPath = "temp"; orbitDesktopAPI.prototype.wallpaperPath = "temp"; diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index 70694331..664b5ba4 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -36,6 +36,17 @@ class DesktopController< ApplicationController render "desktop/settings/sections", :layout => false 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.... def save_desktop_settings diff --git a/app/views/desktop/index.html.erb b/app/views/desktop/index.html.erb index 46f851cf..98ac23e3 100755 --- a/app/views/desktop/index.html.erb +++ b/app/views/desktop/index.html.erb @@ -79,10 +79,10 @@
    -
    Continue anyway?
    +
    - Yes - Cancel + +
    diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb new file mode 100644 index 00000000..3fe90735 --- /dev/null +++ b/app/views/desktop/journal_p.html.erb @@ -0,0 +1,32 @@ +
    +
    +
    + +
    + + +
    + +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/desktop/journal_pages/add.html.erb b/app/views/desktop/journal_pages/add.html.erb new file mode 100644 index 00000000..5870f615 --- /dev/null +++ b/app/views/desktop/journal_pages/add.html.erb @@ -0,0 +1 @@ +This is add page \ No newline at end of file diff --git a/app/views/desktop/journal_pages/list.html.erb b/app/views/desktop/journal_pages/list.html.erb new file mode 100644 index 00000000..035d1006 --- /dev/null +++ b/app/views/desktop/journal_pages/list.html.erb @@ -0,0 +1 @@ +This is list page \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 441a7ab9..2eb08dac 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -114,6 +114,9 @@ Orbit::Application.routes.draw do match '/desktop/settingsections/'=>'desktop#settingsections' match '/desktop/getapplist/'=>'desktop#getapplist' 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 '/panel/:app_name/front_end/:app_action/:id' => 'pages#show_from_link', :constraints => lambda { |request|