menu_editor.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. (function($) {
  2. Drupal.behaviors.menuEditor = {
  3. attach: function (context, settings) {
  4. $('#menu-editor-overview-form #menu-overview', context).each(function(){
  5. // table elements
  6. var table = $(this);
  7. var tbody = $('tbody', this);
  8. // delete all checkbox
  9. (function(){
  10. var th_delete = $('thead th.delete-checkbox', table);
  11. var master_delete_checkbox = $('<input type="checkbox" class="master-delete-checkbox" />');
  12. th_delete.html('<span>&nbsp;'+th_delete.html()+'</span>');
  13. th_delete.prepend(master_delete_checkbox);
  14. var onchange = function(){
  15. var checked_now = master_delete_checkbox.attr('checked');
  16. $('tbody td.delete-checkbox :checkbox', table).attr('checked', checked_now);
  17. };
  18. master_delete_checkbox.change(onchange);
  19. // IE does not trigger the change event..
  20. if ($.browser.msie) {
  21. master_delete_checkbox.click(onchange);
  22. }
  23. })();
  24. // freeze width of first column (currently disabled)
  25. if (false) {
  26. var w = $('td.drag', this).width();
  27. $('td.drag', this).each(function(){
  28. $(this).css('width', w+'px');
  29. });
  30. }
  31. // get reference css for textareas
  32. var ref_input = $('td.path-edit input', this);
  33. var h = ref_input.height();
  34. var ref_css = {
  35. 'height': h + 'px',
  36. 'padding-top': ref_input.css('padding-top'),
  37. 'padding-bottom': ref_input.css('padding-bottom')
  38. };
  39. var div_ref_height = ref_input.parent().height();
  40. // adjust height of existing description textareas
  41. $('td.description textarea', this).css(ref_css);
  42. // this is necessary because of the vertical-align:middle
  43. $('td.description div.form-item', this).css('height', div_ref_height+'px');
  44. // description column resizing
  45. $('td.description textarea', this).focus(function(){
  46. table.addClass('focus-description-column');
  47. $('tr.focus', table).removeClass('focus');
  48. $(this).parents('tr').slice(0, 1).addClass('focus');
  49. });
  50. $('td:not(.description) input', this).focus(function(){
  51. table.removeClass('focus-description-column');
  52. $('tr.focus', table).removeClass('focus');
  53. $(this).parents('tr').slice(0, 1).addClass('focus');
  54. });
  55. });
  56. }
  57. };
  58. })(jQuery);