From 7d865a65e2f28d1609dbea79e6d7fbb603989445 Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Mon, 3 Dec 2012 12:23:56 +0800 Subject: [PATCH] coauthor edit and destroy fixed --- .../javascripts/desktop/journal_pages.js.erb | 41 +++++++++++++++++++ app/assets/javascripts/orbitdesktop.js | 9 +++- app/views/desktop/co_authors/index.html.erb | 4 +- app/views/devise/registrations/edit.html.erb | 2 +- 4 files changed, 52 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/desktop/journal_pages.js.erb b/app/assets/javascripts/desktop/journal_pages.js.erb index 2f6145e7..9d76d5b6 100644 --- a/app/assets/javascripts/desktop/journal_pages.js.erb +++ b/app/assets/javascripts/desktop/journal_pages.js.erb @@ -263,6 +263,47 @@ orbitDesktop.prototype.initializeJournalPapers = function(target,url,cache){ // main: '.tinycanvas', fill: '.s_grid_con' }) + $("a.bt-edit").click(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); + }) + } + }) + return false; + }) + $("a.bt-delete").click(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; + }) } bindHandlers(); } diff --git a/app/assets/javascripts/orbitdesktop.js b/app/assets/javascripts/orbitdesktop.js index ee390441..8176e66c 100755 --- a/app/assets/javascripts/orbitdesktop.js +++ b/app/assets/javascripts/orbitdesktop.js @@ -660,7 +660,14 @@ var orbitDesktop = function(dom){ }; this.initializeSettings = function(target,url,cache){ //this is to initialize setting page - this.initializeSettings.account = function(){} + this.initializeSettings.account = function(data){} + this.initializeSettings.passwordUpdate = function(data){ + if(data.success){ + o.notify(data.msg,"success"); + }else{ + o.notify(data.msg,"alert"); + } + } this.initializeSettings.sections = function(){ // this load section page in setting page var bindHandlers = function(){ // binding handlers in section page diff --git a/app/views/desktop/co_authors/index.html.erb b/app/views/desktop/co_authors/index.html.erb index ccf78acc..6fa5b9f4 100644 --- a/app/views/desktop/co_authors/index.html.erb +++ b/app/views/desktop/co_authors/index.html.erb @@ -16,8 +16,8 @@ <%= co_author.co_author %> <%= co_author.email %> <%= co_author.type%> - <%= link_to 'Edit', edit_desktop_co_author_path(co_author) %> - <%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?' %> + <%= link_to 'Edit', edit_desktop_co_author_path(co_author), :class => "bt-edit" %> + <%= link_to 'Destroy', desktop_co_author_path(co_author), method: :delete, confirm: 'Are you sure?', :class=>"bt-delete" %> <% end %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 8fcee21a..9ec8721d 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,5 +1,5 @@ -<%= form_for(resource, :as => resource_name, :url => users_passwd_path(resource_name), :html => { :method => :put, "form-type"=>"ajax_form" }) do |f| %> +<%= form_for(resource, :as => resource_name, :url => users_passwd_path(resource_name), :html => { :method => :put, "form-type"=>"ajax_form" ,"callback-method"=>"passwordUpdate" }) do |f| %>
<%= f.submit "Update" %>
<%= f.label :current_password %>