From 48cffcfc83bcbcaa6b4c4207f21ddcff47ba6e7f Mon Sep 17 00:00:00 2001 From: fabrixxm Date: Thu, 4 Dec 2014 23:52:37 +0100 Subject: [PATCH] fix invalid recipient error on reply. small fix to message list css --- www/css/index.css | 3 ++- www/js/index.js | 44 ++++++++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/www/css/index.css b/www/css/index.css index f273e6b..4cba42e 100644 --- a/www/css/index.css +++ b/www/css/index.css @@ -97,7 +97,8 @@ section[role="region"][data-position="right"] { /* lista con footer */ .scrollable.header.footer { - height: calc(100% - 10rem); + height: calc(100% - 9.6rem); + overflow-x:hidden; } /* barra rispondi */ diff --git a/www/js/index.js b/www/js/index.js index e1c91a1..85aaabb 100644 --- a/www/js/index.js +++ b/www/js/index.js @@ -1,7 +1,7 @@ function url(endpoint){ - return (app.settings.opts.secure?"https://":"http://") + app.settings.opts.user + ":" + app.settings.opts.pass + "@" + app.settings. opts.host + "/api/" + endpoint + "?callback=?"; + return (app.settings.opts.secure?"https://":"http://") + app.settings.opts.user + ":" + app.settings.opts.pass + "@" + app.settings.opts.host + "/api/" + endpoint + "?callback=?"; } /** @@ -30,11 +30,9 @@ MessageList.prototype.update = function(clb){ out += ""; } } - + this.elm.html(out); - if(clb) clb(data); - }.bind(this)); }; @@ -45,6 +43,7 @@ MessageList.prototype.update = function(clb){ function Messages(sel_elm){ this.elm = $(sel_elm); this.username = null; + this.reply_id = null; } Messages.prototype.update = function(username, clb) { @@ -79,8 +78,7 @@ Messages.prototype.update = function(username, clb) { /* reply form */ $(".message_text").val(""); - $(".message_to").val(username); - $(".message_reply").val(reply_id); + this.reply_id = reply_id; this.elm.html(out); if(clb) clb(data); @@ -88,6 +86,10 @@ Messages.prototype.update = function(username, clb) { }; +Messages.prototype.reply = function(clb){ + app.compose.send(clb, this.username, this.reply_id); +}; + /** * Send Message */ @@ -138,6 +140,10 @@ function Compose(sel_elm){ this.contact_photo.attr("src", this.contact_photo_empty); } }.bind(this)); + + // get friend list + this.update(); + } Compose.prototype.update = function(clb){ @@ -153,7 +159,7 @@ Compose.prototype.update = function(clb){ for (k in data){ var friend = data[k]; if (friend.network == "dfrn") { - this.friends[friend.screen_name] = friend; + this.friends[friend.screen_name] = friend; out += ""; } } @@ -164,10 +170,10 @@ Compose.prototype.update = function(clb){ }; -Compose.prototype.send = function(clb){ +Compose.prototype.send = function(clb, send_to, reply_id){ - var screen_name = $(".message_to").val().trim(); - var replyto = $(".message_reply").val(); + var screen_name; + var replyto = (reply_id?reply_id:$(".message_reply").val()); var text = $(".message_body").val(); if (text=="") text = $(".message_text").val(); @@ -176,9 +182,15 @@ Compose.prototype.send = function(clb){ alert("Please enter the message body"); return; } - if (screen_name=="" || this.friends[screen_name]==undefined){ - alert("Please enter a valid recipient"); - return; + + if (send_to!==undefined) { + screen_name = send_to; + } else { + screen_name = $(".message_to").val().trim(); + if (screen_name=="" || this.friends[screen_name]==undefined){ + alert("Please enter a valid recipient"); + return; + } } /** @@ -218,7 +230,7 @@ Compose.prototype.send = function(clb){ $("").attr('name','text').val(text) ); if (replyto!=="") form.append( - $("").attr('name','replyto').val(replyto) + $("").attr('name','replyto').val(replyto) ); $('body',doc).append(form); // send the form! @@ -345,7 +357,7 @@ var app = { /* send reply */ $("#reply_send").on("click", function(e){ e.preventDefault(); - app.compose.send(function(){ + app.messages.reply(function(){ app.messages.update(); }); }); @@ -370,4 +382,4 @@ $.ajaxSettings.beforeSend = function() { $("progress").show(); } $.ajaxSettings.complete = function() { $("progress").hide(); } -app.initialize(); \ No newline at end of file +app.initialize(); -- 2.1.4