lalala 4.0.0.dev.416 → 4.1.0.dev.299

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/Gemfile +1 -3
  4. data/Haraway.md +14 -0
  5. data/app/assets/javascripts/lalala/base.js +8 -0
  6. data/app/assets/javascripts/lalala/initializers/chosen.module.js +3 -0
  7. data/app/assets/javascripts/lalala/initializers/haraway.module.js +8 -0
  8. data/app/assets/javascripts/lalala/lib/overlay.js +335 -0
  9. data/app/assets/javascripts/lalala/modules/collapsible_pages_tree.module.js +26 -33
  10. data/app/assets/javascripts/lalala/modules/editor.module.js +37 -23
  11. data/app/assets/javascripts/lalala/modules/file-uploader-metadata.module.js +248 -0
  12. data/app/assets/javascripts/lalala/modules/file-uploader.module.js +376 -0
  13. data/app/assets/javascripts/lalala/modules/init.module.js +1 -5
  14. data/app/assets/javascripts/lalala/modules/media_selector.module.js +250 -0
  15. data/app/assets/javascripts/lalala/modules/overlay.module.js +33 -0
  16. data/app/assets/stylesheets/lalala/_base.css.scss +5 -2
  17. data/app/assets/stylesheets/lalala/components/_buttons.css.scss +11 -3
  18. data/app/assets/stylesheets/lalala/components/_forms.css.scss +14 -64
  19. data/app/assets/stylesheets/lalala/lib/_overlay.css.scss +66 -0
  20. data/app/assets/stylesheets/lalala/modules/_dashboard.css.scss +10 -51
  21. data/app/assets/stylesheets/lalala/modules/_editor-cheatsheet.css.scss +1 -17
  22. data/app/assets/stylesheets/lalala/modules/_file-uploader-metadata.css.scss +118 -0
  23. data/app/assets/stylesheets/lalala/modules/_file-uploader.css.scss +289 -0
  24. data/app/assets/stylesheets/lalala/modules/_media-selector.css.scss +113 -0
  25. data/app/assets/stylesheets/lalala/modules/_title-bar.css.scss +0 -17
  26. data/app/controllers/lalala/public/errors_controller.rb +7 -0
  27. data/app/models/lalala/page.rb +0 -1
  28. data/app/views/lalala/markdown/cheatsheet.html.erb +0 -2
  29. data/config/routes.rb +12 -1
  30. data/lalala-assets.gemspec +3 -3
  31. data/lalala-development.gemspec +1 -1
  32. data/lalala-test.gemspec +1 -1
  33. data/lalala.gemspec +4 -5
  34. data/lib/formtastic/form_builder_ext.rb +10 -0
  35. data/lib/formtastic/inputs/haraway_input.rb +151 -0
  36. data/lib/generators/lalala/assets/templates/bower.json.erb +1 -1
  37. data/lib/generators/lalala/install/install_generator.rb +0 -23
  38. data/lib/lalala/admin/pages.rb +1 -26
  39. data/lib/lalala/engine.rb +0 -7
  40. data/lib/lalala/ext_action_dispatch.rb +0 -1
  41. data/lib/lalala/ext_active_record/i18n_translations_writer.rb +0 -1
  42. data/lib/lalala/ext_active_record.rb +0 -1
  43. data/lib/lalala/ext_i18n/input_helper.rb +0 -1
  44. data/lib/lalala/ext_i18n/negotiation_adapter.rb +0 -4
  45. data/lib/lalala/ext_i18n/test_negotiation_adapter.rb +0 -4
  46. data/lib/lalala/ext_rack/i18n_negotiator.rb +7 -9
  47. data/lib/lalala/markdown/handlers/asset.rb +24 -0
  48. data/lib/lalala/markdown/handlers/youtube.rb +9 -13
  49. data/lib/lalala/markdown/html_renderer.rb +2 -2
  50. data/lib/lalala/markdown.rb +2 -3
  51. data/lib/lalala/utils/install_template.rb +3 -9
  52. data/lib/lalala/version.rb +2 -2
  53. data/lib/lalala.rb +6 -7
  54. data/script/ci +33 -30
  55. data/test/dummy/app/admin/articles.rb +26 -12
  56. data/test/dummy/app/admin/dashboard.rb +5 -8
  57. data/test/dummy/app/admin/tags.rb +1 -3
  58. data/test/dummy/app/assets/stylesheets/_normalize.css +423 -0
  59. data/test/dummy/app/assets/stylesheets/application.css.scss +2 -0
  60. data/test/dummy/app/assets/stylesheets/base/_base.css.scss +4 -0
  61. data/test/dummy/app/controllers/pages_controller.rb +4 -0
  62. data/test/dummy/app/models/article.rb +10 -4
  63. data/test/dummy/app/pages/application_page.rb +7 -2
  64. data/test/dummy/app/pages/basic_page.rb +5 -6
  65. data/test/dummy/app/pages/home_page.rb +10 -10
  66. data/test/dummy/app/pages/media_page.rb +23 -0
  67. data/test/dummy/app/views/admin/_stats.html.erb +7 -14
  68. data/test/dummy/app/views/layouts/application.html.erb +6 -2
  69. data/test/dummy/app/views/pages/media.html.erb +3 -0
  70. data/test/dummy/config/initializers/haraway.rb +29 -0
  71. data/test/dummy/config/routes.rb +1 -0
  72. data/test/dummy/db/migrate/20130528092721_create_articles.rb +1 -0
  73. data/test/dummy/db/migrate/20130729125648_create_home_page.rb +4 -0
  74. data/test/dummy/db/migrate/20131122144302_enable_haraway.rb +16 -0
  75. data/test/dummy/db/migrate/20140228141749_create_media_page.rb +8 -0
  76. data/test/dummy/db/schema.rb +2 -4
  77. data/test/integration/aricles_test.rb +0 -1
  78. metadata +59 -81
  79. data/app/assets/javascripts/jquery-ui/sortable.js +0 -0
  80. data/app/assets/javascripts/lalala/lib/jquery-ui.js +0 -16617
  81. data/app/assets/javascripts/lalala/modules/grid.module.js +0 -284
  82. data/app/assets/javascripts/lalala/modules/input_group.module.js +0 -36
  83. data/app/assets/stylesheets/lalala/modules/_grid.css.scss +0 -197
  84. data/app/assets/stylesheets/lalala/modules/_index-as-sortable.css.scss +0 -89
  85. data/app/models/lalala/abstract_asset.rb +0 -24
  86. data/app/models/lalala/file_asset.rb +0 -3
  87. data/app/models/lalala/image_asset.rb +0 -3
  88. data/config/initializers/carrierwave.rb +0 -34
  89. data/lib/formtastic/inputs/grid_input.rb +0 -159
  90. data/lib/formtastic/inputs/single_file_input.rb +0 -44
  91. data/lib/generators/lalala/install/templates/application.html.erb +0 -64
  92. data/lib/generators/lalala/install/templates/helpers/application_helper.rb +0 -16
  93. data/lib/generators/lalala/install/templates/helpers/html_helper.rb +0 -60
  94. data/lib/generators/lalala/install/templates/helpers/open_graph_helper.rb.erb +0 -92
  95. data/lib/generators/lalala/install/templates/helpers/pages_helper.rb +0 -15
  96. data/lib/generators/lalala/install/templates/locales/en.yml +0 -6
  97. data/lib/generators/lalala/install/templates/uploaders/file_uploader.rb +0 -2
  98. data/lib/generators/lalala/install/templates/uploaders/image_uploader.rb +0 -11
  99. data/lib/lalala/ext_action_dispatch/multi_file_upload.rb +0 -55
  100. data/lib/lalala/ext_active_record/assets.rb +0 -25
  101. data/lib/lalala/markdown/handlers/soundcloud.rb +0 -36
  102. data/lib/lalala/markdown/handlers/vimeo.rb +0 -40
  103. data/lib/lalala/uploaders/file.rb +0 -50
  104. data/lib/lalala/uploaders/image.rb +0 -13
  105. data/lib/lalala/uploaders.rb +0 -6
  106. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  107. data/test/dummy/app/models/file_asset.rb +0 -2
  108. data/test/dummy/app/models/image_asset.rb +0 -2
  109. data/test/dummy/app/uploaders/file_uploader.rb +0 -2
  110. data/test/dummy/app/uploaders/image_uploader.rb +0 -11
  111. data/test/dummy/db/migrate/20140926152646_add_pre_and_postpend_test_columns_to_articles.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ef72aab01de9989951e7e4d303f16a2911c8c44f
