muck-contents 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/README.rdoc +9 -0
  2. data/VERSION +1 -1
  3. data/app/views/tiny_mce/files.html.erb +1 -1
  4. data/app/views/tiny_mce/images.html.erb +1 -1
  5. data/app/views/tiny_mce/links.html.erb +1 -1
  6. data/config/initializers/mce_options.rb +1 -1
  7. data/lib/active_record/acts/muck_content.rb +1 -1
  8. data/muck-contents.gemspec +38 -26
  9. data/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/editor_plugin.js +3 -3
  10. data/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/editor_plugin_src.js +3 -3
  11. data/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/js/functions.js +0 -0
  12. data/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/langs/en_dlg.js +0 -0
  13. data/{test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo → public/javascripts/tiny_mce/plugins/muckimage}/editor_plugin.js +3 -3
  14. data/{test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo → public/javascripts/tiny_mce/plugins/muckimage}/editor_plugin_src.js +3 -3
  15. data/public/javascripts/tiny_mce/plugins/{advimagetoo → muckimage}/js/functions.js +0 -0
  16. data/public/javascripts/tiny_mce/plugins/{advimagetoo → muckimage}/langs/en_dlg.js +0 -0
  17. data/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/editor_plugin.js +5 -5
  18. data/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/editor_plugin_src.js +5 -5
  19. data/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/js/functions.js +2 -2
  20. data/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/langs/en_dlg.js +0 -0
  21. data/test/rails_root/config/global_config.yml +2 -0
  22. data/test/rails_root/config/initializers/mce_options.rb +17 -14
  23. data/test/rails_root/public/javascripts/tiny_mce/plugins/bramus_cssextras/editor_plugin.js +649 -0
  24. data/test/rails_root/public/javascripts/tiny_mce/plugins/bramus_cssextras/editor_plugin_src.js +649 -0
  25. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/codehighlighting.htm +50 -0
  26. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/css/codehighlighting.css +32 -0
  27. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/editor_plugin.js +1 -0
  28. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/editor_plugin_src.js +62 -0
  29. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/Thumbs.db +0 -0
  30. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/codehighlight.gif +0 -0
  31. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/codehighlight2.gif +0 -0
  32. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/js/codehighlighting.js +37 -0
  33. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/langs/en.js +12 -0
  34. data/test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/langs/en_dlg.js +12 -0
  35. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/editor_plugin.js +3 -3
  36. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/editor_plugin_src.js +3 -3
  37. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/js/functions.js +0 -0
  38. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advfiletoo → muckfile}/langs/en_dlg.js +0 -0
  39. data/{public/javascripts/tiny_mce/plugins/advimagetoo → test/rails_root/public/javascripts/tiny_mce/plugins/muckimage}/editor_plugin.js +3 -3
  40. data/{public/javascripts/tiny_mce/plugins/advimagetoo → test/rails_root/public/javascripts/tiny_mce/plugins/muckimage}/editor_plugin_src.js +3 -3
  41. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advimagetoo → muckimage}/image.htm +0 -0
  42. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advimagetoo → muckimage}/js/functions.js +0 -0
  43. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advimagetoo → muckimage}/langs/en_dlg.js +0 -0
  44. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/editor_plugin.js +5 -5
  45. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/editor_plugin_src.js +5 -5
  46. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/js/functions.js +2 -2
  47. data/test/rails_root/public/javascripts/tiny_mce/plugins/{advlinktoo → mucklink}/langs/en_dlg.js +0 -0
  48. data/test/rails_root/public/stylesheets/tinymce.css +1 -1
  49. metadata +38 -26
data/README.rdoc CHANGED
@@ -35,6 +35,15 @@ In your app do
35
35
 
36
36
  == Setup
37
37
 
38
+ === Global Config
39
+ Add the following settings to your global_config.yml file and change as is appropriate for your application. In particular
40
+ be sure to set content_css to any css files you want to have show up in your tinymce editor.
41
+ # Content options
42
+ content_git_repository: "#{File.join(RAILS_ROOT, 'repo', RAILS_ENV)}"
43
+ enable_auto_translations: true
44
+ content_enable_solr: false
45
+ content_css: ['/stylesheets/reset.css', '/stylesheets/styles.css']
46
+
38
47
  === Initializer
39
48
  Running rake muck:contents:sync will copy all the needed javascript, image and css files into your project. It will also create an initializer called mce_options.rb. That file
40
49
  contains two basic configurations for tinymce as well as examples on how to create templates. It is recommended that you don't modify that file as it will be overwritten the
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.2.9
@@ -79,7 +79,7 @@
79
79
  </form>
80
80
 
81
81
  <% content_for :head do -%>
82
- <%= javascript_include_tag 'tiny_mce/plugins/advfiletoo/js/functions.js' -%>
82
+ <%= javascript_include_tag 'tiny_mce/plugins/muckfile/js/functions.js' -%>
83
83
  <% end -%>
84
84
  <script language="javascript" type="text/javascript">
