diff --git a/conversation.html b/conversation.html
index f47eac8e..7cdf6058 100644
--- a/conversation.html
+++ b/conversation.html
@@ -73,20 +73,8 @@
-
+
diff --git a/js/views/file_input_view.js b/js/views/file_input_view.js
index 7c1df5d6..db6268d4 100644
--- a/js/views/file_input_view.js
+++ b/js/views/file_input_view.js
@@ -18,12 +18,15 @@ var Whisper = Whisper || {};
(function () {
'use strict';
+ Whisper.FileSizeToast = Whisper.ToastView.extend({
+ template: $('#file-size-modal').html()
+ });
+
Whisper.FileInputView = Backbone.View.extend({
tagName: 'span',
className: 'file-input',
initialize: function() {
this.$input = this.$el.find('input[type=file]');
- this.modal = new Whisper.ModalView({el: $('#file-modal')});
this.thumb = new Whisper.AttachmentPreviewView();
this.$el.addClass('file-input');
},
@@ -48,8 +51,16 @@ var Whisper = Whisper || {};
var files = this.$input.prop('files');
for (var i = 0; i < files.length; i++) {
var FR = new FileReader();
- if ((files[i].size/1024).toFixed(4) >= 420) {
- this.modal.open();
+ var limitKb = 1000000;
+ switch (files[i].type.split('/')[0]) {
+ case 'image': limitKb = 420; break;
+ case 'audio': limitKb = 32000; break;
+ case 'video': limitKb = 8000; break;
+ }
+ if ((files[i].size/1024).toFixed(4) >= limitKb) {
+ new Whisper.FileSizeToast({
+ model: {limit: limitKb}
+ }).render();
this.deleteFiles();
}
else {
diff --git a/js/views/file_modal_view.js b/js/views/toast_view.js
similarity index 68%
rename from js/views/file_modal_view.js
rename to js/views/toast_view.js
index 259730d4..cc842c1a 100644
--- a/js/views/file_modal_view.js
+++ b/js/views/toast_view.js
@@ -17,27 +17,21 @@ var Whisper = Whisper || {};
(function () {
'use strict';
- Whisper.ModalView = Backbone.View.extend({
- tagName: 'div',
- className: 'file-overload-modal',
+ Whisper.ToastView = Backbone.View.extend({
+ className: 'toast',
initialize: function() {
- this.template = $('#file-size-modal').html();
Mustache.parse(this.template);
this.$el.hide();
- this.$el.html($(Mustache.render(this.template)));
- },
-
- events: {
- 'click .modal-close': 'close',
- 'click #closeModal': 'close'
- },
-
- open: function() {
- this.$el.show();
},
close: function() {
- this.$el.hide();
+ this.$el.fadeOut(this.remove.bind(this));
+ },
+
+ render: function() {
+ this.$el.html(Mustache.render(this.template, this.model));
+ this.$el.appendTo($('body')).show();
+ setTimeout(this.close.bind(this), 2000);
}
});
})();
diff --git a/stylesheets/_conversation.scss b/stylesheets/_conversation.scss
index c8fc6361..31a5a13a 100644
--- a/stylesheets/_conversation.scss
+++ b/stylesheets/_conversation.scss
@@ -264,3 +264,14 @@
}
}
+.toast {
+ position: absolute;
+ bottom: 0;
+ margin: 0 2em 3em;
+ padding: 0.5em 1.5em;
+ background: rgba(0, 0, 0, 0.75);
+ color: white;
+ box-shadow: 0 0 5px 0 black;
+ border-radius: 20px;
+ font-size: small;
+}
diff --git a/stylesheets/manifest.css b/stylesheets/manifest.css
index 6e061944..dcb31309 100644
--- a/stylesheets/manifest.css
+++ b/stylesheets/manifest.css
@@ -478,3 +478,14 @@ input.new-message {
border: 0;
outline: 0;
z-index: 5; }
+
+.toast {
+ position: absolute;
+ bottom: 0;
+ margin: 0 2em 3em;
+ padding: 0.5em 1.5em;
+ background: rgba(0, 0, 0, 0.75);
+ color: white;
+ box-shadow: 0 0 5px 0 black;
+ border-radius: 20px;
+ font-size: small; }