4
- data.tar.gz: a7102ce474162384d712bd30c0598b8b02d3ec7e
3
+ metadata.gz: aff21ad204eeefac76dc2d8cc0228cf471e7a652
4
+ data.tar.gz: 7b71c86c78f8f818846c1a215377a6e33be9c033
5
5
  SHA512:
6
- metadata.gz: 5adb784c82733c4548008d64e71547556ed9e6c1a9b2498baceae6c4a9accbd33479e4397becfe86dcb18f4445cb1bf1b6a9f85f316840c0297a4f3e03317dc2
7
- data.tar.gz: a4ce47bd0aa3f5fb9448bb759197dd7f6e8c117471de10760c52664e8e3b758a1ee46641ab83d490e313288183643ba4bf1559e95ff64c15158d1635ca443091
6
+ metadata.gz: 2fd3c377829f45890a6e263e0138ca114ee6eaf58d902cbb1b5b3a3934ec119640a8c47d333e186b9997d7f36cb4bcaf002faf01168dfd259eb0ea3954e157e8
7
+ data.tar.gz: f8a5bd437f23d2de42367364659ba04b540d7da857acd17c9c44944d9d2f97e64eb6b618e680e2f852bca6c4f3b83bf674fb06c3142444516796e2dcce6a0c3e
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1.7
4
+ - 2.0.0
5
5
 
