Mercurial > hg > soundsoftware-site
changeset 710:7db874627e11 feature_36_js_refactoring
Refactoring author/authorship related JS.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 21 Sep 2011 15:47:56 +0100 |
parents | 7fd36e4a99a1 |
children | 1ea217fdcdbf |
files | vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml vendor/plugins/redmine_bibliography/assets/javascripts/authors.js |
diffstat | 2 files changed, 59 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Sep 20 10:57:43 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Wed Sep 21 15:47:56 2011 +0100 @@ -46,7 +46,7 @@ <p> <%- if params[:action] == 'new' -%> - <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button ), :class => 'edit-save-button' } %> <%- else -%> <%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> <%- end -%>
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Sep 20 10:57:43 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Wed Sep 21 15:47:56 2011 +0100 @@ -3,17 +3,21 @@ $(link).up(".fields").hide(); } + function add_author_fields(link, association, content, action) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); $(link).insert({ before: content.replace(regexp, new_id) }); + if(action != "new"){ toggle_save_author(new_id, $(link)); }; } + + function identify_author_status(status, object_id) { $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) { if(status == "no"){ @@ -73,4 +77,57 @@ } }) } - \ No newline at end of file + + +// +// +// +Event.observe(window, 'load', function() { + + // All page's functions + var Publication = { + init: function(){ + var self = this; + var authorshipButton = $('add_another_author'); + + authorshipButton.observe('click', function(event){ + self.addAuthorship(); + }); + }, + + addAuthorship: function(){ + Publication.Authorships.add() + } + + // $(this).previous('div').down('.edit-save-button').observe('click', function(event){ + // alert(Event.element(event).innerHTML); + // alert($(this).id); + // }) + + + // ~ Pulication.Authorships + }; + + + Publication.Authorships = { + init: function(){ + var self = this; + + }, + + add: function(){ + alert("Button Pressed"); + }, + + + state: 'edit' + // ~ Pulication.Authorships + }; + + + // main + Publication.init(); + + +// ~ Event.observe +}); \ No newline at end of file