From 37f8c1637a8d5bbd36914d61a36128abc4a29d11 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Thu, 27 Dec 2012 18:25:54 +0800 Subject: [PATCH] new desktop framework updates --- app/assets/javascripts/desktop.js | 4 +- .../javascripts/desktop/books_pages.js.erb | 33 ++++ .../javascripts/desktop/journal_pages.js.erb | 173 ++---------------- .../javascripts/desktop/seminar_pages.js.erb | 58 ++++++ app/assets/javascripts/orbitdesktop.js | 109 +++++------ app/models/user/user.rb | 2 +- app/views/desktop/books.html.erb | 4 +- .../co_author_relations/_show_form.html.erb | 32 ++-- app/views/desktop/co_authors/index.html.erb | 8 +- app/views/desktop/index.html.erb | 5 +- app/views/desktop/journal_p.html.erb | 2 +- app/views/desktop/seminar_p.html.erb | 6 +- 12 files changed, 180 insertions(+), 256 deletions(-) create mode 100644 app/assets/javascripts/desktop/books_pages.js.erb create mode 100644 app/assets/javascripts/desktop/seminar_pages.js.erb diff --git a/app/assets/javascripts/desktop.js b/app/assets/javascripts/desktop.js index de5f7f71..a0fad151 100644 --- a/app/assets/javascripts/desktop.js +++ b/app/assets/javascripts/desktop.js @@ -14,4 +14,6 @@ //= require orbitdesktopAPI //= require orbitTimeline //= require orbitdesktop -//= require desktop/journal_pages \ No newline at end of file +//= require desktop/journal_pages +//= require desktop/seminar_pages +//= require desktop/books_pages \ No newline at end of file diff --git a/app/assets/javascripts/desktop/books_pages.js.erb b/app/assets/javascripts/desktop/books_pages.js.erb new file mode 100644 index 00000000..48833ff8 --- /dev/null +++ b/app/assets/javascripts/desktop/books_pages.js.erb @@ -0,0 +1,33 @@ +orbitDesktop.prototype.initializeBooks = function(target,url,cache){ + this.initializeBooks.list = function(){ + var bindHandlers = function(){ + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.list_t' + }) + } + + + bindHandlers(); + + } + + this.initializeBooks.addbook = function(){ + var bindHandlers = function(){ + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.s_grid_con' + }) + + } + + bindHandlers(); + + } + this.initializeBooks.list(); + +} diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index e2ed7bd6..79f1d17e 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -49,55 +49,8 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // } return false; }) - - $("div[container=true]").unbind(".edit").on("click.edit",".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); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - $(".bt-cancel").click(function(){ - $("div[container=true]").html(prev_data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.list_t' - }) - }) - } - }) - return false; - }) - $("div[container=true]").unbind(".delete").on("click.delete",".journal_paper_delete",function(){ - var delurl = $(this).attr("href"); - var parent = $(this).parent(); - o.confirm({ - buttons : ["Yes","No"], - highlighted : 2, - message : "Are you sure, you want to delete this paper?" - },function(value){ - if(value){ - $.ajax({ - url : delurl, - type : "DELETE", - success : function(data){ - if(data.success){ - parent.hide("slide",function(){parent.remove();}); - o.notify(data.msg,"success"); - } - } - }) - } - }) - return false; - }) - } - + var bindSecondaryHandlers = function(){ $("#journal_p div#paper_list a.icon-check-empty").click(function(){ if($(this).hasClass("icon-check-empty")){ @@ -113,6 +66,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // }) } + var journalview = function(){ $("#journal_p div#paper_list div.overview").empty(); var column = $('
'), @@ -120,7 +74,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+journal.title+'
    '+paper.title+'
  • '); + li = $('
  • '+journal.title+'
    '+paper.title+'
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -154,7 +108,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // var img = $(''+thistitle+''); file_list.append(img); }) - li.append('
    Edit Delete
    '); + li.append('
    Edit Delete
    '); column.find("ul").append(li); if(counter%3==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -173,7 +127,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.keywords+'
  • '); + li = $('
  • '+paper.title+'
    '+paper.keywords+'
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -193,7 +147,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
  • '); + li = $('
  • '+paper.title+'
  • '); column.find("ul").append(li); if(counter%5==0){ $("#journal_p div#paper_list div.overview").append(column); @@ -212,7 +166,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // li; $.each(journalData,function(i,journal){ $.each(journal.papers,function(j,paper){ - li = $('
  • '+paper.title+'
    '+paper.abstract+'
  • '); + li = $('
  • '+paper.title+'
    '+paper.abstract+'
  • '); column.find("ul").append(li); $("#journal_p div#paper_list div.overview").append(column); column = $('
    '); @@ -231,7 +185,13 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // } getData(); } - + this.initializeJournalPapers.paperDelete = function(data,dom){ + var parent = dom.parent().parent(); + if(data.success){ + parent.hide("slide",function(){parent.remove();}); + o.notify(data.msg,"success"); + } + } 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(); @@ -271,110 +231,7 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // main: '.tinycanvas', fill: '.g_col' }) - $("div[container=true]").unbind(".editcoauthor").on("click.editcoauthor", "a.bt-edit", function(){ - $.ajax({ - url : $(this).attr("href"), - type : "get", - success : function(data){ - var prev_data = $("div[container=true]").html(); - $("div[container=true]").html(data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - $(".bt-cancel").click(function(){ - $("div[container=true]").html(prev_data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.g_col' - }) - }) - } - }) - return false; - }) - $("div[container=true]").unbind(".editype").on("click.edittype", "a.bt-edit-type", function(){ - var parent = $(this).parent().parent(); - parent.find('.list_item_function').hide(); - $.ajax({ - url : $(this).attr("href"), - type : "get", - success : function(data){ - var prev_data = parent.find(".form_space").html(); - parent.find(".form_space").html(data); - $(".bt-cancel-type").click(function(){ - parent.find(".form_space").html(prev_data); - parent.find('.list_item_function').show(); - }); - } - }) - return false; - }) - $("div[container=true]").unbind(".delete").on("click.delete","a.bt-delete",function(){ - - var delurl = $(this).attr("href"); - var parent = $(this).parent().parent(); - o.confirm({ - buttons : ["Yes","No"], - highlighted : 2, - message : "Are you sure, you want to delete this author?" - },function(value){ - if(value){ - $.ajax({ - url : delurl, - type : "DELETE", - success : function(data){ - if(data.success){ - parent.hide("slide",function(){parent.remove();}); - o.notify(data.msg,"success"); - } - } - }) - } - }) - return false; - }) - $("div[container=true]").unbind(".new_type").on("click.new_type","a.bt-new-type",function(){ - $.ajax({ - url : $(this).attr("href"), - type : "get", - success : function(data){ - var prev_data = $("div[container=true]").html(); - $("div[container=true]").html(data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - $(".bt-cancel").click(function(){ - o.sub_menu_item($("div[content-type=menu] a[custom-load=coauthor]")); - - }) - } - }) - return false; - }) - $("div[container=true]").unbind(".bt-co-author").on("click.bt-co-author","a.bt-co-author",function(){ - $.ajax({ - url : $(this).attr("href"), - type : "get", - success : function(data){ - var prev_data = $("div[container=true]").html(); - $("div[container=true]").html(data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - $(".bt-cancel").click(function(){ - $("div[container=true]").html(prev_data); - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.g_col' - }) - }) - } - }) - return false; - }) + } bindHandlers(); } diff --git a/app/assets/javascripts/desktop/seminar_pages.js.erb b/app/assets/javascripts/desktop/seminar_pages.js.erb new file mode 100644 index 00000000..ebe62c18 --- /dev/null +++ b/app/assets/javascripts/desktop/seminar_pages.js.erb @@ -0,0 +1,58 @@ +orbitDesktop.prototype.initializeSeminar = function(target,url,cache){ + + this.initializeSeminar.list = function(){ + var bindHandlers = function(){ + o.tinyscrollbar_ext({ + main : ".tinycanvas", + fill : ".list_t" + }) + } + + + bindHandlers(); + + } + + this.initializeSeminar.addseminar = function(){ + var bindHandlers = function(){ + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.s_grid_con' + }) + } + + bindHandlers(); + + } + this.initializeSeminar.seminar = function(){ + var bindHandlers = function(){ + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.s_grid_con' + }) + } + + bindHandlers(); + + } + this.initializeSeminar.rues = function(){ + var bindHandlers = function(){ + o.simple_drop_down(); + + o.tinyscrollbar_ext({ + main: '.tinycanvas', + fill: '.s_grid_con' + }) + } + + bindHandlers(); + + } + + this.initializeSeminar.list(); + + } \ No newline at end of file diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index e10a6604..7ae36978 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -7,6 +7,9 @@ //load = true is used to load the list element by default //response-type = "json"|"script"|"xml|html" default is json //autocomplete-list = "listname" an array from which autocomplete will be attached to its respective input or textarea +//ajax-remote="get/delete/post" this will automatically bind the with remote ajax call. By default if the resposne is html, it ll be inserted in container=true +// content-holder = "jquery dom", the returned html of server will be put inside the dom mentioned in content-holder of a tag. this can be used in a tags as attributes +//confirm-message ="Some message", this will prompt user with a confirm box and show the message before ajax call is made. $.extend($.expr[':'], { @@ -147,6 +150,42 @@ var orbitDesktop = function(dom){ return false; }) + $("body").on("click","*[ajax-remote]",function(){ + var $e = $(this); + var exe = $e.attr("callback-method"); // (typeof $e.attr("callback-method") == "function"? $e.attr("callback-method") : ""); + var ca = $e.attr("content-holder"); + var a = function(){ + $.ajax({ + type : $e.attr("ajax-remote"), + url : $e.attr("href"), + success : function(data){ + if(typeof data == "string"){ + if(ca) + $(ca).html(data); + else + $("div[container=true]").html(data); + } + if(exe) + window.o[o.data_method][exe](data,$e); + } + }); + } + if($e.attr("confirm-message")){ + o.confirm({ + buttons : ["Yes","No"], + highlighted : 2, + message : $e.attr("confirm-message") + },function(value){ + if(value){ + a(); + } + }) + }else{ + a(); + } + return false; + }) + $(window).resize(function(){ var ww = $(window).width(); $("img#thmbackground").attr({"width":ww}); @@ -177,6 +216,7 @@ var orbitDesktop = function(dom){ var extractLast = function( term ) { return split( term ).pop(); } + var autocompleteListName = null; $("body").on("keydown","*[autocomplete-list]", function( event ) { autocompleteListName = $(this).attr("autocomplete-list"); @@ -1064,73 +1104,8 @@ var orbitDesktop = function(dom){ this.initializeAppstore.onlinestore(); bindHandlers(); } - this.initializeBooks = function(target,url,cache){ - - - this.initializeBooks.list = function(){ - var bindHandlers = function(){ - o.simple_drop_down(); - - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.list_t' - }) - } - - - bindHandlers(); - - } - - this.initializeBooks.addbook = function(){ - var bindHandlers = function(){ - o.simple_drop_down(); - - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - - } - - bindHandlers(); - - } - this.initializeBooks.list(); - - } - this.initializeSeminar = function(target,url,cache){ - - - this.initializeSeminar.list = function(){ - var bindHandlers = function(){ - o.tinyscrollbar_ext({ - main : ".tinycanvas", - fill : ".list_t" - }) - } - - - bindHandlers(); - - } - - this.initializeSeminar.addseminar = function(){ - var bindHandlers = function(){ - o.simple_drop_down(); - - o.tinyscrollbar_ext({ - main: '.tinycanvas', - fill: '.s_grid_con' - }) - } - - bindHandlers(); - - } - this.initializeSeminar.list(); - - } + + this.initializeResearchDomain = function(target,url,cache){ this.initializeResearchDomain.list = function(){ diff --git a/app/models/user/user.rb b/app/models/user/user.rb index 42254d10..966fe5ce 100644 --- a/app/models/user/user.rb +++ b/app/models/user/user.rb @@ -3,7 +3,7 @@ class User include Mongoid::Document include Mongoid::Timestamps - devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable, :timeoutable + devise :database_authenticatable, :recoverable, :rememberable, :trackable, :registerable, :validatable #, :timeoutable mount_uploader :avatar, AvatarUploader diff --git a/app/views/desktop/books.html.erb b/app/views/desktop/books.html.erb index b2c703ea..80990dc9 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/co_author_relations/_show_form.html.erb b/app/views/desktop/co_author_relations/_show_form.html.erb index a5d931a0..ad943e45 100644 --- a/app/views/desktop/co_author_relations/_show_form.html.erb +++ b/app/views/desktop/co_author_relations/_show_form.html.erb @@ -1,17 +1,17 @@ - <% @co_author_relations.each_with_index do |co_author_relation,i| %> +<% @co_author_relations.each_with_index do |co_author_relation,i| %> <% if ( i % 6 ) == 0 %> -
      -
        - <% end %> -
      • -
        <%= co_author_relation.relation %>
        -
        - <%= link_to 'Edit', edit_desktop_co_author_relation_path(co_author_relation), :class => "bt-edit-type admbg2 admtxt" %> - <%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), confirm: 'Are you sure?', method: :delete, :class=>"bt-delete admbg2 admtxt" %> -
        -
      • - <% if ( i % 6 ) == 5 %> -
      -
      - <% end %> - <% end %> \ No newline at end of file +
      +
        + <% end %> +
      • +
        <%= co_author_relation.relation %>
        +
        + <%= link_to 'Edit', edit_desktop_co_author_relation_path(co_author_relation), :class => "bt-edit-type admbg2 admtxt", "content-holder"=>"#form_space_"+i.to_s, "ajax-remote"=>"get" %> + <%= link_to 'Destroy', desktop_co_author_relation_path(co_author_relation), "confirm-message"=>'Are you sure?', "ajax-remote"=>"delete", :class=>"bt-delete admbg2 admtxt" %> +
        +
      • + <% if ( i % 6 ) == 5 %> +
      +
      + <% end %> +<% end %> \ No newline at end of file diff --git a/app/views/desktop/co_authors/index.html.erb b/app/views/desktop/co_authors/index.html.erb index 9881e2bd..4c8e297e 100644 --- a/app/views/desktop/co_authors/index.html.erb +++ b/app/views/desktop/co_authors/index.html.erb @@ -1,7 +1,7 @@
      - <%= link_to "New Co-Author", new_desktop_co_author_path, :class=>"bt-co-author fn_btn hp hh2 thmc2 thmtxt" %> - <%= link_to "New Type", desktop_co_author_relations_path, :class=>"bt-new-type fn_btn hp hh2 thmc2 thmtxt" %> + <%= link_to "New Co-Author", new_desktop_co_author_path, :class=>"bt-co-author fn_btn hp hh2 thmc2 thmtxt", "ajax-remote"=>"get" %> + <%= link_to "New Type", desktop_co_author_relations_path, :class=>"bt-new-type fn_btn hp hh2 thmc2 thmtxt", "ajax-remote"=>"get" %>
      @@ -20,8 +20,8 @@
    • <%= @co_author_relations.find(co_author.co_author_relations_id).relation unless co_author.co_author_relations_id.nil?%>
    - <%= link_to 'Edit', edit_desktop_co_author_path(co_author), :class => "bt-edit admbg2 admtxt" %> - <%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete admbg2 admtxt" %> + <%= link_to 'Edit', edit_desktop_co_author_path(co_author), :class => "bt-edit admbg2 admtxt", "ajax-remote"=>"get" %> + <%= link_to 'Destroy', desktop_co_author_path(co_author), "ajax-remote"=>"delete", "confirm-message"=>'Are you sure?', "callback-method"=>"paperDelete", :class=>"bt-delete admbg2 admtxt" %>
    <% if ( i % 4 ) == 3 %> diff --git a/app/views/desktop/index.html.erb b/app/views/desktop/index.html.erb index 3559dc35..9ce9df2f 100644 --- a/app/views/desktop/index.html.erb +++ b/app/views/desktop/index.html.erb @@ -13,11 +13,10 @@
  • Journal Papers
  • -
  • Seminar Papers
  • +
  • Seminar Papers
  • -
  • Books
  • +
  • Books
  • -
  • Books
  • Research diff --git a/app/views/desktop/journal_p.html.erb b/app/views/desktop/journal_p.html.erb index 37a0aed1..d5526450 100644 --- a/app/views/desktop/journal_p.html.erb +++ b/app/views/desktop/journal_p.html.erb @@ -16,7 +16,7 @@
  • List
  • Add/Edit
  • Journals
  • -
  • Co-Authors
  • +
  • Co-Authors
  • Tags & Keywords
  • Analysis
  • Import
  • diff --git a/app/views/desktop/seminar_p.html.erb b/app/views/desktop/seminar_p.html.erb index c79939cf..80875dc9 100644 --- a/app/views/desktop/seminar_p.html.erb +++ b/app/views/desktop/seminar_p.html.erb @@ -14,9 +14,9 @@