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