85
85
  jQuery(document).ready(function()
@@ -244,7 +244,7 @@
244
244
  </form>
245
245
 
246
246
  <% content_for :head do -%>
247
- <%= javascript_include_tag 'tiny_mce/plugins/advimagetoo/js/functions.js' -%>
247
+ <%= javascript_include_tag 'tiny_mce/plugins/muckimage/js/functions.js' -%>
248
248
  <% end -%>
249
249
  <script language="javascript" type="text/javascript">
250
250
  jQuery(document).ready(function()
@@ -293,7 +293,7 @@
293
293
  </form>
294
294
 
295
295
  <% content_for :head do -%>
296
- <%= javascript_include_tag 'tiny_mce/plugins/advlinktoo/js/functions.js' -%>
296
+ <%= javascript_include_tag 'tiny_mce/plugins/mucklink/js/functions.js' -%>
297
297
  <% end -%>
298
298
  <script language="javascript" type="text/javascript">
299
299
  jQuery(document).ready(function() {
@@ -34,7 +34,7 @@ GlobalConfig.advanced_mce_options = {
34
34
  sub sup charmap separator
35
35
  template visualaid fullscreen code},
36
36
  :theme_advanced_buttons3 => [],
37
- :plugins => %w{ paste media preview inlinepopups safari save searchreplace table style template fullscreen print autosave advimagetoo advlinktoo advfiletoo},
37
+ :plugins => %w{ paste media preview inlinepopups safari save searchreplace table style template fullscreen print autosave muckimage mucklink muckfile},
38
38
  :editor_deselector => "mceNoEditor",
39
39
  :editor_selector => 'mceEditor',
40
40
  :remove_script_host => true,
@@ -207,7 +207,7 @@ module ActiveRecord
207
207
  puts ex
208
208
  # Translations failed, but update the default language
209
209
  translation = translation_for(self.locale)
210
- translation.update_attributes!(:title => self.title, :body => self.body)
210
+ translation.update_attributes!(:title => self.title, :body => self.body) unless translation.blank?
211
211
  end
212
212
  end
213
213
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{muck-contents}
8
- s.version = "0.2.8"
8
+ s.version = "0.2.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Ball", "Joel Duffin"]
@@ -162,10 +162,6 @@ Gem::Specification.new do |s|
162
162
  "public/javascripts/tiny_mce/langs/vi.js",
163
163
  "public/javascripts/tiny_mce/langs/zh.js",
164
164
  "public/javascripts/tiny_mce/license.txt",
165
- "public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js",
166
- "public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js",
167
- "public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js",
168
- "public/javascripts/tiny_mce/plugins/advfiletoo/langs/en_dlg.js",
169
165
  "public/javascripts/tiny_mce/plugins/advhr/css/advhr.css",
170
166
  "public/javascripts/tiny_mce/plugins/advhr/editor_plugin.js",
171
167
  "public/javascripts/tiny_mce/plugins/advhr/editor_plugin_src.js",
@@ -307,10 +303,6 @@ Gem::Specification.new do |s|
307
303
  "public/javascripts/tiny_mce/plugins/advimage/langs/uk_dlg.js",
308
304
  "public/javascripts/tiny_mce/plugins/advimage/langs/vi_dlg.js",
309
305
  "public/javascripts/tiny_mce/plugins/advimage/langs/zh_dlg.js",
310
- "public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js",
311
- "public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js",
312
- "public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js",
313
- "public/javascripts/tiny_mce/plugins/advimagetoo/langs/en_dlg.js",
314
306
  "public/javascripts/tiny_mce/plugins/advlink/css/advlink.css",
315
307
  "public/javascripts/tiny_mce/plugins/advlink/editor_plugin.js",
316
308
  "public/javascripts/tiny_mce/plugins/advlink/editor_plugin_src.js",
@@ -381,10 +373,6 @@ Gem::Specification.new do |s|
381
373
  "public/javascripts/tiny_mce/plugins/advlink/langs/vi_dlg.js",
382
374
  "public/javascripts/tiny_mce/plugins/advlink/langs/zh_dlg.js",
383
375
  "public/javascripts/tiny_mce/plugins/advlink/link.htm",
384
- "public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js",
385
- "public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js",
386
- "public/javascripts/tiny_mce/plugins/advlinktoo/js/functions.js",
387
- "public/javascripts/tiny_mce/plugins/advlinktoo/langs/en_dlg.js",
388
376
  "public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js",
389
377
  "public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js",
390
378
  "public/javascripts/tiny_mce/plugins/autosave/editor_plugin.js",
@@ -657,6 +645,18 @@ Gem::Specification.new do |s|
657
645
  "public/javascripts/tiny_mce/plugins/media/langs/vi_dlg.js",
658
646
  "public/javascripts/tiny_mce/plugins/media/langs/zh_dlg.js",
659
647
  "public/javascripts/tiny_mce/plugins/media/media.htm",
648
+ "public/javascripts/tiny_mce/plugins/muckfile/editor_plugin.js",
649
+ "public/javascripts/tiny_mce/plugins/muckfile/editor_plugin_src.js",
650
+ "public/javascripts/tiny_mce/plugins/muckfile/js/functions.js",
651
+ "public/javascripts/tiny_mce/plugins/muckfile/langs/en_dlg.js",
652
+ "public/javascripts/tiny_mce/plugins/muckimage/editor_plugin.js",
653
+ "public/javascripts/tiny_mce/plugins/muckimage/editor_plugin_src.js",
654
+ "public/javascripts/tiny_mce/plugins/muckimage/js/functions.js",
655
+ "public/javascripts/tiny_mce/plugins/muckimage/langs/en_dlg.js",
656
+ "public/javascripts/tiny_mce/plugins/mucklink/editor_plugin.js",
657
+ "public/javascripts/tiny_mce/plugins/mucklink/editor_plugin_src.js",
658
+ "public/javascripts/tiny_mce/plugins/mucklink/js/functions.js",
659
+ "public/javascripts/tiny_mce/plugins/mucklink/langs/en_dlg.js",
660
660
  "public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin.js",
661
661
  "public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin_src.js",
662
662
  "public/javascripts/tiny_mce/plugins/noneditable/editor_plugin.js",
@@ -1654,10 +1654,6 @@ Gem::Specification.new do |s|
1654
1654
  "test/rails_root/public/javascripts/tiny_mce/langs/vi.js",
1655
1655
  "test/rails_root/public/javascripts/tiny_mce/langs/zh.js",
1656
1656
  "test/rails_root/public/javascripts/tiny_mce/license.txt",
1657
- "test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin.js",
1658
- "test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/editor_plugin_src.js",
1659
- "test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/js/functions.js",
1660
- "test/rails_root/public/javascripts/tiny_mce/plugins/advfiletoo/langs/en_dlg.js",
1661
1657
  "test/rails_root/public/javascripts/tiny_mce/plugins/advhr/css/advhr.css",
1662
1658
  "test/rails_root/public/javascripts/tiny_mce/plugins/advhr/editor_plugin.js",
1663
1659
  "test/rails_root/public/javascripts/tiny_mce/plugins/advhr/editor_plugin_src.js",
@@ -1799,11 +1795,6 @@ Gem::Specification.new do |s|
1799
1795
  "test/rails_root/public/javascripts/tiny_mce/plugins/advimage/langs/uk_dlg.js",
1800
1796
  "test/rails_root/public/javascripts/tiny_mce/plugins/advimage/langs/vi_dlg.js",
1801
1797
  "test/rails_root/public/javascripts/tiny_mce/plugins/advimage/langs/zh_dlg.js",
1802
- "test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin.js",
1803
- "test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/editor_plugin_src.js",
1804
- "test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/image.htm",
1805
- "test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/js/functions.js",
1806
- "test/rails_root/public/javascripts/tiny_mce/plugins/advimagetoo/langs/en_dlg.js",
1807
1798
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/css/advlink.css",
1808
1799
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/editor_plugin.js",
1809
1800
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/editor_plugin_src.js",
@@ -1874,16 +1865,24 @@ Gem::Specification.new do |s|
1874
1865
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/langs/vi_dlg.js",
1875
1866
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/langs/zh_dlg.js",
1876
1867
  "test/rails_root/public/javascripts/tiny_mce/plugins/advlink/link.htm",
1877
- "test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin.js",
1878
- "test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/editor_plugin_src.js",
1879
- "test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/js/functions.js",
1880
- "test/rails_root/public/javascripts/tiny_mce/plugins/advlinktoo/langs/en_dlg.js",
1881
1868
  "test/rails_root/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin.js",
1882
1869
  "test/rails_root/public/javascripts/tiny_mce/plugins/autoresize/editor_plugin_src.js",
1883
1870
  "test/rails_root/public/javascripts/tiny_mce/plugins/autosave/editor_plugin.js",
1884
1871
  "test/rails_root/public/javascripts/tiny_mce/plugins/autosave/editor_plugin_src.js",
1885
1872
  "test/rails_root/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin.js",
1886
1873
  "test/rails_root/public/javascripts/tiny_mce/plugins/bbcode/editor_plugin_src.js",
1874
+ "test/rails_root/public/javascripts/tiny_mce/plugins/bramus_cssextras/editor_plugin.js",
1875
+ "test/rails_root/public/javascripts/tiny_mce/plugins/bramus_cssextras/editor_plugin_src.js",
1876
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/codehighlighting.htm",
1877
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/css/codehighlighting.css",
1878
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/editor_plugin.js",
1879
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/editor_plugin_src.js",
1880
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/Thumbs.db",
1881
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/codehighlight.gif",
1882
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/img/codehighlight2.gif",
1883
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/js/codehighlighting.js",
1884
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/langs/en.js",
1885
+ "test/rails_root/public/javascripts/tiny_mce/plugins/codehighlighting/langs/en_dlg.js",
1887
1886
  "test/rails_root/public/javascripts/tiny_mce/plugins/compat2x/editor_plugin.js",
1888
1887
  "test/rails_root/public/javascripts/tiny_mce/plugins/compat2x/editor_plugin_src.js",
1889
1888
  "test/rails_root/public/javascripts/tiny_mce/plugins/contextmenu/editor_plugin.js",
@@ -2150,6 +2149,19 @@ Gem::Specification.new do |s|
2150
2149
  "test/rails_root/public/javascripts/tiny_mce/plugins/media/langs/vi_dlg.js",
2151
2150
  "test/rails_root/public/javascripts/tiny_mce/plugins/media/langs/zh_dlg.js",
2152
2151
  "test/rails_root/public/javascripts/tiny_mce/plugins/media/media.htm",
2152
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckfile/editor_plugin.js",
2153
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckfile/editor_plugin_src.js",
2154
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckfile/js/functions.js",
2155
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckfile/langs/en_dlg.js",
2156
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckimage/editor_plugin.js",
2157
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckimage/editor_plugin_src.js",
2158
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckimage/image.htm",
2159
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckimage/js/functions.js",
2160
+ "test/rails_root/public/javascripts/tiny_mce/plugins/muckimage/langs/en_dlg.js",
2161
+ "test/rails_root/public/javascripts/tiny_mce/plugins/mucklink/editor_plugin.js",
2162
+ "test/rails_root/public/javascripts/tiny_mce/plugins/mucklink/editor_plugin_src.js",
2163
+ "test/rails_root/public/javascripts/tiny_mce/plugins/mucklink/js/functions.js",
2164
+ "test/rails_root/public/javascripts/tiny_mce/plugins/mucklink/langs/en_dlg.js",
2153
2165
  "test/rails_root/public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin.js",
2154
2166
  "test/rails_root/public/javascripts/tiny_mce/plugins/nonbreaking/editor_plugin_src.js",
2155
2167
  "test/rails_root/public/javascripts/tiny_mce/plugins/noneditable/editor_plugin.js",
@@ -14,8 +14,8 @@
14
14
  return;
15
15
  ed.windowManager.open({
16
16
  file : jQuery('#tiny_mce_files_path').val(),
17
- width : parseInt(jQuery('#tiny_mce_files_width').val()) + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
18
- height : parseInt(jQuery('#tiny_mce_files_height').val()) + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
17
+ width : parseInt(jQuery('#tiny_mce_files_width').val()) + parseInt(ed.getLang('muckfile.delta_width', 0)),
18
+ height : parseInt(jQuery('#tiny_mce_files_height').val()) + parseInt(ed.getLang('muckfile.delta_height', 0)),
19
19
  inline : 1
20
20
  }, {
21
21
  plugin_url : url
@@ -38,5 +38,5 @@
38
38
  }
39
39
  });
40
40
  // Register plugin
41
- tinymce.PluginManager.add('advfiletoo', tinymce.plugins.AdvancedFileTooPlugin);
41
+ tinymce.PluginManager.add('muckfile', tinymce.plugins.AdvancedFileTooPlugin);
42
42
  })();
