Skip to content

Commit c9e5263

Browse files
committed
prettier javascript
1 parent 21e0306 commit c9e5263

File tree

115 files changed

+4364
-4165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+4364
-4165
lines changed

Diff for: .gitignore

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
1-
*.log
21
*.css.map
2+
*.log
33
*.swo
44
*.swp
55
*~
6+
.DS_Store
67
.bundle
78
.sass-cache
8-
coverage/
9-
node_modules/
109
/paternslib.sublime-project
1110
/paternslib.sublime-workspace
1211
/stamp-yarn
1312
Gemfile.lock
1413
cache/
15-
webpack/cache/
14+
coverage/
1615
dist/
17-
stats.json
18-
stats.html
19-
test-reports
16+
node_modules/
2017
src/pat/auto-scale/auto-scale.css
2118
src/pat/auto-submit/auto-submit.css
2219
src/pat/auto-suggest/auto-suggest.css
@@ -57,4 +54,7 @@ src/pat/toggle/toggle.css
5754
src/pat/tooltip/tooltip.css
5855
src/pat/validate/validate.css
5956
src/pat/zoom/zoom.css
60-
.DS_Store
57+
stats.html
58+
stats.json
59+
test-reports
60+
webpack/cache/

Diff for: .travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
dist: xenial
22
language: node_js
33
node_js:
4-
- lts/*
4+
- lts/*
55
before_script: travis_retry make stamp-yarn
66
script: make check
77
sudo: required

Diff for: src/core/base.js

+24-31
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
/**
2-
* A Base pattern for creating scoped patterns. It's similar to Backbone's
3-
* Model class. The advantage of this approach is that each instance of a
4-
* pattern has its own local scope (closure).
5-
*
6-
* A new instance is created for each DOM element on which a pattern applies.
7-
*
8-
* You can assign values, such as $el, to `this` for an instance and they
9-
* will remain unique to that instance.
10-
*
11-
* Older Patternslib patterns on the other hand have a single global scope for
12-
* all DOM elements.
13-
*/
2+
* A Base pattern for creating scoped patterns. It's similar to Backbone's
3+
* Model class. The advantage of this approach is that each instance of a
4+
* pattern has its own local scope (closure).
5+
*
6+
* A new instance is created for each DOM element on which a pattern applies.
7+
*
8+
* You can assign values, such as $el, to `this` for an instance and they
9+
* will remain unique to that instance.
10+
*
11+
* Older Patternslib patterns on the other hand have a single global scope for
12+
* all DOM elements.
13+
*/
1414

1515
import $ from "jquery";
1616
import Registry from "./registry";
1717
import logging from "./logging";
1818
import mockupParser from "./mockup-parser";
1919

20-
2120
var log = logging.getLogger("Patternslib Base");
2221

