You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
3.1 KiB

3 years ago
  1. layer_index = layer.load(1, {
  2. shade: [0.1, '#fff'] //0.1透明度的白色背景
  3. });
  4. $.get(
  5. DocConfig.server+"/api/item/myList",
  6. {},
  7. function(data){
  8. var html = '';
  9. if (data.error_code == 0) {
  10. console.log(data.data);
  11. var json = data.data;
  12. for (var i = 0; i < json.length; i++) {
  13. html += '<li class="span3 text-center">' ;
  14. html += '<a class="thumbnail item-thumbnail" href="?s=home/item/show&item_id='+json[i]['item_id']+'" title="'+json[i]['item_description']+'">';
  15. html += '<span class="item-setting" data-src="?s=home/item/setting&item_id='+json[i]['item_id']+'" title="项目设置">';
  16. html += '<i class="icon-wrench" ></i>';
  17. html += '</span>';
  18. if (json[i]['top'] > 0 ) {
  19. html += '<span class="item-top" data-action="cancel" data-item_id="'+json[i]['item_id']+'" title="取消置顶"><i class="icon-arrow-down" ></i></span>';
  20. }else{
  21. html += '<span class="item-top" data-action="top" data-item_id="'+json[i]['item_id']+'" title="置顶项目"><i class="icon-arrow-up" ></i></span>';
  22. }
  23. html += '<p class="my-item">'+json[i]['item_name']+'</p>';
  24. html += '</a>';
  25. html += '</li> ';
  26. };
  27. html += '<li class="span3 text-center" >';
  28. html += '<a class="thumbnail" href="?s=home/item/add" title="'+lang["add_an_item"]+'">';
  29. html += '<p class="my-item ">'+lang["new_item"]+'&nbsp;<i class="icon-plus"></i></p>';
  30. html += '</a></li>';
  31. $("#item-list").html(html);
  32. $("#add-item").show();
  33. layer.closeAll();
  34. bind_events();
  35. } else {
  36. $.alert(lang["save_fail"]);
  37. }
  38. },
  39. "json"
  40. );
  41. function bind_events(){
  42. //当鼠标放在项目上时将浮现设置和置顶图标
  43. $(".item-thumbnail").mouseover(function(){
  44. $(this).find(".item-setting").show();
  45. $(this).find(".item-top").show();
  46. $(this).find(".item-down").show();
  47. });
  48. //当鼠标离开项目上时将隐藏设置和置顶图标
  49. $(".item-thumbnail").mouseout(function(){
  50. $(this).find(".item-setting").hide();
  51. $(this).find(".item-top").hide();
  52. $(this).find(".item-down").hide();
  53. });
  54. //点击项目设置图标时
  55. $(".item-setting").click(function(){
  56. var url = $(this).data("src");
  57. window.location.href = url ;
  58. return false;
  59. });
  60. //点击项目置顶图标时
  61. $(".item-top").click(function(){
  62. var action = $(this).data("action");
  63. var item_id = $(this).data("item_id");
  64. $.post(
  65. DocConfig.server+"/api/item/top",
  66. {"action":action,"item_id":item_id},
  67. function(data){
  68. window.location.reload();
  69. },
  70. "json"
  71. );
  72. return false;
  73. });
  74. //点击取消置顶图标时
  75. $(".item-down").click(function(){
  76. var action = 'cancel';
  77. var item_id = $(this).data("item_id");
  78. $.post(
  79. DocConfig.server+"/api/item/top",
  80. {"action":action,"item_id":item_id},
  81. function(data){
  82. window.location.reload();
  83. },
  84. "json"
  85. );
  86. return false;
  87. });
  88. }