@@ -14,8 +14,8 @@
14
14
  return;
15
15
  ed.windowManager.open({
16
16
  file : jQuery('#tiny_mce_files_path').val(),
17
- width : parseInt(jQuery('#tiny_mce_files_width').val()) + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
18
- height : parseInt(jQuery('#tiny_mce_files_height').val()) + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
17
+ width : parseInt(jQuery('#tiny_mce_files_width').val()) + parseInt(ed.getLang('muckfile.delta_width', 0)),
18
+ height : parseInt(jQuery('#tiny_mce_files_height').val()) + parseInt(ed.getLang('muckfile.delta_height', 0)),
19
19
  inline : 1
20
20
  }, {
21
21
  plugin_url : url
@@ -38,5 +38,5 @@
38
38
  }
39
39
  });
40
40
  // Register plugin
41
- tinymce.PluginManager.add('advfiletoo', tinymce.plugins.AdvancedFileTooPlugin);
41
+ tinymce.PluginManager.add('muckfile', tinymce.plugins.AdvancedFileTooPlugin);
42
42
  })();
@@ -14,8 +14,8 @@
14
14
  return;
15
15
  ed.windowManager.open({
16
16
  file : jQuery('#tiny_mce_images_path').val(),
17
- width : parseInt(jQuery('#tiny_mce_images_width').val()) + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
18
- height : parseInt(jQuery('#tiny_mce_images_height').val()) + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
17
+ width : parseInt(jQuery('#tiny_mce_images_width').val()) + parseInt(ed.getLang('muckfile.delta_width', 0)),
18
+ height : parseInt(jQuery('#tiny_mce_images_height').val()) + parseInt(ed.getLang('muckfile.delta_height', 0)),
19
19
  inline : 1
20
20
  }, {
21
21
  plugin_url : url
@@ -37,5 +37,5 @@
37
37
  }
38
38
  });
39
39
  // Register plugin
40
- tinymce.PluginManager.add('advimagetoo', tinymce.plugins.AdvancedImageTooPlugin);
40
+ tinymce.PluginManager.add('muckimage', tinymce.plugins.AdvancedImageTooPlugin);
41
41
  })();
@@ -14,8 +14,8 @@
14
14
  return;
15
15
  ed.windowManager.open({
16
16
  file : jQuery('#tiny_mce_images_path').val(),
17
- width : parseInt(jQuery('#tiny_mce_images_width').val()) + parseInt(ed.getLang('advfiletoo.delta_width', 0)),
18
- height : parseInt(jQuery('#tiny_mce_images_height').val()) + parseInt(ed.getLang('advfiletoo.delta_height', 0)),
17
+ width : parseInt(jQuery('#tiny_mce_images_width').val()) + parseInt(ed.getLang('muckfile.delta_width', 0)),
18
+ height : parseInt(jQuery('#tiny_mce_images_height').val()) + parseInt(ed.getLang('muckfile.delta_height', 0)),
19
19
  inline : 1
20
20
  }, {
21
21
  plugin_url : url
@@ -37,5 +37,5 @@
37
37
  }
38
38
  });
