diff options
| author | Dharmraj Jhala <dja@openerp.com> | 2015-06-17 14:31:25 +0530 |
|---|---|---|
| committer | Christophe Matthieu <chm@odoo.com> | 2015-06-17 12:51:47 +0200 |
| commit | bc43417b186c9e05f178127ebf511f8a80d005f6 (patch) | |
| tree | 7edaf26f83685219eea1fbfff40458cae8e0d48f | |
| parent | 77eca089d1697f1bbf7b5df32530f0bd9719eaab (diff) | |
[IMP] website_* Post button improved : Prevented posting to server multiple times
| -rw-r--r-- | addons/website/static/src/js/website.js | 7 | ||||
| -rw-r--r-- | addons/website_blog/views/website_blog_templates.xml | 2 | ||||
| -rw-r--r-- | addons/website_crm/views/website_crm.xml | 4 | ||||
| -rw-r--r-- | addons/website_event_track/views/website_event.xml | 2 | ||||
| -rw-r--r-- | addons/website_forum/views/website_forum.xml | 34 | ||||
| -rw-r--r-- | addons/website_hr_recruitment/views/templates.xml | 2 | ||||
| -rw-r--r-- | addons/website_quote/views/website_quotation.xml | 4 | ||||
| -rw-r--r-- | addons/website_sale/views/templates.xml | 2 | ||||
| -rw-r--r-- | addons/website_slides/view/website_slides.xml | 2 |
9 files changed, 33 insertions, 26 deletions
diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 6e3ef66ab30..4f56cee63cc 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -380,6 +380,13 @@ dom_ready.then(function () { init_kanban(this); }); + $('.js_website_submit_form').on('submit', function() { + var $buttons = $(this).find('button[type="submit"], a.a-submit'); + _.each($buttons, function(btn) { + $(btn).attr('data-loading-text', '<i class="fa fa-spinner fa-spin"></i> ' + $(btn).text()).button('loading'); + }); + }); + setTimeout(function () { if (window.location.hash.indexOf("scrollTop=") > -1) { window.document.body.scrollTop = +location.hash.match(/scrollTop=([0-9]+)/)[1]; diff --git a/addons/website_blog/views/website_blog_templates.xml b/addons/website_blog/views/website_blog_templates.xml index a2b13f31d92..0bfe17ee0b0 100644 --- a/addons/website_blog/views/website_blog_templates.xml +++ b/addons/website_blog/views/website_blog_templates.xml @@ -294,7 +294,7 @@ </xpath> <xpath expr="//ul[@id='comments-list']" position="before"> <section class="mb32 read_width css_editable_mode_hidden"> - <form id="comment" t-attf-action="/blog/post_comment/#{blog_post.id}" method="POST"> + <form id="comment" class="js_website_submit_form" t-attf-action="/blog/post_comment/#{blog_post.id}" method="POST"> <div class="media"> <span class="pull-left"> <img t-if="user_id.partner_id.image_small" class="img img-circle media-object" t-att-src="website.image_url(user_id.partner_id, 'image_small')" style="width: 30px"/> diff --git a/addons/website_crm/views/website_crm.xml b/addons/website_crm/views/website_crm.xml index 836832e668e..f27f68e84b1 100644 --- a/addons/website_crm/views/website_crm.xml +++ b/addons/website_crm/views/website_crm.xml @@ -4,7 +4,7 @@ <template id="contactus_form" name="Contact Form" inherit_id="website.contactus" customize_show="True"> <xpath expr="//div[@name='mail_button']" position="replace"> - <form action="/crm/contactus" method="post" class="form-horizontal mt32" enctype="multipart/form-data"> + <form action="/crm/contactus" method="post" class="form-horizontal mt32 js_website_submit_form" enctype="multipart/form-data"> <div t-attf-class="form-group #{error and 'contact_name' in error and 'has-error' or ''}"> <label class="col-md-3 col-sm-4 control-label" for="contact_name">Your Name</label> <div class="col-md-7 col-sm-8"> @@ -41,7 +41,7 @@ <div class="form-group"> <div class="col-md-offset-3 col-sm-offset-4 col-sm-8 col-md-7"> - <button class="btn btn-primary btn-lg">Send</button> + <button type="submit" class="btn btn-primary btn-lg">Send</button> </div> </div> </form> diff --git a/addons/website_event_track/views/website_event.xml b/addons/website_event_track/views/website_event.xml index deff0d2d3f2..725e35f5e67 100644 --- a/addons/website_event_track/views/website_event.xml +++ b/addons/website_event_track/views/website_event.xml @@ -319,7 +319,7 @@ </section> </div> <section id="forms" t-if="event.show_track_proposal"> - <form class="form-horizontal mt32" t-attf-action="/event/#{event.id}/track_proposal/post" method="post" enctype="multipart/form-data"> + <form class="form-horizontal mt32 js_website_submit_form" t-attf-action="/event/#{event.id}/track_proposal/post" method="post" enctype="multipart/form-data"> <div class="form-group"> <label class="col-md-3 col-sm-4 control-label" for="partner_name">Your Name</label> <div class="col-md-7 col-sm-8"> diff --git a/addons/website_forum/views/website_forum.xml b/addons/website_forum/views/website_forum.xml index e228901aadf..f36e7c7e66d 100644 --- a/addons/website_forum/views/website_forum.xml +++ b/addons/website_forum/views/website_forum.xml @@ -429,7 +429,7 @@ We keep a high level of quality in showcased posts, around 20% of the submited posts will be featured. </p> - <form t-att-action="action_url" method="post" role="form" class="tag_text form-horizontal"> + <form t-att-action="action_url" method="post" role="form" class="tag_text form-horizontal js_website_submit_form"> <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/> <input type="hidden" name="karma_retag" t-attf-value="#{forum.karma_retag}" id="karma_retag"/> <div class="form-group"> @@ -455,7 +455,7 @@ </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-8"> - <button t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" + <button type="submit" t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" t-att-data-karma="forum.karma_ask" disabled="True" data-hashtags="#link" data-social-target-type="other">Post</button> </div> @@ -471,7 +471,7 @@ <p> <b>Share</b> Something Awesome. </p> - <form t-attf-action="/forum/#{slug(forum)}/new?post_type=discussion" method="post" role="form" class="tag_text"> + <form t-attf-action="/forum/#{slug(forum)}/new?post_type=discussion" method="post" role="form" class="tag_text js_website_submit_form"> <input type="text" name="post_name" required="True" t-attf-value="#{post_name}" class="form-control mb16" placeholder="Your Discussion Title..."/> <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/> @@ -483,7 +483,7 @@ <input type="hidden" name="karma_retag" t-attf-value="#{forum.karma_retag}" id="karma_retag"/> <input type="text" name="post_tags" placeholder="Tags" class="form-control js_select2"/> <br/><br/> - <button t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" + <button type="submit" t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" t-att-data-karma="forum.karma_ask" data-hashtags="#discussion" data-social-target-type="default">Post Your Topic</button> </form> @@ -508,7 +508,7 @@ <li>Avoid unnecessary introductions (Hi,... Please... Thanks...),</li> <li>Provide enough details and, if possible, give an example.</li> </ul> - <form t-attf-action="/forum/#{slug(forum)}/new?post_type=question" method="post" role="form" class="tag_text"> + <form t-attf-action="/forum/#{slug(forum)}/new?post_type=question" method="post" role="form" class="tag_text js_website_submit_form"> <input type="text" name="post_name" required="True" pattern=".*\S.*" t-attf-value="#{post_name}" class="form-control mb16" placeholder="Your Question Title..." title="Title must not be empty"/> <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/> @@ -521,7 +521,7 @@ <input type="hidden" name="karma_retag" t-attf-value="#{forum.karma_retag}" id="karma_retag"/> <input type="hidden" name="post_tags" placeholder="Tags" class="form-control js_select2"/> <br/><br/> - <button t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" + <button type="submit" t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} #{(user.karma < forum.karma_ask) and 'karma_required' or ''}" t-att-data-karma="forum.karma_ask" data-hashtags="#question" data-social-target-type="question">Post Your Question</button> </form> @@ -533,7 +533,7 @@ <t t-call="website_forum.header"> <h3 t-if="not is_answer">Edit <span t-field="post.post_type"/></h3> <h3 t-if="is_answer">Edit reply</h3> - <form t-attf-action="/forum/#{slug(forum)}/post/#{slug(post)}/save" method="post" role="form" class="tag_text"> + <form t-attf-action="/forum/#{slug(forum)}/post/#{slug(post)}/save" method="post" role="form" class="tag_text js_website_submit_form"> <div t-if="not is_answer"> <input type="text" name="post_name" required="True" pattern=".*\S.*" t-attf-value="#{post.name}" class="form-control mb8" placeholder="Edit your Post" title="Title must not be empty"/> @@ -551,7 +551,7 @@ <input type="text" name="post_tags" class="form-control col-md-9 js_select2" placeholder="Tags" t-attf-data-init-value="#{tags}" value="Tags"/> <br/> </div> - <button class="btn btn-primary btn-lg">Save</button> + <button type="submit" class="btn btn-primary btn-lg">Save</button> </form> </t> </template> @@ -565,7 +565,7 @@ users having a high karma can see closed posts to moderate them. </p> - <form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(question)}/close" method="post" role="form" class="form-horizontal mt32 mb64"> + <form t-attf-action="/forum/#{ slug(forum) }/question/#{slug(question)}/close" method="post" role="form" class="form-horizontal mt32 mb64 js_website_submit_form"> <input name="post_id" t-att-value="question.id" type="hidden"/> <div class="form-group"> <label class="col-md-3 control-label" for="reason">Post:</label> @@ -585,7 +585,7 @@ </div> <div class="form-group"> <div class="col-md-offset-3 col-md-8"> - <button class="btn btn-primary">Close post</button> + <button type="submit" class="btn btn-primary">Close post</button> <span class="text-muted">or</span> <a class="btn btn-link" t-attf-href="/forum/#{ slug(forum) }/question/#{ slug(question) }">back to post</a> </div> @@ -597,13 +597,13 @@ <!-- Edition: post a reply --> <template id="post_reply"> <div class="css_editable_mode_hidden" groups="base.group_user"> - <form t-attf-id="reply#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse" + <form t-attf-id="reply#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse js_website_submit_form" t-attf-action="/forum/#{ slug(forum) }/#{slug(object)}/reply" method="post" role="form"> <h3 class="mt8">Your Reply</h3> <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/> <textarea name="content" t-attf-id="content-#{str(object.id)}" class="form-control load_editor" required="True" t-att-data-karma="forum.karma_editor"/> - <button class="btn btn-primary mb16">Post Comment</button> + <button type="submit" class="btn btn-primary mb16">Post Comment</button> </form> </div> </template> @@ -618,11 +618,11 @@ - no need to answer the same question twice. Also, please <b>don't forget to vote</b> - it really helps to select the best questions and answers! </p> - <form t-attf-action="/forum/#{ slug(forum) }/#{slug(question)}/reply" method="post" role="form"> + <form t-attf-action="/forum/#{ slug(forum) }/#{slug(question)}/reply" method="post" class="js_website_submit_form" role="form"> <input type="hidden" name="karma" t-attf-value="#{user.karma}" id="karma"/> <textarea name="content" t-attf-id="content-#{str(question.id)}" class="form-control load_editor" required="True" t-att-data-karma="forum.karma_editor"/> - <button t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} mt16 #{not question.can_answer and 'karma_required' or ''}" + <button type="submit" t-attf-class="btn btn-primary #{forum.allow_share and 'oe_social_share_call' or ''} mt16 #{not question.can_answer and 'karma_required' or ''}" t-att-data-karma="question.forum_id.karma_answer" data-social-target-type="answer" data-hashtags="#answer">Post Answer</button> </form> @@ -923,7 +923,7 @@ </small> </div> <div class="css_editable_mode_hidden"> - <form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse oe_comment_grey" + <form t-attf-id="comment#{ object._name.replace('.','') + '-' + str(object.id) }" class="collapse oe_comment_grey js_website_submit_form" t-attf-action="/forum/#{slug(forum)}/post/#{slug(object)}/comment" method="POST"> <input name="post_id" t-att-value="object.id" type="hidden" class="mt8"/> <textarea name="comment" class="form-control" placeholder="Comment this post..."/> @@ -1077,7 +1077,7 @@ <img class="img img-responsive img-circle" t-attf-src="/forum/user/#{user.id}/avatar"/> </div> <div class="col-md-10"> - <form t-attf-action="/forum/#{slug(forum)}/user/#{slug(user)}/save" method="post" role="form" class="form-horizontal"> + <form t-attf-action="/forum/#{slug(forum)}/user/#{slug(user)}/save" method="post" role="form" class="form-horizontal js_website_submit_form"> <input name="user_id" t-att-value="user.id" type="hidden"/> <div class="form-group"> <label class="col-md-2 control-label mb16" for="user_name">Real name</label> @@ -1134,7 +1134,7 @@ </div> </div> <div class="col-sm-offset-2 col-md-2 mb16"> - <button class="btn btn-primary btn-lg">Update</button> + <button type="submit" class="btn btn-primary btn-lg">Update</button> </div> </form> </div> diff --git a/addons/website_hr_recruitment/views/templates.xml b/addons/website_hr_recruitment/views/templates.xml index bc773a2dbeb..f8df63cef5c 100644 --- a/addons/website_hr_recruitment/views/templates.xml +++ b/addons/website_hr_recruitment/views/templates.xml @@ -152,7 +152,7 @@ <div class="row"> <section id="forms"> <!-- TODO Multilingual form action support ? --> - <form class="form-horizontal mt32" action="/jobs/thankyou" method="post" enctype="multipart/form-data"> + <form class="form-horizontal mt32 js_website_submit_form" action="/jobs/thankyou" method="post" enctype="multipart/form-data"> <input type="hidden" t-att-value="job and job.department_id.id or False" name="department_id"/> <input type="hidden" t-att-value="job and job.id or False" name="job_id"/> <div t-attf-class="form-group #{error.get('partner_name') and 'has-error' or ''}"> diff --git a/addons/website_quote/views/website_quotation.xml b/addons/website_quote/views/website_quotation.xml index 8d663dcf775..56507c2e49a 100644 --- a/addons/website_quote/views/website_quotation.xml +++ b/addons/website_quote/views/website_quotation.xml @@ -205,7 +205,7 @@ <!-- modal relative to the actions Accept/Reject/Cancel --> <div class="modal fade" id="modalaccept" role="dialog" aria-hidden="true"> <div class="modal-dialog"> - <form id="accept" method="POST" t-attf-action="/quote/accept/#{quotation.id}/?token=#{quotation.access_token}" class="js_accept_json modal-content"> + <form id="accept" method="POST" t-attf-action="/quote/accept/#{quotation.id}/?token=#{quotation.access_token}" class="js_accept_json modal-content js_website_submit_form"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> <h4 class="modal-title">Validate Order</h4> @@ -281,7 +281,7 @@ <h1 class="page-header">History</h1> <!-- Options:Quotation Chatter: user can reply --> <section class="mb32 css_editable_mode_hidden hidden-print"> - <form id="comment" t-attf-action="/quote/#{quotation.id}/#{quotation.access_token}/post" method="POST"> + <form id="comment" class="js_website_submit_form" t-attf-action="/quote/#{quotation.id}/#{quotation.access_token}/post" method="POST"> <img class="img pull-left img-rounded" t-att-src="website.image_url(user_id.partner_id, 'image_small')" style="width: 50px; margin-right: 10px;"/> <div class="pull-left mb32" style="width: 75%%"> <textarea rows="4" name="comment" class="form-control" placeholder="Send us a note..."></textarea> diff --git a/addons/website_sale/views/templates.xml b/addons/website_sale/views/templates.xml index d6d8a346c64..4717cd19d92 100644 --- a/addons/website_sale/views/templates.xml +++ b/addons/website_sale/views/templates.xml @@ -594,7 +594,7 @@ </li> </ul> <div class="css_editable_mode_hidden"> - <form id="comment" t-attf-action="/shop/product/comment/#{product.id}" method="POST"> + <form id="comment" class="js_website_submit_form" t-attf-action="/shop/product/comment/#{product.id}" method="POST"> <img class="img pull-left img-rounded" t-att-src="website.image_url(user_id.partner_id, 'image_small')" style="width: 50px; margin-right: 10px;"/> <div class="pull-left mb32" style="width: 75%%"> <textarea rows="3" name="comment" class="form-control" placeholder="Write a comment..."></textarea> diff --git a/addons/website_slides/view/website_slides.xml b/addons/website_slides/view/website_slides.xml index 9f015c0f510..4df31e4acd1 100644 --- a/addons/website_slides/view/website_slides.xml +++ b/addons/website_slides/view/website_slides.xml @@ -543,7 +543,7 @@ </h4> </div> <div t-att-class="comments and 'tab-pane fade active in' or 'tab-pane fade'" id="discuss"> - <form id="comment" t-attf-action="/slides/slide/#{slide.id}/comment" method="POST"> + <form id="comment" class="js_website_submit_form" t-attf-action="/slides/slide/#{slide.id}/comment" method="POST"> <div class="media"> <span class="pull-left"> <img class="img img-circle media-object" |
