Created
May 23, 2016 04:38
-
-
Save ptrnov/17b23a4ce0ed21d7aef35c9680465a48 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| Pjax::begin(['id'=>'msg-chat']); | |
| //echo "asd"; | |
| echo Html::mediaList([ | |
| [ | |
| //'id'=>'msg-chat', | |
| 'heading' => false, | |
| 'body' => false, | |
| 'imgOptions'=>false, | |
| 'src' => false, | |
| 'img' =>false, | |
| 'items' =>$body1, // isi chart | |
| ], | |
| ]); | |
| Pjax::end(); | |
| ?> | |
| $params = Yii::$app->request->queryParams; | |
| $id = $params['ChatSearch']['GROUP']; | |
| $this->registerJs(" | |
| var id =\"".$id."\"; | |
| $('#btn').click(function(){ | |
| var comment = $('#comment').val(); | |
| var data = { id : id, comment : comment } | |
| $.ajax({ | |
| url: '/widget/chat/send-chat', | |
| type: 'POST', | |
| //contentType: 'application/json; charset=utf-8', | |
| data: data, | |
| dataType: 'json', | |
| success: function(result) { | |
| if (result == 1){ | |
| // Success | |
| //$('#msg-chat').load(window.location + ' #msg-chat'); | |
| //$.pjax.reload({container:'#comment-chat-id,#msg-chat-comment'}); | |
| //$.pjax.reload('div',{container:'#msg-chat'}); | |
| //$.pjax('div', '#msg-chat', { fragment: '#msg-chat' }); | |
| //$(document).pjax.reload({container:'#msg-chat'}); | |
| //$('#msg-chat').load('#msg-chat'); | |
| //$.pjax.reload({container:'#chat-msg'}); | |
| //$.pjax.reload({container:'#comment'}); | |
| //var element = document.getElementById('chat-msg'); | |
| //element.scrollTop = element.scrollHeight; | |
| $.pjax.reload({container: '#msg-chat', async:false}); | |
| var element = document.getElementById('chat-msg'); | |
| element.scrollTop = element.scrollHeight; | |
| //var js = document.getElementById('chat-msg'); | |
| //$('<div>').load(location.href+ ' #msg-chat', function(response, status, xhr) { | |
| // $('<div>').load(location.href+ ' #msg-chat', function(responseText,response, status, xhr,html) { | |
| // if(js !== null) { | |
| // $('#msg-chat').replaceWith(responseText); | |
| //$('#msg-chat').html(response); | |
| //$('#msg-chat').html($(html).filter('#msg-chat').html()).show(); | |
| //document.body.removeChild(js); | |
| // } | |
| //$(this).remove(); | |
| // }); | |
| //parent.document.getElementById('#msg-cha').reload(); | |
| // $.get(location.href, function(data){ | |
| // $('#msg-cha').empty().append( $(data).find('#msg-cha').children() ); | |
| // }); | |
| } else { | |
| // Fail | |
| } | |
| } | |
| }); | |
| }) | |
| ",$this::POS_READY); | |
| $this->registerJs(" | |
| /* | |
| * Scroll Position Down | |
| * @author ptr.nov@gmail.com | |
| */ | |
| jQuery(document).ready(function($){ | |
| $(function() { | |
| startRefresh(); | |
| }); | |
| function startRefresh() { | |
| setTimeout(function(){ | |
| var element = document.getElementById('chat-msg'); | |
| element.scrollTop = element.scrollHeight; | |
| //$('#chat-msg').load($('#chat-msg').attr('div')); | |
| //$('#msg-chat').load('#msg-chat'); | |
| //$('div#msg-chat').load(); | |
| //$('div#extraControls').show(); | |
| //$('chat-msg').trigger('sporty') | |
| }, 1000); | |
| // $('#chat-msg').pjax({container: '#chat-msg'}); | |
| //$('#chat-msg').load(); | |
| //$('#chat-msg').load(location.href + '#chat-msg'); | |
| //$.pjax.reload({container:'#chat-msg'}); | |
| // var element = document.getElementById('chat-msg'); | |
| // element.scrollTop = element.scrollHeight; | |
| //$('#chat-msg').animate({scrollTop: element.scrollHeight},1); | |
| } | |
| }); | |
| //$('.pre-scrollableChatBase').animate({ scrollTop: $('.pre-scrollableChatBase').innerHeight() }, 'slow'); | |
| //$('.pre-scrollableChatBase').animate({ scrollTop: $('.pre-scrollableChatBase').innerHeight() }, 1); | |
| //$('#chat-msg').attr({ scrollTop: $('#chat-msg').attr('scrollHeight') }); | |
| //return false; | |
| ",$this::POS_READY); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment