Index: lib/utils.js |
diff --git a/lib/utils.js b/lib/utils.js |
index 655ad95c377f5d5fa1fb3c1f8584ea710c376226..b04e7729bc7c4871697a93bae0cf101e084c3c47 100644 |
--- a/lib/utils.js |
+++ b/lib/utils.js |
@@ -119,5 +119,19 @@ var Utils = exports.Utils = { |
yield: function() |
{ |
+ }, |
+ |
+ loadImage: function(path, size) |
Sebastian Noack
2016/01/22 15:59:15
I think I'd rather keep that function in icon.js b
kzar
2016/01/22 16:49:35
Done.
|
+ { |
+ if (!path) |
Sebastian Noack
2016/01/22 15:59:15
Is that actually a scenario we need to handle?
kzar
2016/01/22 16:49:35
Yes, it meant I could simplify the logic to load t
|
+ return Promise.resolve(null); |
+ if (size) |
+ path = path.replace("$size", size.toString()); |
+ |
+ return new Promise(function(resolve, reject) { |
+ let image = new Image(); |
+ image.src = path; |
+ image.addEventListener("load", function() { resolve(image); }); |
Sebastian Noack
2016/01/22 15:59:15
Since both, the code in icon.js and notificationHe
Sebastian Noack
2016/01/22 15:59:15
Since it's a general purpose function now, I'd als
kzar
2016/01/22 16:49:35
Done.
kzar
2016/01/22 16:49:35
Ah cool, didn't know that drawImage could take a c
|
+ }); |
} |
}; |