1
0
mirror of https://github.com/moparisthebest/kaiwa synced 2024-12-25 00:48:51 -05:00

Make fallback uploader work

This commit is contained in:
Lance Stout 2013-09-18 21:11:53 -07:00
parent f790aaebc2
commit cd0ef555b0
3 changed files with 15 additions and 4 deletions

View File

@ -16,7 +16,8 @@ module.exports = BasePage.extend({
events: {
'click .enableAlerts': 'enableAlerts',
'dragover': 'handleAvatarChangeDragOver',
'drop': 'handleAvatarChange'
'drop': 'handleAvatarChange',
'change #uploader': 'handleAvatarChange'
},
initialize: function (spec) {
me.shouldAskForAlertsPermission = app.notifier.shouldAskPermission();
@ -38,8 +39,18 @@ module.exports = BasePage.extend({
return false;
},
handleAvatarChange: function (e) {
var file;
e.preventDefault();
var file = e.dataTransfer.files[0];
if (e.dataTransfer) {
file = e.dataTransfer.files[0];
} else if (e.target.files) {
file = e.target.files[0];
} else {
return;
}
if (file.type.match('image.*')) {
console.log('Got an image file!', file.type);
var fileTracker = new FileReader();

View File

@ -131,7 +131,7 @@ exports.pages.groupchat = function anonymous(locals) {
exports.pages.main = function anonymous(locals) {
var buf = [];
with (locals || {}) {
buf.push('<section class="page main"><button class="enableAlerts">Enable alerts</button><div id="avatarChanger"><h1>Change Avatar</h1><div class="uploadRegion"><p>Drag and drop a new avatar here</p><img width="40" height="40"/><form><input id="uploader" type="file"/></form></div></div><h1>This space intentionally blank</h1></section>');
buf.push('<section class="page main"><button class="enableAlerts">Enable alerts</button><div id="avatarChanger"><h1>Change Avatar</h1><div class="uploadRegion"><p>Drag and drop a new avatar here</p><img/><form><input id="uploader" type="file"/></form></div></div><h1>This space intentionally blank</h1></section>');
}
return buf.join("");
};

View File

@ -5,7 +5,7 @@ section.page.main
h1 Change Avatar
div.uploadRegion
p Drag and drop a new avatar here
img(width="40", height="40")
img
form
input#uploader(type="file")