ckeditor.admin.js 4.5 KB

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