Skip to content

Commit

Permalink
2.57v
Browse files Browse the repository at this point in the history
  • Loading branch information
remdex committed Apr 7, 2017
1 parent b22521f commit 8d17512
Show file tree
Hide file tree
Showing 54 changed files with 4,124 additions and 732 deletions.
40 changes: 40 additions & 0 deletions lhc_web/design/defaulttheme/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -1275,3 +1275,43 @@ input[type="file"]{
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset, 0 0 8px rgba(240, 173, 78, 0.6);
outline: 0 none;
}

.canned-suggester{
position:absolute;
background-color:#f5f5f5;
bottom:54px;
border:1px solid #ddd;
font-size:12px;
}

.current-hash-content ul{
margin-bottom:0;
}

.canned-list {
margin-bottom:0;
}

.canned-list a{
display:block;
padding:2px 5px;
}

.current-hash-content ul li span{
display: table-cell;
padding:2px 5px;
cursor:pointer;
}

.canned-list li.current-item a,
.current-hash-content li.current-item,
.current-hash-content ul li:hover,
.canned-list a:hover{background-color:#cecece;}
.canned-list > li{position:relative;}
.canned-list > li > ul {display: none;}



.message-container-admin{
position:relative;
}
221 changes: 221 additions & 0 deletions lhc_web/design/defaulttheme/js/lh.cannedmsg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,221 @@
var LHCCannedMessageAutoSuggest = (function() {

function LHCCannedMessageAutoSuggest(params) {

this.chat_id = params['chat_id'];
this.suggesting = false; // Are we in suggesting mode
this.cannedMode = false; // false - tag mode menu, true - canned mode

this.currentText = null;
this.currentKeword = null;

this.initialising = false;
this.timeoutDelay = null;

var _that = this;

this.textarea = jQuery('#CSChatMessage-'+this.chat_id);

this.textarea.bind('keyup', function (evt) {

if (evt.key == '#' || evt.keyCode == 51 || evt.keyCode == 222) {
_that.currentText = _that.textarea.val();
_that.showSuggester();
} else if (evt.keyCode == 32 && _that.suggesting == true) {
_that.stopSuggesting();
} else if (_that.suggesting == true && evt.keyCode != 38 && evt.keyCode != 40 && evt.keyCode != 39 && evt.keyCode != 37 && evt.keyCode != 13) {

if (_that.currentText !== _that.textarea.val()) { // Show suggester only if text is different
_that.showSuggester();
_that.currentText = _that.textarea.val();
}

} else if (_that.suggesting == true && (evt.keyCode == 37 || evt.keyCode == 39) && _that.cannedMode === false) {

var oldKeyword = _that.currentKeword;

if (oldKeyword !== _that.extractKeyword()) { // Only if keyword is different, happens if we migrate from canned messages to normal list.
_that.showSuggester();
}

} else if (_that.suggesting == false && (evt.keyCode == 39 || evt.keyCode == 37 || evt.keyCode == 8)) { // Perhaps user moved cursor to the right
if (_that.extractKeyword() !== null) {
_that.showSuggester();
}
}
});

this.textarea.bind('keydown', function (evt) {
if (_that.suggesting == true) {
if (evt.keyCode == 38) {
_that.moveAction('up');
evt.preventDefault();
evt.stopImmediatePropagation();
} else if (evt.keyCode == 40) {
_that.moveAction('down');
evt.preventDefault();
} else if (evt.keyCode == 39 || evt.keyCode == 13) { // right arrow OR enter
if (_that.cannedMode === false) {
$('#canned-hash-'+_that.chat_id+' > li.current-item a').trigger( "click" );
} else {
$('#canned-hash-current-'+_that.chat_id+' > ul > li.current-item > span.canned-msg').trigger( "click" );
}
evt.preventDefault();
evt.stopImmediatePropagation();
} else if (evt.keyCode == 37) { // left arrow
if (_that.cannedMode === true) {
$('#canned-hash-current-'+_that.chat_id+' > ul > li.current-item > span.left-return').trigger( "click" );
evt.preventDefault();
evt.stopImmediatePropagation();
}
}
}
});
}

LHCCannedMessageAutoSuggest.prototype.moveAction = function(action)
{
if (this.cannedMode === false) {
var current = $('#canned-hash-'+this.chat_id+' > li.current-item');
} else {
var current = $('#canned-hash-current-'+this.chat_id+' > ul > li.current-item');
}

if (action == 'up') {
var prev = current.prev();
if (prev.is('li')){
current.removeClass('current-item');
prev.addClass('current-item');
}
} else if(action == 'down') {
var next = current.next();
if (next.is('li')){
current.removeClass('current-item');
next.addClass('current-item');
}
}
}

LHCCannedMessageAutoSuggest.prototype.stopSuggesting = function()
{
this.textarea.parent().find('.canned-suggester').remove();
this.suggesting = false;
this.cannedMode = false;
this.currentText = null;
this.currentKeword = null;
}

LHCCannedMessageAutoSuggest.prototype.extractKeyword = function()
{
var caretPos = this.textarea[0].selectionStart;
currentValue = this.textarea.val();
var keyword = '';

for (i = caretPos; i > 0; i--) {
char = currentValue.substring(i-1, i);
if (char == ' ') {
this.currentKeword = null;
return null;
} else if (char == '#') {
this.currentKeword = keyword;
return keyword;
} else {
keyword = char + keyword;
}
}

this.currentKeword = null;
return null;
}

LHCCannedMessageAutoSuggest.prototype.showSuggester = function()
{
var _that = this;

this.extractKeyword();
this.cannedMode = false;

if (this.currentKeword !== null) {

if (this.initialising === false) {

this.initialising = true;

$.getJSON(WWW_DIR_JAVASCRIPT + 'cannedmsg/showsuggester/' + this.chat_id,{keyword : this.currentKeword}, function(data) {
_that.textarea.parent().find('.canned-suggester').remove();
_that.textarea.before(data.result);
_that.initSuggester();
_that.initialising = false;
_that.suggesting = true;
});

} else {
clearTimeout(this.timeoutDelay);
this.timeoutDelay = setTimeout(function(){
_that.showSuggester();
},500);
}

} else {
this.stopSuggesting();
}
}

LHCCannedMessageAutoSuggest.prototype.initSuggester = function()
{
var _that = this;
$('#canned-hash-'+this.chat_id+' > li:first-child').addClass('current-item');

$('#canned-hash-'+this.chat_id+' > li > a').click(function() {

_that.cannedMode = true;

var content = $('#canned-hash-current-'+_that.chat_id);
content.html('').show();
$(this).parent().find('ul').clone().appendTo(content);
content.find('ul > li:first-child').addClass('current-item');

var container = $(this).parent().parent();
container.hide();

content.find('span.canned-msg').click(function(){

// Insert selected text
var caretPos = _that.textarea[0].selectionStart,
currentValue = _that.textarea.val();

var textBeforeCursor = currentValue.substring(0, caretPos - 1 - _that.currentKeword.length) + $(this).attr('data-msg');
_that.textarea.val(textBeforeCursor + currentValue.substring(caretPos));

// Set cursor position
if ('selectionStart' in _that.textarea[0]) {
_that.textarea[0].selectionStart = textBeforeCursor.length;
_that.textarea[0].selectionEnd = textBeforeCursor.length;
} else if (_that.textarea[0].setSelectionRange) {
_that.textarea[0].setSelectionRange(textBeforeCursor.length, textBeforeCursor.length);
} else if (_that.textarea[0].createTextRange) {
var range = _that.textarea[0].createTextRange();
range.collapse(true);
range.moveEnd('character', textBeforeCursor.length);
range.moveStart('character', textBeforeCursor.length);
range.select();
}

_that.stopSuggesting();
});

content.find('span.left-return').click(function(){
container.show();
content.html('').hide();
_that.cannedMode = false;
});
});

// Show first canned message list if there is only one tag matched
if ($('#canned-hash-'+this.chat_id+' > li').size() == 1) {
$('#canned-hash-'+this.chat_id+' > li > a').trigger( "click" );
}
}

return LHCCannedMessageAutoSuggest;
})();
1 change: 1 addition & 0 deletions lhc_web/design/defaulttheme/js/lh.cannedmsg.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 9 additions & 11 deletions lhc_web/design/defaulttheme/js/lh.js
Original file line number Diff line number Diff line change
Expand Up @@ -1834,18 +1834,20 @@ function lh(){
LHCCallbacks.afterChatWidgetInit();
};
};

