refinerycms 0.9.5.14 → 0.9.5.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -69,7 +69,7 @@ eval("#{(defined? Refinery::Initializer) ? Refinery : Rails}::Initializer").run
69
69
  config.gem "rails", :version => ">= 2.3.4", :lib => "rails"
70
70
  config.gem "aasm", :version => ">= 2.1.3", :lib => "aasm", :source => "http://gemcutter.org"
71
71
  config.gem "unicode", :version => ">= 0.1", :lib => "unicode"
72
- config.gem "slim_scrooge", :source => "http://gemcutter.org"
73
- config.gem "hpricot", :version => "0.8.1", :lib => "hpricot", :source => "http://gemcutter.org"
72
+ config.gem "slim_scrooge", :version => ">= 1.0.1", :lib => "slim_scrooge", :source => "http://gemcutter.org"
73
+ config.gem "hpricot", :version => "= 0.8.1", :lib => "hpricot", :source => "http://gemcutter.org"
74
74
  #===REFINERY END OF REQUIRED GEMS===
75
75
  end
@@ -10,7 +10,7 @@ var wymeditor_boot_options = {
10
10
  , langPath: "/javascripts/wymeditor/lang/"
11
11
  , iframeBasePath: '/'
12
12
  , toolsItems: [
13
- {'name': 'Bold', 'title': 'Bold', 'css': 'wym_tools_strong'}
13
+ {'name': 'Bold', 'title': 'Bold', 'css': 'wym_tools_strong'}
14
14
  ,{'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'}
15
15
  ,{'name': 'InsertOrderedList', 'title': 'Ordered_List', 'css': 'wym_tools_ordered_list'}
16
16
  ,{'name': 'InsertUnorderedList', 'title': 'Unordered_List', 'css': 'wym_tools_unordered_list'}
@@ -24,7 +24,7 @@ var wymeditor_boot_options = {
24
24
 
25
25
  ,toolsHtml: "<ul class='wym_tools wym_section'>" + WYMeditor.TOOLS_ITEMS + WYMeditor.CLASSES + "</ul>"
26
26
 
27
- ,toolsItemHtml:
27
+ ,toolsItemHtml:
28
28
  "<li class='" + WYMeditor.TOOL_CLASS + "'>"
29
29
  + "<a href='#' name='" + WYMeditor.TOOL_NAME + "' title='" + WYMeditor.TOOL_TITLE + "'>" + WYMeditor.TOOL_TITLE + "</a>"
30
30
  + "</li>"
@@ -35,13 +35,13 @@ var wymeditor_boot_options = {
35
35
  ,{'name': 'h2', 'title':'Heading_2', 'css':'wym_containers_h2'}
36
36
  ,{'name': 'h3', 'title':'Heading_3', 'css':'wym_containers_h3'}
37
37
  ,{'name': 'p', 'title':'Paragraph', 'css':'wym_containers_p'}
38
- ]
38
+ ]
39
39
 
40
40
  , classesHtml: "<li class='wym_tools_class'><a href='#' name='" + WYMeditor.APPLY_CLASS + "' title='"+ titleize(WYMeditor.APPLY_CLASS) +"'></a><ul class='wym_classes wym_classes_hidden'>" + WYMeditor.CLASSES_ITEMS + "</ul></li>"
41
41
 
42
42
  , classesItemHtml: "<li><a href='#' name='"+ WYMeditor.CLASS_NAME + "'>"+ WYMeditor.CLASS_TITLE+ "</a></li>"
43
43
  , classesItemHtmlMultiple: "<li class='wym_tools_class_multiple_rules'><span>" + WYMeditor.CLASS_TITLE + "</span><ul>{classesItemHtml}</ul></li>"
44
-
44
+
45
45
  , classesItems: [{name:'text-align', rules:['left', 'center', 'right', 'justify'], join: '-'}, {name: 'image-align', rules:['left', 'right'], join: '-'}, {name: 'font-size', rules:['small','normal','large'], join: '-'}]
46
46
 
47
47
  , containersHtml: "<ul class='wym_containers wym_section'>" + WYMeditor.CONTAINERS_ITEMS + "</ul>"
@@ -51,10 +51,10 @@ var wymeditor_boot_options = {
51
51
  + "<a href='#' name='" + WYMeditor.CONTAINER_NAME + "' title='" + WYMeditor.CONTAINER_TITLE + "'></a>"
52
52
  + "</li>"
53
53
 
54
- , boxHtml:
54
+ , boxHtml:
55
55
  "<div class='wym_box'>"
56
- + "<div class='wym_area_top'>"
57
- + WYMeditor.TOOLS
56
+ + "<div class='wym_area_top'>"
57
+ + WYMeditor.TOOLS
58
58
  + WYMeditor.CONTAINERS
59
59
  + "</div>"
60
60
  + "<div class='wym_area_main'>"
@@ -63,8 +63,8 @@ var wymeditor_boot_options = {
63
63
  + WYMeditor.STATUS
64
64
  + "</div>"
65
65
  + "</div>"
66
-
67
- , iframeHtml:
66
+
67
+ , iframeHtml:
68
68
  "<div class='wym_iframe wym_section'>"
69
69
  + "<iframe id='WYMeditor_" + WYMeditor.INDEX + "' src='" + WYMeditor.IFRAME_BASE_PATH + "wymiframe' frameborder='0'"
70
70
  + " onload='this.contentWindow.parent.WYMeditor.INSTANCES[" + WYMeditor.INDEX + "].initIframe(this);'></iframe>"
@@ -74,7 +74,7 @@ var wymeditor_boot_options = {
74
74
 
75
75
  , dialogLinkHtml: ""
76
76
 
77
- , dialogTableHtml:
77
+ , dialogTableHtml:
78
78
  "<div class='wym_dialog wym_dialog_table'>"
79
79
  + "<form>"
80
80
  + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='"+ WYMeditor.DIALOG_TABLE + "' />"
@@ -97,8 +97,8 @@ var wymeditor_boot_options = {
97
97
  + "</div>"
98
98
  + "</form>"
99
99
  + "</div>"
100
-
101
- , dialogPasteHtml:
100
+
101
+ , dialogPasteHtml:
102
102
  "<div class='wym_dialog wym_dialog_paste'>"
103
103
  + "<form>"
104
104
  + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='" + WYMeditor.DIALOG_PASTE + "' />"
@@ -135,15 +135,15 @@ var wymeditor_boot_options = {
135
135
  , postInit: function(wym)
136
136
  {
137
137
  wym._iframe.style.height = wym._element.height() + "px";
138
- wymeditors_loaded += 1;
139
- if(WYMeditor.INSTANCES.length == wymeditors_loaded){
138
+ wymeditors_loaded += 1;
139
+ if(WYMeditor.INSTANCES.length == wymeditors_loaded){
140
140
  WYMeditor.loaded();
141
141
  }
142
142
  }
143
143
  };
144
144
 
145
145
  // custom function added by us to hook into when all wymeditor instances on the page have finally loaded:
146
- WYMeditor.loaded = function(){}
146
+ WYMeditor.loaded = function(){};
147
147
 
148
148
  jQuery(function()
149
149
  {
@@ -200,7 +200,7 @@ jQuery.extend(WYMeditor, {
200
200
  TOGGLE_HTML : "ToggleHtml",
201
201
  FORMAT_BLOCK : "FormatBlock",
202
202
  PREVIEW : "Preview",
203
-
203
+
204
204
  UNLINK : "Unlink",
205
205
  INSERT_UNORDEREDLIST : "InsertUnorderedList",
206
206
  INSERT_ORDEREDLIST : "InsertOrderedList",
@@ -230,7 +230,7 @@ jQuery.extend(WYMeditor, {
230
230
  ATTRIBUTE: 2,
231
231
  TEXT: 3
232
232
  },
233
-
233
+
234
234
  /*
235
235
  Class: WYMeditor.editor
236
236
  WYMeditor editor main class, instanciated for each editor occurrence.
@@ -302,7 +302,7 @@ jQuery.extend(WYMeditor, {
302
302
  * }
303
303
  * );
304
304
  * @desc Example description here
305
- *
305
+ *
306
306
  * @name WYMeditor
307
307
  * @description WYMeditor is a web-based WYSIWYM XHTML editor
308
308
  * @param Hash hash A hash of parameters
@@ -318,23 +318,23 @@ jQuery.fn.wymeditor = function(options) {
318
318
  options = jQuery.extend({
319
319
 
320
320
  html: "",
321
-
321
+
322
322
  basePath: false,
323
-
323
+
324
324
  skinPath: false,
325
325
  jsSkinPath: false,
326
326
  cssSkinPath: false,
327
-
327
+
328
328
  wymPath: false,
329
-
329
+
330
330
  iframeBasePath: false,
331
-
331
+
332
332
  jQueryPath: false,
333
-
333
+
334
334
  styles: false,
335
-
335
+
336
336
  stylesheet: false,
337
-
337
+
338
338
  skin: "default",
339
339
  initSkin: true,
340
340
  loadSkin: true,
@@ -344,7 +344,7 @@ jQuery.fn.wymeditor = function(options) {
344
344
  direction: "ltr",
345
345
 
346
346
  boxHtml: "<div class='wym_box'>"
347
- + "<div class='wym_area_top'>"
347
+ + "<div class='wym_area_top'>"
348
348
  + WYMeditor.TOOLS
349
349
  + "</div>"
350
350
  + "<div class='wym_area_left'></div>"
@@ -374,7 +374,7 @@ jQuery.fn.wymeditor = function(options) {
374
374
  + WYMeditor.INDEX + "].initIframe(this)'"
375
375
  + "></iframe>"
376
376
  + "</div>",
377
-
377
+
378
378
  editorStyles: [],
379
379
 
380
380
  toolsHtml: "<div class='wym_tools wym_section'>"
@@ -383,7 +383,7 @@ jQuery.fn.wymeditor = function(options) {
383
383
  + WYMeditor.TOOLS_ITEMS
384
384
  + "</ul>"
385
385
  + "</div>",
386
-
386
+
387
387
  toolsItemHtml: "<li class='"
388
388
  + WYMeditor.TOOL_CLASS
389
389
  + "'><a href='#' name='"
@@ -395,7 +395,7 @@ jQuery.fn.wymeditor = function(options) {
395
395
  + "</a></li>",
396
396
 
397
397
  toolsItems: [
398
- {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'},
398
+ {'name': 'Bold', 'title': 'Strong', 'css': 'wym_tools_strong'},
399
399
  {'name': 'Italic', 'title': 'Emphasis', 'css': 'wym_tools_emphasis'},
400
400
  {'name': 'Superscript', 'title': 'Superscript',
401
401
  'css': 'wym_tools_superscript'},
@@ -425,7 +425,7 @@ jQuery.fn.wymeditor = function(options) {
425
425
  + WYMeditor.CONTAINERS_ITEMS
426
426
  + "</ul>"
427
427
  + "</div>",
428
-
428
+
429
429
  containersItemHtml:"<li class='"
430
430
  + WYMeditor.CONTAINER_CLASS
431
431
  + "'>"
@@ -434,7 +434,7 @@ jQuery.fn.wymeditor = function(options) {
434
434
  + "'>"
435
435
  + WYMeditor.CONTAINER_TITLE
436
436
  + "</a></li>",
437
-
437
+
438
438
  containersItems: [
439
439
  {'name': 'P', 'title': 'Paragraph', 'css': 'wym_containers_p'},
440
440
  {'name': 'H1', 'title': 'Heading_1', 'css': 'wym_containers_h1'},
@@ -486,33 +486,33 @@ jQuery.fn.wymeditor = function(options) {
486
486
  classUnhiddenSelector: ".wym_classes",
487
487
  classHiddenSelector: ".wym_classes_hidden",
488
488
  htmlValSelector: ".wym_html_val",
489
-
489
+
490
490
  hrefSelector: ".wym_href",
491
491
  srcSelector: ".wym_src",
492
492
  titleSelector: ".wym_title",
493
493
  targetSelector: ".wym_target",
494
494
  altSelector: ".wym_alt",
495
495
  textSelector: ".wym_text",
496
-
496
+
497
497
  rowsSelector: ".wym_rows",
498
498
  colsSelector: ".wym_cols",
499
499
  captionSelector: ".wym_caption",
500
500
  summarySelector: ".wym_summary",
501
-
501
+
502
502
  submitSelector: ".wym_submit",
503
503
  cancelSelector: ".wym_cancel",
504
504
  previewSelector: "",
505
-
505
+
506
506
  dialogTypeSelector: ".wym_dialog_type",
507
507
  dialogLinkSelector: ".wym_dialog_link",
508
508
  dialogImageSelector: ".wym_dialog_image",
509
509
  dialogTableSelector: ".wym_dialog_table",
510
510
  dialogPasteSelector: ".wym_dialog_paste",
511
511
  dialogPreviewSelector: ".wym_dialog_preview",
512
-
512
+
513
513
  updateSelector: ".wymupdate",
514
514
  updateEvent: "click",
515
-
515
+
516
516
  dialogFeatures: "menubar=no,titlebar=no,toolbar=no,resizable=no"
517
517
  + ",width=560,height=300,top=0,left=0",
518
518
 
@@ -539,7 +539,7 @@ jQuery.fn.wymeditor = function(options) {
539
539
  + "</head>"
540
540
  + WYMeditor.DIALOG_BODY
541
541
  + "</html>",
542
-
542
+
543
543
  dialogLinkHtml: "<div class='wym_dialog wym_dialog_link'>"
544
544
  + "<form>"
545
545
  + "<fieldset>"
@@ -564,7 +564,7 @@ jQuery.fn.wymeditor = function(options) {
564
564
  + "</fieldset>"
565
565
  + "</form>"
566
566
  + "</div>",
567
-
567
+
568
568
  dialogImageHtml: "<div class='wym_dialog wym_dialog_image'>"
569
569
  + "<form>"
570
570
  + "<fieldset>"
@@ -593,7 +593,7 @@ jQuery.fn.wymeditor = function(options) {
593
593
  + "</fieldset>"
594
594
  + "</form>"
595
595
  + "</div>",
596
-
596
+
597
597
  dialogTableHtml: "<div class='wym_dialog wym_dialog_table'>"
598
598
  + "<form>"
599
599
  + "<input type='hidden' id='wym_dialog_type' class='wym_dialog_type' value='"
@@ -645,16 +645,16 @@ jQuery.fn.wymeditor = function(options) {
645
645
  + "</div>",
646
646
 
647
647
  dialogPreviewHtml: "<div class='wym_dialog wym_dialog_preview'></div>",
648
-
648
+
649
649
  dialogStyles: [],
650
650
 
651
651
  stringDelimiterLeft: "{",
652
652
  stringDelimiterRight:"}",
653
-
653
+
654
654
  preInit: null,
655
655
  preBind: null,
656
656
  postInit: null,
657
-
657
+
658
658
  preInitDialog: null,
659
659
  postInitDialog: null
660
660
 
@@ -688,6 +688,7 @@ WYMeditor.editor.prototype.init = function() {
688
688
 
689
689
  //load subclass - browser specific
690
690
  //unsupported browsers: do nothing
691
+
691
692
  if (jQuery.browser.msie) {
692
693
  var WymClass = new WYMeditor.WymClassExplorer(this);
693
694
  }
@@ -700,21 +701,21 @@ WYMeditor.editor.prototype.init = function() {
700
701
  else if (jQuery.browser.safari) {
701
702
  var WymClass = new WYMeditor.WymClassSafari(this);
702
703
  }
703
-
704
+
704
705
  if(WymClass) {
705
-
706
+
706
707
  if(jQuery.isFunction(this._options.preInit)) this._options.preInit(this);
707
708
 
708
709
  var SaxListener = new WYMeditor.XhtmlSaxListener();
709
710
  jQuery.extend(SaxListener, WymClass);
710
711
  this.parser = new WYMeditor.XhtmlParser(SaxListener);
711
-
712
+
712
713
  if(this._options.styles || this._options.stylesheet){
713
714
  this.configureEditorUsingRawCss();
714
715
  }
715
-
716
+
716
717
  this.helper = new WYMeditor.XmlHelper();
717
-
718
+
718
719
  //extend the Wymeditor object
719
720
  //don't use jQuery.extend since 1.1.4
720
721
  //jQuery.extend(this, WymClass);
@@ -727,17 +728,17 @@ WYMeditor.editor.prototype.init = function() {
727
728
  //but keep it compatible with jQuery < 1.2.3, see #122
728
729
  if( jQuery.isFunction( jQuery.fn.data ) )
729
730
  jQuery.data(this._box.get(0), WYMeditor.WYM_INDEX, this._index);
730
-
731
+
731
732
  var h = WYMeditor.Helper;
732
733
 
733
734
  //construct the iframe
734
735
  var iframeHtml = this._options.iframeHtml;
735
736
  iframeHtml = h.replaceAll(iframeHtml, WYMeditor.INDEX, this._index);
736
737
  iframeHtml = h.replaceAll(iframeHtml, WYMeditor.IFRAME_BASE_PATH, this._options.iframeBasePath);
737
-
738
+
738
739
  //construct wymbox
739
740
  var boxHtml = jQuery(this._box).html();
740
-
741
+
741
742
  boxHtml = h.replaceAll(boxHtml, WYMeditor.LOGO, this._options.logoHtml);
742
743
  boxHtml = h.replaceAll(boxHtml, WYMeditor.TOOLS, this._options.toolsHtml);
743
744
  boxHtml = h.replaceAll(boxHtml, WYMeditor.CONTAINERS,this._options.containersHtml);
@@ -745,7 +746,7 @@ WYMeditor.editor.prototype.init = function() {
745
746
  boxHtml = h.replaceAll(boxHtml, WYMeditor.HTML, this._options.htmlHtml);
746
747
  boxHtml = h.replaceAll(boxHtml, WYMeditor.IFRAME, iframeHtml);
747
748
  boxHtml = h.replaceAll(boxHtml, WYMeditor.STATUS, this._options.statusHtml);
748
-
749
+
749
750
  //construct tools list
750
751
  var aTools = eval(this._options.toolsItems);
751
752
  var sTools = "";
@@ -767,7 +768,7 @@ WYMeditor.editor.prototype.init = function() {
767
768
  //construct classes list
768
769
  var aClasses = eval(this._options.classesItems);
769
770
  var sClasses = "";
770
-
771
+
771
772
  for(var i = 0; i < aClasses.length; i++) {
772
773
  var oClass = aClasses[i];
773
774
  if(oClass.name) {
@@ -779,7 +780,7 @@ WYMeditor.editor.prototype.init = function() {
779
780
  sClass = h.replaceAll(sClass, WYMeditor.CLASS_TITLE, rule.title || titleize(rule));
780
781
  sRules += sClass;
781
782
  }.bind(this)); // need to bind 'this' or else it will think 'this' is the window.
782
-
783
+
783
784
  var sClassMultiple = this._options.classesItemHtmlMultiple;
784
785
  sClassMultiple = h.replaceAll(sClassMultiple, WYMeditor.CLASS_TITLE, oClass.title || titleize(oClass.name));
785
786
  sClassMultiple = h.replaceAll(sClassMultiple, '{classesItemHtml}', sRules);
@@ -795,7 +796,7 @@ WYMeditor.editor.prototype.init = function() {
795
796
  }
796
797
 
797
798
  boxHtml = h.replaceAll(boxHtml, WYMeditor.CLASSES_ITEMS, sClasses);
798
-
799
+
799
800
  //construct containers list
800
801
  var aContainers = eval(this._options.containersItems);
801
802
  var sContainers = "";
@@ -817,16 +818,16 @@ WYMeditor.editor.prototype.init = function() {
817
818
 
818
819
  //l10n
819
820
  boxHtml = this.replaceStrings(boxHtml);
820
-
821
+
821
822
  //load html in wymbox
822
823
  jQuery(this._box).html(boxHtml);
823
-
824
+
824
825
  //hide the html value
825
826
  jQuery(this._box).find(this._options.htmlSelector).hide();
826
-
827
+
827
828
  //enable the skin
828
829
  this.loadSkin();
829
-
830
+
830
831
  }
831
832
  };
832
833
 
@@ -834,19 +835,19 @@ WYMeditor.editor.prototype.bindEvents = function() {
834
835
 
835
836
  //copy the instance
836
837
  var wym = this;
837
-
838
+
838
839
  //handle click event on tools buttons
839
840
  jQuery(this._box).find(this._options.toolSelector).click(function() {
840
841
  wym.exec(jQuery(this).attr(WYMeditor.NAME));
841
842
  return(false);
842
843
  });
843
-
844
+
844
845
  //handle click event on containers buttons
845
846
  jQuery(this._box).find(this._options.containerSelector).click(function() {
846
847
  wym.container(jQuery(this).attr(WYMeditor.NAME));
847
848
  return(false);
848
849
  });
849
-
850
+
850
851
  //handle keyup event on html value: set the editor value
851
852
  jQuery(this._box).find(this._options.htmlValSelector).keyup(function() {
852
853
  jQuery(wym._doc.body).html(jQuery(this).val());
@@ -869,29 +870,29 @@ WYMeditor.editor.prototype.bindEvents = function() {
869
870
  replacers.push(classRule.name + (classRule.join || "") + classRule.rules[i]);
870
871
  }
871
872
  }
872
-
873
+
873
874
  oClass = {expr: (classRule.rules[indexOf].expr || null)}
874
875
  }
875
876
  }
876
877
  }.bind(this));
877
878
  }
878
-
879
+
879
880
  if(oClass) {
880
881
  var jqexpr = oClass.expr;
881
882
  // remove all related classes.
882
883
  replacers.each(function(removable_class){
883
884
  wym.removeClass(removable_class, jqexpr);
884
885
  });
885
-
886
+
886
887
  wym.toggleClass(sName, jqexpr);
887
888
  }
888
-
889
+
889
890
  // now hide the menu
890
891
  wym.exec(WYMeditor.APPLY_CLASS);
891
-
892
+
892
893
  return(false);
893
894
  });
894
-
895
+
895
896
  //handle event on update element
896
897
  jQuery(this._options.updateSelector).bind(this._options.updateEvent, function() {
897
898
  wym.update();
@@ -932,7 +933,7 @@ WYMeditor.editor.prototype.xhtml = function() {
932
933
  * @description Executes a button command
933
934
  */
934
935
  WYMeditor.editor.prototype.exec = function(cmd) {
935
-
936
+
936
937
  //base function for execCommand
937
938
  //open a dialog or exec
938
939
  switch(cmd) {
@@ -940,19 +941,19 @@ WYMeditor.editor.prototype.exec = function(cmd) {
940
941
  var container = this.container();
941
942
  if(container || this._selected_image) this.dialog(WYMeditor.DIALOG_LINK);
942
943
  break;
943
-
944
+
944
945
  case WYMeditor.INSERT_IMAGE:
945
946
  this.dialog(WYMeditor.DIALOG_IMAGE);
946
947
  break;
947
-
948
+
948
949
  case WYMeditor.INSERT_TABLE:
949
950
  this.dialog(WYMeditor.DIALOG_TABLE);
950
951
  break;
951
-
952
+
952
953
  case WYMeditor.PASTE:
953
954
  this.dialog(WYMeditor.DIALOG_PASTE);
954
955
  break;
955
-
956
+
956
957
  case WYMeditor.TOGGLE_HTML:
957
958
  this.update();
958
959
  this.toggleHtml();
@@ -961,17 +962,17 @@ WYMeditor.editor.prototype.exec = function(cmd) {
961
962
  if(!jQuery(this._box).find(this._options.htmlSelector).is(':visible'))
962
963
  this.listen();
963
964
  break;
964
-
965
+
965
966
  case WYMeditor.PREVIEW:
966
967
  this.dialog(WYMeditor.PREVIEW);
967
968
  break;
968
-
969
+
969
970
  case WYMeditor.APPLY_CLASS:
970
971
  jQuery(this._box).find(this._options.classUnhiddenSelector).toggleClass(this._options.classHiddenSelector.substring(1)); // substring(1) to remove the . at the start
971
972
  jQuery(this._box).find("a[name=" + WYMeditor.APPLY_CLASS +"]").toggleClass('selected');
972
973
  //this.dialog(WYMeditor.DIALOG_CLASS);
973
974
  break;
974
-
975
+
975
976
  default:
976
977
  this._exec(cmd);
977
978
  break;
@@ -984,16 +985,16 @@ WYMeditor.editor.prototype.exec = function(cmd) {
984
985
  WYMeditor.editor.prototype.container = function(sType) {
985
986
 
986
987
  if(sType) {
987
-
988
+
988
989
  var container = null;
989
-
990
+
990
991
  if(sType.toLowerCase() == WYMeditor.TH) {
991
-
992
+
992
993
  container = this.container();
993
-
994
+
994
995
  //find the TD or TH container
995
996
  switch(container.tagName.toLowerCase()) {
996
-
997
+
997
998
  case WYMeditor.TD: case WYMeditor.TH:
998
999
  break;
999
1000
  default:
@@ -1001,44 +1002,44 @@ WYMeditor.editor.prototype.container = function(sType) {
1001
1002
  container = this.findUp(this.container(), aTypes);
1002
1003
  break;
1003
1004
  }
1004
-
1005
+
1005
1006
  //if it exists, switch
1006
1007
  if(container!=null) {
1007
-
1008
+
1008
1009
  sType = (container.tagName.toLowerCase() == WYMeditor.TD)? WYMeditor.TH: WYMeditor.TD;
1009
1010
  this.switchTo(container,sType);
1010
1011
  this.update();
1011
1012
  }
1012
1013
  } else {
1013
-
1014
+
1014
1015
  //set the container type
1015
1016
  var aTypes=new Array(WYMeditor.P,WYMeditor.H1,WYMeditor.H2,WYMeditor.H3,WYMeditor.H4,WYMeditor.H5,
1016
1017
  WYMeditor.H6,WYMeditor.PRE,WYMeditor.BLOCKQUOTE);
1017
1018
 
1018
1019
  container = this.findUp(this.container(), aTypes);
1019
-
1020
+
1020
1021
  if(container) {
1021
-
1022
+
1022
1023
  var newNode = null;
1023
-
1024
+
1024
1025
  //blockquotes must contain a block level element
1025
1026
  if(sType.toLowerCase() == WYMeditor.BLOCKQUOTE) {
1026
-
1027
+
1027
1028
  var blockquote = this.findUp(this.container(), WYMeditor.BLOCKQUOTE);
1028
-
1029
+
1029
1030
  if(blockquote == null) {
1030
-
1031
+
1031
1032
  newNode = this._doc.createElement(sType);
1032
1033
  container.parentNode.insertBefore(newNode,container);
1033
1034
  newNode.appendChild(container);
1034
1035
  this.setFocusToNode(newNode.firstChild);
1035
-
1036
+
1036
1037
  } else {
1037
-
1038
+
1038
1039
  var nodes = blockquote.childNodes;
1039
1040
  var lgt = nodes.length;
1040
1041
  var firstNode = null;
1041
-
1042
+
1042
1043
  if(lgt > 0) firstNode = nodes.item(0);
1043
1044
  for(var x=0; x<lgt; x++) {
1044
1045
  blockquote.parentNode.insertBefore(nodes.item(0),blockquote);
@@ -1047,9 +1048,9 @@ WYMeditor.editor.prototype.container = function(sType) {
1047
1048
  if(firstNode) this.setFocusToNode(firstNode);
1048
1049
  }
1049
1050
  }
1050
-
1051
+
1051
1052
  else this.switchTo(container,sType);
1052
-
1053
+
1053
1054
  this.update();
1054
1055
  }
1055
1056
  }
@@ -1061,7 +1062,7 @@ WYMeditor.editor.prototype.container = function(sType) {
1061
1062
  * @description Toggles class on selected element, or one of its parents
1062
1063
  */
1063
1064
  WYMeditor.editor.prototype.toggleClass = function(sClass, jqexpr) {
1064
-
1065
+
1065
1066
  var container = jQuery((this._selected_image ? this._selected_image : this.selected(true)));
1066
1067
  if (jqexpr != null) { container = jQuery(container.parentsOrSelf(jqexpr)); }
1067
1068
  container.toggleClass(sClass);
@@ -1073,13 +1074,13 @@ WYMeditor.editor.prototype.toggleClass = function(sClass, jqexpr) {
1073
1074
  * @description Removes class on selected element, or one of its parents
1074
1075
  */
1075
1076
  WYMeditor.editor.prototype.removeClass = function(sClass, jqexpr) {
1076
-
1077
+
1077
1078
  var container = jQuery((this._selected_image ? this._selected_image : jQuery(this.selected(true))));
1078
1079
  if (jqexpr != null) { container = jQuery(container.parentsOrSelf(jqexpr)); }
1079
1080
  container.removeClass(sClass);
1080
1081
 
1081
1082
  if(!container.attr(WYMeditor.CLASS)) container.removeAttr(this._class);
1082
-
1083
+
1083
1084
  }
1084
1085
 
1085
1086
  /* @name findUp
@@ -1092,19 +1093,19 @@ WYMeditor.editor.prototype.findUp = function(node, filter) {
1092
1093
  if(node) {
1093
1094
 
1094
1095
  var tagname = node.tagName.toLowerCase();
1095
-
1096
+
1096
1097
  if(typeof(filter) == WYMeditor.STRING) {
1097
-
1098
+
1098
1099
  while(tagname != filter && tagname != WYMeditor.BODY) {
1099
-
1100
+
1100
1101
  node = node.parentNode;
1101
1102
  tagname = node.tagName.toLowerCase();
1102
1103
  }
1103
-
1104
+
1104
1105
  } else {
1105
-
1106
+
1106
1107
  var bFound = false;
1107
-
1108
+
1108
1109
  while(!bFound && tagname != WYMeditor.BODY) {
1109
1110
  for(var i = 0; i < filter.length; i++) {
1110
1111
  if(tagname == filter[i]) {
@@ -1118,10 +1119,10 @@ WYMeditor.editor.prototype.findUp = function(node, filter) {
1118
1119
  }
1119
1120
  }
1120
1121
  }
1121
-
1122
+
1122
1123
  if(tagname != WYMeditor.BODY) return(node);
1123
1124
  else return(null);
1124
-
1125
+
1125
1126
  } else return(null);
1126
1127
  };
1127
1128
 
@@ -1133,17 +1134,17 @@ WYMeditor.editor.prototype.switchTo = function(selectionOrNode,sType) {
1133
1134
  if (selectionOrNode.getRangeAt) {
1134
1135
  // We have a selection object so we need to create a temporary node around it (bold is easy). This node will be replaced anyway.
1135
1136
  this.exec(WYMeditor.BOLD);
1136
- selectionOrNode = selectionOrNode.focusNode.parentNode;
1137
+ selectionOrNode = selectionOrNode.focusNode.parentNode;
1137
1138
  }
1138
-
1139
+
1139
1140
  // we have a node.
1140
1141
  var html = jQuery(selectionOrNode).html();
1141
1142
  var newNode = this._doc.createElement(sType);
1142
1143
  selectionOrNode.parentNode.replaceChild(newNode,selectionOrNode);
1143
-
1144
+
1144
1145
  jQuery(newNode).html(html);
1145
1146
  this.setFocusToNode(newNode);
1146
-
1147
+
1147
1148
  return newNode;
1148
1149
  };
1149
1150
 
@@ -1164,7 +1165,7 @@ WYMeditor.editor.prototype.replaceStrings = function(sVal) {
1164
1165
 
1165
1166
  //replace all the strings in sVal and return it
1166
1167
  for (var key in WYMeditor.STRINGS[this._options.lang]) {
1167
- sVal = WYMeditor.Helper.replaceAll(sVal, this._options.stringDelimiterLeft + key
1168
+ sVal = WYMeditor.Helper.replaceAll(sVal, this._options.stringDelimiterLeft + key
1168
1169
  + this._options.stringDelimiterRight,
1169
1170
  WYMeditor.STRINGS[this._options.lang][key]);
1170
1171
  };
@@ -1207,7 +1208,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1207
1208
  // change undo or redo on cancel to true to have this happen when a user closes (cancels) a dialogue
1208
1209
  this._undo_on_cancel = false;
1209
1210
  this._redo_on_cancel = false;
1210
-
1211
+
1211
1212
  //set to P if parent = BODY
1212
1213
  if (![WYMeditor.DIALOG_TABLE, WYMeditor.DIALOG_PASTE].include(dialogType))
1213
1214
  {
@@ -1220,7 +1221,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1220
1221
  // somehow select the wymeditor textarea or simulate a click or a keydown on it.
1221
1222
  }
1222
1223
  }
1223
-
1224
+
1224
1225
  selected = this.selected();
1225
1226
  if (dialogType == WYMeditor.DIALOG_LINK && jQuery.browser.mozilla) {
1226
1227
  selection = this._iframe.contentWindow.getSelection();
@@ -1240,7 +1241,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1240
1241
  // set up handlers.
1241
1242
  imageGroup = null;
1242
1243
  ajax_loaded_callback = function(){this.dialog_ajax_callback(selected)}.bind(this, selected);
1243
-
1244
+
1244
1245
  var parent_node = null;
1245
1246
  if (this._selected_image) {
1246
1247
  parent_node = this._selected_image.parentNode;
@@ -1262,7 +1263,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1262
1263
  parent_node._id_before_replaceable = parent.id;
1263
1264
  parent_node.id = 'replace_me_with_' + this._current_unique_stamp;
1264
1265
  }
1265
-
1266
+
1266
1267
  path += (this._wym._options.dialogFeatures.length == 0) ? "?" : "&"
1267
1268
  port = (window.location.port.length > 0 ? (":" + window.location.port) : "")
1268
1269
  path += "current_link=" + parent_node.href.gsub(window.location.protocol + "//" + window.location.hostname + port, "");
@@ -1303,7 +1304,7 @@ WYMeditor.editor.prototype.dialog = function( dialogType ) {
1303
1304
  };
1304
1305
 
1305
1306
  WYMeditor.editor.prototype.dialog_ajax_callback = function(selected) {
1306
-
1307
+
1307
1308
  // look for iframes
1308
1309
  if ((iframes = $(this._options.dialogId).select('iframe')).length > 0 && (iframe = $(iframes[0])) != null)
1309
1310
  {
@@ -1334,7 +1335,7 @@ WYMeditor.editor.prototype.paste = function(sData) {
1334
1335
  console.log('pasting..');
1335
1336
  var sTmp;
1336
1337
  var container = this.selected();
1337
-
1338
+
1338
1339
  //split the data, using double newlines as the separator
1339
1340
  var aP = sData.split(this._newLine + this._newLine);
1340
1341
  var rExp = new RegExp(this._newLine, "g");
@@ -1354,7 +1355,7 @@ console.log('pasting..');
1354
1355
  sTmp = sTmp.replace(rExp, "<br />");
1355
1356
  jQuery(this._doc.body).append("<p>" + sTmp + "</p>");
1356
1357
  }
1357
-
1358
+
1358
1359
  }
1359
1360
  };
1360
1361
 
@@ -1452,7 +1453,7 @@ WYMeditor.editor.prototype.listen = function() {
1452
1453
  //don't use jQuery.find() on the iframe body
1453
1454
  //because of MSIE + jQuery + expando issue (#JQ1143)
1454
1455
  //jQuery(this._doc.body).find("*").bind("mouseup", this.mouseup);
1455
-
1456
+
1456
1457
  jQuery(this._doc.body).bind("mousedown", this.mousedown);
1457
1458
  var images = this._doc.body.getElementsByTagName("img");
1458
1459
  for(var i=0; i < images.length; i++) {
@@ -1461,7 +1462,7 @@ WYMeditor.editor.prototype.listen = function() {
1461
1462
  };
1462
1463
 
1463
1464
  WYMeditor.editor.prototype.mousedown = function(evt) {
1464
-
1465
+
1465
1466
  var wym = WYMeditor.INSTANCES[this.ownerDocument.title];
1466
1467
  wym._selected_image = (this.tagName.toLowerCase() == WYMeditor.IMG) ? this : null;
1467
1468
  evt.stopPropagation();
@@ -1477,7 +1478,7 @@ WYMeditor.editor.prototype.mousedown = function(evt) {
1477
1478
  * href - The CSS path.
1478
1479
  */
1479
1480
  WYMeditor.loadCss = function(href) {
1480
-
1481
+
1481
1482
  var link = document.createElement('link');
1482
1483
  link.rel = 'stylesheet';
1483
1484
  link.href = href;
@@ -1547,7 +1548,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1547
1548
  button.observe('click', function(e){this.close_dialog(e, true)}.bind(wym));
1548
1549
  });
1549
1550
  /*
1550
- switch(dialogType) {
1551
+ switch(dialogType) {
1551
1552
  case WYMeditor.DIALOG_LINK:
1552
1553
  //ensure that we select the link to populate the fields
1553
1554
  if (replaceable[0] != null && replaceable[0].tagName.toLowerCase() == WYMeditor.A)
@@ -1585,10 +1586,10 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1585
1586
  .val(jQuery(wym._selected_image).attr(WYMeditor.ALT));
1586
1587
  }
1587
1588
 
1588
- jQuery(wym._options.dialogLinkSelector + " " + wym._options.submitSelector).click(function()
1589
+ jQuery(wym._options.dialogLinkSelector + " " + wym._options.submitSelector).click(function()
1589
1590
  {
1590
1591
  var sUrl = jQuery(wym._options.hrefSelector).val();
1591
- if(sUrl.length > 0)
1592
+ if(sUrl.length > 0)
1592
1593
  {
1593
1594
  if (replaceable[0] != null) {
1594
1595
  link = wym._doc.createElement("a");
@@ -1625,7 +1626,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1625
1626
  jQuery("a[href=" + wym._current_unique_stamp + "]", wym._doc.body)
1626
1627
  .attr(WYMeditor.HREF, sUrl)
1627
1628
  .attr(WYMeditor.TITLE, jQuery(wym._options.titleSelector).val())
1628
- .attr(WYMeditor.TARGET, jQuery(wym._options.targetSelector).val());
1629
+ .attr(WYMeditor.TARGET, jQuery(wym._options.targetSelector).val());
1629
1630
  }
1630
1631
  }
1631
1632
  // fire a click event on the dialogs close button
@@ -1643,20 +1644,20 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1643
1644
  //var image = jQuery(wym._doc.body).find("img[@src=" + sStamp + "]");
1644
1645
  var image = null;
1645
1646
  var nodes = wym._doc.body.getElementsByTagName(WYMeditor.IMG);
1646
- for(var i=0; i < nodes.length; i++)
1647
+ for(var i=0; i < nodes.length; i++)
1647
1648
  {
1648
- if(jQuery(nodes[i]).attr(WYMeditor.SRC) == wym._current_unique_stamp)
1649
+ if(jQuery(nodes[i]).attr(WYMeditor.SRC) == wym._current_unique_stamp)
1649
1650
  {
1650
1651
  image = jQuery(nodes[i]);
1651
1652
  break;
1652
1653
  }
1653
1654
  }
1654
-
1655
+
1655
1656
  if(image) {
1656
1657
  image.attr(WYMeditor.SRC, sUrl);
1657
1658
  image.attr(WYMeditor.TITLE, sTitle);
1658
1659
  image.attr(WYMeditor.ALT, sAlt);
1659
-
1660
+
1660
1661
  if (!jQuery.browser.safari)
1661
1662
  {
1662
1663
  if (replaceable != null)
@@ -1669,7 +1670,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1669
1670
  }
1670
1671
  }
1671
1672
  }
1672
-
1673
+
1673
1674
  // fire a click event on the dialogs close button
1674
1675
  wym.close_dialog();
1675
1676
  }
@@ -1680,7 +1681,7 @@ WYMeditor.INIT_DIALOG = function(wym, selected, isIframe) {
1680
1681
  var iRows = jQuery(wym._options.rowsSelector).val();
1681
1682
  var iCols = jQuery(wym._options.colsSelector).val();
1682
1683
 
1683
- if(iRows > 0 && iCols > 0)
1684
+ if(iRows > 0 && iCols > 0)
1684
1685
  {
1685
1686
  var table = wym._doc.createElement(WYMeditor.TABLE);
1686
1687
  var newRow = null;
@@ -1738,7 +1739,7 @@ WYMeditor.editor.prototype.close_dialog = function(e, cancelled) {
1738
1739
  replaceable[0].id = replaceable[0]._id_before_replaceable;
1739
1740
  }
1740
1741
  }
1741
-
1742
+
1742
1743
  if (this._undo_on_cancel == true) {
1743
1744
  this._exec("undo");
1744
1745
  }
@@ -1746,19 +1747,19 @@ WYMeditor.editor.prototype.close_dialog = function(e, cancelled) {
1746
1747
  this._exec("redo");
1747
1748
  }
1748
1749
  }
1749
-
1750
+
1750
1751
  if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 8)
1751
1752
  {
1752
1753
  this._iframe.contentWindow.focus();
1753
1754
  }
1754
-
1755
+
1755
1756
  if ((inline_dialog_container = $('inline_dialog_container')) != null)
1756
1757
  {
1757
1758
  inline_dialog_container.remove();
1758
1759
  }
1759
-
1760
+
1760
1761
  tb_remove();
1761
-
1762
+
1762
1763
  if (e) {
1763
1764
  e.stop();
1764
1765
  }
@@ -4048,6 +4049,14 @@ WYMeditor.Helper = {
4048
4049
  }
4049
4050
  };
4050
4051
 
4052
+ function titleize(words) {
4053
+ parts = [];
4054
+ words.gsub(/\./, '').gsub(/[-_]/, ' ').split(' ').each(function(part){
4055
+ parts.push(part[0].toUpperCase() + part.substring(1));
4056
+ });
4057
+
4058
+ return parts.join(" ");
4059
+ }
4051
4060
 
4052
4061
  /*
4053
4062
  * WYMeditor : what you see is What You Mean web-based editor
@@ -4082,10 +4091,10 @@ WYMeditor.WymClassExplorer.prototype.initIframe = function(iframe) {
4082
4091
  //This function is executed twice, though it is called once!
4083
4092
  //But MSIE needs that, otherwise designMode won't work.
4084
4093
  //Weird.
4085
-
4094
+
4086
4095
  this._iframe = iframe;
4087
4096
  this._doc = iframe.contentWindow.document;
4088
-
4097
+
4089
4098
  //add css rules from options
4090
4099
  var styles = this._doc.styleSheets[0];
4091
4100
  var aCss = eval(this._options.editorStyles);
@@ -4096,13 +4105,13 @@ WYMeditor.WymClassExplorer.prototype.initIframe = function(iframe) {
4096
4105
 
4097
4106
  //set the text direction
4098
4107
  jQuery('html', this._doc).attr('dir', this._options.direction);
4099
-
4108
+
4100
4109
  //init html value
4101
4110
  jQuery(this._doc.body).html(this._wym._html);
4102
-
4111
+
4103
4112
  //handle events
4104
4113
  var wym = this;
4105
-
4114
+
4106
4115
  this._doc.body.onfocus = function()
4107
4116
  {wym._doc.designMode = "on"; wym._doc = iframe.contentWindow.document;};
4108
4117
  this._doc.onbeforedeactivate = function() {wym.saveCaret();};
@@ -4111,49 +4120,49 @@ WYMeditor.WymClassExplorer.prototype.initIframe = function(iframe) {
4111
4120
  wym.keyup();
4112
4121
  };
4113
4122
  this._doc.onclick = function() {wym.saveCaret();};
4114
-
4123
+
4115
4124
  this._doc.body.onbeforepaste = function() {
4116
4125
  wym._iframe.contentWindow.event.returnValue = false;
4117
4126
  };
4118
-
4127
+
4119
4128
  this._doc.body.onpaste = function() {
4120
4129
  wym._iframe.contentWindow.event.returnValue = false;
4121
4130
  wym.paste(window.clipboardData.getData("Text"));
4122
4131
  };
4123
-
4132
+
4124
4133
  //callback can't be executed twice, so we check
4125
4134
  if(this._initialized) {
4126
-
4135
+
4127
4136
  //pre-bind functions
4128
4137
  if(jQuery.isFunction(this._options.preBind)) this._options.preBind(this);
4129
-
4138
+
4130
4139
  //bind external events
4131
4140
  this._wym.bindEvents();
4132
-
4141
+
4133
4142
  //post-init functions
4134
4143
  if(jQuery.isFunction(this._options.postInit)) this._options.postInit(this);
4135
-
4144
+
4136
4145
  //add event listeners to doc elements, e.g. images
4137
4146
  this.listen();
4138
4147
  }
4139
-
4148
+
4140
4149
  this._initialized = true;
4141
-
4150
+
4142
4151
  //init designMode
4143
4152
  this._doc.designMode="on";
4144
4153
  try{
4145
4154
  // (bermi's note) noticed when running unit tests on IE6
4146
4155
  // Is this really needed, it trigger an unexisting property on IE6
4147
- this._doc = iframe.contentWindow.document;
4156
+ this._doc = iframe.contentWindow.document;
4148
4157
  }catch(e){}
4149
4158
  };
4150
4159
 
4151
4160
  WYMeditor.WymClassExplorer.prototype._exec = function(cmd,param) {
4152
4161
 
4153
4162
  switch(cmd) {
4154
-
4163
+
4155
4164
  case WYMeditor.INDENT: case WYMeditor.OUTDENT:
4156
-
4165
+
4157
4166
  var container = this.findUp(this.container(), WYMeditor.LI);
4158
4167
  if(container)
4159
4168
  this._doc.execCommand(cmd);
@@ -4163,7 +4172,7 @@ WYMeditor.WymClassExplorer.prototype._exec = function(cmd,param) {
4163
4172
  else this._doc.execCommand(cmd);
4164
4173
  break;
4165
4174
  }
4166
-
4175
+
4167
4176
  this.listen();
4168
4177
  };
4169
4178
 
@@ -4282,43 +4291,46 @@ WYMeditor.WymClassMozilla.prototype.initIframe = function(iframe) {
4282
4291
 
4283
4292
  this._iframe = iframe;
4284
4293
  this._doc = iframe.contentDocument;
4285
-
4294
+
4286
4295
  //add css rules from options
4287
-
4288
- var styles = this._doc.styleSheets[0];
4296
+
4297
+ var styles = this._doc.styleSheets[0];
4289
4298
  var aCss = eval(this._options.editorStyles);
4290
-
4299
+
4291
4300
  this.addCssRules(this._doc, aCss);
4292
4301
 
4293
4302
  this._doc.title = this._wym._index;
4294
4303
 
4295
4304
  //set the text direction
4296
4305
  jQuery('html', this._doc).attr('dir', this._options.direction);
4297
-
4306
+
4298
4307
  //init html value
4299
4308
  this.html(this._wym._html);
4300
-
4309
+
4301
4310
  //init designMode
4302
4311
  this.enableDesignMode();
4303
-
4312
+
4304
4313
  //pre-bind functions
4305
4314
  if(jQuery.isFunction(this._options.preBind)) this._options.preBind(this);
4306
-
4315
+
4307
4316
  //bind external events
4308
4317
  this._wym.bindEvents();
4309
-
4318
+
4310
4319
  //bind editor keydown events
4311
4320
  jQuery(this._doc).bind("keydown", this.keydown);
4312
-
4321
+
4313
4322
  //bind editor keyup events
4314
4323
  jQuery(this._doc).bind("keyup", this.keyup);
4315
-
4324
+
4325
+ //bind editor paste events
4326
+ jQuery(this._doc).bind("paste", this.paste);
4327
+
4316
4328
  //bind editor focus events (used to reset designmode - Gecko bug)
4317
4329
  jQuery(this._doc).bind("focus", this.enableDesignMode);
4318
-
4330
+
4319
4331
  //post-init functions
4320
4332
  if(jQuery.isFunction(this._options.postInit)) this._options.postInit(this);
4321
-
4333
+
4322
4334
  //add event listeners to doc elements, e.g. images
4323
4335
  this.listen();
4324
4336
  };
@@ -4329,20 +4341,20 @@ WYMeditor.WymClassMozilla.prototype.initIframe = function(iframe) {
4329
4341
  WYMeditor.WymClassMozilla.prototype.html = function(html) {
4330
4342
 
4331
4343
  if(typeof html === 'string') {
4332
-
4344
+
4333
4345
  //disable designMode
4334
4346
  try { this._doc.designMode = "off"; } catch(e) { };
4335
-
4347
+
4336
4348
  //replace em by i and strong by bold
4337
4349
  //(designMode issue)
4338
4350
  html = html.replace(/<em(\b[^>]*)>/gi, "<i$1>")
4339
4351
  .replace(/<\/em>/gi, "</i>")
4340
4352
  .replace(/<strong(\b[^>]*)>/gi, "<b$1>")
4341
4353
  .replace(/<\/strong>/gi, "</b>");
4342
-
4354
+
4343
4355
  //update the html body
4344
4356
  jQuery(this._doc.body).html(html);
4345
-
4357
+
4346
4358
  //re-init designMode
4347
4359
  this.enableDesignMode();
4348
4360
  }
@@ -4354,9 +4366,9 @@ WYMeditor.WymClassMozilla.prototype._exec = function(cmd,param) {
4354
4366
  if(!this.selected()) return(false);
4355
4367
 
4356
4368
  switch(cmd) {
4357
-
4369
+
4358
4370
  case WYMeditor.INDENT: case WYMeditor.OUTDENT:
4359
- var focusNode = this.selected();
4371
+ var focusNode = this.selected();
4360
4372
  var sel = this._iframe.contentWindow.getSelection();
4361
4373
  var anchorNode = sel.anchorNode;
4362
4374
  if(anchorNode.nodeName == "#text") anchorNode = anchorNode.parentNode;
@@ -4373,17 +4385,17 @@ WYMeditor.WymClassMozilla.prototype._exec = function(cmd,param) {
4373
4385
  this._doc.execCommand(cmd,'',null);
4374
4386
  }
4375
4387
  break;
4376
-
4388
+
4377
4389
  default:
4378
4390
  if(param) this._doc.execCommand(cmd,'',param);
4379
4391
  else this._doc.execCommand(cmd,'',null);
4380
4392
  }
4381
-
4393
+
4382
4394
  //set to P if parent = BODY
4383
4395
  var container = this.selected();
4384
4396
  if(container.tagName.toLowerCase() == WYMeditor.BODY)
4385
4397
  this._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P);
4386
-
4398
+
4387
4399
  //add event handlers on doc elements
4388
4400
 
4389
4401
  this.listen();
@@ -4395,7 +4407,7 @@ WYMeditor.WymClassMozilla.prototype._exec = function(cmd,param) {
4395
4407
  * @description Returns the selected container
4396
4408
  */
4397
4409
  WYMeditor.WymClassMozilla.prototype.selected = function(upgrade_text_nodes) {
4398
-
4410
+
4399
4411
  if (upgrade_text_nodes == null || upgrade_text_nodes.toString() != "true") { upgrade_text_nodes = false; }
4400
4412
  var sel = this._iframe.contentWindow.getSelection();
4401
4413
  var node = sel.focusNode;
@@ -4424,7 +4436,7 @@ WYMeditor.WymClassMozilla.prototype.selected = function(upgrade_text_nodes) {
4424
4436
  }
4425
4437
  }
4426
4438
  else return(node);
4427
- }
4439
+ }
4428
4440
  else return(null);
4429
4441
  };
4430
4442
 
@@ -4435,10 +4447,10 @@ WYMeditor.WymClassMozilla.prototype.addCssRule = function(styles, oCss) {
4435
4447
 
4436
4448
  //keydown handler, mainly used for keyboard shortcuts
4437
4449
  WYMeditor.WymClassMozilla.prototype.keydown = function(evt) {
4438
-
4450
+
4439
4451
  //'this' is the doc
4440
4452
  var wym = WYMeditor.INSTANCES[this.title];
4441
-
4453
+
4442
4454
  if(evt.ctrlKey){
4443
4455
  if(evt.keyCode == 66){
4444
4456
  //CTRL+b => STRONG
@@ -4458,22 +4470,22 @@ WYMeditor.WymClassMozilla.prototype.keyup = function(evt) {
4458
4470
 
4459
4471
  //'this' is the doc
4460
4472
  var wym = WYMeditor.INSTANCES[this.title];
4461
-
4473
+
4462
4474
  wym._selected_image = null;
4463
4475
  var container = null;
4464
4476
 
4465
4477
  if(evt.keyCode == 13 && !evt.shiftKey) {
4466
-
4478
+
4467
4479
  //RETURN key
4468
4480
  //cleanup <br><br> between paragraphs
4469
4481
  jQuery(wym._doc.body).children(WYMeditor.BR).remove();
4470
-
4482
+
4471
4483
  //fix PRE bug #73
4472
4484
  container = wym.selected();
4473
4485
  if(container && container.tagName.toLowerCase() == WYMeditor.PRE)
4474
4486
  wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P); //create P after PRE
4475
4487
  }
4476
-
4488
+
4477
4489
  else if(evt.keyCode != 8
4478
4490
  && evt.keyCode != 17
4479
4491
  && evt.keyCode != 46
@@ -4482,26 +4494,47 @@ WYMeditor.WymClassMozilla.prototype.keyup = function(evt) {
4482
4494
  && !evt.ctrlKey) {
4483
4495
  //NOT BACKSPACE, NOT DELETE, NOT CTRL, NOT COMMAND
4484
4496
  //text nodes replaced by P
4485
-
4486
- container = wym.selected();
4487
- var name = container.tagName.toLowerCase();
4488
4497
 
4489
- //fix forbidden main containers
4490
- if(
4491
- name == "strong" ||
4492
- name == "b" ||
4493
- name == "em" ||
4494
- name == "i" ||
4495
- name == "sub" ||
4496
- name == "sup" ||
4497
- name == "a"
4498
+ wym.format_block();
4499
+ }
4500
+ };
4498
4501
 
4499
- ) name = container.parentNode.tagName.toLowerCase();
4502
+ WYMeditor.WymClassMozilla.prototype.paste = function(evt) {
4503
+
4504
+ var wym = WYMeditor.INSTANCES[this.title];
4505
+
4506
+ wym.format_block();
4500
4507
 
4501
- if(name == WYMeditor.BODY) wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P);
4502
- }
4503
4508
  };
4504
4509
 
4510
+ WYMeditor.WymClassMozilla.prototype.format_block = function(selected) {
4511
+
4512
+ //'this' should be the wymeditor instance.
4513
+ var wym = this;
4514
+
4515
+ selected = selected || wym.selected();
4516
+
4517
+ wym._selected_image = null;
4518
+ var container = null;
4519
+
4520
+ container = wym.selected();
4521
+ var name = container.tagName.toLowerCase();
4522
+
4523
+ //fix forbidden main containers
4524
+ if(
4525
+ name == "strong" ||
4526
+ name == "b" ||
4527
+ name == "em" ||
4528
+ name == "i" ||
4529
+ name == "sub" ||
4530
+ name == "sup" ||
4531
+ name == "a"
4532
+
4533
+ ) name = container.parentNode.tagName.toLowerCase();
4534
+
4535
+ if(name == WYMeditor.BODY) wym._exec(WYMeditor.FORMAT_BLOCK, WYMeditor.P);
4536
+ }
4537
+
4505
4538
  WYMeditor.WymClassMozilla.prototype.enableDesignMode = function() {
4506
4539
  if(this.designMode == "off") {
4507
4540
  try {
@@ -4536,7 +4569,7 @@ WYMeditor.WymClassMozilla.prototype.openBlockTag = function(tag, attributes)
4536
4569
  return;
4537
4570
  }
4538
4571
  }
4539
-
4572
+
4540
4573
  this.output += this.helper.tag(tag, attributes, true);
4541
4574
  };
4542
4575
 
@@ -4578,9 +4611,9 @@ WYMeditor.WymClassOpera.prototype.initIframe = function(iframe) {
4578
4611
 
4579
4612
  this._iframe = iframe;
4580
4613
  this._doc = iframe.contentWindow.document;
4581
-
4614
+
4582
4615
  //add css rules from options
4583
- var styles = this._doc.styleSheets[0];
4616
+ var styles = this._doc.styleSheets[0];
4584
4617
  var aCss = eval(this._options.editorStyles);
4585
4618
 
4586
4619
  this.addCssRules(this._doc, aCss);
@@ -4589,28 +4622,28 @@ WYMeditor.WymClassOpera.prototype.initIframe = function(iframe) {
4589
4622
 
4590
4623
  //set the text direction
4591
4624
  jQuery('html', this._doc).attr('dir', this._options.direction);
4592
-
4625
+
4593
4626
  //init designMode
4594
4627
  this._doc.designMode = "on";
4595
4628
 
4596
4629
  //init html value
4597
4630
  this.html(this._wym._html);
4598
-
4631
+
4599
4632
  //pre-bind functions
4600
4633
  if(jQuery.isFunction(this._options.preBind)) this._options.preBind(this);
4601
-
4634
+
4602
4635
  //bind external events
4603
4636
  this._wym.bindEvents();
4604
-
4637
+
4605
4638
  //bind editor keydown events
4606
4639
  jQuery(this._doc).bind("keydown", this.keydown);
4607
-
4640
+
4608
4641
  //bind editor events
4609
4642
  jQuery(this._doc).bind("keyup", this.keyup);
4610
-
4643
+
4611
4644
  //post-init functions
4612
4645
  if(jQuery.isFunction(this._options.postInit)) this._options.postInit(this);
4613
-
4646
+
4614
4647
  //add event listeners to doc elements, e.g. images
4615
4648
  this.listen();
4616
4649
  };
@@ -4619,7 +4652,7 @@ WYMeditor.WymClassOpera.prototype._exec = function(cmd,param) {
4619
4652
 
4620
4653
  if(param) this._doc.execCommand(cmd,false,param);
4621
4654
  else this._doc.execCommand(cmd);
4622
-
4655
+
4623
4656
  this.listen();
4624
4657
  };
4625
4658
 
@@ -4641,7 +4674,7 @@ WYMeditor.WymClassOpera.prototype.addCssRule = function(styles, oCss) {
4641
4674
 
4642
4675
  //keydown handler
4643
4676
  WYMeditor.WymClassOpera.prototype.keydown = function(evt) {
4644
-
4677
+
4645
4678
  //'this' is the doc
4646
4679
  var wym = WYMeditor.INSTANCES[this.title];
4647
4680
  var sel = wym._iframe.contentWindow.getSelection();
@@ -4705,12 +4738,12 @@ WYMeditor.WymClassSafari.prototype.initIframe = function(iframe) {
4705
4738
 
4706
4739
  this._iframe = iframe;
4707
4740
  this._doc = iframe.contentDocument;
4708
-
4741
+
4709
4742
  //add css rules from options
4710
-
4711
- var styles = this._doc.styleSheets[0];
4743
+
4744
+ var styles = this._doc.styleSheets[0];
4712
4745
  var aCss = eval(this._options.editorStyles);
4713
-
4746
+
4714
4747
  this.addCssRules(this._doc, aCss);
4715
4748
 
4716
4749
  this._doc.title = this._wym._index;
@@ -4720,25 +4753,25 @@ WYMeditor.WymClassSafari.prototype.initIframe = function(iframe) {
4720
4753
 
4721
4754
  //init designMode
4722
4755
  this._doc.designMode = "on";
4723
-
4756
+
4724
4757
  //init html value
4725
4758
  this.html(this._wym._html);
4726
-
4759
+
4727
4760
  //pre-bind functions
4728
4761
  if(jQuery.isFunction(this._options.preBind)) this._options.preBind(this);
4729
-
4762
+
4730
4763
  //bind external events
4731
4764
  this._wym.bindEvents();
4732
-
4765
+
4733
4766
  //bind editor keydown events
4734
4767
  jQuery(this._doc).bind("keydown", this.keydown);
4735
-
4768
+
4736
4769
  //bind editor keyup events
4737
4770
  jQuery(this._doc).bind("keyup", this.keyup);
4738
-
4771
+
4739
4772
  //post-init functions
4740
4773
  if(jQuery.isFunction(this._options.postInit)) this._options.postInit(this);
4741
-
4774
+
4742
4775
  //add event listeners to doc elements, e.g. images
4743
4776
  this.listen();
4744
4777
  };
@@ -4748,17 +4781,17 @@ WYMeditor.WymClassSafari.prototype._exec = function(cmd,param) {
4748
4781
  if(!this.selected()) return(false);
4749
4782
 
4750
4783
  switch(cmd) {
4751
-
4784
+
4752
4785
  case WYMeditor.INDENT: case WYMeditor.OUTDENT:
4753
-
4754
- var focusNode = this.selected();
4786
+
4787
+ var focusNode = this.selected();
4755
4788
  var sel = this._iframe.contentWindow.getSelection();
4756
4789
  var anchorNode = sel.anchorNode;
4757
4790
  if(anchorNode.nodeName == "#text") anchorNode = anchorNode.parentNode;
4758
-
4791
+
4759
4792
  focusNode = this.findUp(focusNode, WYMeditor.BLOCKS);
4760
4793
  anchorNode = this.findUp(anchorNode, WYMeditor.BLOCKS);
4761
-
4794
+
4762
4795
  if(focusNode && focusNode == anchorNode
4763
4796
  && focusNode.tagName.toLowerCase() == WYMeditor.LI) {
4764
4797
 
@@ -4783,13 +4816,13 @@ WYMeditor.WymClassSafari.prototype._exec = function(cmd,param) {
4783
4816
  if(container) jQuery(container).replaceWith(jQuery(container).html());
4784
4817
 
4785
4818
  break;
4786
-
4819
+
4787
4820
  default:
4788
4821
 
4789
4822
  if(param) this._doc.execCommand(cmd,'',param);
4790
4823
  else this._doc.execCommand(cmd,'',null);
4791
4824
  }
4792
-
4825
+
4793
4826
  //set to P if parent = BODY
4794
4827
  var container = this.selected();
4795
4828
  if(container && container.tagName.toLowerCase() == WYMeditor.BODY)
@@ -4833,7 +4866,7 @@ WYMeditor.WymClassSafari.prototype.selected = function(upgrade_text_nodes) {
4833
4866
  }
4834
4867
  }
4835
4868
  else return(node);
4836
- }
4869
+ }
4837
4870
  else return(null);
4838
4871
  };
4839
4872
 
@@ -4841,7 +4874,7 @@ WYMeditor.WymClassSafari.prototype.selected = function(upgrade_text_nodes) {
4841
4874
  * @description Toggles class on selected element, or one of its parents
4842
4875
  */
4843
4876
  WYMeditor.WymClassSafari.prototype.toggleClass = function(sClass, jqexpr) {
4844
-
4877
+
4845
4878
  var container = null;
4846
4879
  if (this._selected_image) {
4847
4880
  container = jQuery(this._selected_image);
@@ -4849,7 +4882,7 @@ WYMeditor.WymClassSafari.prototype.toggleClass = function(sClass, jqexpr) {
4849
4882
  else {
4850
4883
  container = jQuery(this.selected(true) || this._selected_item);
4851
4884
  }
4852
-
4885
+
4853
4886
  if (jqexpr != null) { container = jQuery(container.parentsOrSelf(jqexpr)); }
4854
4887
  container.toggleClass(sClass);
4855
4888
  if(!container.attr(WYMeditor.CLASS)) container.removeAttr(this._class);
@@ -4865,10 +4898,10 @@ WYMeditor.WymClassSafari.prototype.addCssRule = function(styles, oCss) {
4865
4898
 
4866
4899
  //keydown handler, mainly used for keyboard shortcuts
4867
4900
  WYMeditor.WymClassSafari.prototype.keydown = function(evt) {
4868
-
4901
+
4869
4902
  //'this' is the doc
4870
4903
  var wym = WYMeditor.INSTANCES[this.title];
4871
-
4904
+
4872
4905
  if(evt.ctrlKey){
4873
4906
  if(evt.keyCode == 66){
4874
4907
  //CTRL+b => STRONG
@@ -4888,16 +4921,16 @@ WYMeditor.WymClassSafari.prototype.keyup = function(evt) {
4888
4921
 
4889
4922
  //'this' is the doc
4890
4923
  var wym = WYMeditor.INSTANCES[this.title];
4891
-
4924
+
4892
4925
  wym._selected_image = null;
4893
4926
  var container = null;
4894
4927
 
4895
4928
  if(evt.keyCode == 13 && !evt.shiftKey) {
4896
-
4929
+
4897
4930
  //RETURN key
4898
4931
  //cleanup <br><br> between paragraphs
4899
4932
  jQuery(wym._doc.body).children(WYMeditor.BR).remove();
4900
-
4933
+
4901
4934
  //fix PRE bug #73
4902
4935
  container = wym.selected();
4903
4936
  if(container && container.tagName.toLowerCase() == WYMeditor.PRE)
@@ -4908,17 +4941,17 @@ WYMeditor.WymClassSafari.prototype.keyup = function(evt) {
4908
4941
  if(evt.keyCode == 13 && evt.shiftKey) {
4909
4942
  wym._exec('InsertLineBreak');
4910
4943
  }
4911
-
4944
+
4912
4945
  if(evt.keyCode != 8
4913
4946
  && evt.keyCode != 17
4914
4947
  && evt.keyCode != 46
4915
4948
  && evt.keyCode != 224
4916
4949
  && !evt.metaKey
4917
4950
  && !evt.ctrlKey) {
4918
-
4951
+
4919
4952
  //NOT BACKSPACE, NOT DELETE, NOT CTRL, NOT COMMAND
4920
4953
  //text nodes replaced by P
4921
-
4954
+
4922
4955
  container = wym.selected();
4923
4956
  var name = container.tagName.toLowerCase();
4924
4957
 
@@ -4961,16 +4994,16 @@ WYMeditor.WymClassSafari.prototype.openBlockTag = function(tag, attributes)
4961
4994
  var tag = new_tag;
4962
4995
  this._tag_stack.push(new_tag);
4963
4996
  attributes.style = '';
4964
-
4997
+
4965
4998
  //should fix #125 - also removed the xhtml() override
4966
4999
  if(typeof attributes['class'] == 'string')
4967
5000
  attributes['class'] = attributes['class'].replace(/apple-style-span/gi, '');
4968
-
5001
+
4969
5002
  } else {
4970
5003
  return;
4971
5004
  }
4972
5005
  }
4973
-
5006
+
4974
5007
  this.output += this.helper.tag(tag, attributes, true);
4975
5008
  };
4976
5009
 
@@ -4981,13 +5014,4 @@ WYMeditor.WymClassSafari.prototype.getTagForStyle = function(style) {
4981
5014
  if(/sub/.test(style)) return 'sub';
4982
5015
  if(/super/.test(style)) return 'sup';
4983
5016
  return false;
4984
- };
4985
-
4986
- function titleize(words) {
4987
- parts = [];
4988
- words.gsub(/\./, '').gsub(/[-_]/, ' ').split(' ').each(function(part){
4989
- parts.push(part[0].toUpperCase() + part.substring(1));
4990
- });
4991
-
4992
- return parts.join(" ");
4993
- }
5017
+ };