Clean code.
This commit is contained in:
parent
d9d5e9473d
commit
d9ff0c3cf4
1 changed files with 41 additions and 37 deletions
|
@ -1,15 +1,12 @@
|
|||
modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function ($, _, config, location) {
|
||||
|
||||
var server = {
|
||||
|
||||
backend: config.setup.BACKEND,
|
||||
api: config.setup.API === true,
|
||||
name: config.setup.SERVER_NAME,
|
||||
version: config.setup.SERVER_VERSION,
|
||||
var hasApi = config.setup.API === true;
|
||||
|
||||
request: function (data, callback) {
|
||||
|
||||
if (server.api) {
|
||||
function request(data, callback) {
|
||||
|
||||
if (hasApi) {
|
||||
$.ajax({
|
||||
url: location.getAbsHref(),
|
||||
data: data,
|
||||
|
@ -27,11 +24,11 @@ modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function (
|
|||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
formRequest: function (data) {
|
||||
function formRequest(data) {
|
||||
|
||||
if (server.api) {
|
||||
if (hasApi) {
|
||||
var $form = $('<form method="post" style="display:none;"/>')
|
||||
.attr('action', location.getAbsHref());
|
||||
|
||||
|
@ -46,7 +43,14 @@ modulejs.define('core/server', ['$', '_', 'config', 'core/location'], function (
|
|||
$form.appendTo('body').submit().remove();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
return server;
|
||||
|
||||
return {
|
||||
backend: config.setup.BACKEND,
|
||||
api: hasApi,
|
||||
name: config.setup.SERVER_NAME,
|
||||
version: config.setup.SERVER_VERSION,
|
||||
request: request,
|
||||
formRequest: formRequest
|
||||
};
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue