widget.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. function navigation_widget_configure_init(){
  2. var widgetTitle = $('#widget-title');
  3. $('#widget-title').autocomplete({
  4. action : 'navigation_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.url+'</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. $('#widget-url').val(selected.url);
  22. $('#widget-icon').val(selected.icon);
  23. init_components();
  24. }
  25. });
  26. }
  27. function navigation_widget_configure_save(widget,modal){
  28. var data = $('#navigation-widget-form').toJson();
  29. data.action = 'navigation_widget_configure_save';
  30. data.id = modal.attr('data-widget');
  31. $.action(data,function(){
  32. $.message('success','Configuration enregistrée');
  33. dashboard_dashboardwidget_search();
  34. });
  35. }