ckeditor.admin.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
  3. For licensing, see LICENSE.html or http://ckeditor.com/license
  4. */
  5. (function ($) {
  6. Drupal.ckeditor_ver = false;
  7. $(document).ready(function() {
  8. if (typeof(CKEDITOR) == "undefined")
  9. return;
  10. $('#edit-uicolor-textarea').show();
  11. Drupal.ckeditor_ver = Drupal.settings.ckeditor_version.split('.')[0];
  12. Drupal.editSkinEditorInit = function() {
  13. var skinframe_src = $('#skinframe').attr('src');
  14. //skinframe_src = skinframe_src.replace(/skin=[^&]+/, 'skin='+$("#edit-skin").val());
  15. var skin = skinframe_src.match(/skin=([^&]+)/)[1];
  16. if ($('#edit-uicolor').val() == 'custom') {
  17. skinframe_src = skinframe_src.replace(/uicolor=[^&]+/, 'uicolor='+$('input[name$="uicolor_user"]').val().replace('#', '') || 'D3D3D3');
  18. }
  19. else {
  20. skinframe_src = skinframe_src.replace(/uicolor=[^&]+/, 'uicolor=D3D3D3');
  21. }
  22. $('#skinframe').attr('src', skinframe_src);
  23. if (Drupal.ckeditor_ver == 3) {
  24. if (skin == "kama") {
  25. $("#edit-uicolor").removeAttr('disabled');
  26. $("#edit-uicolor").parent().removeClass('form-disabled');
  27. }
  28. else {
  29. $("#edit-uicolor").attr('disabled', 'disabled');
  30. $("#edit-uicolor").parent().addClass('form-disabled');
  31. }
  32. }
  33. else {
  34. $("#edit-uicolor").removeAttr('disabled');
  35. $("#edit-uicolor").parent().removeClass('form-disabled');
  36. }
  37. };
  38. Drupal.editSkinEditorInit();
  39. $("#edit-uicolor").bind("change", function() {
  40. Drupal.editSkinEditorInit();
  41. });
  42. $("#input-formats :checkbox").change(function() {
  43. $('#security-filters .filter-warning').hide();
  44. $('#security-filters div.filter-text-formats[filter]').html('');
  45. $('#security-filters ul.text-formats-config').html('');
  46. $('#input-formats :checked').each(function() {
  47. var format_name = $(this).val();
  48. var format_label = $('label[for="' + $(this).attr('id') + '"]').html();
  49. if (typeof(Drupal.settings.text_formats_config_links[format_name]) != 'undefined') {
  50. var text = "<li>" + format_label + " - <a href=\"" + Drupal.settings.text_formats_config_links[format_name].config_url + "\">configure</a></li>";
  51. var dataSel = $('#security-filters ul.text-formats-config');
  52. var html = dataSel.html();
  53. if (html == null || html.length == 0) {
  54. dataSel.html(text);
  55. }
  56. else {
  57. html += text;
  58. dataSel.html(html);
  59. }
  60. }
  61. $('#security-filters div.filter-text-formats[filter]').each(function() {
  62. var filter_name = $(this).attr('filter');
  63. var dataSel = $(this);
  64. var html = dataSel.html();
  65. var status = "enabled";
  66. if (typeof Drupal.settings.text_format_filters[format_name][filter_name] == 'undefined') {
  67. status = "disabled";
  68. }
  69. var text = "<span class=\"filter-text-format-status " + status + "\">" + format_label + ': </span><br/>';
  70. if (html == null || html.length == 0) {
  71. dataSel.html(text);
  72. }
  73. else {
  74. html += text;
  75. dataSel.html(html);
  76. }
  77. });
  78. });
  79. });
  80. $("#input-formats :checkbox:eq(0)").trigger('change');
  81. $(".cke_load_toolbar").click(function() {
  82. var buttons = eval('Drupal.settings.'+$(this).attr("id"));
  83. var text = "[\n";
  84. for(i in buttons) {
  85. if (typeof buttons[i] == 'string'){
  86. text = text + " '/',\n";
  87. }
  88. else {
  89. text = text + " [";
  90. max = buttons[i].length - 1;
  91. rows = buttons.length - 1;
  92. for (j in buttons[i]) {
  93. if (j < max){
  94. text = text + "'" + buttons[i][j] + "',";
  95. } else {
  96. text = text + "'" + buttons[i][j] + "'";
  97. }
  98. }
  99. if (i < rows){
  100. text = text + "],\n";
  101. } else {
  102. text = text + "]\n";
  103. }
  104. }
  105. }
  106. text = text + "]";
  107. text = text.replace(/\['\/'\]/g,"'/'");
  108. $("#edit-toolbar").attr('value',text);
  109. if (Drupal.settings.ckeditor_toolbar_wizard == 't'){
  110. Drupal.ckeditorToolbarReload();
  111. }
  112. return false;
  113. });
  114. if (Drupal.settings.ckeditor_toolbar_wizard == 'f'){
  115. $("form#ckeditor-admin-profile-form textarea#edit-toolbar, form#ckeditor-admin-profile-form #edit-toolbar + .grippie").show();
  116. }
  117. });
  118. })(jQuery);