fix in button disablity leading to double click
This commit is contained in:
parent
b35719f1fa
commit
4e1dc65092
7 changed files with 12 additions and 20 deletions
4
js/core.min.js
vendored
4
js/core.min.js
vendored
|
|
@ -62,9 +62,9 @@ wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px
|
|||
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i<options_list.length;i++){var v=options_list[i];value=v.value||v;label=v.label||v;$('<option>').html(label).attr('value',value).appendTo(this);}
|
||||
$(this).val(options_list[0].value||options_list[0]);}
|
||||
$.fn.set_working=function(){var ele=this.get(0);if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.disabled=1;ele.loading_img=$('<img src="images/lib/ui/button-load.gif" \
|
||||
$.fn.set_working=function(){var ele=this.get(0);$(ele).attr('disabled','disabled');if(ele.loading_img){$(ele.loading_img).toggle(true);}else{ele.loading_img=$('<img src="images/lib/ui/button-load.gif" \
|
||||
style="margin-left: 4px; margin-bottom: -2px; display: inline;" />').insertAfter(ele);}}
|
||||
$.fn.done_working=function(){var ele=this.get(0);ele.disabled=0;if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery);
|
||||
$.fn.done_working=function(){var ele=this.get(0);$(ele).attr('disabled',null);if(ele.loading_img){$(ele.loading_img).toggle(false);};}})(jQuery);
|
||||
/*
|
||||
* lib/js/wn/model.js
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ function $c(command, args, callback, error, no_spinner, freeze_msg, btn) {
|
|||
// For calling an object
|
||||
function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) {
|
||||
if(arg && typeof arg!='string') arg = JSON.stringify(arg);
|
||||
|
||||
|
||||
args = {
|
||||
cmd:'runserverobj',
|
||||
arg: arg,
|
||||
|
|
|
|||
|
|
@ -1273,18 +1273,15 @@ _f.ButtonField.prototype.make_input = function() { var me = this;
|
|||
me.df.label, null,
|
||||
{fontWeight:'bold'}, null, 1)
|
||||
|
||||
this.input.onclick = function() {
|
||||
$(this.input).click(function() {
|
||||
if(me.not_in_form) return;
|
||||
this.disabled = 'disabled';
|
||||
|
||||
if(cur_frm.cscript[me.df.fieldname] && (!me.in_filter)) {
|
||||
cur_frm.runclientscript(me.df.fieldname, me.doctype, me.docname);
|
||||
this.disabled = false;
|
||||
} else {
|
||||
cur_frm.runscript(me.df.options, me);
|
||||
this.disabled = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
_f.ButtonField.prototype.hide = function() {
|
||||
|
|
|
|||
|
|
@ -865,7 +865,8 @@ _f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) {
|
|||
// make doc list
|
||||
var doclist = compress_doclist(make_doclist(this.doctype, this.docname));
|
||||
// send to run
|
||||
if(callingfield)callingfield.input.disabled = true;
|
||||
if(callingfield)
|
||||
$(callingfield.input).set_working();
|
||||
|
||||
$c('runserverobj', {'docs':doclist, 'method':scriptname },
|
||||
function(r, rtxt) {
|
||||
|
|
@ -880,7 +881,8 @@ _f.Frm.prototype.runscript = function(scriptname, callingfield, onrefresh) {
|
|||
me.refresh_dependency();
|
||||
|
||||
// enable button
|
||||
if(callingfield)callingfield.input.done_working();
|
||||
if(callingfield)
|
||||
$(callingfield.input).done_working();
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,10 +143,10 @@ wn.dom.set_box_shadow = function(ele, spread) {
|
|||
}
|
||||
$.fn.set_working = function() {
|
||||
var ele = this.get(0);
|
||||
$(ele).attr('disabled', 'disabled');
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(true);
|
||||
} else {
|
||||
ele.disabled = 1;
|
||||
ele.loading_img = $('<img src="images/lib/ui/button-load.gif" \
|
||||
style="margin-left: 4px; margin-bottom: -2px; display: inline;" />')
|
||||
.insertAfter(ele);
|
||||
|
|
@ -154,7 +154,7 @@ wn.dom.set_box_shadow = function(ele, spread) {
|
|||
}
|
||||
$.fn.done_working = function() {
|
||||
var ele = this.get(0);
|
||||
ele.disabled = 0;
|
||||
$(ele).attr('disabled', null);
|
||||
if(ele.loading_img) {
|
||||
$(ele.loading_img).toggle(false);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ wn.request.url = 'index.cgi';
|
|||
wn.request.prepare = function(opts) {
|
||||
// btn indicator
|
||||
if(opts.btn) $(opts.btn).set_working();
|
||||
|
||||
|
||||
// navbar indicator
|
||||
if(opts.show_spinner) set_loading();
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ wn.ui.Button = function(args) {
|
|||
// ajax loading
|
||||
me.loading_img = wn.dom.add(me.btn.args.parent,'img','',{margin:'0px 4px -2px 4px', display:'none'});
|
||||
me.loading_img.src= 'images/lib/ui/button-load.gif';
|
||||
if(args.is_ajax) wn.dom.css(me.btn,{marginRight:'24px'});
|
||||
|
||||
// label
|
||||
me.btn.innerHTML = args.label;
|
||||
|
|
@ -53,17 +52,11 @@ wn.ui.Button = function(args) {
|
|||
|
||||
set_working: function() {
|
||||
me.btn.disabled = 'disabled';
|
||||
if(me.btn.args.is_ajax) {
|
||||
$(me.btn).css('margin-right', '0px');
|
||||
}
|
||||
$(me.loading_img).css('display','inline');
|
||||
},
|
||||
|
||||
done_working: function() {
|
||||
me.btn.disabled = false;
|
||||
if(me.btn.args.is_ajax) {
|
||||
$(me.btn).css('margin-right', '24px');
|
||||
}
|
||||
$(me.loading_img).toggle(false);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue