refinerycms-wymeditor 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (129) hide show
  1. data/.gitignore +88 -0
  2. data/app/assets/images/wymeditor/skins/refinery/arrow_redo.png +0 -0
  3. data/app/assets/images/wymeditor/skins/refinery/arrow_undo.png +0 -0
  4. data/app/assets/images/wymeditor/skins/refinery/eye.png +0 -0
  5. data/app/assets/images/wymeditor/skins/refinery/html5/article.png +0 -0
  6. data/app/assets/images/wymeditor/skins/refinery/html5/aside.png +0 -0
  7. data/app/assets/images/wymeditor/skins/refinery/html5/blockquote.png +0 -0
  8. data/app/assets/images/wymeditor/skins/refinery/html5/command.png +0 -0
  9. data/app/assets/images/wymeditor/skins/refinery/html5/details.png +0 -0
  10. data/app/assets/images/wymeditor/skins/refinery/html5/figcaption.png +0 -0
  11. data/app/assets/images/wymeditor/skins/refinery/html5/figure.png +0 -0
  12. data/app/assets/images/wymeditor/skins/refinery/html5/footer.png +0 -0
  13. data/app/assets/images/wymeditor/skins/refinery/html5/h1.png +0 -0
  14. data/app/assets/images/wymeditor/skins/refinery/html5/h2.png +0 -0
  15. data/app/assets/images/wymeditor/skins/refinery/html5/h3.png +0 -0
  16. data/app/assets/images/wymeditor/skins/refinery/html5/h4.png +0 -0
  17. data/app/assets/images/wymeditor/skins/refinery/html5/h5.png +0 -0
  18. data/app/assets/images/wymeditor/skins/refinery/html5/h6.png +0 -0
  19. data/app/assets/images/wymeditor/skins/refinery/html5/header.png +0 -0
  20. data/app/assets/images/wymeditor/skins/refinery/html5/hgroup.png +0 -0
  21. data/app/assets/images/wymeditor/skins/refinery/html5/mark.png +0 -0
  22. data/app/assets/images/wymeditor/skins/refinery/html5/meter.png +0 -0
  23. data/app/assets/images/wymeditor/skins/refinery/html5/nav.png +0 -0
  24. data/app/assets/images/wymeditor/skins/refinery/html5/p.png +0 -0
  25. data/app/assets/images/wymeditor/skins/refinery/html5/pre.png +0 -0
  26. data/app/assets/images/wymeditor/skins/refinery/html5/progress.png +0 -0
  27. data/app/assets/images/wymeditor/skins/refinery/html5/readme.md +1 -0
  28. data/app/assets/images/wymeditor/skins/refinery/html5/rp.png +0 -0
  29. data/app/assets/images/wymeditor/skins/refinery/html5/rt.png +0 -0
  30. data/app/assets/images/wymeditor/skins/refinery/html5/ruby.png +0 -0
  31. data/app/assets/images/wymeditor/skins/refinery/html5/section.png +0 -0
  32. data/app/assets/images/wymeditor/skins/refinery/html5/summary.png +0 -0
  33. data/app/assets/images/wymeditor/skins/refinery/html5/time.png +0 -0
  34. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-blockquote.png +0 -0
  35. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h1.png +0 -0
  36. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h2.png +0 -0
  37. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h3.png +0 -0
  38. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h4.png +0 -0
  39. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h5.png +0 -0
  40. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-h6.png +0 -0
  41. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-p.png +0 -0
  42. data/app/assets/images/wymeditor/skins/refinery/iframe/lbl-pre.png +0 -0
  43. data/app/assets/images/wymeditor/skins/refinery/link_add.png +0 -0
  44. data/app/assets/images/wymeditor/skins/refinery/link_break.png +0 -0
  45. data/app/assets/images/wymeditor/skins/refinery/page_code.png +0 -0
  46. data/app/assets/images/wymeditor/skins/refinery/page_paste.png +0 -0
  47. data/app/assets/images/wymeditor/skins/refinery/photo_add.png +0 -0
  48. data/app/assets/images/wymeditor/skins/refinery/right.png +0 -0
  49. data/app/assets/images/wymeditor/skins/refinery/style.png +0 -0
  50. data/app/assets/images/wymeditor/skins/refinery/table_add.png +0 -0
  51. data/app/assets/images/wymeditor/skins/refinery/text_align_center.png +0 -0
  52. data/app/assets/images/wymeditor/skins/refinery/text_align_justify.png +0 -0
  53. data/app/assets/images/wymeditor/skins/refinery/text_align_left.png +0 -0
  54. data/app/assets/images/wymeditor/skins/refinery/text_align_right.png +0 -0
  55. data/app/assets/images/wymeditor/skins/refinery/text_bold.png +0 -0
  56. data/app/assets/images/wymeditor/skins/refinery/text_heading_1.png +0 -0
  57. data/app/assets/images/wymeditor/skins/refinery/text_heading_2.png +0 -0
  58. data/app/assets/images/wymeditor/skins/refinery/text_heading_3.png +0 -0
  59. data/app/assets/images/wymeditor/skins/refinery/text_heading_4.png +0 -0
  60. data/app/assets/images/wymeditor/skins/refinery/text_heading_5.png +0 -0
  61. data/app/assets/images/wymeditor/skins/refinery/text_heading_6.png +0 -0
  62. data/app/assets/images/wymeditor/skins/refinery/text_indent.png +0 -0
  63. data/app/assets/images/wymeditor/skins/refinery/text_indent_remove.png +0 -0
  64. data/app/assets/images/wymeditor/skins/refinery/text_italic.png +0 -0
  65. data/app/assets/images/wymeditor/skins/refinery/text_list_bullets.png +0 -0
  66. data/app/assets/images/wymeditor/skins/refinery/text_list_numbers.png +0 -0
  67. data/app/assets/images/wymeditor/skins/refinery/text_paragraph.png +0 -0
  68. data/app/assets/images/wymeditor/skins/refinery/text_strikethrough.png +0 -0
  69. data/app/assets/images/wymeditor/skins/refinery/text_subscript.png +0 -0
  70. data/app/assets/images/wymeditor/skins/refinery/text_superscript.png +0 -0
  71. data/app/assets/images/wymeditor/skins/refinery/text_underline.png +0 -0
  72. data/app/assets/images/wymeditor/skins/wymeditor_icon.png +0 -0
  73. data/app/assets/javascripts/refinery/boot_wym.js.erb +289 -0
  74. data/app/assets/javascripts/refinery/wymeditor.js +37 -0
  75. data/app/assets/javascripts/wymeditor/browsers/ie.js.erb +224 -0
  76. data/app/assets/javascripts/wymeditor/browsers/mozilla.js.erb +293 -0
  77. data/app/assets/javascripts/wymeditor/browsers/opera.js.erb +123 -0
  78. data/app/assets/javascripts/wymeditor/browsers/webkit.js.erb +284 -0
  79. data/app/assets/javascripts/wymeditor/classes.js.erb +1577 -0
  80. data/app/assets/javascripts/wymeditor/functions.js.erb +218 -0
  81. data/app/assets/javascripts/wymeditor/lang/bg.js +57 -0
  82. data/app/assets/javascripts/wymeditor/lang/ca.js +45 -0
  83. data/app/assets/javascripts/wymeditor/lang/cs.js +58 -0
  84. data/app/assets/javascripts/wymeditor/lang/da.js +48 -0
  85. data/app/assets/javascripts/wymeditor/lang/de.js +45 -0
  86. data/app/assets/javascripts/wymeditor/lang/en.js +57 -0
  87. data/app/assets/javascripts/wymeditor/lang/es.js +58 -0
  88. data/app/assets/javascripts/wymeditor/lang/fa.js +46 -0
  89. data/app/assets/javascripts/wymeditor/lang/fi.js +57 -0
  90. data/app/assets/javascripts/wymeditor/lang/fr.js +57 -0
  91. data/app/assets/javascripts/wymeditor/lang/he.js +45 -0
  92. data/app/assets/javascripts/wymeditor/lang/hu.js +45 -0
  93. data/app/assets/javascripts/wymeditor/lang/it.js +48 -0
  94. data/app/assets/javascripts/wymeditor/lang/ja.js +47 -0
  95. data/app/assets/javascripts/wymeditor/lang/lv.js +47 -0
  96. data/app/assets/javascripts/wymeditor/lang/nb.js +48 -0
  97. data/app/assets/javascripts/wymeditor/lang/nl.js +47 -0
  98. data/app/assets/javascripts/wymeditor/lang/nn.js +45 -0
  99. data/app/assets/javascripts/wymeditor/lang/pl.js +45 -0
  100. data/app/assets/javascripts/wymeditor/lang/pt-BR.js +58 -0
  101. data/app/assets/javascripts/wymeditor/lang/pt.js +45 -0
  102. data/app/assets/javascripts/wymeditor/lang/rs.js +47 -0
  103. data/app/assets/javascripts/wymeditor/lang/ru.js +56 -0
  104. data/app/assets/javascripts/wymeditor/lang/sk.js +56 -0
  105. data/app/assets/javascripts/wymeditor/lang/sl.js +47 -0
  106. data/app/assets/javascripts/wymeditor/lang/sv.js +45 -0
  107. data/app/assets/javascripts/wymeditor/lang/tr.js +45 -0
  108. data/app/assets/javascripts/wymeditor/lang/vi.js +47 -0
  109. data/app/assets/javascripts/wymeditor/lang/zh_cn.js +47 -0
  110. data/app/assets/javascripts/wymeditor/prototypes.js.erb +1106 -0
  111. data/app/assets/javascripts/wymeditor/setup.js.erb +622 -0
  112. data/app/assets/javascripts/wymeditor/skins/refinery/skin.js +48 -0
  113. data/app/assets/javascripts/wymeditor/validators.js.erb +776 -0
  114. data/app/assets/stylesheets/theme.css.scss +36 -0
  115. data/app/assets/stylesheets/wymeditor/skins/refinery/skin.css.scss +530 -0
  116. data/app/assets/stylesheets/wymeditor/skins/refinery/wymiframe.css.scss +156 -0
  117. data/app/assets/stylesheets/wymeditor.css.scss +0 -0
  118. data/app/controllers/refinery/wymeditor_controller.rb +9 -0
  119. data/app/views/refinery/wymiframe.html.erb +14 -0
  120. data/config/initializers/refinery/wymeditor.rb.erb +4 -0
  121. data/lib/refinery/wymeditor/configuration.rb +10 -0
  122. data/lib/refinery/wymeditor/engine.rb +30 -0
  123. data/lib/refinery/wymeditor.rb +12 -0
  124. data/public/wymeditor/GPL-license.txt +278 -0
  125. data/public/wymeditor/MIT-license.txt +20 -0
  126. data/public/wymeditor/README +35 -0
  127. data/readme.md +96 -0
  128. data/refinerycms-wymeditor.gemspec +17 -0
  129. metadata +173 -0
