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:
parent
f790aaebc2
commit
cd0ef555b0
@ -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();
|
||||
|
@ -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("");
|
||||
};
|
||||
|
@ -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")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user