widget.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. function stats_widget_configure_init(){
  2. var widgetTitle = $('#widget-stats');
  3. widgetTitle.autocomplete({
  4. action : 'stats_widget_configure_autocomplete',
  5. skin : function(item){
  6. var html = '';
  7. var re = new RegExp(widgetTitle.val(),"gi");
  8. name = item.name.replace(re, function (x) {
  9. return '<strong>'+x+'</strong>';
  10. });
  11. html += '<h5 class="mt-1"><i class="'+item.icon+'"></i> <span>'+name+'</span></h5>';
  12. html +='<small>'+item.report+'</small></div>';
  13. html += '<div class="clear"></div>';
  14. return html;
  15. },
  16. highlight : function(item){
  17. return item;
  18. },
  19. onClick : function(selected,element){
  20. widgetTitle.val(selected.name);
  21. widgetTitle.attr('data-id',selected.id)
  22. init_components();
  23. }
  24. });
  25. }
  26. function widget_stats_init(){
  27. init_components();
  28. $('.widgetStatsContainer canvas').css('height','280px');
  29. $('.widgetStatsContainer canvas[data-type="doughnut"]').css('width','280px').css('margin','auto');
  30. }
  31. function stats_widget_configure_save(widget,modal){
  32. var data = $('#stats-widget-form').toJson();
  33. data.action = 'stats_widget_configure_save';
  34. data.id = modal.attr('data-widget');
  35. data.stats = $('#widget-stats').attr('data-id');
  36. $.action(data,function(){
  37. $.message('success','Configuration enregistrée');
  38. dashboard_dashboardwidget_search();
  39. });
  40. }