this.addAdminChatFinished = function(chat_id, last_message_id, arg) {

var _that = this;

var $textarea = jQuery('#CSChatMessage-'+chat_id);

$textarea.bind('keydown', 'return', function (evt){
_that.addmsgadmin(chat_id);
ee.emitEvent('afterAdminMessageSent',[chat_id]);
$textarea[0].rows = 2;
return false;
var cannedMessageSuggest = new LHCCannedMessageAutoSuggest({'chat_id':chat_id});

$textarea.bind('keydown', 'return', function (evt){
_that.addmsgadmin(chat_id);
ee.emitEvent('afterAdminMessageSent',[chat_id]);
$textarea[0].rows = 2;
return false;
});

$textarea.bind('keyup', 'up', function (evt){
Expand All @@ -1860,10 +1862,9 @@ function lh(){
ta.style.overflow = 'hidden';
ta.rows += 1;
}
if (ta.scrollHeight > ta.clientHeight) ta.style.overflow = 'auto';
if (ta.scrollHeight > ta.clientHeight) ta.style.overflow = 'auto';
});


// Resize by user
$messageBlock = $('#messagesBlock-'+chat_id);

Expand Down Expand Up @@ -2807,9 +2808,6 @@ function gMapsCallback(){
},500);
showMarkers();
});



};

