summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorLeonardo Schäffer <leonardo.schaffer@gmail.com>2015-07-05 18:39:17 -0300
committerLeonardo Schäffer <leonardo.schaffer@gmail.com>2015-07-05 18:39:17 -0300
commite07a76471291256094028f0a29e4f278baa83cf6 (patch)
tree5203c6d3a341df052620d1b20662243fe67301cd /web-ui
parent8d7adde3179d12fc215a899d8f533789a440441b (diff)
Moved floatlabel function to a mixin
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/compose_box.js22
-rw-r--r--web-ui/app/js/mail_view/ui/draft_box.js22
-rw-r--r--web-ui/app/js/mixins/with_mail_edit_base.js16
3 files changed, 20 insertions, 40 deletions
diff --git a/web-ui/app/js/mail_view/ui/compose_box.js b/web-ui/app/js/mail_view/ui/compose_box.js
index e8210193..28f6dc83 100644
--- a/web-ui/app/js/mail_view/ui/compose_box.js
+++ b/web-ui/app/js/mail_view/ui/compose_box.js
@@ -54,29 +54,11 @@ define(
this.renderComposeBox = function() {
this.render(templates.compose.box, {});
+ this.enableFloatlabel('input.floatlabel');
+ this.enableFloatlabel('textarea.floatlabel');
this.select('recipientsFields').show();
this.on(this.select('closeButton'), 'click', this.showNoMessageSelected);
this.enableAutoSave();
-
- function floatlabelHandler(element) {
- $(function() {
- var showClass = 'showfloatlabel';
- $(element).bind('checkval', function() {
- var label = $(this).prev('label');
- if (this.value !== '') {
- label.addClass(showClass);
- $(this).addClass(showClass);
- } else {
- label.removeClass(showClass);
- $(this).removeClass(showClass);
- }
- }).on('keyup',function() {
- $(this).trigger('checkval');
- }).trigger('checkval');
- });
- }
- floatlabelHandler('input.floatlabel');
- floatlabelHandler('textarea.floatlabel');
};
this.mailDeleted = function(event, data) {
diff --git a/web-ui/app/js/mail_view/ui/draft_box.js b/web-ui/app/js/mail_view/ui/draft_box.js
index da8b3055..8c2e15c7 100644
--- a/web-ui/app/js/mail_view/ui/draft_box.js
+++ b/web-ui/app/js/mail_view/ui/draft_box.js
@@ -66,32 +66,14 @@ define(
body: body
});
+ this.enableFloatlabel('input.floatlabel');
+ this.enableFloatlabel('textarea.floatlabel');
this.select('recipientsFields').show();
this.select('bodyBox').focus();
this.select('tipMsg').hide();
this.enableAutoSave();
this.on(this.select('cancelButton'), 'click', this.showNoMessageSelected);
this.on(this.select('closeMailButton'), 'click', this.showNoMessageSelected);
-
- function floatlabelHandler(element) {
- $(function() {
- var showClass = 'showfloatlabel';
- $(element).bind('checkval', function() {
- var label = $(this).prev('label');
- if (this.value !== '') {
- label.addClass(showClass);
- $(this).addClass(showClass);
- } else {
- label.removeClass(showClass);
- $(this).removeClass(showClass);
- }
- }).on('keyup',function() {
- $(this).trigger('checkval');
- }).trigger('checkval');
- });
- }
- floatlabelHandler('input.floatlabel');
- floatlabelHandler('textarea.floatlabel');
};
this.mailDeleted = function(event, data) {
diff --git a/web-ui/app/js/mixins/with_mail_edit_base.js b/web-ui/app/js/mixins/with_mail_edit_base.js
index 848fe026..3a7b14b5 100644
--- a/web-ui/app/js/mixins/with_mail_edit_base.js
+++ b/web-ui/app/js/mixins/with_mail_edit_base.js
@@ -203,6 +203,22 @@ define(
this.trigger(document, events.ui.userAlerts.displayMessage, { message: 'Your message was sent!' });
};
+ this.enableFloatlabel = function(element) {
+ var showClass = 'showfloatlabel';
+ $(element).bind('checkval', function() {
+ var label = $(this).prev('label');
+ if (this.value !== '') {
+ label.addClass(showClass);
+ $(this).addClass(showClass);
+ } else {
+ label.removeClass(showClass);
+ $(this).removeClass(showClass);
+ }
+ }).on('keyup', function() {
+ $(this).trigger('checkval');
+ }).trigger('checkval');
+ };
+
this.after('initialize', function () {
this.on(document, events.dispatchers.rightPane.clear, this.teardown);
this.on(document, events.ui.recipients.updated, this.recipientsUpdated);