dante-editor 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,14 @@
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>
@@ -0,0 +1,36 @@
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>
@@ -0,0 +1,2532 @@
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.8"
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
+ "mouseover .graf--figure.graf--iframe": "handleGrafFigureSelectIframe",
438
+ "mouseleave .graf--figure.graf--iframe": "handleGrafFigureUnSelectIframe",
439
+ "keyup .graf--figure figcaption": "handleGrafCaptionTyping",
440
+ "mouseover .markup--anchor": "displayPopOver",
441
+ "mouseout .markup--anchor": "hidePopOver"
442
+ };
443
+
444
+ Editor.prototype.initialize = function(opts) {
445
+ if (opts == null) {
446
+ opts = {};
447
+ }
448
+ this.editor_options = opts;
449
+ this.initial_html = $(this.el).html();
450
+ this.current_range = null;
451
+ this.current_node = null;
452
+ this.el = opts.el || "#editor";
453
+ this.upload_url = opts.upload_url || "/uploads.json";
454
+ this.oembed_url = opts.oembed_url || "http://api.embed.ly/1/oembed?url=";
455
+ this.extract_url = opts.extract_url || "http://api.embed.ly/1/extract?key=86c28a410a104c8bb58848733c82f840&url=";
456
+ this.default_loading_placeholder = opts.default_loading_placeholder || Dante.defaults.image_placeholder;
457
+ this.store_url = opts.store_url;
458
+ this.spell_check = opts.spellcheck || false;
459
+ this.disable_title = opts.disable_title || false;
460
+ this.store_interval = opts.store_interval || 15000;
461
+ this.paste_element_id = "#dante-paste-div";
462
+ window.debugMode = opts.debug || false;
463
+ if (window.debugMode) {
464
+ $(this.el).addClass("debug");
465
+ }
466
+ if (localStorage.getItem('contenteditable')) {
467
+ $(this.el).html(localStorage.getItem('contenteditable'));
468
+ }
469
+ this.store();
470
+ this.title_placeholder = "<span class='defaultValue defaultValue--root'>Title</span><br>";
471
+ this.body_placeholder = "<span class='defaultValue defaultValue--root'>Tell your story…</span><br>";
472
+ this.embed_placeholder = "<span class='defaultValue defaultValue--prompt'>Paste a YouTube, Vine, Vimeo, or other video link, and press Enter</span><br>";
473
+ 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>";
474
+ };
475
+
476
+ Editor.prototype.store = function() {
477
+ if (!this.store_url) {
478
+ return;
479
+ }
480
+ return setTimeout((function(_this) {
481
+ return function() {
482
+ return _this.checkforStore();
483
+ };
484
+ })(this), this.store_interval);
485
+ };
486
+
487
+ Editor.prototype.checkforStore = function() {
488
+ if (this.content === this.getContent()) {
489
+ utils.log("content not changed skip store");
490
+ return this.store();
491
+ } else {
492
+ utils.log("content changed! update");
493
+ this.content = this.getContent();
494
+ return $.ajax({
495
+ url: this.store_url,
496
+ method: "post",
497
+ data: this.getContent(),
498
+ success: function(res) {
499
+ utils.log("store!");
500
+ return utils.log(res);
501
+ },
502
+ complete: (function(_this) {
503
+ return function(jxhr) {
504
+ return _this.store();
505
+ };
506
+ })(this)
507
+ });
508
+ }
509
+ };
510
+
511
+ Editor.prototype.getContent = function() {
512
+ return $(this.el).find(".section-inner").html();
513
+ };
514
+
515
+ Editor.prototype.renderTitle = function() {
516
+ return "<h3 class='graf graf--h3'>" + this.title_placeholder + " </h3>";
517
+ };
518
+
519
+ Editor.prototype.template = function() {
520
+ 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>";
521
+ };
522
+
523
+ Editor.prototype.baseParagraphTmpl = function() {
524
+ return "<p class='graf--p' name='" + (utils.generateUniqueName()) + "'><br></p>";
525
+ };
526
+
527
+ Editor.prototype.appendMenus = function() {
528
+ $("<div id='dante-menu' class='dante-menu'></div>").insertAfter(this.el);
529
+ $("<div class='inlineTooltip'></div>").insertAfter(this.el);
530
+ this.editor_menu = new Dante.Editor.Menu({
531
+ editor: this
532
+ });
533
+ this.tooltip_view = new Dante.Editor.Tooltip({
534
+ editor: this
535
+ });
536
+ this.pop_over = new Dante.Editor.PopOver({
537
+ editor: this
538
+ });
539
+ this.pop_over.render().hide();
540
+ return this.tooltip_view.render().hide();
541
+ };
542
+
543
+ Editor.prototype.appendInitialContent = function() {
544
+ $(this.el).find(".section-inner").html(this.initial_html);
545
+ return $(this.el).attr("spellcheck", this.spell_check);
546
+ };
547
+
548
+ Editor.prototype.start = function() {
549
+ this.render();
550
+ $(this.el).attr("contenteditable", "true");
551
+ $(this.el).addClass("postField postField--body editable smart-media-plugin");
552
+ $(this.el).wrap("<article class='postArticle'><div class='postContent'><div class='notesSource'></div></div></article>");
553
+ this.appendMenus();
554
+ if (!_.isEmpty(this.initial_html.trim())) {
555
+ this.appendInitialContent();
556
+ }
557
+ return this.parseInitialMess();
558
+ };
559
+
560
+ Editor.prototype.restart = function() {
561
+ return this.render();
562
+ };
563
+
564
+ Editor.prototype.render = function() {
565
+ this.template();
566
+ return $(this.el).html(this.template());
567
+ };
568
+
569
+ Editor.prototype.getSelectedText = function() {
570
+ var text;
571
+ text = "";
572
+ if (typeof window.getSelection !== "undefined") {
573
+ text = window.getSelection().toString();
574
+ } else if (typeof document.selection !== "undefined" && document.selection.type === "Text") {
575
+ text = document.selection.createRange().text;
576
+ }
577
+ return text;
578
+ };
579
+
580
+ Editor.prototype.selection = function() {
581
+ selection;
582
+ var selection;
583
+ if (window.getSelection) {
584
+ return selection = window.getSelection();
585
+ } else if (document.selection && document.selection.type !== "Control") {
586
+ return selection = document.selection;
587
+ }
588
+ };
589
+
590
+ Editor.prototype.getRange = function() {
591
+ var editor, range;
592
+ editor = $(this.el)[0];
593
+ range = selection && selection.rangeCount && selection.getRangeAt(0);
594
+ if (!range) {
595
+ range = document.createRange();
596
+ }
597
+ if (!editor.contains(range.commonAncestorContainer)) {
598
+ range.selectNodeContents(editor);
599
+ range.collapse(false);
600
+ }
601
+ return range;
602
+ };
603
+
604
+ Editor.prototype.setRange = function(range) {
605
+ range = range || this.current_range;
606
+ if (!range) {
607
+ range = this.getRange();
608
+ range.collapse(false);
609
+ }
610
+ this.selection().removeAllRanges();
611
+ this.selection().addRange(range);
612
+ return this;
613
+ };
614
+
615
+ Editor.prototype.getCharacterPrecedingCaret = function() {
616
+ var precedingChar, precedingRange, range, sel;
617
+ precedingChar = "";
618
+ sel = void 0;
619
+ range = void 0;
620
+ precedingRange = void 0;
621
+ if (window.getSelection) {
622
+ sel = window.getSelection();
623
+ if (sel.rangeCount > 0) {
624
+ range = sel.getRangeAt(0).cloneRange();
625
+ range.collapse(true);
626
+ range.setStart(this.getNode(), 0);
627
+ precedingChar = range.toString().slice(0);
628
+ }
629
+ } else if ((sel = document.selection) && sel.type !== "Control") {
630
+ range = sel.createRange();
631
+ precedingRange = range.duplicate();
632
+ precedingRange.moveToElementText(containerEl);
633
+ precedingRange.setEndPoint("EndToStart", range);
634
+ precedingChar = precedingRange.text.slice(0);
635
+ }
636
+ return precedingChar;
637
+ };
638
+
639
+ Editor.prototype.isLastChar = function() {
640
+ return $(this.getNode()).text().trim().length === this.getCharacterPrecedingCaret().trim().length;
641
+ };
642
+
643
+ Editor.prototype.isFirstChar = function() {
644
+ return this.getCharacterPrecedingCaret().trim().length === 0;
645
+ };
646
+
647
+ Editor.prototype.isSelectingAll = function(element) {
648
+ var a, b;
649
+ a = this.getSelectedText().killWhiteSpace().length;
650
+ b = $(element).text().killWhiteSpace().length;
651
+ return a === b;
652
+ };
653
+
654
+ Editor.prototype.setRangeAt = function(element, int) {
655
+ var range, sel;
656
+ if (int == null) {
657
+ int = 0;
658
+ }
659
+ range = document.createRange();
660
+ sel = window.getSelection();
661
+ range.setStart(element, int);
662
+ range.collapse(true);
663
+ sel.removeAllRanges();
664
+ sel.addRange(range);
665
+ return element.focus();
666
+ };
667
+
668
+ Editor.prototype.setRangeAtText = function(element, int) {
669
+ var node, range, sel;
670
+ if (int == null) {
671
+ int = 0;
672
+ }
673
+ range = document.createRange();
674
+ sel = window.getSelection();
675
+ node = element.firstChild;
676
+ range.setStart(node, 0);
677
+ range.setEnd(node, 0);
678
+ range.collapse(true);
679
+ sel.removeAllRanges();
680
+ sel.addRange(range);
681
+ return element.focus();
682
+ };
683
+
684
+ Editor.prototype.focus = function(focusStart) {
685
+ if (!focusStart) {
686
+ this.setRange();
687
+ }
688
+ $(this.el).focus();
689
+ return this;
690
+ };
691
+
692
+ Editor.prototype.focusNode = function(node, range) {
693
+ range.setStartAfter(node);
694
+ range.setEndBefore(node);
695
+ range.collapse(false);
696
+ return this.setRange(range);
697
+ };
698
+
699
+ Editor.prototype.getNode = function() {
700
+ var node, range, root;
701
+ node = void 0;
702
+ root = $(this.el).find(".section-inner")[0];
703
+ if (this.selection().rangeCount < 1) {
704
+ return;
705
+ }
706
+ range = this.selection().getRangeAt(0);
707
+ node = range.commonAncestorContainer;
708
+ if (!node || node === root) {
709
+ return null;
710
+ }
711
+ while (node && (node.nodeType !== 1 || !$(node).hasClass("graf")) && (node.parentNode !== root)) {
712
+ node = node.parentNode;
713
+ }
714
+ if (!$(node).hasClass("graf--li")) {
715
+ while (node && (node.parentNode !== root)) {
716
+ node = node.parentNode;
717
+ }
718
+ }
719
+ if (root && root.contains(node)) {
720
+ return node;
721
+ } else {
722
+ return null;
723
+ }
724
+ };
725
+
726
+ Editor.prototype.displayMenu = function(sel) {
727
+ return setTimeout((function(_this) {
728
+ return function() {
729
+ var pos;
730
+ _this.editor_menu.render();
731
+ pos = utils.getSelectionDimensions();
732
+ _this.relocateMenu(pos);
733
+ return _this.editor_menu.show();
734
+ };
735
+ })(this), 10);
736
+ };
737
+
738
+ Editor.prototype.handleDrag = function() {
739
+ return false;
740
+ };
741
+
742
+ Editor.prototype.handleGrafCaptionTyping = function(ev) {
743
+ if (_.isEmpty(utils.getNode().textContent.trim())) {
744
+ return $(this.getNode()).addClass("is-defaultValue");
745
+ } else {
746
+ return $(this.getNode()).removeClass("is-defaultValue");
747
+ }
748
+ };
749
+
750
+ Editor.prototype.handleTextSelection = function(anchor_node) {
751
+ var text;
752
+ this.editor_menu.hide();
753
+ text = this.getSelectedText();
754
+ if (!$(anchor_node).is(".graf--mixtapeEmbed, .graf--figure") && !_.isEmpty(text.trim())) {
755
+ this.current_node = anchor_node;
756
+ return this.displayMenu();
757
+ }
758
+ };
759
+
760
+ Editor.prototype.relocateMenu = function(position) {
761
+ var height, left, padd, top;
762
+ height = this.editor_menu.$el.outerHeight();
763
+ padd = this.editor_menu.$el.width() / 2;
764
+ top = position.top + $(window).scrollTop() - height;
765
+ left = position.left + (position.width / 2) - padd;
766
+ return this.editor_menu.$el.offset({
767
+ left: left,
768
+ top: top
769
+ });
770
+ };
771
+
772
+ Editor.prototype.hidePlaceholder = function(element) {
773
+ return $(element).find("span.defaultValue").remove().html("<br>");
774
+ };
775
+
776
+ Editor.prototype.displayEmptyPlaceholder = function(element) {
777
+ $(".graf--first").html(this.title_placeholder);
778
+ return $(".graf--last").html(this.body_placeholder);
779
+ };
780
+
781
+ Editor.prototype.displayPopOver = function(ev) {
782
+ return this.pop_over.displayAt(ev);
783
+ };
784
+
785
+ Editor.prototype.hidePopOver = function(ev) {
786
+ return this.pop_over.hide(ev);
787
+ };
788
+
789
+ Editor.prototype.handleGrafFigureSelectImg = function(ev) {
790
+ var element;
791
+ utils.log("FIGURE SELECT");
792
+ element = ev.currentTarget;
793
+ this.markAsSelected(element);
794
+ $(element).parent(".graf--figure").addClass("is-selected is-mediaFocused");
795
+ return this.selection().removeAllRanges();
796
+ };
797
+
798
+ Editor.prototype.handleGrafFigureSelectIframe = function(ev) {
799
+ var element;
800
+ utils.log("FIGURE IFRAME SELECT");
801
+ element = ev.currentTarget;
802
+ this.iframeSelected = element;
803
+ this.markAsSelected(element);
804
+ $(element).addClass("is-selected is-mediaFocused");
805
+ return this.selection().removeAllRanges();
806
+ };
807
+
808
+ Editor.prototype.handleGrafFigureUnSelectIframe = function(ev) {
809
+ var element;
810
+ utils.log("FIGURE IFRAME UNSELECT");
811
+ element = ev.currentTarget;
812
+ this.iframeSelected = null;
813
+ return $(element).removeClass("is-selected is-mediaFocused");
814
+ };
815
+
816
+ Editor.prototype.handleGrafFigureSelectCaption = function(ev) {
817
+ var element;
818
+ utils.log("FIGCAPTION");
819
+ element = ev.currentTarget;
820
+ return $(element).parent(".graf--figure").removeClass("is-mediaFocused");
821
+ };
822
+
823
+ Editor.prototype.handleMouseUp = function(ev) {
824
+ var anchor_node;
825
+ utils.log("MOUSE UP");
826
+ anchor_node = this.getNode();
827
+ if (_.isNull(anchor_node)) {
828
+ return;
829
+ }
830
+ this.prev_current_node = anchor_node;
831
+ this.handleTextSelection(anchor_node);
832
+ this.hidePlaceholder(anchor_node);
833
+ this.markAsSelected(anchor_node);
834
+ return this.displayTooltipAt(anchor_node);
835
+ };
836
+
837
+ Editor.prototype.scrollTo = function(node) {
838
+ var top;
839
+ if (utils.isElementInViewport($(node))) {
840
+ return;
841
+ }
842
+ top = node.offset().top;
843
+ return $('html, body').animate({
844
+ scrollTop: top
845
+ }, 20);
846
+ };
847
+
848
+ Editor.prototype.handleArrow = function(ev) {
849
+ var current_node;
850
+ current_node = $(this.getNode());
851
+ if (current_node.length > 0) {
852
+ this.markAsSelected(current_node);
853
+ return this.displayTooltipAt(current_node);
854
+ }
855
+ };
856
+
857
+ Editor.prototype.handleArrowForKeyDown = function(ev) {
858
+ var caret_node, current_node, ev_type, n, next_node, num, prev_node;
859
+ caret_node = this.getNode();
860
+ current_node = $(caret_node);
861
+ utils.log(ev);
862
+ ev_type = ev.originalEvent.key || ev.originalEvent.keyIdentifier;
863
+ utils.log("ENTER ARROW for key " + ev_type);
864
+ switch (ev_type) {
865
+ case "Down":
866
+ if (_.isUndefined(current_node) || !current_node.exists()) {
867
+ if ($(".is-selected").exists()) {
868
+ current_node = $(".is-selected");
869
+ }
870
+ }
871
+ next_node = current_node.next();
872
+ utils.log("NEXT NODE IS " + (next_node.attr('class')));
873
+ utils.log("CURRENT NODE IS " + (current_node.attr('class')));
874
+ if (!$(current_node).hasClass("graf")) {
875
+ return;
876
+ }
877
+ if (!(current_node.hasClass("graf--figure") || $(current_node).editableCaretOnLastLine())) {
878
+ return;
879
+ }
880
+ utils.log("ENTER ARROW PASSED RETURNS");
881
+ if (next_node.hasClass("graf--figure") && caret_node) {
882
+ n = next_node.find(".imageCaption");
883
+ this.scrollTo(n);
884
+ utils.log("1 down");
885
+ utils.log(n[0]);
886
+ this.skip_keyup = true;
887
+ this.selection().removeAllRanges();
888
+ this.markAsSelected(next_node);
889
+ next_node.addClass("is-mediaFocused is-selected");
890
+ return false;
891
+ } else if (next_node.hasClass("graf--mixtapeEmbed")) {
892
+ n = current_node.next(".graf--mixtapeEmbed");
893
+ num = n[0].childNodes.length;
894
+ this.setRangeAt(n[0], num);
895
+ this.scrollTo(n);
896
+ utils.log("2 down");
897
+ return false;
898
+ }
899
+ if (current_node.hasClass("graf--figure") && next_node.hasClass("graf")) {
900
+ this.scrollTo(next_node);
901
+ utils.log("3 down, from figure to next graf");
902
+ this.markAsSelected(next_node);
903
+ this.setRangeAt(next_node[0]);
904
+ return false;
905
+ }
906
+ break;
907
+ case "Up":
908
+ prev_node = current_node.prev();
909
+ utils.log("PREV NODE IS " + (prev_node.attr('class')));
910
+ utils.log("CURRENT NODE IS up " + (current_node.attr('class')));
911
+ if (!$(current_node).hasClass("graf")) {
912
+ return;
913
+ }
914
+ if (!$(current_node).editableCaretOnFirstLine()) {
915
+ return;
916
+ }
917
+ utils.log("ENTER ARROW PASSED RETURNS");
918
+ if (prev_node.hasClass("graf--figure")) {
919
+ utils.log("1 up");
920
+ n = prev_node.find(".imageCaption");
921
+ this.scrollTo(n);
922
+ this.skip_keyup = true;
923
+ this.selection().removeAllRanges();
924
+ this.markAsSelected(prev_node);
925
+ prev_node.addClass("is-mediaFocused");
926
+ return false;
927
+ } else if (prev_node.hasClass("graf--mixtapeEmbed")) {
928
+ n = current_node.prev(".graf--mixtapeEmbed");
929
+ num = n[0].childNodes.length;
930
+ this.setRangeAt(n[0], num);
931
+ this.scrollTo(n);
932
+ utils.log("2 up");
933
+ return false;
934
+ }
935
+ if (current_node.hasClass("graf--figure") && prev_node.hasClass("graf")) {
936
+ this.setRangeAt(prev_node[0]);
937
+ this.scrollTo(prev_node);
938
+ utils.log("3 up");
939
+ return false;
940
+ } else if (prev_node.hasClass("graf")) {
941
+ n = current_node.prev(".graf");
942
+ num = n[0].childNodes.length;
943
+ this.scrollTo(n);
944
+ utils.log("4 up");
945
+ this.skip_keyup = true;
946
+ this.markAsSelected(prev_node);
947
+ return false;
948
+ }
949
+ }
950
+ };
951
+
952
+ Editor.prototype.parseInitialMess = function() {
953
+ return this.setupElementsClasses($(this.el).find('.section-inner'), (function(_this) {
954
+ return function() {
955
+ return _this.handleUnwrappedImages($(_this.el).find('.section-inner'));
956
+ };
957
+ })(this));
958
+ };
959
+
960
+ Editor.prototype.handleDblclick = function() {
961
+ var node;
962
+ utils.log("handleDblclick");
963
+ node = this.getNode();
964
+ if (_.isNull(node)) {
965
+ this.setRangeAt(this.prev_current_node);
966
+ }
967
+ return false;
968
+ };
969
+
970
+ Editor.prototype.handlePaste = function(ev) {
971
+ var cbd, pastedText;
972
+ utils.log("pasted!");
973
+ this.aa = this.getNode();
974
+ pastedText = void 0;
975
+ if (window.clipboardData && window.clipboardData.getData) {
976
+ pastedText = window.clipboardData.getData('Text');
977
+ } else if (ev.originalEvent.clipboardData && ev.originalEvent.clipboardData.getData) {
978
+ cbd = ev.originalEvent.clipboardData;
979
+ pastedText = _.isEmpty(cbd.getData('text/html')) ? cbd.getData('text/plain') : cbd.getData('text/html');
980
+ }
981
+ utils.log("Process and handle text...");
982
+ if (pastedText.match(/<\/*[a-z][^>]+?>/gi)) {
983
+ utils.log("HTML DETECTED ON PASTE");
984
+ pastedText = pastedText.replace(/&.*;/g, "");
985
+ pastedText = pastedText.replace(/<div>([\w\W]*?)<\/div>/gi, '<p>$1</p>');
986
+ document.body.appendChild($("<div id='" + (this.paste_element_id.replace('#', '')) + "'></div>")[0]);
987
+ $(this.paste_element_id).html("<span>" + pastedText + "</span>");
988
+ this.setupElementsClasses($(this.paste_element_id), (function(_this) {
989
+ return function() {
990
+ var last_node, new_node, nodes, num, top;
991
+ nodes = $($(_this.paste_element_id).html()).insertAfter($(_this.aa));
992
+ $(_this.paste_element_id).remove();
993
+ last_node = nodes.last()[0];
994
+ num = last_node.childNodes.length;
995
+ _this.setRangeAt(last_node, num);
996
+ new_node = $(_this.getNode());
997
+ top = new_node.offset().top;
998
+ _this.markAsSelected(new_node);
999
+ _this.displayTooltipAt($(_this.el).find(".is-selected"));
1000
+ _this.handleUnwrappedImages(nodes);
1001
+ return $('html, body').animate({
1002
+ scrollTop: top
1003
+ }, 200);
1004
+ };
1005
+ })(this));
1006
+ return false;
1007
+ }
1008
+ };
1009
+
1010
+ Editor.prototype.handleUnwrappedImages = function(elements) {
1011
+ return _.each(elements.find("img"), (function(_this) {
1012
+ return function(image) {
1013
+ utils.log("process image here!");
1014
+ return _this.tooltip_view.uploadExistentImage(image);
1015
+ };
1016
+ })(this));
1017
+ };
1018
+
1019
+ Editor.prototype.handleInmediateDeletion = function(element) {
1020
+ var new_node;
1021
+ this.inmediateDeletion = false;
1022
+ new_node = $(this.baseParagraphTmpl()).insertBefore($(element));
1023
+ new_node.addClass("is-selected");
1024
+ this.setRangeAt($(element).prev()[0]);
1025
+ return $(element).remove();
1026
+ };
1027
+
1028
+ Editor.prototype.handleUnwrappedNode = function(element) {
1029
+ var new_node, tmpl;
1030
+ tmpl = $(this.baseParagraphTmpl());
1031
+ this.setElementName(tmpl);
1032
+ $(element).wrap(tmpl);
1033
+ new_node = $("[name='" + (tmpl.attr('name')) + "']");
1034
+ new_node.addClass("is-selected");
1035
+ this.setRangeAt(new_node[0]);
1036
+ return false;
1037
+ };
1038
+
1039
+
1040
+ /*
1041
+ This is a rare hack only for FF (I hope),
1042
+ when there is no range it creates a new element as a placeholder,
1043
+ then finds previous element from that placeholder,
1044
+ then it focus the prev and removes the placeholder.
1045
+ a nasty nasty one...
1046
+ */
1047
+
1048
+ Editor.prototype.handleNullAnchor = function() {
1049
+ var node, num, prev, range, sel, span;
1050
+ utils.log("WARNING! this is an empty node");
1051
+ sel = this.selection();
1052
+ if (sel.isCollapsed && sel.rangeCount > 0) {
1053
+ range = sel.getRangeAt(0);
1054
+ span = $(this.baseParagraphTmpl())[0];
1055
+ range.insertNode(span);
1056
+ range.setStart(span, 0);
1057
+ range.setEnd(span, 0);
1058
+ sel.removeAllRanges();
1059
+ sel.addRange(range);
1060
+ node = $(range.commonAncestorContainer);
1061
+ prev = node.prev();
1062
+ num = prev[0].childNodes.length;
1063
+ utils.log(prev);
1064
+ if (prev.hasClass("graf")) {
1065
+ this.setRangeAt(prev[0], num);
1066
+ node.remove();
1067
+ this.markAsSelected(this.getNode());
1068
+ } else if (prev.hasClass("graf--mixtapeEmbed")) {
1069
+ this.setRangeAt(prev[0], num);
1070
+ node.remove();
1071
+ this.markAsSelected(this.getNode());
1072
+ } else if (!prev) {
1073
+ this.setRangeAt(this.$el.find(".section-inner p")[0]);
1074
+ }
1075
+ return this.displayTooltipAt($(this.el).find(".is-selected"));
1076
+ }
1077
+ };
1078
+
1079
+ Editor.prototype.handleCompleteDeletion = function(element) {
1080
+ if (_.isEmpty($(element).text().trim())) {
1081
+ utils.log("HANDLE COMPLETE DELETION");
1082
+ this.selection().removeAllRanges();
1083
+ this.render();
1084
+ setTimeout((function(_this) {
1085
+ return function() {
1086
+ return _this.setRangeAt($(_this.el).find(".section-inner p")[0]);
1087
+ };
1088
+ })(this), 20);
1089
+ return this.completeDeletion = true;
1090
+ }
1091
+ };
1092
+
1093
+ Editor.prototype.handleTab = function(anchor_node) {
1094
+ var classes, next;
1095
+ utils.log("HANDLE TAB");
1096
+ classes = ".graf, .graf--mixtapeEmbed, .graf--figure, .graf--figure";
1097
+ next = $(anchor_node).next(classes);
1098
+ if ($(next).hasClass("graf--figure")) {
1099
+ next = $(next).find("figcaption");
1100
+ this.setRangeAt(next[0]);
1101
+ this.markAsSelected($(next).parent(".graf--figure"));
1102
+ this.displayTooltipAt(next);
1103
+ this.scrollTo($(next));
1104
+ return false;
1105
+ }
1106
+ if (_.isEmpty(next) || _.isUndefined(next[0])) {
1107
+ next = $(".graf:first");
1108
+ }
1109
+ this.setRangeAt(next[0]);
1110
+ this.markAsSelected(next);
1111
+ this.displayTooltipAt(next);
1112
+ return this.scrollTo($(next));
1113
+ };
1114
+
1115
+ Editor.prototype.handleKeyDown = function(e) {
1116
+ var $node, anchor_node, li, parent, utils_anchor_node;
1117
+ utils.log("KEYDOWN");
1118
+ anchor_node = this.getNode();
1119
+ $node = $(anchor_node);
1120
+ if (anchor_node) {
1121
+ this.markAsSelected(anchor_node);
1122
+ }
1123
+ if (e.which === 9) {
1124
+ this.handleTab(anchor_node);
1125
+ return false;
1126
+ }
1127
+ if (e.which === 13) {
1128
+ $(this.el).find(".is-selected").removeClass("is-selected");
1129
+ parent = $(anchor_node);
1130
+ utils.log(this.isLastChar());
1131
+ if ($node.hasClass("graf--p")) {
1132
+ li = this.handleSmartList($node, e);
1133
+ if (li) {
1134
+ anchor_node = li;
1135
+ }
1136
+ } else if ($node.hasClass("graf--li") && ($node.text() === "")) {
1137
+ this.handleListLineBreak($node, e);
1138
+ }
1139
+ if (parent.hasClass("is-embedable")) {
1140
+ this.tooltip_view.getEmbedFromNode($(anchor_node));
1141
+ } else if (parent.hasClass("is-extractable")) {
1142
+ this.tooltip_view.getExtractFromNode($(anchor_node));
1143
+ }
1144
+ if (parent.hasClass("graf--mixtapeEmbed") || parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1145
+ utils.log("supress linebreak from embed !(last char)");
1146
+ if (!this.isLastChar()) {
1147
+ return false;
1148
+ }
1149
+ }
1150
+ if (parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1151
+ if (this.isLastChar()) {
1152
+ this.handleLineBreakWith("p", parent);
1153
+ this.setRangeAtText($(".is-selected")[0]);
1154
+ $(".is-selected").trigger("mouseup");
1155
+ return false;
1156
+ } else {
1157
+ return false;
1158
+ }
1159
+ }
1160
+ this.tooltip_view.cleanOperationClasses($(anchor_node));
1161
+ if (anchor_node && this.editor_menu.lineBreakReg.test(anchor_node.nodeName)) {
1162
+ if (this.isLastChar()) {
1163
+ utils.log("new paragraph if it's the last character");
1164
+ e.preventDefault();
1165
+ this.handleLineBreakWith("p", parent);
1166
+ }
1167
+ }
1168
+ setTimeout((function(_this) {
1169
+ return function() {
1170
+ var node;
1171
+ node = _this.getNode();
1172
+ if (_.isUndefined(node)) {
1173
+ return;
1174
+ }
1175
+ _this.setElementName($(node));
1176
+ if (node.nodeName.toLowerCase() === "div") {
1177
+ node = _this.replaceWith("p", $(node))[0];
1178
+ }
1179
+ _this.markAsSelected($(node));
1180
+ _this.setupFirstAndLast();
1181
+ if (_.isEmpty($(node).text().trim())) {
1182
+ _.each($(node).children(), function(n) {
1183
+ return $(n).remove();
1184
+ });
1185
+ $(node).append("<br>");
1186
+ }
1187
+ return _this.displayTooltipAt($(_this.el).find(".is-selected"));
1188
+ };
1189
+ })(this), 2);
1190
+ }
1191
+ if (e.which === 8) {
1192
+ this.tooltip_view.hide();
1193
+ utils.log("removing from down");
1194
+ if (this.reachedTop) {
1195
+ utils.log("REACHED TOP");
1196
+ }
1197
+ if (this.prevented || this.reachedTop && this.isFirstChar()) {
1198
+ return false;
1199
+ }
1200
+ utils.log("pass initial validations");
1201
+ anchor_node = this.getNode();
1202
+ utils_anchor_node = utils.getNode();
1203
+ if ($node.hasClass("graf--li") && this.getCharacterPrecedingCaret().length === 0) {
1204
+ return this.handleListBackspace($node, e);
1205
+ }
1206
+ if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1207
+ utils.log("SECTION DETECTED FROM KEYDOWN " + (_.isEmpty($(utils_anchor_node).text())));
1208
+ if (_.isEmpty($(utils_anchor_node).text())) {
1209
+ return false;
1210
+ }
1211
+ }
1212
+ if (anchor_node && anchor_node.nodeType === 3) {
1213
+ utils.log("TextNode detected from Down!");
1214
+ }
1215
+ if ($(anchor_node).hasClass("graf--mixtapeEmbed") || $(anchor_node).hasClass("graf--iframe")) {
1216
+ if (_.isEmpty($(anchor_node).text().trim() || this.isFirstChar())) {
1217
+ utils.log("Check for inmediate deletion on empty embed text");
1218
+ this.inmediateDeletion = this.isSelectingAll(anchor_node);
1219
+ if (this.inmediateDeletion) {
1220
+ this.handleInmediateDeletion($(anchor_node));
1221
+ }
1222
+ return false;
1223
+ }
1224
+ }
1225
+ if ($(anchor_node).prev().hasClass("graf--mixtapeEmbed")) {
1226
+ if (this.isFirstChar() && !_.isEmpty($(anchor_node).text().trim())) {
1227
+ return false;
1228
+ }
1229
+ }
1230
+ if ($(".is-selected").hasClass("graf--figure") && (anchor_node == null)) {
1231
+ this.replaceWith("p", $(".is-selected"));
1232
+ this.setRangeAt($(".is-selected")[0]);
1233
+ return false;
1234
+ }
1235
+ }
1236
+ if (e.which === 32) {
1237
+ utils.log("SPACEBAR");
1238
+ if ($node.hasClass("graf--p")) {
1239
+ this.handleSmartList($node, e);
1240
+ }
1241
+ }
1242
+ if (_.contains([38, 40], e.which)) {
1243
+ utils.log(e.which);
1244
+ this.handleArrowForKeyDown(e);
1245
+ }
1246
+ if (anchor_node) {
1247
+ if (!_.isEmpty($(anchor_node).text())) {
1248
+ this.tooltip_view.hide();
1249
+ $(anchor_node).removeClass("graf--empty");
1250
+ }
1251
+ }
1252
+ if (_.isUndefined(anchor_node) && $(".is-selected").hasClass("is-mediaFocused")) {
1253
+ this.setRangeAt($(".is-selected").find("figcaption")[0]);
1254
+ $(".is-selected").removeClass("is-mediaFocused");
1255
+ return false;
1256
+ }
1257
+ };
1258
+
1259
+ Editor.prototype.handleKeyUp = function(e, node) {
1260
+ var anchor_node, next_graf, utils_anchor_node;
1261
+ if (this.skip_keyup) {
1262
+ this.skip_keyup = null;
1263
+ utils.log("SKIP KEYUP");
1264
+ return false;
1265
+ }
1266
+ utils.log("KEYUP");
1267
+ this.editor_menu.hide();
1268
+ this.reachedTop = false;
1269
+ anchor_node = this.getNode();
1270
+ utils_anchor_node = utils.getNode();
1271
+ this.handleTextSelection(anchor_node);
1272
+ if (e.which === 8) {
1273
+ if ($(utils_anchor_node).hasClass("postField--body")) {
1274
+ utils.log("ALL GONE from UP");
1275
+ this.handleCompleteDeletion($(this.el));
1276
+ if (this.completeDeletion) {
1277
+ this.completeDeletion = false;
1278
+ return false;
1279
+ }
1280
+ }
1281
+ if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1282
+ utils.log("SECTION DETECTED FROM KEYUP " + (_.isEmpty($(utils_anchor_node).text())));
1283
+ if (_.isEmpty($(utils_anchor_node).text())) {
1284
+ next_graf = $(utils_anchor_node).next(".graf")[0];
1285
+ if (next_graf) {
1286
+ this.setRangeAt(next_graf);
1287
+ $(utils_anchor_node).remove();
1288
+ this.setupFirstAndLast();
1289
+ }
1290
+ return false;
1291
+ }
1292
+ }
1293
+ if (_.isNull(anchor_node)) {
1294
+ this.handleNullAnchor();
1295
+ return false;
1296
+ }
1297
+ if ($(anchor_node).hasClass("graf--first")) {
1298
+ utils.log("THE FIRST ONE! UP");
1299
+ if (this.getSelectedText() === this.getNode().textContent) {
1300
+ utils.log("remove selection dectected");
1301
+ this.getNode().innerHTML = "<br>";
1302
+ }
1303
+ this.markAsSelected(anchor_node);
1304
+ this.setupFirstAndLast();
1305
+ false;
1306
+ }
1307
+ }
1308
+ if (_.contains([37, 38, 39, 40], e.which)) {
1309
+ return this.handleArrow(e);
1310
+ }
1311
+ };
1312
+
1313
+ Editor.prototype.handleLineBreakWith = function(element_type, from_element) {
1314
+ var new_paragraph;
1315
+ new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1316
+ if (from_element.parent().is('[class^="graf--"]')) {
1317
+ new_paragraph.insertAfter(from_element.parent());
1318
+ } else {
1319
+ new_paragraph.insertAfter(from_element);
1320
+ }
1321
+ this.setRangeAt(new_paragraph[0]);
1322
+ return this.scrollTo(new_paragraph);
1323
+ };
1324
+
1325
+ Editor.prototype.replaceWith = function(element_type, from_element) {
1326
+ var new_paragraph;
1327
+ new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1328
+ from_element.replaceWith(new_paragraph);
1329
+ this.setRangeAt(new_paragraph[0]);
1330
+ this.scrollTo(new_paragraph);
1331
+ return new_paragraph;
1332
+ };
1333
+
1334
+ Editor.prototype.displayTooltipAt = function(element) {
1335
+ utils.log("POSITION FOR TOOLTIP");
1336
+ element = $(element);
1337
+ if (!element || _.isEmpty(element) || element[0].tagName === "LI") {
1338
+ return;
1339
+ }
1340
+ this.tooltip_view.hide();
1341
+ if (!_.isEmpty(element.text())) {
1342
+ return;
1343
+ }
1344
+ this.positions = element.offset();
1345
+ this.tooltip_view.render();
1346
+ return this.tooltip_view.move(this.positions);
1347
+ };
1348
+
1349
+ Editor.prototype.markAsSelected = function(element) {
1350
+ if (_.isUndefined(element)) {
1351
+ return;
1352
+ }
1353
+ $(this.el).find(".is-selected").removeClass("is-mediaFocused is-selected");
1354
+ $(element).addClass("is-selected");
1355
+ $(element).find(".defaultValue").remove();
1356
+ if ($(element).hasClass("graf--first")) {
1357
+ this.reachedTop = true;
1358
+ if ($(element).find("br").length === 0) {
1359
+ return $(element).append("<br>");
1360
+ }
1361
+ }
1362
+ };
1363
+
1364
+ Editor.prototype.addClassesToElement = function(element) {
1365
+ var n, name, new_el;
1366
+ n = element;
1367
+ name = n.nodeName.toLowerCase();
1368
+ switch (name) {
1369
+ case "p":
1370
+ case "pre":
1371
+ case "div":
1372
+ if (!$(n).hasClass("graf--mixtapeEmbed")) {
1373
+ $(n).removeClass().addClass("graf graf--" + name);
1374
+ }
1375
+ if (name === "p" && $(n).find("br").length === 0) {
1376
+ $(n).append("<br>");
1377
+ }
1378
+ break;
1379
+ case "h1":
1380
+ case "h2":
1381
+ case "h3":
1382
+ case "h4":
1383
+ case "h5":
1384
+ case "h6":
1385
+ if (name === "h1") {
1386
+ new_el = $("<h2 class='graf graf--h2'>" + ($(n).text()) + "</h2>");
1387
+ $(n).replaceWith(new_el);
1388
+ this.setElementName(n);
1389
+ } else {
1390
+ $(n).removeClass().addClass("graf graf--" + name);
1391
+ }
1392
+ break;
1393
+ case "code":
1394
+ $(n).unwrap().wrap("<p class='graf graf--pre'></p>");
1395
+ n = $(n).parent();
1396
+ break;
1397
+ case "ol":
1398
+ case "ul":
1399
+ utils.log("lists");
1400
+ $(n).removeClass().addClass("postList");
1401
+ _.each($(n).find("li"), function(li) {
1402
+ return $(li).removeClass().addClass("graf graf--li");
1403
+ });
1404
+ break;
1405
+ case "img":
1406
+ utils.log("images");
1407
+ this.tooltip_view.uploadExistentImage(n);
1408
+ break;
1409
+ case "a":
1410
+ case 'strong':
1411
+ case 'em':
1412
+ case 'br':
1413
+ case 'b':
1414
+ case 'u':
1415
+ case 'i':
1416
+ utils.log("links");
1417
+ $(n).wrap("<p class='graf graf--p'></p>");
1418
+ n = $(n).parent();
1419
+ break;
1420
+ case "blockquote":
1421
+ n = $(n).removeClass().addClass("graf graf--" + name);
1422
+ break;
1423
+ case "figure":
1424
+ if ($(n).hasClass(".graf--figure")) {
1425
+ n = $(n);
1426
+ }
1427
+ break;
1428
+ default:
1429
+ $(n).wrap("<p class='graf graf--" + name + "'></p>");
1430
+ n = $(n).parent();
1431
+ }
1432
+ return n;
1433
+ };
1434
+
1435
+ Editor.prototype.setupElementsClasses = function(element, cb) {
1436
+ if (_.isUndefined(element)) {
1437
+ this.element = $(this.el).find('.section-inner');
1438
+ } else {
1439
+ this.element = element;
1440
+ }
1441
+ return setTimeout((function(_this) {
1442
+ return function() {
1443
+ _this.cleanContents(_this.element);
1444
+ _this.wrapTextNodes(_this.element);
1445
+ _.each(_this.element.children(), function(n) {
1446
+ var name;
1447
+ name = $(n).prop("tagName").toLowerCase();
1448
+ n = _this.addClassesToElement(n);
1449
+ return _this.setElementName(n);
1450
+ });
1451
+ _this.setupLinks(_this.element.find("a"));
1452
+ _this.setupFirstAndLast();
1453
+ if (_.isFunction(cb)) {
1454
+ return cb();
1455
+ }
1456
+ };
1457
+ })(this), 20);
1458
+ };
1459
+
1460
+ Editor.prototype.cleanContents = function(element) {
1461
+ var s;
1462
+ if (_.isUndefined(element)) {
1463
+ this.element = $(this.el).find('.section-inner');
1464
+ } else {
1465
+ this.element = element;
1466
+ }
1467
+ s = new Sanitize({
1468
+ elements: ['strong', 'img', 'em', 'br', 'a', 'blockquote', 'b', 'u', 'i', 'pre', 'p', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li'],
1469
+ attributes: {
1470
+ '__ALL__': ['class'],
1471
+ a: ['href', 'title', 'target'],
1472
+ img: ['src']
1473
+ },
1474
+ protocols: {
1475
+ a: {
1476
+ href: ['http', 'https', 'mailto']
1477
+ }
1478
+ },
1479
+ transformers: [
1480
+ function(input) {
1481
+ if (input.node_name === "span" && $(input.node).hasClass("defaultValue")) {
1482
+ return {
1483
+ whitelist_nodes: [input.node]
1484
+ };
1485
+ } else {
1486
+ return null;
1487
+ }
1488
+ }, function(input) {
1489
+ if (input.node_name === 'div' && $(input.node).hasClass("graf--mixtapeEmbed")) {
1490
+ return {
1491
+ whitelist_nodes: [input.node]
1492
+ };
1493
+ } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1494
+ return {
1495
+ attr_whitelist: ["style"]
1496
+ };
1497
+ } else {
1498
+ return null;
1499
+ }
1500
+ }, function(input) {
1501
+ if (input.node_name === 'figure' && $(input.node).hasClass("graf--iframe")) {
1502
+ return {
1503
+ whitelist_nodes: [input.node]
1504
+ };
1505
+ } else if (input.node_name === 'div' && $(input.node).hasClass("iframeContainer") && $(input.node).parent(".graf--iframe").exists()) {
1506
+ return {
1507
+ whitelist_nodes: [input.node]
1508
+ };
1509
+ } else if (input.node_name === 'iframe' && $(input.node).parent(".iframeContainer").exists()) {
1510
+ return {
1511
+ whitelist_nodes: [input.node]
1512
+ };
1513
+ } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--iframe").exists()) {
1514
+ return {
1515
+ whitelist_nodes: [input.node]
1516
+ };
1517
+ } else {
1518
+ return null;
1519
+ }
1520
+ }, function(input) {
1521
+ if (input.node_name === 'figure' && $(input.node).hasClass("graf--figure")) {
1522
+ return {
1523
+ whitelist_nodes: [input.node]
1524
+ };
1525
+ } else if (input.node_name === 'div' && ($(input.node).hasClass("aspectRatioPlaceholder") && $(input.node).parent(".graf--figure").exists())) {
1526
+ return {
1527
+ whitelist_nodes: [input.node]
1528
+ };
1529
+ } else if (input.node_name === 'div' && ($(input.node).hasClass("aspect-ratio-fill") && $(input.node).parent(".aspectRatioPlaceholder").exists())) {
1530
+ return {
1531
+ whitelist_nodes: [input.node]
1532
+ };
1533
+ } else if (input.node_name === 'img' && $(input.node).parent(".graf--figure").exists()) {
1534
+ return {
1535
+ whitelist_nodes: [input.node]
1536
+ };
1537
+ } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1538
+ return {
1539
+ attr_whitelist: ["style"]
1540
+ };
1541
+ } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--figure").exists()) {
1542
+ return {
1543
+ whitelist_nodes: [input.node]
1544
+ };
1545
+ } else if (input.node_name === 'span' && $(input.node).parent(".imageCaption").exists()) {
1546
+ return {
1547
+ whitelist_nodes: [input.node]
1548
+ };
1549
+ } else {
1550
+ return null;
1551
+ }
1552
+ }
1553
+ ]
1554
+ });
1555
+ if (this.element.exists()) {
1556
+ utils.log("CLEAN HTML " + this.element[0].tagName);
1557
+ return this.element.html(s.clean_node(this.element[0]));
1558
+ }
1559
+ };
1560
+
1561
+ Editor.prototype.setupLinks = function(elems) {
1562
+ return _.each(elems, (function(_this) {
1563
+ return function(n) {
1564
+ return _this.setupLink(n);
1565
+ };
1566
+ })(this));
1567
+ };
1568
+
1569
+ Editor.prototype.setupLink = function(n) {
1570
+ var href, parent_name;
1571
+ parent_name = $(n).parent().prop("tagName").toLowerCase();
1572
+ $(n).addClass("markup--anchor markup--" + parent_name + "-anchor");
1573
+ href = $(n).attr("href");
1574
+ return $(n).attr("data-href", href);
1575
+ };
1576
+
1577
+ Editor.prototype.preCleanNode = function(element) {
1578
+ var s;
1579
+ s = new Sanitize({
1580
+ elements: ['strong', 'em', 'br', 'a', 'b', 'u', 'i', 'ul', 'ol', 'li'],
1581
+ attributes: {
1582
+ a: ['href', 'title', 'target']
1583
+ },
1584
+ protocols: {
1585
+ a: {
1586
+ href: ['http', 'https', 'mailto']
1587
+ }
1588
+ }
1589
+ });
1590
+ $(element).html(s.clean_node(element[0]));
1591
+ element = this.addClassesToElement($(element)[0]);
1592
+ return $(element);
1593
+ };
1594
+
1595
+ Editor.prototype.setupFirstAndLast = function() {
1596
+ var childs;
1597
+ childs = $(this.el).find(".section-inner").children();
1598
+ childs.removeClass("graf--last , graf--first");
1599
+ childs.first().addClass("graf--first");
1600
+ return childs.last().addClass("graf--last");
1601
+ };
1602
+
1603
+ Editor.prototype.wrapTextNodes = function(element) {
1604
+ if (_.isUndefined(element)) {
1605
+ element = $(this.el).find('.section-inner');
1606
+ } else {
1607
+ element = element;
1608
+ }
1609
+ return element.contents().filter(function() {
1610
+ return this.nodeType === 3 && this.data.trim().length > 0;
1611
+ }).wrap("<p class='graf grap--p'></p>");
1612
+ };
1613
+
1614
+ Editor.prototype.setElementName = function(element) {
1615
+ return $(element).attr("name", utils.generateUniqueName());
1616
+ };
1617
+
1618
+ Editor.prototype.listify = function($paragraph, listType, tagLength) {
1619
+ var $li, $list, content;
1620
+ utils.log("LISTIFY PARAGRAPH");
1621
+ content = $paragraph.html().replace(/&nbsp;/g, " ");
1622
+ utils.log(tagLength);
1623
+ content = content.slice(tagLength, content.length);
1624
+ switch (listType) {
1625
+ case "ul":
1626
+ $list = $("<ul></ul>");
1627
+ break;
1628
+ case "ol":
1629
+ $list = $("<ol></ol>");
1630
+ break;
1631
+ default:
1632
+ return false;
1633
+ }
1634
+ this.addClassesToElement($list[0]);
1635
+ this.replaceWith("li", $paragraph);
1636
+ $li = $(".is-selected");
1637
+ this.setElementName($li[0]);
1638
+ $li.html(content).wrap($list);
1639
+ if ($li.find("br").length === 0) {
1640
+ $li.append("<br/>");
1641
+ }
1642
+ this.setRangeAt($li[0]);
1643
+ return $li[0];
1644
+ };
1645
+
1646
+ Editor.prototype.handleSmartList = function($item, e) {
1647
+ var $li, match;
1648
+ utils.log("HANDLE A SMART LIST");
1649
+ match = $item.text().match(/^\s*(\-|\*)\s*/);
1650
+ if (match) {
1651
+ utils.log("CREATING UL LIST ITEM");
1652
+ e.preventDefault();
1653
+ $li = this.listify($item, "ul", match[0].length);
1654
+ } else if (match = $item.text().match(/^\s*1(\.|\))\s*/)) {
1655
+ utils.log("CREATING OL LIST ITEM");
1656
+ e.preventDefault();
1657
+ $li = this.listify($item, "ol", match[0].length);
1658
+ }
1659
+ return $li;
1660
+ };
1661
+
1662
+ Editor.prototype.handleListLineBreak = function($li, e) {
1663
+ var $list, $paragraph;
1664
+ utils.log("LIST LINE BREAK");
1665
+ e.preventDefault();
1666
+ this.tooltip_view.hide();
1667
+ $list = $li.parent("ol, ul");
1668
+ $paragraph = $("<p></p>");
1669
+ if ($list.children().length === 1) {
1670
+ return this.replaceWith("p", $list);
1671
+ } else if ($li.next().length === 0 && $li.text() === "") {
1672
+ $list.after($paragraph);
1673
+ $li.remove();
1674
+ this.addClassesToElement($paragraph[0]);
1675
+ this.setRangeAt($paragraph[0]);
1676
+ this.markAsSelected($paragraph[0]);
1677
+ return this.scrollTo($paragraph);
1678
+ }
1679
+ };
1680
+
1681
+ Editor.prototype.handleListBackspace = function($li, e) {
1682
+ var $list, $paragraph, content;
1683
+ $list = $li.parent("ol, ul");
1684
+ utils.log("LIST BACKSPACE");
1685
+ if ($li.prev().length === 0) {
1686
+ e.preventDefault();
1687
+ $list.before($li);
1688
+ content = $li.html();
1689
+ this.replaceWith("p", $li);
1690
+ $paragraph = $(".is-selected");
1691
+ $paragraph.removeClass("graf--empty").html(content);
1692
+ if ($list.children().length === 0) {
1693
+ $list.remove();
1694
+ }
1695
+ return this.setupFirstAndLast();
1696
+ }
1697
+ };
1698
+
1699
+ return Editor;
1700
+
1701
+ })(Dante.View);
1702
+
1703
+ }).call(this);
1704
+ (function() {
1705
+ var utils,
1706
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1707
+ __hasProp = {}.hasOwnProperty,
1708
+ __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; };
1709
+
1710
+ utils = Dante.utils;
1711
+
1712
+ Dante.Editor.Tooltip = (function(_super) {
1713
+ __extends(Tooltip, _super);
1714
+
1715
+ function Tooltip() {
1716
+ this.hide = __bind(this.hide, this);
1717
+ this.getExtract = __bind(this.getExtract, this);
1718
+ this.getExtractFromNode = __bind(this.getExtractFromNode, this);
1719
+ this.getEmbedFromNode = __bind(this.getEmbedFromNode, this);
1720
+ this.uploadCompleted = __bind(this.uploadCompleted, this);
1721
+ this.updateProgressBar = __bind(this.updateProgressBar, this);
1722
+ this.uploadFile = __bind(this.uploadFile, this);
1723
+ this.uploadFiles = __bind(this.uploadFiles, this);
1724
+ this.toggleOptions = __bind(this.toggleOptions, this);
1725
+ this.render = __bind(this.render, this);
1726
+ this.initialize = __bind(this.initialize, this);
1727
+ return Tooltip.__super__.constructor.apply(this, arguments);
1728
+ }
1729
+
1730
+ Tooltip.prototype.el = ".inlineTooltip";
1731
+
1732
+ Tooltip.prototype.events = {
1733
+ "click .inlineTooltip-button.control": "toggleOptions",
1734
+ "click .inlineTooltip-menu button": "handleClick"
1735
+ };
1736
+
1737
+ Tooltip.prototype.initialize = function(opts) {
1738
+ if (opts == null) {
1739
+ opts = {};
1740
+ }
1741
+ this.current_editor = opts.editor;
1742
+ return this.buttons = [
1743
+ {
1744
+ icon: "icon-image",
1745
+ title: "Add an image",
1746
+ action: "image"
1747
+ }, {
1748
+ icon: "icon-video",
1749
+ title: "Add a video",
1750
+ action: "embed"
1751
+ }, {
1752
+ icon: "icon-embed",
1753
+ title: "Add an embed",
1754
+ action: "embed-extract"
1755
+ }
1756
+ ];
1757
+ };
1758
+
1759
+ Tooltip.prototype.template = function() {
1760
+ var menu;
1761
+ menu = "";
1762
+ _.each(this.buttons, function(b) {
1763
+ var data_action_value;
1764
+ data_action_value = b.action_value ? "data-action-value='" + b.action_value + "'" : "";
1765
+ 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>";
1766
+ });
1767
+ 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>";
1768
+ };
1769
+
1770
+ Tooltip.prototype.insertTemplate = function() {
1771
+ 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>";
1772
+ };
1773
+
1774
+ Tooltip.prototype.extractTemplate = function() {
1775
+ 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>";
1776
+ };
1777
+
1778
+ Tooltip.prototype.embedTemplate = function() {
1779
+ 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>";
1780
+ };
1781
+
1782
+ Tooltip.prototype.render = function() {
1783
+ $(this.el).html(this.template());
1784
+ $(this.el).addClass("is-active");
1785
+ return this;
1786
+ };
1787
+
1788
+ Tooltip.prototype.toggleOptions = function() {
1789
+ utils.log("Toggle Options!!");
1790
+ $(this.el).toggleClass("is-scaled");
1791
+ return false;
1792
+ };
1793
+
1794
+ Tooltip.prototype.move = function(coords) {
1795
+ var control_spacing, control_width, coord_left, coord_top, pull_size, tooltip;
1796
+ tooltip = $(this.el);
1797
+ control_width = tooltip.find(".control").css("width");
1798
+ control_spacing = tooltip.find(".inlineTooltip-menu").css("padding-left");
1799
+ pull_size = parseInt(control_width.replace(/px/, "")) + parseInt(control_spacing.replace(/px/, ""));
1800
+ coord_left = coords.left - pull_size;
1801
+ coord_top = coords.top;
1802
+ return $(this.el).offset({
1803
+ top: coord_top,
1804
+ left: coord_left
1805
+ });
1806
+ };
1807
+
1808
+ Tooltip.prototype.handleClick = function(ev) {
1809
+ var name;
1810
+ name = $(ev.currentTarget).data('action');
1811
+ utils.log(name);
1812
+ switch (name) {
1813
+ case "inline-menu-image":
1814
+ this.placeholder = "<p>PLACEHOLDER</p>";
1815
+ this.imageSelect(ev);
1816
+ break;
1817
+ case "inline-menu-embed":
1818
+ this.displayEmbedPlaceHolder();
1819
+ break;
1820
+ case "inline-menu-embed-extract":
1821
+ this.displayExtractPlaceHolder();
1822
+ break;
1823
+ case "inline-menu-hr":
1824
+ this.splitSection();
1825
+ }
1826
+ return false;
1827
+ };
1828
+
1829
+ Tooltip.prototype.uploadExistentImage = function(image_element, opts) {
1830
+ var i, img, n, node, tmpl, _i, _ref;
1831
+ if (opts == null) {
1832
+ opts = {};
1833
+ }
1834
+ utils.log("process image here!");
1835
+ tmpl = $(this.insertTemplate());
1836
+ tmpl.find("img").attr('src', this.current_editor.default_loading_placeholder);
1837
+ if ($(image_element).parents(".graf").length > 0) {
1838
+ if ($(image_element).parents(".graf").hasClass("graf--figure")) {
1839
+ return;
1840
+ }
1841
+ utils.log("UNO");
1842
+ tmpl.insertBefore($(image_element).parents(".graf"));
1843
+ node = this.current_editor.getNode();
1844
+ if (node) {
1845
+ this.current_editor.preCleanNode($(node));
1846
+ this.current_editor.addClassesToElement(node);
1847
+ }
1848
+ } else {
1849
+ utils.log("DOS");
1850
+ img = $(image_element).parentsUntil(".section-inner").first();
1851
+ $(img).replaceWith(tmpl);
1852
+ }
1853
+ utils.log($("[name='" + (tmpl.attr('name')) + "']").attr("name"));
1854
+ this.replaceImg(image_element, $("[name='" + (tmpl.attr('name')) + "']"));
1855
+ n = $("[name='" + (tmpl.attr('name')) + "']").parentsUntil(".section-inner").length;
1856
+ if (n !== 0) {
1857
+ for (i = _i = 0, _ref = n - 1; _i <= _ref; i = _i += 1) {
1858
+ $("[name='" + (tmpl.attr('name')) + "']").unwrap();
1859
+ }
1860
+ }
1861
+ return utils.log("FIG");
1862
+ };
1863
+
1864
+ Tooltip.prototype.replaceImg = function(image_element, figure) {
1865
+ var img, self;
1866
+ utils.log(figure.attr("name"));
1867
+ utils.log(figure);
1868
+ $(image_element).remove();
1869
+ img = new Image();
1870
+ img.src = image_element.src;
1871
+ self = this;
1872
+ return img.onload = function() {
1873
+ var ar;
1874
+ utils.log("replace image with loaded info");
1875
+ utils.log(figure.attr("name"));
1876
+ utils.log(this.width + 'x' + this.height);
1877
+ ar = self.getAspectRatio(this.width, this.height);
1878
+ figure.find(".aspectRatioPlaceholder").css({
1879
+ 'max-width': ar.width,
1880
+ 'max-height': ar.height
1881
+ });
1882
+ figure.find(".graf-image").attr({
1883
+ "data-height": this.height,
1884
+ "data-width": this.width
1885
+ });
1886
+ figure.find(".aspect-ratio-fill").css({
1887
+ "padding-bottom": "" + ar.ratio + "%"
1888
+ });
1889
+ return figure.find("img").attr("src", image_element.src);
1890
+ };
1891
+ };
1892
+
1893
+ Tooltip.prototype.displayAndUploadImages = function(file) {
1894
+ return this.displayCachedImage(file);
1895
+ };
1896
+
1897
+ Tooltip.prototype.imageSelect = function(ev) {
1898
+ var $selectFile, self;
1899
+ $selectFile = $('<input type="file" multiple="multiple">').click();
1900
+ self = this;
1901
+ return $selectFile.change(function() {
1902
+ var t;
1903
+ t = this;
1904
+ return self.uploadFiles(t.files);
1905
+ });
1906
+ };
1907
+
1908
+ Tooltip.prototype.displayCachedImage = function(file) {
1909
+ var reader;
1910
+ this.current_editor.tooltip_view.hide();
1911
+ reader = new FileReader();
1912
+ reader.onload = (function(_this) {
1913
+ return function(e) {
1914
+ var img, node, self;
1915
+ img = new Image;
1916
+ img.src = e.target.result;
1917
+ node = _this.current_editor.getNode();
1918
+ self = _this;
1919
+ return img.onload = function() {
1920
+ var ar, img_tag, new_tmpl, replaced_node;
1921
+ new_tmpl = $(self.insertTemplate());
1922
+ replaced_node = $(new_tmpl).insertBefore($(node));
1923
+ img_tag = new_tmpl.find('img.graf-image').attr('src', e.target.result);
1924
+ img_tag.height = this.height;
1925
+ img_tag.width = this.width;
1926
+ utils.log("UPLOADED SHOW FROM CACHE");
1927
+ ar = self.getAspectRatio(this.width, this.height);
1928
+ replaced_node.find(".aspectRatioPlaceholder").css({
1929
+ 'max-width': ar.width,
1930
+ 'max-height': ar.height
1931
+ });
1932
+ replaced_node.find(".graf-image").attr({
1933
+ "data-height": this.height,
1934
+ "data-width": this.width
1935
+ });
1936
+ replaced_node.find(".aspect-ratio-fill").css({
1937
+ "padding-bottom": "" + ar.ratio + "%"
1938
+ });
1939
+ return self.uploadFile(file, replaced_node);
1940
+ };
1941
+ };
1942
+ })(this);
1943
+ return reader.readAsDataURL(file);
1944
+ };
1945
+
1946
+ Tooltip.prototype.getAspectRatio = function(w, h) {
1947
+ var fill_ratio, height, maxHeight, maxWidth, ratio, result, width;
1948
+ maxWidth = 700;
1949
+ maxHeight = 700;
1950
+ ratio = 0;
1951
+ width = w;
1952
+ height = h;
1953
+ if (width > maxWidth) {
1954
+ ratio = maxWidth / width;
1955
+ height = height * ratio;
1956
+ width = width * ratio;
1957
+ } else if (height > maxHeight) {
1958
+ ratio = maxHeight / height;
1959
+ width = width * ratio;
1960
+ height = height * ratio;
1961
+ }
1962
+ fill_ratio = height / width * 100;
1963
+ result = {
1964
+ width: width,
1965
+ height: height,
1966
+ ratio: fill_ratio
1967
+ };
1968
+ utils.log(result);
1969
+ return result;
1970
+ };
1971
+
1972
+ Tooltip.prototype.formatData = function(file) {
1973
+ var formData;
1974
+ formData = new FormData();
1975
+ formData.append('file', file);
1976
+ return formData;
1977
+ };
1978
+
1979
+ Tooltip.prototype.uploadFiles = function(files) {
1980
+ var acceptedTypes, file, i, _results;
1981
+ acceptedTypes = {
1982
+ "image/png": true,
1983
+ "image/jpeg": true,
1984
+ "image/gif": true
1985
+ };
1986
+ i = 0;
1987
+ _results = [];
1988
+ while (i < files.length) {
1989
+ file = files[i];
1990
+ if (acceptedTypes[file.type] === true) {
1991
+ $(this.placeholder).append("<progress class=\"progress\" min=\"0\" max=\"100\" value=\"0\">0</progress>");
1992
+ this.displayAndUploadImages(file);
1993
+ }
1994
+ _results.push(i++);
1995
+ }
1996
+ return _results;
1997
+ };
1998
+
1999
+ Tooltip.prototype.uploadFile = function(file, node) {
2000
+ var handleUp, n;
2001
+ n = node;
2002
+ handleUp = (function(_this) {
2003
+ return function(jqxhr) {
2004
+ return _this.uploadCompleted(jqxhr, n);
2005
+ };
2006
+ })(this);
2007
+ return $.ajax({
2008
+ type: "post",
2009
+ url: this.current_editor.upload_url,
2010
+ xhr: (function(_this) {
2011
+ return function() {
2012
+ var xhr;
2013
+ xhr = new XMLHttpRequest();
2014
+ xhr.upload.onprogress = _this.updateProgressBar;
2015
+ return xhr;
2016
+ };
2017
+ })(this),
2018
+ cache: false,
2019
+ contentType: false,
2020
+ success: (function(_this) {
2021
+ return function(response) {
2022
+ handleUp(response);
2023
+ };
2024
+ })(this),
2025
+ error: (function(_this) {
2026
+ return function(jqxhr) {
2027
+ return utils.log("ERROR: got error uploading file " + jqxhr.responseText);
2028
+ };
2029
+ })(this),
2030
+ processData: false,
2031
+ data: this.formatData(file)
2032
+ });
2033
+ };
2034
+
2035
+ Tooltip.prototype.updateProgressBar = function(e) {
2036
+ var $progress, complete;
2037
+ $progress = $('.progress:first', this.$el);
2038
+ complete = "";
2039
+ if (e.lengthComputable) {
2040
+ complete = e.loaded / e.total * 100;
2041
+ complete = complete != null ? complete : {
2042
+ complete: 0
2043
+ };
2044
+ utils.log("complete");
2045
+ return utils.log(complete);
2046
+ }
2047
+ };
2048
+
2049
+ Tooltip.prototype.uploadCompleted = function(url, node) {
2050
+ return node.find("img").attr("src", url);
2051
+ };
2052
+
2053
+ Tooltip.prototype.displayEmbedPlaceHolder = function() {
2054
+ var ph;
2055
+ ph = this.current_editor.embed_placeholder;
2056
+ this.node = this.current_editor.getNode();
2057
+ $(this.node).html(ph).addClass("is-embedable");
2058
+ this.current_editor.setRangeAt(this.node);
2059
+ this.hide();
2060
+ return false;
2061
+ };
2062
+
2063
+ Tooltip.prototype.getEmbedFromNode = function(node) {
2064
+ this.node = $(node);
2065
+ this.node_name = this.node.attr("name");
2066
+ this.node.addClass("spinner");
2067
+ return $.getJSON("" + this.current_editor.oembed_url + ($(this.node).text())).success((function(_this) {
2068
+ return function(data) {
2069
+ var iframe_src, replaced_node, tmpl, url;
2070
+ _this.node = $("[name=" + _this.node_name + "]");
2071
+ iframe_src = $(data.html).prop("src");
2072
+ tmpl = $(_this.embedTemplate());
2073
+ tmpl.attr("name", _this.node.attr("name"));
2074
+ $(_this.node).replaceWith(tmpl);
2075
+ replaced_node = $(".graf--iframe[name=" + (_this.node.attr("name")) + "]");
2076
+ replaced_node.find("iframe").attr("src", iframe_src);
2077
+ url = data.url || data.author_url;
2078
+ utils.log("URL IS " + url);
2079
+ replaced_node.find(".markup--anchor").attr("href", url).text(url);
2080
+ return _this.hide();
2081
+ };
2082
+ })(this));
2083
+ };
2084
+
2085
+ Tooltip.prototype.displayExtractPlaceHolder = function() {
2086
+ var ph;
2087
+ ph = this.current_editor.extract_placeholder;
2088
+ this.node = this.current_editor.getNode();
2089
+ $(this.node).html(ph).addClass("is-extractable");
2090
+ this.current_editor.setRangeAt(this.node);
2091
+ this.hide();
2092
+ return false;
2093
+ };
2094
+
2095
+ Tooltip.prototype.getExtractFromNode = function(node) {
2096
+ this.node = $(node);
2097
+ this.node_name = this.node.attr("name");
2098
+ this.node.addClass("spinner");
2099
+ return $.getJSON("" + this.current_editor.extract_url + ($(this.node).text())).success((function(_this) {
2100
+ return function(data) {
2101
+ var iframe_src, image_node, replaced_node, tmpl;
2102
+ _this.node = $("[name=" + _this.node_name + "]");
2103
+ iframe_src = $(data.html).prop("src");
2104
+ tmpl = $(_this.extractTemplate());
2105
+ tmpl.attr("name", _this.node.attr("name"));
2106
+ $(_this.node).replaceWith(tmpl);
2107
+ replaced_node = $(".graf--mixtapeEmbed[name=" + (_this.node.attr("name")) + "]");
2108
+ replaced_node.find("strong").text(data.title);
2109
+ replaced_node.find("em").text(data.description);
2110
+ replaced_node.append(data.provider_url);
2111
+ replaced_node.find(".markup--anchor").attr("href", data.url);
2112
+ if (!_.isEmpty(data.images)) {
2113
+ image_node = replaced_node.find(".mixtapeImage");
2114
+ image_node.css("background-image", "url(" + data.images[0].url + ")");
2115
+ image_node.removeClass("mixtapeImage--empty u-ignoreBlock");
2116
+ }
2117
+ return _this.hide();
2118
+ };
2119
+ })(this));
2120
+ };
2121
+
2122
+ Tooltip.prototype.getExtract = function(url) {
2123
+ return $.getJSON("" + this.current_editor.extract_url + url).done(function(data) {
2124
+ return utils.log(data);
2125
+ });
2126
+ };
2127
+
2128
+ Tooltip.prototype.cleanOperationClasses = function(node) {
2129
+ return node.removeClass("is-embedable is-extractable");
2130
+ };
2131
+
2132
+ Tooltip.prototype.hide = function() {
2133
+ return $(this.el).removeClass("is-active is-scaled");
2134
+ };
2135
+
2136
+ return Tooltip;
2137
+
2138
+ })(Dante.View);
2139
+
2140
+ }).call(this);
2141
+ (function() {
2142
+ var utils,
2143
+ __hasProp = {}.hasOwnProperty,
2144
+ __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; };
2145
+
2146
+ utils = Dante.utils;
2147
+
2148
+ Dante.Editor.PopOver = (function(_super) {
2149
+ __extends(PopOver, _super);
2150
+
2151
+ function PopOver() {
2152
+ return PopOver.__super__.constructor.apply(this, arguments);
2153
+ }
2154
+
2155
+ PopOver.prototype.el = "body";
2156
+
2157
+ PopOver.prototype.events = {
2158
+ "mouseover .popover": "cancelHide",
2159
+ "mouseout .popover": "hide"
2160
+ };
2161
+
2162
+ PopOver.prototype.initialize = function(opts) {
2163
+ if (opts == null) {
2164
+ opts = {};
2165
+ }
2166
+ utils.log("initialized popover");
2167
+ this.editor = opts.editor;
2168
+ this.hideTimeout;
2169
+ return this.settings = {
2170
+ timeout: 300
2171
+ };
2172
+ };
2173
+
2174
+ PopOver.prototype.template = function() {
2175
+ 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>";
2176
+ };
2177
+
2178
+ PopOver.prototype.positionAt = function(ev) {
2179
+ var left_value, popover_width, target, target_height, target_offset, target_positions, target_width, top_value;
2180
+ target = $(ev.currentTarget);
2181
+ target_positions = this.resolveTargetPosition(target);
2182
+ target_offset = target.offset();
2183
+ target_width = target.outerWidth();
2184
+ target_height = target.outerHeight();
2185
+ popover_width = $(this.el).find(".popover").outerWidth();
2186
+ top_value = target_positions.top + target_height;
2187
+ left_value = target_offset.left + (target_width / 2) - (popover_width / 2);
2188
+ $(this.el).find(".popover").css("top", top_value).css("left", left_value).show();
2189
+ return this.handleDirection(target);
2190
+ };
2191
+
2192
+ PopOver.prototype.displayAt = function(ev) {
2193
+ var target;
2194
+ this.cancelHide();
2195
+ target = $(ev.currentTarget);
2196
+ $(this.el).find(".popover-inner a").text(target.attr('href')).attr('href', target.attr("href"));
2197
+ this.positionAt(ev);
2198
+ $(this.el).find(".popover--tooltip").css("pointer-events", "auto");
2199
+ return $(this.el).show();
2200
+ };
2201
+
2202
+ PopOver.prototype.cancelHide = function() {
2203
+ utils.log("Cancel Hide");
2204
+ return clearTimeout(this.hideTimeout);
2205
+ };
2206
+
2207
+ PopOver.prototype.hide = function(ev) {
2208
+ this.cancelHide();
2209
+ return this.hideTimeout = setTimeout((function(_this) {
2210
+ return function() {
2211
+ return $(_this.el).find(".popover").hide();
2212
+ };
2213
+ })(this), this.settings.timeout);
2214
+ };
2215
+
2216
+ PopOver.prototype.resolveTargetPosition = function(target) {
2217
+ if (target.parents(".graf--mixtapeEmbed").exists()) {
2218
+ return target.parents(".graf--mixtapeEmbed").position();
2219
+ } else {
2220
+ return target.position();
2221
+ }
2222
+ };
2223
+
2224
+ PopOver.prototype.handleDirection = function(target) {
2225
+ if (target.parents(".graf--mixtapeEmbed").exists()) {
2226
+ return $(this.el).find(".popover").removeClass("popover--bottom").addClass("popover--top");
2227
+ } else {
2228
+ return $(this.el).find(".popover").removeClass("popover--top").addClass("popover--bottom");
2229
+ }
2230
+ };
2231
+
2232
+ PopOver.prototype.render = function() {
2233
+ return $(this.template()).insertAfter(this.editor.$el);
2234
+ };
2235
+
2236
+ return PopOver;
2237
+
2238
+ })(Dante.View);
2239
+
2240
+ }).call(this);
2241
+ (function() {
2242
+ var utils,
2243
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2244
+ __hasProp = {}.hasOwnProperty,
2245
+ __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; };
2246
+
2247
+ utils = Dante.utils;
2248
+
2249
+ Dante.Editor.Menu = (function(_super) {
2250
+ __extends(Menu, _super);
2251
+
2252
+ function Menu() {
2253
+ this.createlink = __bind(this.createlink, this);
2254
+ this.handleInputEnter = __bind(this.handleInputEnter, this);
2255
+ this.render = __bind(this.render, this);
2256
+ this.template = __bind(this.template, this);
2257
+ this.initialize = __bind(this.initialize, this);
2258
+ return Menu.__super__.constructor.apply(this, arguments);
2259
+ }
2260
+
2261
+ Menu.prototype.el = "#dante-menu";
2262
+
2263
+ Menu.prototype.events = {
2264
+ "mousedown li": "handleClick",
2265
+ "click .dante-menu-linkinput .dante-menu-button": "closeInput",
2266
+ "keypress input": "handleInputEnter"
2267
+ };
2268
+
2269
+ Menu.prototype.initialize = function(opts) {
2270
+ if (opts == null) {
2271
+ opts = {};
2272
+ }
2273
+ this.config = opts.buttons || this.default_config();
2274
+ this.current_editor = opts.editor;
2275
+ this.commandsReg = {
2276
+ block: /^(?:p|h[1-6]|blockquote|pre)$/,
2277
+ inline: /^(?:bold|italic|underline|insertorderedlist|insertunorderedlist|indent|outdent)$/,
2278
+ source: /^(?:insertimage|createlink|unlink)$/,
2279
+ insert: /^(?:inserthorizontalrule|insert)$/,
2280
+ wrap: /^(?:code)$/
2281
+ };
2282
+ this.lineBreakReg = /^(?:blockquote|pre|div|p)$/i;
2283
+ this.effectNodeReg = /(?:[pubia]|h[1-6]|blockquote|[uo]l|li)/i;
2284
+ return this.strReg = {
2285
+ whiteSpace: /(^\s+)|(\s+$)/g,
2286
+ mailTo: /^(?!mailto:|.+\/|.+#|.+\?)(.*@.*\..+)$/,
2287
+ http: /^(?!\w+?:\/\/|mailto:|\/|\.\/|\?|#)(.*)$/
2288
+ };
2289
+ };
2290
+
2291
+ Menu.prototype.default_config = function() {
2292
+ return {
2293
+
2294
+ /*
2295
+ buttons: [
2296
+ 'blockquote', 'h2', 'h3', 'p', 'code', 'insertorderedlist', 'insertunorderedlist', 'inserthorizontalrule',
2297
+ 'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink'
2298
+ ]
2299
+ */
2300
+ buttons: ['bold', 'italic', 'h2', 'h3', 'h4', 'blockquote', 'createlink']
2301
+ };
2302
+ };
2303
+
2304
+ Menu.prototype.template = function() {
2305
+ var html;
2306
+ html = "<div class='dante-menu-linkinput'><input class='dante-menu-input' placeholder='http://'><div class='dante-menu-button'>x</div></div>";
2307
+ html += "<ul class='dante-menu-buttons'>";
2308
+ _.each(this.config.buttons, function(item) {
2309
+ return html += "<li class='dante-menu-button'><i class=\"dante-icon icon-" + item + "\" data-action=\"" + item + "\"></i></li>";
2310
+ });
2311
+ html += "</ul>";
2312
+ return html;
2313
+ };
2314
+
2315
+ Menu.prototype.render = function() {
2316
+ $(this.el).html(this.template());
2317
+ return this.show();
2318
+ };
2319
+
2320
+ Menu.prototype.handleClick = function(ev) {
2321
+ var action, element, input;
2322
+ element = $(ev.currentTarget).find('.dante-icon');
2323
+ action = element.data("action");
2324
+ input = $(this.el).find("input.dante-menu-input");
2325
+ utils.log("menu " + action + " item clicked!");
2326
+ this.savedSel = utils.saveSelection();
2327
+ if (/(?:createlink)/.test(action)) {
2328
+ if ($(ev.currentTarget).hasClass("active")) {
2329
+ this.removeLink();
2330
+ } else {
2331
+ $(this.el).addClass("dante-menu--linkmode");
2332
+ input.focus();
2333
+ }
2334
+ } else {
2335
+ this.menuApply(action);
2336
+ }
2337
+ return false;
2338
+ };
2339
+
2340
+ Menu.prototype.closeInput = function(e) {
2341
+ $(this.el).removeClass("dante-menu--linkmode");
2342
+ return false;
2343
+ };
2344
+
2345
+ Menu.prototype.handleInputEnter = function(e) {
2346
+ if (e.which === 13) {
2347
+ utils.restoreSelection(this.savedSel);
2348
+ return this.createlink($(e.target));
2349
+ }
2350
+ };
2351
+
2352
+ Menu.prototype.removeLink = function() {
2353
+ var elem;
2354
+ this.menuApply("unlink");
2355
+ elem = this.current_editor.getNode();
2356
+ return this.current_editor.cleanContents($(elem));
2357
+ };
2358
+
2359
+ Menu.prototype.createlink = function(input) {
2360
+ var action, inputValue;
2361
+ $(this.el).removeClass("dante-menu--linkmode");
2362
+ if (input.val()) {
2363
+ inputValue = input.val().replace(this.strReg.whiteSpace, "").replace(this.strReg.mailTo, "mailto:$1").replace(this.strReg.http, "http://$1");
2364
+ return this.menuApply("createlink", inputValue);
2365
+ }
2366
+ action = "unlink";
2367
+ return this.menuApply(action);
2368
+ };
2369
+
2370
+ Menu.prototype.menuApply = function(action, value) {
2371
+ if (this.commandsReg.block.test(action)) {
2372
+ utils.log("block here");
2373
+ this.commandBlock(action);
2374
+ } else if (this.commandsReg.inline.test(action) || this.commandsReg.source.test(action)) {
2375
+ utils.log("overall here");
2376
+ this.commandOverall(action, value);
2377
+ } else if (this.commandsReg.insert.test(action)) {
2378
+ utils.log("insert here");
2379
+ this.commandInsert(action);
2380
+ } else if (this.commandsReg.wrap.test(action)) {
2381
+ utils.log("wrap here");
2382
+ this.commandWrap(action);
2383
+ } else {
2384
+ utils.log("can't find command function for action: " + action);
2385
+ }
2386
+ return false;
2387
+ };
2388
+
2389
+ Menu.prototype.setupInsertedElement = function(element) {
2390
+ var n;
2391
+ n = this.current_editor.addClassesToElement(element);
2392
+ this.current_editor.setElementName(n);
2393
+ return this.current_editor.markAsSelected(n);
2394
+ };
2395
+
2396
+ Menu.prototype.cleanContents = function() {
2397
+ return this.current_editor.cleanContents();
2398
+ };
2399
+
2400
+ Menu.prototype.commandOverall = function(cmd, val) {
2401
+ var message, n;
2402
+ message = " to exec 「" + cmd + "」 command" + (val ? " with value: " + val : "");
2403
+ if (document.execCommand(cmd, false, val)) {
2404
+ utils.log("success" + message);
2405
+ n = this.current_editor.getNode();
2406
+ this.current_editor.setupLinks($(n).find("a"));
2407
+ this.displayHighlights();
2408
+ if ($(n).parent().hasClass("section-inner")) {
2409
+ n = this.current_editor.addClassesToElement(n);
2410
+ this.current_editor.setElementName(n);
2411
+ }
2412
+ this.current_editor.handleTextSelection(n);
2413
+ } else {
2414
+ utils.log("fail" + message, true);
2415
+ }
2416
+ };
2417
+
2418
+ Menu.prototype.commandInsert = function(name) {
2419
+ var node;
2420
+ node = this.current_editor.current_node;
2421
+ if (!node) {
2422
+ return;
2423
+ }
2424
+ this.current_editor.current_range.selectNode(node);
2425
+ this.current_editor.current_range.collapse(false);
2426
+ return this.commandOverall(node, name);
2427
+ };
2428
+
2429
+ Menu.prototype.commandBlock = function(name) {
2430
+ var list, node;
2431
+ node = this.current_editor.current_node;
2432
+ list = this.effectNode(this.current_editor.getNode(node), true);
2433
+ if (list.indexOf(name) !== -1) {
2434
+ name = "p";
2435
+ }
2436
+ return this.commandOverall("formatblock", name);
2437
+ };
2438
+
2439
+ Menu.prototype.commandWrap = function(tag) {
2440
+ var node, val;
2441
+ node = this.current_editor.current_node;
2442
+ val = "<" + tag + ">" + selection + "</" + tag + ">";
2443
+ return this.commandOverall("insertHTML", val);
2444
+ };
2445
+
2446
+ Menu.prototype.effectNode = function(el, returnAsNodeName) {
2447
+ var nodes;
2448
+ nodes = [];
2449
+ el = el || this.current_editor.$el[0];
2450
+ while (el !== this.current_editor.$el[0]) {
2451
+ if (el.nodeName.match(this.effectNodeReg)) {
2452
+ nodes.push((returnAsNodeName ? el.nodeName.toLowerCase() : el));
2453
+ }
2454
+ el = el.parentNode;
2455
+ }
2456
+ return nodes;
2457
+ };
2458
+
2459
+ Menu.prototype.displayHighlights = function() {
2460
+ var nodes;
2461
+ $(this.el).find(".active").removeClass("active");
2462
+ nodes = this.effectNode(utils.getNode());
2463
+ utils.log(nodes);
2464
+ return _.each(nodes, (function(_this) {
2465
+ return function(node) {
2466
+ var tag;
2467
+ tag = node.nodeName.toLowerCase();
2468
+ switch (tag) {
2469
+ case "a":
2470
+ $(_this.el).find('input').val($(node).attr("href"));
2471
+ tag = "createlink";
2472
+ break;
2473
+ case "i":
2474
+ tag = "italic";
2475
+ break;
2476
+ case "u":
2477
+ tag = "underline";
2478
+ break;
2479
+ case "b":
2480
+ tag = "bold";
2481
+ break;
2482
+ case "code":
2483
+ tag = "code";
2484
+ break;
2485
+ case "ul":
2486
+ tag = "insertunorderedlist";
2487
+ break;
2488
+ case "ol":
2489
+ tag = "insertorderedlist";
2490
+ break;
2491
+ case "li":
2492
+ tag = "indent";
2493
+ utils.log("nothing to select");
2494
+ }
2495
+ if (tag.match(/(?:h[1-6])/i)) {
2496
+ $(_this.el).find(".icon-bold, .icon-italic, .icon-blockquote").parent("li").remove();
2497
+ } else if (tag === "indent") {
2498
+ $(_this.el).find(".icon-h2, .icon-h3, .icon-h4, .icon-blockquote").parent("li").remove();
2499
+ }
2500
+ return _this.highlight(tag);
2501
+ };
2502
+ })(this));
2503
+ };
2504
+
2505
+ Menu.prototype.highlight = function(tag) {
2506
+ return $(".icon-" + tag).parent("li").addClass("active");
2507
+ };
2508
+
2509
+ Menu.prototype.show = function() {
2510
+ $(this.el).addClass("dante-menu--active");
2511
+ this.closeInput();
2512
+ return this.displayHighlights();
2513
+ };
2514
+
2515
+ Menu.prototype.hide = function() {
2516
+ return $(this.el).removeClass("dante-menu--active");
2517
+ };
2518
+
2519
+ return Menu;
2520
+
2521
+ })(Dante.View);
2522
+
2523
+ }).call(this);
2524
+ //Editor components
2525
+
2526
+
2527
+
2528
+
2529
+
2530
+
2531
+
2532
+ ;