dante-editor-seo 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +40 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +23 -0
  6. data/Gemfile.lock +140 -0
  7. data/Procfile +1 -0
  8. data/README.md +187 -0
  9. data/ROADMAP.md +10 -0
  10. data/TODO.md +30 -0
  11. data/app/assets/fonts/dante/dante.eot +0 -0
  12. data/app/assets/fonts/dante/dante.svg +14 -0
  13. data/app/assets/fonts/dante/dante.ttf +0 -0
  14. data/app/assets/fonts/dante/dante.woff +0 -0
  15. data/app/assets/fonts/dante/fontello.eot +0 -0
  16. data/app/assets/fonts/dante/fontello.svg +36 -0
  17. data/app/assets/fonts/dante/fontello.ttf +0 -0
  18. data/app/assets/fonts/dante/fontello.woff +0 -0
  19. data/app/assets/images/dante/media-loading-placeholder.png +0 -0
  20. data/app/assets/javascripts/dante/dante.js.coffee.erb +10 -0
  21. data/app/assets/javascripts/dante/editor.js.coffee +1250 -0
  22. data/app/assets/javascripts/dante/menu.js.coffee +216 -0
  23. data/app/assets/javascripts/dante/popover.js.coffee +75 -0
  24. data/app/assets/javascripts/dante/tooltip.js.coffee +82 -0
  25. data/app/assets/javascripts/dante/tooltip_widget.js.coffee +10 -0
  26. data/app/assets/javascripts/dante/tooltip_widgets/embed.js.coffee +60 -0
  27. data/app/assets/javascripts/dante/tooltip_widgets/extract.js.coffee +64 -0
  28. data/app/assets/javascripts/dante/tooltip_widgets/uploader.js.coffee +248 -0
  29. data/app/assets/javascripts/dante/utils.js.coffee +235 -0
  30. data/app/assets/javascripts/dante/view.js.coffee +101 -0
  31. data/app/assets/javascripts/dante.js +12 -0
  32. data/app/assets/stylesheets/dante/_animations.scss +54 -0
  33. data/app/assets/stylesheets/dante/_caption.scss +52 -0
  34. data/app/assets/stylesheets/dante/_debug.scss +11 -0
  35. data/app/assets/stylesheets/dante/_fonts.scss +17 -0
  36. data/app/assets/stylesheets/dante/_graf.scss +238 -0
  37. data/app/assets/stylesheets/dante/_icons.scss +57 -0
  38. data/app/assets/stylesheets/dante/_media.scss +39 -0
  39. data/app/assets/stylesheets/dante/_menu.scss +153 -0
  40. data/app/assets/stylesheets/dante/_needsorder.scss +209 -0
  41. data/app/assets/stylesheets/dante/_popover.scss +134 -0
  42. data/app/assets/stylesheets/dante/_post.scss +69 -0
  43. data/app/assets/stylesheets/dante/_scaffold.scss +20 -0
  44. data/app/assets/stylesheets/dante/_tooltip.scss +131 -0
  45. data/app/assets/stylesheets/dante/_utilities.scss +55 -0
  46. data/app/assets/stylesheets/dante/_variables.scss +46 -0
  47. data/app/assets/stylesheets/dante.scss +18 -0
  48. data/bower.json +44 -0
  49. data/config.rb +86 -0
  50. data/config.ru +42 -0
  51. data/dante-editor.gemspec +19 -0
  52. data/dist/css/dante-editor.css +1116 -0
  53. data/dist/fonts/dante/dante.eot +0 -0
  54. data/dist/fonts/dante/dante.svg +14 -0
  55. data/dist/fonts/dante/dante.ttf +0 -0
  56. data/dist/fonts/dante/dante.woff +0 -0
  57. data/dist/fonts/dante/fontello.eot +0 -0
  58. data/dist/fonts/dante/fontello.svg +36 -0
  59. data/dist/fonts/dante/fontello.ttf +0 -0
  60. data/dist/fonts/dante/fontello.woff +0 -0
  61. data/dist/images/dante/media-loading-placeholder.png +0 -0
  62. data/dist/js/dante-editor.js +2878 -0
  63. data/lib/dante-editor/rails.rb +4 -0
  64. data/lib/dante-editor/version.rb +5 -0
  65. data/lib/dante-editor.rb +5 -0
  66. data/license.md +22 -0
  67. data/rakefile +2 -0
  68. data/source/assets/images/dante-editor-logo.png +0 -0
  69. data/source/assets/images/github-logo.png +0 -0
  70. data/source/assets/javascripts/all.js +3 -0
  71. data/source/assets/javascripts/dante-editor.js +1 -0
  72. data/source/assets/javascripts/deps.js +4 -0
  73. data/source/assets/javascripts/examples/custom_toolbar.js.coffee +30 -0
  74. data/source/assets/javascripts/spec.js +2 -0
  75. data/source/assets/javascripts/specs/cleaner.js.coffee +8 -0
  76. data/source/assets/javascripts/specs/dante_view.js.coffee +74 -0
  77. data/source/assets/javascripts/specs/editor.js.coffee +78 -0
  78. data/source/assets/stylesheets/_layout.scss +51 -0
  79. data/source/assets/stylesheets/_scaffold.scss +8 -0
  80. data/source/assets/stylesheets/_tooltips.scss +216 -0
  81. data/source/assets/stylesheets/all.css.scss +5 -0
  82. data/source/assets/stylesheets/dante-editor.css.scss +1 -0
  83. data/source/assets/stylesheets/normalize.css +375 -0
  84. data/source/custom_toolbar.erb +29 -0
  85. data/source/embeds.html.erb +27 -0
  86. data/source/icons/dante.json +143 -0
  87. data/source/icons/embed.svg +13 -0
  88. data/source/icons/image.svg +13 -0
  89. data/source/icons/plus.svg +13 -0
  90. data/source/icons/video.svg +13 -0
  91. data/source/index.html.erb +18 -0
  92. data/source/layouts/layout.erb +26 -0
  93. data/source/layouts/spec.html.erb +22 -0
  94. data/source/lists.html.erb +18 -0
  95. data/source/partials/_content.erb +6 -0
  96. data/source/partials/_example_1.erb +45 -0
  97. data/source/partials/_example_2.erb +32 -0
  98. data/source/partials/_example_3.erb +4 -0
  99. data/source/partials/_lists.erb +13 -0
  100. data/source/partials/_readme.markdown +24 -0
  101. data/source/partials/test/_example_1.erb +39 -0
  102. data/source/tests/dante_view.html.erb +11 -0
  103. data/source/tests/index.html.erb +39 -0
  104. data/tmp/.gitkeep +0 -0
  105. metadata +151 -0
