Skip to content

Commit

Permalink
Merge pull request #171 from forio/jquery3
Browse files Browse the repository at this point in the history
Jquery3
  • Loading branch information
mmrj authored Sep 20, 2016
2 parents 75699ca + 5f7d4b3 commit 8cc4e9e
Show file tree
Hide file tree
Showing 34 changed files with 307 additions and 381 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist/* binary
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pids
!.bowerrc
!.gitignore
!.jscsrc
!.gitattributes

# sass
.sass-cache/
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"tests"
],
"dependencies": {
"jquery": "~2.1.1",
"jquery": "~3.1.0",
"cometd-jquery": "2.9.0"
},
"devDependencies": {}
Expand Down
6 changes: 3 additions & 3 deletions dist/components/assignment/assignment.js

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions dist/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ $(function () {
})
.then(function () {
window.location = action;
})
.done(function () {
$('.group-selection-dialog').hide();
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/assignment/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://forio.com/tools/js-libs/<%= version %>/components/assignment/assignment.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/2.4.1/lodash.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion src/components/assignment/js/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Assignment.prototype = {
this._showUpdating();
var maxUsers = +this.$('#max-users').val();
return this.worlds.autoAssignAll({ maxUsers: maxUsers })
.done(this._hideUpdating)
.then(this._hideUpdating)
.fail(this._hideUpdating)
.then(function () {
this.worlds.joinUsers();
Expand Down
2 changes: 1 addition & 1 deletion src/components/assignment/js/users-collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ module.exports = classFrom(Base, {
.then(function (users) {
users = _.map(users, function (u) { return _.extend(u, { groupId: groupId }); });
_this.set(users);
dtd.resolve(users, _this);
dtd.resolve(users);
});

return dtd.promise();
Expand Down
2 changes: 1 addition & 1 deletion src/components/login/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<link rel="stylesheet" href="https://forio.com/tools/js-libs/<%= version %>/components/login/login.css">

<!-- make sure to include jquery, epicenter.js and login.js -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://forio.com/tools/js-libs/<%= version %>/epicenter.min.js"></script>
<script src="https://forio.com/tools/js-libs/<%= version %>/components/login/login.js"></script>
</head>
Expand Down
2 changes: 0 additions & 2 deletions src/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ $(function () {
})
.then(function () {
window.location = action;
})
.done(function () {
$('.group-selection-dialog').hide();
});
});
Expand Down
4 changes: 2 additions & 2 deletions src/env-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ var envLoad = function (callback) {
}
var infoUrl = host + envPath;
envPromise = $.ajax({ url: infoUrl, async: false });
envPromise.done(function (res) {
envPromise.then(function (res) {
var api = res.api;
$.extend(urlConfigService, api);
}).fail(function (res) {
// Epicenter/webserver not properly configured
// fallback to api.forio.com
$.extend(urlConfigService, { protocol: 'https', host: 'api.forio.com' });
});
return envPromise.done(callback).fail(callback);
return envPromise.then(callback).fail(callback);
};

module.exports = envLoad;
2 changes: 1 addition & 1 deletion src/managers/auth-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ AuthManager.prototype = $.extend(AuthManager.prototype, {
_this.sessionManager.removeSession();
};

return this.authAdapter.logout(adapterOptions).done(removeCookieFn);
return this.authAdapter.logout(adapterOptions).then(removeCookieFn);
},

/**
Expand Down
4 changes: 2 additions & 2 deletions src/managers/run-strategies/multiplayer-strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ var Strategy = classFrom(IdentityStrategy, {

var loadRunFromWorld = function (world) {
if (!world) {
return dtd.reject({ statusCode: 404, error: 'The user is not in any world.' }, { options: this.options, session: session });
return dtd.reject({ statusCode: 404, error: 'The user is not in any world.' }, { options: _this.options, session: session });
}

return worldApi.getCurrentRunId({ model: model, filter: world.id })
Expand All @@ -60,7 +60,7 @@ var Strategy = classFrom(IdentityStrategy, {

var serverError = function (error) {
// is this possible?
dtd.reject(error, session, this.options);
dtd.reject(error, session, _this.options);
};

this.worldApi
Expand Down
2 changes: 1 addition & 1 deletion src/managers/world-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function buildStrategy(worldId, dtd) {
return _this.runService.load(runId);
})
.then(function (run) {
dtd.resolve.call(this, run, _this.runService);
dtd.resolveWith(_this, [run]);
})
.fail(dtd.reject);
}
Expand Down
2 changes: 1 addition & 1 deletion src/service/asset-api-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ module.exports = function (config) {
var fullPathFiles = $.map(files, function (file) {
return buildUrl(file, urlOptions);
});
dtd.resolve(fullPathFiles, me);
dtd.resolveWith(me, [fullPathFiles]);
})
.fail(dtd.reject);

Expand Down
2 changes: 1 addition & 1 deletion src/service/run-api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ module.exports = function (config) {
);
}
$.when.apply(this, queue)
.done(function () {
.then(function () {
$d.resolve.apply(this, arguments);
postOptions.success.apply(this.arguments);
})
Expand Down
4 changes: 2 additions & 2 deletions src/service/world-api-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -585,10 +585,10 @@ module.exports = function (config) {
var currentWorld = worlds[0];

if (currentWorld) {
serviceOptions.filter = currentWorld.id;
serviceOptions.filter = currentWorld.id;
}

dtd.resolve(currentWorld, me);
dtd.resolveWith(me, [currentWorld]);
})
.fail(dtd.reject);

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/assets/assets-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ $(function() {
am.login({
userName: $('#txtUsername').val(),
password: $('#txtPassword').val(),
}).done(function (response) {
}).then(function (response) {
$loginEl.modal('hide');
$('.status').append('<div class="alert alert-success">Logged in as: ' + credentials.userName + '</div>');
_this.assetAdapter = new F.service.Asset(server);
Expand All @@ -66,7 +66,7 @@ $(function() {
var imageExtensions = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'bmp'];
$('.images').empty();

this.assetAdapter.list({ scope: scope }).done(function (response) {
this.assetAdapter.list({ scope: scope }).then(function (response) {
$.each(response, function () {
var url = this;
var filename = url.substring(url.lastIndexOf('/') + 1);
Expand Down Expand Up @@ -103,7 +103,7 @@ $(function() {

try {
// filename will be ignored if it's a multipart/form-data request
this.assetAdapter.create(filename, data, { scope: scope }).done(function () {
this.assetAdapter.create(filename, data, { scope: scope }).then(function () {
$('.status').html('<div class="alert alert-success">File uploaded! Reloading assets... </div>');
$('.list [name=scope]').val(scope);
_this.listAssets();
Expand All @@ -130,7 +130,7 @@ $(function() {
// var aa = new F.service.Asset($.extend(server, extra));
// aa.create('test.txt', { encoding: 'BASE_64', data: 'VGhpcyBpcyBhIHRlc3QgZmlsZS4=' }, { scope: 'user' });
//aa.delete('test1.txt', { scope: 'user' });
// aa.list({ scope: 'user', fullUrl: true }).done(function (response) {
// aa.list({ scope: 'user', fullUrl: true }).then(function (response) {
// console.log(response);
// });
});
2 changes: 1 addition & 1 deletion tests/integration/multiplayer/test-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ $(function () {
password: $('#txtPassword').val(),
account: $('#txtAccount').val(),
project: $('#txtProject').val()
}).done(function () {
}).then(function () {
window.alert('login successful');
});
});
Expand Down
4 changes: 1 addition & 3 deletions tests/spec/test-ajax-http-transport.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
server.respondWith('GET', /api\.fail/, function (xhr, id) {
xhr.respond(500, { 'Content-Type': 'application/json' }, JSON.stringify({ url: xhr.url }));
});
//server.autoRespond = true;
server.respondImmediately = true;

});

Expand Down Expand Up @@ -96,7 +96,6 @@
ajax.get({ a:2,b:3 }, {
success: callback
});
server.respond();
callback.called.should.equal(true);
});
it('should call fail callback on success', function () {
Expand All @@ -106,7 +105,6 @@
ajax.get({ a:2,b:3 }, {
error: callback
});
server.respond();

callback.called.should.equal(true);
});
Expand Down
36 changes: 17 additions & 19 deletions tests/spec/test-asset-api-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
server.respondWith('POST', /(.*)\/asset\/(.*)\/(.*)/, function (xhr, id) {
xhr.respond(204);
});
server.autoRespond = true;
server.respondImmediately = true;
});

after(function () {
Expand Down Expand Up @@ -177,29 +177,27 @@
it('should get the list of the assets for the user', function () {
var callback = sinon.spy();
var aa = new F.service.Asset(defaults);
aa.list({ scope: 'user', fullUrl: false }).done(callback);

server.respond();
var req = server.requests.pop();
req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId');
req.method.should.equal('GET');
callback.should.have.been.called;
callback.should.have.been.calledWith(['file.txt', 'file2.txt']);
return aa.list({ scope: 'user', fullUrl: false }).then(callback).then(function () {
var req = server.requests.pop();
req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId');
req.method.should.equal('GET');
callback.should.have.been.called;
callback.should.have.been.calledWith(['file.txt', 'file2.txt']);
});
});

it('should get the list of the assets for the user with the full URL', function () {
var callback = sinon.spy();
var aa = new F.service.Asset(defaults);
aa.list({ scope: 'user' }).done(callback);

server.respond();
var req = server.requests.pop();
req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId');
req.method.should.equal('GET');
callback.should.have.been.called;
callback.should.have.been.calledWith([
baseURL + 'user/forio/js-libs/asset-group/myUserId/file.txt',
baseURL + 'user/forio/js-libs/asset-group/myUserId/file2.txt']);
return aa.list({ scope: 'user' }).then(callback).then(function () {
var req = server.requests.pop();
req.url.should.equal(baseURL + 'user/forio/js-libs/asset-group/myUserId');
req.method.should.equal('GET');
callback.should.have.been.called;
callback.should.have.been.calledWith([
baseURL + 'user/forio/js-libs/asset-group/myUserId/file.txt',
baseURL + 'user/forio/js-libs/asset-group/myUserId/file2.txt']);
});
});
});

Expand Down
3 changes: 1 addition & 2 deletions tests/spec/test-auth-api-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{ 'refresh_token':'snip-refresh','access_token': token,'expires':43199 }
));
});
server.autoRespond = true;
server.respondImmediately = true;
});

after(function () {
Expand All @@ -27,7 +27,6 @@
var as = new AuthService({ transport: { beforeSend: callback } });
as.login({ userName: 'john', password: 'y' });

server.respond();
server.requests.pop();
callback.should.have.been.called;
});
Expand Down
Loading

0 comments on commit 8cc4e9e

Please sign in to comment.