23-
var initBasePattern = function($el, options, trigger) {
24-
if(!$el.jquery) {
22+
var initBasePattern = function ($el, options, trigger) {
23+
if (!$el.jquery) {
2524
$el = $($el);
2625
}
2726
var name = this.prototype.name;
@@ -35,18 +34,15 @@ var initBasePattern = function($el, options, trigger) {
3534
: options;
3635
pattern = new Registry.patterns[name]($el, options, trigger);
3736
} catch (e) {
38-
log.error(
39-
"Failed while initializing '" + name + "' pattern.",
40-
e
41-
);
37+
log.error("Failed while initializing '" + name + "' pattern.", e);
4238
}
4339
$el.data("pattern-" + name, pattern);
4440
}
4541
return pattern;
4642
};
4743

48-
var Base = function($el, options, trigger) {
49-
if(!$el.jquery) {
44+
var Base = function ($el, options, trigger) {
45+
if (!$el.jquery) {
5046
$el = $($el);
5147
}
5248
this.$el = $el;
@@ -57,22 +53,19 @@ var Base = function($el, options, trigger) {
5753

5854
Base.prototype = {
5955
constructor: Base,
60-
on: function(eventName, eventCallback) {
61-
this.$el.on(
62-
eventName + "." + this.name + ".patterns",
63-
eventCallback
64-
);
56+
on: function (eventName, eventCallback) {
57+
this.$el.on(eventName + "." + this.name + ".patterns", eventCallback);
6558
},
66-
emit: function(eventName, args) {
59+
emit: function (eventName, args) {
6760
// args should be a list
6861
if (args === undefined) {
6962
args = [];
7063
}
7164
this.$el.trigger(eventName + "." + this.name + ".patterns", args);
72-
}
65+
},
7366
};
7467

75-
Base.extend = function(patternProps) {
68+
Base.extend = function (patternProps) {
7669
/* Helper function to correctly set up the prototype chain for new patterns.
7770
*/
7871
var parent = this;
@@ -91,7 +84,7 @@ Base.extend = function(patternProps) {
9184
if (patternProps.hasOwnProperty("constructor")) {
9285
child = patternProps.constructor;
9386
} else {
94-
child = function() {
87+
child = function () {
9588
parent.apply(this, arguments);
9689
};
9790
}
@@ -106,7 +99,7 @@ Base.extend = function(patternProps) {
10699

107100
// Set the prototype chain to inherit from `parent`, without calling
108101
// `parent`'s constructor function.
109-
var Surrogate = function() {
102+
var Surrogate = function () {
110103
this.constructor = child;
111104
};
112105
Surrogate.prototype = parent.prototype;

Diff for: src/core/base.test.js

+36-35
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import $ from "jquery";
33
import Base from "./base";
44
import _ from "underscore";
55

6-
describe("pat-base: The Base class for patterns", function() {
6+
describe("pat-base: The Base class for patterns", function () {
77
var patterns = registry.patterns;
88

99
beforeEach(function () {
@@ -14,21 +14,21 @@ describe("pat-base: The Base class for patterns", function() {
1414
registry.patterns = patterns;
1515
});
1616

17-
it("can be extended and used in similar way as classes", function() {
17+
it("can be extended and used in similar way as classes", function () {
1818
var Tmp = Base.extend({
1919
name: "example",
2020
trigger: "pat-example",
2121
some: "thing",
22-
init: function() {
22+
init: function () {
2323
expect(this.$el.hasClass("pat-example")).toEqual(true);
2424
expect(_.includes(_.keys(this.options), "option")).toBeTruthy();
2525
this.extra();
2626
},
27-
extra: function() {
27+
extra: function () {
2828
expect(this.some).toEqual("thing");
29-
}
29+
},
3030
});
31-
var tmp = new Tmp($("<div class=\"pat-example\"/>"), {option: "value"});
31+
var tmp = new Tmp($('<div class="pat-example"/>'), { option: "value" });
3232
expect(tmp instanceof Tmp).toBeTruthy();
3333
});
3434

@@ -54,11 +54,11 @@ describe("pat-base: The Base class for patterns", function() {
5454
expect(tmp instanceof Tmp).toBeTruthy();
5555
});
5656

57-
it("will automatically register a pattern in the registry when extended", function() {
57+
it("will automatically register a pattern in the registry when extended", function () {
5858
spyOn(registry, "register").and.callThrough();
5959
var NewPattern = Base.extend({
6060
name: "example",
61-
trigger: ".pat-example"
61+
trigger: ".pat-example",
6262
});
6363
expect(NewPattern.prototype.trigger).toEqual(".pat-example");
6464
expect(NewPattern.prototype.name).toEqual("example");
@@ -67,86 +67,87 @@ describe("pat-base: The Base class for patterns", function() {
6767
expect(_.includes(_.keys(registry.patterns), "example")).toBeTruthy();
6868
});
6969

70-
it("will not automatically register a pattern without a \"name\" attribute", function() {
70+
it('will not automatically register a pattern without a "name" attribute', function () {
7171
spyOn(registry, "register").and.callThrough();
72-
var NewPattern = Base.extend({trigger: ".pat-example"});
72+
var NewPattern = Base.extend({ trigger: ".pat-example" });
7373
expect(NewPattern.prototype.trigger).toEqual(".pat-example");
7474
expect(registry.register).not.toHaveBeenCalled();
7575
});
7676

77-
it("will not automatically register a pattern without a \"trigger\" attribute", function() {
77+
it('will not automatically register a pattern without a "trigger" attribute', function () {
7878
spyOn(registry, "register").and.callThrough();
79-
var NewPattern = Base.extend({name: "example"});
79+
var NewPattern = Base.extend({ name: "example" });
8080
expect(registry.register).not.toHaveBeenCalled();
8181
expect(NewPattern.prototype.name).toEqual("example");
8282
});
8383

84-
it("will instantiate new instances of a pattern when the DOM is scanned", function() {
84+
it("will instantiate new instances of a pattern when the DOM is scanned", function () {
8585
var NewPattern = Base.extend({
8686
name: "example",
8787
trigger: ".pat-example",
88-
init: function() {
88+
init: function () {
8989
expect(this.$el.attr("class")).toEqual("pat-example");
90-
}
90+
},
9191
});
9292
spyOn(NewPattern, "init").and.callThrough();
93-
registry.scan($("<div class=\"pat-example\"/>"));
93+
registry.scan($('<div class="pat-example"/>'));
9494
expect(NewPattern.init).toHaveBeenCalled();
9595
});
9696

97-
it("requires that patterns that extend it provide an object of properties", function() {
98-
expect(Base.extend)
99-
.toThrowError(
100-
"Pattern configuration properties required when calling Base.extend"
101-
);
97+
it("requires that patterns that extend it provide an object of properties", function () {
98+
expect(Base.extend).toThrowError(
99+
"Pattern configuration properties required when calling Base.extend"
100+
);
102101
});
103102

104-
it("can be extended multiple times", function() {
103+
it("can be extended multiple times", function () {
105104
var Tmp1 = Base.extend({
106105
name: "thing",
107106
trigger: "pat-thing",
108107
something: "else",
109-
init: function() {
108+
init: function () {
110109
expect(this.some).toEqual("thing3");
111110
expect(this.something).toEqual("else");
112-
}
111+
},
113112
});
114113
var Tmp2 = Tmp1.extend({
115114
name: "thing",
116115
trigger: "pat-thing",
117116
some: "thing2",
118-
init: function() {
117+
init: function () {
119118
expect(this.some).toEqual("thing3");
120119
expect(this.something).toEqual("else");
121-
this.constructor.__super__.constructor.__super__.init.call(this);
122-
}
120+
this.constructor.__super__.constructor.__super__.init.call(
121+
this
122+
);
123+
},
123124
});
124125
var Tmp3 = Tmp2.extend({
125126
name: "thing",
126127
trigger: "pat-thing",
127128
some: "thing3",
128-
init: function() {
129+
init: function () {
129130
expect(this.some).toEqual("thing3");
130131
expect(this.something).toEqual("else");
131132
this.constructor.__super__.init.call(this);
132-
}
133+
},
133134
});
134-
new Tmp3($("<div>"), {option: "value"});
135+
new Tmp3($("<div>"), { option: "value" });
135136
});
136137

137-
it("has on/emit helpers to prefix events", function() {
138+
it("has on/emit helpers to prefix events", function () {
138139
var Tmp = Base.extend({
139140
name: "tmp",
140141
trigger: ".pat-tmp",
141-
init: function() {
142-
this.on("something", function(e, arg1) {
142+
init: function () {
143+
this.on("something", function (e, arg1) {
143144
expect(arg1).toEqual("yaay!");
144145
});
145146
this.emit("somethingelse", ["yaay!"]);
146-
}
147+
},
147148
});
148149
new Tmp(
149-
$("<div/>").on("somethingelse.tmp.patterns", function(e, arg1) {
150+
$("<div/>").on("somethingelse.tmp.patterns", function (e, arg1) {
150151
$(this).trigger("something.tmp.patterns", [arg1]);
151152
})
152153
);

0 commit comments

Comments
 (0)