@@ -0,0 +1,2878 @@
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.13"
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
+ var extend;
321
+
322
+ Dante.View = (function() {
323
+ function View(opts) {
324
+ if (opts == null) {
325
+ opts = {};
326
+ }
327
+ if (opts.el) {
328
+ this.el = opts.el;
329
+ }
330
+ this._ensureElement();
331
+ this.initialize.apply(this, arguments);
332
+ this._ensureEvents();
333
+ }
334
+
335
+ View.prototype.initialize = function(opts) {
336
+ if (opts == null) {
337
+ opts = {};
338
+ }
339
+ };
340
+
341
+ View.prototype.events = function() {};
342
+
343
+ View.prototype.render = function() {
344
+ return this;
345
+ };
346
+
347
+ View.prototype.remove = function() {
348
+ this._removeElement();
349
+ this.stopListening();
350
+ return this;
351
+ };
352
+
353
+ View.prototype._removeElement = function() {
354
+ return this.$el.remove();
355
+ };
356
+
357
+ View.prototype.setElement = function(element) {
358
+ this._setElement(element);
359
+ return this;
360
+ };
361
+
362
+ View.prototype.setEvent = function(opts) {
363
+ if (!_.isEmpty(opts)) {
364
+ return _.each(opts, (function(_this) {
365
+ return function(f, key) {
366
+ var element, func, key_arr;
367
+ key_arr = key.split(" ");
368
+ if (_.isFunction(f)) {
369
+ func = f;
370
+ } else if (_.isString(f)) {
371
+ func = _this[f];
372
+ } else {
373
+ throw "error event needs a function or string";
374
+ }
375
+ element = key_arr.length > 1 ? key_arr.splice(1, 3).join(" ") : null;
376
+ return $(_this.el).on(key_arr[0], element, _.bind(func, _this));
377
+ };
378
+ })(this));
379
+ }
380
+ };
381
+
382
+ View.prototype._ensureElement = function() {
383
+ return this.setElement(_.result(this, 'el'));
384
+ };
385
+
386
+ View.prototype._ensureEvents = function() {
387
+ return this.setEvent(_.result(this, 'events'));
388
+ };
389
+
390
+ View.prototype._setElement = function(el) {
391
+ this.$el = el instanceof $ ? el : $(el);
392
+ return this.el = this.$el[0];
393
+ };
394
+
395
+ return View;
396
+
397
+ })();
398
+
399
+ extend = function(protoProps, staticProps) {
400
+ var Surrogate, child, parent;
401
+ parent = this;
402
+ child = void 0;
403
+ if (protoProps && _.has(protoProps, 'constructor')) {
404
+ child = protoProps.constructor;
405
+ } else {
406
+ child = function() {
407
+ return parent.apply(this, arguments);
408
+ };
409
+ }
410
+ _.extend(child, parent, staticProps);
411
+ Surrogate = function() {
412
+ this.constructor = child;
413
+ };
414
+ Surrogate.prototype = parent.prototype;
415
+ child.prototype = new Surrogate;
416
+ if (protoProps) {
417
+ _.extend(child.prototype, protoProps);
418
+ }
419
+ child.__super__ = parent.prototype;
420
+ return child;
421
+ };
422
+
423
+ Dante.View.extend = extend;
424
+
425
+ }).call(this);
426
+ (function() {
427
+ var utils,
428
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
429
+ __hasProp = {}.hasOwnProperty,
430
+ __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; };
431
+
432
+ utils = Dante.utils;
433
+
434
+ Dante.Editor = (function(_super) {
435
+ var BACKSPACE, DOWNARROW, ENTER, LEFTARROW, RIGHTARROW, SPACEBAR, TAB, UPARROW;
436
+
437
+ __extends(Editor, _super);
438
+
439
+ function Editor() {
440
+ this.setupFirstAndLast = __bind(this.setupFirstAndLast, this);
441
+ this.addClassesToElement = __bind(this.addClassesToElement, this);
442
+ this.handlePaste = __bind(this.handlePaste, this);
443
+ this.handleArrowForKeyDown = __bind(this.handleArrowForKeyDown, this);
444
+ this.handleArrow = __bind(this.handleArrow, this);
445
+ this.handleMouseUp = __bind(this.handleMouseUp, this);
446
+ this.selection = __bind(this.selection, this);
447
+ this.render = __bind(this.render, this);
448
+ this.restart = __bind(this.restart, this);
449
+ this.start = __bind(this.start, this);
450
+ this.appendInitialContent = __bind(this.appendInitialContent, this);
451
+ this.appendMenus = __bind(this.appendMenus, this);
452
+ this.template = __bind(this.template, this);
453
+ this.initialize = __bind(this.initialize, this);
454
+ return Editor.__super__.constructor.apply(this, arguments);
455
+ }
456
+
457
+ BACKSPACE = 8;
458
+
459
+ TAB = 9;
460
+
461
+ ENTER = 13;
462
+
463
+ SPACEBAR = 32;
464
+
465
+ LEFTARROW = 37;
466
+
467
+ UPARROW = 38;
468
+
469
+ RIGHTARROW = 39;
470
+
471
+ DOWNARROW = 40;
472
+
473
+ Editor.prototype.events = {
474
+ "mouseup": "handleMouseUp",
475
+ "keydown": "handleKeyDown",
476
+ "keyup": "handleKeyUp",
477
+ "paste": "handlePaste",
478
+ "dblclick": "handleDblclick",
479
+ "dragstart": "handleDrag",
480
+ "drop": "handleDrag",
481
+ "click .graf--figure .aspectRatioPlaceholder": "handleGrafFigureSelectImg",
482
+ "click .graf--figure figcaption": "handleGrafFigureSelectCaption",
483
+ "mouseover .graf--figure.graf--iframe": "handleGrafFigureSelectIframe",
484
+ "mouseleave .graf--figure.graf--iframe": "handleGrafFigureUnSelectIframe",
485
+ "keyup .graf--figure figcaption": "handleGrafCaptionTyping",
486
+ "mouseover .markup--anchor": "displayPopOver",
487
+ "mouseout .markup--anchor": "hidePopOver"
488
+ };
489
+
490
+ Editor.prototype.initialize = function(opts) {
491
+ var body, bodyplaceholder, embedplaceholder, extractplaceholder, title, titleplaceholder;
492
+ if (opts == null) {
493
+ opts = {};
494
+ }
495
+ this.editor_options = opts;
496
+ this.initial_html = $(this.el).html();
497
+ this.current_range = null;
498
+ this.current_node = null;
499
+ this.el = opts.el || "#editor";
500
+ this.upload_url = opts.upload_url || "/uploads.json";
501
+ this.upload_callback = opts.upload_callback;
502
+ this.upload_params = opts.upload_params || null;
503
+ this.oembed_url = opts.oembed_url || "http://api.embed.ly/1/oembed?url=";
504
+ this.extract_url = opts.extract_url || "http://api.embed.ly/1/extract?key=86c28a410a104c8bb58848733c82f840&url=";
505
+ this.default_loading_placeholder = opts.default_loading_placeholder || Dante.defaults.image_placeholder;
506
+ this.store_url = opts.store_url;
507
+ this.store_method = opts.store_method || "POST";
508
+ this.store_params = opts.store_params || null;
509
+ this.spell_check = opts.spellcheck || false;
510
+ this.disable_title = opts.disable_title || false;
511
+ this.store_interval = opts.store_interval || 15000;
512
+ this.paste_element_id = "#dante-paste-div";
513
+ this.tooltip_class = opts.tooltip_class || Dante.Editor.Tooltip;
514
+ opts.base_widgets || (opts.base_widgets = ["uploader", "embed", "embed_extract"]);
515
+ this.widgets = [];
516
+ window.debugMode = opts.debug || false;
517
+ if (window.debugMode) {
518
+ $(this.el).addClass("debug");
519
+ }
520
+ if (localStorage.getItem('contenteditable')) {
521
+ $(this.el).html(localStorage.getItem('contenteditable'));
522
+ }
523
+ this.store();
524
+ titleplaceholder = opts.title_placeholder || 'Title';
525
+ this.title_placeholder = "<span class='defaultValue defaultValue--root'>" + titleplaceholder + "</span><br>";
526
+ title = opts.title || '';
527
+ this.title = title;
528
+ body = opts.body || '';
529
+ this.body = body;
530
+ bodyplaceholder = opts.body_placeholder || 'Tell your story…';
531
+ this.body_placeholder = "<span class='defaultValue defaultValue--root'>" + bodyplaceholder + "</span><br>";
532
+ embedplaceholder = opts.embed_placeholder || 'Paste a YouTube, Vine, Vimeo, or other video link, and press Enter';
533
+ this.embed_placeholder = "<span class='defaultValue defaultValue--root'>" + embedplaceholder + "</span><br>";
534
+ extractplaceholder = opts.extract_placeholder || "Paste a link to embed content from another site (e.g. Twitter) and press Enter";
535
+ this.extract_placeholder = "<span class='defaultValue defaultValue--root'>" + extractplaceholder + "</span><br>";
536
+ return this.initializeWidgets(opts);
537
+ };
538
+
539
+ Editor.prototype.initializeWidgets = function(opts) {
540
+ var base_widgets, self;
541
+ base_widgets = opts.base_widgets;
542
+ self = this;
543
+ if (base_widgets.indexOf("uploader") >= 0) {
544
+ this.uploader_widget = new Dante.View.TooltipWidget.Uploader({
545
+ current_editor: this
546
+ });
547
+ this.widgets.push(this.uploader_widget);
548
+ }
549
+ if (base_widgets.indexOf("embed") >= 0) {
550
+ this.embed_widget = new Dante.View.TooltipWidget.Embed({
551
+ current_editor: this
552
+ });
553
+ this.widgets.push(this.embed_widget);
554
+ }
555
+ if (base_widgets.indexOf("embed_extract") >= 0) {
556
+ this.embed_extract_widget = new Dante.View.TooltipWidget.EmbedExtract({
557
+ current_editor: this
558
+ });
559
+ this.widgets.push(this.embed_extract_widget);
560
+ }
561
+ if (opts.extra_tooltip_widgets) {
562
+ return _.each(opts.extra_tooltip_widgets, (function(_this) {
563
+ return function(w) {
564
+ if (!w.current_editor) {
565
+ w.current_editor = self;
566
+ }
567
+ return _this.widgets.push(w);
568
+ };
569
+ })(this));
570
+ }
571
+ };
572
+
573
+ Editor.prototype.store = function() {
574
+ if (!this.store_url) {
575
+ return;
576
+ }
577
+ return setTimeout((function(_this) {
578
+ return function() {
579
+ return _this.checkforStore();
580
+ };
581
+ })(this), this.store_interval);
582
+ };
583
+
584
+ Editor.prototype.checkforStore = function() {
585
+ if (this.content === this.getContent()) {
586
+ utils.log("content not changed skip store");
587
+ return this.store();
588
+ } else {
589
+ utils.log("content changed! update");
590
+ this.content = this.getContent();
591
+ return $.ajax({
592
+ url: this.store_url,
593
+ method: this.store_method,
594
+ data: {
595
+ body: this.getContent(),
596
+ store_params: this.store_params
597
+ },
598
+ success: function(res) {
599
+ utils.log("store!");
600
+ return utils.log(res);
601
+ },
602
+ complete: (function(_this) {
603
+ return function(jxhr) {
604
+ return _this.store();
605
+ };
606
+ })(this)
607
+ });
608
+ }
609
+ };
610
+
611
+ Editor.prototype.getContent = function() {
612
+ return $(this.el).find(".section-inner").html();
613
+ };
614
+
615
+ Editor.prototype.renderBody = function() {
616
+ return "<p class='graf graf--p body'>" + (this.body.length > 0 ? this.body : this.body_placeholder) + "<p>";
617
+ };
618
+
619
+ Editor.prototype.renderTitle = function() {
620
+ return "<h3 class='graf graf--h3'>" + (this.title.length > 0 ? this.title : this.title_placeholder) + "</h3>";
621
+ };
622
+
623
+ Editor.prototype.template = function() {
624
+ 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()) + " " + (this.renderBody()) + " </div> </div> </section>";
625
+ };
626
+
627
+ Editor.prototype.baseParagraphTmpl = function() {
628
+ return "<p class='graf--p' name='" + (utils.generateUniqueName()) + "'><br></p>";
629
+ };
630
+
631
+ Editor.prototype.appendMenus = function() {
632
+ $("<div id='dante-menu' class='dante-menu'></div>").insertAfter(this.el);
633
+ $("<div class='inlineTooltip'></div>").insertAfter(this.el);
634
+ this.editor_menu = new Dante.Editor.Menu({
635
+ editor: this
636
+ });
637
+ this.tooltip_view = new this.tooltip_class({
638
+ editor: this,
639
+ widgets: this.widgets
640
+ });
641
+ this.pop_over = new Dante.Editor.PopOver({
642
+ editor: this
643
+ });
644
+ this.pop_over.render().hide();
645
+ return this.tooltip_view.render().hide();
646
+ };
647
+
648
+ Editor.prototype.appendInitialContent = function() {
649
+ $(this.el).find(".section-inner").html(this.initial_html);
650
+ return $(this.el).attr("spellcheck", this.spell_check);
651
+ };
652
+
653
+ Editor.prototype.start = function() {
654
+ this.render();
655
+ $(this.el).attr("contenteditable", "true");
656
+ $(this.el).addClass("postField postField--body editable smart-media-plugin");
657
+ $(this.el).wrap("<article class='postArticle'><div class='postContent'><div class='notesSource'></div></div></article>");
658
+ this.appendMenus();
659
+ if (!_.isEmpty(this.initial_html.trim())) {
660
+ this.appendInitialContent();
661
+ }
662
+ return this.parseInitialMess();
663
+ };
664
+
665
+ Editor.prototype.restart = function() {
666
+ return this.render();
667
+ };
668
+
669
+ Editor.prototype.render = function() {
670
+ this.template();
671
+ return $(this.el).html(this.template());
672
+ };
673
+
674
+ Editor.prototype.getSelectedText = function() {
675
+ var text;
676
+ text = "";
677
+ if (typeof window.getSelection !== "undefined") {
678
+ text = window.getSelection().toString();
679
+ } else if (typeof document.selection !== "undefined" && document.selection.type === "Text") {
680
+ text = document.selection.createRange().text;
681
+ }
682
+ return text;
683
+ };
684
+
685
+ Editor.prototype.selection = function() {
686
+ selection;
687
+ var selection;
688
+ if (window.getSelection) {
689
+ return selection = window.getSelection();
690
+ } else if (document.selection && document.selection.type !== "Control") {
691
+ return selection = document.selection;
692
+ }
693
+ };
694
+
695
+ Editor.prototype.getRange = function() {
696
+ var editor, range;
697
+ editor = $(this.el)[0];
698
+ range = selection && selection.rangeCount && selection.getRangeAt(0);
699
+ if (!range) {
700
+ range = document.createRange();
701
+ }
702
+ if (!editor.contains(range.commonAncestorContainer)) {
703
+ range.selectNodeContents(editor);
704
+ range.collapse(false);
705
+ }
706
+ return range;
707
+ };
708
+
709
+ Editor.prototype.setRange = function(range) {
710
+ range = range || this.current_range;
711
+ if (!range) {
712
+ range = this.getRange();
713
+ range.collapse(false);
714
+ }
715
+ this.selection().removeAllRanges();
716
+ this.selection().addRange(range);
717
+ return this;
718
+ };
719
+
720
+ Editor.prototype.getCharacterPrecedingCaret = function() {
721
+ var precedingChar, precedingRange, range, sel;
722
+ precedingChar = "";
723
+ sel = void 0;
724
+ range = void 0;
725
+ precedingRange = void 0;
726
+ if (window.getSelection) {
727
+ sel = window.getSelection();
728
+ if (sel.rangeCount > 0) {
729
+ range = sel.getRangeAt(0).cloneRange();
730
+ range.collapse(true);
731
+ range.setStart(this.getNode(), 0);
732
+ precedingChar = range.toString().slice(0);
733
+ }
734
+ } else if ((sel = document.selection) && sel.type !== "Control") {
735
+ range = sel.createRange();
736
+ precedingRange = range.duplicate();
737
+ precedingRange.moveToElementText(containerEl);
738
+ precedingRange.setEndPoint("EndToStart", range);
739
+ precedingChar = precedingRange.text.slice(0);
740
+ }
741
+ return precedingChar;
742
+ };
743
+
744
+ Editor.prototype.isLastChar = function() {
745
+ return $(this.getNode()).text().trim().length === this.getCharacterPrecedingCaret().trim().length;
746
+ };
747
+
748
+ Editor.prototype.isFirstChar = function() {
749
+ return this.getCharacterPrecedingCaret().trim().length === 0;
750
+ };
751
+
752
+ Editor.prototype.isSelectingAll = function(element) {
753
+ var a, b;
754
+ a = this.getSelectedText().killWhiteSpace().length;
755
+ b = $(element).text().killWhiteSpace().length;
756
+ return a === b;
757
+ };
758
+
759
+ Editor.prototype.setRangeAt = function(element, int) {
760
+ var range, sel;
761
+ if (int == null) {
762
+ int = 0;
763
+ }
764
+ range = document.createRange();
765
+ sel = window.getSelection();
766
+ range.setStart(element, int);
767
+ range.collapse(true);
768
+ sel.removeAllRanges();
769
+ sel.addRange(range);
770
+ return element.focus();
771
+ };
772
+
773
+ Editor.prototype.setRangeAtText = function(element, int) {
774
+ var node, range, sel;
775
+ if (int == null) {
776
+ int = 0;
777
+ }
778
+ range = document.createRange();
779
+ sel = window.getSelection();
780
+ node = element.firstChild;
781
+ range.setStart(node, 0);
782
+ range.setEnd(node, 0);
783
+ range.collapse(true);
784
+ sel.removeAllRanges();
785
+ sel.addRange(range);
786
+ return element.focus();
787
+ };
788
+
789
+ Editor.prototype.focus = function(focusStart) {
790
+ if (!focusStart) {
791
+ this.setRange();
792
+ }
793
+ $(this.el).focus();
794
+ return this;
795
+ };
796
+
797
+ Editor.prototype.focusNode = function(node, range) {
798
+ range.setStartAfter(node);
799
+ range.setEndBefore(node);
800
+ range.collapse(false);
801
+ return this.setRange(range);
802
+ };
803
+
804
+ Editor.prototype.getNode = function() {
805
+ var node, range, root;
806
+ node = void 0;
807
+ root = $(this.el).find(".section-inner")[0];
808
+ if (this.selection().rangeCount < 1) {
809
+ return;
810
+ }
811
+ range = this.selection().getRangeAt(0);
812
+ node = range.commonAncestorContainer;
813
+ if (!node || node === root) {
814
+ return null;
815
+ }
816
+ while (node && (node.nodeType !== 1 || !$(node).hasClass("graf")) && (node.parentNode !== root)) {
817
+ node = node.parentNode;
818
+ }
819
+ if (!$(node).hasClass("graf--li")) {
820
+ while (node && (node.parentNode !== root)) {
821
+ node = node.parentNode;
822
+ }
823
+ }
824
+ if (root && root.contains(node)) {
825
+ return node;
826
+ } else {
827
+ return null;
828
+ }
829
+ };
830
+
831
+ Editor.prototype.displayMenu = function(sel) {
832
+ return setTimeout((function(_this) {
833
+ return function() {
834
+ var pos;
835
+ _this.editor_menu.render();
836
+ pos = utils.getSelectionDimensions();
837
+ _this.relocateMenu(pos);
838
+ return _this.editor_menu.show();
839
+ };
840
+ })(this), 10);
841
+ };
842
+
843
+ Editor.prototype.handleDrag = function() {
844
+ return false;
845
+ };
846
+
847
+ Editor.prototype.handleGrafCaptionTyping = function(ev) {
848
+ if (_.isEmpty(utils.getNode().textContent.trim())) {
849
+ return $(this.getNode()).addClass("is-defaultValue");
850
+ } else {
851
+ return $(this.getNode()).removeClass("is-defaultValue");
852
+ }
853
+ };
854
+
855
+ Editor.prototype.handleTextSelection = function(anchor_node) {
856
+ var text;
857
+ this.editor_menu.hide();
858
+ text = this.getSelectedText();
859
+ if (!$(anchor_node).is(".graf--mixtapeEmbed, .graf--figure") && !_.isEmpty(text.trim())) {
860
+ this.current_node = anchor_node;
861
+ return this.displayMenu();
862
+ }
863
+ };
864
+
865
+ Editor.prototype.relocateMenu = function(position) {
866
+ var height, left, padd, top;
867
+ height = this.editor_menu.$el.outerHeight();
868
+ padd = this.editor_menu.$el.width() / 2;
869
+ top = position.top + $(window).scrollTop() - height;
870
+ left = position.left + (position.width / 2) - padd;
871
+ return this.editor_menu.$el.offset({
872
+ left: left,
873
+ top: top
874
+ });
875
+ };
876
+
877
+ Editor.prototype.hidePlaceholder = function(element) {
878
+ return $(element).find("span.defaultValue").remove().html("<br>");
879
+ };
880
+
881
+ Editor.prototype.displayEmptyPlaceholder = function(element) {
882
+ $(".graf--first").html(this.title_placeholder);
883
+ return $(".graf--last").html(this.body_placeholder);
884
+ };
885
+
886
+ Editor.prototype.displayPopOver = function(ev) {
887
+ return this.pop_over.displayAt(ev);
888
+ };
889
+
890
+ Editor.prototype.hidePopOver = function(ev) {
891
+ return this.pop_over.hide(ev);
892
+ };
893
+
894
+ Editor.prototype.handleGrafFigureSelectImg = function(ev) {
895
+ var element;
896
+ utils.log("FIGURE SELECT");
897
+ element = ev.currentTarget;
898
+ this.markAsSelected(element);
899
+ $(element).parent(".graf--figure").addClass("is-selected is-mediaFocused");
900
+ return this.selection().removeAllRanges();
901
+ };
902
+
903
+ Editor.prototype.handleGrafFigureSelectIframe = function(ev) {
904
+ var element;
905
+ utils.log("FIGURE IFRAME SELECT");
906
+ element = ev.currentTarget;
907
+ this.iframeSelected = element;
908
+ this.markAsSelected(element);
909
+ $(element).addClass("is-selected is-mediaFocused");
910
+ return this.selection().removeAllRanges();
911
+ };
912
+
913
+ Editor.prototype.handleGrafFigureUnSelectIframe = function(ev) {
914
+ var element;
915
+ utils.log("FIGURE IFRAME UNSELECT");
916
+ element = ev.currentTarget;
917
+ this.iframeSelected = null;
918
+ return $(element).removeClass("is-selected is-mediaFocused");
919
+ };
920
+
921
+ Editor.prototype.handleGrafFigureSelectCaption = function(ev) {
922
+ var element;
923
+ utils.log("FIGCAPTION");
924
+ element = ev.currentTarget;
925
+ return $(element).parent(".graf--figure").removeClass("is-mediaFocused");
926
+ };
927
+
928
+ Editor.prototype.handleMouseUp = function(ev) {
929
+ var anchor_node;
930
+ utils.log("MOUSE UP");
931
+ anchor_node = this.getNode();
932
+ if (_.isNull(anchor_node)) {
933
+ return;
934
+ }
935
+ this.prev_current_node = anchor_node;
936
+ this.handleTextSelection(anchor_node);
937
+ this.hidePlaceholder(anchor_node);
938
+ this.markAsSelected(anchor_node);
939
+ return this.displayTooltipAt(anchor_node);
940
+ };
941
+
942
+ Editor.prototype.scrollTo = function(node) {
943
+ var top;
944
+ if (utils.isElementInViewport($(node))) {
945
+ return;
946
+ }
947
+ top = node.offset().top;
948
+ return $('html, body').animate({
949
+ scrollTop: top
950
+ }, 20);
951
+ };
952
+
953
+ Editor.prototype.handleArrow = function(ev) {
954
+ var current_node;
955
+ current_node = $(this.getNode());
956
+ if (current_node.length > 0) {
957
+ this.markAsSelected(current_node);
958
+ return this.displayTooltipAt(current_node);
959
+ }
960
+ };
961
+
962
+ Editor.prototype.handleArrowForKeyDown = function(ev) {
963
+ var caret_node, current_node, ev_type, n, next_node, num, prev_node;
964
+ caret_node = this.getNode();
965
+ current_node = $(caret_node);
966
+ utils.log(ev);
967
+ ev_type = ev.originalEvent.key || ev.originalEvent.keyIdentifier;
968
+ utils.log("ENTER ARROW for key " + ev_type);
969
+ switch (ev_type) {
970
+ case "Down":
971
+ if (_.isUndefined(current_node) || !current_node.exists()) {
972
+ if ($(".is-selected").exists()) {
973
+ current_node = $(".is-selected");
974
+ }
975
+ }
976
+ next_node = current_node.next();
977
+ utils.log("NEXT NODE IS " + (next_node.attr('class')));
978
+ utils.log("CURRENT NODE IS " + (current_node.attr('class')));
979
+ if (!$(current_node).hasClass("graf")) {
980
+ return;
981
+ }
982
+ if (!(current_node.hasClass("graf--figure") || $(current_node).editableCaretOnLastLine())) {
983
+ return;
984
+ }
985
+ utils.log("ENTER ARROW PASSED RETURNS");
986
+ if (next_node.hasClass("graf--figure") && caret_node) {
987
+ n = next_node.find(".imageCaption");
988
+ this.scrollTo(n);
989
+ utils.log("1 down");
990
+ utils.log(n[0]);
991
+ this.skip_keyup = true;
992
+ this.selection().removeAllRanges();
993
+ this.markAsSelected(next_node);
994
+ next_node.addClass("is-mediaFocused is-selected");
995
+ return false;
996
+ } else if (next_node.hasClass("graf--mixtapeEmbed")) {
997
+ n = current_node.next(".graf--mixtapeEmbed");
998
+ num = n[0].childNodes.length;
999
+ this.setRangeAt(n[0], num);
1000
+ this.scrollTo(n);
1001
+ utils.log("2 down");
1002
+ return false;
1003
+ }
1004
+ if (current_node.hasClass("graf--figure") && next_node.hasClass("graf")) {
1005
+ this.scrollTo(next_node);
1006
+ utils.log("3 down, from figure to next graf");
1007
+ this.markAsSelected(next_node);
1008
+ this.setRangeAt(next_node[0]);
1009
+ return false;
1010
+ }
1011
+ break;
1012
+ case "Up":
1013
+ prev_node = current_node.prev();
1014
+ utils.log("PREV NODE IS " + (prev_node.attr('class')));
1015
+ utils.log("CURRENT NODE IS up " + (current_node.attr('class')));
1016
+ if (!$(current_node).hasClass("graf")) {
1017
+ return;
1018
+ }
1019
+ if (!$(current_node).editableCaretOnFirstLine()) {
1020
+ return;
1021
+ }
1022
+ utils.log("ENTER ARROW PASSED RETURNS");
1023
+ if (prev_node.hasClass("graf--figure")) {
1024
+ utils.log("1 up");
1025
+ n = prev_node.find(".imageCaption");
1026
+ this.scrollTo(n);
1027
+ this.skip_keyup = true;
1028
+ this.selection().removeAllRanges();
1029
+ this.markAsSelected(prev_node);
1030
+ prev_node.addClass("is-mediaFocused");
1031
+ return false;
1032
+ } else if (prev_node.hasClass("graf--mixtapeEmbed")) {
1033
+ n = current_node.prev(".graf--mixtapeEmbed");
1034
+ num = n[0].childNodes.length;
1035
+ this.setRangeAt(n[0], num);
1036
+ this.scrollTo(n);
1037
+ utils.log("2 up");
1038
+ return false;
1039
+ }
1040
+ if (current_node.hasClass("graf--figure") && prev_node.hasClass("graf")) {
1041
+ this.setRangeAt(prev_node[0]);
1042
+ this.scrollTo(prev_node);
1043
+ utils.log("3 up");
1044
+ return false;
1045
+ } else if (prev_node.hasClass("graf")) {
1046
+ n = current_node.prev(".graf");
1047
+ num = n[0].childNodes.length;
1048
+ this.scrollTo(n);
1049
+ utils.log("4 up");
1050
+ this.skip_keyup = true;
1051
+ this.markAsSelected(prev_node);
1052
+ return false;
1053
+ }
1054
+ }
1055
+ };
1056
+
1057
+ Editor.prototype.parseInitialMess = function() {
1058
+ return this.setupElementsClasses($(this.el).find('.section-inner'), (function(_this) {
1059
+ return function() {
1060
+ return _this.handleUnwrappedImages($(_this.el).find('.section-inner'));
1061
+ };
1062
+ })(this));
1063
+ };
1064
+
1065
+ Editor.prototype.handleDblclick = function() {
1066
+ var node;
1067
+ utils.log("handleDblclick");
1068
+ node = this.getNode();
1069
+ if (_.isNull(node)) {
1070
+ this.setRangeAt(this.prev_current_node);
1071
+ }
1072
+ return false;
1073
+ };
1074
+
1075
+ Editor.prototype.handlePaste = function(ev) {
1076
+ var cbd, pastedText;
1077
+ utils.log("pasted!");
1078
+ this.aa = this.getNode();
1079
+ pastedText = void 0;
1080
+ if (window.clipboardData && window.clipboardData.getData) {
1081
+ pastedText = window.clipboardData.getData('Text');
1082
+ } else if (ev.originalEvent.clipboardData && ev.originalEvent.clipboardData.getData) {
1083
+ cbd = ev.originalEvent.clipboardData;
1084
+ pastedText = _.isEmpty(cbd.getData('text/html')) ? cbd.getData('text/plain') : cbd.getData('text/html');
1085
+ }
1086
+ utils.log("Process and handle text...");
1087
+ if (pastedText.match(/<\/*[a-z][^>]+?>/gi)) {
1088
+ utils.log("HTML DETECTED ON PASTE");
1089
+ pastedText = pastedText.replace(/&.*;/g, "");
1090
+ pastedText = pastedText.replace(/<div>([\w\W]*?)<\/div>/gi, '<p>$1</p>');
1091
+ document.body.appendChild($("<div id='" + (this.paste_element_id.replace('#', '')) + "'></div>")[0]);
1092
+ $(this.paste_element_id).html("<span>" + pastedText + "</span>");
1093
+ this.setupElementsClasses($(this.paste_element_id), (function(_this) {
1094
+ return function() {
1095
+ var last_node, new_node, nodes, num, top;
1096
+ nodes = $($(_this.paste_element_id).html()).insertAfter($(_this.aa));
1097
+ $(_this.paste_element_id).remove();
1098
+ last_node = nodes.last()[0];
1099
+ num = last_node.childNodes.length;
1100
+ _this.setRangeAt(last_node, num);
1101
+ new_node = $(_this.getNode());
1102
+ top = new_node.offset().top;
1103
+ _this.markAsSelected(new_node);
1104
+ _this.displayTooltipAt($(_this.el).find(".is-selected"));
1105
+ _this.handleUnwrappedImages(nodes);
1106
+ return $('html, body').animate({
1107
+ scrollTop: top
1108
+ }, 200);
1109
+ };
1110
+ })(this));
1111
+ return false;
1112
+ }
1113
+ };
1114
+
1115
+ Editor.prototype.handleUnwrappedImages = function(elements) {
1116
+ return _.each(elements.find("img"), (function(_this) {
1117
+ return function(image) {
1118
+ utils.log("process image here!");
1119
+ return _this.uploader_widget.uploadExistentImage(image);
1120
+ };
1121
+ })(this));
1122
+ };
1123
+
1124
+ Editor.prototype.handleInmediateDeletion = function(element) {
1125
+ var new_node;
1126
+ this.inmediateDeletion = false;
1127
+ new_node = $(this.baseParagraphTmpl()).insertBefore($(element));
1128
+ new_node.addClass("is-selected");
1129
+ this.setRangeAt($(element).prev()[0]);
1130
+ return $(element).remove();
1131
+ };
1132
+
1133
+ Editor.prototype.handleUnwrappedNode = function(element) {
1134
+ var new_node, tmpl;
1135
+ tmpl = $(this.baseParagraphTmpl());
1136
+ this.setElementName(tmpl);
1137
+ $(element).wrap(tmpl);
1138
+ new_node = $("[name='" + (tmpl.attr('name')) + "']");
1139
+ new_node.addClass("is-selected");
1140
+ this.setRangeAt(new_node[0]);
1141
+ return false;
1142
+ };
1143
+
1144
+
1145
+ /*
1146
+ This is a rare hack only for FF (I hope),
1147
+ when there is no range it creates a new element as a placeholder,
1148
+ then finds previous element from that placeholder,
1149
+ then it focus the prev and removes the placeholder.
1150
+ a nasty nasty one...
1151
+ */
1152
+
1153
+ Editor.prototype.handleNullAnchor = function() {
1154
+ var node, num, prev, range, sel, span;
1155
+ utils.log("WARNING! this is an empty node");
1156
+ sel = this.selection();
1157
+ if (sel.isCollapsed && sel.rangeCount > 0) {
1158
+ range = sel.getRangeAt(0);
1159
+ span = $(this.baseParagraphTmpl())[0];
1160
+ range.insertNode(span);
1161
+ range.setStart(span, 0);
1162
+ range.setEnd(span, 0);
1163
+ sel.removeAllRanges();
1164
+ sel.addRange(range);
1165
+ node = $(range.commonAncestorContainer);
1166
+ prev = node.prev();
1167
+ num = prev[0].childNodes.length;
1168
+ utils.log(prev);
1169
+ if (prev.hasClass("graf")) {
1170
+ this.setRangeAt(prev[0], num);
1171
+ node.remove();
1172
+ this.markAsSelected(this.getNode());
1173
+ } else if (prev.hasClass("graf--mixtapeEmbed")) {
1174
+ this.setRangeAt(prev[0], num);
1175
+ node.remove();
1176
+ this.markAsSelected(this.getNode());
1177
+ } else if (!prev) {
1178
+ this.setRangeAt(this.$el.find(".section-inner p")[0]);
1179
+ }
1180
+ return this.displayTooltipAt($(this.el).find(".is-selected"));
1181
+ }
1182
+ };
1183
+
1184
+ Editor.prototype.handleCompleteDeletion = function(element) {
1185
+ if (_.isEmpty($(element).text().trim())) {
1186
+ utils.log("HANDLE COMPLETE DELETION");
1187
+ this.selection().removeAllRanges();
1188
+ this.render();
1189
+ setTimeout((function(_this) {
1190
+ return function() {
1191
+ return _this.setRangeAt($(_this.el).find(".section-inner p")[0]);
1192
+ };
1193
+ })(this), 20);
1194
+ return this.completeDeletion = true;
1195
+ }
1196
+ };
1197
+
1198
+ Editor.prototype.handleTab = function(anchor_node) {
1199
+ var classes, next;
1200
+ utils.log("HANDLE TAB");
1201
+ classes = ".graf, .graf--mixtapeEmbed, .graf--figure, .graf--figure";
1202
+ next = $(anchor_node).next(classes);
1203
+ if ($(next).hasClass("graf--figure")) {
1204
+ next = $(next).find("figcaption");
1205
+ this.setRangeAt(next[0]);
1206
+ this.markAsSelected($(next).parent(".graf--figure"));
1207
+ this.displayTooltipAt(next);
1208
+ this.scrollTo($(next));
1209
+ return false;
1210
+ }
1211
+ if (_.isEmpty(next) || _.isUndefined(next[0])) {
1212
+ next = $(".graf:first");
1213
+ }
1214
+ this.setRangeAt(next[0]);
1215
+ this.markAsSelected(next);
1216
+ this.displayTooltipAt(next);
1217
+ return this.scrollTo($(next));
1218
+ };
1219
+
1220
+ Editor.prototype.handleKeyDown = function(e) {
1221
+ var anchor_node, eventHandled, li, parent, utils_anchor_node;
1222
+ utils.log("KEYDOWN");
1223
+ anchor_node = this.getNode();
1224
+ parent = $(anchor_node);
1225
+ if (anchor_node) {
1226
+ this.markAsSelected(anchor_node);
1227
+ }
1228
+ if (e.which === TAB) {
1229
+ this.handleTab(anchor_node);
1230
+ return false;
1231
+ }
1232
+ if (e.which === ENTER) {
1233
+ $(this.el).find(".is-selected").removeClass("is-selected");
1234
+ utils.log(this.isLastChar());
1235
+ if (parent.hasClass("graf--p")) {
1236
+ li = this.handleSmartList(parent, e);
1237
+ if (li) {
1238
+ anchor_node = li;
1239
+ }
1240
+ } else if (parent.hasClass("graf--li")) {
1241
+ this.handleListLineBreak(parent, e);
1242
+ }
1243
+ utils.log("HANDLING WIDGET KEYDOWNS");
1244
+ _.each(this.widgets, (function(_this) {
1245
+ return function(w) {
1246
+ if (w.handleEnterKey) {
1247
+ return w.handleEnterKey(e, parent);
1248
+ }
1249
+ };
1250
+ })(this));
1251
+ if (parent.hasClass("graf--mixtapeEmbed") || parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1252
+ utils.log("supress linebreak from embed !(last char)");
1253
+ if (!this.isLastChar()) {
1254
+ return false;
1255
+ }
1256
+ }
1257
+ if (parent.hasClass("graf--iframe") || parent.hasClass("graf--figure")) {
1258
+ if (this.isLastChar()) {
1259
+ this.handleLineBreakWith("p", parent);
1260
+ this.setRangeAtText($(".is-selected")[0]);
1261
+ $(".is-selected").trigger("mouseup");
1262
+ return false;
1263
+ } else {
1264
+ return false;
1265
+ }
1266
+ }
1267
+ this.tooltip_view.cleanOperationClasses($(anchor_node));
1268
+ if (anchor_node && this.editor_menu.lineBreakReg.test(anchor_node.nodeName)) {
1269
+ if (this.isLastChar()) {
1270
+ utils.log("new paragraph if it's the last character");
1271
+ e.preventDefault();
1272
+ this.handleLineBreakWith("p", parent);
1273
+ }
1274
+ }
1275
+ setTimeout((function(_this) {
1276
+ return function() {
1277
+ var node;
1278
+ node = _this.getNode();
1279
+ if (_.isUndefined(node)) {
1280
+ return;
1281
+ }
1282
+ _this.setElementName($(node));
1283
+ if (node.nodeName.toLowerCase() === "div") {
1284
+ node = _this.replaceWith("p", $(node))[0];
1285
+ }
1286
+ _this.markAsSelected($(node));
1287
+ _this.setupFirstAndLast();
1288
+ if (_.isEmpty($(node).text().trim())) {
1289
+ _.each($(node).children(), function(n) {
1290
+ return $(n).remove();
1291
+ });
1292
+ $(node).append("<br>");
1293
+ }
1294
+ return _this.displayTooltipAt($(_this.el).find(".is-selected"));
1295
+ };
1296
+ })(this), 2);
1297
+ }
1298
+ if (e.which === BACKSPACE) {
1299
+ eventHandled = false;
1300
+ this.tooltip_view.hide();
1301
+ utils.log("removing from down");
1302
+ if (this.reachedTop) {
1303
+ utils.log("REACHED TOP");
1304
+ }
1305
+ if (this.prevented || this.reachedTop && this.isFirstChar()) {
1306
+ return false;
1307
+ }
1308
+ utils.log("pass initial validations");
1309
+ anchor_node = this.getNode();
1310
+ utils_anchor_node = utils.getNode();
1311
+ utils.log(anchor_node);
1312
+ utils.log(utils_anchor_node);
1313
+ utils.log("HANDLING WIDGET BACKSPACES");
1314
+ _.each(this.widgets, (function(_this) {
1315
+ return function(w) {
1316
+ var handled;
1317
+ if (w.handleBackspaceKey && !handled) {
1318
+ return handled = w.handleBackspaceKey(e, anchor_node);
1319
+ }
1320
+ };
1321
+ })(this));
1322
+ if (eventHandled) {
1323
+ e.preventDefault();
1324
+ return false;
1325
+ }
1326
+ if (parent.hasClass("graf--li") && this.getCharacterPrecedingCaret().length === 0) {
1327
+ return this.handleListBackspace(parent, e);
1328
+ }
1329
+ if ($(anchor_node).hasClass("graf--p") && this.isFirstChar) {
1330
+ if ($(anchor_node).prev().hasClass("graf--figure")) {
1331
+ e.preventDefault();
1332
+ $(anchor_node).prev().find("img").click();
1333
+ utils.log("Focus on the previous image");
1334
+ }
1335
+ }
1336
+ if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1337
+ utils.log("SECTION DETECTED FROM KEYDOWN " + (_.isEmpty($(utils_anchor_node).text())));
1338
+ if (_.isEmpty($(utils_anchor_node).text())) {
1339
+ return false;
1340
+ }
1341
+ }
1342
+ if (anchor_node && anchor_node.nodeType === 3) {
1343
+ utils.log("TextNode detected from Down!");
1344
+ }
1345
+ if ($(anchor_node).hasClass("graf--mixtapeEmbed") || $(anchor_node).hasClass("graf--iframe")) {
1346
+ if (_.isEmpty($(anchor_node).text().trim() || this.isFirstChar())) {
1347
+ utils.log("Check for inmediate deletion on empty embed text");
1348
+ this.inmediateDeletion = this.isSelectingAll(anchor_node);
1349
+ if (this.inmediateDeletion) {
1350
+ this.handleInmediateDeletion($(anchor_node));
1351
+ }
1352
+ return false;
1353
+ }
1354
+ }
1355
+ if ($(anchor_node).prev().hasClass("graf--mixtapeEmbed")) {
1356
+ if (this.isFirstChar() && !_.isEmpty($(anchor_node).text().trim())) {
1357
+ return false;
1358
+ }
1359
+ }
1360
+ }
1361
+ if (e.which === SPACEBAR) {
1362
+ utils.log("SPACEBAR");
1363
+ if (parent.hasClass("graf--p")) {
1364
+ this.handleSmartList(parent, e);
1365
+ }
1366
+ }
1367
+ if (_.contains([UPARROW, DOWNARROW], e.which)) {
1368
+ utils.log(e.which);
1369
+ this.handleArrowForKeyDown(e);
1370
+ }
1371
+ if (anchor_node) {
1372
+ if (!_.isEmpty($(anchor_node).text())) {
1373
+ this.tooltip_view.hide();
1374
+ $(anchor_node).removeClass("graf--empty");
1375
+ }
1376
+ }
1377
+ if (_.isUndefined(anchor_node) && $(".is-selected").hasClass("is-mediaFocused")) {
1378
+ this.setRangeAt($(".is-selected").find("figcaption")[0]);
1379
+ $(".is-selected").removeClass("is-mediaFocused");
1380
+ return false;
1381
+ }
1382
+ };
1383
+
1384
+ Editor.prototype.handleKeyUp = function(e, node) {
1385
+ var anchor_node, next_graf, utils_anchor_node;
1386
+ if (this.skip_keyup) {
1387
+ this.skip_keyup = null;
1388
+ utils.log("SKIP KEYUP");
1389
+ return false;
1390
+ }
1391
+ utils.log("KEYUP");
1392
+ this.editor_menu.hide();
1393
+ this.reachedTop = false;
1394
+ anchor_node = this.getNode();
1395
+ utils_anchor_node = utils.getNode();
1396
+ this.handleTextSelection(anchor_node);
1397
+ if (_.contains([BACKSPACE, SPACEBAR, ENTER], e.which)) {
1398
+ if ($(anchor_node).hasClass("graf--li")) {
1399
+ this.removeSpanTag($(anchor_node));
1400
+ }
1401
+ }
1402
+ if (e.which === BACKSPACE) {
1403
+ if ($(utils_anchor_node).hasClass("postField--body")) {
1404
+ utils.log("ALL GONE from UP");
1405
+ this.handleCompleteDeletion($(this.el));
1406
+ if (this.completeDeletion) {
1407
+ this.completeDeletion = false;
1408
+ return false;
1409
+ }
1410
+ }
1411
+ if ($(utils_anchor_node).hasClass("section-content") || $(utils_anchor_node).hasClass("graf--first")) {
1412
+ utils.log("SECTION DETECTED FROM KEYUP " + (_.isEmpty($(utils_anchor_node).text())));
1413
+ if (_.isEmpty($(utils_anchor_node).text())) {
1414
+ next_graf = $(utils_anchor_node).next(".graf")[0];
1415
+ if (next_graf) {
1416
+ this.setRangeAt(next_graf);
1417
+ $(utils_anchor_node).remove();
1418
+ this.setupFirstAndLast();
1419
+ }
1420
+ return false;
1421
+ }
1422
+ }
1423
+ if (_.isNull(anchor_node)) {
1424
+ this.handleNullAnchor();
1425
+ return false;
1426
+ }
1427
+ if ($(anchor_node).hasClass("graf--first")) {
1428
+ utils.log("THE FIRST ONE! UP");
1429
+ if (this.getSelectedText() === this.getNode().textContent) {
1430
+ utils.log("remove selection dectected");
1431
+ this.getNode().innerHTML = "<br>";
1432
+ }
1433
+ this.markAsSelected(anchor_node);
1434
+ this.setupFirstAndLast();
1435
+ false;
1436
+ }
1437
+ }
1438
+ if (_.contains([LEFTARROW, UPARROW, RIGHTARROW, DOWNARROW], e.which)) {
1439
+ return this.handleArrow(e);
1440
+ }
1441
+ };
1442
+
1443
+ Editor.prototype.handleLineBreakWith = function(element_type, from_element) {
1444
+ var new_paragraph;
1445
+ new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1446
+ if (from_element.parent().is('[class^="graf--"]')) {
1447
+ new_paragraph.insertAfter(from_element.parent());
1448
+ } else {
1449
+ new_paragraph.insertAfter(from_element);
1450
+ }
1451
+ this.setRangeAt(new_paragraph[0]);
1452
+ return this.scrollTo(new_paragraph);
1453
+ };
1454
+
1455
+ Editor.prototype.replaceWith = function(element_type, from_element) {
1456
+ var new_paragraph;
1457
+ new_paragraph = $("<" + element_type + " class='graf graf--" + element_type + " graf--empty is-selected'><br/></" + element_type + ">");
1458
+ from_element.replaceWith(new_paragraph);
1459
+ this.setRangeAt(new_paragraph[0]);
1460
+ this.scrollTo(new_paragraph);
1461
+ return new_paragraph;
1462
+ };
1463
+
1464
+ Editor.prototype.displayTooltipAt = function(element) {
1465
+ utils.log("POSITION FOR TOOLTIP");
1466
+ element = $(element);
1467
+ if (!element || _.isUndefined(element) || _.isEmpty(element) || element[0].tagName === "LI") {
1468
+ return;
1469
+ }
1470
+ this.tooltip_view.hide();
1471
+ if (!_.isEmpty(element.text())) {
1472
+ return;
1473
+ }
1474
+ this.positions = element.offset();
1475
+ this.tooltip_view.render();
1476
+ return this.tooltip_view.move(this.positions);
1477
+ };
1478
+
1479
+ Editor.prototype.markAsSelected = function(element) {
1480
+ if (_.isUndefined(element)) {
1481
+ return;
1482
+ }
1483
+ $(this.el).find(".is-selected").removeClass("is-mediaFocused is-selected");
1484
+ $(element).addClass("is-selected");
1485
+ $(element).find(".defaultValue").remove();
1486
+ if ($(element).hasClass("graf--first")) {
1487
+ this.reachedTop = true;
1488
+ if ($(element).find("br").length === 0) {
1489
+ return $(element).append("<br>");
1490
+ }
1491
+ }
1492
+ };
1493
+
1494
+ Editor.prototype.addClassesToElement = function(element) {
1495
+ var n, name, new_el;
1496
+ n = element;
1497
+ name = n.nodeName.toLowerCase();
1498
+ switch (name) {
1499
+ case "p":
1500
+ case "pre":
1501
+ case "div":
1502
+ if (!$(n).hasClass("graf--mixtapeEmbed")) {
1503
+ $(n).removeClass().addClass("graf graf--" + name);
1504
+ }
1505
+ if (name === "p" && $(n).find("br").length === 0) {
1506
+ $(n).append("<br>");
1507
+ }
1508
+ break;
1509
+ case "h1":
1510
+ case "h2":
1511
+ case "h3":
1512
+ case "h4":
1513
+ case "h5":
1514
+ case "h6":
1515
+ if (name === "h1") {
1516
+ new_el = $("<h2 class='graf graf--h2'>" + ($(n).text()) + "</h2>");
1517
+ $(n).replaceWith(new_el);
1518
+ this.setElementName(n);
1519
+ } else {
1520
+ $(n).removeClass().addClass("graf graf--" + name);
1521
+ }
1522
+ break;
1523
+ case "code":
1524
+ $(n).unwrap().wrap("<p class='graf graf--pre'></p>");
1525
+ n = $(n).parent();
1526
+ break;
1527
+ case "ol":
1528
+ case "ul":
1529
+ utils.log("lists");
1530
+ $(n).removeClass().addClass("postList");
1531
+ _.each($(n).find("li"), function(li) {
1532
+ return $(li).removeClass().addClass("graf graf--li");
1533
+ });
1534
+ break;
1535
+ case "img":
1536
+ utils.log("images");
1537
+ this.uploader_widget.uploadExistentImage(n);
1538
+ break;
1539
+ case "a":
1540
+ case 'strong':
1541
+ case 'em':
1542
+ case 'br':
1543
+ case 'b':
1544
+ case 'u':
1545
+ case 'i':
1546
+ utils.log("links");
1547
+ $(n).wrap("<p class='graf graf--p'></p>");
1548
+ n = $(n).parent();
1549
+ break;
1550
+ case "blockquote":
1551
+ n = $(n).removeClass().addClass("graf graf--" + name);
1552
+ break;
1553
+ case "figure":
1554
+ if ($(n).hasClass(".graf--figure")) {
1555
+ n = $(n);
1556
+ }
1557
+ break;
1558
+ default:
1559
+ $(n).wrap("<p class='graf graf--" + name + "'></p>");
1560
+ n = $(n).parent();
1561
+ }
1562
+ return n;
1563
+ };
1564
+
1565
+ Editor.prototype.setupElementsClasses = function(element, cb) {
1566
+ if (_.isUndefined(element)) {
1567
+ this.element = $(this.el).find('.section-inner');
1568
+ } else {
1569
+ this.element = element;
1570
+ }
1571
+ return setTimeout((function(_this) {
1572
+ return function() {
1573
+ _this.cleanContents(_this.element);
1574
+ _this.wrapTextNodes(_this.element);
1575
+ _.each(_this.element.children(), function(n) {
1576
+ var name;
1577
+ name = $(n).prop("tagName").toLowerCase();
1578
+ n = _this.addClassesToElement(n);
1579
+ return _this.setElementName(n);
1580
+ });
1581
+ _this.setupLinks(_this.element.find("a"));
1582
+ _this.setupFirstAndLast();
1583
+ if (_.isFunction(cb)) {
1584
+ return cb();
1585
+ }
1586
+ };
1587
+ })(this), 20);
1588
+ };
1589
+
1590
+ Editor.prototype.cleanContents = function(element) {
1591
+ var s;
1592
+ if (_.isUndefined(element)) {
1593
+ this.element = $(this.el).find('.section-inner');
1594
+ } else {
1595
+ this.element = element;
1596
+ }
1597
+ s = new Sanitize({
1598
+ elements: ['strong', 'img', 'em', 'br', 'a', 'blockquote', 'b', 'u', 'i', 'pre', 'p', 'h1', 'h2', 'h3', 'h4', 'ul', 'ol', 'li'],
1599
+ attributes: {
1600
+ '__ALL__': ['class'],
1601
+ a: ['href', 'title', 'target'],
1602
+ img: ['src']
1603
+ },
1604
+ protocols: {
1605
+ a: {
1606
+ href: ['http', 'https', 'mailto']
1607
+ }
1608
+ },
1609
+ transformers: [
1610
+ function(input) {
1611
+ if (input.node_name === "span" && $(input.node).hasClass("defaultValue")) {
1612
+ return {
1613
+ whitelist_nodes: [input.node]
1614
+ };
1615
+ } else {
1616
+ return null;
1617
+ }
1618
+ }, function(input) {
1619
+ if (input.node_name === 'div' && $(input.node).hasClass("graf--mixtapeEmbed")) {
1620
+ return {
1621
+ whitelist_nodes: [input.node]
1622
+ };
1623
+ } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1624
+ return {
1625
+ attr_whitelist: ["style"]
1626
+ };
1627
+ } else {
1628
+ return null;
1629
+ }
1630
+ }, function(input) {
1631
+ if (input.node_name === 'figure' && $(input.node).hasClass("graf--iframe")) {
1632
+ return {
1633
+ whitelist_nodes: [input.node]
1634
+ };
1635
+ } else if (input.node_name === 'div' && $(input.node).hasClass("iframeContainer") && $(input.node).parent(".graf--iframe").exists()) {
1636
+ return {
1637
+ whitelist_nodes: [input.node]
1638
+ };
1639
+ } else if (input.node_name === 'iframe' && $(input.node).parent(".iframeContainer").exists()) {
1640
+ return {
1641
+ whitelist_nodes: [input.node]
1642
+ };
1643
+ } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--iframe").exists()) {
1644
+ return {
1645
+ whitelist_nodes: [input.node]
1646
+ };
1647
+ } else {
1648
+ return null;
1649
+ }
1650
+ }, function(input) {
1651
+ if (input.node_name === 'figure' && $(input.node).hasClass("graf--figure")) {
1652
+ return {
1653
+ whitelist_nodes: [input.node]
1654
+ };
1655
+ } else if (input.node_name === 'div' && ($(input.node).hasClass("aspectRatioPlaceholder") && $(input.node).parent(".graf--figure").exists())) {
1656
+ return {
1657
+ whitelist_nodes: [input.node]
1658
+ };
1659
+ } else if (input.node_name === 'div' && ($(input.node).hasClass("aspect-ratio-fill") && $(input.node).parent(".aspectRatioPlaceholder").exists())) {
1660
+ return {
1661
+ whitelist_nodes: [input.node]
1662
+ };
1663
+ } else if (input.node_name === 'img' && $(input.node).parent(".graf--figure").exists()) {
1664
+ return {
1665
+ whitelist_nodes: [input.node]
1666
+ };
1667
+ } else if (input.node_name === 'a' && $(input.node).parent(".graf--mixtapeEmbed").exists()) {
1668
+ return {
1669
+ attr_whitelist: ["style"]
1670
+ };
1671
+ } else if (input.node_name === 'figcaption' && $(input.node).parent(".graf--figure").exists()) {
1672
+ return {
1673
+ whitelist_nodes: [input.node]
1674
+ };
1675
+ } else if (input.node_name === 'span' && $(input.node).parent(".imageCaption").exists()) {
1676
+ return {
1677
+ whitelist_nodes: [input.node]
1678
+ };
1679
+ } else {
1680
+ return null;
1681
+ }
1682
+ }
1683
+ ]
1684
+ });
1685
+ if (this.element.exists()) {
1686
+ utils.log("CLEAN HTML " + this.element[0].tagName);
1687
+ return this.element.html(s.clean_node(this.element[0]));
1688
+ }
1689
+ };
1690
+
1691
+ Editor.prototype.setupLinks = function(elems) {
1692
+ return _.each(elems, (function(_this) {
1693
+ return function(n) {
1694
+ return _this.setupLink(n);
1695
+ };
1696
+ })(this));
1697
+ };
1698
+
1699
+ Editor.prototype.setupLink = function(n) {
1700
+ var href, parent_name;
1701
+ parent_name = $(n).parent().prop("tagName").toLowerCase();
1702
+ $(n).addClass("markup--anchor markup--" + parent_name + "-anchor");
1703
+ href = $(n).attr("href");
1704
+ return $(n).attr("data-href", href);
1705
+ };
1706
+
1707
+ Editor.prototype.preCleanNode = function(element) {
1708
+ var s;
1709
+ s = new Sanitize({
1710
+ elements: ['strong', 'em', 'br', 'a', 'b', 'u', 'i', 'ul', 'ol', 'li'],
1711
+ attributes: {
1712
+ a: ['href', 'title', 'target']
1713
+ },
1714
+ protocols: {
1715
+ a: {
1716
+ href: ['http', 'https', 'mailto']
1717
+ }
1718
+ }
1719
+ });
1720
+ $(element).html(s.clean_node(element[0]));
1721
+ element = this.addClassesToElement($(element)[0]);
1722
+ return $(element);
1723
+ };
1724
+
1725
+ Editor.prototype.setupFirstAndLast = function() {
1726
+ var childs;
1727
+ childs = $(this.el).find(".section-inner").children();
1728
+ childs.removeClass("graf--last , graf--first");
1729
+ childs.first().addClass("graf--first");
1730
+ return childs.last().addClass("graf--last");
1731
+ };
1732
+
1733
+ Editor.prototype.wrapTextNodes = function(element) {
1734
+ if (_.isUndefined(element)) {
1735
+ element = $(this.el).find('.section-inner');
1736
+ } else {
1737
+ element = element;
1738
+ }
1739
+ return element.contents().filter(function() {
1740
+ return this.nodeType === 3 && this.data.trim().length > 0;
1741
+ }).wrap("<p class='graf grap--p'></p>");
1742
+ };
1743
+
1744
+ Editor.prototype.setElementName = function(element) {
1745
+ return $(element).attr("name", utils.generateUniqueName());
1746
+ };
1747
+
1748
+ Editor.prototype.listify = function($paragraph, listType, regex) {
1749
+ var $li, $list, content;
1750
+ utils.log("LISTIFY PARAGRAPH");
1751
+ this.removeSpanTag($paragraph);
1752
+ content = $paragraph.html().replace(/&nbsp;/g, " ").replace(regex, "");
1753
+ switch (listType) {
1754
+ case "ul":
1755
+ $list = $("<ul></ul>");
1756
+ break;
1757
+ case "ol":
1758
+ $list = $("<ol></ol>");
1759
+ break;
1760
+ default:
1761
+ return false;
1762
+ }
1763
+ this.addClassesToElement($list[0]);
1764
+ this.replaceWith("li", $paragraph);
1765
+ $li = $(".is-selected");
1766
+ this.setElementName($li[0]);
1767
+ $li.html(content).wrap($list);
1768
+ if ($li.find("br").length === 0) {
1769
+ $li.append("<br/>");
1770
+ }
1771
+ this.setRangeAt($li[0]);
1772
+ return $li[0];
1773
+ };
1774
+
1775
+ Editor.prototype.handleSmartList = function($item, e) {
1776
+ var $li, chars, match, regex;
1777
+ utils.log("HANDLE A SMART LIST");
1778
+ chars = this.getCharacterPrecedingCaret();
1779
+ match = chars.match(/^\s*(\-|\*)\s*$/);
1780
+ if (match) {
1781
+ utils.log("CREATING LIST ITEM");
1782
+ e.preventDefault();
1783
+ regex = new RegExp(/\s*(\-|\*)\s*/);
1784
+ $li = this.listify($item, "ul", regex);
1785
+ } else {
1786
+ match = chars.match(/^\s*1(\.|\))\s*$/);
1787
+ if (match) {
1788
+ utils.log("CREATING LIST ITEM");
1789
+ e.preventDefault();
1790
+ regex = new RegExp(/\s*1(\.|\))\s*/);
1791
+ $li = this.listify($item, "ol", regex);
1792
+ }
1793
+ }
1794
+ return $li;
1795
+ };
1796
+
1797
+ Editor.prototype.handleListLineBreak = function($li, e) {
1798
+ var $list, $paragraph, content;
1799
+ utils.log("LIST LINE BREAK");
1800
+ this.tooltip_view.hide();
1801
+ $list = $li.parent("ol, ul");
1802
+ $paragraph = $("<p></p>");
1803
+ utils.log($li.prev());
1804
+ if ($list.children().length === 1 && $li.text() === "") {
1805
+ this.replaceWith("p", $list);
1806
+ } else if ($li.text() === "" && ($li.next().length !== 0)) {
1807
+ e.preventDefault();
1808
+ } else if ($li.next().length === 0) {
1809
+ if ($li.text() === "") {
1810
+ e.preventDefault();
1811
+ utils.log("BREAK FROM LIST");
1812
+ $list.after($paragraph);
1813
+ $li.addClass("graf--removed").remove();
1814
+ } else if ($li.prev().length !== 0 && $li.prev().text() === "" && this.getCharacterPrecedingCaret() === "") {
1815
+ e.preventDefault();
1816
+ utils.log("PREV IS EMPTY");
1817
+ content = $li.html();
1818
+ $list.after($paragraph);
1819
+ $li.prev().remove();
1820
+ $li.addClass("graf--removed").remove();
1821
+ $paragraph.html(content);
1822
+ }
1823
+ }
1824
+ if ($list && $list.children().length === 0) {
1825
+ $list.remove();
1826
+ }
1827
+ utils.log($li);
1828
+ if ($li.hasClass("graf--removed")) {
1829
+ utils.log("ELEMENT REMOVED");
1830
+ this.addClassesToElement($paragraph[0]);
1831
+ this.setRangeAt($paragraph[0]);
1832
+ this.markAsSelected($paragraph[0]);
1833
+ return this.scrollTo($paragraph);
1834
+ }
1835
+ };
1836
+
1837
+ Editor.prototype.handleListBackspace = function($li, e) {
1838
+ var $list, $paragraph, content;
1839
+ $list = $li.parent("ol, ul");
1840
+ utils.log("LIST BACKSPACE");
1841
+ if ($li.prev().length === 0) {
1842
+ e.preventDefault();
1843
+ $list.before($li);
1844
+ content = $li.html();
1845
+ this.replaceWith("p", $li);
1846
+ $paragraph = $(".is-selected");
1847
+ $paragraph.removeClass("graf--empty").html(content);
1848
+ if ($list.children().length === 0) {
1849
+ $list.remove();
1850
+ }
1851
+ return this.setupFirstAndLast();
1852
+ }
1853
+ };
1854
+
1855
+ Editor.prototype.removeSpanTag = function($item) {
1856
+ var $spans, span, _i, _len;
1857
+ $spans = $item.find("span");
1858
+ for (_i = 0, _len = $spans.length; _i < _len; _i++) {
1859
+ span = $spans[_i];
1860
+ if (!$(span).hasClass("defaultValue")) {
1861
+ $(span).replaceWith($(span).html());
1862
+ }
1863
+ }
1864
+ return $item;
1865
+ };
1866
+
1867
+ return Editor;
1868
+
1869
+ })(Dante.View);
1870
+
1871
+ }).call(this);
1872
+ (function() {
1873
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1874
+ __hasProp = {}.hasOwnProperty,
1875
+ __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; };
1876
+
1877
+ Dante.View.TooltipWidget = (function(_super) {
1878
+ __extends(TooltipWidget, _super);
1879
+
1880
+ function TooltipWidget() {
1881
+ this.hide = __bind(this.hide, this);
1882
+ return TooltipWidget.__super__.constructor.apply(this, arguments);
1883
+ }
1884
+
1885
+ TooltipWidget.prototype.initialize = function(opts) {
1886
+ if (opts == null) {
1887
+ opts = {};
1888
+ }
1889
+ this.icon = opts.icon;
1890
+ this.title = opts.title;
1891
+ return this.actionEvent = opts.title;
1892
+ };
1893
+
1894
+ TooltipWidget.prototype.hide = function() {
1895
+ return this.current_editor.tooltip_view.hide();
1896
+ };
1897
+
1898
+ return TooltipWidget;
1899
+
1900
+ })(Dante.View);
1901
+
1902
+ }).call(this);
1903
+ (function() {
1904
+ var utils,
1905
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1906
+ __hasProp = {}.hasOwnProperty,
1907
+ __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; };
1908
+
1909
+ utils = Dante.utils;
1910
+
1911
+ Dante.View.TooltipWidget.Uploader = (function(_super) {
1912
+ __extends(Uploader, _super);
1913
+
1914
+ function Uploader() {
1915
+ this.handleBackspaceKey = __bind(this.handleBackspaceKey, this);
1916
+ this.uploadCompleted = __bind(this.uploadCompleted, this);
1917
+ this.updateProgressBar = __bind(this.updateProgressBar, this);
1918
+ this.uploadFile = __bind(this.uploadFile, this);
1919
+ this.uploadFiles = __bind(this.uploadFiles, this);
1920
+ return Uploader.__super__.constructor.apply(this, arguments);
1921
+ }
1922
+
1923
+ Uploader.prototype.initialize = function(opts) {
1924
+ if (opts == null) {
1925
+ opts = {};
1926
+ }
1927
+ this.icon = opts.icon || "icon-image";
1928
+ this.title = opts.title || "Add an image";
1929
+ this.action = opts.action || "menu-image";
1930
+ return this.current_editor = opts.current_editor;
1931
+ };
1932
+
1933
+ Uploader.prototype.handleClick = function(ev) {
1934
+ return this.imageSelect(ev);
1935
+ };
1936
+
1937
+ Uploader.prototype.insertTemplate = function() {
1938
+ 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>";
1939
+ };
1940
+
1941
+ Uploader.prototype.uploadExistentImage = function(image_element, opts) {
1942
+ var i, img, n, node, tmpl, _i, _ref;
1943
+ if (opts == null) {
1944
+ opts = {};
1945
+ }
1946
+ utils.log("process image here!");
1947
+ tmpl = $(this.insertTemplate());
1948
+ tmpl.find("img").attr('src', this.current_editor.default_loading_placeholder);
1949
+ if ($(image_element).parents(".graf").length > 0) {
1950
+ if ($(image_element).parents(".graf").hasClass("graf--figure")) {
1951
+ return;
1952
+ }
1953
+ utils.log("UNO");
1954
+ tmpl.insertBefore($(image_element).parents(".graf"));
1955
+ node = this.current_editor.getNode();
1956
+ if (node) {
1957
+ this.current_editor.preCleanNode($(node));
1958
+ this.current_editor.addClassesToElement(node);
1959
+ }
1960
+ } else {
1961
+ utils.log("DOS");
1962
+ img = $(image_element).parentsUntil(".section-inner").first();
1963
+ $(img).replaceWith(tmpl);
1964
+ }
1965
+ utils.log($("[name='" + (tmpl.attr('name')) + "']").attr("name"));
1966
+ this.replaceImg(image_element, $("[name='" + (tmpl.attr('name')) + "']"));
1967
+ n = $("[name='" + (tmpl.attr('name')) + "']").parentsUntil(".section-inner").length;
1968
+ if (n !== 0) {
1969
+ for (i = _i = 0, _ref = n - 1; _i <= _ref; i = _i += 1) {
1970
+ $("[name='" + (tmpl.attr('name')) + "']").unwrap();
1971
+ }
1972
+ }
1973
+ return utils.log("FIG");
1974
+ };
1975
+
1976
+ Uploader.prototype.replaceImg = function(image_element, figure) {
1977
+ var img, self;
1978
+ utils.log(figure.attr("name"));
1979
+ utils.log(figure);
1980
+ $(image_element).remove();
1981
+ img = new Image();
1982
+ img.src = image_element.src;
1983
+ self = this;
1984
+ return img.onload = function() {
1985
+ var ar;
1986
+ utils.log("replace image with loaded info");
1987
+ utils.log(figure.attr("name"));
1988
+ utils.log(this.width + 'x' + this.height);
1989
+ ar = self.getAspectRatio(this.width, this.height);
1990
+ figure.find(".aspectRatioPlaceholder").css({
1991
+ 'max-width': ar.width,
1992
+ 'max-height': ar.height
1993
+ });
1994
+ figure.find(".graf-image").attr({
1995
+ "data-height": this.height,
1996
+ "data-width": this.width
1997
+ });
1998
+ figure.find(".aspect-ratio-fill").css({
1999
+ "padding-bottom": "" + ar.ratio + "%"
2000
+ });
2001
+ return figure.find("img").attr("src", image_element.src);
2002
+ };
2003
+ };
2004
+
2005
+ Uploader.prototype.displayAndUploadImages = function(file) {
2006
+ return this.displayCachedImage(file);
2007
+ };
2008
+
2009
+ Uploader.prototype.imageSelect = function(ev) {
2010
+ var $selectFile, self;
2011
+ $selectFile = $('<input type="file" multiple="multiple">').click();
2012
+ self = this;
2013
+ return $selectFile.change(function() {
2014
+ var t;
2015
+ t = this;
2016
+ return self.uploadFiles(t.files);
2017
+ });
2018
+ };
2019
+
2020
+ Uploader.prototype.displayCachedImage = function(file) {
2021
+ var reader;
2022
+ this.current_editor.tooltip_view.hide();
2023
+ reader = new FileReader();
2024
+ reader.onload = (function(_this) {
2025
+ return function(e) {
2026
+ var img, node, self;
2027
+ img = new Image;
2028
+ img.src = e.target.result;
2029
+ node = _this.current_editor.getNode();
2030
+ self = _this;
2031
+ return img.onload = function() {
2032
+ var ar, img_tag, new_tmpl, replaced_node;
2033
+ new_tmpl = $(self.insertTemplate());
2034
+ replaced_node = $(new_tmpl).insertBefore($(node));
2035
+ img_tag = new_tmpl.find('img.graf-image').attr('src', e.target.result);
2036
+ img_tag.height = this.height;
2037
+ img_tag.width = this.width;
2038
+ utils.log("UPLOADED SHOW FROM CACHE");
2039
+ ar = self.getAspectRatio(this.width, this.height);
2040
+ replaced_node.find(".aspectRatioPlaceholder").css({
2041
+ 'max-width': ar.width,
2042
+ 'max-height': ar.height
2043
+ });
2044
+ replaced_node.find(".graf-image").attr({
2045
+ "data-height": this.height,
2046
+ "data-width": this.width
2047
+ });
2048
+ replaced_node.find(".aspect-ratio-fill").css({
2049
+ "padding-bottom": "" + ar.ratio + "%"
2050
+ });
2051
+ return self.uploadFile(file, replaced_node);
2052
+ };
2053
+ };
2054
+ })(this);
2055
+ return reader.readAsDataURL(file);
2056
+ };
2057
+
2058
+ Uploader.prototype.getAspectRatio = function(w, h) {
2059
+ var fill_ratio, height, maxHeight, maxWidth, ratio, result, width;
2060
+ maxWidth = 700;
2061
+ maxHeight = 700;
2062
+ ratio = 0;
2063
+ width = w;
2064
+ height = h;
2065
+ if (width > maxWidth) {
2066
+ ratio = maxWidth / width;
2067
+ height = height * ratio;
2068
+ width = width * ratio;
2069
+ } else if (height > maxHeight) {
2070
+ ratio = maxHeight / height;
2071
+ width = width * ratio;
2072
+ height = height * ratio;
2073
+ }
2074
+ fill_ratio = height / width * 100;
2075
+ result = {
2076
+ width: width,
2077
+ height: height,
2078
+ ratio: fill_ratio
2079
+ };
2080
+ utils.log(result);
2081
+ return result;
2082
+ };
2083
+
2084
+ Uploader.prototype.formatData = function(file, upload_params) {
2085
+ var formData;
2086
+ formData = new FormData();
2087
+ formData.append('file', file);
2088
+ formData.append('upload_params', upload_params);
2089
+ return formData;
2090
+ };
2091
+
2092
+ Uploader.prototype.uploadFiles = function(files) {
2093
+ var acceptedTypes, file, i, _results;
2094
+ acceptedTypes = {
2095
+ "image/png": true,
2096
+ "image/jpeg": true,
2097
+ "image/gif": true
2098
+ };
2099
+ i = 0;
2100
+ _results = [];
2101
+ while (i < files.length) {
2102
+ file = files[i];
2103
+ if (acceptedTypes[file.type] === true) {
2104
+ $(this.placeholder).append("<progress class=\"progress\" min=\"0\" max=\"100\" value=\"0\">0</progress>");
2105
+ this.displayAndUploadImages(file);
2106
+ }
2107
+ _results.push(i++);
2108
+ }
2109
+ return _results;
2110
+ };
2111
+
2112
+ Uploader.prototype.uploadFile = function(file, node) {
2113
+ var handleUp, n;
2114
+ n = node;
2115
+ handleUp = (function(_this) {
2116
+ return function(jqxhr) {
2117
+ return _this.uploadCompleted(jqxhr, n);
2118
+ };
2119
+ })(this);
2120
+ return $.ajax({
2121
+ type: "post",
2122
+ url: this.current_editor.upload_url,
2123
+ xhr: (function(_this) {
2124
+ return function() {
2125
+ var xhr;
2126
+ xhr = new XMLHttpRequest();
2127
+ xhr.upload.onprogress = _this.updateProgressBar;
2128
+ return xhr;
2129
+ };
2130
+ })(this),
2131
+ cache: false,
2132
+ contentType: false,
2133
+ success: (function(_this) {
2134
+ return function(response) {
2135
+ if (_this.current_editor.upload_callback) {
2136
+ response = _this.current_editor.upload_callback(response);
2137
+ }
2138
+ handleUp(response);
2139
+ };
2140
+ })(this),
2141
+ error: (function(_this) {
2142
+ return function(jqxhr) {
2143
+ return utils.log("ERROR: got error uploading file " + jqxhr.responseText);
2144
+ };
2145
+ })(this),
2146
+ processData: false,
2147
+ data: this.formatData(file, this.upload_params)
2148
+ });
2149
+ };
2150
+
2151
+ Uploader.prototype.updateProgressBar = function(e) {
2152
+ var $progress, complete;
2153
+ $progress = $('.progress:first', this.$el);
2154
+ complete = "";
2155
+ if (e.lengthComputable) {
2156
+ complete = e.loaded / e.total * 100;
2157
+ complete = complete != null ? complete : {
2158
+ complete: 0
2159
+ };
2160
+ utils.log("complete");
2161
+ return utils.log(complete);
2162
+ }
2163
+ };
2164
+
2165
+ Uploader.prototype.uploadCompleted = function(url, node) {
2166
+ return node.find("img").attr("src", url);
2167
+ };
2168
+
2169
+
2170
+ /*
2171
+ * Handles the behavior of deleting images when using the backspace key
2172
+ *
2173
+ * @param {Event} e - The backspace event that is being handled
2174
+ * @param {Node} node - The node the backspace was used in, assumed to be from te editor's getNode() function
2175
+ *
2176
+ * @return {Boolean} true if this function handled the backspace event, otherwise false
2177
+ */
2178
+
2179
+ Uploader.prototype.handleBackspaceKey = function(e, node) {
2180
+ if ($(".is-selected").hasClass("graf--figure") && (typeof anchor_node === "undefined" || anchor_node === null)) {
2181
+ utils.log("Replacing selected node");
2182
+ this.current_editor.replaceWith("p", $(".is-selected"));
2183
+ e.preventDefault();
2184
+ this.current_editor.setRangeAt($(".is-selected")[0]);
2185
+ return true;
2186
+ }
2187
+ return false;
2188
+ };
2189
+
2190
+ return Uploader;
2191
+
2192
+ })(Dante.View.TooltipWidget);
2193
+
2194
+ }).call(this);
2195
+ (function() {
2196
+ var utils,
2197
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2198
+ __hasProp = {}.hasOwnProperty,
2199
+ __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; };
2200
+
2201
+ utils = Dante.utils;
2202
+
2203
+ Dante.View.TooltipWidget.Embed = (function(_super) {
2204
+ __extends(Embed, _super);
2205
+
2206
+ function Embed() {
2207
+ this.getEmbedFromNode = __bind(this.getEmbedFromNode, this);
2208
+ return Embed.__super__.constructor.apply(this, arguments);
2209
+ }
2210
+
2211
+ Embed.prototype.initialize = function(opts) {
2212
+ if (opts == null) {
2213
+ opts = {};
2214
+ }
2215
+ this.icon = opts.icon || "icon-video";
2216
+ this.title = opts.title || "Add a video";
2217
+ this.action = opts.action || "embed";
2218
+ return this.current_editor = opts.current_editor;
2219
+ };
2220
+
2221
+ Embed.prototype.handleClick = function(ev) {
2222
+ return this.displayEmbedPlaceHolder(ev);
2223
+ };
2224
+
2225
+ Embed.prototype.handleEnterKey = function(ev, $node) {
2226
+ if ($node.hasClass("is-embedable")) {
2227
+ return this.getEmbedFromNode($node);
2228
+ }
2229
+ };
2230
+
2231
+ Embed.prototype.embedTemplate = function() {
2232
+ 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>";
2233
+ };
2234
+
2235
+ Embed.prototype.displayEmbedPlaceHolder = function() {
2236
+ var ph;
2237
+ ph = this.current_editor.embed_placeholder;
2238
+ this.node = this.current_editor.getNode();
2239
+ $(this.node).html(ph).addClass("is-embedable");
2240
+ this.current_editor.setRangeAt(this.node);
2241
+ this.hide();
2242
+ return false;
2243
+ };
2244
+
2245
+ Embed.prototype.getEmbedFromNode = function(node) {
2246
+ this.node = $(node);
2247
+ this.node_name = this.node.attr("name");
2248
+ this.node.addClass("spinner");
2249
+ return $.getJSON("" + this.current_editor.oembed_url + ($(this.node).text())).success((function(_this) {
2250
+ return function(data) {
2251
+ var iframe_src, replaced_node, tmpl, url;
2252
+ _this.node = $("[name=" + _this.node_name + "]");
2253
+ iframe_src = $(data.html).prop("src");
2254
+ tmpl = $(_this.embedTemplate());
2255
+ tmpl.attr("name", _this.node.attr("name"));
2256
+ $(_this.node).replaceWith(tmpl);
2257
+ replaced_node = $(".graf--iframe[name=" + (_this.node.attr("name")) + "]");
2258
+ replaced_node.find("iframe").attr("src", iframe_src);
2259
+ url = data.url || data.author_url;
2260
+ utils.log("URL IS " + url);
2261
+ replaced_node.find(".markup--anchor").attr("href", url).text(url);
2262
+ return _this.hide();
2263
+ };
2264
+ })(this)).error((function(_this) {
2265
+ return function(res) {
2266
+ return _this.node.removeClass("spinner");
2267
+ };
2268
+ })(this));
2269
+ };
2270
+
2271
+ return Embed;
2272
+
2273
+ })(Dante.View.TooltipWidget);
2274
+
2275
+ }).call(this);
2276
+ (function() {
2277
+ var utils,
2278
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2279
+ __hasProp = {}.hasOwnProperty,
2280
+ __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; };
2281
+
2282
+ utils = Dante.utils;
2283
+
2284
+ Dante.View.TooltipWidget.EmbedExtract = (function(_super) {
2285
+ __extends(EmbedExtract, _super);
2286
+
2287
+ function EmbedExtract() {
2288
+ this.getExtract = __bind(this.getExtract, this);
2289
+ this.getExtractFromNode = __bind(this.getExtractFromNode, this);
2290
+ return EmbedExtract.__super__.constructor.apply(this, arguments);
2291
+ }
2292
+
2293
+ EmbedExtract.prototype.initialize = function(opts) {
2294
+ if (opts == null) {
2295
+ opts = {};
2296
+ }
2297
+ this.icon = opts.icon || "icon-embed";
2298
+ this.title = opts.title || "Add an embed";
2299
+ this.action = opts.action || "embed-extract";
2300
+ return this.current_editor = opts.current_editor;
2301
+ };
2302
+
2303
+ EmbedExtract.prototype.handleClick = function(ev) {
2304
+ return this.displayExtractPlaceHolder(ev);
2305
+ };
2306
+
2307
+ EmbedExtract.prototype.handleEnterKey = function(ev, $node) {
2308
+ if ($node.hasClass("is-extractable")) {
2309
+ return this.getExtractFromNode($node);
2310
+ }
2311
+ };
2312
+
2313
+ EmbedExtract.prototype.extractTemplate = function() {
2314
+ 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>";
2315
+ };
2316
+
2317
+ EmbedExtract.prototype.displayExtractPlaceHolder = function() {
2318
+ var ph;
2319
+ ph = this.current_editor.extract_placeholder;
2320
+ this.node = this.current_editor.getNode();
2321
+ $(this.node).html(ph).addClass("is-extractable");
2322
+ this.current_editor.setRangeAt(this.node);
2323
+ this.hide();
2324
+ return false;
2325
+ };
2326
+
2327
+ EmbedExtract.prototype.getExtractFromNode = function(node) {
2328
+ this.node = $(node);
2329
+ this.node_name = this.node.attr("name");
2330
+ this.node.addClass("spinner");
2331
+ return $.getJSON("" + this.current_editor.extract_url + ($(this.node).text())).success((function(_this) {
2332
+ return function(data) {
2333
+ var iframe_src, image_node, replaced_node, tmpl;
2334
+ _this.node = $("[name=" + _this.node_name + "]");
2335
+ iframe_src = $(data.html).prop("src");
2336
+ tmpl = $(_this.extractTemplate());
2337
+ tmpl.attr("name", _this.node.attr("name"));
2338
+ $(_this.node).replaceWith(tmpl);
2339
+ replaced_node = $(".graf--mixtapeEmbed[name=" + (_this.node.attr("name")) + "]");
2340
+ replaced_node.find("strong").text(data.title);
2341
+ replaced_node.find("em").text(data.description);
2342
+ replaced_node.append(data.provider_url);
2343
+ replaced_node.find(".markup--anchor").attr("href", data.url);
2344
+ if (!_.isEmpty(data.images)) {
2345
+ image_node = replaced_node.find(".mixtapeImage");
2346
+ image_node.css("background-image", "url(" + data.images[0].url + ")");
2347
+ image_node.removeClass("mixtapeImage--empty u-ignoreBlock");
2348
+ }
2349
+ return _this.hide();
2350
+ };
2351
+ })(this)).error((function(_this) {
2352
+ return function(data) {
2353
+ return _this.node.removeClass("spinner");
2354
+ };
2355
+ })(this));
2356
+ };
2357
+
2358
+ EmbedExtract.prototype.getExtract = function(url) {
2359
+ return $.getJSON("" + this.current_editor.extract_url + url).done(function(data) {
2360
+ return utils.log(data);
2361
+ });
2362
+ };
2363
+
2364
+ return EmbedExtract;
2365
+
2366
+ })(Dante.View.TooltipWidget);
2367
+
2368
+ }).call(this);
2369
+ (function() {
2370
+ var utils,
2371
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2372
+ __hasProp = {}.hasOwnProperty,
2373
+ __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; };
2374
+
2375
+ utils = Dante.utils;
2376
+
2377
+ Dante.Editor.Tooltip = (function(_super) {
2378
+ __extends(Tooltip, _super);
2379
+
2380
+ function Tooltip() {
2381
+ this.hide = __bind(this.hide, this);
2382
+ this.toggleOptions = __bind(this.toggleOptions, this);
2383
+ this.render = __bind(this.render, this);
2384
+ this.initialize = __bind(this.initialize, this);
2385
+ return Tooltip.__super__.constructor.apply(this, arguments);
2386
+ }
2387
+
2388
+ Tooltip.prototype.el = ".inlineTooltip";
2389
+
2390
+ Tooltip.prototype.events = {
2391
+ "click .inlineTooltip-button.control": "toggleOptions",
2392
+ "click .inlineTooltip-menu button": "handleClick"
2393
+ };
2394
+
2395
+ Tooltip.prototype.initialize = function(opts) {
2396
+ if (opts == null) {
2397
+ opts = {};
2398
+ }
2399
+ this.current_editor = opts.editor;
2400
+ return this.widgets = opts.widgets;
2401
+ };
2402
+
2403
+ Tooltip.prototype.template = function() {
2404
+ var menu;
2405
+ menu = "";
2406
+ _.each(this.widgets, function(b) {
2407
+ var data_action_value;
2408
+ data_action_value = b.action_value ? "data-action-value='" + b.action_value + "'" : "";
2409
+ 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>";
2410
+ });
2411
+ 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>";
2412
+ };
2413
+
2414
+ Tooltip.prototype.findWidgetByAction = function(name) {
2415
+ return _.find(this.widgets, function(e) {
2416
+ return e.action === name;
2417
+ });
2418
+ };
2419
+
2420
+ Tooltip.prototype.render = function() {
2421
+ $(this.el).html(this.template());
2422
+ $(this.el).addClass("is-active");
2423
+ return this;
2424
+ };
2425
+
2426
+ Tooltip.prototype.toggleOptions = function() {
2427
+ utils.log("Toggle Options!!");
2428
+ $(this.el).toggleClass("is-scaled");
2429
+ return false;
2430
+ };
2431
+
2432
+ Tooltip.prototype.move = function(coords) {
2433
+ var control_spacing, control_width, coord_left, coord_top, pull_size, tooltip;
2434
+ tooltip = $(this.el);
2435
+ control_width = tooltip.find(".control").css("width");
2436
+ control_spacing = tooltip.find(".inlineTooltip-menu").css("padding-left");
2437
+ pull_size = parseInt(control_width.replace(/px/, "")) + parseInt(control_spacing.replace(/px/, ""));
2438
+ coord_left = coords.left - pull_size;
2439
+ coord_top = coords.top;
2440
+ return $(this.el).offset({
2441
+ top: coord_top,
2442
+ left: coord_left
2443
+ });
2444
+ };
2445
+
2446
+ Tooltip.prototype.handleClick = function(ev) {
2447
+ var detected_widget, name, sub_name;
2448
+ name = $(ev.currentTarget).data('action');
2449
+ utils.log(name);
2450
+
2451
+ /*
2452
+ switch name
2453
+ when "inline-menu-image"
2454
+ @placeholder = "<p>PLACEHOLDER</p>"
2455
+ @imageSelect(ev)
2456
+ when "inline-menu-embed"
2457
+ @displayEmbedPlaceHolder()
2458
+ when "inline-menu-embed-extract"
2459
+ @displayExtractPlaceHolder()
2460
+ when "inline-menu-hr"
2461
+ @splitSection()
2462
+ */
2463
+ sub_name = name.replace("inline-menu-", "");
2464
+ if (detected_widget = this.findWidgetByAction(sub_name)) {
2465
+ detected_widget.handleClick(ev);
2466
+ }
2467
+ return false;
2468
+ };
2469
+
2470
+ Tooltip.prototype.cleanOperationClasses = function(node) {
2471
+ return node.removeClass("is-embedable is-extractable");
2472
+ };
2473
+
2474
+ Tooltip.prototype.hide = function() {
2475
+ return $(this.el).removeClass("is-active is-scaled");
2476
+ };
2477
+
2478
+ return Tooltip;
2479
+
2480
+ })(Dante.View);
2481
+
2482
+ }).call(this);
2483
+ (function() {
2484
+ var utils,
2485
+ __hasProp = {}.hasOwnProperty,
2486
+ __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; };
2487
+
2488
+ utils = Dante.utils;
2489
+
2490
+ Dante.Editor.PopOver = (function(_super) {
2491
+ __extends(PopOver, _super);
2492
+
2493
+ function PopOver() {
2494
+ return PopOver.__super__.constructor.apply(this, arguments);
2495
+ }
2496
+
2497
+ PopOver.prototype.el = "body";
2498
+
2499
+ PopOver.prototype.events = {
2500
+ "mouseover .popover": "cancelHide",
2501
+ "mouseout .popover": "hide"
2502
+ };
2503
+
2504
+ PopOver.prototype.initialize = function(opts) {
2505
+ if (opts == null) {
2506
+ opts = {};
2507
+ }
2508
+ utils.log("initialized popover");
2509
+ this.editor = opts.editor;
2510
+ this.hideTimeout;
2511
+ return this.settings = {
2512
+ timeout: 300
2513
+ };
2514
+ };
2515
+
2516
+ PopOver.prototype.template = function() {
2517
+ 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>";
2518
+ };
2519
+
2520
+ PopOver.prototype.positionAt = function(ev) {
2521
+ var left_value, popover_width, target, target_height, target_offset, target_positions, target_width, top_value;
2522
+ target = $(ev.currentTarget);
2523
+ target_positions = this.resolveTargetPosition(target);
2524
+ target_offset = target.offset();
2525
+ target_width = target.outerWidth();
2526
+ target_height = target.outerHeight();
2527
+ popover_width = $(this.el).find(".popover").outerWidth();
2528
+ top_value = target_positions.top + target_height;
2529
+ left_value = target_offset.left + (target_width / 2) - (popover_width / 2);
2530
+ $(this.el).find(".popover").css("top", top_value).css("left", left_value).show();
2531
+ return this.handleDirection(target);
2532
+ };
2533
+
2534
+ PopOver.prototype.displayAt = function(ev) {
2535
+ var target;
2536
+ this.cancelHide();
2537
+ target = $(ev.currentTarget);
2538
+ $(this.el).find(".popover-inner a").text(target.attr('href')).attr('href', target.attr("href"));
2539
+ this.positionAt(ev);
2540
+ $(this.el).find(".popover--tooltip").css("pointer-events", "auto");
2541
+ return $(this.el).show();
2542
+ };
2543
+
2544
+ PopOver.prototype.cancelHide = function() {
2545
+ utils.log("Cancel Hide");
2546
+ return clearTimeout(this.hideTimeout);
2547
+ };
2548
+
2549
+ PopOver.prototype.hide = function(ev) {
2550
+ this.cancelHide();
2551
+ return this.hideTimeout = setTimeout((function(_this) {
2552
+ return function() {
2553
+ return $(_this.el).find(".popover").hide();
2554
+ };
2555
+ })(this), this.settings.timeout);
2556
+ };
2557
+
2558
+ PopOver.prototype.resolveTargetPosition = function(target) {
2559
+ if (target.parents(".graf--mixtapeEmbed").exists()) {
2560
+ return target.parents(".graf--mixtapeEmbed").position();
2561
+ } else {
2562
+ return target.position();
2563
+ }
2564
+ };
2565
+
2566
+ PopOver.prototype.handleDirection = function(target) {
2567
+ if (target.parents(".graf--mixtapeEmbed").exists()) {
2568
+ return $(this.el).find(".popover").removeClass("popover--bottom").addClass("popover--top");
2569
+ } else {
2570
+ return $(this.el).find(".popover").removeClass("popover--top").addClass("popover--bottom");
2571
+ }
2572
+ };
2573
+
2574
+ PopOver.prototype.render = function() {
2575
+ return $(this.template()).insertAfter(this.editor.$el);
2576
+ };
2577
+
2578
+ return PopOver;
2579
+
2580
+ })(Dante.View);
2581
+
2582
+ }).call(this);
2583
+ (function() {
2584
+ var utils,
2585
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2586
+ __hasProp = {}.hasOwnProperty,
2587
+ __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; };
2588
+
2589
+ utils = Dante.utils;
2590
+
2591
+ Dante.Editor.Menu = (function(_super) {
2592
+ __extends(Menu, _super);
2593
+
2594
+ function Menu() {
2595
+ this.createlink = __bind(this.createlink, this);
2596
+ this.handleInputEnter = __bind(this.handleInputEnter, this);
2597
+ this.render = __bind(this.render, this);
2598
+ this.template = __bind(this.template, this);
2599
+ this.initialize = __bind(this.initialize, this);
2600
+ return Menu.__super__.constructor.apply(this, arguments);
2601
+ }
2602
+
2603
+ Menu.prototype.el = "#dante-menu";
2604
+
2605
+ Menu.prototype.events = {
2606
+ "mousedown li": "handleClick",
2607
+ "click .dante-menu-linkinput .dante-menu-button": "closeInput",
2608
+ "keypress input": "handleInputEnter"
2609
+ };
2610
+
2611
+ Menu.prototype.initialize = function(opts) {
2612
+ if (opts == null) {
2613
+ opts = {};
2614
+ }
2615
+ this.config = opts.buttons || this.default_config();
2616
+ this.current_editor = opts.editor;
2617
+ this.commandsReg = {
2618
+ block: /^(?:p|h[1-6]|blockquote|pre)$/,
2619
+ inline: /^(?:bold|italic|underline|insertorderedlist|insertunorderedlist|indent|outdent)$/,
2620
+ source: /^(?:insertimage|createlink|unlink)$/,
2621
+ insert: /^(?:inserthorizontalrule|insert)$/,
2622
+ wrap: /^(?:code)$/
2623
+ };
2624
+ this.lineBreakReg = /^(?:blockquote|pre|div|p)$/i;
2625
+ this.effectNodeReg = /(?:[pubia]|h[1-6]|blockquote|[uo]l|li)/i;
2626
+ return this.strReg = {
2627
+ whiteSpace: /(^\s+)|(\s+$)/g,
2628
+ mailTo: /^(?!mailto:|.+\/|.+#|.+\?)(.*@.*\..+)$/,
2629
+ http: /^(?!\w+?:\/\/|mailto:|\/|\.\/|\?|#)(.*)$/
2630
+ };
2631
+ };
2632
+
2633
+ Menu.prototype.default_config = function() {
2634
+ return {
2635
+
2636
+ /*
2637
+ buttons: [
2638
+ 'blockquote', 'h2', 'h3', 'p', 'code', 'insertorderedlist', 'insertunorderedlist', 'inserthorizontalrule',
2639
+ 'indent', 'outdent', 'bold', 'italic', 'underline', 'createlink'
2640
+ ]
2641
+ */
2642
+ buttons: ['bold', 'italic', 'h2', 'h3', 'h4', 'blockquote', 'createlink']
2643
+ };
2644
+ };
2645
+
2646
+ Menu.prototype.template = function() {
2647
+ var html;
2648
+ html = "<div class='dante-menu-linkinput'><input class='dante-menu-input' placeholder='http://'><div class='dante-menu-button'>x</div></div>";
2649
+ html += "<ul class='dante-menu-buttons'>";
2650
+ _.each(this.config.buttons, function(item) {
2651
+ return html += "<li class='dante-menu-button'><i class=\"dante-icon icon-" + item + "\" data-action=\"" + item + "\"></i></li>";
2652
+ });
2653
+ html += "</ul>";
2654
+ return html;
2655
+ };
2656
+
2657
+ Menu.prototype.render = function() {
2658
+ $(this.el).html(this.template());
2659
+ return this.show();
2660
+ };
2661
+
2662
+ Menu.prototype.handleClick = function(ev) {
2663
+ var action, element, input;
2664
+ element = $(ev.currentTarget).find('.dante-icon');
2665
+ action = element.data("action");
2666
+ input = $(this.el).find("input.dante-menu-input");
2667
+ utils.log("menu " + action + " item clicked!");
2668
+ this.savedSel = utils.saveSelection();
2669
+ if (/(?:createlink)/.test(action)) {
2670
+ if ($(ev.currentTarget).hasClass("active")) {
2671
+ this.removeLink();
2672
+ } else {
2673
+ $(this.el).addClass("dante-menu--linkmode");
2674
+ input.focus();
2675
+ }
2676
+ } else {
2677
+ this.menuApply(action);
2678
+ }
2679
+ return false;
2680
+ };
2681
+
2682
+ Menu.prototype.closeInput = function(e) {
2683
+ $(this.el).removeClass("dante-menu--linkmode");
2684
+ return false;
2685
+ };
2686
+
2687
+ Menu.prototype.handleInputEnter = function(e) {
2688
+ if (e.which === 13) {
2689
+ utils.restoreSelection(this.savedSel);
2690
+ return this.createlink($(e.target));
2691
+ }
2692
+ };
2693
+
2694
+ Menu.prototype.removeLink = function() {
2695
+ var elem;
2696
+ this.menuApply("unlink");
2697
+ elem = this.current_editor.getNode();
2698
+ return this.current_editor.cleanContents($(elem));
2699
+ };
2700
+
2701
+ Menu.prototype.createlink = function(input) {
2702
+ var action, inputValue;
2703
+ $(this.el).removeClass("dante-menu--linkmode");
2704
+ if (input.val()) {
2705
+ inputValue = input.val().replace(this.strReg.whiteSpace, "").replace(this.strReg.mailTo, "mailto:$1").replace(this.strReg.http, "http://$1");
2706
+ return this.menuApply("createlink", inputValue);
2707
+ }
2708
+ action = "unlink";
2709
+ return this.menuApply(action);
2710
+ };
2711
+
2712
+ Menu.prototype.menuApply = function(action, value) {
2713
+ if (this.commandsReg.block.test(action)) {
2714
+ utils.log("block here");
2715
+ this.commandBlock(action);
2716
+ } else if (this.commandsReg.inline.test(action) || this.commandsReg.source.test(action)) {
2717
+ utils.log("overall here");
2718
+ this.commandOverall(action, value);
2719
+ } else if (this.commandsReg.insert.test(action)) {
2720
+ utils.log("insert here");
2721
+ this.commandInsert(action);
2722
+ } else if (this.commandsReg.wrap.test(action)) {
2723
+ utils.log("wrap here");
2724
+ this.commandWrap(action);
2725
+ } else {
2726
+ utils.log("can't find command function for action: " + action);
2727
+ }
2728
+ return false;
2729
+ };
2730
+
2731
+ Menu.prototype.setupInsertedElement = function(element) {
2732
+ var n;
2733
+ n = this.current_editor.addClassesToElement(element);
2734
+ this.current_editor.setElementName(n);
2735
+ return this.current_editor.markAsSelected(n);
2736
+ };
2737
+
2738
+ Menu.prototype.cleanContents = function() {
2739
+ return this.current_editor.cleanContents();
2740
+ };
2741
+
2742
+ Menu.prototype.commandOverall = function(cmd, val) {
2743
+ var message, n;
2744
+ message = " to exec 「" + cmd + "」 command" + (val ? " with value: " + val : "");
2745
+ if (document.execCommand(cmd, false, val)) {
2746
+ utils.log("success" + message);
2747
+ n = this.current_editor.getNode();
2748
+ this.current_editor.setupLinks($(n).find("a"));
2749
+ this.displayHighlights();
2750
+ if ($(n).parent().hasClass("section-inner")) {
2751
+ n = this.current_editor.addClassesToElement(n);
2752
+ this.current_editor.setElementName(n);
2753
+ }
2754
+ this.current_editor.handleTextSelection(n);
2755
+ } else {
2756
+ utils.log("fail" + message, true);
2757
+ }
2758
+ };
2759
+
2760
+ Menu.prototype.commandInsert = function(name) {
2761
+ var node;
2762
+ node = this.current_editor.current_node;
2763
+ if (!node) {
2764
+ return;
2765
+ }
2766
+ this.current_editor.current_range.selectNode(node);
2767
+ this.current_editor.current_range.collapse(false);
2768
+ return this.commandOverall(node, name);
2769
+ };
2770
+
2771
+ Menu.prototype.commandBlock = function(name) {
2772
+ var list, node;
2773
+ node = this.current_editor.current_node;
2774
+ list = this.effectNode(this.current_editor.getNode(node), true);
2775
+ if (list.indexOf(name) !== -1) {
2776
+ name = "p";
2777
+ }
2778
+ return this.commandOverall("formatblock", name);
2779
+ };
2780
+
2781
+ Menu.prototype.commandWrap = function(tag) {
2782
+ var node, val;
2783
+ node = this.current_editor.current_node;
2784
+ val = "<" + tag + ">" + selection + "</" + tag + ">";
2785
+ return this.commandOverall("insertHTML", val);
2786
+ };
2787
+
2788
+ Menu.prototype.effectNode = function(el, returnAsNodeName) {
2789
+ var nodes;
2790
+ nodes = [];
2791
+ el = el || this.current_editor.$el[0];
2792
+ while (el !== this.current_editor.$el[0]) {
2793
+ if (el.nodeName.match(this.effectNodeReg)) {
2794
+ nodes.push((returnAsNodeName ? el.nodeName.toLowerCase() : el));
2795
+ }
2796
+ el = el.parentNode;
2797
+ }
2798
+ return nodes;
2799
+ };
2800
+
2801
+ Menu.prototype.displayHighlights = function() {
2802
+ var nodes;
2803
+ $(this.el).find(".active").removeClass("active");
2804
+ nodes = this.effectNode(utils.getNode());
2805
+ utils.log(nodes);
2806
+ return _.each(nodes, (function(_this) {
2807
+ return function(node) {
2808
+ var tag;
2809
+ tag = node.nodeName.toLowerCase();
2810
+ switch (tag) {
2811
+ case "a":
2812
+ $(_this.el).find('input').val($(node).attr("href"));
2813
+ tag = "createlink";
2814
+ break;
2815
+ case "i":
2816
+ tag = "italic";
2817
+ break;
2818
+ case "u":
2819
+ tag = "underline";
2820
+ break;
2821
+ case "b":
2822
+ tag = "bold";
2823
+ break;
2824
+ case "code":
2825
+ tag = "code";
2826
+ break;
2827
+ case "ul":
2828
+ tag = "insertunorderedlist";
2829
+ break;
2830
+ case "ol":
2831
+ tag = "insertorderedlist";
2832
+ break;
2833
+ case "li":
2834
+ tag = "indent";
2835
+ utils.log("nothing to select");
2836
+ }
2837
+ if (tag.match(/(?:h[1-6])/i)) {
2838
+ $(_this.el).find(".icon-bold, .icon-italic, .icon-blockquote").parent("li").remove();
2839
+ } else if (tag === "indent") {
2840
+ $(_this.el).find(".icon-h2, .icon-h3, .icon-h4, .icon-blockquote").parent("li").remove();
2841
+ }
2842
+ return _this.highlight(tag);
2843
+ };
2844
+ })(this));
2845
+ };
2846
+
2847
+ Menu.prototype.highlight = function(tag) {
2848
+ return $(".icon-" + tag).parent("li").addClass("active");
2849
+ };
2850
+
2851
+ Menu.prototype.show = function() {
2852
+ $(this.el).addClass("dante-menu--active");
2853
+ this.closeInput();
2854
+ return this.displayHighlights();
2855
+ };
2856
+
2857
+ Menu.prototype.hide = function() {
2858
+ return $(this.el).removeClass("dante-menu--active");
2859
+ };
2860
+
2861
+ return Menu;
2862
+
2863
+ })(Dante.View);
2864
+
2865
+ }).call(this);
2866
+ //Editor components
2867
+
2868
+
2869
+
2870
+
2871
+
2872
+
2873
+
2874
+
2875
+
2876
+
2877
+
2878
+ ;