39
39
  // Register plugin
40
- tinymce.PluginManager.add('advimagetoo', tinymce.plugins.AdvancedImageTooPlugin);
40
+ tinymce.PluginManager.add('muckimage', tinymce.plugins.AdvancedImageTooPlugin);
41
41
  })();
@@ -15,8 +15,8 @@
15
15
  return;
16
16
  ed.windowManager.open({
17
17
  file : jQuery('#tiny_mce_links_path').val(),
18
- width : parseInt(jQuery('#tiny_mce_links_width').val()) + parseInt(ed.getLang('advlinktoo.delta_width', 0)),
19
- height : parseInt(jQuery('#tiny_mce_links_height').val()) + parseInt(ed.getLang('advlinktoo.delta_height', 0)),
18
+ width : parseInt(jQuery('#tiny_mce_links_width').val()) + parseInt(ed.getLang('mucklink.delta_width', 0)),
19
+ height : parseInt(jQuery('#tiny_mce_links_height').val()) + parseInt(ed.getLang('mucklink.delta_height', 0)),
20
20
  inline : 1
21
21
  }, {
22
22
  plugin_url : url
@@ -24,10 +24,10 @@
24
24
  });
25
25
  // Register buttons
26
26
  ed.addButton('link', {
27
- title : 'advlinktoo.link_desc',
27
+ title : 'mucklink.link_desc',
28
28
  cmd : 'mceAdvLinkToo'
29
29
  });
30
- ed.addShortcut('ctrl+k', 'advlinktoo.advlink_desc', 'mceAdvLinkToo');
30
+ ed.addShortcut('ctrl+k', 'mucklink.advlink_desc', 'mceAdvLinkToo');
31
31
  ed.onNodeChange.add(function(ed, cm, n, co) {
32
32
  cm.setDisabled('link', co && n.nodeName != 'A');
33
33
  cm.setActive('link', n.nodeName == 'A' && !n.name);
@@ -43,5 +43,5 @@
43
43
  }
44
44
  });
45
45
  // Register plugin
46
- tinymce.PluginManager.add('advlinktoo', tinymce.plugins.AdvancedLinkTooPlugin);
46
+ tinymce.PluginManager.add('mucklink', tinymce.plugins.AdvancedLinkTooPlugin);
47
47
  })();
@@ -15,8 +15,8 @@
15
15
  return;
16
16
  ed.windowManager.open({
17
17
  file : jQuery('#tiny_mce_links_path').val(),
18
- width : parseInt(jQuery('#tiny_mce_links_width').val()) + parseInt(ed.getLang('advlinktoo.delta_width', 0)),
19
- height : parseInt(jQuery('#tiny_mce_links_height').val()) + parseInt(ed.getLang('advlinktoo.delta_height', 0)),
18
+ width : parseInt(jQuery('#tiny_mce_links_width').val()) + parseInt(ed.getLang('mucklink.delta_width', 0)),
19
+ height : parseInt(jQuery('#tiny_mce_links_height').val()) + parseInt(ed.getLang('mucklink.delta_height', 0)),
20
20
  inline : 1
21
21
  }, {
22
22
  plugin_url : url
@@ -24,10 +24,10 @@
24
24
  });
25
25
  // Register buttons
26
26
  ed.addButton('link', {
27
- title : 'advlinktoo.link_desc',
27
+ title : 'mucklink.link_desc',
28
28
  cmd : 'mceAdvLinkToo'
29
29
  });
30
- ed.addShortcut('ctrl+k', 'advlinktoo.advlink_desc', 'mceAdvLinkToo');
30
+ ed.addShortcut('ctrl+k', 'mucklink.advlink_desc', 'mceAdvLinkToo');
31
31
  ed.onNodeChange.add(function(ed, cm, n, co) {
32
32
  cm.setDisabled('link', co && n.nodeName != 'A');
33
33
  cm.setActive('link', n.nodeName == 'A' && !n.name);
@@ -43,5 +43,5 @@
43
43
  }
44
44
  });
45
45
  // Register plugin
46
- tinymce.PluginManager.add('advlinktoo', tinymce.plugins.AdvancedLinkTooPlugin);
46
+ tinymce.PluginManager.add('mucklink', tinymce.plugins.AdvancedLinkTooPlugin);
47
47
  })();
