diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js index 7bfcb0b5..37c654c7 100644 --- a/app/assets/javascripts/desktop.js +++ b/app/assets/javascripts/desktop.js @@ -7,6 +7,7 @@ //= require jquery //= require jquery_ujs //= require jquery-ui +//= require jquery.form //= require jquery.tinyscrollbar //= require jquery.miniColors.min //= require bootstrap diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index 2aca179b..de5500ea 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -2,6 +2,9 @@ //harry //Inititialize function will initialize desktop +//callback-method will be called after desktop controlled ajax call; +//container=true is the area where the view will be loaded + $.extend($.expr[':'], { 'containsi': function (elem, i, match, array) { @@ -82,7 +85,7 @@ var orbitDesktop = function(dom){ $(".docklist a").click(function(){ var target = $(this).attr("id"); var url = $(this).attr("href"); - o.data_method = $(this).attr("data-method"); + o.data_method = $(this).attr("callback-method"); if(o.currenthtml!=target){ if(o.desktopData[o.currentface] == "undefined") o.desktopData[o.currentface] = ""; @@ -95,47 +98,28 @@ var orbitDesktop = function(dom){ $(o.contentHolder).empty().load(url,function(){ if(typeof o.data_method != "undefined"){ if(o.data_method != "") - window.o[o.data_method](target,url,cache); + window.o[o.data_method](target,url,cache); } + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]")); }); }else{ $(o.contentHolder).html(o.desktopData[o.currentface]); + o.sub_menu_item($(o.contentHolder).find("*[content-type=menu] a[load=true]").trigger("click")); cache = true; if(typeof o.data_method != "undefined"){ if(o.data_method != "") - window.o[o.data_method](target,url,cache); + window.o[o.data_method](target,url,cache); } } }); } 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'); - } + o.sub_menu_item($(this)); return false; }, mouseenter: function(){ @@ -147,7 +131,23 @@ var orbitDesktop = function(dom){ var t = $(this).hasClass('active') ? '' : 'thmc1 thmtxt'; $(this).switchClass(t,'admtxt',0); } - },'.s_menu a'); + },'*[content-type=menu] a'); + + $("body").on("submit","form[type=ajax_form]",function(){ + var callback_method = $(this).attr("callback-method"); + var options = { + success:function(responseText, statusText, xhr, $form){ + if(typeof callback_method != "undefined"){ + if(callback_method != ""){ + window.o[o.data_method][callback_method](responseText,statusText,xhr,$form); + } + } + } + } + $(this).ajaxSubmit(options); + return false; + }) + $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -171,6 +171,26 @@ var orbitDesktop = function(dom){ $fn_des.stop(true, true).fadeOut(); }); }; + this.sub_menu_item = function(dom){ + if(!dom.hasClass('active')){ + var sub_data_method = dom.attr('callback-method'); + if(sub_data_method){ + $("div[container=true]").load(dom.attr("href"),function(){ + 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](); + } + } + } + } + }) + } + $('*[content-type=menu] a').removeClass('thmc1 thmtxt active'); + dom.addClass('thmc1 thmtxt active'); + } + } this.initializeDesktop = function(target,url,cache){ //this is for initializing main desktops that are sections and tiles if(!target)target = "desktop"; @@ -806,6 +826,14 @@ var orbitDesktop = function(dom){ }; this.initializeJournalPapers = function(target,url,cache){ // this init journal papers + this.initializeJournalPapers.formCallback = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + o.sub_menu_item($("div[content-type=menu] a").eq(0)); + }else{ + o.notify(data.msg,"alert"); + } + } this.initializeJournalPapers.list = function(){ // to open list part in journal papers page var journalData; @@ -817,7 +845,6 @@ var orbitDesktop = function(dom){ fill: '.list_t' }) - $("#journal_selection_options a").click(function(){ switch($(this).attr("href")){ case "all": @@ -849,10 +876,26 @@ var orbitDesktop = function(dom){ } return false; }) + + $("div[container=true]").on("click",".journal_paper_edit",function(){ + $.ajax({ + url : $(this).attr("href"), + type : "get", + success : function(data){ + var prev_data = $("div[container=true]").html(); + $("div[container=true]").html(data); + $(".bt-cancel").click(function(){ + $("div[container=true]").html(prev_data); + }) + } + }) + return false; + }) + } var bindSecondaryHandlers = function(){ - $("#journal_p div#paper_list a").click(function(){ + $("#journal_p div#paper_list a.icon-check-empty").click(function(){ if($(this).hasClass("icon-check-empty")){ $(this).switchClass("icon-check-empty","icon-check",0); } else if($(this) .hasClass("icon-check")) { @@ -873,7 +916,7 @@ var orbitDesktop = function(dom){ li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('