Squiz Matrix  4.12.2
 All Data Structures Namespaces Functions Variables Pages
visual_aid.inc
1 <?php
18 global $ROOT_PATH;
19 include_once($ROOT_PATH.'wysiwyg_plugin.inc');
20 
21 
34 class visual_aid extends WYSIWYG_Plugin
35 {
36 
37 
43  function visual_aid(&$wysiwyg)
44  {
45  wysiwyg_plugin::wysiwyg_plugin($wysiwyg);
46  $this->_add_button('visual_aid','Visual_Aid','Visual Aid','false','61');
47 
48  }//end constructor
49 
50 
59  function paint_generic()
60  {
61  ?>
62  <script type="text/javascript" src="<?php echo sq_web_path('fudge').'/wysiwyg/plugins/visual_aid/visual-aid.js' ?>"></script>
63  <script type="text/javascript" language="Javascript">
64  var visual_aid_image_path = "<?php echo sq_web_path('fudge') ?>/wysiwyg/plugins/visual_aid/images";
65  var visual_aid_mode = false;
66 
67  HTMLArea.prototype._visualAidToggle = function(target, change_mode) {
68  var editor = this;
69 
70  if (target.length == 1 && target[0] == "all") {
71  var tag_types = visual_aid_types;
72  } else {
73  var tag_types = target;
74  }
75 
76  // html elements with the start and end tags
77  var elements = Array();
78  if (HTMLArea.is_gecko) {
79  for (var i = 0; i < tag_types.length; i++) {
80  elements[tag_types[i]] = this._doc.getElementsByTagName(tag_types[i]);
81  }
82  } else if (HTMLArea.is_ie) {
83  for (var i = 0; i < tag_types.length; i++) {
84  elements[tag_types[i]] = this._docContent.getElementsByTagName(tag_types[i]);
85  }
86  }
87  for (var tag in elements) {
88  if (elements[tag].length > 0) {
89  for (var j = 0; j < elements[tag].length; j++) {
90  //for (var j = elements[tag].length - 1; j >= 0; j--) {
91  var obj = new visual_aid_factory(tag, elements[tag][j], editor);
92  if (visual_aid_mode) {
93  obj.turnOff();
94  } else {
95  obj.turnOn();
96  }
97  }
98  }
99  }
100  if (change_mode) {
101  visual_aid_mode = !visual_aid_mode;
102  }
103  }
104  </script>
105  <?php
106 
107  }//end paint_generic()
108 
109 
117  {
118  ?>
119  case "visual_aid":
120  var target = new Array("all");
121  this._visualAidToggle(target, true);
122  break;
123  <?php
124 
125  }//end print_plugin_button_click()
126 
127 
136  {
137  ?>
138  if (visual_aid_mode) {
139  var target = new Array("all");
140  this._visualAidToggle(target, true);
141  }
142  <?php
143 
144  }//end print_plugin_pre_get_html()
145 
146 
154  {
155  ?>
156  case 'm': // Toggle Visual Aid
157  var target = new Array("all");
158  this._visualAidToggle(target, true);
159  HTMLArea._stopEvent(ev);
160  break;
161  <?php
162 
163  }//end print_plugin_shortcuts()
164 
165 
166 }//end class()
167 
168 ?>