ajaxgetdropmenu.html.php 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <?php js::set('poolID', $poolID);?>
  2. <?php js::set('module', $module);?>
  3. <?php js::set('method', $method);?>
  4. <style>
  5. #navTabs {position: sticky; top: 0; background: #fff; z-index: 950;}
  6. #navTabs>li {padding: 0px 10px; display: inline-block}
  7. #navTabs>li>span {display: inline-block;}
  8. #navTabs>li>a {margin: 0!important; padding: 8px 0px; display: inline-block}
  9. #tabContent {margin-top: 5px; z-index: 900; max-width: 220px}
  10. .demandpoolTree ul {list-style: none; margin: 0}
  11. .demandpoolTree .demandpools>ul {padding-left: 7px;}
  12. .demandpoolTree .demandpools>ul>li>div {display: flex; flex-flow: row nowrap; justify-content: flex-start; align-items: center;}
  13. .demandpoolTree .demandpools>ul>li label {background: rgba(255,255,255,0.5); line-height: unset; color: #838a9d; border: 1px solid #d8d8d8; border-radius: 2px; padding: 1px 4px;}
  14. .demandpoolTree li a i.icon {font-size: 15px !important;}
  15. .demandpoolTree li a i.icon:before {min-width: 16px !important;}
  16. .demandpoolTree li .label {position: unset; margin-bottom: 0;}
  17. .demandpoolTree li>a, div.hide-in-search>a {display: block; padding: 2px 10px 2px 5px; overflow: hidden; line-height: 20px; text-overflow: ellipsis; white-space: nowrap; border-radius: 4px;}
  18. .demandpoolTree .tree li>.list-toggle {line-height: 24px;}
  19. .demandpoolTree .tree li.has-list.open:before {content: unset;}
  20. #swapper li>div.hide-in-search>a:focus, #swapper li>div.hide-in-search>a:hover {color: #838a9d; cursor: default;}
  21. #swapper li > a {margin-top: 4px; margin-bottom: 4px;}
  22. #swapper li {padding-top: 0; padding-bottom: 0;}
  23. #swapper .tree li>.list-toggle {top: -1px;}
  24. #closed {width: 93px; height: 25px; line-height: 25px; background-color: #ddd; color: #3c495c; text-align: center; margin-left: 15px; border-radius: 2px;}
  25. #gray-line {width:230px; height: 1px; margin-left: 10px; margin-bottom:2px; background-color: #ddd;}
  26. </style>
  27. <?php
  28. $demandpoolCounts = array();
  29. $demandpoolNames = array();
  30. $tabActive = '';
  31. $myDemandpools = 0;
  32. $others = 0;
  33. $dones = 0;
  34. $demandpoolCounts['myDemandpool'] = 0;
  35. $demandpoolCounts['others'] = 0;
  36. $demandpoolCounts['closed'] = 0;
  37. foreach($demandpools as $index => $demandpool)
  38. {
  39. if($demandpool->status != 'closed' and strpos(",{$demandpool->owner},", ",{$this->app->user->account},") !== false) $demandpoolCounts['myDemandpool'] ++;
  40. if($demandpool->status != 'closed' and strpos(",{$demandpool->owner},", ",{$this->app->user->account},") === false) $demandpoolCounts['others'] ++;
  41. if($demandpool->status == 'closed') $demandpoolCounts['closed'] ++;
  42. $demandpoolNames[] = $demandpool->name;
  43. }
  44. $demandpoolsPinYin = common::convert2Pinyin($demandpoolNames);
  45. $myDemandpoolsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  46. $normalDemandpoolsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  47. $closedDemandpoolsHtml = '<ul class="tree tree-angles" data-ride="tree">';
  48. foreach($demandpools as $index => $demandpool)
  49. {
  50. $selected = $demandpool->id == $poolID ? 'selected' : '';
  51. $demandpoolName = $demandpool->name;
  52. if($demandpool->status != 'closed' and strpos(",{$demandpool->owner},", ",{$this->app->user->account},") !== false)
  53. {
  54. $myDemandpoolsHtml .= '<li>' . html::a(sprintf($link, $demandpool->id), $demandpoolName, '', "class='$selected clickable' title='{$demandpool->name}' data-key='" . zget($demandpoolsPinYin, $demandpool->name, '') . "'") . '</li>';
  55. if($selected == 'selected') $tabActive = 'myDemandpool';
  56. $myDemandpools ++;
  57. }
  58. else if($demandpool->status != 'closed' and strpos(",{$demandpool->owner},", ",{$this->app->user->account},") === false)
  59. {
  60. $normalDemandpoolsHtml .= '<li>' . html::a(sprintf($link, $demandpool->id), $demandpoolName, '', "class='$selected clickable' title='{$demandpool->name}' data-key='" . zget($demandpoolsPinYin, $demandpool->name, '') . "'") . '</li>';
  61. if($selected == 'selected') $tabActive = 'other';
  62. $others ++;
  63. }
  64. else if($demandpool->status == 'closed')
  65. {
  66. $closedDemandpoolsHtml .= '<li>' . html::a(sprintf($link, $demandpool->id), $demandpoolName, '', "class='$selected clickable' title='$demandpool->name' data-key='" . zget($demandpoolsPinYin, $demandpool->name, '') . "'") . '</li>';
  67. if($selected == 'selected') $tabActive = 'closed';
  68. }
  69. }
  70. $myDemandpoolsHtml .= '</ul>';
  71. $normalDemandpoolsHtml .= '</ul>';
  72. $closedDemandpoolsHtml .= '</ul>';
  73. ?>
  74. <div class="table-row">
  75. <div class="table-col col-left">
  76. <div class='list-group'>
  77. <?php $tabActive = ($myDemandpools and ($tabActive == 'closed' or $tabActive == 'myDemandpool')) ? 'myDemandpool' : 'other';?>
  78. <?php if($myDemandpools): ?>
  79. <ul class="nav nav-tabs nav-tabs-primary" id="navTabs">
  80. <li class="<?php if($tabActive == 'myDemandpool') echo 'active';?>"><?php echo html::a('#myDemandpool', $lang->demandpool->myDemand, '', "data-toggle='tab' class='not-list-item not-clear-menu'");?><span class="label label-light label-badge"><?php echo $myDemandpools;?></span><li>
  81. <li class="<?php if($tabActive == 'other') echo 'active';?>"><?php echo html::a('#other', $lang->demandpool->other, '', "data-toggle='tab' class='not-list-item not-clear-menu'")?><span class="label label-light label-badge"><?php echo $others;?></span><li>
  82. </ul>
  83. <?php endif;?>
  84. <div class="tab-content demandpoolTree" id="tabContent">
  85. <div class="tab-pane demandpools <?php if($tabActive == 'myDemandpool') echo 'active';?>" id="myDemandpool">
  86. <?php echo $myDemandpoolsHtml;?>
  87. </div>
  88. <div class="tab-pane demandpools <?php if($tabActive == 'other') echo 'active';?>" id="other">
  89. <?php echo $normalDemandpoolsHtml;?>
  90. </div>
  91. </div>
  92. </div>
  93. <div class="col-footer">
  94. <?php //echo html::a(helper::createLink('demandpool', 'browse', 'programID=0&browseType=all'), '<i class="icon icon-cards-view muted"></i> ' . $lang->demandpool->all, '', 'class="not-list-item"'); ?>
  95. <a class='pull-right toggle-right-col not-list-item'><?php echo $lang->demandpool->doneDemands?><i class='icon icon-angle-right'></i></a>
  96. </div>
  97. </div>
  98. <div id="gray-line" hidden></div>
  99. <div id="closed" hidden><?php echo $lang->demandpool->closedDemandpool?></div>
  100. <div class="table-col col-right demandpoolTree">
  101. <div class='list-group demandpools'><?php echo $closedDemandpoolsHtml;?></div>
  102. </div>
  103. </div>
  104. <script>scrollToSelected();</script>
  105. <script>
  106. $(function()
  107. {
  108. $('.nav-tabs li span').hide();
  109. $('.nav-tabs li.active').find('span').show();
  110. $('.nav-tabs>li a').click(function()
  111. {
  112. if($('#swapper input[type="search"]').val() == '')
  113. {
  114. $(this).siblings().show();
  115. $(this).parent().siblings('li').find('span').hide();
  116. }
  117. })
  118. $('#swapper [data-ride="tree"]').tree('expand');
  119. $('#swapper #dropMenu .search-box').on('onSearchChange', function(event, value)
  120. {
  121. if(value != '')
  122. {
  123. $('div.hide-in-search').siblings('i').addClass('hide-in-search');
  124. $('.nav-tabs li span').hide();
  125. }
  126. else
  127. {
  128. $('div.hide-in-search').siblings('i').removeClass('hide-in-search');
  129. $('li.has-list div.hide-in-search').removeClass('hidden');
  130. $('.nav-tabs li.active').find('span').show();
  131. }
  132. if($('.form-control.search-input').val().length > 0)
  133. {
  134. $('#closed').attr("hidden", false);
  135. $('#gray-line').attr("hidden", false);
  136. }
  137. else
  138. {
  139. $('#closed').attr("hidden", true);
  140. $('#gray-line').attr("hidden", true);
  141. }
  142. });
  143. $('#swapper #dropMenu').on('onSearchComplete', function(event, value)
  144. {
  145. if($('.list-group.demandpools').height() == 0)
  146. {
  147. $('#closed').attr("hidden", true);
  148. $('#gray-line').attr("hidden", true);
  149. }
  150. });
  151. })
  152. </script>