Browse Source

- Comment "composing/paused" chat system

- Fix a type in Login
pull/16/head
Jaussoin Timothée 13 years ago
parent
commit
6db21567ee
  1. 46
      app/widgets/Chat/Chat.php
  2. 2
      app/widgets/Login/Login.php
  3. 128
      app/widgets/WidgetCommon/WidgetCommon.php

46
app/widgets/Chat/Chat.php

@ -396,26 +396,8 @@ class Chat extends WidgetBase
onkeypress="
if(event.keyCode == 13) {
'.$this->genCallAjax('ajaxSendMessage', "'".$contact->jid."'", "sendMessage(this, '".$contact->jid."')").'
lastkeypress = new Date().getTime()+1000;
return false;
}
if(lastkeypress < new Date().getTime())
'.$this->genCallAjax('ajaxSendComposing', "'".$contact->jid."'").'
lastkeypress = new Date().getTime()+1000;
"
onkeyup="
movim_textarea_autoheight(this);
var val = this.value;
setTimeout(function()
{
if(lastkeypress < new Date().getTime() && val != \'\') {
'.$this->genCallAjax('ajaxSendPaused', "'".$contact->jid."'").'
lastkeypress = new Date().getTime()+1000;
}
},1100); // Listen for 2 seconds of silence
"
}"
></textarea>
</div>
</div>
@ -429,6 +411,32 @@ class Chat extends WidgetBase
';
return $html;
/* This is the un optimized system to send "composing" and "paused"
* onkeypress="
if(event.keyCode == 13) {
'.$this->genCallAjax('ajaxSendMessage', "'".$contact->jid."'", "sendMessage(this, '".$contact->jid."')").'
lastkeypress = new Date().getTime()+1000;
return false;
}
if(lastkeypress < new Date().getTime())
'.$this->genCallAjax('ajaxSendComposing', "'".$contact->jid."'").'
lastkeypress = new Date().getTime()+1000;
"
onkeyup="
movim_textarea_autoheight(this);
var val = this.value;
setTimeout(function()
{
if(lastkeypress < new Date().getTime() && val != \'\') {
'.$this->genCallAjax('ajaxSendPaused', "'".$contact->jid."'").'
lastkeypress = new Date().getTime()+1000;
}
},1100); // Listen for 2 seconds of silence
"
* */
}
function build()

2
app/widgets/Login/Login.php

@ -144,7 +144,7 @@ class Login extends WidgetBase {
case 'mecerror':
$warning = '
<div class="message warning">
'.t('The server takes too much time to repond').'
'.t('The server takes too much time to respond').'
</div>';
break;
}

128
app/widgets/WidgetCommon/WidgetCommon.php

