Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 248ff43

Browse files
committed
chore: prettify sources
1 parent 1900f97 commit 248ff43

14 files changed

+2744
-1460
lines changed

src/sortable.js

Lines changed: 200 additions & 105 deletions
Large diffs are not rendered by default.

test/karma.conf.js

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,22 @@ module.exports = function(config) {
77
var wiredep = require('wiredep');
88

99
var fs = require('fs');
10-
var bowerOverrides = JSON.parse(fs.readFileSync('./test/bower_overrides.json'));
10+
var bowerOverrides = JSON.parse(
11+
fs.readFileSync('./test/bower_overrides.json')
12+
);
1113

1214
var devJSDependencies = wiredep({
1315
devDependencies: true,
1416
overrides: bowerOverrides
1517
}).js;
1618

1719
config.set({
18-
1920
// base path, that will be used to resolve files and exclude
2021
basePath: '..',
2122

22-
2323
// frameworks to use
2424
frameworks: ['jasmine'],
2525

26-
2726
// list of files / patterns to load in the browser
2827
files: devJSDependencies.concat([
2928
'test/libs/jquery.simulate.dragandrevert.js',
@@ -34,35 +33,26 @@ module.exports = function(config) {
3433
'test/sortable.tests.css'
3534
]),
3635

37-
3836
// list of files to exclude
39-
exclude: [
40-
41-
],
42-
37+
exclude: [],
4338

4439
// test results reporter to use
4540
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
4641
reporters: ['progress'],
4742

48-
4943
// web server port
5044
port: 9876,
5145

52-
5346
// enable / disable colors in the output (reporters and logs)
5447
colors: true,
5548

56-
5749
// level of logging
5850
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
5951
logLevel: config.LOG_INFO,
6052

61-
6253
// enable / disable watching file and executing tests whenever any file changes
6354
autoWatch: false,
6455

65-
6656
// Start these browsers, currently available:
6757
// - Chrome
6858
// - ChromeCanary
@@ -71,13 +61,11 @@ module.exports = function(config) {
7161
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`)
7262
// - PhantomJS
7363
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`)
74-
browsers: ['Chrome', 'Firefox'/*, 'PhantomJS'*/],
75-
64+
browsers: ['Chrome', 'Firefox' /*, 'PhantomJS'*/],
7665

7766
// If browser does not capture in given timeout [ms], kill it
7867
captureTimeout: 60000,
7968

80-
8169
// Continuous Integration mode
8270
// if true, it capture browsers, run tests and exit
8371
singleRun: false
Lines changed: 59 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
1-
;(function($, undefined) {
2-
function findCenter(elem) {
3-
var offset,
4-
document = $(elem.ownerDocument);
5-
elem = $(elem);
6-
offset = elem.offset();
7-
8-
return {
9-
x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
10-
y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
11-
};
12-
}
13-
14-
$.extend($.simulate.prototype, {
15-
simulateDragAndRevert: function() {
16-
var i = 0,
17-
target = this.target,
18-
options = this.options,
19-
center = findCenter(target),
20-
x = Math.floor(center.x),
21-
y = Math.floor(center.y),
22-
dx = options.dx || 0,
23-
dy = options.dy || 0,
24-
moves = options.moves || 3,
25-
coord = {
26-
clientX: x,
27-
clientY: y
28-
};
29-
30-
this.simulateEvent(target, "mousedown", coord);
31-
32-
for (; i < moves; i++) {
33-
x += dx / moves;
34-
y += dy / moves;
35-
36-
coord = {
37-
clientX: Math.round(x),
38-
clientY: Math.round(y)
39-
};
40-
41-
this.simulateEvent(document, "mousemove", coord);
42-
}
43-
44-
for (i = 0; i < moves; i++) {
45-
x -= dx / moves;
46-
y -= dy / moves;
47-
48-
coord = {
49-
clientX: Math.round(x),
50-
clientY: Math.round(y)
51-
};
52-
53-
this.simulateEvent(document, "mousemove", coord);
54-
}
55-
56-
this.simulateEvent(target, "mouseup", coord);
57-
this.simulateEvent(target, "click", coord);
58-
}
59-
});
1+
(function($, undefined) {
2+
function findCenter(elem) {
3+
var offset,
4+
document = $(elem.ownerDocument);
5+
elem = $(elem);
6+
offset = elem.offset();
7+
8+
return {
9+
x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(),
10+
y: offset.top + elem.outerHeight() / 2 - document.scrollTop()
11+
};
12+
}
13+
14+
$.extend($.simulate.prototype, {
15+
simulateDragAndRevert: function() {
16+
var i = 0,
17+
target = this.target,
18+
options = this.options,
19+
center = findCenter(target),
20+
x = Math.floor(center.x),
21+
y = Math.floor(center.y),
22+
dx = options.dx || 0,
23+
dy = options.dy || 0,
24+
moves = options.moves || 3,
25+
coord = {
26+
clientX: x,
27+
clientY: y
28+
};
29+
30+
this.simulateEvent(target, 'mousedown', coord);
31+
32+
for (; i < moves; i++) {
33+
x += dx / moves;
34+
y += dy / moves;
35+
36+
coord = {
37+
clientX: Math.round(x),
38+
clientY: Math.round(y)
39+
};
40+
41+
this.simulateEvent(document, 'mousemove', coord);
42+
}
43+
44+
for (i = 0; i < moves; i++) {
45+
x -= dx / moves;
46+
y -= dy / moves;
47+
48+
coord = {
49+
clientX: Math.round(x),
50+
clientY: Math.round(y)
51+
};
52+
53+
this.simulateEvent(document, 'mousemove', coord);
54+
}
55+
56+
this.simulateEvent(target, 'mouseup', coord);
57+
this.simulateEvent(target, 'click', coord);
58+
}
59+
});
6060
})(jQuery);

test/sortable.e2e.callbacks.attr.spec.js

Lines changed: 68 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
11
'use strict';
22

33
describe('uiSortable', function() {
4-
5-
beforeEach(module(function($compileProvider) {
6-
if (typeof $compileProvider.debugInfoEnabled === 'function') {
7-
$compileProvider.debugInfoEnabled(false);
8-
}
9-
}));
4+
beforeEach(
5+
module(function($compileProvider) {
6+
if (typeof $compileProvider.debugInfoEnabled === 'function') {
7+
$compileProvider.debugInfoEnabled(false);
8+
}
9+
})
10+
);
1011

1112
// Ensure the sortable angular module is loaded
1213
beforeEach(module('ui.sortable'));
1314
beforeEach(module('ui.sortable.testHelper'));
1415

15-
var EXTRA_DY_PERCENTAGE, listContent, hasUndefinedProperties, beforeLiElement, afterLiElement;
16-
17-
beforeEach(inject(function (sortableTestHelper) {
18-
EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
19-
listContent = sortableTestHelper.listContent;
20-
hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
21-
beforeLiElement = sortableTestHelper.extraElements && sortableTestHelper.extraElements.beforeLiElement;
22-
afterLiElement = sortableTestHelper.extraElements && sortableTestHelper.extraElements.afterLiElement;
23-
}));
16+
var EXTRA_DY_PERCENTAGE,
17+
listContent,
18+
hasUndefinedProperties,
19+
beforeLiElement,
20+
afterLiElement;
21+
22+
beforeEach(
23+
inject(function(sortableTestHelper) {
24+
EXTRA_DY_PERCENTAGE = sortableTestHelper.EXTRA_DY_PERCENTAGE;
25+
listContent = sortableTestHelper.listContent;
26+
hasUndefinedProperties = sortableTestHelper.hasUndefinedProperties;
27+
beforeLiElement =
28+
sortableTestHelper.extraElements &&
29+
sortableTestHelper.extraElements.beforeLiElement;
30+
afterLiElement =
31+
sortableTestHelper.extraElements &&
32+
sortableTestHelper.extraElements.afterLiElement;
33+
})
34+
);
2435

2536
tests.description = 'Attribute Callbacks related';
26-
function tests (useExtraElements) {
27-
37+
function tests(useExtraElements) {
2838
var host;
2939

30-
beforeEach(inject(function() {
31-
host = $('<div id="test-host"></div>');
32-
$('body').append(host);
40+
beforeEach(
41+
inject(function() {
42+
host = $('<div id="test-host"></div>');
43+
$('body').append(host);
3344

34-
if (!useExtraElements) {
35-
beforeLiElement = afterLiElement = '';
36-
}
37-
}));
45+
if (!useExtraElements) {
46+
beforeLiElement = afterLiElement = '';
47+
}
48+
})
49+
);
3850

3951
afterEach(function() {
4052
host.remove();
@@ -44,12 +56,15 @@ describe('uiSortable', function() {
4456
it('should cancel sorting of node "Two"', function() {
4557
inject(function($compile, $rootScope) {
4658
var element;
47-
element = $compile(''.concat(
48-
'<ul ui-sortable ui-sortable-update="update" ng-model="items">',
49-
beforeLiElement,
50-
'<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>',
51-
afterLiElement,
52-
'</ul>'))($rootScope);
59+
element = $compile(
60+
''.concat(
61+
'<ul ui-sortable ui-sortable-update="update" ng-model="items">',
62+
beforeLiElement,
63+
'<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>',
64+
afterLiElement,
65+
'</ul>'
66+
)
67+
)($rootScope);
5368
$rootScope.$apply(function() {
5469
$rootScope.update = function(e, ui) {
5570
if (ui.item.sortable.model === 'Two') {
@@ -97,7 +112,8 @@ describe('uiSortable', function() {
97112

98113
it('should call all callbacks with the proper context', function() {
99114
inject(function($compile, $rootScope) {
100-
var element, callbackContexts = {};
115+
var element,
116+
callbackContexts = {};
101117
$rootScope.$apply(function() {
102118
$rootScope.create = function() {
103119
callbackContexts.create = this;
@@ -134,27 +150,28 @@ describe('uiSortable', function() {
134150
spyOn($rootScope, 'deactivate').and.callThrough();
135151
spyOn($rootScope, 'stop').and.callThrough();
136152
$rootScope.items = ['One', 'Two', 'Three'];
137-
element = $compile(''.concat(
138-
'<ul ui-sortable ' +
139-
'ui-sortable-create="create" ' +
140-
// 'ui-sortable-helper="helper" ' +
141-
'ui-sortable-start="start" ' +
142-
'ui-sortable-activate="activate" ' +
143-
'ui-sortable-update="update" ' +
144-
'ui-sortable-before-stop="beforeStop" ' +
145-
'ui-sortable-deactivate="deactivate" ' +
146-
'ui-sortable-stop="stop" ' +
147-
'ng-model="items">',
148-
beforeLiElement,
149-
'<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>',
150-
afterLiElement +
151-
'</ul>'))($rootScope);
153+
element = $compile(
154+
''.concat(
155+
'<ul ui-sortable ' +
156+
'ui-sortable-create="create" ' +
157+
// 'ui-sortable-helper="helper" ' +
158+
'ui-sortable-start="start" ' +
159+
'ui-sortable-activate="activate" ' +
160+
'ui-sortable-update="update" ' +
161+
'ui-sortable-before-stop="beforeStop" ' +
162+
'ui-sortable-deactivate="deactivate" ' +
163+
'ui-sortable-stop="stop" ' +
164+
'ng-model="items">',
165+
beforeLiElement,
166+
'<li ng-repeat="item in items" id="s-{{$index}}">{{ item }}</li>',
167+
afterLiElement + '</ul>'
168+
)
169+
)($rootScope);
152170
});
153171

154172
host.append(element);
155173

156-
$rootScope.$apply(function() {
157-
});
174+
$rootScope.$apply(function() {});
158175
var li = element.find('[ng-repeat]:eq(0)');
159176
var dy = (2 + EXTRA_DY_PERCENTAGE) * li.outerHeight();
160177
li.simulate('drag', { dy: dy });
@@ -184,16 +201,15 @@ describe('uiSortable', function() {
184201
});
185202
}
186203

187-
[0, 1].forEach(function(useExtraElements){
204+
[0, 1].forEach(function(useExtraElements) {
188205
var testDescription = tests.description;
189206

190207
if (useExtraElements) {
191208
testDescription += ' with extra elements';
192209
}
193210

194-
describe(testDescription, function(){
211+
describe(testDescription, function() {
195212
tests(useExtraElements);
196213
});
197214
});
198-
199-
});
215+
});

0 commit comments

Comments
 (0)