side.html.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. $sideLibs = array();
  3. foreach($lang->doclib->tabList as $libType => $typeName) $sideLibs[$libType] = $this->doc->getLimitLibs($libType);
  4. $allModules = $this->loadModel('tree')->getDocStructure();
  5. $sideSubLibs = array();
  6. $sideSubLibs['product'] = $this->doc->getSubLibGroups('product', array_keys($sideLibs['product']));
  7. $sideSubLibs['execution'] = $this->doc->getSubLibGroups('execution', array_keys($sideLibs['execution']));
  8. if($this->methodName != 'browse')
  9. {
  10. $browseType = '';
  11. $moduleID = '';
  12. }
  13. if(empty($type)) $type = 'product';
  14. $sideWidth = common::checkNotCN() ? '270' : '238';
  15. ?>
  16. <div class="side-col" style="width:<?php echo $sideWidth;?>px" data-min-width="<?php echo $sideWidth;?>">
  17. <div class="cell" id="<?php echo $type;?>">
  18. <div id='title'>
  19. <li class='menu-title'><?php echo $this->lang->doc->menuTitle;?></li>
  20. <?php
  21. $canEditLib = common::hasPriv('doc', 'editLib');
  22. $canManageBook = common::hasPriv('doc', 'manageBook');
  23. $canManageMenu = common::hasPriv('tree', 'browse');
  24. $canEditLib = common::hasPriv('doc', 'editLib');
  25. $canDeleteLib = common::hasPriv('doc', 'deleteLib');
  26. if($type != 'book' and ($canManageMenu or $canEditLib or $canDeleteLib))
  27. {
  28. echo "<div class='menu-actions'>";
  29. echo html::a('javascript:;', "<i class='icon icon-ellipsis-v'></i>", '', "data-toggle='dropdown' class='btn btn-link'");
  30. echo "<ul class='dropdown-menu pull-right'>";
  31. if($canManageMenu)
  32. {
  33. echo '<li>' . html::a($this->createLink('tree', 'browse', "rootID=$libID&view=doc", '', true), '<i class="icon-cog-outline"></i> ' . $this->lang->doc->manageType, '', "class='iframe'") . '</li>';
  34. echo "<li class='divider'></li>";
  35. }
  36. if($canEditLib) echo '<li>' . html::a($this->createLink('doc', 'editLib', "rootID=$libID"), '<i class="icon-edit"></i> ' . $lang->doc->editLib, '', "class='iframe'") . '</li>';
  37. if($canDeleteLib) echo '<li>' . html::a($this->createLink('doc', 'deleteLib', "rootID=$libID"), '<i class="icon-trash"></i> ' . $lang->doc->deleteLib, 'hiddenwin') . '</li>';
  38. echo '</ul></div>';
  39. }
  40. if($type == 'book' and ($canEditLib or $canManageBook))
  41. {
  42. echo "<div class='menu-actions'>";
  43. echo html::a('javascript:;', "<i class='icon icon-ellipsis-v'></i>", '', "data-toggle='dropdown' class='btn btn-link'");
  44. echo "<ul class='dropdown-menu pull-right'>";
  45. if($canEditLib) echo '<li>' . html::a($this->createLink('doc', 'editLib', "rootID=$libID"), '<i class="icon-edit"></i> ' . $lang->doc->editBook, '', "class='iframe'") . '</li>';
  46. if($canManageBook) echo '<li>' . html::a($this->createLink('doc', 'manageBook', "bookID=$libID"), '<i class="icon-cog-outline"></i> ' . $lang->doc->manageBook) . '</li>';
  47. echo '</ul></div>';
  48. }
  49. ?>
  50. </div>
  51. <?php if(!$moduleTree):?>
  52. <hr class="space">
  53. <div class="text-center text-muted tips">
  54. <?php echo $type == 'book' ? $lang->doc->noChapter : $lang->doc->noModule;?>
  55. </div>
  56. <hr class="space">
  57. <?php endif;?>
  58. <?php if($type == 'book'):?>
  59. <?php include './bookside.html.php';?>
  60. <?php else:?>
  61. <?php echo $moduleTree;?>
  62. <?php endif;?>
  63. </div>
  64. <style>
  65. .sortable-sorting .module-name > a {cursor: move;}
  66. .sortable-sorting li >.tree-group {opacity: .5;}
  67. .sortable-sorting .drop-here .tree-group {background-color: #fff3e0;}
  68. .sortable-sorting .drop-here .tree-group > * {opacity: .1;}
  69. .sortable-sorting .drag-shadow .tree-group {opacity: 1!important;}
  70. .sortable-sorting .drag-shadow .tree-actions {visibility: hidden;}
  71. .is-sorting > li > .tree-group {opacity: 1; border-radius: 4px;}
  72. .is-sorting > li ul {display: none!important;}
  73. li.drag-shadow ul {display: none!important;}
  74. </style>
  75. <script>
  76. $(function()
  77. {
  78. /* Make modules tree sortable */
  79. $('#modules').sortable(
  80. {
  81. trigger: '.module-name>a.sort-module, .tree-actions>.sortModule>.icon-move, .module-name>a.sortDoc, .tree-actions>.sortDoc>.icon-move',
  82. dropToClass: 'sort-to',
  83. stopPropagation: true,
  84. nested: true,
  85. selector: 'li',
  86. dragCssClass: 'drop-here',
  87. canMoveHere: function($ele, $target)
  88. {
  89. var maxTop = $('.side-col > .cell > ul').height() - $ele.height();
  90. if(parseFloat($('.drag-shadow').css('top')) < 0) $('.drag-shadow').css('top', '0');
  91. if(parseFloat($('.drag-shadow').css('left')) != 0) $('.drag-shadow').css('left', '0');
  92. if(parseFloat($('.drag-shadow').css('top')) > maxTop) $('.drag-shadow').css('top', maxTop + 'px');
  93. return true;
  94. },
  95. targetSelector: function($ele, $root)
  96. {
  97. var $ul = $ele.closest('ul');
  98. setTimeout(function()
  99. {
  100. if($('#modules').hasClass('sortable-sorting')) $ul.addClass('is-sorting');
  101. }, 100);
  102. if($ele.hasClass('sortDoc'))
  103. {
  104. return $ul.children('li.sortDoc');
  105. }
  106. else
  107. {
  108. return $ul.children('li.catalog');
  109. }
  110. },
  111. always: function()
  112. {
  113. $('#modules,#modules .is-sorting').removeClass('is-sorting');
  114. },
  115. finish: function(e)
  116. {
  117. if(!e.changed) return;
  118. var orders = {};
  119. var link = '';
  120. var elementClass = e.list.context.className;
  121. if(elementClass.indexOf('sortDoc') >= 0)
  122. {
  123. $('#modules').find('li.sortDoc').each(function()
  124. {
  125. var $li = $(this);
  126. var item = $li.data();
  127. orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
  128. });
  129. link = createLink('doc', 'updateOrder');
  130. }
  131. else
  132. {
  133. $('#modules').find('li.can-sort').each(function()
  134. {
  135. var $li = $(this);
  136. var item = $li.data();
  137. '<?php echo $type;?>' == 'book' ? orders['sort[' + item.id + ']'] = $li.attr('data-order') || item.order : orders['orders[' + item.id + ']'] = $li.attr('data-order') || item.order;
  138. });
  139. link = '<?php echo $type?>' == 'book' ? createLink('doc', 'sortBookOrder') : createLink('tree', 'updateOrder');
  140. }
  141. $.post(link, orders, function(data){}).error(function()
  142. {
  143. bootbox.alert(lang.timeout);
  144. });
  145. }
  146. });
  147. });
  148. </script>
  149. </div>