Created
October 1, 2013 11:12
-
-
Save pavelpower/6776961 to your computer and use it in GitHub Desktop.
multiselect requester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sendMultiRequestFor(userIds, cfg, method) { | |
var i = 1, width = 300, len = userIds.length, step = width / len, | |
dataFn = cfg.dataFn || function(userId) { | |
return { | |
user_id: userId | |
} | |
}; | |
Ext.MessageBox.show({ | |
title: cfg.msgBox.title, | |
msg: cfg.msgBox.msg, | |
progressText: cfg.msgBox.progressText, | |
width: width, | |
progress: true, | |
closable: false | |
}); | |
function progress() { | |
Ext.MessageBox.updateProgress(i * step, Math.round(i * 100/ len) + '% been completed!'); | |
i++; | |
} | |
if (method !== 'post' && method !== 'update') { | |
return $.when.apply(this, $.map(userIds, function(userId) { | |
return $[method](cfg.url.supplant(dataFn(userId)), progress); | |
})); | |
} else { | |
return $.when.apply(this, $.map(userIds, function(userId) { | |
return $.post(cfg.url, dataFn(userId), progress); | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment