Skip to content

Commit eb44f49

Browse files
adamzapSaptakS
authored andcommitted
Moved and simplified fundraising-heart.js
jQuery integration has been removed. It was only used for a single element selection call and a single data attribute access call. The file has been removed from the module system, put in the general JavaScript directory, and added to the one page that uses it. The actual `Heart` code has not been changed.
1 parent e5da289 commit eb44f49

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

djangoproject/static/js/mod/fundraising-heart.js renamed to djangoproject/static/js/fundraising-heart.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
define(['jquery'], function ($) {
1+
(function () {
22
var maroon = '#ad1d45';
33
var amaranth = '#d9195c';
44
var cerise = '#d62d75';
@@ -45,8 +45,8 @@ define(['jquery'], function ($) {
4545
{ x: 3, y: 5, color: razzmatazz },
4646
];
4747

48-
var Heart = function (heart) {
49-
this.heart = $(heart);
48+
var Heart = function (selector) {
49+
this.heart = document.querySelector(selector);
5050
this.init();
5151
};
5252

@@ -61,7 +61,7 @@ define(['jquery'], function ($) {
6161
},
6262
fadePixels: function () {
6363
var pixels;
64-
var percent = this.heart.data('percent');
64+
var percent = this.heart.dataset.percent;
6565
var fadedCount = Math.ceil((this.pixels.length * (100 - percent)) / 100);
6666
for (var i = 0; i < fadedCount; i++) {
6767
pixels = this.visiblePixels();
@@ -115,6 +115,5 @@ define(['jquery'], function ($) {
115115
},
116116
};
117117

118-
// Export a single instance of our module:
119-
return new Heart('.fundraising-heart');
120-
});
118+
new Heart('.fundraising-heart');
119+
})();

djangoproject/static/js/main.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ define(function () {
1212
mods.push('mod/list-collapsing');
1313
}
1414

15-
//fundraising heart
16-
if (hasClass('fundraising-heart')) {
17-
mods.push('mod/fundraising-heart');
18-
}
19-
2015
if (hasClass('dashboard-index')) {
2116
mods.push('dashboard/index');
2217
}

djangoproject/templates/fundraising/includes/donation_form_with_heart.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,5 @@ <h3>{% translate "Help us make it happen:" %}</h3>
6969
{% endwith %}
7070

7171
<hr style="margin: 40px 0" />
72+
73+
<script async src="{% static "js/fundraising-heart.js" %}"></script>

0 commit comments

Comments
 (0)