@@ -26,8 +26,8 @@ function init() {
26
26
  var action = "insert";
27
27
  var html;
28
28
 
29
- document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','advlinktoo');
30
- document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','advlinktoo');
29
+ document.getElementById('hrefbrowsercontainer').innerHTML = getBrowserHTML('hrefbrowser','href','file','mucklink');
30
+ document.getElementById('popupurlbrowsercontainer').innerHTML = getBrowserHTML('popupurlbrowser','popupurl','file','mucklink');
31
31
  document.getElementById('linklisthrefcontainer').innerHTML = getLinkListHTML('linklisthref','href');
32
32
  document.getElementById('anchorlistcontainer').innerHTML = getAnchorListHTML('anchorlist','href');
33
33
  document.getElementById('targetlistcontainer').innerHTML = getTargetListHTML('targetlist','target');
@@ -57,9 +57,11 @@ default: &DEFAULT
57
57
  content_git_repository: "#{File.join(RAILS_ROOT, 'repo', RAILS_ENV)}"
58
58
  enable_auto_translations: true
59
59
  content_enable_solr: false
60
+ content_css: ['/stylesheets/reset.css', '/stylesheets/styles.css']
60
61
 
61
62
  production:
62
63
  <<: *DEFAULT
64
+ content_css: ['/stylesheets/all.css']
63
65
 
64
66
  development:
65
67
  <<: *DEFAULT
@@ -1,10 +1,6 @@
1
- content_css = ['/stylesheets/reset.css', '/stylesheets/ie.css', '/stylesheets/application.css', '/stylesheets/common.css', '/stylesheets/standard.css']
2
- if Rails.env.production?
3
- content_css = ['/stylesheets/all.css']
4
- end
5
1
  GlobalConfig.advanced_mce_options = {
6
2
  :theme => 'advanced',
7
- :content_css => content_css,
3
+ :content_css => GlobalConfig.content_css,
8
4
  :body_id => 'content',
9
5
  :mode => "textareas",
10
6
  :height => 650,
@@ -24,17 +20,24 @@ GlobalConfig.advanced_mce_options = {
24
20
  :theme_advanced_buttons1 => %w{save cancel print preview separator
25
21
  search replace separator
26
22
  cut copy paste pastetext pasteword selectall undo redo separator
27
- bold italic underline strikethrough styleprops separator
23
+ bold italic underline strikethrough separator
28
24
  justifyleft justifycenter justifyright indent outdent separator
29
25
  bullist numlist separator
30
- link unlink image file media anchor separator
31
- help},
32
- :theme_advanced_buttons2 => %w{formatselect fontselect fontsizeselect forecolor backcolor separator
26
+ link unlink image file media anchor separator
27
+ template visualaid separator
28
+ fullscreen code},
29
+ :theme_advanced_buttons2 => %w{styleprops styleselect separator
30
+ formatselect fontselect fontsizeselect separator
31
+ forecolor backcolor separator
33
32
  tablecontrols separator
34
- sub sup charmap separator
35
- template visualaid fullscreen code},
36
- :theme_advanced_buttons3 => [],
37
- :plugins => %w{ paste media preview inlinepopups safari save searchreplace table style template fullscreen print autosave advimagetoo advlinktoo advfiletoo},
33
+ sub sup charmap },
34
+ :theme_advanced_buttons3 => %w{}, #bramus_cssextras_classes bramus_cssextras_ids
35
+ #:theme_advanced_buttons3 => %w{cleanup code insertdate inserttime removeformat insertlayer},
36
+ :plugins => %w{ paste media preview inlinepopups safari save searchreplace table style template fullscreen print autosave muckimage mucklink},
37
+ # codehighlighting
38
+ # spellchecker,pagebreak,layer,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,
39
+ # contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template
40
+ # bramus_cssextras
38
41
  :editor_deselector => "mceNoEditor",
39
42
  :editor_selector => 'mceEditor',
40
43
  :remove_script_host => true,
@@ -50,7 +53,7 @@ GlobalConfig.advanced_mce_options = {
50
53
 
51
54
  GlobalConfig.simple_mce_options = {
52
55
  :theme => 'advanced',
53
- :content_css => content_css,
56
+ :content_css => GlobalConfig.content_css,
54
57
  :body_id => 'content',
55
58
  :browsers => %w{msie gecko safari},
56
59
  :cleanup_on_startup => true,
@@ -0,0 +1,649 @@
1
+ /**
2
+ * @name bramus_cssextras
3
+ * @version 0.5.0
4
+ *
5
+ * @author Bramus! (Bram Van Damme)
6
+ * @authorURL http://www.bram.us/
7
+ * @infoURL http://www.bram.us/projects/tinymce-plugins/
8
+ *
9
+ * @license Creative Commons Attribution-Share Alike 2.5
10
+ * @licenseURL http://creativecommons.org/licenses/by-sa/2.5/
11
+ *
12
+ * v 0.5.0 - 2007.12.11 - NEW : TinyMCE 3.x Compatibility (TinyMCE 2.x is no longer supported)
13
+ * v 0.4.1 - 2007.11.22 - BUG : didn't work with multiple content_css files specified (@see http://www.bram.us/projects/tinymce-plugins/tinymce-classes-and-ids-plugin-bramus_cssextras/#comment-89820)
14
+ * - BUG : If for example p.test is defined multiple times, show "test" only once in the dropdown.
15
+ * v 0.4.0 - 2007.09.10 - BUG : selection noclass returned "undefined" as class, should be empty
16
+ * - ADD : automatic building of the bramus_cssextras_classesstring and bramus_cssextras_idsstring
17
+ * v 0.3.3 - 2007.07.27 - getInfo returned wrong version. Fixed + version increment.
18
+ * v 0.3.2 - 2007.07.23 - minor change in outputted HTML of the selects
19
+ * v 0.3.1 - 2007.06.28 - ids must be unique, so added a check and confirm thingy ;-)
20
+ * v 0.3 - 2007.06.27 - Plugin changed from bramus_classeslist to bramus_cssextras as it now supports the settings of ids too :-)
21
+ * v 0.2 - 2007.06.22 - added Undo Levels + a few extra comments (should be fully commented now)
22
+ * v 0.1 - 2007.06.19 - initial build
23
+ */
24
+
25
+ (function() {
26
+
27
+ // Load plugin specific language pack
28
+ // tinymce.PluginManager.requireLangPack('bramus_cssextras');
29
+
30
+ tinymce.create('tinymce.plugins.BramusCssExtras', {
31
+
32
+ /**
33
+ * Returns information about the plugin as a name/value array.
34
+ * The current keys are longname, author, authorurl, infourl and version.
35
+ *
36
+ * @return {Object} Name/value array containing information about the plugin.
37
+ */
38
+ getInfo : function() {
39
+ return {
40
+ longname : 'Plugin to support the adding of classes and ids to elements (or their parent element)',
41
+ author : 'Bramus!',
42
+ authorurl : 'http://www.bram.us/',
43
+ infourl : 'http://www.bram.us/projects/tinymce-plugins/',
44
+ version : "0.5.0"
45
+ };
46
+ },
47
+
48
+
49
+ /**
50
+ * Initializes the plugin, this will be executed after the plugin has been created.
51
+ * This call is done before the editor instance has finished it's initialization so use the onInit event
52
+ * of the editor instance to intercept that event.
53
+ *
54
+ * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
55
+ * @param {string} url Absolute URL to where the plugin is located.
56
+ */
57
+ init : function(ed, url) {
58
+ this._init(ed, url);
59
+ },
60
+
61
+
62
+ /**
63
+ * Creates control instances based in the incomming name. This method is normally not
64
+ * needed since the addButton method of the tinymce.Editor class is a more easy way of adding buttons
65
+ * but you sometimes need to create more complex controls like listboxes, split buttons etc then this
66
+ * method can be used to create those.
67
+ *
68
+ * @param {String} n Name of the control to create.
69
+ * @param {tinymce.ControlManager} cm Control manager to use inorder to create new control.
70
+ * @return {tinymce.ui.Control} New control instance or null if no control was created.
71
+ */
72
+ createControl : function(n, cm) {
73
+ switch (n) {
74
+ case 'bramus_cssextras_classes':
75
+ case 'bramus_cssextras_ids':
76
+ return this._createControl(n, cm);
77
+ break;
78
+ }
79
+
80
+ return null;
81
+ },
82
+
83
+
84
+ /**
85
+ * Internally used variables
86
+ * ---------------------------------------------------------------------------------------------------
87
+ */
88
+
89
+ // Strings that will hold all possible classes/ids /* removed, these are global now */
90
+ // _coreClassesString : null,
91
+ // _coreIdsStrings : null,
92
+
93
+ // Arrays that will hold all possible classes/ids /* removed, these are global now */
94
+ // _coreClassesArray : null,
95
+ // _coreIdsArray : null,
96
+
97
+ // The dropdowns
98
+ _coreClassesDropdown : null,
99
+ _coreIdsDropdown : null,
100
+
101
+ // XHR Object & Response - needed for loading the content_css file(s) if needed
102
+ _xmlhttp : null,
103
+ _xmlhttpresponse : null,
104
+
105
+ // CPU Power Savers : The previous node (don't calculate if nothing changed) and Already loaded (only init this plugin once)
106
+ _previousNode : null,
107
+ // _loaded : null, /* removed, these are global now */
108
+
109
+
110
+ /**
111
+ * Helper Functions
112
+ * ---------------------------------------------------------------------------------------------------
113
+ */
114
+
115
+ // Helper function : trim a string
116
+ _trim : function(str) {
117
+ return str.replace(/^\s+|\s+$/g,"");
118
+ },
119
+
120
+ // Helper function : left trim a string
121
+ _ltrim : function(str) {
122
+ return str.replace(/^\s+/,"");
123
+ },
124
+
125
+ // Helper function : right trim a a string
126
+ _rtrim : function() {
127
+ return this.replace(/\s+$/,"");
128
+ },
129
+
130
+ // Helper function : is element in array (and return position if so)
131
+ _inArray : function(needle, haystack) {
132
+
133
+ // loop all elements of array (haystack)
134
+ for (var i = 0; i < haystack.length; i++){
135
+
136
+ // compare with needle
137
+ if (needle == haystack[i]) {
138
+
139
+ // got hit : return position in array
140
+ return i;
141
+
142
+ }
143
+
144
+ }
145
+ // no hit
146
+ return false;
147
+ },
148
+
149
+ /**
150
+ * Init function
151
+ * ---------------------------------------------------------------------------------------------------
152
+ */
153
+
154
+ _init : function (ed, url) {
155
+
156
+ // if not intialized yet: get the params & build the arrays
157
+ if (tinymce.plugins.BramusCssExtras._loaded == undefined) {
158
+
159
+ // get the params
160
+ tinymce.plugins.BramusCssExtras._coreClassesString = tinyMCE.activeEditor.getParam("bramus_cssextras_classesstring", undefined);
161
+ tinymce.plugins.BramusCssExtras._coreIdsString = tinyMCE.activeEditor.getParam("bramus_cssextras_idsstring", undefined);
162
+
163
+ // one of the params was not set, try to get the content_css over XHR (Ajax)
164
+ if ((tinymce.plugins.BramusCssExtras._coreClassesString == undefined) || (tinymce.plugins.BramusCssExtras._coreIdsString == undefined)) {
165
+ this._loadContentCSS(tinyMCE.activeEditor.getParam("content_css", false));
166
+ }
167
+
168
+ // now that we have the params, process 'm
169
+ tinymce.plugins.BramusCssExtras._coreClassesArray = this._processElementsAndShizzle(tinymce.plugins.BramusCssExtras._coreClassesString.split(';'));
170
+ tinymce.plugins.BramusCssExtras._coreIdsArray = this._processElementsAndShizzle(tinymce.plugins.BramusCssExtras._coreIdsString.split(';'));
171
+
172
+ // debug
173
+ // console.log(tinymce.plugins.BramusCssExtras._coreClassesArray);
174
+ // console.log(tinymce.plugins.BramusCssExtras._coreIdsArray);
175
+
176
+ }
177
+
178
+ // hook plugin to nodeChange event
179
+ ed.onNodeChange.add(this._nodeChange, this);
180
+
181
+ // hook Commands
182
+ ed.addCommand('bceClass', function(ui, v) {
183
+ this._execCommand(ed, v, this._coreClassesDropdown, "class");
184
+ }, this);
185
+
186
+ ed.addCommand('bceId', function(ui, v) {
187
+ this._execCommand(ed, v, this._coreIdsDropdown, "id");
188
+ }, this);
189
+
190
+ // set loaded
191
+ tinymce.plugins.BramusCssExtras._loaded = true;
192
+ },
193
+
194
+ /**
195
+ * loadContentCSS function : loads in the content_css over XHR
196
+ * ---------------------------------------------------------------------------------------------------
197
+ */
198
+
199
+ _loadContentCSS : function(content_css) {
200
+
201
+ // only proceed if content_css is set
202
+ if (content_css == false) {
203
+ return;
204
+ }
205
+
206
+ // create nex XHR object
207
+ if (window.XMLHttpRequest) {
208
+ this._xmlhttp = new XMLHttpRequest();
209
+ } else if (window.ActiveXObject) {
210
+ this._xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
211
+ }
212
+
213
+ // var which will hold all data from all files referred through content_css
214
+ content_css_data = "";
215
+
216
+ // make sure it's an object
217
+ if (typeof(this._xmlhttp) == 'object') {
218
+
219
+ // content_css exists?
220
+ if (content_css && (content_css != null) && (content_css != "")) {
221
+
222
+ // support the referring of multiple classes
223
+ content_css_arr = content_css.split(',');
224
+
225
+ // loop all referred css files
226
+ for (i = 0; i < content_css_arr.length; i++) {
227
+
228
+ // load it in, but <<<< SYNCHRONOUS >>>>
229
+ // this._xmlhttp.onreadystatechange = this._doneLoadContentCSS; // SYNCHRONOUS, no need to set onreadystatechange!
230
+ this._xmlhttp.open('GET', this._trim(content_css_arr[i]), false); // false == SYNCHRONOUS ;-)
231
+ this._xmlhttp.send(null);
232
+
233
+ // wait for it to load
234
+ if (this._xmlhttp.readyState == 4) {
235
+
236
+ // loaded!
237
+ if (this._xmlhttp.status == 200) {
238
+
239
+ // get the responseText
240
+ this._xmlhttpresponse = this._xmlhttp.responseText;
241
+
242
+ // run some prelim regexes on them
243
+ this._xmlhttpresponse = this._xmlhttpresponse.replace(/(\r\n)/g, ""); // get all CSS rules on 1 line per selector : 1 line on whole document
244
+ this._xmlhttpresponse = this._xmlhttpresponse.replace(/(\})/g, "}\n"); // get all CSS rules on 1 line per selector : 1 line per selector
245
+ this._xmlhttpresponse = this._xmlhttpresponse.replace(/\{(.*)\}/g, ""); // strip out css rules themselves
246
+ this._xmlhttpresponse = this._xmlhttpresponse.replace(/\/\*(.*)\*\//g, ""); // strip out comments
247
+ this._xmlhttpresponse = this._xmlhttpresponse.replace(/\t/g, ""); // strip out tabs
248
+
249
+ content_css_data += this._xmlhttpresponse + "\n";
250
+
251
+ // not loaded!
252
+ } else {
253
+ tinyMCE.activeEditor.windowManager.alert("[bramus_cssextras] Error while loading content_css file '" + content_css_arr[i] + "', make sure the path is correct!");
254
+ }
255
+ }
256
+ }
257
+
258
+ // clear the xhr object
259
+ this._xmlhttp = null;
260
+
261
+ }
262
+ }
263
+
264
+ // process the content_css_data (only if the vars are not set yet - viz. don't overwrite)
265
+ if (tinymce.plugins.BramusCssExtras._coreClassesString == undefined) {
266
+ tinymce.plugins.BramusCssExtras._coreClassesString = this._processContentCSSMatches(content_css_data, ".");
267
+ }
268
+
269
+ if (tinymce.plugins.BramusCssExtras._coreIdsString == undefined) {
270
+ tinymce.plugins.BramusCssExtras._coreIdsString = this._processContentCSSMatches(content_css_data, "#");
271
+ }
272
+
273
+
274
+ },
275
+
276
+ /**
277
+ * processContentCSSMatches function : processes the matches loaded over XHR
278
+ * ---------------------------------------------------------------------------------------------------
279
+ */
280
+
281
+ _processContentCSSMatches : function(content_css_data, identifier) {
282
+
283
+ // split da sucker!
284
+ if (identifier == ".") {
285
+ matches = content_css_data.match(/([a-zA-Z0-9])+(\.)([a-zA-Z0-9_\-])+(\b)?/g);
286
+ } else {
287
+ matches = content_css_data.match(/([a-zA-Z0-9])+(\#)([a-zA-Z0-9_\-])+(\b)?/g);
288
+ }
289
+
290
+ // got any matches?
291
+ if (!matches) {
292
+ return "";
293
+ } else {
294
+ arr_selectors = new Array();
295
+ arr_values = new Array();
296
+ }
297
+
298
+ // run matches and build selectors and values arrays.
299
+ for (var i = 0; i < matches.length; i++) {
300
+
301
+ // split on the identifier
302
+ matches[i] = matches[i].split(identifier);
303
+
304
+ var position = this._inArray(((matches[i][0] != "ul")?matches[i][0]:"li") + "::" + ((matches[i][0] != "ul")?"self":matches[i][0]), arr_selectors);
305
+
306
+ // not found : add selector and classes/ids
307
+ if (position === false) {
308
+ arr_selectors.push(((matches[i][0] != "ul")?matches[i][0]:"li") + "::" + ((matches[i][0] != "ul")?"self":matches[i][0]));
309
+ arr_values.push(matches[i][1]);
310
+
311
+ // found, adjust ids on position
312
+ } else {
313
+ // extra check: check if ain't class/id isn't in values yet!
314
+ if (this._inArray(matches[i][1], arr_values[position].split(',')) === false) {
315
+ arr_values[position] = arr_values[position] + "," + matches[i][1];
316
+ }
317
+ }
318
+
319
+ }
320
+
321
+ // build the elmsAndShizzleArray (Shizzle being either Ids or Classes)
322
+ var elmsAndShizzleArray = new Array();
323
+
324
+ for (var i = 0; i < arr_selectors.length; i++) {
325
+ elmsAndShizzleArray.push(arr_selectors[i] + "[" + arr_values[i] + "]");
326
+ }
327
+
328
+ return elmsAndShizzleArray.join(';');
329
+ },
330
+
331
+ /**
332
+ * processMatches
333
+ * ---------------------------------------------------------------------------------------------------
334
+ */
335
+
336
+ _processElementsAndShizzle : function(elmsAndShizzleArray) {
337
+
338
+ // create new array to hold the real stuff
339
+ coreArray = new Array();
340
+
341
+ // if no array passed in, return an empty array!
342
+ if (!elmsAndShizzleArray) {
343
+ return coreArray;
344
+ }
345
+
346
+ // loop the entries of elmsAndClassesArray
347
+ if (elmsAndShizzleArray.length > 0) {
348
+ for (var i = 0; i < elmsAndShizzleArray.length; i++) {
349
+
350
+ // check if syntax is correct and get data from the entry
351
+ var elmAndShizzleString = elmsAndShizzleArray[i];
352
+ var elmAndShizzleArray = elmAndShizzleString.match(/(.*)::(.*)\[(.*)\]/);
353
+
354
+ // got less than 4 matches : invalid entry!
355
+ if ((!elmAndShizzleArray) || (elmAndShizzleArray.length < 4)) {
356
+
357
+ // nothing
358
+
359
+ // found 4 matches : valid entry!
360
+ } else{
361
+
362
+ // get elementNodeName, parentElementNodeName, elementClasses and push them on the arrayz!
363
+ coreArray.push(new Array(elmAndShizzleArray[1], elmAndShizzleArray[2], elmAndShizzleArray[3].split(',')));
364
+ }
365
+ }
366
+ }
367
+
368
+ // return it
369
+ return coreArray;
370
+ },
371
+
372
+ /**
373
+ * createControl function
374
+ * ---------------------------------------------------------------------------------------------------
375
+ */
376
+
377
+ _createControl : function (n, cm) {
378
+
379
+ switch(n) {
380
+
381
+ // bramus_cssextras_classes
382
+ case "bramus_cssextras_classes":
383
+
384
+ // create a dropdown
385
+ ddm = cm.createListBox('bramus_cssextras_classes_dropdown_' + tinyMCE.activeEditor.id, {
386
+ title : '.class',
387
+ cmd : 'bceClass'
388
+ });
389
+
390
+ // keep a reference to it in our own instance!
391
+ this._coreClassesDropdown = ddm;
392
+
393
+ // return it
394
+ return ddm;
395
+
396
+ break;
397
+
398
+ // bramus_cssextras_ids
399
+ case "bramus_cssextras_ids":
400
+
401
+ // create a dropdown
402
+ ddm = cm.createListBox('bramus_cssextras_ids_dropdown_' + tinyMCE.activeEditor.id, {
403
+ title : '#id',
404
+ cmd : 'bceId'
405
+ });
406
+
407
+ // keep a reference to it in our own instance!
408
+ this._coreIdsDropdown = ddm;
409
+
410
+ // return it
411
+ return ddm;
412
+
413
+ break;
414
+
415
+ }
416
+
417
+ return null;
418
+ },
419
+
420
+
421
+ /**
422
+ * nodeChange Function : event which gets triggered when the node has changed
423
+ * ---------------------------------------------------------------------------------------------------
424
+ */
425
+
426
+ _nodeChange : function(ed, cm, n) {
427
+
428
+ // save your energy : check if ed.id equals tinyMCE.activeEditor.id
429
+ if (tinyMCE.activeEditor.id != ed.id) {
430
+ return;
431
+ }
432
+
433
+ // save your energy : no node select : return!
434
+ if (n == null)
435
+ return;
436
+
437
+ // save your energy : check if node differs from previousnode. If not, then we don't need to loop this all again ;-)
438
+ if (n == this._previousNode) {
439
+ return;
440
+ } else {
441
+ this._previousNode = n;
442
+ }
443
+
444
+ // check if current elem has a match in the _coreArrayClasses or _coreArrayIds
445
+ var gotHitClass = this._checkHit(tinymce.plugins.BramusCssExtras._coreClassesArray);
446
+ var gotHitIds = this._checkHit(tinymce.plugins.BramusCssExtras._coreIdsArray);
447
+
448
+ // now do something with that hit and that dropdown!
449
+ this._rebuildDropdown(gotHitClass, this._coreClassesDropdown, "class", ed);
450
+ this._rebuildDropdown(gotHitIds, this._coreIdsDropdown, "id", ed);
451
+
452
+ },
453
+
454
+
455
+ /**
456
+ * checkHit : checks if the current node matches any of the arrays
457
+ * ---------------------------------------------------------------------------------------------------
458
+ */
459
+ _checkHit : function(coreArray) {
460
+
461
+ // correarray not null?
462
+ if (coreArray) {
463
+ for (var i = 0; i < coreArray.length; i++) {
464
+ if (coreArray[i][0].toLowerCase() == this._previousNode.nodeName.toLowerCase()) {
465
+ return coreArray[i];
466
+ }
467
+ }
468
+ }
469
+
470
+ return null;
471
+
472
+ },
473
+
474
+
475
+ /**
476
+ * rebuildDropdown : rebuilds the dropdowns and makes it so that the correct value is selected
477
+ * ---------------------------------------------------------------------------------------------------
478
+ */
479
+ _rebuildDropdown : function(gotHit, selectDropDown, what, ed) {
480
+
481
+ if (gotHit === null) {
482
+
483
+ // only continue if a dropdown is present!
484
+ if (selectDropDown) {
485
+
486
+ // remove existing items
487
+ selectDropDown.items = [];
488
+
489
+ // TinyMCE fix - TIP : Moxiecode should provide a neat way to removing all items!
490
+ selectDropDown.oldID = null;
491
+
492
+ // select nothing
493
+ selectDropDown.select();
494
+
495
+ // disable the dropdown
496
+ selectDropDown.setDisabled(true);
497
+
498
+ }
499
+
500
+ } else {
501
+
502
+ // get params from gotHit
503
+ var elemNodeName = gotHit[0];
504
+ var parentElemNodeName = gotHit[1];
505
+ var elementClasses = gotHit[2];
506
+
507
+ // continue if parentElemNodeName equals self, or if parent node equals parentElemNodeName
508
+ if ((parentElemNodeName == "self") || (ed.dom.getParent(this._previousNode, parentElemNodeName).nodeName.toLowerCase() == parentElemNodeName)) {
509
+
510
+ // remove existing items
511
+ selectDropDown.items = [];
512
+
513
+ // TinyMCE fix - TIP : Moxiecode should provide a neat way to removing all items!
514
+ selectDropDown.oldID = null;
515
+
516
+ // push on the new ones (and enforce first one)
517
+ selectDropDown.add('[ no ' + what + ' ]', parentElemNodeName + "::");
518
+
519
+ // select nothing
520
+ selectDropDown.select();
521
+
522
+ // fill the dropdown with the values
523
+ for (var i = 0; i < elementClasses.length; i++) {
524
+
525
+ selectDropDown.add(elementClasses[i], parentElemNodeName + "::" + elementClasses[i]);
526
+
527
+ // this node or the parent node?
528
+ if (parentElemNodeName == "self") {
529
+ var pNode = this._previousNode;
530
+ } else {
531
+ var pNode = ed.dom.getParent(this._previousNode, parentElemNodeName);
532
+ }
533
+
534
+ // if the instance currently has this class, set this option as selected
535
+ switch(what) {
536
+ case "class":
537
+ if (ed.dom.hasClass(pNode, elementClasses[i])) {
538
+ selectDropDown.select(parentElemNodeName + "::" + elementClasses[i]);
539
+ }
540
+ break;
541
+ case "id":
542
+ if (pNode.id == elementClasses[i]) {
543
+ selectDropDown.select(parentElemNodeName + "::" + elementClasses[i]);
544
+ }
545
+ break;
546
+ }
547
+
548
+ }
549
+
550
+ }
551
+
552
+ // render the selectdropdown
553
+ selectDropDown.renderMenu();
554
+
555
+ // enable the selectbox!
556
+ selectDropDown.setDisabled(false);
557
+
558
+ }
559
+
560
+ },
561
+
562
+ _execCommand : function(ed, listValue, selectDropDown, what) {
563
+
564
+ // this node or the parent node?
565
+ if (listValue.split("::")[0] == "self") {
566
+ var node = ed.selection.getNode();
567
+ } else {
568
+ var node = ed.dom.getParent(ed.selection.getNode(), listValue.split("::")[0]);
569
+ }
570
+
571
+ // begin Undo
572
+ tinyMCE.execCommand('mceBeginUndoLevel');
573
+
574
+ // define what to set class or id to
575
+ toSetTo = (listValue.split("::")[1] != undefined)?listValue.split("::")[1]:"";
576
+
577
+ // set className
578
+ if (what == "class") {
579
+ node.className = toSetTo;
580
+
581
+ // set id
582
+ } else {
583
+
584
+ // toSetTo is not empty : perform a check if an element with that id already exists
585
+ if (toSetTo != "") {
586
+
587
+ // there already exists an element with that id?
588
+ if (ed.getDoc().getElementById(toSetTo)) {
589
+
590
+ // confirm the move of the id
591
+ if (confirm("There already exists an element with that id, ids must be unique.\nPress 'OK' to move the id to the current element.\nPress 'Cancel' to leave unchanged")) {
592
+
593
+ // remove id from current element with that id
594
+ ed.getDoc().getElementById(toSetTo).id = "";
595
+
596
+ // set id on node
597
+ node.id = toSetTo;
598
+
599
+ // not confirmed, set selectedindex of node to the first item
600
+ } else {
601
+
602
+ // select the first item
603
+ selectDropDown.select(listValue.split("::")[0] + '::');
604
+
605
+ // stop the click event
606
+ // console.log(tinymce.dom.Event.events);
607
+ tinymce.dom.Event.cancel(tinymce.dom.Event.events[0]); // BUG! - this ain't workin :-( ... how can I cancel the current event (viz. the click on the item in the ListBox)?
608
+ }
609
+
610
+ // no element with that id exists yet : set the id
611
+ } else {
612
+
613
+ // set id on node
614
+ node.id = toSetTo;
615
+ }
616
+
617
+ // toSetTo is empty : clear the id on the selected element
618
+ } else {
619
+
620
+ // set id on node
621
+ node.id = toSetTo;
622
+ }
623
+ }
624
+
625
+ // endUndo
626
+ tinyMCE.execCommand('mceEndUndoLevel');
627
+
628
+ // repaint the instance
629
+ ed.execCommand('mceRepaint');
630
+
631
+ // This is needed?
632
+ // EditorManager.activeEditor.nodeChanged();
633
+
634
+ },
635
+
636
+
637
+ /**
638
+ * End Of Plugin (EOP)
639
+ * ---------------------------------------------------------------------------------------------------
640
+ */
641
+
642
+ // The last one (so I don't forget to close)
643
+ EOP : true
644
+
645
+ });
646
+
647
+ // Register plugin
648
+ tinymce.PluginManager.add('bramus_cssextras', tinymce.plugins.BramusCssExtras);
649
+ })();