var focused = true;
Expand Down
2 changes: 1 addition & 1 deletion lhc_web/design/defaulttheme/js/lh.min.js

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhcannedmsg/showsuggester.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="canned-suggester">
<ul class="list-unstyled canned-list" id="canned-hash-<?php echo $chat->id?>">
<?php foreach (erLhcoreClassModelCannedMsgTagLink::formatSuggester($tags,array('chat' => $chat, 'user' => erLhcoreClassUser::instance()->getUserData())) as $item) : ?>
<li><a href="#">[<?php echo htmlspecialchars($item['tag']->cnt)?>] <?php echo htmlspecialchars($item['tag']->tag)?> &raquo;</a>
<ul class="list-unstyled">
<?php foreach ($item['messages'] as $message) : ?>
<li><span class="mr-0 left-return">&laquo;&nbsp;</span><span class="canned-msg" data-msg="<?php echo htmlspecialchars($message->msg_to_user)?>"><?php echo htmlspecialchars($message->message_title)?> &raquo;</span></li>
<?php endforeach; ?>
</ul>
</li>
<?php endforeach; ?>
</ul>
<div id="canned-hash-current-<?php echo $chat->id?>" class="current-hash-content"></div>
</div>
2 changes: 2 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhchat/adminchat.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@

<div class="user-is-typing" id="user-is-typing-<?php echo $chat->id?>"><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chat','User is typing now...')?></div>

<div class="message-container-admin">
<textarea placeholder="<?php if ($chat->user_id != erLhcoreClassUser::instance()->getUserID()) : ?><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/chat','You are not chat owner, type with caution')?><?php endif;?>" class="form-control form-group<?php if ($chat->user_id != erLhcoreClassUser::instance()->getUserID()) : ?> form-control-warning<?php endif;?>" rows="2" <?php if ($chat->status == erLhcoreClassModelChat::STATUS_CLOSED_CHAT) : ?>readonly="readonly"<?php endif;?> name="ChatMessage" id="CSChatMessage-<?php echo $chat->id?>"></textarea>
</div>

<?php include(erLhcoreClassDesign::designtpl('lhchat/part/after_text_area_block.tpl.php')); ?>

Expand Down
5 changes: 5 additions & 0 deletions lhc_web/design/defaulttheme/tpl/lhchat/cannedmsgform.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
<input type="text" class="form-control" name="Title" value="<?php echo htmlspecialchars($canned_message->title);?>" />
</div>

<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation("chat/cannedmsg","Tag's");?></label>
<input type="text" class="form-control" name="Tags" value="<?php echo htmlspecialchars($canned_message->tags_plain)?>" />
</div>

<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Explain');?></label>
<input type="text" class="form-control" name="ExplainHover" value="<?php echo htmlspecialchars($canned_message->explain);?>" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Explain');?></label>
<input type="text" class="form-control" name="ExplainHover" value="<?php echo htmlspecialchars($canned_msg->explain);?>" />
</div>

<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation("chat/cannedmsg","Tag's");?></label>
<input type="text" class="form-control" name="Tags" value="<?php echo htmlspecialchars($canned_msg->tags_plain)?>" />
</div>

<div class="form-group">
<label><?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/cannedmsg','Message');?></label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@
confLH.sn_off = <?php echo (int)erLhcoreClassModelUserSetting::getSetting('sn_off',1)?>;
confLH.ownntfonly = <?php echo (int)erLhcoreClassModelUserSetting::getSetting('ownntfonly',0)?>;
</script>
<script type="text/javascript" src="<?php echo erLhcoreClassDesign::designJS('vendor/jquery/jquery.min.js;vendor/bootstrap/js/bootstrap.min.js;js/modernizr.js;js/lh.min.js;js/jquery.hotkeys.min.js;js/fileupload/jquery.fileupload.min.js;js/jquery.zoom.min.js;js/datepicker.min.js;js/lh/dist/common.js;js/lh/dist/bundle.js;js/EventEmitter.min.js;js/events.js');?>"></script>
<script type="text/javascript" src="<?php echo erLhcoreClassDesign::designJS('vendor/jquery/jquery.min.js;vendor/bootstrap/js/bootstrap.min.js;js/modernizr.js;js/lh.min.js;js/lh.cannedmsg.min.js;js/jquery.hotkeys.min.js;js/fileupload/jquery.fileupload.min.js;js/jquery.zoom.min.js;js/datepicker.min.js;js/lh/dist/common.js;js/lh/dist/bundle.js;js/EventEmitter.min.js;js/events.js');?>"></script>
<?php echo isset($Result['additional_header_js']) ? $Result['additional_header_js'] : ''?>
9 changes: 9 additions & 0 deletions lhc_web/doc/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
2.57v

1. Canned messages with hashes. Just type # and get suggested canned messages.
2. In canned messages edit window you can enter tags, tags has to be separated by ","

execute doc/update_db/update_132.sql for update

2.56v

1. REST API for registering mobile devices. Perhaps someone in the future will make open source app etc.
2. And just various small fixes.

execute doc/update_db/update_131.sql for update

2.55v

1. Device type detection
Expand Down
Loading

0 comments on commit 8d17512

Please sign in to comment.