dante-editor 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/app/assets/javascripts/dante.js +4 -0
  4. data/app/assets/javascripts/dante/editor.js.coffee +56 -25
  5. data/app/assets/javascripts/dante/tooltip.js.coffee +14 -304
  6. data/app/assets/javascripts/dante/tooltip_widget.js.coffee +10 -0
  7. data/app/assets/javascripts/dante/tooltip_widgets/embed.js.coffee +60 -0
  8. data/app/assets/javascripts/dante/tooltip_widgets/extract.js.coffee +64 -0
  9. data/app/assets/javascripts/dante/tooltip_widgets/uploader.js.coffee +224 -0
  10. data/app/assets/javascripts/dante/view.js.coffee +46 -1
  11. data/app/assets/stylesheets/{dante.css.scss → dante.scss} +0 -0
  12. data/bower.json +1 -1
  13. data/config.rb +2 -2
  14. data/dist/{0.0.10/css → css}/dante-editor.css +0 -0
  15. data/dist/{0.0.10/fonts → fonts}/dante/dante.eot +0 -0
  16. data/dist/{0.0.10/fonts → fonts}/dante/dante.svg +0 -0
  17. data/dist/{0.0.10/fonts → fonts}/dante/dante.ttf +0 -0
  18. data/dist/{0.0.10/fonts → fonts}/dante/dante.woff +0 -0
  19. data/dist/{0.0.10/fonts → fonts}/dante/fontello.eot +0 -0
  20. data/dist/{0.0.10/fonts → fonts}/dante/fontello.svg +0 -0
  21. data/dist/{0.0.10/fonts → fonts}/dante/fontello.ttf +0 -0
  22. data/dist/{0.0.10/fonts → fonts}/dante/fontello.woff +0 -0
  23. data/dist/{0.0.10/images → images}/dante/media-loading-placeholder.png +0 -0
  24. data/dist/{0.0.10/js → js}/dante-editor.js +355 -138
  25. data/lib/dante-editor/version.rb +1 -1
  26. data/source/assets/javascripts/examples/custom_toolbar.js.coffee +30 -0
  27. data/source/custom_toolbar.erb +29 -0
  28. data/source/layouts/layout.erb +1 -1
  29. metadata +20 -47
  30. data/dist/0.0.7/css/dante-editor.css +0 -1077
  31. data/dist/0.0.7/fonts/dante/dante.eot +0 -0
  32. data/dist/0.0.7/fonts/dante/dante.svg +0 -14
  33. data/dist/0.0.7/fonts/dante/dante.ttf +0 -0
  34. data/dist/0.0.7/fonts/dante/dante.woff +0 -0
  35. data/dist/0.0.7/fonts/dante/fontello.eot +0 -0
  36. data/dist/0.0.7/fonts/dante/fontello.svg +0 -36
  37. data/dist/0.0.7/fonts/dante/fontello.ttf +0 -0
  38. data/dist/0.0.7/fonts/dante/fontello.woff +0 -0
  39. data/dist/0.0.7/images/dante/media-loading-placeholder.png +0 -0
  40. data/dist/0.0.7/js/dante-editor.js +0 -2610
  41. data/dist/0.0.8/css/dante-editor.css +0 -1116
  42. data/dist/0.0.8/fonts/dante/dante.eot +0 -0
  43. data/dist/0.0.8/fonts/dante/dante.svg +0 -14
  44. data/dist/0.0.8/fonts/dante/dante.ttf +0 -0
  45. data/dist/0.0.8/fonts/dante/dante.woff +0 -0
  46. data/dist/0.0.8/fonts/dante/fontello.eot +0 -0
  47. data/dist/0.0.8/fonts/dante/fontello.svg +0 -36
  48. data/dist/0.0.8/fonts/dante/fontello.ttf +0 -0
  49. data/dist/0.0.8/fonts/dante/fontello.woff +0 -0
  50. data/dist/0.0.8/images/dante/media-loading-placeholder.png +0 -0
  51. data/dist/0.0.8/js/dante-editor.js +0 -2532
  52. data/dist/0.0.9/css/dante-editor.css +0 -1116
  53. data/dist/0.0.9/fonts/dante/dante.eot +0 -0
  54. data/dist/0.0.9/fonts/dante/dante.svg +0 -14
  55. data/dist/0.0.9/fonts/dante/dante.ttf +0 -0
  56. data/dist/0.0.9/fonts/dante/dante.woff +0 -0
  57. data/dist/0.0.9/fonts/dante/fontello.eot +0 -0
  58. data/dist/0.0.9/fonts/dante/fontello.svg +0 -36
  59. data/dist/0.0.9/fonts/dante/fontello.ttf +0 -0
  60. data/dist/0.0.9/fonts/dante/fontello.woff +0 -0
  61. data/dist/0.0.9/images/dante/media-loading-placeholder.png +0 -0
  62. data/dist/0.0.9/js/dante-editor.js +0 -2575
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by IcoMoon</metadata>
5
- <defs>
6
- <font id="icomoon" horiz-adv-x="1024">
7
- <font-face units-per-em="1024" ascent="960" descent="-64" />
8
- <missing-glyph horiz-adv-x="1024" />
9
- <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
- <glyph unicode="&#xe600;" d="M256 759.559v-623.174c0-70.118 47.316-95.291 105.683-55.222l428.634 294.258c58.622 40.244 58.367 105.034 0 145.103l-428.634 294.258c-58.622 40.244-105.683 15.345-105.683-55.222zM320 766.664l426.195-293.488c30.527-20.25 29.832-31 0-51.070l-426.195-295.039v639.598z" />
11
- <glyph unicode="&#xe601;" d="M294.4 768l0.489 2.446c13.868 69.342 82.599 125.554 152.977 125.554h128.267c70.619 0 139.014-55.74 152.977-125.554l0.489-2.446h166.78c70.483 0 127.62-57.611 127.62-127.489v-449.022c0-70.41-57.249-127.489-127.62-127.489h-768.76c-70.483 0-127.62 57.611-127.62 127.489v449.022c0 70.41 57.249 127.489 127.62 127.489h166.78zM347.123 704h-218.685c-35.641 0-64.438-28.583-64.438-63.843v-448.314c0-35.279 28.85-63.843 64.438-63.843h767.124c35.641 0 64.438 28.583 64.438 63.843v448.314c0 35.279-28.85 63.843-64.438 63.843h-218.816l-13.864 65.375c-7.263 34.25-41.874 62.625-77.145 62.625h-147.627c-35.433 0-69.805-28.038-77.134-62.625l-13.853-65.375zM320 448c0-105.823 85.961-192 192-192 105.823 0 192 85.961 192 192 0 105.823-85.961 192-192 192-105.823 0-192-85.961-192-192zM384 448c0 70.692 56.815 128 128 128 70.692 0 128-56.815 128-128 0-70.692-56.815-128-128-128-70.692 0-128 56.815-128 128z" />
12
- <glyph unicode="&#xe602;" d="M544 416v-375.294c0-17.673-14.327-32-32-32s-32 14.327-32 32v375.294h-375.294c-17.673 0-32 14.327-32 32s14.327 32 32 32h375.294v375.294c0 17.673 14.327 32 32 32s32-14.327 32-32v-375.294h375.294c17.673 0 32-14.327 32-32s-14.327-32-32-32h-375.294z" />
13
- <glyph unicode="&#xe603;" d="M882.24 449.498l-235.855 234.241c-12.497 12.411-12.497 32.534 0 44.945s32.758 12.411 45.255 0l253.704-251.968c1.872-1.201 3.645-2.616 5.284-4.244 12.497-12.411 12.497-32.534 0-44.945l-257.992-256.226c-12.497-12.411-32.758-12.411-45.255 0s-12.497 32.534 0 44.945l234.859 233.252zM67.842 461.229c-6.562-12.128-4.719-27.599 5.53-37.848 2.863-2.863 6.133-5.070 9.624-6.621l249.364-249.364c12.497-12.497 32.758-12.497 45.255 0s12.497 32.758 0 45.255l-234.859 234.859 233.863 233.863c12.497 12.497 12.497 32.758 0 45.255s-32.758 12.497-45.255 0l-251.712-251.712c-1.872-1.209-3.645-2.634-5.284-4.273-2.805-2.805-4.981-6.002-6.527-9.414v0 0z" />
14
- </font></defs></svg>
@@ -1,36 +0,0 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Copyright (C) 2012 by original authors @ fontello.com</metadata>
5
- <defs>
6
- <font id="fontello" horiz-adv-x="1000" >
7
- <font-face font-family="fontello" font-weight="400" font-stretch="normal" units-per-em="1000" ascent="850" descent="-150" />
8
- <missing-glyph horiz-adv-x="1000" />
9
- <glyph glyph-name="location" unicode="&#xe815;" d="M429 493q0 59-42 101t-101 42-101-42-42-101 42-101 101-42 101 42 42 101z m143 0q0-61-18-100l-203-432q-9-18-27-29t-38-11-38 11-26 29l-204 432q-18 39-18 100 0 118 84 202t202 84 202-84 84-202z" horiz-adv-x="571.429" />
10
- <glyph glyph-name="fit" unicode="&#xe80f;" d="M429 314l0-250q0-15-11-25t-25-11-25 11l-80 80-185-185q-6-6-13-6t-13 6l-64 64q-6 6-6 13t6 13l185 185-80 80q-11 11-11 25t11 25 25 11l250 0q15 0 25-11t11-25z m421 375q0-7-6-13l-185-185 80-80q11-11 11-25t-11-25-25-11l-250 0q-15 0-25 11t-11 25l0 250q0 15 11 25t25 11 25-11l80-80 185 185q6 6 13 6t13-6l64-64q6-6 6-13z" horiz-adv-x="857.143" />
11
- <glyph glyph-name="bold" unicode="&#xe805;" d="M310 1q42-18 78-18 73 0 121 23t68 63q21 39 21 101 0 64-23 100-32 52-79 70-45 18-138 18-41 0-56-6l0-80-1-97 2-151q0-8 7-25z m-8 416q24-4 61-4 98 0 147 36t50 125q0 62-47 104t-142 42q-29 0-73-7 0-25 1-43 4-68 3-156l-1-55q0-24 1-43z m-302-496l1 52q25 5 38 7 43 7 69 17 9 15 12 28 5 37 5 108l-1 277q-3 143-5 225-1 49-6 61-1 2-7 7-10 7-39 8-17 1-64 7l-2 46 145 3 212 7 25 1q3 0 8 0t8 0q1 0 12 0t23 0l41 0q49 0 107-15 24-7 54-22 32-16 57-42t36-58 12-68q0-39-18-71t-53-59q-15-11-84-43 99-23 149-81 51-59 51-132 0-42-16-90-12-35-40-65-37-40-78-60t-113-33q-46-8-110-6l-110 2q-47 1-166-6-18-2-152-6z" horiz-adv-x="785.714" />
12
- <glyph glyph-name="italic" unicode="&#xe806;" d="M0-77l9 47q2 1 43 11 42 11 65 22 16 21 23 56l15 78 31 150 7 36q4 25 9 47t9 37 7 26 5 17 2 6l16 88 9 35 12 75 4 28 0 21q-23 12-80 16-16 1-21 2l11 57 177-8q22-1 41-1 37 0 119 5 18 1 38 3t20 1q-1-11-3-21-4-16-7-28-31-11-61-17-36-9-56-17-7-17-13-49-5-25-7-46-25-111-37-171l-34-174-21-88-24-131-7-25q-1-4 1-15 36-8 66-12 20-3 37-6-1-16-4-32-4-17-5-23-10 0-13-1-13-1-23-1-5 0-16 2t-81 9l-110 1q-23 1-97-6-41-4-55-5z" horiz-adv-x="571.429" />
13
- <glyph glyph-name="justifyleft" unicode="&#xe80a;" d="M1000 100l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m-214 214l0-71q0-15-11-25t-25-11l-714 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l714 0q15 0 25-11t11-25z m143 214l0-71q0-15-11-25t-25-11l-857 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l857 0q15 0 25-11t11-25z m-214 214l0-71q0-15-11-25t-25-11l-643 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l643 0q15 0 25-11t11-25z" horiz-adv-x="1000" />
14
- <glyph glyph-name="justifycenter" unicode="&#xe80b;" d="M1000 100l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m-214 214l0-71q0-15-11-25t-25-11l-500 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l500 0q15 0 25-11t11-25z m143 214l0-71q0-15-11-25t-25-11l-786 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l786 0q15 0 25-11t11-25z m-214 214l0-71q0-15-11-25t-25-11l-357 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l357 0q15 0 25-11t11-25z" horiz-adv-x="1000" />
15
- <glyph glyph-name="justifyright" unicode="&#xe80c;" d="M1000 100l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-714 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l714 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-857 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l857 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-643 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l643 0q15 0 25-11t11-25z" horiz-adv-x="1000" />
16
- <glyph glyph-name="justifyfull" unicode="&#xe80d;" d="M1000 100l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z m0 214l0-71q0-15-11-25t-25-11l-929 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l929 0q15 0 25-11t11-25z" horiz-adv-x="1000" />
17
- <glyph glyph-name="outdent" unicode="&#xe800;" d="M214 546l0-321q0-7-5-13t-13-5q-8 0-13 5l-161 161q-5 5-5 13t5 13l161 161q5 5 13 5 7 0 13-5t5-13z m786-429l0-107q0-7-5-13t-13-5l-964 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l964 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-607 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l607 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-607 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l607 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-964 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l964 0q7 0 13-5t5-13z" horiz-adv-x="1000" />
18
- <glyph glyph-name="indent" unicode="&#xe801;" d="M196 386q0-8-5-13l-161-161q-5-5-13-5-7 0-13 5t-5 13l0 321q0 7 5 13t13 5q8 0 13-5l161-161q5-5 5-13z m804-268l0-107q0-7-5-13t-13-5l-964 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l964 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-607 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l607 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-607 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l607 0q7 0 13-5t5-13z m0 214l0-107q0-7-5-13t-13-5l-964 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l964 0q7 0 13-5t5-13z" horiz-adv-x="1000" />
19
- <glyph glyph-name="mode" unicode="&#xe813;" d="M429 46l0 607q-83 0-152-41t-110-110-41-152 41-152 110-110 152-41z m429 304q0-117-57-215t-156-156-215-57-215 57-156 156-57 215 57 215 156 156 215 57 215-57 156-156 57-215z" horiz-adv-x="857.143" />
20
- <glyph glyph-name="fullscreen" unicode="&#xe80e;" d="M716 548l-198-198 198-198 80 80q16 17 39 8 22-9 22-33l0-250q0-15-11-25t-25-11l-250 0q-23 0-33 22-9 22 8 39l80 80-198 198-198-198 80-80q17-17 8-39t-33-22l-250 0q-15 0-25 11t-11 25l0 250q0 23 22 33 22 9 39-8l80-80 198 198-198 198-80-80q-11-11-25-11-7 0-13 3-22 9-22 33l0 250q0 15 11 25t25 11l250 0q23 0 33-22 9-22-8-39l-80-80 198-198 198 198-80 80q-17 17-8 39t33 22l250 0q15 0 25-11t11-25l0-250q0-23-22-33-7-3-14-3-15 0-25 11z" horiz-adv-x="857.143" />
21
- <glyph glyph-name="insertunorderedlist" unicode="&#xe802;" d="M214 64q0-45-31-76t-76-31-76 31-31 76 31 76 76 31 76-31 31-76z m0 286q0-45-31-76t-76-31-76 31-31 76 31 76 76 31 76-31 31-76z m786-232l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l679 0q7 0 13-5t5-13z m-786 518q0-45-31-76t-76-31-76 31-31 76 31 76 76 31 76-31 31-76z m786-232l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l679 0q7 0 13-5t5-13z m0 286l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l679 0q7 0 13-5t5-13z" horiz-adv-x="1000" />
22
- <glyph glyph-name="insertorderedlist" unicode="&#xe803;" d="M213-54q0-45-30-70t-76-26q-59 0-96 37l32 49q27-25 59-25 16 0 28 8t12 24q0 36-59 31l-15 31q4 6 18 24t24 30 21 21l0 1q-9 0-27-1t-27-1l0-30-59 0 0 85 186 0 0-49-53-64q28-7 45-27t17-49z m1 350l0-89-202 0q-3 20-3 30 0 28 13 52t32 38 37 27 32 24 13 25q0 14-8 21t-22 8q-26 0-45-32l-47 33q13 28 40 44t59 16q41 0 69-23t28-63q0-28-19-51t-42-36-42-28-20-29l71 0 0 33 59 0z m786-178l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 8 5 13t13 5l679 0q7 0 13-5t5-13z m-786 502l0-55-187 0 0 55 60 0q0 23 0 68t0 68l0 7-1 0q-4-9-28-30l-40 42 76 71 59 0 0-225 60 0z m786-216l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 8 5 13t13 5l679 0q7 0 13-5t5-13z m0 286l0-107q0-7-5-13t-13-5l-679 0q-7 0-13 5t-5 13l0 107q0 7 5 13t13 5l679 0q7 0 13-5t5-13z" horiz-adv-x="1000" />
23
- <glyph glyph-name="strikethrough" unicode="&#xe807;" d="M982 350q8 0 13-5t5-13l0-36q0-8-5-13t-13-5l-964 0q-8 0-13 5t-5 13l0 36q0 8 5 13t13 5l964 0z m-713 36q-16 20-28 45-27 54-27 105 0 101 75 172 74 71 219 71 28 0 93-11 37-7 99-27 6-21 12-66 8-69 8-102 0-10-3-25l-7-2-47 3-8 1q-28 83-57 114-49 51-117 51-64 0-102-33-37-32-37-81 0-41 37-78t156-72q39-11 97-37 32-16 53-29l-415 0z m283-143l229 0q4-22 4-51 0-62-23-118-13-31-40-58-21-20-61-45-45-27-85-37-45-12-113-12-64 0-109 13l-78 22q-32 9-40 16-4 4-4 12l0 7q0 60-1 87-1 17 0 38l1 21 0 25 57 1q8-19 17-40t13-31 7-15q20-32 45-52 24-20 59-32 33-12 74-12 36 0 78 15 43 15 68 48 26 34 26 72 0 47-45 88-19 16-76 40z" horiz-adv-x="1000" />
24
- <glyph glyph-name="underline" unicode="&#xe804;" d="M27 726q-21 1-25 2l-2 49q7 1 22 1 33 0 62-2 74-4 93-4 48 0 94 2 65 2 81 3 31 0 48 1l-1-8 1-36 0-5q-33-5-69-5-33 0-44-14-7-8-7-74 0-7 0-18t0-14l1-128 8-156q3-69 28-113 20-33 54-51 49-26 99-26 58 0 107 16 31 10 55 28 27 20 36 36 20 31 30 64 12 41 12 128 0 44-2 71t-6 68-8 89l-2 33q-3 37-13 49-19 20-43 19l-56-1-8 2 1 48 47 0 114-6q42-2 109 6l10-1q3-21 3-28 0-4-2-17-25-7-47-7-41-6-44-9-8-8-8-23 0-4 1-15t1-17q4-11 12-221 3-109-8-170-8-42-23-68-21-36-62-69-42-32-102-50-61-18-142-18-93 0-158 26-66 26-100 68t-46 109q-9 45-9 132l0 186q0 105-9 119-14 20-82 22z m830-786l0 36q0 8-5 13t-13 5l-821 0q-8 0-13-5t-5-13l0-36q0-8 5-13t13-5l821 0q8 0 13 5t5 13z" horiz-adv-x="857.143" />
25
- <glyph glyph-name="blockquote" unicode="&#xe814;" d="M429 671l0-393q0-58-23-111t-61-91-91-61-111-23l-36 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l36 0q59 0 101 42t42 101l0 18q0 22-16 38t-38 16l-125 0q-45 0-76 31t-31 76l0 214q0 45 31 76t76 31l214 0q45 0 76-31t31-76z m500 0l0-393q0-58-23-111t-61-91-91-61-111-23l-36 0q-15 0-25 11t-11 25l0 71q0 15 11 25t25 11l36 0q59 0 101 42t42 101l0 18q0 22-16 38t-38 16l-125 0q-45 0-76 31t-31 76l0 214q0 45 31 76t76 31l214 0q45 0 76-31t31-76z" horiz-adv-x="928.571" />
26
- <glyph glyph-name="undo" unicode="&#xe817;" d="M1000 225q0-93-71-252-2-4-6-13t-8-17-7-12q-7-9-16-9-8 0-13 6t-5 14q0 5 1 15t1 13q3 38 3 69 0 56-10 101t-27 77-45 56-59 39-74 24-86 12-98 3l-125 0 0-143q0-15-11-25t-25-11-25 11l-286 286q-11 11-11 25t11 25l286 286q11 11 25 11t25-11 11-25l0-143 125 0q398 0 488-225 30-75 30-186z" horiz-adv-x="1000" />
27
- <glyph glyph-name="code" unicode="&#xe816;" d="M344 69l-28-28q-6-6-13-6t-13 6l-260 260q-6 6-6 13t6 13l260 260q6 6 13 6t13-6l28-28q6-6 6-13t-6-13l-219-219 219-219q6-6 6-13t-6-13z m330 595l-208-720q-2-7-9-11t-13-1l-35 9q-7 2-11 9t-1 14l208 720q2 7 9 11t13 1l35-9q7-2 11-9t1-14z m367-363l-260-260q-6-6-13-6t-13 6l-28 28q-6 6-6 13t6 13l219 219-219 219q-6 6-6 13t6 13l28 28q6 6 13 6t13-6l260-260q6-6 6-13t-6-13z" horiz-adv-x="1071.429" />
28
- <glyph glyph-name="unlink" unicode="&#xe811;" d="M245 141l-143-143q-6-5-13-5t-13 5q-5 6-5 13t5 13l143 143q6 5 13 5t13-5q5-6 5-13t-5-13z m94-23l0-179q0-8-5-13t-13-5-13 5-5 13l0 179q0 8 5 13t13 5 13-5 5-13z m-125 125q0-8-5-13t-13-5l-179 0q-8 0-13 5t-5 13 5 13 13 5l179 0q8 0 13-5t5-13z m705-71q0-67-47-113l-82-81q-46-46-113-46-68 0-114 47l-186 187q-12 12-23 31l133 10 152-153q15-15 38-15t38 15l82 81q16 16 16 37 0 22-16 38l-153 153 10 133q20-12 31-23l187-187q47-48 47-114z m-344 404l-133-10-152 153q-16 16-38 16t-38-15l-82-81q-16-16-16-37 0-22 16-38l153-153-10-134q-20 12-31 23l-187 187q-47 48-47 114 0 67 47 113l82 81q46 46 113 46 68 0 114-47l186-187q12-12 23-31z m353-47q0-8-5-13t-13-5l-179 0q-8 0-13 5t-5 13 5 13 13 5l179 0q8 0 13-5t5-13z m-304 304l0-179q0-8-5-13t-13-5-13 5-5 13l0 179q0 8 5 13t13 5 13-5 5-13z m227-84l-143-143q-6-5-13-5t-13 5q-5 6-5 13t5 13l143 143q6 5 13 5t13-5q5-6 5-13t-5-13z" horiz-adv-x="928.571" />
29
- <glyph glyph-name="superscript" unicode="&#xe808;" d="M501 86l0-93-138 0-89 141-13 23q-4 5-6 12l-2 0-5-12q-6-11-14-25l-86-140-144 0 0 93 71 0 110 162-103 152-76 0 0 94 154 0 78-127q1-2 13-23 4-5 6-12l2 0q2 5 6 12l14 23 78 127 143 0 0-94-70 0-103-149 114-165 61 0z m355 379l0-115-287 0-2 15q-2 16-2 26 0 36 15 65t36 48 47 36 47 30 36 30 15 36q0 21-16 35t-39 14q-28 0-54-22-8-6-20-21l-59 51q15 21 35 37 46 36 105 36 61 0 99-33t38-88q0-31-14-57t-35-43-45-33-46-28-37-29-17-35l129 0 0 45 70 0z" horiz-adv-x="857.143" />
30
- <glyph glyph-name="subscript" unicode="&#xe809;" d="M501 86l0-93-138 0-89 141-13 23q-4 5-6 12l-2 0-5-12q-6-11-14-25l-86-140-144 0 0 93 71 0 110 162-103 152-76 0 0 94 154 0 78-127q1-2 13-23 4-5 6-12l2 0q2 5 6 12l14 23 78 127 143 0 0-94-70 0-103-149 114-165 61 0z m357-121l0-115-287 0-2 15q-2 25-2 26 0 36 15 65t36 48 47 36 47 30 36 30 15 36q0 21-16 35t-39 14q-28 0-54-22-8-6-20-21l-59 51q15 21 35 37 45 36 105 36 61 0 99-33t38-88q0-37-19-66t-47-48-56-35-49-35-23-41l129 0 0 45 70 0z" horiz-adv-x="857.143" />
31
- <glyph glyph-name="inserthorizontalrule" unicode="&#xe818;" d="M214 439l0-107q0-22-16-38t-38-16l-107 0q-22 0-38 16t-16 38l0 107q0 22 16 38t38 16l107 0q22 0 38-16t16-38z m286 0l0-107q0-22-16-38t-38-16l-107 0q-22 0-38 16t-16 38l0 107q0 22 16 38t38 16l107 0q22 0 38-16t16-38z m286 0l0-107q0-22-16-38t-38-16l-107 0q-22 0-38 16t-16 38l0 107q0 22 16 38t38 16l107 0q22 0 38-16t16-38z" horiz-adv-x="785.714" />
32
- <glyph glyph-name="pin" unicode="&#xe812;" d="M268 368l0 250q0 8-5 13t-13 5-13-5-5-13l0-250q0-8 5-13t13-5 13 5 5 13z m375-196q0-15-11-25t-25-11l-239 0-28-270q-1-7-6-11t-11-5l-1 0q-15 0-18 15l-42 271-225 0q-15 0-25 11t-11 25q0 69 44 124t99 55l0 286q-29 0-50 21t-21 50 21 50 50 21l357 0q29 0 50-21t21-50-21-50-50-21l0-286q55 0 99-55t44-124z" horiz-adv-x="642.857" />
33
- <glyph glyph-name="createlink" unicode="&#xe810;" d="M812 171q0 22-16 38l-116 116q-16 16-38 16-23 0-40-18 2-2 11-10t12-12 8-11 7-14 2-15q0-22-16-38t-38-16q-8 0-15 2t-14 7-11 8-12 12-10 11q-18-17-18-41 0-22 16-38l115-116q15-15 38-15 22 0 38 15l82 81q16 16 16 37z m-392 393q0 22-16 38l-115 116q-16 16-38 16t-38-15l-82-81q-16-16-16-37 0-22 16-38l116-116q15-15 38-15t40 17q-2 2-11 10t-12 12-8 11-7 14-2 15q0 22 16 38t38 16q8 0 15-2t14-7 11-8 12-12 10-11q18 17 18 41z m499-393q0-67-47-113l-82-81q-46-46-113-46-68 0-114 47l-115 116q-46 46-46 113 0 69 49 117l-49 49q-48-49-116-49-67 0-114 47l-116 116q-47 47-47 114t47 113l82 81q46 46 113 46 68 0 114-47l115-116q46-46 46-113 0-69-49-117l49-49q48 49 116 49 67 0 114-47l116-116q47-47 47-114z" horiz-adv-x="928.571" />
34
- </font>
35
- </defs>
36
- </svg>
@@ -1,2610 +0,0 @@
1
- (function() {
2
- window.Dante = {
3
- Editor: {
4
- ToolTip: {},
5
- PopOver: {},
6
- Menu: {}
7
- },
8
- defaults: {
9
- image_placeholder: '../images/dante/media-loading-placeholder.png'
10
- },
11
- version: "0.0.7"
12
- };
13
-
14
- }).call(this);
15
- (function() {
16
- var LINE_HEIGHT, is_caret_at_end_of_node, is_caret_at_start_of_node, utils;
17
-
18
- String.prototype.killWhiteSpace = function() {
19
- return this.replace(/\s/g, '');
20
- };
21
-
22
- String.prototype.reduceWhiteSpace = function() {
23
- return this.replace(/\s+/g, ' ');
24
- };
25
-
26
- utils = {};
27
-
28
- window.Dante.utils = utils;
29
-
30
- utils.log = function(message, force) {
31
- if (window.debugMode || force) {
32
- return console.log(message);
33
- }
34
- };
35
-
36
- utils.getBase64Image = function(img) {
37
- var canvas, ctx, dataURL;
38
- canvas = document.createElement("canvas");
39
- canvas.width = img.width;
40
- canvas.height = img.height;
41
- ctx = canvas.getContext("2d");
42
- ctx.drawImage(img, 0, 0);
43
- dataURL = canvas.toDataURL("image/png");
44
- return dataURL;
45
- };
46
-
47
- utils.generateUniqueName = function() {
48
- return Math.random().toString(36).slice(8);
49
- };
50
-
51
- utils.saveSelection = function() {
52
- var i, len, ranges, sel;
53
- if (window.getSelection) {
54
- sel = window.getSelection();
55
- if (sel.getRangeAt && sel.rangeCount) {
56
- ranges = [];
57
- i = 0;
58
- len = sel.rangeCount;
59
- while (i < len) {
60
- ranges.push(sel.getRangeAt(i));
61
- ++i;
62
- }
63
- return ranges;
64
- }
65
- } else {
66
- if (document.selection && document.selection.createRange) {
67
- return document.selection.createRange();
68
- }
69
- }
70
- return null;
71
- };
72
-
73
- utils.restoreSelection = function(savedSel) {
74
- var i, len, sel;
75
- if (savedSel) {
76
- if (window.getSelection) {
77
- sel = window.getSelection();
78
- sel.removeAllRanges();
79
- i = 0;
80
- len = savedSel.length;
81
- while (i < len) {
82
- sel.addRange(savedSel[i]);
83
- ++i;
84
- }
85
- } else {
86
- if (document.selection && savedSel.select) {
87
- savedSel.select();
88
- }
89
- }
90
- }
91
- };
92
-
93
- utils.getNode = function() {
94
- var container, range, sel;
95
- range = void 0;
96
- sel = void 0;
97
- container = void 0;
98
- if (document.selection && document.selection.createRange) {
99
- range = document.selection.createRange();
100
- return range.parentElement();
101
- } else if (window.getSelection) {
102
- sel = window.getSelection();
103
- if (sel.getRangeAt) {
104
- if (sel.rangeCount > 0) {
105
- range = sel.getRangeAt(0);
106
- }
107
- } else {
108
- range = document.createRange();
109
- range.setStart(sel.anchorNode, sel.anchorOffset);
110
- range.setEnd(sel.focusNode, sel.focusOffset);
111
- if (range.collapsed !== sel.isCollapsed) {
112
- range.setStart(sel.focusNode, sel.focusOffset);
113
- range.setEnd(sel.anchorNode, sel.anchorOffset);
114
- }
115
- }
116
- if (range) {
117
- container = range.commonAncestorContainer;
118
- if (container.nodeType === 3) {
119
- return container.parentNode;
120
- } else {
121
- return container;
122
- }
123
- }
124
- }
125
- };
126
-
127
- utils.getSelectionDimensions = function() {
128
- var height, left, range, rect, sel, top, width;
129
- sel = document.selection;
130
- range = void 0;
131
- width = 0;
132
- height = 0;
133
- left = 0;
134
- top = 0;
135
- if (sel) {
136
- if (sel.type !== "Control") {
137
- range = sel.createRange();
138
- width = range.boundingWidth;
139
- height = range.boundingHeight;
140
- }
141
- } else if (window.getSelection) {
142
- sel = window.getSelection();
143
- if (sel.rangeCount) {
144
- range = sel.getRangeAt(0).cloneRange();
145
- if (range.getBoundingClientRect) {
146
- rect = range.getBoundingClientRect();
147
- width = rect.right - rect.left;
148
- height = rect.bottom - rect.top;
149
- }
150
- }
151
- }
152
- return {
153
- width: width,
154
- height: height,
155
- top: rect.top,
156
- left: rect.left
157
- };
158
- };
159
-
160
- utils.getCaretPosition = function(editableDiv) {
161
- var caretPos, containerEl, range, sel, tempEl, tempRange;
162
- caretPos = 0;
163
- containerEl = null;
164
- sel = void 0;
165
- range = void 0;
166
- if (window.getSelection) {
167
- sel = window.getSelection();
168
- if (sel.rangeCount) {
169
- range = sel.getRangeAt(0);
170
- if (range.commonAncestorContainer.parentNode === editableDiv) {
171
- caretPos = range.endOffset;
172
- }
173
- }
174
- } else if (document.selection && document.selection.createRange) {
175
- range = document.selection.createRange();
176
- if (range.parentElement() === editableDiv) {
177
- tempEl = document.createElement("span");
178
- editableDiv.insertBefore(tempEl, editableDiv.firstChild);
179
- tempRange = range.duplicate();
180
- tempRange.moveToElementText(tempEl);
181
- tempRange.setEndPoint("EndToEnd", range);
182
- caretPos = tempRange.text.length;
183
- }
184
- }
185
- return caretPos;
186
- };
187
-
188
- utils.isElementInViewport = function(el) {
189
- var rect;
190
- if (typeof jQuery === "function" && el instanceof jQuery) {
191
- el = el[0];
192
- }
193
- rect = el.getBoundingClientRect();
194
- return rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth);
195
- };
196
-
197
- LINE_HEIGHT = 20;
198
-
199
- is_caret_at_start_of_node = function(node, range) {
200
- var pre_range;
201
- pre_range = document.createRange();
202
- pre_range.selectNodeContents(node);
203
- pre_range.setEnd(range.startContainer, range.startOffset);
204
- return pre_range.toString().trim().length === 0;
205
- };
206
-
207
- is_caret_at_end_of_node = function(node, range) {
208
- var post_range;
209
- post_range = document.createRange();
210
- post_range.selectNodeContents(node);
211
- post_range.setStart(range.endContainer, range.endOffset);
212
- return post_range.toString().trim().length === 0;
213
- };
214
-
215
- $.fn.editableIsCaret = function() {
216
- return window.getSelection().type === 'Caret';
217
- };
218
-
219
- $.fn.editableRange = function() {
220
- var sel;
221
- sel = window.getSelection();
222
- if (!(sel.rangeCount > 0)) {
223
- return;
224
- }
225
- return sel.getRangeAt(0);
226
- };
227
-
228
- $.fn.editableCaretRange = function() {
229
- if (!this.editableIsCaret()) {
230
- return;
231
- }
232
- return this.editableRange();
233
- };
234
-
235
- $.fn.editableSetRange = function(range) {
236
- var sel;
237
- sel = window.getSelection();
238
- if (sel.rangeCount > 0) {
239
- sel.removeAllRanges();
240
- }
241
- return sel.addRange(range);
242
- };
243
-
244
- $.fn.editableFocus = function(at_start) {
245
- var range, sel;
246
- if (at_start == null) {
247
- at_start = true;
248
- }
249
- if (!this.attr('contenteditable')) {
250
- return;
251
- }
252
- sel = window.getSelection();
253
- if (sel.rangeCount > 0) {
254
- sel.removeAllRanges();
255
- }
256
- range = document.createRange();
257
- range.selectNodeContents(this[0]);
258
- range.collapse(at_start);
259
- return sel.addRange(range);
260
- };
261
-
262
- $.fn.editableCaretAtStart = function() {
263
- var range;
264
- range = this.editableRange();
265
- if (!range) {
266
- return false;
267
- }
268
- return is_caret_at_start_of_node(this[0], range);
269
- };
270
-
271
- $.fn.editableCaretAtEnd = function() {
272
- var range;
273
- range = this.editableRange();
274
- if (!range) {
275
- return false;
276
- }
277
- return is_caret_at_end_of_node(this[0], range);
278
- };
279
-
280
- $.fn.editableCaretOnFirstLine = function() {
281
- var ctop, etop, range;
282
- range = this.editableRange();
283
- if (!range) {
284
- return false;
285
- }
286
- if (is_caret_at_start_of_node(this[0], range)) {
287
- return true;
288
- } else if (is_caret_at_end_of_node(this[0], range)) {
289
- ctop = this[0].getBoundingClientRect().bottom - LINE_HEIGHT;
290
- } else {
291
- ctop = range.getClientRects()[0].top;
292
- }
293
- etop = this[0].getBoundingClientRect().top;
294
- return ctop < etop + LINE_HEIGHT;
295
- };
296
-
297
- $.fn.editableCaretOnLastLine = function() {
298
- var cbtm, ebtm, range;
299
- range = this.editableRange();
300
- if (!range) {
301
- return false;
302
- }
303
- if (is_caret_at_end_of_node(this[0], range)) {
304
- return true;
305
- } else if (is_caret_at_start_of_node(this[0], range)) {
306
- cbtm = this[0].getBoundingClientRect().top + LINE_HEIGHT;
307
- } else {
308
- cbtm = range.getClientRects()[0].bottom;
309
- }
310
- ebtm = this[0].getBoundingClientRect().bottom;
311
- return cbtm > ebtm - LINE_HEIGHT;
312
- };
313
-
314
- $.fn.exists = function() {
315
- return this.length > 0;
316
- };
317
-
318
- }).call(this);
319
- (function() {
320
- Dante.View = (function() {
321
- function View(opts) {
322
- if (opts == null) {
323
- opts = {};
324
- }
325
- if (opts.el) {
326
- this.el = opts.el;
327
- }
328
- this._ensureElement();
329
- this.initialize.apply(this, arguments);
330
- this._ensureEvents();
331
- }
332
-
333
- View.prototype.initialize = function(opts) {
334
- if (opts == null) {
335
- opts = {};
336
- }
337
- };
338
-
339
- View.prototype.events = function() {};
340
-
341
- View.prototype.render = function() {
342
- return this;
343
- };
344
-
345
- View.prototype.remove = function() {
346
- this._removeElement();
347
- this.stopListening();
348
- return this;
349
- };
350
-
351
- View.prototype._removeElement = function() {
352
- return this.$el.remove();
353
- };
354
-
355
- View.prototype.setElement = function(element) {
356
- this._setElement(element);
357
- return this;
358
- };
359
-
360
- View.prototype.setEvent = function(opts) {
361
- if (!_.isEmpty(opts)) {
362
- return _.each(opts, (function(_this) {
363
- return function(f, key) {
364
- var element, func, key_arr;
365
- key_arr = key.split(" ");
366
- if (_.isFunction(f)) {
367
- func = f;
368
- } else if (_.isString(f)) {
369
- func = _this[f];
370
- } else {
371
- throw "error event needs a function or string";
372
- }
373
- element = key_arr.length > 1 ? key_arr.splice(1, 3).join(" ") : null;
374
- return $(_this.el).on(key_arr[0], element, _.bind(func, _this));
375
- };
376
- })(this));
377
- }
378
- };
379
-
380
- View.prototype._ensureElement = function() {
381
- return this.setElement(_.result(this, 'el'));
382
- };
383
-
384
- View.prototype._ensureEvents = function() {
385
- return this.setEvent(_.result(this, 'events'));
386
- };
387
-
388
- View.prototype._setElement = function(el) {
389
- this.$el = el instanceof $ ? el : $(el);
390
- return this.el = this.$el[0];
391
- };
392
-
393
- return View;
394
-
395
- })();
396
-
397
- }).call(this);
398
- (function() {
399
- var utils,
400
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
401
- __hasProp = {}.hasOwnProperty,
402
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
403
-
404
- utils = Dante.utils;
405
-
406
- Dante.Editor = (function(_super) {
407
- __extends(Editor, _super);
408
-
409
- function Editor() {
410
- this.setupFirstAndLast = __bind(this.setupFirstAndLast, this);
411
- this.addClassesToElement = __bind(this.addClassesToElement, this);
412
- this.handlePaste = __bind(this.handlePaste, this);
413
- this.handleArrowForKeyDown = __bind(this.handleArrowForKeyDown, this);
414
- this.handleArrow = __bind(this.handleArrow, this);
415
- this.handleMouseUp = __bind(this.handleMouseUp, this);
416
- this.selection = __bind(this.selection, this);
417
- this.render = __bind(this.render, this);
418
- this.restart = __bind(this.restart, this);
419
- this.start = __bind(this.start, this);
420
- this.appendInitialContent = __bind(this.appendInitialContent, this);
421
- this.appendMenus = __bind(this.appendMenus, this);
422
- this.template = __bind(this.template, this);
423
- this.initialize = __bind(this.initialize, this);
424
- return Editor.__super__.constructor.apply(this, arguments);
425
- }
426
-
427
- Editor.prototype.events = {
428
- "mouseup": "handleMouseUp",
429
- "keydown": "handleKeyDown",
430
- "keyup": "handleKeyUp",
431
- "paste": "handlePaste",
432
- "dblclick": "handleDblclick",
433
- "dragstart": "handleDrag",
434
- "drop": "handleDrag",
435
- "click .graf--figure .aspectRatioPlaceholder": "handleGrafFigureSelectImg",
436
- "click .graf--figure figcaption": "handleGrafFigureSelectCaption",
437
- "keyup .graf--figure figcaption": "handleGrafCaptionTyping",
438
- "mouseover .markup--anchor": "displayPopOver",
439
- "mouseout .markup--anchor": "hidePopOver"
440
- };
441
-
442
- Editor.prototype.initialize = function(opts) {
443
- if (opts == null) {
444
- opts = {};
445
- }
446
- this.editor_options = opts;
447
- this.initial_html = $(this.el).html();
448
- this.current_range = null;
449
- this.current_node = null;
450
- this.el = opts.el || "#editor";
451
- this.upload_url = opts.upload_url || "/uploads.json";
452
- this.oembed_url = opts.oembed_url || "http://api.embed.ly/1/oembed?url=";
453
- this.extract_url = opts.extract_url || "http://api.embed.ly/1/extract?key=86c28a410a104c8bb58848733c82f840&url=";
454
- this.default_loading_placeholder = opts.default_loading_placeholder || Dante.defaults.image_placeholder;
455
- this.store_url = opts.store_url;
456
- this.spell_check = opts.spellcheck || false;
457
- this.disable_title = opts.disable_title || false;
458
- this.store_interval = opts.store_interval || 15000;
459
- window.debugMode = opts.debug || false;
460
- if (window.debugMode) {
461
- $(this.el).addClass("debug");
462
- }
463
- if (localStorage.getItem('contenteditable')) {
464
- $(this.el).html(localStorage.getItem('contenteditable'));
465
- }
466
- this.store();
467
- this.title_placeholder = "<span class='defaultValue defaultValue--root'>Title</span><br>";
468
- this.body_placeholder = "<span class='defaultValue defaultValue--root'>Tell your story&hellip;</span><br>";
469
- this.embed_placeholder = "<span class='defaultValue defaultValue--prompt'>Paste a YouTube, Vine, Vimeo, or other video link, and press Enter</span><br>";
470
- return this.extract_placeholder = "<span class='defaultValue defaultValue--prompt'>Paste a link to embed content from another site (e.g. Twitter) and press Enter</span><br>";
471
- };
472
-
473
- Editor.prototype.store = function() {
474
- if (!this.store_url) {
475
- return;
476
- }
477
- return setTimeout((function(_this) {
478
- return function() {
479
- return _this.checkforStore();
480
- };
481
- })(this), this.store_interval);
482
- };
483
-
484
- Editor.prototype.checkforStore = function() {
485
- if (this.content === this.getContent()) {
486
- utils.log("content not changed skip store");
487
- return this.store();
488
- } else {
489
- utils.log("content changed! update");
490
- this.content = this.getContent();
491
- return $.ajax({
492
- url: this.store_url,
493
- method: "post",
494
- data: this.getContent(),
495
- success: function(res) {
496
- utils.log("store!");
497
- return utils.log(res);
498
- },
499
- complete: (function(_this) {
500
- return function(jxhr) {
501
- return _this.store();
502
- };
503
- })(this)
504
- });
505
- }
506
- };
507
-
508
- Editor.prototype.getContent = function() {
509
- return $(this.el).find(".section-inner").html();
510
- };
511
-
512
- Editor.prototype.renderTitle = function() {
513
- return "<h3 class='graf graf--h3'>" + this.title_placeholder + " </h3>";
514
- };
515
-
516
- Editor.prototype.template = function() {
517
- return "<section class='section--first section--last'> <div class='section-divider layoutSingleColumn'> <hr class='section-divider'> </div> <div class='section-content'> <div class='section-inner layoutSingleColumn'> " + (this.disable_title ? '' : this.renderTitle()) + " <p class='graf graf--p'>" + this.body_placeholder + "<p> </div> </div> </section>";
518
- };
519
-
520
- Editor.prototype.baseParagraphTmpl = function() {
521
- return "<p class='graf--p' name='" + (utils.generateUniqueName()) + "'><br></p>";
522
- };
523
-
524
- Editor.prototype.appendMenus = function() {
525
- $("<div id='dante-menu' class='dante-menu'></div>").insertAfter(this.el);
526
- $("<div class='inlineTooltip'></div>").insertAfter(this.el);
527
- this.editor_menu = new Dante.Editor.Menu({
528
- editor: this
529
- });
530
- this.tooltip_view = new Dante.Editor.Tooltip({
531
- editor: this
532
- });
533
- this.pop_over = new Dante.Editor.PopOver({
534
- editor: this
535
- });
536
- this.pop_over.render().hide();
537
- return this.tooltip_view.render().hide();
538
- };
539
-
540
- Editor.prototype.appendInitialContent = function() {
541
- $(this.el).find(".section-inner").html(this.initial_html);
542
- return $(this.el).attr("spellcheck", this.spell_check);
543
- };
544
-
545
- Editor.prototype.start = function() {
546
- this.render();
547
- $(this.el).attr("contenteditable", "true");
548
- $(this.el).addClass("postField postField--body editable smart-media-plugin");
549
- $(this.el).wrap("<article class='postArticle'><div class='postContent'><div class='notesSource'></div></div></article>");
550
- this.appendMenus();
551
- if (!_.isEmpty(this.initial_html.trim())) {
552
- this.appendInitialContent();
553
- }
554
- return this.parseInitialMess();
555
- };
556
-
557
- Editor.prototype.restart = function() {
558
- return this.render();
559
- };
560
-
561
- Editor.prototype.render = function() {
562
- this.template();
563
- return $(this.el).html(this.template());
564
- };
565
-
566
- Editor.prototype.getSelectedText = function() {
567
- var text;
568
- text = "";
569
- if (typeof window.getSelection !== "undefined") {
570
- text = window.getSelection().toString();
571
- } else if (typeof document.selection !== "undefined" && document.selection.type === "Text") {
572
- text = document.selection.createRange().text;
573
- }
574
- return text;
575
- };
576
-
577
- Editor.prototype.selection = function() {
578
- selection;
579
- var selection;
580
- if (window.getSelection) {
581
- return selection = window.getSelection();
582
- } else if (document.selection && document.selection.type !== "Control") {
583
- return selection = document.selection;
584
- }
585
- };
586
-
587
- Editor.prototype.getRange = function() {
588
- var editor, range;
589
- editor = $(this.el)[0];
590
- range = selection && selection.rangeCount && selection.getRangeAt(0);
591
- if (!range) {
592
- range = document.createRange();
593
- }
594
- if (!editor.contains(range.commonAncestorContainer)) {
595
- range.selectNodeContents(editor);
596
- range.collapse(false);
597
- }
598
- return range;
599
- };
600
-
601
- Editor.prototype.setRange = function(range) {
602
- range = range || this.current_range;
603
- if (!range) {
604
- range = this.getRange();
605
- range.collapse(false);
606
- }
607
- this.selection().removeAllRanges();
608
- this.selection().addRange(range);
609
- return this;
610
- };
611
-
612
- Editor.prototype.getCharacterPrecedingCaret = function() {
613
- var precedingChar, precedingRange, range, sel;
614
- precedingChar = "";
615
- sel = void 0;
616
- range = void 0;
617
- precedingRange = void 0;
618
- if (window.getSelection) {
619
- sel = window.getSelection();
620
- if (sel.rangeCount > 0) {
621
- range = sel.getRangeAt(0).cloneRange();
622
- range.collapse(true);
623
- range.setStart(this.getNode(), 0);
624
- precedingChar = range.toString().slice(0);
625
- }
626
- } else if ((sel = document.selection) && sel.type !== "Control") {
627
- range = sel.createRange();
628
- precedingRange = range.duplicate();
629
- precedingRange.moveToElementText(containerEl);
630
- precedingRange.setEndPoint("EndToStart", range);
631
- precedingChar = precedingRange.text.slice(0);
632
- }
633
- return precedingChar;
634
- };
635
-
636
- Editor.prototype.isLastChar = function() {
637
- return $(this.getNode()).text().trim().length === this.getCharacterPrecedingCaret().trim().length;
638
- };
639
-
640
- Editor.prototype.isFirstChar = function() {
641
- return this.getCharacterPrecedingCaret().trim().length === 0;
642
- };
643
-
644
- Editor.prototype.isSelectingAll = function(element) {
645
- var a, b;
646
- a = this.getSelectedText().killWhiteSpace().length;
647
- b = $(element).text().killWhiteSpace().length;
648
- return a === b;
649
- };
650
-
651
- Editor.prototype.setRangeAt = function(element, int) {
652
- var range, sel;
653
- if (int == null) {
654
- int = 0;
655
- }
656
- range = document.createRange();
657
- sel = window.getSelection();
658
- range.setStart(element, int);
659
- range.collapse(true);
660
- sel.removeAllRanges();
661
- sel.addRange(range);
662
- return element.focus();
663
- };
664
-
665
- Editor.prototype.setRangeAtText = function(element, int) {
666
- var node, range, sel;
667
- if (int == null) {
668
- int = 0;
669
- }
670
- range = document.createRange();
671
- sel = window.getSelection();
672
- node = element.firstChild;
673
- range.setStart(node, 0);
674
- range.setEnd(node, 0);
675
- range.collapse(true);
676
- sel.removeAllRanges();
677
- sel.addRange(range);
678
- return element.focus();
679
- };
680
-
681
- Editor.prototype.focus = function(focusStart) {
682
- if (!focusStart) {
683
- this.setRange();
684
- }
685
- $(this.el).focus();
686
- return this;
687
- };
688
-
689
- Editor.prototype.focusNode = function(node, range) {
690
- range.setStartAfter(node);
691
- range.setEndBefore(node);
692
- range.collapse(false);
693
- return this.setRange(range);
694
- };
695
-
696
- Editor.prototype.getNode = function() {
697
- var node, range, root;
698
- node = void 0;
699
- root = $(this.el).find(".section-inner")[0];
700
- if (this.selection().rangeCount < 1) {
701
- return;
702
- }
703
- range = this.selection().getRangeAt(0);
704
- node = range.commonAncestorContainer;
705
- if (!node || node === root) {
706
- return null;
707
- }
708
- while (node && (node.nodeType !== 1 || !$(node).hasClass("graf")) && (node.parentNode !== root)) {
709
- node = node.parentNode;
710
- }
711
-
712
- //With the modification to the line above, Im not sure this loop is even necessary
713
- if(!$(node).hasClass("graf--li")){
714
- while (node && (node.parentNode !== root)) {
715
- node = node.parentNode;
716
- }
717
- }
718
- if (root && root.contains(node)) {
719
- return node;
720
- } else {
721
- return null;
722
- }
723
- };
724
-
725
- Editor.prototype.displayMenu = function(sel) {
726
- return setTimeout((function(_this) {
727
- return function() {
728
- var pos;
729
- _this.editor_menu.render();
730
- pos = utils.getSelectionDimensions();
731
- _this.relocateMenu(pos);
732
- return _this.editor_menu.show();
733
- };
734
- })(this), 10);
735
- };
736
-
737
- Editor.prototype.handleDrag = function() {
738
- return false;
739
- };
740
-
741
- Editor.prototype.handleGrafCaptionTyping = function(ev) {
742
- if (_.isEmpty(utils.getNode().textContent.trim())) {
743
- return $(this.getNode()).addClass("is-defaultValue");
744
- } else {
745
- return $(this.getNode()).removeClass("is-defaultValue");
746
- }
747
- };
748
-
749
- Editor.prototype.handleTextSelection = function(anchor_node) {
750
- var text;
751
- this.editor_menu.hide();
752
- text = this.getSelectedText();
753
- if (!$(anchor_node).is(".graf--mixtapeEmbed, .graf--figure") && !_.isEmpty(text.trim())) {
754
- this.current_node = anchor_node;
755
- return this.displayMenu();
756
- }
757
- };
758
-
759
- Editor.prototype.relocateMenu = function(position) {
760
- var height, left, padd, top;
761
- height = this.editor_menu.$el.outerHeight();
762
- padd = this.editor_menu.$el.width() / 2;
763
- top = position.top + $(window).scrollTop() - height;
764
- left = position.left + (position.width / 2) - padd;
765
- return this.editor_menu.$el.offset({
766
- left: left,
767
- top: top
768
- });
769
- };
770
-
771
- Editor.prototype.hidePlaceholder = function(element) {
772
- return $(element).find("span.defaultValue").remove().html("<br>");
773
- };
774
-
775
- Editor.prototype.displayEmptyPlaceholder = function(element) {
776
- $(".graf--first").html(this.title_placeholder);
777
- return $(".graf--last").html(this.body_placeholder);
778
- };
779
-
780
- Editor.prototype.displayPopOver = function(ev) {
781
- return this.pop_over.displayAt(ev);
782
- };
783
-
784
- Editor.prototype.hidePopOver = function(ev) {
785
- return this.pop_over.hide(ev);
786
- };
787
-
788
- Editor.prototype.handleGrafFigureSelectImg = function(ev) {
789
- var element;
790
- utils.log("FIGURE SELECT");
791
- element = ev.currentTarget;
792
- this.markAsSelected(element);
793
- $(element).parent(".graf--figure").addClass("is-selected is-mediaFocused");
794
- return this.selection().removeAllRanges();
795
- };
796
-
797
- Editor.prototype.handleGrafFigureSelectCaption = function(ev) {
798
- var element;
799
- utils.log("FIGCAPTION");
800
- element = ev.currentTarget;
801
- return $(element).parent(".graf--figure").removeClass("is-mediaFocused");
802
- };
803
-
804
- Editor.prototype.handleMouseUp = function(ev) {
805
- var anchor_node;
806
- utils.log("MOUSE UP");
807
- anchor_node = this.getNode();
808
- if (_.isNull(anchor_node)) {
809
- return;
810
- }
811
- this.prev_current_node = anchor_node;
812
- this.handleTextSelection(anchor_node);
813
- this.hidePlaceholder(anchor_node);
814
- this.markAsSelected(anchor_node);
815
- return this.displayTooltipAt(anchor_node);
816
- };
817
-
818
- Editor.prototype.scrollTo = function(node) {
819
- var top;
820
- if (utils.isElementInViewport($(node))) {
821
- return;
822
- }
823
- top = node.offset().top;
824
- return $('html, body').animate({
825
- scrollTop: top
826
- }, 20);
827
- };
828
-
829
- Editor.prototype.handleArrow = function(ev) {
830
- var current_node;
831
- current_node = $(this.getNode());
832
- if (current_node.length > 0) {
833
- this.markAsSelected(current_node);
834
- return this.displayTooltipAt(current_node);
835
- }
836
- };
837
-
838
- Editor.prototype.handleArrowForKeyDown = function(ev) {
839
- var caret_node, current_node, ev_type, n, next_node, num, prev_node;
840
- caret_node = this.getNode();
841
- current_node = $(caret_node);
842
- utils.log(ev);
843
- ev_type = ev.originalEvent.key || ev.originalEvent.keyIdentifier;
844
- utils.log("ENTER ARROW for key " + ev_type);
845
- switch (ev_type) {
846
- case "Down":
847
- if (_.isUndefined(current_node) || !current_node.exists()) {
848
- if ($(".is-selected").exists()) {
849
- current_node = $(".is-selected");
850
- }
851
- }
852
- next_node = current_node.next();
853
- utils.log("NEXT NODE IS " + (next_node.attr('class')));
854
- utils.log("CURRENT NODE IS " + (current_node.attr('class')));
855
- if (!$(current_node).hasClass("graf")) {
856
- return;
857
- }
858
- if (!(current_node.hasClass("graf--figure") || $(current_node).editableCaretOnLastLine())) {
859
- return;
860
- }
861
- utils.log("ENTER ARROW PASSED RETURNS");
862
- if (next_node.hasClass("graf--figure") && caret_node) {
863
- n = next_node.find(".imageCaption");
864
- this.scrollTo(n);
865
- utils.log("1 down");
866
- utils.log(n[0]);
867
- this.skip_keyup = true;
868
- this.selection().removeAllRanges();
869
- this.markAsSelected(next_node);
870
- next_node.addClass("is-mediaFocused is-selected");
871
- return false;
872
- } else if (next_node.hasClass("graf--mixtapeEmbed")) {
873
- n = current_node.next(".graf--mixtapeEmbed");
874
- num = n[0].childNodes.length;
875
- this.setRangeAt(n[0], num);
876
- this.scrollTo(n);
877
- utils.log("2 down");
878
- return false;
879
- }
880
- if (current_node.hasClass("graf--figure") && next_node.hasClass("graf")) {
881
- this.scrollTo(next_node);
882
- utils.log("3 down, from figure to next graf");
883
- this.markAsSelected(next_node);
884
- this.setRangeAt(next_node[0]);
885
- return false;
886
- }
887
- break;
888
- case "Up":
889
- prev_node = current_node.prev();
890
- utils.log("PREV NODE IS " + (prev_node.attr('class')));
891
- utils.log("CURRENT NODE IS up " + (current_node.attr('class')));
892
- if (!$(current_node).hasClass("graf")) {
893
- return;
894
- }
895
- if (!$(current_node).editableCaretOnFirstLine()) {
896
- return;
897
- }
898
- utils.log("ENTER ARROW PASSED RETURNS");
899
- if (prev_node.hasClass("graf--figure")) {
900
- utils.log("1 up");
901
- n = prev_node.find(".imageCaption");
902
- this.scrollTo(n);
903
- this.skip_keyup = true;
904
- this.selection().removeAllRanges();
905
- this.markAsSelected(prev_node);
906
- prev_node.addClass("is-mediaFocused");
907
- return false;
908
- } else if (prev_node.hasClass("graf--mixtapeEmbed")) {
909
- n = current_node.prev(".graf--mixtapeEmbed");
910
- num = n[0].childNodes.length;
911
- this.setRangeAt(n[0], num);
912
- this.scrollTo(n);
913
- utils.log("2 up");
914
- return false;
915
- }
916
- if (current_node.hasClass("graf--figure") && prev_node.hasClass("graf")) {
917
- this.setRangeAt(prev_node[0]);
918
- this.scrollTo(prev_node);
919
- utils.log("3 up");
920
- return false;
921
- } else if (prev_node.hasClass("graf")) {
922
- n = current_node.prev(".graf");
923
- num = n[0].childNodes.length;
924
- this.scrollTo(n);
925
- utils.log("4 up");
926
- this.skip_keyup = true;
927
- this.markAsSelected(prev_node);
928
- return false;
929
- }
930
- }
931
- };
932
-
933
- Editor.prototype.parseInitialMess = function() {
934
- return this.setupElementsClasses($(this.el).find('.section-inner'), (function(_this) {
935
- return function() {
936
- return _this.handleUnwrappedImages($(_this.el).find('.section-inner'));
937
- };
938
- })(this));
939
- };
940
-
941
- Editor.prototype.handleDblclick = function() {
942
- var node;
943
- utils.log("handleDblclick");
944
- node = this.getNode();
945
- if (_.isNull(node)) {
946
- this.setRangeAt(this.prev_current_node);
947
- }
948
- return false;
949
- };
950
-
951
- Editor.prototype.handlePaste = function(ev) {
952
- var cbd, pastedText;
953
- utils.log("pasted!");
954
- this.aa = this.getNode();
955
- pastedText = void 0;
956
- if (window.clipboardData && window.clipboardData.getData) {
957
- pastedText = window.clipboardData.getData('Text');
958
- } else if (ev.originalEvent.clipboardData && ev.originalEvent.clipboardData.getData) {
959
- cbd = ev.originalEvent.clipboardData;
960
- pastedText = _.isEmpty(cbd.getData('text/html')) ? cbd.getData('text/plain') : cbd.getData('text/html');
961
- }
962
- utils.log(pastedText);
963
- if (pastedText.match(/<\/*[a-z][^>]+?>/gi)) {
964
- utils.log("HTML DETECTED ON PASTE");
965
- $(pastedText);
966
- document.body.appendChild($("<div id='paste'></div>")[0]);
967
- $("#paste").html(pastedText);
968
- this.setupElementsClasses($("#paste"), (function(_this) {
969
- return function() {
970
- var last_node, new_node, nodes, num, top;
971
- nodes = $($("#paste").html()).insertAfter($(_this.aa));
972
- $("#paste").remove();
973
- last_node = nodes.last()[0];
974
- num = last_node.childNodes.length;
975
- _this.setRangeAt(last_node, num);
976
- new_node = $(_this.getNode());
977
- top = new_node.offset().top;
978
- _this.markAsSelected(new_node);
979
- _this.displayTooltipAt($(_this.el).find(".is-selected"));
980
- _this.handleUnwrappedImages(nodes);
981
- return $('html, body').animate({
982
- scrollTop: top
983
- }, 200);
984
- };
985
- })(this));
986
- return false;
987
- }
988
- };
989
-
990
- Editor.prototype.handleUnwrappedImages = function(elements) {
991
- return _.each(elements.find("img"), (function(_this) {
992
- return function(image) {
993
- utils.log("process image here!");
994
- return _this.tooltip_view.uploadExistentImage(image);
995
- };
996
- })(this));
997
- };
998
-
999
- Editor.prototype.handleInmediateDeletion = function(element) {
1000
- var new_node;
1001
- this.inmediateDeletion = false;
1002
- new_node = $(this.baseParagraphTmpl()).insertBefore($(element));
1003
- new_node.addClass("is-selected");
1004
- this.setRangeAt($(element).prev()[0]);
1005
- return $(element).remove();
1006
- };
1007
-
1008
- Editor.prototype.handleUnwrappedNode = function(element) {
1009
- var new_node, tmpl;
1010
- tmpl = $(this.baseParagraphTmpl());
1011
- this.setElementName(tmpl);
1012
- $(element).wrap(tmpl);
1013
- new_node = $("[name='" + (tmpl.attr('name')) + "']");
1014
- new_node.addClass("is-selected");
1015
- this.setRangeAt(new_node[0]);
1016
- return false;
1017
- };
1018
-
1019
-
1020
- /*
1021
- This is a rare hack only for FF (I hope),
1022
- when there is no range it creates a new element as a placeholder,
1023
- then finds previous element from that placeholder,
1024
- then it focus the prev and removes the placeholder.
1025
- a nasty nasty one...
1026
- */
1027
-
1028
- Editor.prototype.handleNullAnchor = function() {
1029
- var node, num, prev, range, sel, span;
1030
- utils.log("WARNING! this is an empty node");
1031
- sel = this.selection();
1032
- if (sel.isCollapsed && sel.rangeCount > 0) {
1033
- range = sel.getRangeAt(0);
1034
- span = $(this.baseParagraphTmpl())[0];
1035
- range.insertNode(span);
1036
- range.setStart(span, 0);
1037
- range.setEnd(span, 0);
1038
- sel.removeAllRanges();
1039
- sel.addRange(range);
1040
- node = $(range.commonAncestorContainer);
1041
- prev = node.prev();
1042
- num = prev[0].childNodes.length;
1043
- utils.log(prev);
1044
- if (prev.hasClass("graf")) {
1045
- this.setRangeAt(prev[0], num);
1046
- node.remove();
1047
- this.markAsSelected(this.getNode());
1048
- } else if (prev.hasClass("graf--mixtapeEmbed")) {
1049
- this.setRangeAt(prev[0], num);
1050
- node.remove();
1051
- this.markAsSelected(this.getNode());
1052
- } else if (!prev) {
1053
- this.setRangeAt(this.$el.find(".section-inner p")[0]);
1054
- }
1055
- return this.displayTooltipAt($(this.el).find(".is-selected"));
1056
- }
1057
- };
1058
-
1059
- Editor.prototype.handleCompleteDeletion = function(element) {
1060
- if (_.isEmpty($(element).text().trim())) {
1061
- utils.log("HANDLE COMPLETE DELETION");
1062
- this.selection().removeAllRanges();
1063
- this.render();
1064
- setTimeout((function(_this) {
1065
- return function() {
1066
- return _this.setRangeAt($(_this.el).find(".section-inner p")[0]);
1067
- };
1068
- })(this), 20);
1069
- return this.completeDeletion = true;
1070
- }
1071
- };
1072
-
1073
- Editor.prototype.handleTab = function(anchor_node) {
1074
- var classes, next;
1075
- utils.log("HANDLE TAB");
1076
- classes = ".graf, .graf--mixtapeEmbed, .graf--figure, .graf--figure";
1077
- next = $(anchor_node).next(classes);
1078
- if ($(next).hasClass("graf--figure")) {
1079
- next = $(next).find("figcaption");
1080
- this.setRangeAt(next[0]);
1081
- this.markAsSelected($(next).parent(".graf--figure"));
1082
- this.displayTooltipAt(next);
1083
- this.scrollTo($(next));
1084
- return false;
1085
- }
1086
- if (_.isEmpty(next) || _.isUndefined(next[0])) {
1087
- next = $(".graf:first");
1088
- }
1089
- this.setRangeAt(next[0]);
1090
- this.markAsSelected(next);
1091
- this.displayTooltipAt(next);
1092
- return this.scrollTo($(next));
1093
- };
1094
-
1095
- Editor.prototype.handleKeyDown = function(e) {
1096
- var anchor_node, parent, utils_anchor_node, $node;
1097
- utils.log("KEYDOWN");
1098
- anchor_node = this.getNode();
1099
- $node = $(anchor_node);
1100
- if (anchor_node) {
1101
- this.markAsSelected(anchor_node);
1102
- }
1103
- if (e.which === 9) {
1104
- this.handleTab(anchor_node);
1105
- return false;
1106
- }
1107
- if (e.which === 13) {
1108
-
1109
- if($node.hasClass("graf--p")){
1110
- this.handleSmartList($node, e);
1111
- }
1112
-
1113
- else if($node.hasClass("graf--li") && $node.text() === ""){
1114
- this.handleListLineBreak($node, e);
1115
- }
1116
- $(this.el).find(".is-selected").removeClass("is-selected");
1117
- parent = $(anchor_node);
1118
- utils.log(this.isLastChar());
1119
- utils.log(parent);
1120
- if (parent.hasClass("is-embedable")) {
1121
- this.tooltip_view.getEmbedFromNode($(anchor_node));
1122
- } else if (parent.hasClass("is-extractable")) {
1123
- this.tooltip_view.getExtractFromNode($(anchor_node));
1124
- }
1125
- if (parent.hasClass("graf--mixtapeEmbed") || parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1126
- utils.log("supress linebreak from embed !(last char)");
1127
- if (!this.isLastChar()) {
1128
- return false;
1129
- }
1130
- }
1131
- if (parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1132
- if (this.isLastChar()) {
1133
- this.handleLineBreakWith("p", parent);
1134
- this.setRangeAtText($(".is-selected")[0]);
1135
- $(".is-selected").trigger("mouseup");
1136
- return false;
1137
- } else {
1138
- return false;
1139
- }
1140
- }
1141
- this.tooltip_view.cleanOperationClasses($(anchor_node));
1142
- if (anchor_node && this.editor_menu.lineBreakReg.test(anchor_node.nodeName)) {
1143
- if (this.isLastChar()) {
1144
- utils.log("new paragraph if it's the last character");
1145
- e.preventDefault();
1146
- this.handleLineBreakWith("p", parent);
1147
- }
1148
- }
1149
- setTimeout((function(_this) {
1150
- return function() {
1151
- var node;
1152
- node = _this.getNode();
1153
- _this.setElementName($(node));
1154
- if (node.nodeName.toLowerCase() === "div") {
1155
- node = _this.replaceWith("p", $(node))[0];
1156
- }
1157
- _this.markAsSelected($(node));
1158
- _this.setupFirstAndLast();
1159
- if (_.isEmpty($(node).text().trim())) {
1160
- _.each($(node).children(), function(n) {
1161
- return $(n).remove();
1162
- });
1163
- $(node).append("<br>");
1164
- }
1165
- return _this.displayTooltipAt($(_this.el).find(".is-selected"));
1166
- };
1167
- })(this), 2);
1168
- }
1169
- if (e.which === 8) {
1170
- this.tooltip_view.hide();
1171
- utils.log("removing from down");
1172
- if (this.reachedTop) {
1173
- utils.log("REACHED TOP");
1174
- }
1175
- if (this.prevented || this.reachedTop && this.isFirstChar()) {
1176
- return false;
1177
- }
1178
- utils.log("pass initial validations");
1179
- anchor_node = this.getNode();
1180
- utils_anchor_node = utils.getNode();
1181
-
1182
- if($node.hasClass("graf--li") && this.getCharacterPrecedingCaret().length === 0){
1183
- return this.handleListBackspace($node, e);
1184
- }
1185
- if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1186
- utils.log("SECTION DETECTED FROM KEYDOWN " + (_.isEmpty($(utils_anchor_node).text())));
1187
- if (_.isEmpty($(utils_anchor_node).text())) {
1188
- return false;
1189
- }
1190
- }
1191
- if (anchor_node && anchor_node.nodeType === 3) {
1192
- utils.log("TextNode detected from Down!");
1193
- }
1194
- if ($(anchor_node).hasClass("graf--mixtapeEmbed") || $(anchor_node).hasClass("graf--iframe")) {
1195
- if (_.isEmpty($(anchor_node).text().trim())) {
1196
- utils.log("EMPTY CHAR");
1197
- return false;
1198
- } else {
1199
- if (this.isFirstChar()) {
1200
- utils.log("FIRST CHAR");
1201
- if (this.isSelectingAll(anchor_node)) {
1202
- this.inmediateDeletion = true;
1203
- }
1204
- return false;
1205
- }
1206
- }
1207
- }
1208
- if ($(anchor_node).prev().hasClass("graf--mixtapeEmbed")) {
1209
- if (this.isFirstChar() && !_.isEmpty($(anchor_node).text().trim())) {
1210
- return false;
1211
- }
1212
- }
1213
- utils.log(anchor_node);
1214
- if ($(".is-selected").hasClass("graf--figure")) {
1215
- this.replaceWith("p", $(".is-selected"));
1216
- this.setRangeAt($(".is-selected")[0]);
1217
- return false;
1218
- }
1219
- }
1220
-
1221
- //spacebar key handler
1222
- if(e.which === 32){
1223
- utils.log("SPACEBAR");
1224
- if($(anchor_node).hasClass("graf--p")){
1225
- this.handleSmartList($node, e);
1226
- }
1227
- }
1228
- if (_.contains([38, 40], e.which)) {
1229
- utils.log(e.which);
1230
- this.handleArrowForKeyDown(e);
1231
- }
1232
- if (anchor_node) {
1233
- if (!_.isEmpty($(anchor_node).text())) {
1234
- this.tooltip_view.hide();
1235
- $(anchor_node).removeClass("graf--empty");
1236
- }
1237
- }
1238
- if (_.isUndefined(anchor_node) && $(".is-selected").hasClass("is-mediaFocused")) {
1239
- this.setRangeAt($(".is-selected").find("figcaption")[0]);
1240
- $(".is-selected").removeClass("is-mediaFocused");
1241
- return false;
1242
- }
1243
- };
1244
-
1245
- Editor.prototype.handleKeyUp = function(e, node) {
1246
- var anchor_node, next_graf, utils_anchor_node;
1247
- if (this.skip_keyup) {
1248
- this.skip_keyup = null;
1249
- utils.log("SKIP KEYUP");
1250
- return false;
1251
- }
1252
- utils.log("KEYUP");
1253
- this.editor_menu.hide();
1254
- this.reachedTop = false;
1255
- anchor_node = this.getNode();
1256
- utils_anchor_node = utils.getNode();
1257
- this.handleTextSelection(anchor_node);
1258
- if (e.which === 8) {
1259
- if ($(utils_anchor_node).hasClass("postField--body")) {
1260
- utils.log("ALL GONE from UP");
1261
- this.handleCompleteDeletion($(this.el));
1262
- if (this.completeDeletion) {
1263
- this.completeDeletion = false;
1264
- return false;
1265
- }
1266
- }
1267
- if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1268
- utils.log("SECTION DETECTED FROM KEYUP " + (_.isEmpty($(utils_anchor_node).text())));
1269
- if (_.isEmpty($(utils_anchor_node).text())) {
1270
- next_graf = $(utils_anchor_node).next(".graf")[0];
1271
- if (next_graf) {
1272
- this.setRangeAt(next_graf);
1273
- $(utils_anchor_node).remove();
1274
- this.setupFirstAndLast();
1275
- }
1276
- return false;
1277
- }
1278
- }
1279
- if (_.isNull(anchor_node)) {
1280
- this.handleNullAnchor();
1281
- return false;
1282
- }
1283
- if ($(anchor_node).hasClass("graf--first")) {
1284
- utils.log("THE FIRST ONE! UP");
1285
- if (this.getSelectedText() === this.getNode().textContent) {
1286
- utils.log("remove selection dectected");
1287
- this.getNode().innerHTML = "<br>";
1288
- }
1289
- this.markAsSelected(anchor_node);
1290
- this.setupFirstAndLast();
1291
- false;
1292
- }
1293
- }
1294
- if (_.contains([37, 38, 39, 40], e.which)) {
1295
- return this.handleArrow(e);
1296
- }
1297
- };
1298
-
1299
- Editor.prototype.handleLineBreakWith = function(element_type, from_element) {
1300
- var new_paragraph;
1301
- new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1302
- if (from_element.parent().is('[class^="graf--"]')) {
1303
- new_paragraph.insertAfter(from_element.parent());
1304
- } else {
1305
- new_paragraph.insertAfter(from_element);
1306
- }
1307
- this.setRangeAt(new_paragraph[0]);
1308
- return this.scrollTo(new_paragraph);
1309
- };
1310
-
1311
- Editor.prototype.replaceWith = function(element_type, from_element) {
1312
- var new_paragraph;
1313
- new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1314
- this.setElementName(new_paragraph);
1315
- from_element.replaceWith(new_paragraph);
1316
- this.setRangeAt(new_paragraph[0]);
1317
- this.scrollTo(new_paragraph);
1318
- return new_paragraph;
1319
- };
1320
-
1321
- Editor.prototype.displayTooltipAt = function(element) {
1322
- utils.log("POSITION FOR TOOLTIP");
1323
- if (!element) {
1324
- return;
1325
- }
1326
- this.tooltip_view.hide();
1327
- if (!_.isEmpty($(element).text())) {
1328
- return;
1329
- }
1330
- this.positions = $(element).offset();
1331
- this.tooltip_view.render();
1332
- return this.tooltip_view.move(this.positions);
1333
- };
1334
-
1335
- Editor.prototype.markAsSelected = function(element) {
1336
- if (_.isUndefined(element)) {
1337
- return;
1338
- }
1339
- $(this.el).find(".is-selected").removeClass("is-mediaFocused is-selected");
1340
- $(element).addClass("is-selected");
1341
- $(element).find(".defaultValue").remove();
1342
- if ($(element).hasClass("graf--first")) {
1343
- this.reachedTop = true;
1344
- if ($(element).find("br").length === 0) {
1345
- return $(element).append("<br>");
1346
- }
1347
- }
1348
- };
1349
-
1350
- Editor.prototype.addClassesToElement = function(element) {
1351
- var n, name, new_el;
1352
- n = element;
1353
- name = n.nodeName.toLowerCase();
1354
- switch (name) {
1355
- case "p":
1356
- case "pre":
1357
- case "div":
1358
- if (!$(n).hasClass("graf--mixtapeEmbed")) {
1359
- $(n).removeClass().addClass("graf graf--" + name);
1360
- }
1361
- if (name === "p" && $(n).find("br").length === 0) {
1362
- $(n).append("<br>");
1363
- }
1364
- break;
1365
- case "h1":
1366
- case "h2":
1367
- case "h3":
1368
- case "h4":
1369
- case "h5":
1370
- case "h6":
1371
- if (name === "h1") {
1372
- new_el = $("<h2 class='graf graf--h2'>" + ($(n).text()) + "</h2>");
1373
- $(n).replaceWith(new_el);
1374
- this.setElementName(n);
1375
- } else {
1376
- $(n).removeClass().addClass("graf graf--" + name);
1377
- }
1378
- break;
1379
- case "code":
1380
- $(n).unwrap().wrap("<p class='graf graf--pre'></p>");
1381
- n = $(n).parent();
1382
- break;
1383
- case "ol":
1384
- case "ul":
1385
- $(n).removeClass().addClass("postList");
1386
- _.each($(n).find("li"), function(li) {
1387
- return li.removeClass().addClass("graf graf--li");
1388
- });
1389
- break;
1390
- case "img":
1391
- utils.log("images");
1392
- this.tooltip_view.uploadExistentImage(n);
1393
- break;
1394
- case "a":
1395
- case 'strong':
1396
- case 'em':
1397
- case 'br':
1398
- case 'b':
1399
- case 'u':
1400
- case 'i':
1401
- utils.log("links");
1402
- $(n).wrap("<p class='graf graf--p'></p>");
1403
- n = $(n).parent();
1404
- break;
1405
- case "blockquote":
1406
- n = $(n).removeClass().addClass("graf graf--" + name);
1407
- break;
1408
- case "figure":
1409
- if ($(n).hasClass(".graf--figure")) {
1410
- n = $(n);
1411
- }
1412
- break;
1413
- default:
1414
- $(n).wrap("<p class='graf graf--" + name + "'></p>");
1415
- n = $(n).parent();
1416
- }
1417
- return n;
1418
- };
1419
-
1420
- Editor.prototype.setupElementsClasses = function(element, cb) {
1421
- if (_.isUndefined(element)) {
1422
- this.element = $(this.el).find('.section-inner');
1423
- } else {
1424
- this.element = element;
1425
- }
1426
- return setTimeout((function(_this) {
1427
- return function() {
1428
- _this.cleanContents(_this.element);
1429
- _this.wrapTextNodes(_this.element);
1430
- _.each(_this.element.children(), function(n) {
1431
- var name;
1432
- name = $(n).prop("tagName").toLowerCase();
1433
- n = _this.addClassesToElement(n);
1434
- return _this.setElementName(n);
1435
- });
1436
- _this.setupLinks(_this.element.find("a"));
1437
- _this.setupFirstAndLast();
1438
- if (_.isFunction(cb)) {
1439
- return cb();
1440
- }
1441
- };
1442
- })(this), 20);
1443
- };
1444
-
1445
- Editor.prototype.cleanContents = function(element) {
1446
- var s;
1447
- if (_.isUndefined(element)) {
1448
- this.element = $(this.el).find('.section-inner');
1449
- } else {
1450
- this.element = element;
1451
- }
1452
- s = new Sanitize({
1453
- elements: ['strong', 'img', 'em', 'br', 'a', 'blockquote', 'b', 'u', 'i', 'pre', 'p', 'h1', 'h2', 'h3', 'h4'],
1454
- attributes: {
1455
- '__ALL__': ['class'],
1456
- a: ['href', 'title', 'target'],
1457
- img: ['src']
1458
- },
1459
- protocols: {
1460
- a: {
1461
- href: ['http', 'https', 'mailto']
1462
- }
1463
- },
1464
- transformers: [
1465
- function(input) {
1466
- if (input.node_name === "span" && $(input.node).hasClass("defaultValue")) {
1467
- return {
1468
- whitelist_nodes: [input.node]
1469
- };
1470
- } else {
1471
- return null;
1472
- }
1473
- }, function(input) {
1474
- if (input.node_name === 'div' && $(input.node).hasClass("graf--mixtapeEmbed")) {
1475
- return {
1476
- whitelist_nodes: [input.node]
1477
- };
1478
- } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1479
- return {
1480
- attr_whitelist: ["style"]
1481
- };
1482
- } else {
1483
- return null;
1484
- }
1485
- }, function(input) {
1486
- if (input.node_name === 'figure' && $(input.node).hasClass("graf--iframe")) {
1487
- return {
1488
- whitelist_nodes: [input.node]
1489
- };
1490
- } else if (input.node_name === 'div' && $(input.node).hasClass("iframeContainer") && $(input.node).parent(".graf--iframe").exists()) {
1491
- return {
1492
- whitelist_nodes: [input.node]
1493
- };
1494
- } else if (input.node_name === 'iframe' && $(input.node).parent(".iframeContainer").exists()) {
1495
- return {
1496
- whitelist_nodes: [input.node]
1497
- };
1498
- } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--iframe").exists()) {
1499
- return {
1500
- whitelist_nodes: [input.node]
1501
- };
1502
- } else {
1503
- return null;
1504
- }
1505
- }, function(input) {
1506
- if (input.node_name === 'figure' && $(input.node).hasClass("graf--figure")) {
1507
- return {
1508
- whitelist_nodes: [input.node]
1509
- };
1510
- } else if (input.node_name === 'div' && ($(input.node).hasClass("aspectRatioPlaceholder") && $(input.node).parent(".graf--figure").exists())) {
1511
- return {
1512
- whitelist_nodes: [input.node]
1513
- };
1514
- } else if (input.node_name === 'div' && ($(input.node).hasClass("aspect-ratio-fill") && $(input.node).parent(".aspectRatioPlaceholder").exists())) {
1515
- return {
1516
- whitelist_nodes: [input.node]
1517
- };
1518
- } else if (input.node_name === 'img' && $(input.node).parent(".graf--figure").exists()) {
1519
- return {
1520
- whitelist_nodes: [input.node]
1521
- };
1522
- } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1523
- return {
1524
- attr_whitelist: ["style"]
1525
- };
1526
- } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--figure").exists()) {
1527
- return {
1528
- whitelist_nodes: [input.node]
1529
- };
1530
- } else if (input.node_name === 'span' && $(input.node).parent(".imageCaption").exists()) {
1531
- return {
1532
- whitelist_nodes: [input.node]
1533
- };
1534
- } else {
1535
- return null;
1536
- }
1537
- }
1538
- ]
1539
- });
1540
- if (this.element.exists()) {
1541
- utils.log("CLEAN HTML");
1542
- return this.element.html(s.clean_node(this.element[0]));
1543
- }
1544
- };
1545
-
1546
- Editor.prototype.setupLinks = function(elems) {
1547
- return _.each(elems, (function(_this) {
1548
- return function(n) {
1549
- return _this.setupLink(n);
1550
- };
1551
- })(this));
1552
- };
1553
-
1554
- Editor.prototype.setupLink = function(n) {
1555
- var href, parent_name;
1556
- parent_name = $(n).parent().prop("tagName").toLowerCase();
1557
- $(n).addClass("markup--anchor markup--" + parent_name + "-anchor");
1558
- href = $(n).attr("href");
1559
- return $(n).attr("data-href", href);
1560
- };
1561
-
1562
- Editor.prototype.preCleanNode = function(element) {
1563
- var s;
1564
- s = new Sanitize({
1565
- elements: ['strong', 'em', 'br', 'a', 'b', 'u', 'i'],
1566
- attributes: {
1567
- a: ['href', 'title', 'target']
1568
- },
1569
- protocols: {
1570
- a: {
1571
- href: ['http', 'https', 'mailto']
1572
- }
1573
- }
1574
- });
1575
- $(element).html(s.clean_node(element[0]));
1576
- element = this.addClassesToElement($(element)[0]);
1577
- return $(element);
1578
- };
1579
-
1580
- Editor.prototype.setupFirstAndLast = function() {
1581
- var childs, $firstTarget, $lastTarget;
1582
- childs = $(this.el).find(".section-inner").children();
1583
- childs.removeClass("graf--last , graf--first");
1584
- $firstTarget = $(childs.first());
1585
- $lastTarget = $(childs.last());
1586
- if($firstTarget.hasClass("postList")){
1587
- $firstTarget = $firstTarget.children().first();
1588
- }
1589
-
1590
- if($lastTarget.hasClass("postList")){
1591
- $lastTarget = $lastTarget.children().last();
1592
- }
1593
-
1594
- $firstTarget.addClass("graf--first");
1595
- return $lastTarget.addClass("graf--last");
1596
- };
1597
-
1598
- Editor.prototype.wrapTextNodes = function(element) {
1599
- if (_.isUndefined(element)) {
1600
- element = $(this.el).find('.section-inner');
1601
- } else {
1602
- element = element;
1603
- }
1604
- return element.contents().filter(function() {
1605
- return this.nodeType === 3 && this.data.trim().length > 0;
1606
- }).wrap("<p class='graf grap--p'></p>");
1607
- };
1608
-
1609
- Editor.prototype.setElementName = function(element) {
1610
- return $(element).attr("name", utils.generateUniqueName());
1611
- };
1612
-
1613
- /**
1614
- * Takes a paragraph and makes a list out of it
1615
- *
1616
- * @param {jQuery} paragraph The paragraph to listify
1617
- * @param {string} list_type The type of list (ol or ul)
1618
- * @param {int} tagLength The Length of the smartlist trigger string
1619
- *
1620
- * @return false if list_type is not ol or ul. Otherwise, the new list is returned
1621
- */
1622
- Editor.prototype.listify = function($paragraph, listType, tagLength){
1623
- var content, $list, $li;
1624
-
1625
- //get the content of the old container
1626
- content = $paragraph.html().replace(/&nbsp;/g, " ");
1627
- utils.log(tagLength);
1628
-
1629
- //remove the smartlist shortcut formatting
1630
- content = content.slice(tagLength, content.length);
1631
-
1632
- //validation of second parameter
1633
- switch(listType){
1634
- case "ul":
1635
- $list = $("<ul></ul>");
1636
- break;
1637
-
1638
- case "ol":
1639
- $list = $("<ol></ol>");
1640
- break;
1641
-
1642
- default:
1643
- return false;
1644
- }
1645
-
1646
- //add the proper classes to the list
1647
- this.addClassesToElement($list[0]);
1648
-
1649
- //replace the paragraph with the list item, then select it
1650
- this.replaceWith("li", $paragraph);
1651
- $li = $(".is-selected");
1652
- this.setElementName($li[0]);
1653
-
1654
- //wrap the list item in the proper list, then focus on it
1655
- $li.html(content).wrap($list);
1656
-
1657
- if($li.find("br").length === 0){
1658
- $li.append("<br/>");
1659
- }
1660
- this.setRangeAt($li[0], 0);
1661
- this.scrollTo($li[0]);
1662
- }
1663
-
1664
- /**
1665
- * Handles the analysis and creation of smart lists
1666
- *
1667
- * @param {jQuery} $node - the paragraph to analyze
1668
- * @param {event} e - The event object that generated a smart list check
1669
- */
1670
- Editor.prototype.handleSmartList = function($node, e){
1671
- //check if an unordered list should be entered
1672
- utils.log("CHECK SMART LIST");
1673
- utils.log($node);
1674
-
1675
-
1676
- var match = $node.text().match(/^\s*(\-|\*)\s*/);
1677
- if(match){
1678
-
1679
- //replace default action with creating an unordered list
1680
- utils.log("CREATING LIST ITEM");
1681
- e.preventDefault();
1682
- this.listify($node, "ul", match[0].length);
1683
- return;
1684
- }
1685
-
1686
- //check if an ordered list should be entered
1687
- else{
1688
- match = $node.text().match(/^\s*1(\.|\))\s*/);
1689
- if(match){
1690
-
1691
- //replace default action with ordered list insertion
1692
- utils.log("CREATING LIST ITEM");
1693
- e.preventDefault();
1694
- this.listify($node, "ol", match[0].length);
1695
- }
1696
- }
1697
-
1698
- }
1699
-
1700
-
1701
- /**
1702
- * Handles the processing of line breaks when in a list
1703
- *
1704
- * @param {jQuery} $li - The list item where a line break was entered
1705
- * @param {event} e - The event that generates the line break
1706
- *
1707
- */
1708
- Editor.prototype.handleListLineBreak = function($li, e){
1709
- var $list, $parahraph;
1710
-
1711
- utils.log("LIST LINE BREAK HANDLE");
1712
- e.preventDefault();
1713
- this.tooltip_view.hide();
1714
-
1715
- //get the list containing the selected list item
1716
- $list = $($li.parent("ol, ul")[0]);
1717
-
1718
- //generate replacement paragraph
1719
- $paragraph = $("<p></p>");
1720
-
1721
-
1722
- //if the list has only one child, replace it with a paragraph
1723
- if($list.children().length === 1){
1724
- this.replaceWith("p", $list);
1725
-
1726
- }
1727
-
1728
- //if the list item is the last child and is empty
1729
- else if($li.next().length == 0 && $li.text() === ""){
1730
-
1731
- //put the replacement paragraph after the list and remove the empty list item
1732
- $list.after($paragraph);
1733
- $li.remove();
1734
-
1735
- //select and focus on the new paragraph
1736
- this.addClassesToElement($paragraph[0]);
1737
- this.setRangeAt($paragraph[0]);
1738
- this.markAsSelected($paragraph[0]);
1739
- return this.scrollTo($paragraph);
1740
- }
1741
- }
1742
-
1743
- /**
1744
- * Handles backspace keydowns in lists
1745
- *
1746
- * @param {jQuery} $li - The list item where backspace was pressed
1747
- * @param {event} e - The backspace event object
1748
- *
1749
- */
1750
- Editor.prototype.handleListBackspace = function($li, e){
1751
-
1752
- var content, $list, $paragraph;
1753
-
1754
- //get the list item's parent list
1755
- $list = $li.parent("ol, ul");
1756
- utils.log("LIST BACKSPACE");
1757
-
1758
- //if on the first list item of a list
1759
- if($li.prev().length === 0){
1760
- e.preventDefault();
1761
-
1762
- //move the item outside of the list, and replace it with a paragraph
1763
- $list.before($li);
1764
- content = $li.html();
1765
- this.replaceWith("p", $li);
1766
- $paragraph = $(".is-selected");
1767
- $paragraph.removeClass("graf--empty").html(content);
1768
-
1769
- //then, if the list is empty, remove it
1770
- if($list.children().length === 0){
1771
- $list.remove();
1772
- }
1773
-
1774
- //set up first and last attributes
1775
- this.setupFirstAndLast();
1776
- }
1777
- }
1778
-
1779
-
1780
- return Editor;
1781
-
1782
- })(Dante.View);
1783
-
1784
- }).call(this);
1785
- (function() {
1786
- var utils,
1787
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1788
- __hasProp = {}.hasOwnProperty,
1789
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
1790
-
1791
- utils = Dante.utils;
1792
-
1793
- Dante.Editor.Tooltip = (function(_super) {
1794
- __extends(Tooltip, _super);
1795
-
1796
- function Tooltip() {
1797
- this.hide = __bind(this.hide, this);
1798
- this.getExtract = __bind(this.getExtract, this);
1799
- this.getExtractFromNode = __bind(this.getExtractFromNode, this);
1800
- this.getEmbedFromNode = __bind(this.getEmbedFromNode, this);
1801
- this.uploadCompleted = __bind(this.uploadCompleted, this);
1802
- this.updateProgressBar = __bind(this.updateProgressBar, this);
1803
- this.uploadFile = __bind(this.uploadFile, this);
1804
- this.uploadFiles = __bind(this.uploadFiles, this);
1805
- this.toggleOptions = __bind(this.toggleOptions, this);
1806
- this.render = __bind(this.render, this);
1807
- this.initialize = __bind(this.initialize, this);
1808
- return Tooltip.__super__.constructor.apply(this, arguments);
1809
- }
1810
-
1811
- Tooltip.prototype.el = ".inlineTooltip";
1812
-
1813
- Tooltip.prototype.events = {
1814
- "click .inlineTooltip-button.control": "toggleOptions",
1815
- "click .inlineTooltip-menu button": "handleClick"
1816
- };
1817
-
1818
- Tooltip.prototype.initialize = function(opts) {
1819
- if (opts == null) {
1820
- opts = {};
1821
- }
1822
- this.current_editor = opts.editor;
1823
- return this.buttons = [
1824
- {
1825
- icon: "icon-image",
1826
- title: "Add an image",
1827
- action: "image"
1828
- }, {
1829
- icon: "icon-video",
1830
- title: "Add a video",
1831
- action: "embed"
1832
- }, {
1833
- icon: "icon-embed",
1834
- title: "Add an embed",
1835
- action: "embed-extract"
1836
- }
1837
- ];
1838
- };
1839
-
1840
- Tooltip.prototype.template = function() {
1841
- var menu;
1842
- menu = "";
1843
- _.each(this.buttons, function(b) {
1844
- var data_action_value;
1845
- data_action_value = b.action_value ? "data-action-value='" + b.action_value + "'" : "";
1846
- return menu += "<button class='inlineTooltip-button scale' title='" + b.title + "' data-action='inline-menu-" + b.action + "' " + data_action_value + "> <span class='tooltip-icon " + b.icon + "'></span> </button>";
1847
- });
1848
- return "<button class='inlineTooltip-button control' title='Close Menu' data-action='inline-menu'> <span class='tooltip-icon icon-plus'></span> </button> <div class='inlineTooltip-menu'> " + menu + " </div>";
1849
- };
1850
-
1851
- Tooltip.prototype.insertTemplate = function() {
1852
- return "<figure contenteditable='false' class='graf graf--figure is-defaultValue' name='" + (utils.generateUniqueName()) + "' tabindex='0'> <div style='' class='aspectRatioPlaceholder is-locked'> <div style='padding-bottom: 100%;' class='aspect-ratio-fill'></div> <img src='' data-height='' data-width='' data-image-id='' class='graf-image' data-delayed-src=''> </div> <figcaption contenteditable='true' data-default-value='Type caption for image (optional)' class='imageCaption'> <span class='defaultValue'>Type caption for image (optional)</span> <br> </figcaption> </figure>";
1853
- };
1854
-
1855
- Tooltip.prototype.extractTemplate = function() {
1856
- return "<div class='graf graf--mixtapeEmbed is-selected' name=''> <a target='_blank' data-media-id='' class='js-mixtapeImage mixtapeImage mixtapeImage--empty u-ignoreBlock' href=''> </a> <a data-tooltip-type='link' data-tooltip-position='bottom' data-tooltip='' title='' class='markup--anchor markup--mixtapeEmbed-anchor' data-href='' href='' target='_blank'> <strong class='markup--strong markup--mixtapeEmbed-strong'></strong> <em class='markup--em markup--mixtapeEmbed-em'></em> </a> </div>";
1857
- };
1858
-
1859
- Tooltip.prototype.embedTemplate = function() {
1860
- return "<figure contenteditable='false' class='graf--figure graf--iframe graf--first' name='504e' tabindex='0'> <div class='iframeContainer'> <iframe frameborder='0' width='700' height='393' data-media-id='' src='' data-height='480' data-width='854'> </iframe> </div> <figcaption contenteditable='true' data-default-value='Type caption for embed (optional)' class='imageCaption'> <a rel='nofollow' class='markup--anchor markup--figure-anchor' data-href='' href='' target='_blank'> </a> </figcaption> </figure>";
1861
- };
1862
-
1863
- Tooltip.prototype.render = function() {
1864
- $(this.el).html(this.template());
1865
- $(this.el).addClass("is-active");
1866
- return this;
1867
- };
1868
-
1869
- Tooltip.prototype.toggleOptions = function() {
1870
- utils.log("Toggle Options!!");
1871
- $(this.el).toggleClass("is-scaled");
1872
- return false;
1873
- };
1874
-
1875
- Tooltip.prototype.move = function(coords) {
1876
- var control_spacing, control_width, coord_left, coord_top, pull_size, tooltip;
1877
- tooltip = $(this.el);
1878
- control_width = tooltip.find(".control").css("width");
1879
- control_spacing = tooltip.find(".inlineTooltip-menu").css("padding-left");
1880
- pull_size = parseInt(control_width.replace(/px/, "")) + parseInt(control_spacing.replace(/px/, ""));
1881
- coord_left = coords.left - pull_size;
1882
- coord_top = coords.top;
1883
- return $(this.el).offset({
1884
- top: coord_top,
1885
- left: coord_left
1886
- });
1887
- };
1888
-
1889
- Tooltip.prototype.handleClick = function(ev) {
1890
- var name;
1891
- name = $(ev.currentTarget).data('action');
1892
- utils.log(name);
1893
- switch (name) {
1894
- case "inline-menu-image":
1895
- this.placeholder = "<p>PLACEHOLDER</p>";
1896
- this.imageSelect(ev);
1897
- break;
1898
- case "inline-menu-embed":
1899
- this.displayEmbedPlaceHolder();
1900
- break;
1901
- case "inline-menu-embed-extract":
1902
- this.displayExtractPlaceHolder();
1903
- break;
1904
- case "inline-menu-hr":
1905
- this.splitSection();
1906
- }
1907
- return false;
1908
- };
1909
-
1910
- Tooltip.prototype.uploadExistentImage = function(image_element, opts) {
1911
- var i, img, n, node, tmpl, _i, _ref;
1912
- if (opts == null) {
1913
- opts = {};
1914
- }
1915
- utils.log("process image here!");
1916
- tmpl = $(this.insertTemplate());
1917
- tmpl.find("img").attr('src', this.current_editor.default_loading_placeholder);
1918
- if ($(image_element).parents(".graf").length > 0) {
1919
- if ($(image_element).parents(".graf").hasClass("graf--figure")) {
1920
- return;
1921
- }
1922
- utils.log("UNO");
1923
- tmpl.insertBefore($(image_element).parents(".graf"));
1924
- node = this.current_editor.getNode();
1925
- if (node) {
1926
- this.current_editor.preCleanNode($(node));
1927
- this.current_editor.addClassesToElement(node);
1928
- }
1929
- } else {
1930
- utils.log("DOS");
1931
- img = $(image_element).parentsUntil(".section-inner").first();
1932
- $(img).replaceWith(tmpl);
1933
- }
1934
- utils.log($("[name='" + (tmpl.attr('name')) + "']").attr("name"));
1935
- this.replaceImg(image_element, $("[name='" + (tmpl.attr('name')) + "']"));
1936
- n = $("[name='" + (tmpl.attr('name')) + "']").parentsUntil(".section-inner").length;
1937
- if (n !== 0) {
1938
- for (i = _i = 0, _ref = n - 1; _i <= _ref; i = _i += 1) {
1939
- $("[name='" + (tmpl.attr('name')) + "']").unwrap();
1940
- }
1941
- }
1942
- return utils.log("FIG");
1943
- };
1944
-
1945
- Tooltip.prototype.replaceImg = function(image_element, figure) {
1946
- var img, self;
1947
- utils.log(figure.attr("name"));
1948
- utils.log(figure);
1949
- $(image_element).remove();
1950
- img = new Image();
1951
- img.src = image_element.src;
1952
- self = this;
1953
- return img.onload = function() {
1954
- var ar;
1955
- utils.log("replace image with loaded info");
1956
- utils.log(figure.attr("name"));
1957
- utils.log(this.width + 'x' + this.height);
1958
- ar = self.getAspectRatio(this.width, this.height);
1959
- figure.find(".aspectRatioPlaceholder").css({
1960
- 'max-width': ar.width,
1961
- 'max-height': ar.height
1962
- });
1963
- figure.find(".graf-image").attr({
1964
- "data-height": this.height,
1965
- "data-width": this.width
1966
- });
1967
- figure.find(".aspect-ratio-fill").css({
1968
- "padding-bottom": "" + ar.ratio + "%"
1969
- });
1970
- return figure.find("img").attr("src", image_element.src);
1971
- };
1972
- };
1973
-
1974
- Tooltip.prototype.displayAndUploadImages = function(file) {
1975
- return this.displayCachedImage(file);
1976
- };
1977
-
1978
- Tooltip.prototype.imageSelect = function(ev) {
1979
- var $selectFile, self;
1980
- $selectFile = $('<input type="file" multiple="multiple">').click();
1981
- self = this;
1982
- return $selectFile.change(function() {
1983
- var t;
1984
- t = this;
1985
- return self.uploadFiles(t.files);
1986
- });
1987
- };
1988
-
1989
- Tooltip.prototype.displayCachedImage = function(file) {
1990
- var reader;
1991
- this.current_editor.tooltip_view.hide();
1992
- reader = new FileReader();
1993
- reader.onload = (function(_this) {
1994
- return function(e) {
1995
- var img, node, self;
1996
- img = new Image;
1997
- img.src = e.target.result;
1998
- node = _this.current_editor.getNode();
1999
- self = _this;
2000
- return img.onload = function() {
2001
- var ar, img_tag, new_tmpl, replaced_node;
2002
- new_tmpl = $(self.insertTemplate());
2003
- replaced_node = $(new_tmpl).insertBefore($(node));
2004
- img_tag = new_tmpl.find('img.graf-image').attr('src', e.target.result);
2005
- img_tag.height = this.height;
2006
- img_tag.width = this.width;
2007
- utils.log("UPLOADED SHOW FROM CACHE");
2008
- ar = self.getAspectRatio(this.width, this.height);
2009
- replaced_node.find(".aspectRatioPlaceholder").css({
2010
- 'max-width': ar.width,
2011
- 'max-height': ar.height
2012
- });
2013
- replaced_node.find(".graf-image").attr({
2014
- "data-height": this.height,
2015
- "data-width": this.width
2016
- });
2017
- replaced_node.find(".aspect-ratio-fill").css({
2018
- "padding-bottom": "" + ar.ratio + "%"
2019
- });
2020
- return self.uploadFile(file, replaced_node);
2021
- };
2022
- };
2023
- })(this);
2024
- return reader.readAsDataURL(file);
2025
- };
2026
-
2027
- Tooltip.prototype.getAspectRatio = function(w, h) {
2028
- var fill_ratio, height, maxHeight, maxWidth, ratio, result, width;
2029
- maxWidth = 700;
2030
- maxHeight = 700;
2031
- ratio = 0;
2032
- width = w;
2033
- height = h;
2034
- if (width > maxWidth) {
2035
- ratio = maxWidth / width;
2036
- height = height * ratio;
2037
- width = width * ratio;
2038
- } else if (height > maxHeight) {
2039
- ratio = maxHeight / height;
2040
- width = width * ratio;
2041
- height = height * ratio;
2042
- }
2043
- fill_ratio = height / width * 100;
2044
- result = {
2045
- width: width,
2046
- height: height,
2047
- ratio: fill_ratio
2048
- };
2049
- utils.log(result);
2050
- return result;
2051
- };
2052
-
2053
- Tooltip.prototype.formatData = function(file) {
2054
- var formData;
2055
- formData = new FormData();
2056
- formData.append('file', file);
2057
- return formData;
2058
- };
2059
-
2060
- Tooltip.prototype.uploadFiles = function(files) {
2061
- var acceptedTypes, file, i, _results;
2062
- acceptedTypes = {
2063
- "image/png": true,
2064
- "image/jpeg": true,
2065
- "image/gif": true
2066
- };
2067
- i = 0;
2068
- _results = [];
2069
- while (i < files.length) {
2070
- file = files[i];
2071
- if (acceptedTypes[file.type] === true) {
2072
- $(this.placeholder).append("<progress class=\"progress\" min=\"0\" max=\"100\" value=\"0\">0</progress>");
2073
- this.displayAndUploadImages(file);
2074
- }
2075
- _results.push(i++);
2076
- }
2077
- return _results;
2078
- };
2079
-
2080
- Tooltip.prototype.uploadFile = function(file, node) {
2081
- var handleUp, n;
2082
- n = node;
2083
- handleUp = (function(_this) {
2084
- return function(jqxhr) {
2085
- return _this.uploadCompleted(jqxhr, n);
2086
- };
2087
- })(this);
2088
- return $.ajax({
2089
- type: "post",
2090
- url: this.current_editor.upload_url,
2091
- xhr: (function(_this) {
2092
- return function() {
2093
- var xhr;
2094
- xhr = new XMLHttpRequest();
2095
- xhr.upload.onprogress = _this.updateProgressBar;
2096
- return xhr;
2097
- };
2098
- })(this),
2099
- cache: false,
2100
- contentType: false,
2101
- success: (function(_this) {
2102
- return function(response) {
2103
- handleUp(response);
2104
- };
2105
- })(this),
2106
- error: (function(_this) {
2107
- return function(jqxhr) {
2108
- return utils.log("ERROR: got error uploading file " + jqxhr.responseText);
2109
- };
2110
- })(this),
2111
- processData: false,
2112
- data: this.formatData(file)
2113
- });
2114
- };
2115
-
2116
- Tooltip.prototype.updateProgressBar = function(e) {
2117
- var $progress, complete;
2118
- $progress = $('.progress:first', this.$el);
2119
- complete = "";
2120
- if (e.lengthComputable) {
2121
- complete = e.loaded / e.total * 100;
2122
- complete = complete != null ? complete : {
2123
- complete: 0
2124
- };
2125
- utils.log("complete");
2126
- return utils.log(complete);
2127
- }
2128
- };
2129
-
2130
- Tooltip.prototype.uploadCompleted = function(url, node) {
2131
- return node.find("img").attr("src", url);
2132
- };
2133
-
2134
- Tooltip.prototype.displayEmbedPlaceHolder = function() {
2135
- var ph;
2136
- ph = this.current_editor.embed_placeholder;
2137
- this.node = this.current_editor.getNode();
2138
- $(this.node).html(ph).addClass("is-embedable");
2139
- this.current_editor.setRangeAt(this.node);
2140
- this.hide();
2141
- return false;
2142
- };
2143
-
2144
- Tooltip.prototype.getEmbedFromNode = function(node) {
2145
- this.node_name = $(node).attr("name");
2146
- return $.getJSON("" + this.current_editor.oembed_url + ($(this.node).text())).success((function(_this) {
2147
- return function(data) {
2148
- var iframe_src, replaced_node, tmpl, url;
2149
- _this.node = $("[name=" + _this.node_name + "]");
2150
- iframe_src = $(data.html).prop("src");
2151
- tmpl = $(_this.embedTemplate());
2152
- tmpl.attr("name", _this.node.attr("name"));
2153
- $(_this.node).replaceWith(tmpl);
2154
- replaced_node = $(".graf--iframe[name=" + (_this.node.attr("name")) + "]");
2155
- replaced_node.find("iframe").attr("src", iframe_src);
2156
- url = data.url || data.author_url;
2157
- utils.log("URL IS " + url);
2158
- replaced_node.find(".markup--anchor").attr("href", url).text(url);
2159
- return _this.hide();
2160
- };
2161
- })(this));
2162
- };
2163
-
2164
- Tooltip.prototype.displayExtractPlaceHolder = function() {
2165
- var ph;
2166
- ph = this.current_editor.extract_placeholder;
2167
- this.node = this.current_editor.getNode();
2168
- $(this.node).html(ph).addClass("is-extractable");
2169
- this.current_editor.setRangeAt(this.node);
2170
- this.hide();
2171
- return false;
2172
- };
2173
-
2174
- Tooltip.prototype.getExtractFromNode = function(node) {
2175
- this.node_name = $(node).attr("name");
2176
- return $.getJSON("" + this.current_editor.extract_url + ($(this.node).text())).success((function(_this) {
2177
- return function(data) {
2178
- var iframe_src, image_node, replaced_node, tmpl;
2179
- _this.node = $("[name=" + _this.node_name + "]");
2180
- iframe_src = $(data.html).prop("src");
2181
- tmpl = $(_this.extractTemplate());
2182
- tmpl.attr("name", _this.node.attr("name"));
2183
- $(_this.node).replaceWith(tmpl);
2184
- replaced_node = $(".graf--mixtapeEmbed[name=" + (_this.node.attr("name")) + "]");
2185
- replaced_node.find("strong").text(data.title);
2186
- replaced_node.find("em").text(data.description);
2187
- replaced_node.append(data.provider_url);
2188
- replaced_node.find(".markup--anchor").attr("href", data.url);
2189
- if (!_.isEmpty(data.images)) {
2190
- image_node = replaced_node.find(".mixtapeImage");
2191
- image_node.css("background-image", "url(" + data.images[0].url + ")");
2192
- image_node.removeClass("mixtapeImage--empty u-ignoreBlock");
2193
- }
2194
- return _this.hide();
2195
- };
2196
- })(this));
2197
- };
2198
-
2199
- Tooltip.prototype.getExtract = function(url) {
2200
- return $.getJSON("" + this.current_editor.extract_url + url).done(function(data) {
2201
- return utils.log(data);
2202
- });
2203
- };
2204
-
2205
- Tooltip.prototype.cleanOperationClasses = function(node) {
2206
- return node.removeClass("is-embedable is-extractable");
2207
- };
2208
-
2209
- Tooltip.prototype.hide = function() {
2210
- return $(this.el).removeClass("is-active is-scaled");
2211
- };
2212
-
2213
- return Tooltip;
2214
-
2215
- })(Dante.View);
2216
-
2217
- }).call(this);
2218
- (function() {
2219
- var utils,
2220
- __hasProp = {}.hasOwnProperty,
2221
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2222
-
2223
- utils = Dante.utils;
2224
-
2225
- Dante.Editor.PopOver = (function(_super) {
2226
- __extends(PopOver, _super);
2227
-
2228
- function PopOver() {
2229
- return PopOver.__super__.constructor.apply(this, arguments);
2230
- }
2231
-
2232
- PopOver.prototype.el = "body";
2233
-
2234
- PopOver.prototype.events = {
2235
- "mouseover .popover": "cancelHide",
2236
- "mouseout .popover": "hide"
2237
- };
2238
-
2239
- PopOver.prototype.initialize = function(opts) {
2240
- if (opts == null) {
2241
- opts = {};
2242
- }
2243
- utils.log("initialized popover");
2244
- this.editor = opts.editor;
2245
- this.hideTimeout;
2246
- return this.settings = {
2247
- timeout: 300
2248
- };
2249
- };
2250
-
2251
- PopOver.prototype.template = function() {
2252
- return "<div class='popover popover--tooltip popover--Linktooltip popover--bottom is-active'> <div class='popover-inner'> <a href='#' target='_blank'> Link </a> </div> <div class='popover-arrow'> </div> </div>";
2253
- };
2254
-
2255
- PopOver.prototype.positionAt = function(ev) {
2256
- var left_value, popover_width, target, target_height, target_offset, target_positions, target_width, top_value;
2257
- target = $(ev.currentTarget);
2258
- target_positions = this.resolveTargetPosition(target);
2259
- target_offset = target.offset();
2260
- target_width = target.outerWidth();
2261
- target_height = target.outerHeight();
2262
- popover_width = $(this.el).find(".popover").outerWidth();
2263
- top_value = target_positions.top + target_height;
2264
- left_value = target_offset.left + (target_width / 2) - (popover_width / 2);
2265
- $(this.el).find(".popover").css("top", top_value).css("left", left_value).show();
2266
- return this.handleDirection(target);
2267
- };
2268
-
2269
- PopOver.prototype.displayAt = function(ev) {
2270
- var target;
2271
- this.cancelHide();
2272
- target = $(ev.currentTarget);
2273
- $(this.el).find(".popover-inner a").text(target.attr('href')).attr('href', target.attr("href"));
2274
- this.positionAt(ev);
2275
- $(this.el).find(".popover--tooltip").css("pointer-events", "auto");
2276
- return $(this.el).show();
2277
- };
2278
-
2279
- PopOver.prototype.cancelHide = function() {
2280
- utils.log("Cancel Hide");
2281
- return clearTimeout(this.hideTimeout);
2282
- };
2283
-
2284
- PopOver.prototype.hide = function(ev) {
2285
- this.cancelHide();
2286
- return this.hideTimeout = setTimeout((function(_this) {
2287
- return function() {
2288
- return $(_this.el).find(".popover").hide();
2289
- };
2290
- })(this), this.settings.timeout);
2291
- };
2292
-
2293
- PopOver.prototype.resolveTargetPosition = function(target) {
2294
- if (target.parents(".graf--mixtapeEmbed").exists()) {
2295
- return target.parents(".graf--mixtapeEmbed").position();
2296
- } else {
2297
- return target.position();
2298
- }
2299
- };
2300
-
2301
- PopOver.prototype.handleDirection = function(target) {
2302
- if (target.parents(".graf--mixtapeEmbed").exists()) {
2303
- return $(this.el).find(".popover").removeClass("popover--bottom").addClass("popover--top");
2304
- } else {
2305
- return $(this.el).find(".popover").removeClass("popover--top").addClass("popover--bottom");
2306
- }
2307
- };
2308
-
2309
- PopOver.prototype.render = function() {
2310
- return $(this.template()).insertAfter(this.editor.$el);
2311
- };
2312
-
2313
- return PopOver;
2314
-
2315
- })(Dante.View);
2316
-
2317
- }).call(this);
2318
- (function() {
2319
- var utils,
2320
- __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2321
- __hasProp = {}.hasOwnProperty,
2322
- __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
2323
-
2324
- utils = Dante.utils;
2325
-
2326
- Dante.Editor.Menu = (function(_super) {
2327
- __extends(Menu, _super);
2328
-
2329
- function Menu() {
2330
- this.createlink = __bind(this.createlink, this);
2331
- this.handleInputEnter = __bind(this.handleInputEnter, this);
2332
- this.render = __bind(this.render, this);
2333
- this.template = __bind(this.template, this);
2334
- this.initialize = __bind(this.initialize, this);
2335
- return Menu.__super__.constructor.apply(this, arguments);
2336
- }
2337
-
2338
- Menu.prototype.el = "#dante-menu";
2339
-
2340
- Menu.prototype.events = {
2341
- "mousedown li": "handleClick",
2342
- "click .dante-menu-linkinput .dante-menu-button": "closeInput",
2343
- "keypress input": "handleInputEnter"
2344
- };
2345
-
2346
- Menu.prototype.initialize = function(opts) {
2347
- if (opts == null) {
2348
- opts = {};
2349
- }
2350
- this.config = opts.buttons || this.default_config();
2351
- this.current_editor = opts.editor;
2352
- this.commandsReg = {
2353
- block: /^(?:p|h[1-6]|blockquote|pre)$/,
2354
- inline: /^(?:bold|italic|underline|insertorderedlist|insertunorderedlist|indent|outdent)$/,
2355
- source: /^(?:insertimage|createlink|unlink)$/,
2356
- insert: /^(?:inserthorizontalrule|insert)$/,
2357
- wrap: /^(?:code)$/
2358
- };
2359
- this.lineBreakReg = /^(?:blockquote|pre|div|p)$/i;
2360
- this.effectNodeReg = /(?:[pubia]|h[1-6]|blockquote|[uo]l|li)/i;
2361
- return this.strReg = {
2362
- whiteSpace: /(^\s+)|(\s+$)/g,
2363
- mailTo: /^(?!mailto:|.+\/|.+#|.+\?)(.*@.*\..+)$/,
2364
- http: /^(?!\w+?:\/\/|mailto:|\/|\.\/|\?|#)(.*)$/
2365
- };
2366
- };
2367
-
2368
- Menu.prototype.default_config = function() {
2369
- return {
2370
-
2371
- /*
2372
- buttons: [
2373
- 'blockquote', 'h2', 'h3', 'p', 'code', 'insertorderedlist', 'insertunorderedlist', 'inserthorizontalrule',
2374
- 'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink'
2375
- ]
2376
- */
2377
- buttons: ['bold', 'italic', 'h2', 'h3', 'h4', 'blockquote', 'createlink']
2378
- };
2379
- };
2380
-
2381
- Menu.prototype.template = function() {
2382
- var html;
2383
- html = "<div class='dante-menu-linkinput'><input class='dante-menu-input' placeholder='http://'><div class='dante-menu-button'>x</div></div>";
2384
- html += "<ul class='dante-menu-buttons'>";
2385
- _.each(this.config.buttons, function(item) {
2386
- return html += "<li class='dante-menu-button'><i class=\"dante-icon icon-" + item + "\" data-action=\"" + item + "\"></i></li>";
2387
- });
2388
- html += "</ul>";
2389
- return html;
2390
- };
2391
-
2392
- Menu.prototype.render = function() {
2393
- $(this.el).html(this.template());
2394
- return this.show();
2395
- };
2396
-
2397
- Menu.prototype.handleClick = function(ev) {
2398
- var action, element, input;
2399
- element = $(ev.currentTarget).find('.dante-icon');
2400
- action = element.data("action");
2401
- input = $(this.el).find("input.dante-menu-input");
2402
- utils.log("menu " + action + " item clicked!");
2403
- this.savedSel = utils.saveSelection();
2404
- if (/(?:createlink)/.test(action)) {
2405
- if ($(ev.currentTarget).hasClass("active")) {
2406
- this.removeLink();
2407
- } else {
2408
- $(this.el).addClass("dante-menu--linkmode");
2409
- input.focus();
2410
- }
2411
- } else {
2412
- this.menuApply(action);
2413
- }
2414
- return false;
2415
- };
2416
-
2417
- Menu.prototype.closeInput = function(e) {
2418
- $(this.el).removeClass("dante-menu--linkmode");
2419
- return false;
2420
- };
2421
-
2422
- Menu.prototype.handleInputEnter = function(e) {
2423
- if (e.which === 13) {
2424
- utils.restoreSelection(this.savedSel);
2425
- return this.createlink($(e.target));
2426
- }
2427
- };
2428
-
2429
- Menu.prototype.removeLink = function() {
2430
- var elem;
2431
- this.menuApply("unlink");
2432
- elem = this.current_editor.getNode();
2433
- return this.current_editor.cleanContents($(elem));
2434
- };
2435
-
2436
- Menu.prototype.createlink = function(input) {
2437
- var action, inputValue;
2438
- $(this.el).removeClass("dante-menu--linkmode");
2439
- if (input.val()) {
2440
- inputValue = input.val().replace(this.strReg.whiteSpace, "").replace(this.strReg.mailTo, "mailto:$1").replace(this.strReg.http, "http://$1");
2441
- return this.menuApply("createlink", inputValue);
2442
- }
2443
- action = "unlink";
2444
- return this.menuApply(action);
2445
- };
2446
-
2447
- Menu.prototype.menuApply = function(action, value) {
2448
- if (this.commandsReg.block.test(action)) {
2449
- utils.log("block here");
2450
- this.commandBlock(action);
2451
- } else if (this.commandsReg.inline.test(action) || this.commandsReg.source.test(action)) {
2452
- utils.log("overall here");
2453
- this.commandOverall(action, value);
2454
- } else if (this.commandsReg.insert.test(action)) {
2455
- utils.log("insert here");
2456
- this.commandInsert(action);
2457
- } else if (this.commandsReg.wrap.test(action)) {
2458
- utils.log("wrap here");
2459
- this.commandWrap(action);
2460
- } else {
2461
- utils.log("can't find command function for action: " + action);
2462
- }
2463
- return false;
2464
- };
2465
-
2466
- Menu.prototype.setupInsertedElement = function(element) {
2467
- var n;
2468
- n = this.current_editor.addClassesToElement(element);
2469
- this.current_editor.setElementName(n);
2470
- return this.current_editor.markAsSelected(n);
2471
- };
2472
-
2473
- Menu.prototype.cleanContents = function() {
2474
- return this.current_editor.cleanContents();
2475
- };
2476
-
2477
- Menu.prototype.commandOverall = function(cmd, val) {
2478
- var message, n;
2479
- message = " to exec 「" + cmd + "」 command" + (val ? " with value: " + val : "");
2480
- if (document.execCommand(cmd, false, val)) {
2481
- utils.log("success" + message);
2482
- n = this.current_editor.getNode();
2483
- this.current_editor.setupLinks($(n).find("a"));
2484
- this.displayHighlights();
2485
- if ($(n).parent().hasClass("section-inner")) {
2486
- n = this.current_editor.addClassesToElement(n);
2487
- this.current_editor.setElementName(n);
2488
- }
2489
- this.current_editor.handleTextSelection(n);
2490
- } else {
2491
- utils.log("fail" + message, true);
2492
- }
2493
- };
2494
-
2495
- Menu.prototype.commandInsert = function(name) {
2496
- var node;
2497
- node = this.current_editor.current_node;
2498
- if (!node) {
2499
- return;
2500
- }
2501
- this.current_editor.current_range.selectNode(node);
2502
- this.current_editor.current_range.collapse(false);
2503
- return this.commandOverall(node, name);
2504
- };
2505
-
2506
- Menu.prototype.commandBlock = function(name) {
2507
- var list, node;
2508
- node = this.current_editor.current_node;
2509
- list = this.effectNode(this.current_editor.getNode(node), true);
2510
- if (list.indexOf(name) !== -1) {
2511
- name = "p";
2512
- }
2513
- return this.commandOverall("formatblock", name);
2514
- };
2515
-
2516
- Menu.prototype.commandWrap = function(tag) {
2517
- var node, val;
2518
- node = this.current_editor.current_node;
2519
- val = "<" + tag + ">" + selection + "</" + tag + ">";
2520
- return this.commandOverall("insertHTML", val);
2521
- };
2522
-
2523
- Menu.prototype.effectNode = function(el, returnAsNodeName) {
2524
- var nodes;
2525
- nodes = [];
2526
- el = el || this.current_editor.$el[0];
2527
- while (el !== this.current_editor.$el[0]) {
2528
- if (el.nodeName.match(this.effectNodeReg)) {
2529
- nodes.push((returnAsNodeName ? el.nodeName.toLowerCase() : el));
2530
- }
2531
- el = el.parentNode;
2532
- }
2533
- return nodes;
2534
- };
2535
-
2536
- Menu.prototype.displayHighlights = function() {
2537
- var nodes;
2538
- $(this.el).find(".active").removeClass("active");
2539
- nodes = this.effectNode(utils.getNode());
2540
- utils.log(nodes);
2541
- return _.each(nodes, (function(_this) {
2542
- return function(node) {
2543
- var tag;
2544
- tag = node.nodeName.toLowerCase();
2545
- switch (tag) {
2546
- case "a":
2547
- $(_this.el).find('input').val($(node).attr("href"));
2548
- tag = "createlink";
2549
- break;
2550
- case "i":
2551
- tag = "italic";
2552
- break;
2553
- case "u":
2554
- tag = "underline";
2555
- break;
2556
- case "b":
2557
- tag = "bold";
2558
- break;
2559
- case "code":
2560
- tag = "code";
2561
- break;
2562
- case "ul":
2563
- tag = "insertunorderedlist";
2564
- break;
2565
- case "ol":
2566
- tag = "insertorderedlist";
2567
- break;
2568
- case "li":
2569
- tag = "indent";
2570
- utils.log("nothing to select");
2571
- }
2572
- if (tag.match(/(?:h[1-6])/i)) {
2573
- $(_this.el).find(".icon-bold, .icon-italic, .icon-blockquote").parent("li").remove();
2574
- }
2575
- else if(tag === "indent"){
2576
- $(_this.el).find(".icon-h2, .icon-h3, .icon-h4, .icon-blockquote").parent("li").remove();
2577
- }
2578
- return _this.highlight(tag);
2579
- };
2580
- })(this));
2581
- };
2582
-
2583
- Menu.prototype.highlight = function(tag) {
2584
- return $(".icon-" + tag).parent("li").addClass("active");
2585
- };
2586
-
2587
- Menu.prototype.show = function() {
2588
- $(this.el).addClass("dante-menu--active");
2589
- this.closeInput();
2590
- return this.displayHighlights();
2591
- };
2592
-
2593
- Menu.prototype.hide = function() {
2594
- return $(this.el).removeClass("dante-menu--active");
2595
- };
2596
-
2597
- return Menu;
2598
-
2599
- })(Dante.View);
2600
-
2601
- }).call(this);
2602
- //Editor components
2603
-
2604
-
2605
-
2606
-
2607
-
2608
-
2609
-
2610
- ;