diff --git a/app/assets/javascripts/orbitTimeline.js b/app/assets/javascripts/orbitTimeline.js index bd2fbb78..bdde5a24 100644 --- a/app/assets/javascripts/orbitTimeline.js +++ b/app/assets/javascripts/orbitTimeline.js @@ -59,7 +59,7 @@ var orbitTimeline = function(dom){ this.constructTimeScale = function(callbackFn){ var mon ="",year="",formname; var scale = $("
"); - $.getJSON("desktop_orbit/gettimelinespan",{"get":"papers"},function(years){ + $.getJSON("/desktop_orbit/gettimelinespan",{"get":"papers"},function(years){ var $ul = $(""); var startyear = years.startyear, endyear = years.endyear,year = years.startyear; $ul.append('
  • '+startyear+'
  • '); @@ -69,7 +69,7 @@ var orbitTimeline = function(dom){ } $("div#orbit div#year_navigation").html($ul); }) - $.getJSON("desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ + $.getJSON("/desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){ $.each(papersArray,function(i,pa){ $.each(pa.papers,function(i,paper){ var dt = new Date(paper.created_at); @@ -150,7 +150,7 @@ var orbitTimeline = function(dom){ var scale = $("#scale_wrapper"); t.ajaxload = false; - $.getJSON("desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){ + $.getJSON("/desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){ $.each(papersArray,function(i,pa){ $.each(pa.papers,function(i,paper){ var dt = new Date(paper.created_at); @@ -235,7 +235,7 @@ var orbitTimeline = function(dom){ this.ajaxEventPull = function(){ if(!t.update){ t.update = true; - $.getJSON("desktop_orbit/ajaxeventpull",{"from":t.fromdate},function(){ + $.getJSON("/desktop_orbit/ajaxeventpull",{"from":t.fromdate},function(){ }) } diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 2b4eb629..2321d92a 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -1,6 +1,8 @@ // 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; @@ -17,19 +19,22 @@ var sortDescending = function(a, b) { }; var orbitDesktop = function(dom){ orbitDesktopAPI.apply(this); - o = this; + // o = this; this.contentHolder = dom; this.themesettings = ""; this.theme = "4f8d3f493b67fcd05f086359"; this.transitionTime = 500; this.currenthtml = "desktop.html"; this.currentface = "home"; - this.desktopData = {"home":"","settings":"","work":"","favorite":"","apps_manager":"","sections":"","journal_p":"","appstore":"","orbit":"","books":"","seminar_p":"","research_d":"","research_p":""}; + this.desktopData = {}; this.tp = ""; this.sectionList; + this.data_method; this.initialize = function(){ + var theme = o.theme; var custom = false; + $.getJSON("/desktop/get_desktop_settings",{"get":"desktop","desktopid":o.desktopId},function(desktopSettings){ if(desktopSettings){ if(desktopSettings.theme!="custom"){ @@ -50,7 +55,16 @@ var orbitDesktop = function(dom){ $("head").find("#dyn_css").remove(); $("head").append(customtheme); } - $(document).ready(function(){o.loadWallpaper(customwallpaper);o.bindDesktopEvents();o.loadIconCache();o.initializeDesktop();}); + $(document).ready(function(){ + o.loadWallpaper(customwallpaper); + o.bindDesktopEvents(); + o.loadIconCache(); + + $(o.contentHolder).empty().load("desktop",function(){ + o.desktopData["d_desktop"] = ""; + o.initializeDesktop("d_desktop","",false); + }) + }); }) } } @@ -65,105 +79,75 @@ var orbitDesktop = function(dom){ }) }; 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"); + $(".docklist a").click(function(){ + var target = $(this).attr("id"); + var url = $(this).attr("href"); + o.data_method = $(this).attr("data-method"); if(o.currenthtml!=target){ + if(o.desktopData[o.currentface] == "undefined") + o.desktopData[o.currentface] = ""; o.desktopData[o.currentface] = $(o.contentHolder).html(); $("#content").hide("drop",o.transitionTime,function(){ - o.initializeAppSearch(target); + o.currenthtml = target; + o.currentface = target; + var cache = false; + if(!o.desktopData[o.currentface]){ + $(o.contentHolder).empty().load(url,function(){ + if(typeof o.data_method != "undefined"){ + if(o.data_method != "") + window.o[o.data_method](target,url,cache); + } + }); + }else{ + $(o.contentHolder).html(o.desktopData[o.currentface]); + cache = true; + if(typeof o.data_method != "undefined"){ + if(o.data_method != "") + window.o[o.data_method](target,url,cache); + } + } }); } - }); - $("a#d_desktop").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.initializeDesktop(target); - }); + return false; + }) + $('body').on({ + click: function(){ + if(!$(this).hasClass('active')){ + var sub_data_method = $(this).attr('data-method'); + if(sub_data_method){ + $("#panel_r").load($(this).attr("href"),function(){ + // o.simple_drop_down(); + + // o.tinyscrollbar_ext({ + // main: '.tinycanvas', + // fill: '.s_grid_con' + // }) + if(typeof o.data_method != "undefined"){ + if(o.data_method != ""){ + if(typeof sub_data_method != "undefined"){ + if(sub_data_method != ""){ + window.o[o.data_method][sub_data_method](); + } + } + } + } + }) + } + $('.s_menu a').removeClass('thmc1 thmtxt active'); + $(this).addClass('thmc1 thmtxt active'); + } + return false; + }, + mouseenter: function(){ + if(!$(this).hasClass('active')){ + $(this).switchClass('admtxt','thmc1 thmtxt',0); + } + }, + mouseleave: function(){ + var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; + $(this).switchClass(t,'admtxt',0); } - }); - $("a#d_sections").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.initializeSectionsManager(target); - }); - } - }); - $("#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){ - o.desktopData[o.currentface] = $(o.contentHolder).html(); - $("#content").hide("drop",o.transitionTime,function(){ - o.initializeSettings(target); - }); - } - }); - $("a#d_appstore").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.initializeAppstore(target); - }); - } - }); - $("a#d_orbit").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.initializeOrbitTimeline(target); - }); - } - }); - $("a#d_books").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.initializeBooks(target); - }); - } - }); - $("a#d_seminar_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.initializeSeminar(target); - }); - } - }); - $("a#d_research_d").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.initializeResearchDomain(target); - }); - } - }); - $("a#d_research_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.initializeResearchProject(target); - }); - } - }); + },'.s_menu a'); $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -188,11 +172,8 @@ var orbitDesktop = function(dom){ }); }; - this.initializeDesktop = function(target){ //this is for initializing main desktops that are sections and tiles + this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles if(!target)target = "desktop"; - o.currenthtml = target; - o.currentface = "home"; - var bindHandlers = function(){ // this function will bind all the handlers in the desktop var groupWrapperWidth = 0; $("div#desktop .group").each(function(){groupWrapperWidth+=$(this).outerWidth(true);}); @@ -339,7 +320,7 @@ var orbitDesktop = function(dom){ $group.find('.col'+colindex).append($li); } } - $("div#desktop div#group_wrapper").append($group); + $("div#desktop div#group_wrapper").append($group); }) bindHandlers(); o.initializeWidgets(); @@ -368,27 +349,23 @@ var orbitDesktop = function(dom){ loadTiles(o.sectionId); }) } - - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadTiles(o.sectionId); - loadSectionList(); - }); + if(cache){ + bindHandlers(); + o.initializeWidgets(); + bindSecondaryHandlers(); + $("div#desktop ul#section_list").empty(); + $.each(o.sectionList,function(i,section){ + var tempstyle=""; + if(section._id==o.sectionId){ + tempstyle = "style='display:none;'"; + $("div#desktop span#section_heading").text(section.name); + } + $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); + }) + bindSecondaryHandlers(); }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - o.initializeWidgets(); - bindSecondaryHandlers(); - $("div#desktop ul#section_list").empty(); - $.each(o.sectionList,function(i,section){ - var tempstyle=""; - if(section._id==o.sectionId){ - tempstyle = "style='display:none;'"; - $("div#desktop span#section_heading").text(section.name); - } - $("div#desktop ul#section_list").append($('
  • '+section.name+'
  • ')); - }) - bindSecondaryHandlers(); + loadTiles(o.sectionId); + loadSectionList(); } }; @@ -396,9 +373,8 @@ var orbitDesktop = function(dom){ $.post("desktop/twitter",function(){}); }; - this.initializeAppSearch = function(target){ //this is application search ie is app manager initialization - o.currenthtml = target; - o.currentface = "apps_manager"; + this.initializeAppSearch = function(target,url,cache){ //this is application search ie is app manager initialization + var searchArray,allApps; var bindHandlers = function(){ // bind handler for app manager page var gn = $('.g_col').length, @@ -474,18 +450,13 @@ var orbitDesktop = function(dom){ bindHandlers(); }) } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadApps(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - } + if(cache) + bindHandlers(); + else + loadApps(); }; - this.initializeSectionsManager = function(target){ // this is init function for section manager - o.currenthtml = target; - o.currentface = "sections"; + this.initializeSectionsManager = function(target,url,cache){ // this is init function for section manager + var elementParent,element,slabel; var bindHandlers = function(){ // this is bind handler for section manager page var groupWrapperWidth = 0; @@ -572,50 +543,15 @@ var orbitDesktop = function(dom){ bindHandlers(); }) } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - loadApps(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); + if(cache) bindHandlers(); - } + else + loadApps(); }; - this.initializeSettings = function(target){ //this is to initialize setting page - o.currenthtml = target; - o.currentface = "settings"; - 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")){ - var tfunc = $(this).attr("href"); - switch(tfunc){ - case "themes": - themes(); - break; - case "sections": - sections(); - break; - case "connection": - connection(); - 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 sections = function(){ // this load section page in setting page + this.initializeSettings = function(target,url,cache){ //this is to initialize setting page + + this.initializeSettings.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(), @@ -644,17 +580,17 @@ var orbitDesktop = function(dom){ }) }) } - $("div#settings div#panel_r").load("/desktop/settingsections",function(){ + $.getJSON("/desktop/get_desktop_settings",{"get":"sectionnames","desktopid":o.desktopId},function(sectionnames){ $("#desktop_names input").each(function(i){ $(this).val(sectionnames[i]); }) bindHandlers(); }) - }) + } - var themes = function(){ // this opens themes page in setting page + this.initializeSettings.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(){ @@ -760,7 +696,7 @@ var orbitDesktop = function(dom){ }); } - $("div#settings div#panel_r").load("/desktop/settingthemes",function(){ + $.getJSON("/desktop/get_desktop_settings",{"get":"theme","desktopid":o.desktopId},function(theme){ $('#st1 .theme_list [id='+theme+']') .addClass("thmc1 active", 300) @@ -770,10 +706,11 @@ var orbitDesktop = function(dom){ bindHandlers(); loadthmc(); }) - }) + } - var connection = function(){ + this.initializeSettings.connection = function(){ + var bindHandlers = function(){ $("#connection_setting ul a").click(function(){ var what = $(this).attr("for"), @@ -846,8 +783,8 @@ var orbitDesktop = function(dom){ } }) } - $("div#settings div#panel_r").load("/desktop/settingconnection",function(){ - $.getJSON("desktop/getaccounts",function(accounts){ + + $.getJSON("/otheraccounts/getaccounts",function(accounts){ $.each(accounts,function(i,account){ $ul = $("#"+account.type+"_connection"); $ul.find("input[type=text]").replaceWith("
    "+account.email+"
    ") @@ -859,64 +796,18 @@ var orbitDesktop = function(dom){ bindHandlers(); }) - }) } - - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); - themes(); - }); }; - this.initializeOrbitTimeline = function(target){ - o.currenthtml = target; - o.currentface = "orbit"; - var bindHandlers = function(){ - var timeline = new orbitTimeline("#timeline"); - timeline.initialize(); - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop_orbit/"+target,function(){ - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - } - }; - this.initializeJournalPapers = function(target){ // this init journal papers - o.currenthtml = target; - o.currentface = "journal_p"; - var bindHandlers = function(){ // bind handler for journal paper - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addpaper': - addpaper(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeOrbitTimeline = function(target,url,cache){ + + var timeline = new orbitTimeline("#timeline"); + timeline.initialize(); - var list = function(){ // to open list part in journal papers page + }; + this.initializeJournalPapers = function(target,url,cache){ // this init journal papers + + this.initializeJournalPapers.list = function(){ // to open list part in journal papers page var journalData; var bindHandlers = function(){ // to bind handlers for list page o.simple_drop_down(); @@ -961,7 +852,7 @@ var orbitDesktop = function(dom){ $("#journal_p div#paper_list a").click(function(){ if($(this).hasClass("icon-check-empty")){ $(this).switchClass("icon-check-empty","icon-check",0); - } else if($(this).hasClass("icon-check")) { + } else if($(this) .hasClass("icon-check")) { $(this).switchClass("icon-check","icon-check-empty",0); } else if($(this).hasClass("icon-star")){ $(this).removeClass("icon-star").addClass("icon-star-empty"); @@ -1048,16 +939,14 @@ var orbitDesktop = function(dom){ bindSecondaryHandlers(); } - $("div#journal_p div#panel_r").load("/desktop/journal_p_list",function(){ - $.getJSON("/desktop_publications/getjournals",function(journals){ - journalData = eval(journals); - journalview(); - bindHandlers(); - }) + $.getJSON("/desktop_publications/getjournals",function(journals){ + journalData = eval(journals); + journalview(); + bindHandlers(); }) } - var addpaper = function(){ // to open add pages in journal papers page + this.initializeJournalPapers.addpaper = function(){ // to open add pages in journal papers page var bindHandlers = function(){ // to bind handlers for add page o.simple_drop_down(); @@ -1066,54 +955,15 @@ var orbitDesktop = function(dom){ fill: '.s_grid_con' }) } - $("div#journal_p div#panel_r").load("/desktop/journal_p_add",function(){ - bindHandlers(); - }) + bindHandlers(); } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - bindHandlers(); - list(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - bindHandlers(); - list(); - } + }; - this.initializeAppstore = function(target){ - o.currenthtml = target; - o.currentface = "appstore"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'widgets': - widgets(); - break; - case 'onlinestore': - onlinestore(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var widgets = function(){ + this.initializeAppstore = function(target,url,cache){ + + + this.initializeAppstore.widgets = function(){ var bindHandlers = function(){ $("#widget_list a").click(function(){ var sectionid = $(this).attr("for"); @@ -1180,7 +1030,7 @@ var orbitDesktop = function(dom){ fill: '.list_t' }) } - $("div#apps_store div#panel_r").load("/desktop_appstore/widgets",function(){ + $.getJSON("/desktop_appstore/getuserwidgets",function(userwidgets){ var column = $('
    '), @@ -1230,62 +1080,25 @@ var orbitDesktop = function(dom){ counter++; }) $("#apps_store div#widget_list").append(column); - bindHandlers(); + }) - }) + } - var onlinestore = function(){ + this.initializeAppstore.onlinestore = function(){ var bindHandlers = function(){ } - $("div#apps_store div#panel_r").load("/desktop_appstore/onlinestore",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop_appstore/"+target,function(){ - onlinestore(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - onlinestore(); - bindHandlers(); + } + this.initializeAppstore.onlinestore(); + bindHandlers(); } - this.initializeBooks = function(target){ - o.currenthtml = target; - o.currentface = "books"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addbook': - addbook(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeBooks = function(target,url,cache){ + - var list = function(){ + this.initializeBooks.list = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1295,12 +1108,12 @@ var orbitDesktop = function(dom){ }) } - $("div#books div#panel_r").load("/desktop/books_list",function(){ + bindHandlers(); - }) + } - var addbook = function(){ + this.initializeBooks.addbook = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1310,55 +1123,17 @@ var orbitDesktop = function(dom){ }) } - - $("div#books div#panel_r").load("/desktop/books_add",function(){ - bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); + bindHandlers(); + } - } - this.initializeSeminar = function(target){ - o.currenthtml = target; - o.currentface = "seminar_p"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'addseminar': - addseminar(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } + this.initializeBooks.list(); - var list = function(){ + } + this.initializeSeminar = function(target,url,cache){ + + + this.initializeSeminar.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1366,12 +1141,12 @@ var orbitDesktop = function(dom){ }) } - $("div#seminar_p div#panel_r").load("/desktop/seminar_p_list",function(){ + bindHandlers(); - }) + } - var addseminar = function(){ + this.initializeSeminar.addseminar = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1381,53 +1156,15 @@ var orbitDesktop = function(dom){ }) } - $("div#seminar_p div#panel_r").load("/desktop/seminar_p_add",function(){ - bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); bindHandlers(); + } + this.initializeSeminar.list(); + } - this.initializeResearchDomain = function(target){ - o.currenthtml = target; - o.currentface = "research_d"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'add': - add_this(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var list = function(){ + this.initializeResearchDomain = function(target,url,cache){ + + this.initializeResearchDomain.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1435,67 +1172,25 @@ var orbitDesktop = function(dom){ }) } - $("div#research_d div#panel_r").load("/desktop/research_d_list",function(){ + bindHandlers(); - }) + } - var add_this = function(){ + this.initializeResearchDomain.add_this = function(){ var bindHandlers = function(){ - o.simple_drop_down(); - - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) + } - $("div#research_d div#panel_r").load("/desktop/research_d_add",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); - bindHandlers(); + } + this.initializeResearchDomain.list(); + } - this.initializeResearchProject = function(target){ - o.currenthtml = target; - o.currentface = "research_p"; - var bindHandlers = function(){ - $('.s_menu a').on({ - click: function(){ - if(!$(this).hasClass('active')){ - var tfunc = $(this).attr('href'); - switch(tfunc){ - case 'list': - list(); - break; - case 'add': - add_this(); - break; - } - $('.s_menu a').removeClass('thmc1 thmtxt active'); - $(this).addClass('thmc1 thmtxt active'); - } - }, - mouseenter: function(){ - if(!$(this).hasClass('active')){ - $(this).switchClass('admtxt','thmc1 thmtxt',0); - } - }, - mouseleave: function(){ - var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; - $(this).switchClass(t,'admtxt',0); - } - }); - } - var list = function(){ + this.initializeResearchProject = function(target,url,cache){ + + this.initializeResearchProject.list = function(){ var bindHandlers = function(){ o.tinyscrollbar_ext({ main : ".tinycanvas", @@ -1503,11 +1198,11 @@ var orbitDesktop = function(dom){ }) } - $("div#research_p div#panel_r").load("/desktop/research_p_list",function(){ + bindHandlers(); - }) + } - var add_this = function(){ + this.initializeResearchProject.add_this = function(){ var bindHandlers = function(){ o.simple_drop_down(); @@ -1517,20 +1212,12 @@ var orbitDesktop = function(dom){ }) } - $("div#research_p div#panel_r").load("/desktop/research_p_add",function(){ + bindHandlers(); - }) - } - if(!o.desktopData[o.currentface]){ - $(o.contentHolder).empty().load("/desktop/"+target,function(){ - list(); - bindHandlers(); - }); - }else{ - $(o.contentHolder).html(o.desktopData[o.currentface]); - list(); - bindHandlers(); + } + this.initializeResearchProject.list(); + } this.loadWallpaper = function(wallpaper){ // this is to load new wallpaper if(!wallpaper)wallpapernm = o.themesettings.background;else wallpapernm = wallpaper @@ -1566,7 +1253,7 @@ var orbitDesktop = function(dom){ }) }; this.saveWallpaper = function(wallpaper){ // this function saves wallpaper in db - $.post("desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){ + $.post("/desktop/save_desktop_settings",{"save":"wallpaper","wallpapernm":wallpaper,"desktopid":o.desktopId},function(result){ if(result[0].success=="true") o.notify("Wallpaper saved!!","success",2); else diff --git a/app/controllers/desktop_controller.rb b/app/controllers/desktop_controller.rb index ff657441..279694b6 100644 --- a/app/controllers/desktop_controller.rb +++ b/app/controllers/desktop_controller.rb @@ -27,17 +27,17 @@ class DesktopController< ApplicationController render :layout => false end - def settingthemes + def themes @themes = DesktopTheme.all # raise @themes.inspect render "desktop/settings/themes", :layout => false end - def settingsections + def sections render "desktop/settings/sections", :layout => false end - def settingconnection + def connections render "desktop/settings/connections", :layout => false end @@ -116,7 +116,7 @@ class DesktopController< ApplicationController if tile.data_category == "widget" widge = DesktopWidget.find(tile.desktop_widget_id.to_s) # data_content = widge.widget_layout.file - data_content = "desktop/widget_layout?id="+tile.desktop_widget_id.to_s + data_content = "/desktop/widget_layout?id="+tile.desktop_widget_id.to_s jsfile = widge.javascripts.collect{|js| js.file} cssfile = widge.css_default.file shape = widge.shape diff --git a/app/controllers/desktop_publications_controller.rb b/app/controllers/desktop_publications_controller.rb index fc3f36ab..14307022 100644 --- a/app/controllers/desktop_publications_controller.rb +++ b/app/controllers/desktop_publications_controller.rb @@ -8,7 +8,6 @@ class DesktopPublicationsController< ApplicationController end def journal_p_add - debugger render "desktop/journal_pages/add", :layout => false end diff --git a/app/views/desktop/appstore.html.erb b/app/views/desktop/appstore.html.erb index ab83d9d9..d0a4d5b7 100644 --- a/app/views/desktop/appstore.html.erb +++ b/app/views/desktop/appstore.html.erb @@ -10,8 +10,8 @@
    diff --git a/app/views/desktop/books.html.erb b/app/views/desktop/books.html.erb index 861a9926..6e8dd0dc 100644 --- a/app/views/desktop/books.html.erb +++ b/app/views/desktop/books.html.erb @@ -13,8 +13,8 @@
      -
    • List
    • -
    • Add/Edit
    • +
    • List
    • +
    • Add/Edit
    • Books
    • Co-Authors
    • Tags & Keywords
    • diff --git a/app/views/desktop/index.html.erb b/app/views/desktop/index.html.erb index 039ae65f..701e5c08 100755 --- a/app/views/desktop/index.html.erb +++ b/app/views/desktop/index.html.erb @@ -1,59 +1,64 @@
        -
      • Home +
      • Home
          -
        • App Manager
        • -
        • All Sections
        • -
        • Settings
        • +
        • App Manager
        • +
        • All Sections
        • +
        • Settings
      • -
      • Publication +
      • Publication
          -
        • Journal Papers
        • -
        • Seminar Papers
        • -
        • Books
        • + +
        • Journal Papers
        • + +
        • Seminar Papers
        • + +
        • Books
        • + +
        • Books
      • -
      • Research +
      • Research
          -
        • Research Domain
        • -
        • Research Project
        • -
        • Patents
        • -
        • Labs
        • +
        • Research Domain
        • +
        • Research Project
        • +
        • Patents
        • +
        • Labs
      • -
      • Experience +
      • Experience
          -
        • Working
        • -
        • Education
        • -
        • Honors
        • -
        • Activities
        • -
        • Clubs
        • +
        • Working
        • +
        • Education
        • +
        • Honors
        • +
        • Activities
        • +
        • Clubs
      • -
      • Learning & Teaching +
      • Learning & Teaching
          -
        • Courses
        • -
        • Homework
        • -
        • Certification
        • +
        • Courses
        • +
        • Homework
        • +
        • Certification
      • -
      • Personal +
      • Personal
          -
        • myPage
        • -
        • Blog
        • -
        • Album
        • -
        • Calendar
        • -
        • Files
        • +
        • myPage
        • +
        • Blog
        • +
        • Album
        • +
        • Calendar
        • +
        • Files
      • -
      • Orbit +
      • Orbit
          -
        • Academia Connection
        • +
        • Academia Connection
      • -
      • AppStore
      • +
      • AppStore
      diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index 6dddb734..07452f20 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -13,8 +13,8 @@
        -
      • List
      • -
      • Add/Edit
      • +
      • List
      • +
      • Add/Edit
      • Journals
      • Co-Authors
      • Tags & Keywords
      • diff --git a/app/views/desktop/journal_pages/list.html.erb b/app/views/desktop/journal_pages/list.html.erb index 3d396711..14abf97d 100644 --- a/app/views/desktop/journal_pages/list.html.erb +++ b/app/views/desktop/journal_pages/list.html.erb @@ -85,18 +85,3 @@
      -Panel::PersonalJournal::Plugin::WritingJournals - diff --git a/app/views/desktop/research_d.html.erb b/app/views/desktop/research_d.html.erb index f9b8bf5c..e96691d3 100644 --- a/app/views/desktop/research_d.html.erb +++ b/app/views/desktop/research_d.html.erb @@ -13,8 +13,8 @@
        -
      • List
      • -
      • Add/Edit
      • +
      • List
      • +
      • Add/Edit
      • Domains
      • Co-Authors
      • Tags & Keywords
      • diff --git a/app/views/desktop/research_p.html.erb b/app/views/desktop/research_p.html.erb index 43eab7be..085d3af4 100644 --- a/app/views/desktop/research_p.html.erb +++ b/app/views/desktop/research_p.html.erb @@ -13,8 +13,8 @@
        \ No newline at end of file diff --git a/app/views/desktop/settings/connections.html.erb b/app/views/desktop/settings/connections.html.erb index 148762da..153a0a46 100644 --- a/app/views/desktop/settings/connections.html.erb +++ b/app/views/desktop/settings/connections.html.erb @@ -4,7 +4,7 @@
        • No Connection
        • -
        • Facebook

        • +
        • Facebook

        • @@ -16,7 +16,7 @@
        • No Connection
        • -
        • Twitter

        • +
        • Twitter

        • @@ -28,7 +28,7 @@
        • No Connection
        • -
        • Gmail

        • +
        • Gmail

        • diff --git a/app/views/desktop/settings/themes.html.erb b/app/views/desktop/settings/themes.html.erb index 6a3c34f8..fb1ac8a5 100644 --- a/app/views/desktop/settings/themes.html.erb +++ b/app/views/desktop/settings/themes.html.erb @@ -12,7 +12,7 @@
          <% @themes.each do |theme| %> -
          <%= theme.name %>
          +
          <%= theme.name %>
          <% end %>
          @@ -63,18 +63,18 @@
        -
        1.jpg
        -
        2.jpg
        -
        3.jpg
        -
        4.jpg
        -
        5.jpg
        -
        6.jpg
        -
        7.jpg
        -
        8.jpg
        -
        9.jpg
        -
        10.jpg
        -
        11.jpg
        -
        12.jpg
        +
        1.jpg
        +
        2.jpg
        +
        3.jpg
        +
        4.jpg
        +
        5.jpg
        +
        6.jpg
        +
        7.jpg
        +
        8.jpg
        +
        9.jpg
        +
        10.jpg
        +
        11.jpg
        +
        12.jpg
        + <%= f.text_field :color, :class => "color-picker miniColors input-small", :maxlength => "5", :autocomplete=>"off",:value=>@calendar.color %> + + <%= f.fields_for :name_translations do |name| %> + <% @site_valid_locales.each_with_index do |locale, i| %> + + <%= name.text_field locale, :class => "input-large", :value=>@calendar.name_translations[locale] %> + + <% end %> <% end %> - <% end %> -
        -
        - <%= f.submit t("calendar.save"), :class=>"btn btn-primary" %> - -
        + + + + <%= f.submit t("calendar.save"), :class=>"btn btn-primary" %> + + + + <% end %> \ No newline at end of file diff --git a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb index 80de4ed2..3c63da80 100644 --- a/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb +++ b/vendor/built_in_modules/calendar/app/views/panel/calendar/back_end/cals/new.html.erb @@ -1,5 +1,6 @@ <%= stylesheet_link_tag "jquery.miniColors" %> <%= stylesheet_link_tag "calendar" %> +<%= stylesheet_link_tag "bootstrap-responsive" %> <%= javascript_include_tag "jquery.miniColors.min" %> <% content_for :page_specific_javascript do %> <%= javascript_include_tag "calendarAPI" %> @@ -57,7 +58,7 @@ <% end %> <% end %>
      -
      +
      <%= f.submit t("calendar.save"), :class=>"btn btn-primary" %>
      <% end %> diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index 59c251a4..bf32b693 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -1,190 +1,232 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController -include AdminHelper - - # before_filter :force_order_for_visitor,:only=>[:index] - before_filter :force_order_for_user#,:except => [:index] + include AdminHelper - def index - if is_manager? || is_admin? || is_sub_manager? - @authenticated = true #turn this value to false for view only - else - @authenticated = false - end - @categorylist = GalleryCategory.all - @cid = params['cat'] - @tags = GalleryTag.all - end + before_filter :force_order_for_user, :except => [:index,:get_album_json] - def show - if is_manager? || is_admin? || is_sub_manager? - @authenticated = true #turn this value to false for view only - else - @authenticated = false - end - @album = GalleryAlbum.find(params[:id]) - @tags = GalleryTag.all - end + def index + if is_manager? || is_admin? || is_sub_manager? + @authenticated = true #turn this value to false for view only + else + @authenticated = false + end + @categorylist = GalleryCategory.all + @cid = params['cat'] + @tags = GalleryTag.all + end - def new - if is_manager? || is_admin? - @categorylist = GalleryCategory.all - elsif is_sub_manager? - @categorylist = GalleryCategory.authed_for_user(current_user,"new_album") - end - @album = GalleryAlbum.new - render :layout => false - end + def show + if is_manager? || is_admin? || is_sub_manager? + @authenticated = true #turn this value to false for view only + else + @authenticated = false + end + @album = GalleryAlbum.find(params[:id]) + @tags = GalleryTag.all + end - def create - album = GalleryAlbum.new(params[:gallery_album]) - album.save! - respond_to do |h| - h.js - end - end + def new + if is_manager? || is_admin? + @categorylist = GalleryCategory.all + elsif is_sub_manager? + @categorylist = GalleryCategory.authed_for_user(current_user,"new_album") + end + @album = GalleryAlbum.new + render :layout => false + end - def get_albums - @categoryids = params["cid"] - @tags = params["tid"] - @albums = Array.new - if @categoryids == "all" - if @tags - if @tags.kind_of?(Array) - @tags.each do |tag| - @albums << GalleryAlbum.where(tag_ids: tag) - end - else - @albums << GalleryAlbum.where(tag_ids: @tags) - end - else - @albums << GalleryAlbum.all - end - else - @categoryids.each do |id| - category = GalleryCategory.find(id) - if @tags - if @tags.kind_of?(Array) - @tags.each do |tag| - @albums << category.gallery_albums.where(tag_ids: tag) - end - else - @albums << category.gallery_albums.where(tag_ids: @tags) - end - else - @albums << category.gallery_albums.all - end - end - end - @output = Array.new - @albums.each do |album| - @albs = Array.new - album.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end - category = GalleryCategory.find(values.gallery_category_id).name - @albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} - end - @output << @albs - end - render :json=>@output.to_json - end + def create + album = GalleryAlbum.new(params[:gallery_album]) + album.save! + respond_to do |h| + h.js + end + end - def destroy - album = GalleryAlbum.find(params[:id]) - album.delete - render :json =>{"success"=>true}.to_json - end + def get_albums + @categoryids = params["cid"] + @tags = params["tid"] + @albums = Array.new + if @categoryids == "all" + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << GalleryAlbum.where(tag_ids: tag) + end + else + @albums << GalleryAlbum.where(tag_ids: @tags) + end + else + @albums << GalleryAlbum.all + end + else + @categoryids.each do |id| + category = GalleryCategory.find(id) + if @tags + if @tags.kind_of?(Array) + @tags.each do |tag| + @albums << category.gallery_albums.where(tag_ids: tag) + end + else + @albums << category.gallery_albums.where(tag_ids: @tags) + end + else + @albums << category.gallery_albums.all + end + end + end + @output = Array.new + @albums.each do |album| + @albs = Array.new + album.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + category = GalleryCategory.find(values.gallery_category_id).name + @albs << {"_id"=>values.id,"show_path"=>panel_gallery_back_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags} + end + @output << @albs + end + render :json=>@output.to_json + end - def edit - if is_manager? || is_admin? || is_sub_manager? - @album = GalleryAlbum.find(params[:id]) - @images = @album.gallery_images.all - @album_name = @album.name_translations - @cover = @album.cover - @tags = GalleryTag.all - end - end + def destroy + album = GalleryAlbum.find(params[:id]) + album.delete + render :json =>{"success"=>true}.to_json + end - def set_cover - album = GalleryAlbum.find(params[:album_id]) - image = GalleryImage.find(params[:imageid]) - album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]}) - render :json =>{"success"=>true}.to_json - end + def edit + if is_manager? || is_admin? || is_sub_manager? + @album = GalleryAlbum.find(params[:id]) + @images = @album.gallery_images.all + @album_name = @album.name_translations + @cover = @album.cover + @tags = GalleryTag.all + end + end - def imgs - @album = GalleryAlbum.find(params[:album_id]) - @tag_names = Array.new - @images = @album.gallery_images.all - @output = Array.new - @images.each do |values| - tags = Array.new - values.tag_ids.each do |tag| - tags << GalleryTag.find(tag)[I18n.locale] - end - @output << {"_id"=>values.id,"theater_link"=>panel_gallery_back_end_album_image_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags} - end - if is_manager? || is_admin? || is_sub_manager? - @authenticated = true #turn this value to false for view only - else - @authenticated = false - end - if @authenticated - render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json - else - @album.tag_ids.each do |tag| - @tag_names << GalleryTag.find(tag)[I18n.locale] - end - render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json - end - end - def upload_panel - @album = GalleryAlbum.find(params[:album_id]) - render :layout => false - end - def upload_image - @album = GalleryAlbum.find(params[:album_id]) - @files = params['files'] - a = Array.new - @files.each do |file| - @image = @album.gallery_images.new - @image.file = file - @image.save! - a << {"thumbnail_url"=>@image.file.thumb.url} - end - render :json=>a.to_json - end - def images_tags - album = GalleryAlbum.find(params[:album_id]) - tags = Array.new - images = album.gallery_images.all - images.each do |image| - tags << {"id"=>image.id, "tags" => image.tag_ids} - end - render :json=>tags.to_json - end + def set_cover + album = GalleryAlbum.find(params[:album_id]) + image = GalleryImage.find(params[:imageid]) + album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:imageid]}) + render :json =>{"success"=>true}.to_json + end - def update - @album = GalleryAlbum.find(params[:id]) - @album.update_attributes(params[:gallery_album]) - if is_manager? || is_admin? || is_sub_manager? - @authenticated = true #turn this value to false for view only - else - @authenticated = false - end - if params['delete_cover'] == "true" - @album.update_attributes(:cover=>"default") - end - @tags = GalleryTag.all - render :action => :show - end + def get_album_json + albums = GalleryAlbum.all + output = Array.new + albums.each do |album| + tag_names = Array.new + all_image = Array.new + + images = album.gallery_images.all + images.each do |image| + tags = Array.new + + image.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + + all_image << { + image_title: image.title, + image_description: image.description, + image_file: { url: "http://#{request.host_with_port+image.file.url}", + thumb: "http://#{request.host_with_port+image.file.thumb.to_s}"}, + image_tag_names: tags} + end + + album.tag_ids.each do |tag| + tag_names << GalleryTag.find(tag)[I18n.locale] + end + + output << { + album_cover_file: "http://#{request.host_with_port+album.cover_path}", + album_name: album.name, + album_tag_names: tag_names, + images: all_image + } + end + + #render :json=>{:images => @output, + # :tag_names => @tag_names}.to_json + render :json=>JSON.pretty_generate(output) + end + + def imgs + @album = GalleryAlbum.find(params[:album_id]) + @tag_names = Array.new + @images = @album.gallery_images.all + @output = Array.new + @images.each do |values| + tags = Array.new + values.tag_ids.each do |tag| + tags << GalleryTag.find(tag)[I18n.locale] + end + @output << { _id: values.id, + theater_link: panel_gallery_back_end_album_image_path(values), + description: values.description, + title: values.title, + file: values.file, + gallery_album_id: values.gallery_album_id, + tag_ids: values.tag_ids, + tag_names: tags} + end + if is_manager? || is_admin? || is_sub_manager? + @authenticated = true #turn this value to false for view only + else + @authenticated = false + end + if @authenticated + render :json=>{"images" => @output, "tags" => @album.tag_ids}.to_json + else + @album.tag_ids.each do |tag| + @tag_names << GalleryTag.find(tag)[I18n.locale] + end + render :json=>{"images" => @output, "tags" => @album.tag_ids, "tag_names" => @tag_names}.to_json + end + end + + def upload_panel + @album = GalleryAlbum.find(params[:album_id]) + render :layout => false + end + + def upload_image + @album = GalleryAlbum.find(params[:album_id]) + @files = params['files'] + a = Array.new + @files.each do |file| + @image = @album.gallery_images.new + @image.file = file + @image.save! + a << {"thumbnail_url"=>@image.file.thumb.url} + end + render :json=>a.to_json + end + def images_tags + album = GalleryAlbum.find(params[:album_id]) + tags = Array.new + images = album.gallery_images.all + images.each do |image| + tags << {"id"=>image.id, "tags" => image.tag_ids} + end + render :json=>tags.to_json + end + + def update + @album = GalleryAlbum.find(params[:id]) + @album.update_attributes(params[:gallery_album]) + if is_manager? || is_admin? || is_sub_manager? + @authenticated = true #turn this value to false for view only + else + @authenticated = false + end + if params['delete_cover'] == "true" + @album.update_attributes(:cover=>"default") + end + @tags = GalleryTag.all + render :action => :show + end end - - - - - - diff --git a/vendor/built_in_modules/gallery/config/routes.rb b/vendor/built_in_modules/gallery/config/routes.rb index 77de541e..8795594b 100644 --- a/vendor/built_in_modules/gallery/config/routes.rb +++ b/vendor/built_in_modules/gallery/config/routes.rb @@ -1,54 +1,55 @@ Rails.application.routes.draw do - namespace :panel do - namespace :gallery do - namespace :back_end do - match "get_albums" => "albums#get_albums" - match "upload_image" => "albums#upload_image" - match "save_tags" => "tags#save_tags" - match "albums/save_tags" => "tags#save_tags" - resources :albums do - match "set_cover" => "albums#set_cover" - match "imgs" => "albums#imgs" - match "upload_panel" => "albums#upload_panel" - match "images_tags" => "albums#images_tags" - end + namespace :panel do + namespace :gallery do + namespace :back_end do + match "get_albums" => "albums#get_albums" + match "upload_image" => "albums#upload_image" + match "save_tags" => "tags#save_tags" + match "albums/save_tags" => "tags#save_tags" + resources :albums do + match "set_cover" => "albums#set_cover" + match "imgs" => "albums#imgs" + match "upload_panel" => "albums#upload_panel" + match "images_tags" => "albums#images_tags" + collection do + get "get_album_json" + end + end - match "album_images/#!/:id" => "album_images#show" - - resources :album_images + match "album_images/#!/:id" => "album_images#show" + resources :album_images + resources :gallery_categories + resources :tags - resources :gallery_categories - resources :tags - - end - namespace :front_end do - match "get_albums" => "albums#get_albums" - # match "orbit_galleries" => "orbit_galleries#index" - # match "gallery_category_save" => "orbit_galleries#new_category" - # match "categorylist" => "orbit_galleries#categorylist" - # match "gallery_category_delete" => "orbit_galleries#gallery_category_delete" - # match "add_album" => "orbit_galleries#add_album" - # match "create_album" => "orbit_galleries#create_album" - # match "get_albums" => "orbit_galleries#get_albums" - # match "upload_image" => "orbit_galleries#upload_image" - # match "upload_panel" => "orbit_galleries#upload_panel" - # match "get_images" => "orbit_galleries#get_images" - # match "theater" => "orbit_galleries#theater" - # match "delete_album" => "orbit_galleries#delete_album" - # match "edit_album" => "orbit_galleries#edit_album" - # match "set_cover" => "orbit_galleries#set_cover" - # match "delete_images" => "orbit_galleries#delete_images" - # match "update_album" => "orbit_galleries#update_album" - # match "save_tags" => "orbit_galleries#save_tags" - resources :albums do - member do - get "imgs" - get "theater" - end - end - resources :album_images - end - end - end + end + namespace :front_end do + match "get_albums" => "albums#get_albums" + # match "orbit_galleries" => "orbit_galleries#index" + # match "gallery_category_save" => "orbit_galleries#new_category" + # match "categorylist" => "orbit_galleries#categorylist" + # match "gallery_category_delete" => "orbit_galleries#gallery_category_delete" + # match "add_album" => "orbit_galleries#add_album" + # match "create_album" => "orbit_galleries#create_album" + # match "get_albums" => "orbit_galleries#get_albums" + # match "upload_image" => "orbit_galleries#upload_image" + # match "upload_panel" => "orbit_galleries#upload_panel" + # match "get_images" => "orbit_galleries#get_images" + # match "theater" => "orbit_galleries#theater" + # match "delete_album" => "orbit_galleries#delete_album" + # match "edit_album" => "orbit_galleries#edit_album" + # match "set_cover" => "orbit_galleries#set_cover" + # match "delete_images" => "orbit_galleries#delete_images" + # match "update_album" => "orbit_galleries#update_album" + # match "save_tags" => "orbit_galleries#save_tags" + resources :albums do + member do + get "imgs" + get "theater" + end + end + resources :album_images + end + end + end end diff --git a/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js b/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js new file mode 100644 index 00000000..dee720fa --- /dev/null +++ b/vendor/built_in_modules/gprs/app/assets/javascripts/panel/gprs/back_end/locations.js @@ -0,0 +1,2 @@ +// Place all the behaviors and hooks related to the matching controller here. +// All this logic will automatically be available in application.js. diff --git a/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css b/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css new file mode 100644 index 00000000..afad32db --- /dev/null +++ b/vendor/built_in_modules/gprs/app/assets/stylesheets/panel/gprs/back_end/locations.css @@ -0,0 +1,4 @@ +/* + Place all the styles related to the matching controller here. + They will automatically be included in application.css. +*/ diff --git a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb index c09b1379..884e5d13 100644 --- a/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb +++ b/vendor/built_in_modules/gprs/app/controllers/panel/gprs/back_end/locations_controller.rb @@ -1,29 +1,77 @@ class Panel::Gprs::BackEnd::LocationsController < OrbitBackendController - - def index - @newlocation = Location.new - end - def create - debugger - @newlocation = Location.new(params[:location]) - @newlocation.save! - render :action => "index" - end + #before_filter :clean_values, :only => [:create, :update] - def get_locations - locations = Location.all - @data = Array.new + before_filter :force_order_for_visitor,:only => [:index, :new, :edit, :delete] + before_filter :force_order_for_user,:except => :get_locations + #before_filter :for_app_sub_manager,:except => [:index, :new, :edit, :delete, :get_locations] - locations.each do |location| - picurl = "http://"+request.host + location.file.url - thumburl = "http://"+request.host + location.file.thumb.url - @data << {"name"=>location.name,"pic_url"=>picurl,"thumb_url"=>thumburl,"description"=>location.description} - end - render :json => @data.to_json - end - + def index + @locations = Location.all + respond_to do |format| + format.html # new.html.erb + format.json { render json: @locations } + end + end + + def new + @location = Location.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @location } + end + end + + def edit + @location = Location.find(params[:id]) + end + + def show + @location = Location.find(params[:id]) + respond_to do |format| + format.html + format.json { render json: @location } + end + end + + def create + @location = Location.new(params[:location]) + @location.save! + redirect_to panel_gprs_back_end_locations_url + end + + def update + @location = Location.find(params[:id]) + @location.update_attributes(params[:location]) + redirect_to panel_gprs_back_end_locations_url + end + + def destroy + @location = Location.find(params[:id]) + @location.destroy + redirect_to panel_gprs_back_end_locations_url + + end + + def get_locations + locations = Location.all + @data = Array.new + + locations.each do |location| + picurl = "http://#{request.host_with_port + location.file.url}", + thumburl = "http://#{request.host_with_port + location.file.thumb.url}" + @data << { name: location.name, + pic_url: picurl, + thumb_url: thumburl, + longitude: location.longitude, + latitude: location.latitude, + description: location.description } + end + + #print readable json + render :json => JSON.pretty_generate({location: @data}) + + #render :json => {location: @data}.to_json + end end - - - diff --git a/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb b/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb new file mode 100644 index 00000000..50985d54 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/helpers/panel/gprs/back_end/locations_helper.rb @@ -0,0 +1,2 @@ +module Panel::Gprs::BackEnd::LocationsHelper +end diff --git a/vendor/built_in_modules/gprs/app/models/location.rb b/vendor/built_in_modules/gprs/app/models/location.rb index 2f955205..f6455920 100644 --- a/vendor/built_in_modules/gprs/app/models/location.rb +++ b/vendor/built_in_modules/gprs/app/models/location.rb @@ -1,12 +1,11 @@ class Location - include Mongoid::Document - include Mongoid::Timestamps + include Mongoid::Document + include Mongoid::Timestamps - mount_uploader :file, GprsUploader + mount_uploader :file, GprsUploader - field :name - field :description - field :longitude, type: Float - field :latitude, type: Float - -end \ No newline at end of file + field :name + field :description + field :longitude, type: Float + field :latitude, type: Float +end diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb new file mode 100644 index 00000000..62e8b21b --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/_form.html.erb @@ -0,0 +1,30 @@ +
      + +
      + <%= f.text_field :name, :class=>"span4", :placeholder => "Area" %> +
      +
      +
      + +
      + <%= f.file_field :file %> +
      +
      +
      + +
      + <%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> + <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> +
      +
      +
      + +
      + <%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %> +
      +
      +
      +
      + <%= f.submit "Save", :class=>"btn" %> +
      +
      diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb new file mode 100644 index 00000000..82a59afa --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/edit.html.erb @@ -0,0 +1,4 @@ +<%= form_for @location, :url=> panel_gprs_back_end_location_path(@location), :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> + diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb index 912c0184..6731688d 100644 --- a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/index.html.erb @@ -1,42 +1,28 @@ + + + + + + + + + + + + + + <% @locations.each do |location| %> + + + + + + + + + + <% end %> + +
      <%= t('location.picture') %><%= t('location.name') %><%= t('location.longitude') %><%= t('location.latitude') %><%= t('location.description') %><%= t('location.edit') %><%= t('location.delete') %>
      <%= image_tag(location.file, alt: location.file, size: "50x50" )%><%= location.name%><%= location.longitude%><%= location.latitude%><%= location.description%><%= link_to 'Edit', edit_panel_gprs_back_end_location_path(location) %><%= link_to 'Destroy', panel_gprs_back_end_location_path(location), method: :delete , :confirm => t(:sure?) %>
      - -<%= form_for @newlocation, :url=>{:action => "create"}, :remote => true, :class=>"form-horizontal" do |f| %> -
      - -
      - - <%= f.text_field :name, :class=>"span4", :placeholder => "Area" %> -
      -
      -
      - -
      - - <%= f.file_field :file %> -
      -
      -
      - -
      - - <%= f.text_field :longitude, :class=>"span2", :placeholder => "Longitude" %> - <%= f.text_field :latitude, :class=>"span2", :placeholder => "Langitude" %> - - -
      -
      -
      - -
      - - <%= f.text_area :description, :class=>"span4", :cols=>"30", :row=>"5" %> -
      -
      -
      -
      - - <%= f.submit "Save", :class=>"btn" %> -
      -
      - <% end %> - \ No newline at end of file +<%= link_to 'New', new_panel_gprs_back_end_location_path %> diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb new file mode 100644 index 00000000..4f911d83 --- /dev/null +++ b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/new.html.erb @@ -0,0 +1,3 @@ +<%= form_for @location, :url=> panel_gprs_back_end_locations_path, :html => { :class=>"form-horizontal"} do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> +<% end %> diff --git a/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/show.html.erb b/vendor/built_in_modules/gprs/app/views/panel/gprs/back_end/locations/show.html.erb new file mode 100644 index 00000000..e69de29b diff --git a/vendor/built_in_modules/gprs/config/routes.rb b/vendor/built_in_modules/gprs/config/routes.rb index 050b2cbd..0ba8a27c 100644 --- a/vendor/built_in_modules/gprs/config/routes.rb +++ b/vendor/built_in_modules/gprs/config/routes.rb @@ -1,14 +1,12 @@ Rails.application.routes.draw do - namespace :panel do - namespace :gprs do - namespace :back_end do + namespace :panel do + namespace :gprs do + namespace :back_end do - match "locations/get_locations" => "locations#get_locations" - - resources :locations - - end - end - end + match "locations/get_locations" => "locations#get_locations" + resources :locations + end + end + end end diff --git a/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb b/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb new file mode 100644 index 00000000..bb6d0908 --- /dev/null +++ b/vendor/built_in_modules/gprs/test/functional/panel/gprs/back_end/locations_controller_test.rb @@ -0,0 +1,14 @@ +require 'test_helper' + +class Panel::Gprs::BackEnd::LocationsControllerTest < ActionController::TestCase + test "should get index" do + get :index + assert_response :success + end + + test "should get edit" do + get :edit + assert_response :success + end + +end diff --git a/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb b/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb new file mode 100644 index 00000000..e1302ea2 --- /dev/null +++ b/vendor/built_in_modules/gprs/test/unit/helpers/panel/gprs/back_end/locations_helper_test.rb @@ -0,0 +1,4 @@ +require 'test_helper' + +class Panel::Gprs::BackEnd::LocationsHelperTest < ActionView::TestCase +end