6
6
  env:
7
7
  global:
data/Gemfile CHANGED
@@ -1,10 +1,8 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- ruby "2.1.7"
3
+ ruby "2.0.0"
4
4
 
5
5
  gemspec name: 'lalala'
6
6
  gemspec name: 'lalala-development', groups: [:development]
7
7
  gemspec name: 'lalala-assets', groups: [:development, :assets]
8
8
  gemspec name: 'lalala-test', groups: [:test]
9
-
10
- gem "active_admin-sortable_tree"
data/Haraway.md ADDED
@@ -0,0 +1,14 @@
1
+ # Haraway
2
+
3
+ ## How to use
4
+
5
+ 1. Create initializer (config/initializers/haraway.rb)
6
+ 2. Add "haraway_metadata" column to the necessary tables (type = "text")
7
+ 3. In the model:
8
+ `has_many_assets :asset_association_name, :profile`
9
+ `attr_accessible :asset_association_name`
10
+
11
+
12
+ ## To do
13
+
14
+ - Include actual Haraway gem (not the local repo)
@@ -3,6 +3,14 @@
3
3
 
4
4
  //= require_tree ../browser
5
5
  //= require_tree ./modules
6
+ //= require_tree ./initializers
6
7
  //= require_self
7
8
 
9
+ var haraway = require("lalala/initializers/haraway");
10
+
11
+ $(function() {
12
+ haraway.init();
13
+ });
14
+
15
+ // TODO - refactor
8
16
  require('lalala/modules/init');
