expand.blade.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <div>
  2. <span class="grid-expand" data-url="{{ $url }}" data-inserted="0" data-id="{{ $key }}" data-key="{{ $dataKey }}" data-toggle="collapse" data-target="#grid-collapse-{{ $dataKey }}">
  3. <a href="javascript:void(0)"><i class="feather icon-chevrons-right"></i> {!! $button !!}</a>
  4. </span>
  5. <template class="grid-expand-{{ $dataKey }}">
  6. <div id="grid-collapse-{{ $dataKey }}">{!! $html !!}</div>
  7. </template>
  8. </div>
  9. <script once>
  10. $('.grid-expand').off('click').on('click', function () {
  11. var _th = $(this), url = _th.data('url');
  12. if ($(this).data('inserted') == '0') {
  13. var key = _th.data('key');
  14. var row = _th.closest('tr');
  15. var html = $('template.grid-expand-'+key).html();
  16. var id = 'expand-'+key+Dcat.helpers.random(10);
  17. var rowKey = _th.data('id');
  18. $(this).attr('data-expand', '#'+id);
  19. row.after("<tr id="+id+"><td colspan='"+(row.find('td').length)+"' style='padding:0 !important; border:0;height:0;'>"+html+"</td></tr>");
  20. if (url) {
  21. var collapse = $('#grid-collapse-'+key);
  22. collapse.find('div').loading();
  23. $('.dcat-loading').css({position: 'inherit', 'padding-top': '70px'});
  24. Dcat.helpers.asyncRender(url+'&key='+rowKey, function (html) {
  25. collapse.html(html);
  26. })
  27. }
  28. $(this).data('inserted', 1);
  29. } else {
  30. if ($("i", this).hasClass('icon-chevrons-right')) {
  31. $(_th.data('expand')).show();
  32. } else {
  33. setTimeout(function() {
  34. $(_th.data('expand')).hide();
  35. }, 250);
  36. }
  37. }
  38. $("i", this).toggleClass("icon-chevrons-right icon-chevrons-down");
  39. });
  40. </script>