@@ -0,0 +1,776 @@
1
+ /**
2
+ * XhtmlValidator for validating tag attributes
3
+ *
4
+ * @author Bermi Ferrer - http://bermi.org
5
+ */
6
+ WYMeditor.XhtmlValidator = {
7
+ "_attributes":
8
+ {
9
+ "core":
10
+ {
11
+ "except":<%= [
12
+ "base",
13
+ "head",
14
+ "html",
15
+ "meta",
16
+ "param",
17
+ "script",
18
+ "style",
19
+ "title"
20
+ ].reject{|a| Refinery::Wymeditor.whitelist_tags.keys.map(&:to_s).include?(a)}.inspect %>,
21
+ "attributes":[
22
+ "class",
23
+ "id",
24
+ "style",
25
+ "title",
26
+ "accesskey",
27
+ "tabindex",
28
+ "data",
29
+ "^data-.*"
30
+ ]
31
+ },
32
+ "language":
33
+ {
34
+ "except":<%= [
35
+ "base",
36
+ "br",
37
+ "hr",
38
+ "iframe",
39
+ "param",
40
+ "script"
41
+ ].reject{|a| Refinery::Wymeditor.whitelist_tags.keys.map(&:to_s).include?(a)}.inspect %>,
42
+ "attributes":
43
+ {
44
+ "dir":[
45
+ "ltr",
46
+ "rtl"
47
+ ],
48
+ "0":"lang",
49
+ "1":"xml:lang"
50
+ }
51
+ },
52
+ "keyboard":
53
+ {
54
+ "attributes":
55
+ {
56
+ "accesskey":/^(\w){1}$/,
57
+ "tabindex":/^(\d)+$/
58
+ }
59
+ }
60
+ },
61
+ "_events":
62
+ {
63
+ "window":
64
+ {
65
+ "only":[
66
+ "body"
67
+ ],
68
+ "attributes":[
69
+ "onload",
70
+ "onunload"
71
+ ]
72
+ },
73
+ "form":
74
+ {
75
+ "only":[
76
+ "form",
77
+ "input",
78
+ "textarea",
79
+ "select",
80
+ "a",
81
+ "label",
82
+ "button"
83
+ ],
84
+ "attributes":[
85
+ "onchange",
86
+ "onsubmit",
87
+ "onreset",
88
+ "onselect",
89
+ "onblur",
90
+ "onfocus"
91
+ ]
92
+ },
93
+ "keyboard":
94
+ {
95
+ "except":<%= [
96
+ "base",
97
+ "bdo",
98
+ "br",
99
+ "frame",
100
+ "frameset",
101
+ "head",
102
+ "html",
103
+ "iframe",
104
+ "meta",
105
+ "param",
106
+ "script",
107
+ "style",
108
+ "title"
109
+ ].reject{|a| Refinery::Wymeditor.whitelist_tags.keys.map(&:to_s).include?(a)}.inspect %>,
110
+ "attributes":[
111
+ "onkeydown",
112
+ "onkeypress",
113
+ "onkeyup"
114
+ ]
115
+ },
116
+ "mouse":
117
+ {
118
+ "except":<%= [
119
+ "base",
120
+ "bdo",
121
+ "br",
122
+ "head",
123
+ "html",
124
+ "meta",
125
+ "param",
126
+ "script",
127
+ "style",
128
+ "title"
129
+ ].reject{|a| Refinery::Wymeditor.whitelist_tags.keys.map(&:to_s).include?(a)}.inspect %>,
130
+ "attributes":[
131
+ "onclick",
132
+ "ondblclick",
133
+ "onmousedown",
134
+ "onmousemove",
135
+ "onmouseover",
136
+ "onmouseout",
137
+ "onmouseup"
138
+ ]
139
+ }
140
+ },
141
+ "_tags":
142
+ {
143
+ "a":
144
+ {
145
+ "attributes":
146
+ {
147
+ "0":"charset",
148
+ "1":"coords",
149
+ "2":"href",
150
+ "3":"hreflang",
151
+ "4":"name",
152
+ "rel":/^(alternate|designates|stylesheet|start|next|nofollow|prev|contents|index|glossary|copyright|chapter|section|subsection|appendix|help|bookmark| |shortcut|icon|moodalbox)+$/,
153
+ "rev":/^(alternate|designates|stylesheet|start|next|prev|contents|index|glossary|copyright|chapter|section|subsection|appendix|help|bookmark| |shortcut|icon|moodalbox)+$/,
154
+ "shape":/^(rect|rectangle|circ|circle|poly|polygon)$/,
155
+ "5":"type",
156
+ "target":/^(_blank)+$/
157
+ }
158
+ },
159
+ "0":"abbr",
160
+ "1":"acronym",
161
+ "2":"address",
162
+ "area":
163
+ {
164
+ "attributes":
165
+ {
166
+ "0":"alt",
167
+ "1":"coords",
168
+ "2":"href",
169
+ "nohref":/^(true|false)$/,
170
+ "shape":/^(rect|rectangle|circ|circle|poly|polygon)$/
171
+ },
172
+ "required":[
173
+ "alt"
174
+ ]
175
+ },
176
+ "3":"b",
177
+ "base":
178
+ {
179
+ "attributes":[
180
+ "href"
181
+ ],
182
+ "required":[
183
+ "href"
184
+ ]
185
+ },
186
+ "bdo":
187
+ {
188
+ "attributes":
189
+ {
190
+ "dir":/^(ltr|rtl)$/
191
+ },
192
+ "required":[
193
+ "dir"
194
+ ]
195
+ },
196
+ "4":"big",
197
+ "blockquote":
198
+ {
199
+ "attributes":[
200
+ "cite"
201
+ ]
202
+ },
203
+ "5":"body",
204
+ "6":"br",
205
+ "button":
206
+ {
207
+ "attributes":
208
+ {
209
+ "disabled":/^(disabled)$/,
210
+ "type":/^(button|reset|submit)$/,
211
+ "0":"value"
212
+ },
213
+ "inside":"form"
214
+ },
215
+ "7":"caption",
216
+ "8":"cite",
217
+ "9":"code",
218
+ "col":
219
+ {
220
+ "attributes":
221
+ {
222
+ "align":/^(right|left|center|justify)$/,
223
+ "0":"char",
224
+ "1":"charoff",
225
+ "span":/^(\d)+$/,
226
+ "valign":/^(top|middle|bottom|baseline)$/,
227
+ "2":"width"
228
+ },
229
+ "inside":"colgroup"
230
+ },
231
+ "colgroup":
232
+ {
233
+ "attributes":
234
+ {
235
+ "align":/^(right|left|center|justify)$/,
236
+ "0":"char",
237
+ "1":"charoff",
238
+ "span":/^(\d)+$/,
239
+ "valign":/^(top|middle|bottom|baseline)$/,
240
+ "2":"width"
241
+ }
242
+ },
243
+ "10":"dd",
244
+ "del":
245
+ {
246
+ "attributes":
247
+ {
248
+ "0":"cite",
249
+ "datetime":/^([0-9]){8}/
250
+ }
251
+ },
252
+ "11":"div",
253
+ "12":"dfn",
254
+ "13":"dl",
255
+ "14":"dt",
256
+ "15":"em",
257
+ "fieldset":
258
+ {
259
+ "inside":"form"
260
+ },
261
+ "form":
262
+ {
263
+ "attributes":
264
+ {
265
+ "0":"action",
266
+ "1":"accept",
267
+ "2":"accept-charset",
268
+ "3":"enctype",
269
+ "method":/^(get|post)$/
270
+ },
271
+ "required":[
272
+ "action"
273
+ ]
274
+ },
275
+ "head":
276
+ {
277
+ "attributes":[
278
+ "profile"
279
+ ]
280
+ },
281
+ "16":"h1",
282
+ "17":"h2",
283
+ "18":"h3",
284
+ "19":"h4",
285
+ "20":"h5",
286
+ "21":"h6",
287
+ "22":"hr",
288
+ "html":
289
+ {
290
+ "attributes":[
291
+ "xmlns"
292
+ ]
293
+ },
294
+ "23":"i",
295
+ "iframe":
296
+ {
297
+ "attributes":[
298
+ "src",
299
+ "width",
300
+ "height",
301
+ "frameborder",
302
+ "scrolling",
303
+ "marginheight",
304
+ "marginwidth"
305
+ ],
306
+ "required":[
307
+ "src"
308
+ ]
309
+ },
310
+ "img":
311
+ {
312
+ "attributes":{
313
+ "align":/^(right|left|center|justify)$/,
314
+ "0":"alt",
315
+ "1":"src",
316
+ "2":"height",
317
+ "3":"ismap",
318
+ "4":"longdesc",
319
+ "5":"usemap",
320
+ "6":"width",
321
+ "7":"rel"
322
+ },
323
+ "required":[
324
+ "alt",
325
+ "src"
326
+ ]
327
+ },
328
+ "input":
329
+ {
330
+ "attributes":
331
+ {
332
+ "0":"accept",
333
+ "1":"alt",
334
+ "checked":/^(checked)$/,
335
+ "disabled":/^(disabled)$/,
336
+ "maxlength":/^(\d)+$/,
337
+ "2":"name",
338
+ "readonly":/^(readonly)$/,
339
+ "size":/^(\d)+$/,
340
+ "3":"src",
341
+ "type":/^(button|checkbox|file|hidden|image|password|radio|reset|submit|text|tel|search|url|email|datetime|date|month|week|time|datetime-local|number|range|color|placeholder)$/,
342
+ "4":"value"
343
+ },
344
+ "inside":"form"
345
+ },
346
+ "ins":
347
+ {
348
+ "attributes":
349
+ {
350
+ "0":"cite",
351
+ "datetime":/^([0-9]){8}/
352
+ }
353
+ },
354
+ "24":"kbd",
355
+ "label":
356
+ {
357
+ "attributes":[
358
+ "for"
359
+ ],
360
+ "inside":"form"
361
+ },
362
+ "25":"legend",
363
+ "26":"li",
364
+ "link":
365
+ {
366
+ "attributes":
367
+ {
368
+ "0":"charset",
369
+ "1":"href",
370
+ "2":"hreflang",
371
+ "media":/^(all|braille|print|projection|screen|speech|,|;| )+$/i,
372
+ //next comment line required by Opera!
373
+ /*"rel":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,*/
374
+ "rel":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|nofollow|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,
375
+ "rev":/^(alternate|appendix|bookmark|chapter|contents|copyright|glossary|help|home|index|next|prev|section|start|stylesheet|subsection| |shortcut|icon)+$/i,
376
+ "3":"type"
377
+ },
378
+ "inside":"head"
379
+ },
380
+ "map":
381
+ {
382
+ "attributes":[
383
+ "id",
384
+ "name"
385
+ ],
386
+ "required":[
387
+ "id"
388
+ ]
389
+ },
390
+ "meta":
391
+ {
392
+ "attributes":
393
+ {
394
+ "0":"content",
395
+ "http-equiv":/^(content\-type|expires|refresh|set\-cookie)$/i,
396
+ "1":"name",
397
+ "2":"scheme"
398
+ },
399
+ "required":[
400
+ "content"
401
+ ]
402
+ },
403
+ "27":"noscript",
404
+ "28":"ol",
405
+ "optgroup":
406
+ {
407
+ "attributes":
408
+ {
409
+ "0":"label",
410
+ "disabled": /^(disabled)$/
411
+ },
412
+ "required":[
413
+ "label"
414
+ ]
415
+ },
416
+ "option":
417
+ {
418
+ "attributes":
419
+ {
420
+ "0":"label",
421
+ "disabled":/^(disabled)$/,
422
+ "selected":/^(selected)$/,
423
+ "1":"value"
424
+ },
425
+ "inside":"select"
426
+ },
427
+ "29":"p",
428
+ "param":
429
+ {
430
+ "attributes":
431
+ [
432
+ "type",
433
+ "value",
434
+ "name"
435
+ ],
436
+ "required":[
437
+ "name"
438
+ ],
439
+ "inside":"object"
440
+ },
441
+ "embed":
442
+ {
443
+ "attributes":
444
+ [
445
+ "width",
446
+ "height",
447
+ "allowfullscreen",
448
+ "allowscriptaccess",
449
+ "wmode",
450
+ "type",
451
+ "src",
452
+ "flashvars"
453
+ ],
454
+ "inside":"object"
455
+ },
456
+ "object":
457
+ {
458
+ "attributes":[
459
+ "archive",
460
+ "classid",
461
+ "codebase",
462
+ "codetype",
463
+ "data",
464
+ "declare",
465
+ "height",
466
+ "name",
467
+ "standby",
468
+ "type",
469
+ "usemap",
470
+ "width"
471
+ ]
472
+ },
473
+ "30":"pre",
474
+ "q":
475
+ {
476
+ "attributes":[
477
+ "cite"
478
+ ]
479
+ },
480
+ "31":"samp",
481
+ "script":
482
+ {
483
+ "attributes":
484
+ {
485
+ "type":/^(text\/ecmascript|text\/javascript|text\/jscript|text\/vbscript|text\/vbs|text\/xml)$/,
486
+ "0":"charset",
487
+ "defer":/^(defer)$/,
488
+ "1":"src"
489
+ },
490
+ "required":[
491
+ "type"
492
+ ]
493
+ },
494
+ "select":
495
+ {
496
+ "attributes":
497
+ {
498
+ "disabled":/^(disabled)$/,
499
+ "multiple":/^(multiple)$/,
500
+ "0":"name",
501
+ "1":"size"
502
+ },
503
+ "inside":"form"
504
+ },
505
+ "32":"small",
506
+ "33":"span",
507
+ "34":"strong",
508
+ "style":
509
+ {
510
+ "attributes":
511
+ {
512
+ "0":"type",
513
+ "media":/^(screen|tty|tv|projection|handheld|print|braille|aural|all)$/
514
+ },
515
+ "required":[
516
+ "type"
517
+ ]
518
+ },
519
+ "35":"sub",
520
+ "36":"sup",
521
+ "table":
522
+ {
523
+ "attributes":
524
+ {
525
+ "0":"border",
526
+ "1":"cellpadding",
527
+ "2":"cellspacing",
528
+ "frame":/^(void|above|below|hsides|lhs|rhs|vsides|box|border)$/,
529
+ "rules":/^(none|groups|rows|cols|all)$/,
530
+ "3":"summary",
531
+ "4":"width"
532
+ }
533
+ },
534
+ "tbody":
535
+ {
536
+ "attributes":
537
+ {
538
+ "align":/^(right|left|center|justify)$/,
539
+ "0":"char",
540
+ "1":"charoff",
541
+ "valign":/^(top|middle|bottom|baseline)$/
542
+ }
543
+ },
544
+ "td":
545
+ {
546
+ "attributes":
547
+ {
548
+ "0":"abbr",
549
+ "align":/^(left|right|center|justify|char)$/,
550
+ "1":"axis",
551
+ "2":"char",
552
+ "3":"charoff",
553
+ "colspan":/^(\d)+$/,
554
+ "4":"headers",
555
+ "rowspan":/^(\d)+$/,
556
+ "scope":/^(col|colgroup|row|rowgroup)$/,
557
+ "valign":/^(top|middle|bottom|baseline)$/
558
+ }
559
+ },
560
+ "textarea":
561
+ {
562
+ "attributes":[
563
+ "cols",
564
+ "rows",
565
+ "disabled",
566
+ "name",
567
+ "readonly"
568
+ ],
569
+ "required":[
570
+ "cols",
571
+ "rows"
572
+ ],
573
+ "inside":"form"
574
+ },
575
+ "tfoot":
576
+ {
577
+ "attributes":
578
+ {
579
+ "align":/^(right|left|center|justify)$/,
580
+ "0":"char",
581
+ "1":"charoff",
582
+ "valign":/^(top|middle|bottom)$/,
583
+ "2":"baseline"
584
+ }
585
+ },
586
+ "th":
587
+ {
588
+ "attributes":
589
+ {
590
+ "0":"abbr",
591
+ "align":/^(left|right|center|justify|char)$/,
592
+ "1":"axis",
593
+ "2":"char",
594
+ "3":"charoff",
595
+ "colspan":/^(\d)+$/,
596
+ "4":"headers",
597
+ "rowspan":/^(\d)+$/,
598
+ "scope":/^(col|colgroup|row|rowgroup)$/,
599
+ "valign":/^(top|middle|bottom|baseline)$/
600
+ }
601
+ },
602
+ "thead":
603
+ {
604
+ "attributes":
605
+ {
606
+ "align":/^(right|left|center|justify)$/,
607
+ "0":"char",
608
+ "1":"charoff",
609
+ "valign":/^(top|middle|bottom|baseline)$/
610
+ }
611
+ },
612
+ "37":"title",
613
+ "tr":
614
+ {
615
+ "attributes":
616
+ {
617
+ "align":/^(right|left|center|justify|char)$/,
618
+ "0":"char",
619
+ "1":"charoff",
620
+ "valign":/^(top|middle|bottom|baseline)$/
621
+ }
622
+ },
623
+ "38":"tt",
624
+ "39":"ul",
625
+ "40":"var",
626
+ "41":"section",
627
+ "42":"article",
628
+ "43":"aside",
629
+ "44":"details",
630
+ "45":"header",
631
+ "46":"footer",
632
+ "47":"nav",
633
+ "48":"dialog",
634
+ "49":"figure",
635
+ "50":"figcaption",
636
+ "51":"address",
637
+ "52":"hgroup",
638
+ "53":"mark",
639
+ "54":"time",
640
+ "55":"canvas",
641
+ "56":"audio",
642
+ "57":"video",
643
+ "58":"source",
644
+ "59":"output",
645
+ "60":"progress",
646
+ "61":"ruby",
647
+ "62":"rt",
648
+ "63":"rp",
649
+ "64":"summary",
650
+ "65":"command"<% Refinery::Wymeditor.whitelist_tags.each do |key, value| %>,
651
+ <%= key.inspect %>:<%= value.to_json %><% end %>
652
+ },
653
+
654
+ // Temporary skipped attributes
655
+ skipped_attributes : [],
656
+ skipped_attribute_values : [],
657
+
658
+ getValidTagAttributes: function(tag, attributes)
659
+ {
660
+ var valid_attributes = {};
661
+ var possible_attributes = this.getPossibleTagAttributes(tag);
662
+ var regexp_attributes = [];
663
+ $.each((possible_attributes || []), function(i, val) {
664
+ if (val.indexOf("*") > -1) {
665
+ regexp_attributes.push(new RegExp(val));
666
+ }
667
+ });
668
+ var h = WYMeditor.Helper;
669
+ for(var attribute in attributes) {
670
+ var value = attributes[attribute];
671
+ if(!h.contains(this.skipped_attributes, attribute) && !h.contains(this.skipped_attribute_values, value)){
672
+ if (typeof value != 'function') {
673
+ if (h.contains(possible_attributes, attribute)) {
674
+ if (this.doesAttributeNeedsValidation(tag, attribute)) {
675
+ if(this.validateAttribute(tag, attribute, value)){
676
+ valid_attributes[attribute] = value;
677
+ }
678
+ }else{
679
+ valid_attributes[attribute] = value;
680
+ }
681
+ }
682
+ else {
683
+ $.each(regexp_attributes, function(i, val) {
684
+ if (attribute.match(val)) {
685
+ valid_attributes[attribute] = value;
686
+ }
687
+ });
688
+ }
689
+ }
690
+ }
691
+ }
692
+ return valid_attributes;
693
+ },
694
+ getUniqueAttributesAndEventsForTag: function(tag)
695
+ {
696
+ var result = [];
697
+
698
+ if (this._tags[tag] && this._tags[tag]['attributes']) {
699
+ for (k in this._tags[tag]['attributes']) {
700
+ result.push(parseInt(k) == k ? this._tags[tag]['attributes'][k] : k);
701
+ }
702
+ }
703
+ return result;
704
+ },
705
+ getDefaultAttributesAndEventsForTags: function()
706
+ {
707
+ var result = [];
708
+ for (var key in this._events){
709
+ result.push(this._events[key]);
710
+ }
711
+ for (var key in this._attributes){
712
+ result.push(this._attributes[key]);
713
+ }
714
+ return result;
715
+ },
716
+ isValidTag: function(tag)
717
+ {
718
+ if(this._tags[tag]){
719
+ return true;
720
+ }
721
+ for(var key in this._tags){
722
+ if(this._tags[key] == tag){
723
+ return true;
724
+ }
725
+ }
726
+ return false;
727
+ },
728
+ getDefaultAttributesAndEventsForTag: function(tag)
729
+ {
730
+ var default_attributes = [];
731
+ if (this.isValidTag(tag)) {
732
+ var default_attributes_and_events = this.getDefaultAttributesAndEventsForTags();
733
+
734
+ for(var key in default_attributes_and_events) {
735
+ var defaults = default_attributes_and_events[key];
736
+ if(typeof defaults == 'object'){
737
+ var h = WYMeditor.Helper;
738
+ if ((defaults['except'] && h.contains(defaults['except'], tag)) || (defaults['only'] && !h.contains(defaults['only'], tag))) {
739
+ continue;
740
+ }
741
+
742
+ var tag_defaults = defaults['attributes'] ? defaults['attributes'] : defaults['events'];
743
+ for(var k in tag_defaults) {
744
+ default_attributes.push(typeof tag_defaults[k] != 'string' ? k : tag_defaults[k]);
745
+ }
746
+ }
747
+ }
748
+ }
749
+ return default_attributes;
750
+ },
751
+ doesAttributeNeedsValidation: function(tag, attribute)
752
+ {
753
+ return this._tags[tag] && ((this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute]) || (this._tags[tag]['required'] &&
754
+ WYMeditor.Helper.contains(this._tags[tag]['required'], attribute)));
755
+ },
756
+ validateAttribute: function(tag, attribute, value)
757
+ {
758
+ if ( this._tags[tag] &&
759
+ (this._tags[tag]['attributes'] && this._tags[tag]['attributes'][attribute] && value.length > 0 && !value.match(this._tags[tag]['attributes'][attribute])) || // invalid format
760
+ (this._tags[tag] && this._tags[tag]['required'] && WYMeditor.Helper.contains(this._tags[tag]['required'], attribute) && value.length == 0) // required attribute
761
+ ) {
762
+ return false;
763
+ }
764
+ return typeof this._tags[tag] != 'undefined';
765
+ },
766
+ getPossibleTagAttributes: function(tag)
767
+ {
768
+ if (!this._possible_tag_attributes) {
769
+ this._possible_tag_attributes = {};
770
+ }
771
+ if (!this._possible_tag_attributes[tag]) {
772
+ this._possible_tag_attributes[tag] = this.getUniqueAttributesAndEventsForTag(tag).concat(this.getDefaultAttributesAndEventsForTag(tag));
773
+ }
774
+ return this._possible_tag_attributes[tag];
775
+ }
776
+ };