@@ -0,0 +1,3 @@
1
+ exports.init = function() {
2
+ $('select').not(".bypass-chosen").chosen();
3
+ };
@@ -0,0 +1,8 @@
1
+ var FileUploader = require("lalala/modules/file-uploader");
2
+
3
+
4
+ exports.init = function() {
5
+ $("x-files").each(function() {
6
+ new FileUploader(this);
7
+ });
8
+ };
@@ -0,0 +1,335 @@
1
+ /*
2
+
3
+ OVERLAY JS
4
+ v0.1.0
5
+
6
+ */
7
+
8
+ (function($) {
9
+
10
+ "use strict";
11
+
12
+ var __bind = function(fn, me) {
13
+ return function() { return fn.apply(me, arguments); };
14
+ };
15
+
16
+ var default_template_function = function() {
17
+ return [
18
+ '<div class="overlay-outer-wrapper">',
19
+ '<div class="overlay-inner-wrapper">',
20
+ '<div class="overlay-content">',
21
+ '<div class="overlay-header">',
22
+ '<a href="#" class="close"></a>',
23
+ '</div>',
24
+ '</div>',
25
+ '</div>',
26
+ '</div>'
27
+ ].join('');
28
+ };
29
+
30
+ var default_background_template_function = function() {
31
+ return [
32
+ ''
33
+ ].join('');
34
+ };
35
+
36
+
37
+ //
38
+ // Default settings
39
+ //
40
+ Overlay.prototype.settings = {
41
+ class_name: "mod-overlay",
42
+ background_class_name: "mod-overlay-background",
43
+ content_class_name: "overlay-content",
44
+
45
+ is_shown_class: "visible",
46
+
47
+ template_function: default_template_function,
48
+ background_template_function: default_background_template_function
49
+ };
50
+
51
+
52
+
53
+ //
54
+ // Constructor
55
+ // -> and main setup
56
+ //
57
+ function Overlay(el, settings) {
58
+ //
59
+ // instance variables:
60
+ // el, $el, bg, $bg,
61
+ // $content, state
62
+
63
+ this.bind_some_methods_to_self();
64
+ this.set_initial_state_object();
65
+ this.set_initial_settings_object(settings);
66
+ this.create_new_or_use_element(el);
67
+ this.bind_events();
68
+ }
69
+
70
+
71
+
72
+ //
73
+ // Create new or use element
74
+ //
75
+ // -> If an element is given, set that element as
76
+ // the main element and find the associated background element.
77
+ //
78
+ // If not, make new elements and append them to the body element.
79
+ //
80
+ // And also cache some other elements.
81
+ //
82
+ Overlay.prototype.create_new_or_use_element = function(element) {
83
+ var predefined = !!element;
84
+ var background;
85
+
86
+ // main element
87
+ if (!predefined) {
88
+ element = document.createElement("div");
89
+ element.className = this.settings.class_name;
90
+ element.innerHTML = this.settings.template_function();
91
+ }
92
+
93
+ this.el = element;
94
+ this.$el = $(this.el);
95
+
96
+ // background
97
+ if (!predefined) {
98
+ background = document.createElement("div");
99
+ background.className = this.settings.background_class_name;
100
+ background.innerHTML = this.settings.background_template_function();
101
+ } else {
102
+ background = this.$el.siblings("." + this.settings.background_class_name).get(0);
103
+ }
104
+
105
+ this.bg = background;
106
+ this.$bg = $(this.bg);
107
+
108
+ // add to dom if needed
109
+ if (!predefined) {
110
+ document.body.appendChild(element);
111
+ document.body.appendChild(background);
112
+ }
113
+
114
+ // cache other elements
115
+ this.cache_other_elements();
116
+ };
117
+
118
+
119
+ Overlay.prototype.cache_other_elements = function() {
120
+ this.$content = this.$el.find("." + this.settings.content_class_name);
121
+ };
122
+
123
+
124
+
125
+ //
126
+ // Show + callback
127
+ //
128
+ // -> Shows the main element and background by
129
+ // setting 'display: block', then adds the
130
+ // is_shown class to those elements and then
131
+ // calls the callback on transitionend (if supported).
132
+ //
133
+ // The reason for the setTimeout usage is that, for example.
134
+ // If you set the following at the same time,
135
+ // 'display: block' and 'opacity: 1' along with
136
+ // a transition for opacity. Then the transition won't work,
137
+ // for reasons unknown.
138
+ //
139
+ Overlay.prototype.show = function(content_key) {
140
+ var that = this;
141
+
142
+ // content key
143
+ content_key = content_key || "default";
144
+
145
+ // show
146
+ setTimeout(function() {
147
+ that.$el.add(that.$bg).css("display", "block");
148
+ }, 0);
149
+
150
+ // main
151
+ setTimeout(function() {
152
+ that.$el.add(that.$bg)
153
+ .addClass(that.settings.is_shown_class)
154
+ .addClass(content_key);
155
+ }, 25);
156
+
157
+ // state
158
+ this.state.is_shown = true;
159
+ this.state.content_key = content_key;
160
+
161
+ // callback
162
+ if (this.state.transition_key) {
163
+ this.$el.on(this.state.transition_key, this.show_callback);
164
+ } else {
165
+ this.show_callback();
166
+ }
167
+ };
168
+
169
+
170
+ Overlay.prototype.show_callback = function() {
171
+ this.$el.off(this.state.transition_key, this.show_callback);
172
+
173
+ $(window).trigger("overlay.open." + this.state.content_key);
174
+ };
175
+
176
+
177
+
178
+ //
179
+ // Hide + callback
180
+ //
181
+ Overlay.prototype.hide = function() {
182
+ this.$el.add(this.$bg)
183
+ .removeClass(this.settings.is_shown_class)
184
+ .removeClass(this.state.content_key);
185
+
186
+ // state
187
+ this.state.content_key = false;
188
+ this.state.is_shown = false;
189
+
190
+ // callback
191
+ if (this.state.transition_key) {
192
+ this.$el.on(this.state.transition_key, this.hide_callback);
193
+ } else {
194
+ this.hide_callback();
195
+ }
196
+ };
197
+
198
+
199
+ Overlay.prototype.hide_callback = function() {
200
+ this.$el.off(this.state.transition_key, this.hide_callback);
201
+
202
+ this.$el.add(this.$bg).css("display", "none");
203
+ this.clear_content();
204
+
205
+ $(window).trigger("overlay.hide");
206
+ };
207
+
208
+
209
+
210
+ //
211
+ // Content
212
+ //
213
+ Overlay.prototype.append_content = function(x) {
214
+ this.$content.append(x);
215
+ };
216
+
217
+
218
+ Overlay.prototype.clear_content = function() {
219
+ this.el.innerHTML = this.settings.template_function();
220
+ this.cache_other_elements();
221
+ };
222
+
223
+
224
+
225
+ //
226
+ // Destroy self
227
+ //
228
+ Overlay.prototype.destroy = function() {
229
+ this.unbind_events();
230
+ this.$el.remove();
231
+ this.el = null;
232
+ };
233
+
234
+
235
+
236
+ //
237
+ // State
238
+ //
239
+ Overlay.prototype.set_initial_state_object = function() {
240
+ var fake_el, transitions, transition_key;
241
+
242
+ // state object
243
+ this.state = {
244
+ is_shown: false
245
+ };
246
+
247
+ // find correct transtionend key
248
+ fake_el = document.createElement("fake");
249
+
250
+ transitions = {
251
+ "transition" : "transitionend",
252
+ "WebkitTransition" : "webkitTransitionEnd",
253
+ "MozTransition" : "transitionend",
254
+ "msTransition" : "MSTransitionEnd",
255
+ "OTransition" : "otransitionend"
256
+ };
257
+
258
+ for (var t in transitions) {
259
+ if (fake_el.style[t] !== undefined) {
260
+ transition_key = transitions[t];
261
+ break;
262
+ }
263
+ }
264
+
265
+ this.state.transition_key = transition_key;
266
+ };
267
+
268
+
269
+ Overlay.prototype.set_initial_settings_object = function(settings) {
270
+ this.settings = $.extend({}, this.settings, settings || {});
271
+ };
272
+
273
+
274
+
275
+ //
276
+ // Events
277
+ //
278
+ Overlay.prototype.bind_events = function() {
279
+ // every element with class .close closes the overlay
280
+ this.$el.on("click.overlay", ".close", this.close_click_handler);
281
+
282
+ // close overlay when ESC key is pressed
283
+ $(document).on("keydown.overlay", this.document_keydown_handler);
284
+ };
285
+
286
+
287
+ Overlay.prototype.unbind_events = function() {
288
+ this.$el.off("click.overlay", ".close", this.close_click_handler);
289
+ $(document).off("keydown.overlay", this.document_keydown_handler);
290
+ };
291
+
292
+
293
+ Overlay.prototype.close_click_handler = function(e) {
294
+ e.preventDefault();
295
+
296
+ this.hide();
297
+ };
298
+
299
+
300
+ Overlay.prototype.document_keydown_handler = function(e) {
301
+ if (e.which == 27 && this.state.is_shown) {
302
+ this.hide();
303
+ }
304
+ };
305
+
306
+
307
+
308
+ //
309
+ // Utilities
310
+ //
311
+ Overlay.prototype.bind_some_methods_to_self = function() {
312
+ var methods = [
313
+ "show_callback", "hide_callback",
314
+ "close_click_handler", "document_keydown_handler"
315
+ ];
316
+
317
+ for (var i=0, j=methods.length; i<j; ++i) {
318
+ this.bind_to_self(methods[i]);
319
+ }
320
+ };
321
+
322
+
323
+ Overlay.prototype.bind_to_self = function(method_name) {
324
+ this[method_name] = __bind(this[method_name], this);
325
+ };
326
+
327
+
328
+
329
+ //
330
+ // Export
331
+ //
332
+ window.Overlay = Overlay;
333
+
334
+
335
+ })(jQuery || Zepto);
@@ -71,58 +71,51 @@ CPT.prototype.addTriggers = function() {
71
71
  CPT.prototype.initStates = function() {
72
72
  var _this = this;
73
73
 
74
- // Close all
75
- this.$tree_parents.each(function() {
76
- var $tree_parent = $(this),
77
- $target = $tree_parent.data('collapsible_target'),
78
- $trigger = $tree_parent.find('.collapse');
79
-
80
- _this.update($target, $trigger, 'close', false);
81
- });
82
-
83
- // Open saved states
84
74
  $.each(this.states, function(idx, value) {
85
75
  var $tree_parent = $('#' + value),
86
76
  $target = $tree_parent.data('collapsible_target'),
87
77
  $trigger = $tree_parent.find('.collapse');
88
78
 
89
- _this.update($target, $trigger, 'open', false);
79
+ _this.close($target, $trigger);
90
80
  });
91
81
  };
92
82
 
93
83
 
94
84
  /**
95
- * Update target state
85
+ * Close target
96
86
  *
97
- * @param {jQuery object} $target The element to be closed
98
- * @param {jQuery object} $trigger The trigger element
99
- * @param {Boolean} save_state Default TRUE
87
+ * @param {jQuery object} $target The element to be closed
88
+ * @param {jQuery object} $trigger The trigger element
100
89
  */
101
- CPT.prototype.update = function($target, $trigger, state, save_state) {
90
+ CPT.prototype.close = function($target, $trigger) {
102
91
  if ( !$target ) {
103
- console.warn('Collapsible tree: Can not find tree target');
92
+ console.warn('Can not find tree target');
104
93
  return;
105
94
  }
106
95
 
107
- save_state = (typeof save_state == 'undefined') ? true : save_state;
96
+ $target.hide();
97
+ $trigger.addClass('closed');
108
98
 
109
- if ( state == 'close' ) {
110
- $target.hide();
111
- $trigger.addClass('closed');
99
+ this.saveState();
100
+ };
112
101
 
113
- } else if ( state == 'open') {
114
- $target.show();
115
- $trigger.removeClass('closed');
116
102
 
117
- } else {
118
- console.warn('Collapsible tree: Unknown state');
103
+ /**
104
+ * Open target
105
+ *
106
+ * @param {jQuery object} $target The element to be closed
107
+ * @param {jQuery object} $trigger The trigger element
108
+ */
109
+ CPT.prototype.open = function($target, $trigger) {
110
+ if ( !$target ) {
111
+ console.warn('Can not find tree target');
119
112
  return;
120
-
121
113
  }
122
114
 
123
- if ( save_state ) {
124
- this.saveState();
125
- }
115
+ $target.show();
116
+ $trigger.removeClass('closed');
117
+
118
+ this.saveState();
126
119
  };
127
120
 
128
121
 
@@ -136,10 +129,10 @@ CPT.prototype.toggleState = function(event) {
136
129
  $target = $trigger.data('tree_parent').data('collapsible_target');
137
130
 
138
131
  if ( $target.is(':visible') ) {
139
- this.update($target, $trigger, 'close');
132
+ this.close($target, $trigger);
140
133
 
141
134
  } else {
142
- this.update($target, $trigger, 'open');
135
+ this.open($target, $trigger);
143
136
 
144
137
  }
145
138
 
@@ -158,7 +151,7 @@ CPT.prototype.saveState = function() {
158
151
  var $tree_parent = $(this),
159
152
  $trigger = $tree_parent.find('.collapse');
160
153
 
161
- if ( !$trigger.hasClass('closed') ) {
154
+ if ( $trigger.hasClass('closed') ) {
162
155
  new_states.push($tree_parent.attr('id'));
163
156
  }
164
157
 
@@ -1,9 +1,15 @@
1
- var markdown_settings;
1
+ var Overlay = require("./overlay"),
2
+ MediaSelector = require("./media_selector"),
3
+
4
+ markdown_settings;
5
+
2
6
 
3
7
  exports.init = function(){
4
8
  $("textarea.markdown").each(setup);
5
9
  };
6
10
 
11
+
12
+
7
13
  function setup() {
8
14
  var $this = $(this);
9
15
  var settings = $.extend({}, markdown_settings);
@@ -15,35 +21,30 @@ function setup() {
15
21
  $markitup_wrapper.find('.fullscreen').click(open_fullscreen);
16
22
  $markitup_wrapper.find('.close-fullscreen').click(close_fullscreen);
17
23
  $markitup_wrapper.find('.markdown-cheatsheet').click(toggle_cheatsheet);
18
- $('body').on('click', '.markdown-cheatsheet-close', toggle_cheatsheet);
24
+ $markitup_wrapper.find('.add-image').click(add_image_click_handler);
19
25
  }
20
26
 
27
+
28
+
21
29
  //
22
- // Go fullscreen
30
+ // Fullscreen
23
31
  //
24
32
  function open_fullscreen(event) {
25
33
  var $markitup_wrapper = $(this).closest('.markItUp');
26
34
  $markitup_wrapper.find('.markItUpHeader .preview').trigger('mouseup');
27
35
  $markitup_wrapper.addClass('fullscreen');
28
-
29
- $('body').on('keyup.MARKDOWN_FULLSCREEN', function (event) {
30
- if (event.which === 27) {
31
- close_fullscreen(event);
32
- }
33
- });
34
36
  }
35
37
 
36
- //
37
- // Close fullscreen
38
- //
38
+
39
39
  function close_fullscreen(event) {
40
- var $markitup_wrapper = $('.close-fullscreen').closest('.markItUp');
40
+ var $markitup_wrapper = $(this).closest('.markItUp');
41
41
  $markitup_wrapper.removeClass('fullscreen');
42
- $('body').off('keyup.MARKDOWN_FULLSCREEN');
43
42
  }
44
43
 
44
+
45
+
45
46
  //
46
- // Toggle Markdown cheatsheet
47
+ // Cheatsheet
47
48
  //
48
49
  function toggle_cheatsheet(event) {
49
50
  var $markdown_cheatsheet = $('#markdown-cheatsheet');
@@ -63,9 +64,7 @@ function toggle_cheatsheet(event) {
63
64
  }
64
65
  }
65
66
 
66
- //
67
- // Load Markdown syntax cheatsheet
68
- //
67
+
69
68
  function load_cheatsheat(options) {
70
69
  $.get('/lalala/markdown/cheatsheet', function(data) {
71
70
  var $div = $('<div id="markdown-cheatsheet" />');
@@ -82,8 +81,26 @@ function load_cheatsheat(options) {
82
81
  });
83
82
  }
84
83
 
84
+
85
+
86
+ //
87
+ // Images
88
+ //
89
+ function add_image_click_handler(e) {
90
+ var ms, overlay;
91
+
92
+ ms = new MediaSelector();
93
+ ms.$markitup_container = $(e.currentTarget).closest(".markItUpContainer");
94
+
95
+ overlay = Overlay.get_instance();
96
+ overlay.append_content(ms.$el);
97
+ overlay.show("media-selector");
98
+ }
99
+
100
+
101
+
85
102
  //
86
- // Mark It Up settings
103
+ // Mark It Up settings
87
104
  //
88
105
  var base_path = window.location.pathname.replace(/[\/][^\/]+$/, "");
89
106
 
@@ -101,13 +118,10 @@ markdown_settings = {
101
118
  { separator: '---' },
102
119
  { name: 'Unordered list', openWith: '- ', className: 'unordered-list', multiline: true },
103
120
  { name: 'Ordered list', openWith: '1. ', closeWith: '\n2. \n3. ', className: 'ordered-list', multiline: true },
104
- /*
105
- | column header |\n| ------------- | ------------- |\n| | |
106
- */
107
121
  { name: 'Add table', openWith: '| ', closeWith: ' | column header |\n| ------------- | ------------- |\n| | |', placeHolder: 'Column header', className: 'add-table', multiline: true },
108
122
  { separator: '---' },
109
123
  { name: 'Link', key: 'L', openWith: '[[![Link text]!]', closeWith: ']([![Url:!:http://]!])', className: 'add-link' },
110
- //{ name: 'Image', openWith: '![[![Alternative text]!]]', closeWith: '([![Url:!:http://]!] "[![Image title]!]")', className: 'add-image' },
124
+ { name: 'Image', className: 'add-image' },
111
125
  { separator: '---' },
112
126
  { name: 'Preview', call: 'preview', className: "preview" },
113
127
  { name: 'Fullscreen', className: 'fullscreen' },