@ -17,9 +17,13 @@
class WidgetCommon extends WidgetBase {
private function loadTemplate() {
$this->view = new RainTPL;
$this->view->configure('tpl_dir', $this->respath('', true, true));
$this->view->assign('c', $this);
$view = new RainTPL;
$view->configure('tpl_dir', APP_PATH.'widgets/WidgetCommon/');
$view->configure('cache_dir', USERS_PATH);
$view->configure('tpl_ext', 'tpl');
$view->assign('c', $this);
return $view;
}
protected function printPost($post, $comments = false, $public = false) {
@ -174,23 +178,23 @@ class WidgetCommon extends WidgetBase {
}
private function getToolbox($post) {
/*$this->loadTemplate();
$view = $this->loadTemplate();
$this->view->assign(
$view->assign(
'privacy_post_orange',
$this->genCallAjax(
'ajaxPrivacyPost',
"'".$post->nodeid."'",
"'orange'"));
$this->view->assign(
$view->assign(
'privacy_post_black',
$this->genCallAjax(
'ajaxPrivacyPost',
"'".$post->nodeid."'",
"'black'"));
$this->view->assign(
$view->assign(
'delete_post',
$this->genCallAjax(
'ajaxDeletePost',
@ -198,65 +202,63 @@ class WidgetCommon extends WidgetBase {
"'".$post->node."'",
"'".$post->nodeid."'"));
$html = $this->draw('_post_toolbox', true);
$html = $view->draw('_post_toolbox', true);
RainTPL::configure('tpl_dir', $this->respath('', true));
*/
return $html;
}
protected function printComments($post, $comments, $public = false) {
$tmp .= '
<div class="comments" id="'.$post->nodeid.'comments">';
$tmp .= '
<div class="comments" id="'.$post->nodeid.'comments">';
$commentshtml = $this->prepareComments($comments);
if($commentshtml != false)
$tmp .= $commentshtml;
$commentshtml = $this->prepareComments($comments);
if($commentshtml != false)
$tmp .= $commentshtml;
if($public == false) {
$tmp .= '
<div class="comment">
<a
class="getcomments icon chat"
onclick="'.$this->genCallAjax('ajaxGetComments', "'".$post->commentplace."'", "'".$post->nodeid."'").'; this.innerHTML = \''.t('Loading comments ...').'\'">'.
t('Get the comments').'
if($public == false) {
$tmp .= '
<div class="comment">
<a
class="getcomments icon chat"
onclick="'.$this->genCallAjax('ajaxGetComments', "'".$post->commentplace."'", "'".$post->nodeid."'").'; this.innerHTML = \''.t('Loading comments ...').'\'">'.
t('Get the comments').'
</a>
</div></div>';
$tmp .= '<div class="comments">
<div
class="comment"
onclick="this.parentNode.querySelector(\'#commentsubmit\').style.display = \'table\'; this.style.display =\'none\'">
<a class="addcomment icon chat">'.t('Add a comment').'</a>
</div>
<table id="commentsubmit">
<tr>
<td>
<textarea id="'.$post->nodeid.'commentcontent" onkeyup="movim_textarea_autoheight(this);"></textarea>
</td>
</tr>
<tr class="commentsubmitrow">
<td style="width: 100%;"></td>
<td>
<a
onclick="
if(document.getElementById(\''.$post->nodeid.'commentcontent\').value != \'\') {
'.$this->genCallAjax(
'ajaxPublishComment',
"'".$post->commentplace."'",
"'".$post->nodeid."'",
"encodeURIComponent(document.getElementById('".$post->nodeid."commentcontent').value)").
'document.getElementById(\''.$post->nodeid.'commentcontent\').value = \'\';
}"
class="button color green icon yes"
>'.
t("Submit").'
</a>
</div></div>';
$tmp .= '<div class="comments">
<div
class="comment"
onclick="this.parentNode.querySelector(\'#commentsubmit\').style.display = \'table\'; this.style.display =\'none\'">
<a class="addcomment icon chat">'.t('Add a comment').'</a>
</div>
<table id="commentsubmit">
<tr>
<td>
<textarea id="'.$post->nodeid.'commentcontent" onkeyup="movim_textarea_autoheight(this);"></textarea>
</td>
</tr>
<tr class="commentsubmitrow">
<td style="width: 100%;"></td>
<td>
<a
onclick="
if(document.getElementById(\''.$post->nodeid.'commentcontent\').value != \'\') {
'.$this->genCallAjax(
'ajaxPublishComment',
"'".$post->commentplace."'",
"'".$post->nodeid."'",
"encodeURIComponent(document.getElementById('".$post->nodeid."commentcontent').value)").
'document.getElementById(\''.$post->nodeid.'commentcontent\').value = \'\';
}"
class="button color green icon yes"
>'.
t("Submit").'
</a>
</td>
</tr>
</table>';
}
$tmp .= '</div>';
</td>
</tr>
</table>';
}
$tmp .= '</div>';
return $tmp;
}
@ -397,11 +399,11 @@ class WidgetCommon extends WidgetBase {
}
protected function prepareSubmitForm($server = '', $node = '') {
/*$this->loadTemplate();
$view = $this->loadTemplate();
$this->view->assign('toggle_position', $this->genCallAjax('ajaxShowPosition', "'poss'"));
$view->assign('toggle_position', $this->genCallAjax('ajaxShowPosition', "'poss'"));
$this->view->assign(
$view->assign(
'publish_item',
$this->genCallAjax(
'ajaxPublishItem',
@ -409,13 +411,13 @@ class WidgetCommon extends WidgetBase {
"'".$node."'",
"movim_parse_form('postpublish')"));
$this->view->assign(
$view->assign(
'post_preview',
$this->genCallAjax(
'ajaxPostPreview',
"document.querySelector('#postpublishcontent').value"));
$html = $this->view->draw('_submit_form', true);*/
$html = $view->draw('_submit_form', true);
return $html;
}

Loading…
Cancel
Save