main.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. function bx_cnv_delete(e, iConvoId) {
  2. return bx_cnv_action('delete', e, iConvoId, true);
  3. }
  4. function bx_cnv_mark_unread(e, iConvoId) {
  5. return bx_cnv_action('mark_unread', e, iConvoId, false);
  6. }
  7. function bx_cnv_action(sAction, e, iConvoId, isConfirm) {
  8. var oPerform = function() {
  9. bx_loading_btn(e, 1);
  10. $.post(sUrlRoot + 'modules/?r=convos/' + sAction + '/' + parseInt(iConvoId), function (s) {
  11. bx_loading_btn(e, 0);
  12. if (sUrlRoot == s.substring(0,sUrlRoot.length))
  13. location.href = s;
  14. else
  15. bx_alert(s);
  16. });
  17. };
  18. if (isConfirm)
  19. bx_confirm(_t('_Are_you_sure'), oPerform);
  20. else
  21. oPerform();
  22. }
  23. $(document).ready(function () {
  24. var ePreviews = $('.bx-cnv-grid-preview');
  25. if (!ePreviews.length)
  26. return;
  27. var f = function () {
  28. // calculate width of all table rows, except the one which contains messages preview
  29. var iInnerWidth = $('.bx-grid-table').parent().innerWidth();
  30. var iCalcWidth = 0;
  31. $('.bx-grid-table tbody tr:first-child td').each(function () {
  32. if (!$(this).find('.bx-cnv-grid-preview').length)
  33. iCalcWidth += $(this).outerWidth();
  34. });
  35. // set width for messages previews
  36. $('.bx-cnv-grid-preview').each(function () {
  37. var eWrapper = $(this).parent();
  38. var w = iInnerWidth - iCalcWidth - parseInt(eWrapper.css('padding-left')) - parseInt(eWrapper.css('padding-right'));
  39. $(this).width(w + 'px');
  40. });
  41. };
  42. $(window).resize(function() {
  43. f();
  44. });
  45. BxDolGrid.prototype.onDataReloaded = function (isSkipSearchInput) {
  46. f();
  47. };
  48. f();
  49. });