Merge pull request #162 from szimszon/master

The disabled_with message should be translatable
This commit is contained in:
mdipierro
2013-08-05 05:39:43 -07:00
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -211,12 +211,13 @@
}, },
trap_form: function (action, target) { trap_form: function (action, target) {
var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working...";
$('#' + target + ' form').each(function (i) { $('#' + target + ' form').each(function (i) {
var form = $(this); var form = $(this);
form.attr('data-w2p_target', target); form.attr('data-w2p_target', target);
if(!form.hasClass('no_trap')) { if(!form.hasClass('no_trap')) {
//should be there by default ? //should be there by default ?
form.find('input[type=submit]').attr('data-w2p_disable_with', 'Working...'); form.find('input[type=submit]').attr('data-w2p_disable_with', disable_with_message);
form.submit(function (e) { form.submit(function (e) {
web2py.hide_flash(); web2py.hide_flash();
web2py.ajax_page('post', action, form.serialize(), target, form); web2py.ajax_page('post', action, form.serialize(), target, form);
@@ -431,11 +432,12 @@
disableElement: function (el) { disableElement: function (el) {
el.addClass('disabled'); el.addClass('disabled');
var method = el.prop('type') == 'submit' ? 'val' : 'html'; var method = el.prop('type') == 'submit' ? 'val' : 'html';
var disable_with_message = (typeof w2p_ajax_disable_with_message != 'undefined') ? w2p_ajax_disable_with_message : "Working...";
// store enabled state // store enabled state
el.data('w2p:enable-with', el[method]()); el.data('w2p:enable-with', el[method]());
/* little addition by default*/ /* little addition by default*/
if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) { if((el.data('w2p_disable_with') == 'default') || (el.data('w2p_disable_with') === undefined)) {
el.data('w2p_disable_with', 'Working...'); el.data('w2p_disable_with', disable_with_message);
} }
// set to disabled state // set to disabled state
el[method](el.data('w2p_disable_with')); el[method](el.data('w2p_disable_with'));
@@ -1,6 +1,7 @@
<script type="text/javascript"><!-- <script type="text/javascript"><!--
// These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below). // These variables are used by the web2py_ajax_init function in web2py_ajax.js (which is loaded below).
var w2p_ajax_confirm_message = "{{=T('Are you sure you want to delete this object?')}}"; var w2p_ajax_confirm_message = "{{=T('Are you sure you want to delete this object?')}}";
var w2p_ajax_disable_with_message = "{{=T('Working...')}}";
var w2p_ajax_date_format = "{{=T('%Y-%m-%d')}}"; var w2p_ajax_date_format = "{{=T('%Y-%m-%d')}}";
var w2p_ajax_datetime_format = "{{=T('%Y-%m-%d %H:%M:%S')}}"; var w2p_ajax_datetime_format = "{{=T('%Y-%m-%d %H:%M:%S')}}";
var ajax_error_500 = '{{=XML(T('An error occured, please %s the page') % A(T('reload'), _href=URL(args=request.args, vars=request.get_vars))) }}' var ajax_error_500 = '{{=XML(T('An error occured, please %s the page') % A(T('reload'), _href=URL(args=request.args, vars=request.get_vars))) }}'