mirror of
https://github.com/moparisthebest/kaiwa
synced 2025-01-13 14:48:09 -05:00
Make fallback uploader work
This commit is contained in:
parent
f790aaebc2
commit
cd0ef555b0
@ -16,7 +16,8 @@ module.exports = BasePage.extend({
|
|||||||
events: {
|
events: {
|
||||||
'click .enableAlerts': 'enableAlerts',
|
'click .enableAlerts': 'enableAlerts',
|
||||||
'dragover': 'handleAvatarChangeDragOver',
|
'dragover': 'handleAvatarChangeDragOver',
|
||||||
'drop': 'handleAvatarChange'
|
'drop': 'handleAvatarChange',
|
||||||
|
'change #uploader': 'handleAvatarChange'
|
||||||
},
|
},
|
||||||
initialize: function (spec) {
|
initialize: function (spec) {
|
||||||
me.shouldAskForAlertsPermission = app.notifier.shouldAskPermission();
|
me.shouldAskForAlertsPermission = app.notifier.shouldAskPermission();
|
||||||
@ -38,8 +39,18 @@ module.exports = BasePage.extend({
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
handleAvatarChange: function (e) {
|
handleAvatarChange: function (e) {
|
||||||
|
var file;
|
||||||
|
|
||||||
e.preventDefault();
|
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.*')) {
|
if (file.type.match('image.*')) {
|
||||||
console.log('Got an image file!', file.type);
|
console.log('Got an image file!', file.type);
|
||||||
var fileTracker = new FileReader();
|
var fileTracker = new FileReader();
|
||||||
|
@ -131,7 +131,7 @@ exports.pages.groupchat = function anonymous(locals) {
|
|||||||
exports.pages.main = function anonymous(locals) {
|
exports.pages.main = function anonymous(locals) {
|
||||||
var buf = [];
|
var buf = [];
|
||||||
with (locals || {}) {
|
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("");
|
return buf.join("");
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,7 @@ section.page.main
|
|||||||
h1 Change Avatar
|
h1 Change Avatar
|
||||||
div.uploadRegion
|
div.uploadRegion
|
||||||
p Drag and drop a new avatar here
|
p Drag and drop a new avatar here
|
||||||
img(width="40", height="40")
|
img
|
||||||
form
|
form
|
||||||
input#uploader(type="file")
|
input#uploader(type="file")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user