main.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. Jquery.dashboard V1.0
  3. @author V.carruesco aka idleman
  4. @mail idleman@idleman.fr
  5. @licence CC-by-nc-sa
  6. */
  7. $(document).ready(function(){
  8. var view = $('#dashboard_switch').val();
  9. plugin_dashboard_load_view(view);
  10. });
  11. function plugin_dashboard_load_view(view){
  12. if($.trim(view) =='') return;
  13. $.ajax({
  14. dataType: "json",
  15. url: 'action.php?action=GET_WIDGETS',
  16. data : {dashboard : view},
  17. success: function(response){
  18. $('#dashboard').dashboard({
  19. models: response.model ,
  20. data: response.data ,
  21. onCreate : function(widget,bloc,column,cell){
  22. $.ajax({
  23. dataType: "json",
  24. url: 'action.php?action=ADD_WIDGET',
  25. data : {view : $('#dashboard_switch').val(),model : widget['uid'],data:widget['data'] , column:column,cell:cell},
  26. method : 'POST',
  27. success : function(response){
  28. $.dashboard.setBlocData(bloc,response);
  29. if(widget.onLoad!=null){
  30. $.ajax({
  31. url : widget.onLoad,
  32. data : {id:widget.id},
  33. method : 'POST',
  34. success : function(response2){
  35. $.dashboard.setBlocData(bloc,response2);
  36. }
  37. });
  38. }
  39. }
  40. });
  41. },
  42. onLoad : function(model,widget){
  43. },
  44. onDelete : function(widget,bloc){
  45. $.ajax({
  46. dataType: "json",
  47. url: 'action.php?action=DELETE_WIDGET',
  48. data : {id : widget.id},
  49. method : 'POST'
  50. });
  51. if(widget.onDelete!=null){
  52. $.ajax({
  53. url : widget.onDelete,
  54. data : {id:widget.id},
  55. method : 'POST'
  56. });
  57. }
  58. },
  59. onMinimize : function(widget){
  60. $.ajax({
  61. dataType: "json",
  62. url: 'action.php?action=MINIMIZE_WIDGET',
  63. data : {id : widget.id},
  64. method : 'POST'
  65. });
  66. if(widget.onMinimize!=null){
  67. $.ajax({
  68. url : widget.onMinimize,
  69. data : {id:widget.id},
  70. method : 'POST'
  71. });
  72. }
  73. },
  74. onMaximize : function(widget){
  75. $.ajax({
  76. dataType: "json",
  77. url: 'action.php?action=MAXIMIZE_WIDGET',
  78. data : {id : widget.id},
  79. method : 'POST'
  80. });
  81. if(widget.onMaximize!=null){
  82. $.ajax({
  83. url : id.onMaximize,
  84. data : {id:widget.id},
  85. method : 'POST'
  86. });
  87. }
  88. },
  89. onMove : function(widget,sort){
  90. $.ajax({
  91. dataType: "json",
  92. url: 'action.php?action=MOVE_WIDGET',
  93. data : {id : widget.id , sort : sort},
  94. method : 'POST'
  95. });
  96. if(widget.onMove!=null){
  97. $.ajax({
  98. url : widget.onMove,
  99. data : {id:widget.id, sort : sort},
  100. method : 'POST'
  101. });
  102. }
  103. }
  104. });
  105. }
  106. });
  107. }