spontaneous 0.2.0.beta5 → 0.2.0.beta6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +39 -0
  4. data/Gemfile +2 -0
  5. data/Readme.markdown +4 -4
  6. data/application/css/core.css.scss +144 -43
  7. data/application/css/definitions.css.scss +50 -16
  8. data/application/css/dialogue.css.scss +5 -2
  9. data/application/css/editing.css.scss +7 -7
  10. data/application/css/font.css.scss +1 -1
  11. data/application/css/meta.css.scss +6 -6
  12. data/application/css/popover.css.scss +6 -6
  13. data/application/css/top.css.scss +8 -1
  14. data/application/js/add_alias_dialogue.js +137 -36
  15. data/application/js/add_home_dialogue.js +10 -10
  16. data/application/js/ajax.js +26 -26
  17. data/application/js/authentication.js +2 -2
  18. data/application/js/box.js +21 -10
  19. data/application/js/box_container.js +13 -7
  20. data/application/js/compatibility.js +19 -17
  21. data/application/js/conflicted_field_dialogue.js +5 -5
  22. data/application/js/content.js +22 -16
  23. data/application/js/content_area.js +62 -33
  24. data/application/js/dialogue.js +16 -16
  25. data/application/js/dom.js +9 -10
  26. data/application/js/edit_panel.js +25 -20
  27. data/application/js/editing.js +21 -8
  28. data/application/js/entry.js +1 -1
  29. data/application/js/extensions.js +11 -11
  30. data/application/js/field/boolean.js +6 -6
  31. data/application/js/field/date.js +1 -1
  32. data/application/js/field/file.js +17 -17
  33. data/application/js/field/image.js +27 -27
  34. data/application/js/field/markdown.js +72 -71
  35. data/application/js/field/select.js +9 -9
  36. data/application/js/field/string.js +3 -3
  37. data/application/js/field/webvideo.js +2 -2
  38. data/application/js/field_preview.js +3 -0
  39. data/application/js/init.js +3 -2
  40. data/application/js/jquery-selection-position.js +13 -13
  41. data/application/js/location.js +17 -12
  42. data/application/js/login.js +2 -2
  43. data/application/js/meta_view/user_admin.js +101 -101
  44. data/application/js/metadata.js +1 -1
  45. data/application/js/page.js +2 -2
  46. data/application/js/page_browser.js +13 -13
  47. data/application/js/page_entry.js +1 -1
  48. data/application/js/panel/root_menu.js +10 -10
  49. data/application/js/popover.js +6 -5
  50. data/application/js/popover_view.js +5 -5
  51. data/application/js/preview.js +10 -4
  52. data/application/js/progress.js +6 -6
  53. data/application/js/properties.js +35 -6
  54. data/application/js/publish.js +43 -43
  55. data/application/js/require.js +14 -14
  56. data/application/js/services.js +3 -3
  57. data/application/js/sharded_upload.js +9 -8
  58. data/application/js/side_bar.js +5 -5
  59. data/application/js/state.js +2 -2
  60. data/application/js/status_bar.js +6 -6
  61. data/application/js/top_bar.js +97 -65
  62. data/application/js/types.js +9 -6
  63. data/application/js/upload.js +4 -4
  64. data/application/js/upload_manager.js +21 -21
  65. data/application/js/user.js +1 -1
  66. data/application/js/vendor/jquery.velocity.min.js +7 -0
  67. data/application/js/views.js +32 -8
  68. data/application/js/views/box_view.js +51 -31
  69. data/application/js/views/page_piece_view.js +17 -15
  70. data/application/js/views/page_view.js +54 -43
  71. data/application/js/views/piece_view.js +44 -37
  72. data/application/static/font/fontawesome-webfont-4f0022f25672c7f501c339cbf98d9117.ttf +0 -0
  73. data/application/views/index.erb +1 -0
  74. data/db/migrations/20130114120000_create_revision_tables.rb +2 -1
  75. data/db/migrations/20130813111009_increase_path_length.rb +11 -2
  76. data/db/migrations/20140506171823_add_index_to_target_id.rb +11 -0
  77. data/db/migrations/20140514090204_add_content_hash.rb +59 -0
  78. data/db/migrations/20140519150253_add_content_hash_timestamp.rb +20 -0
  79. data/lib/spontaneous.rb +0 -1
  80. data/lib/spontaneous/asset/environment.rb +77 -15
  81. data/lib/spontaneous/box.rb +21 -0
  82. data/lib/spontaneous/capistrano/deploy.rb +1 -1
  83. data/lib/spontaneous/capistrano/sync.rb +8 -7
  84. data/lib/spontaneous/change.rb +4 -2
  85. data/lib/spontaneous/cli/fields.rb +7 -3
  86. data/lib/spontaneous/cli/generate.rb +2 -0
  87. data/lib/spontaneous/cli/init.rb +24 -93
  88. data/lib/spontaneous/cli/init/db.rb +94 -0
  89. data/lib/spontaneous/cli/init/mysql.rb +17 -0
  90. data/lib/spontaneous/cli/init/postgresql.rb +33 -0
  91. data/lib/spontaneous/cli/init/sqlite.rb +14 -0
  92. data/lib/spontaneous/cli/site.rb +45 -20
  93. data/lib/spontaneous/collections/box_set.rb +3 -0
  94. data/lib/spontaneous/collections/entry_set.rb +43 -4
  95. data/lib/spontaneous/collections/field_set.rb +14 -2
  96. data/lib/spontaneous/data_mapper.rb +40 -7
  97. data/lib/spontaneous/data_mapper/content_model.rb +1 -1
  98. data/lib/spontaneous/data_mapper/content_model/associations.rb +63 -12
  99. data/lib/spontaneous/data_mapper/content_model/timestamps.rb +9 -14
  100. data/lib/spontaneous/data_mapper/content_table.rb +4 -2
  101. data/lib/spontaneous/data_mapper/dataset.rb +31 -2
  102. data/lib/spontaneous/data_mapper/scope.rb +37 -20
  103. data/lib/spontaneous/errors.rb +6 -0
  104. data/lib/spontaneous/facet.rb +20 -10
  105. data/lib/spontaneous/field/base.rb +8 -1
  106. data/lib/spontaneous/field/file.rb +28 -3
  107. data/lib/spontaneous/field/image.rb +2 -0
  108. data/lib/spontaneous/field/update.rb +6 -0
  109. data/lib/spontaneous/field/webvideo/vimeo.rb +6 -1
  110. data/lib/spontaneous/field/webvideo/vine.rb +1 -1
  111. data/lib/spontaneous/field/webvideo/youtube.rb +1 -1
  112. data/lib/spontaneous/generators/site.rb +6 -4
  113. data/lib/spontaneous/generators/site/.gitignore +1 -0
  114. data/lib/spontaneous/generators/site/Gemfile.tt +3 -3
  115. data/lib/spontaneous/generators/site/config/{indexes.rb.tt → initializers/indexes.rb.tt} +0 -0
  116. data/lib/spontaneous/generators/site/config/initializers/publishing.rb.tt +78 -0
  117. data/lib/spontaneous/generators/site/{config/database.yml.tt → db/mysql2.yml.tt} +7 -6
  118. data/lib/spontaneous/generators/site/db/postgres.yml.tt +25 -0
  119. data/lib/spontaneous/generators/site/db/sqlite3.yml.tt +18 -0
  120. data/lib/spontaneous/generators/site/public/humans.txt.tt +14 -0
  121. data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +51 -0
  122. data/lib/spontaneous/loader.rb +1 -1
  123. data/lib/spontaneous/logger.rb +1 -1
  124. data/lib/spontaneous/media/image/optimizer.rb +1 -1
  125. data/lib/spontaneous/media/image/processor.rb +11 -2
  126. data/lib/spontaneous/media/image/renderable.rb +2 -0
  127. data/lib/spontaneous/model.rb +3 -0
  128. data/lib/spontaneous/model/box/allowed_types.rb +17 -4
  129. data/lib/spontaneous/model/core.rb +36 -3
  130. data/lib/spontaneous/model/core/aliases.rb +5 -2
  131. data/lib/spontaneous/model/core/boxes.rb +6 -0
  132. data/lib/spontaneous/model/core/cascading_change.rb +38 -0
  133. data/lib/spontaneous/model/core/content_hash.rb +171 -0
  134. data/lib/spontaneous/model/core/entries.rb +0 -19
  135. data/lib/spontaneous/model/core/fields.rb +11 -0
  136. data/lib/spontaneous/model/core/modifications.rb +22 -21
  137. data/lib/spontaneous/model/core/render.rb +3 -0
  138. data/lib/spontaneous/model/core/serialisation.rb +18 -17
  139. data/lib/spontaneous/model/page.rb +35 -8
  140. data/lib/spontaneous/model/page/page_tree.rb +20 -8
  141. data/lib/spontaneous/model/page/paths.rb +79 -50
  142. data/lib/spontaneous/model/page/singleton.rb +71 -0
  143. data/lib/spontaneous/model/page/site_map.rb +2 -1
  144. data/lib/spontaneous/model/page/site_timestamps.rb +2 -2
  145. data/lib/spontaneous/model/piece.rb +10 -0
  146. data/lib/spontaneous/output/context.rb +13 -6
  147. data/lib/spontaneous/output/format.rb +30 -5
  148. data/lib/spontaneous/output/helpers/script_helper.rb +8 -0
  149. data/lib/spontaneous/output/helpers/stylesheet_helper.rb +7 -0
  150. data/lib/spontaneous/output/renderable.rb +16 -0
  151. data/lib/spontaneous/output/store.rb +1 -1
  152. data/lib/spontaneous/output/template/renderer.rb +2 -2
  153. data/lib/spontaneous/page_piece.rb +25 -1
  154. data/lib/spontaneous/prototypes/box_prototype.rb +13 -0
  155. data/lib/spontaneous/prototypes/field_prototype.rb +7 -4
  156. data/lib/spontaneous/publishing.rb +10 -5
  157. data/lib/spontaneous/publishing/immediate.rb +32 -349
  158. data/lib/spontaneous/publishing/pipeline.rb +43 -0
  159. data/lib/spontaneous/publishing/progress.rb +186 -0
  160. data/lib/spontaneous/publishing/publish.rb +107 -0
  161. data/lib/spontaneous/publishing/rerender.rb +17 -0
  162. data/lib/spontaneous/publishing/revision.rb +53 -18
  163. data/lib/spontaneous/publishing/simultaneous.rb +1 -1
  164. data/lib/spontaneous/publishing/steps.rb +154 -0
  165. data/lib/spontaneous/publishing/steps/activate_revision.rb +45 -0
  166. data/lib/spontaneous/publishing/steps/archive_old_revisions.rb +22 -0
  167. data/lib/spontaneous/publishing/steps/base_step.rb +49 -0
  168. data/lib/spontaneous/publishing/steps/copy_static_files.rb +74 -0
  169. data/lib/spontaneous/publishing/steps/create_revision_directory.rb +24 -0
  170. data/lib/spontaneous/publishing/steps/generate_rackup_file.rb +51 -0
  171. data/lib/spontaneous/publishing/steps/generate_search_indexes.rb +24 -0
  172. data/lib/spontaneous/publishing/steps/render_revision.rb +69 -0
  173. data/lib/spontaneous/publishing/steps/write_revision_file.rb +43 -0
  174. data/lib/spontaneous/rack/back.rb +3 -1
  175. data/lib/spontaneous/rack/back/alias.rb +9 -8
  176. data/lib/spontaneous/rack/front.rb +1 -1
  177. data/lib/spontaneous/rack/middleware.rb +7 -4
  178. data/lib/spontaneous/rack/middleware/transaction.rb +14 -0
  179. data/lib/spontaneous/rack/page_controller.rb +23 -8
  180. data/lib/spontaneous/revision.rb +5 -10
  181. data/lib/spontaneous/schema.rb +5 -0
  182. data/lib/spontaneous/server.rb +3 -1
  183. data/lib/spontaneous/site.rb +17 -10
  184. data/lib/spontaneous/site/publishing.rb +25 -3
  185. data/lib/spontaneous/site/state.rb +7 -3
  186. data/lib/spontaneous/tasks/database.rake +5 -10
  187. data/lib/spontaneous/utils/database/mysql_dumper.rb +5 -1
  188. data/lib/spontaneous/version.rb +1 -1
  189. data/spontaneous.gemspec +4 -3
  190. data/test/fixtures/example_application/config/initializers/initializer1.rb +1 -0
  191. data/test/fixtures/example_application/config/initializers/initializer2.rb +1 -0
  192. data/test/fixtures/example_application/config/initializers/publishing.rb +13 -0
  193. data/test/fixtures/search/config/{indexes.rb → initializers/indexes.rb} +0 -0
  194. data/test/fixtures/serialisation/root_hash.yaml.erb +10 -4
  195. data/test/functional/test_application.rb +10 -0
  196. data/test/functional/test_back.rb +23 -5
  197. data/test/functional/test_cli.rb +98 -34
  198. data/test/functional/test_front.rb +7 -3
  199. data/test/test_helper.rb +35 -28
  200. data/test/unit/test_alias.rb +20 -3
  201. data/test/unit/test_assets.rb +58 -30
  202. data/test/unit/test_changesets.rb +20 -12
  203. data/test/unit/test_content_hash.rb +496 -0
  204. data/test/unit/test_context.rb +28 -1
  205. data/test/unit/test_controllers.rb +96 -61
  206. data/test/unit/test_crypt.rb +1 -8
  207. data/test/unit/test_datamapper.rb +95 -19
  208. data/test/unit/test_features.rb +1 -4
  209. data/test/unit/test_fields.rb +61 -12
  210. data/test/unit/test_generators.rb +39 -2
  211. data/test/unit/test_images.rb +3 -1
  212. data/test/unit/test_modifications.rb +224 -219
  213. data/test/unit/test_output_store.rb +10 -0
  214. data/test/unit/{test_formats.rb → test_outputs.rb} +75 -6
  215. data/test/unit/test_page.rb +61 -15
  216. data/test/unit/test_plugins.rb +2 -42
  217. data/test/unit/test_publishing_pipeline.rb +1050 -0
  218. data/test/unit/test_render.rb +30 -0
  219. data/test/unit/test_revisions.rb +110 -2
  220. data/test/unit/test_schema.rb +4 -0
  221. data/test/unit/test_search.rb +1 -1
  222. data/test/unit/test_serialisation.rb +6 -1
  223. data/test/unit/test_singletons.rb +159 -0
  224. data/test/unit/test_site.rb +71 -44
  225. metadata +140 -86
  226. data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
  227. data/test/unit/test_publishing.rb +0 -330
@@ -8,7 +8,7 @@ Spontaneous.EditPanel = (function($, S) {
8
8
  this.parent_view = parent_view;
9
9
  },
10
10
  buttons: function() {
11
- var save_label = "Save (" + ((window.navigator.platform.indexOf("Mac") === 0) ? "Cmd" : "Ctrl") + "+s)", btns = {};
11
+ var save_label = 'Save (' + ((window.navigator.platform.indexOf('Mac') === 0) ? 'Cmd' : 'Ctrl') + '+s)', btns = {};
12
12
  btns[save_label] = this.save.bind(this);
13
13
  return btns;
14
14
  },
@@ -41,7 +41,7 @@ Spontaneous.EditPanel = (function($, S) {
41
41
  field_data.append(v.name, v.value);
42
42
  size += (v.name.length + v.value.length);
43
43
  });
44
- $('> *', this.form).animate({'opacity': 0.3}, 400);
44
+ $('> *', this.form).velocity({'opacity': 0.3}, 400);
45
45
  if (values.length > 0) {
46
46
  Spontaneous.UploadManager.form(this, field_data, size);
47
47
  } else {
@@ -78,13 +78,14 @@ Spontaneous.EditPanel = (function($, S) {
78
78
 
79
79
  conflicts_resolved: function(conflict_list) {
80
80
  // console.log('conflicts resolved', conflict_list)
81
- var ff = this.parent_view.field_list(), conflicts = {};
81
+ var ff = this.parent_view.field_list(), conflicts = {}, conflict, field;
82
82
  for (var i =0, ii = conflict_list.length; i < ii; i++) {
83
- var conflict = conflict_list[i];
83
+ conflict = conflict_list[i];
84
84
  conflicts[conflict.field.schema_id()] = conflict;
85
85
  }
86
- for (var i = 0, ii = ff.length; i < ii; i++) {
87
- var field = ff[i], conflict = conflicts[field.schema_id()];
86
+ for (i = 0, ii = ff.length; i < ii; i++) {
87
+ field = ff[i];
88
+ conflict = conflicts[field.schema_id()];
88
89
  if (conflict) {
89
90
  // console.log(">>> conflicts_resolved", field, conflict.version)
90
91
  field.set_edited_value(conflict.value);
@@ -129,7 +130,7 @@ Spontaneous.EditPanel = (function($, S) {
129
130
  if (class_name) { toolbar.addClass(class_name); }
130
131
  return toolbar;
131
132
  };
132
- var editing = dom.form(['.editing-panel', this.parent_view.depth_class()], {'enctype':'multipart/form-data', 'accept-charset':'UTF-8', 'method':'post'})
133
+ var editing = dom.form(['.editing-panel', this.parent_view.depth_class()], {'enctype':'multipart/form-data', 'accept-charset':'UTF-8', 'method':'post'});
133
134
  var toolbar = get_toolbar();
134
135
  var outer = dom.div('.editing-fields');
135
136
  var text_field_wrap = dom.div('.field-group.text');
@@ -137,10 +138,11 @@ Spontaneous.EditPanel = (function($, S) {
137
138
  var text_fields = this.parent_view.text_fields();
138
139
  var submit = dom.input({'type':'submit'});
139
140
  var __dialogue = this;
140
- var fieldViews = [];
141
+ var fieldViews = [], field, view;
141
142
  editing.append(toolbar);
142
143
  for (var i = 0, ii = text_fields.length; i < ii; i++) {
143
- var field = text_fields[i], view = this.field_edit(field);
144
+ field = text_fields[i];
145
+ view = this.field_edit(field);
144
146
  fieldViews.push(view);
145
147
  text_field_wrap.append(view);
146
148
  }
@@ -148,10 +150,13 @@ Spontaneous.EditPanel = (function($, S) {
148
150
  if (text_fields.length > 0) {
149
151
  outer.append(text_field_wrap);
150
152
  }
151
- var image_fields = this.parent_view.image_fields();
153
+ var image_fields = this.parent_view.image_fields()
154
+ , click = function() { __dialogue.field_focus(this); }
155
+ ;
152
156
 
153
- for (var i = 0, ii = image_fields.length; i < ii; i++) {
154
- var field = image_fields[i], view = this.field_edit(field).click(function() { __dialogue.field_focus(this); });
157
+ for (i = 0, ii = image_fields.length; i < ii; i++) {
158
+ field = image_fields[i];
159
+ view = this.field_edit(field).click(click);
155
160
  fieldViews.push(view);
156
161
  image_field_wrap.append(view);
157
162
  }
@@ -191,7 +196,7 @@ Spontaneous.EditPanel = (function($, S) {
191
196
  tab_to_next: function(input, upwards) {
192
197
  var active_field = $(input).data('field')
193
198
  , text_fields = this.parent_view.text_fields(), position = 0, next_position, next_field
194
- , direction = upwards ? -1 : 1;
199
+ , direction = upwards ? -1 : 1;
195
200
  for (var i = 0, ii = text_fields.length; i < ii; i++) {
196
201
  if (text_fields[i] === active_field) {
197
202
  position = i;
@@ -207,15 +212,15 @@ Spontaneous.EditPanel = (function($, S) {
207
212
  var fields = this.parent_view.field_list();
208
213
  $.each(fields, function(n, f) {
209
214
  f.on_show();
210
- })
211
- if (!focus_field || !(focus_field['focus']) || !focus_field.accepts_focus) { focus_field = null; }
212
- var focus_field = focus_field || this.parent_view.text_fields()[0];
215
+ });
216
+ if (!focus_field || !(focus_field.focus) || !focus_field.accepts_focus) { focus_field = null; }
217
+ focus_field = focus_field || this.parent_view.text_fields()[0];
213
218
  if (focus_field) {
214
219
  focus_field.focus();
215
220
  }
216
221
  },
217
222
  field_focus: function(input) {
218
- var active_field = $(input).data('field')
223
+ var active_field = $(input).data('field');
219
224
  if (active_field === this.active_field) { return; }
220
225
  if (active_field) {
221
226
  this.active_field = active_field;
@@ -223,7 +228,7 @@ Spontaneous.EditPanel = (function($, S) {
223
228
  }
224
229
  },
225
230
  field_blur: function(input) {
226
- var active_field = $(input).data('field')
231
+ var active_field = $(input).data('field');
227
232
  if (active_field) {
228
233
  active_field.on_blur();
229
234
  }
@@ -244,12 +249,12 @@ Spontaneous.EditPanel = (function($, S) {
244
249
  field.editor = this;
245
250
  var d = dom.div('.field');
246
251
  // console.log("field_edit", field.type)
247
- d.addClass(field.type.type.toLowerCase().split(".").splice(1).join("-"));
252
+ d.addClass(field.type.type.toLowerCase().split('.').splice(1).join('-'));
248
253
  // d.append($(dom.label, {'class':'name', 'for':field.css_id()}).html(field.label()));
249
254
  var label = dom.label('.name', {'for':field.css_id()}).html(field.label());
250
255
  if (field.type.comment) {
251
256
  var comment = dom.span('.comment').text('('+field.type.comment+')');
252
- label.append(comment)
257
+ label.append(comment);
253
258
  }
254
259
  d.append(label);
255
260
  var toolbar = field.toolbar();
@@ -17,20 +17,27 @@ Spontaneous.Editing = (function($, S) {
17
17
  },
18
18
  goto_page: function(page) {
19
19
  if (!page) { return; }
20
- this.container.show().fadeOut(0)
21
- S.Ajax.get(["/page", page.id].join("/"), this.page_loaded.bind(this));
20
+ this.container.show().velocity('fadeOut', 0);
21
+ S.Ajax.get(['/page', page.id].join('/'), this.page_loaded.bind(this));
22
22
  this.set('location', page);
23
23
  },
24
24
  page_loaded: function(page_data) {
25
- var page = this.get('page');
25
+ var self = this
26
+ , page = self.get('page')
27
+ , view = self.get('view')
28
+ , panel = self.container;
26
29
  if (page) { page.unload(); }
30
+ if (view) { view.unload(); }
27
31
  page = new Page(page_data);
28
- page.watch('path', this.path_updated.bind(this));
32
+ page.watch('path', self.path_updated.bind(self));
29
33
  view = new S.Views.PageView(page);
30
- this.container.empty();
31
- this.container.append(view.panel());
32
- this.set('page', page);
33
- this.container.fadeIn(300);
34
+ panel.animate({opacity: 0}, 0, function() {
35
+ panel.empty().show();
36
+ panel.append(view.panel());
37
+ self.set('page', page);
38
+ self.set('view', view);
39
+ panel.velocity({opacity: 1}, 200);
40
+ });
34
41
  },
35
42
  path_updated: function(path) {
36
43
  this.set('path', path);
@@ -48,6 +55,12 @@ Spontaneous.Editing = (function($, S) {
48
55
  },
49
56
  show: function() {
50
57
  this.container.show();
58
+ },
59
+ showLoading: function() {
60
+ this.container.velocity({'opacity': 0}, 100);
61
+ },
62
+ hideLoading: function() {
63
+ // let the page_loaded function deal with actually showing the new page
51
64
  }
52
65
  });
53
66
  return Editing;
@@ -7,7 +7,7 @@ Spontaneous.Entry = (function($, S) {
7
7
  initialize: function(content, container) {
8
8
  this.container = container;
9
9
  this.callSuper(content);
10
- },
10
+ }
11
11
  });
12
12
  return Entry;
13
13
  })(jQuery, Spontaneous);
@@ -2,7 +2,7 @@ if (!window.console) {
2
2
  window.console = {
3
3
  log: function() {},
4
4
  warn: function() {},
5
- error: function() {},
5
+ error: function() {}
6
6
  };
7
7
  } else {
8
8
  // var debug = Spontaneous.debug;
@@ -29,7 +29,7 @@ function $A(iterable) {
29
29
  var length = iterable.length || 0, results = new Array(length);
30
30
  while (length--) results[length] = iterable[length];
31
31
  return results;
32
- };
32
+ }
33
33
 
34
34
  (function($) {
35
35
 
@@ -40,7 +40,7 @@ function $A(iterable) {
40
40
 
41
41
  var function_id = 0;
42
42
 
43
- if (!(typeof Function.prototype.bind === 'function')) {
43
+ if (typeof Function.prototype.bind !== 'function') {
44
44
  Function.prototype.bind = function() {
45
45
  var __method = this, args = $A(arguments), object = args.shift();
46
46
  return function() {
@@ -48,11 +48,11 @@ function $A(iterable) {
48
48
  };
49
49
  };
50
50
  }
51
- if (!(typeof Function.prototype.delay === 'function')) {
51
+ if (typeof Function.prototype.delay !== 'function') {
52
52
  Function.prototype.delay = function(delay) {
53
53
  var __function__ = this;
54
54
  return function() {
55
- window.setTimeout(__function__, delay)
55
+ window.setTimeout(__function__, delay);
56
56
  };
57
57
  };
58
58
  }
@@ -71,9 +71,9 @@ function $A(iterable) {
71
71
 
72
72
  $.extend(Number.prototype, {
73
73
  to_filesize: function() {
74
- var thou = 1000, units = [" B", ' kB', ' MB', ' GB'],
75
- power = Math.floor(Math.log(this) / Math.log(thou))
76
- return Math.round(this / (Math.pow(thou, power))) + units[power]
74
+ var thou = 1000, units = [' B', ' kB', ' MB', ' GB'],
75
+ power = Math.floor(Math.log(this) / Math.log(thou));
76
+ return Math.round(this / (Math.pow(thou, power))) + units[power];
77
77
  }
78
78
  });
79
79
 
@@ -81,13 +81,13 @@ function $A(iterable) {
81
81
 
82
82
  $.fn.appear = function(callback) {
83
83
  var $this = this, siblings = $this.siblings(), fade_in = function() {
84
- $this.animate({'opacity':1}, {
84
+ $this.velocity({'opacity':1}, {
85
85
  duration: opacity_change_duration,
86
86
  complete: callback
87
87
  });
88
88
  };
89
89
 
90
- if (siblings.length == 0) {
90
+ if (siblings.length === 0) {
91
91
  // skip height animation and just fade the element in
92
92
  // otherwise there's this weird gap where nothing seems to be
93
93
  // happening. this only happens when the item being 'appeared' is
@@ -106,7 +106,7 @@ function $A(iterable) {
106
106
 
107
107
  $.fn.disappear = function(callback) {
108
108
  var $this = this;
109
- this.animate({'opacity':0}, {
109
+ this.velocity({'opacity':0}, {
110
110
  duration: opacity_change_duration,
111
111
  complete: function() {
112
112
  $this.animate({'height':'hide'}, {
@@ -3,21 +3,21 @@ Spontaneous.Field.Boolean = (function($, S) {
3
3
  var BooleanField = new JS.Class(Spontaneous.Field.String, {
4
4
  edit: function() {
5
5
  var self = this
6
- , w = dom.div(dom.id(self.css_id()))
6
+ , w = dom.div(dom.id(self.css_id()))
7
7
  , input = self.input() // ensure we have created the radio inputs $on & $off
8
8
  , labels = self.type.labels
9
- , label = function(label, radio) { return dom.label().text(label).prepend(radio); }
10
- ;
9
+ , label = function(label, radio) { return dom.label().text(label).prepend(radio); };
10
+
11
11
  w.append(label(labels['true'], self.$on), label(labels['false'], self.$off));
12
12
  return w;
13
13
  },
14
14
  generate_input: function() {
15
15
  var self = this
16
- , checked = (this.get('unprocessed_value') == 'true')
16
+ , checked = (this.get('unprocessed_value') == 'true')
17
17
  , click = function() { self.editor.field_focus(self.input()); }
18
18
  , on = dom.radio({'name':this.form_name(), 'value': 'true', 'checked': checked})
19
- , off = dom.radio({'name':this.form_name(), 'value': 'false', 'checked': !checked})
20
- ;
19
+ , off = dom.radio({'name':this.form_name(), 'value': 'false', 'checked': !checked});
20
+
21
21
  self.$on = on;
22
22
  self.$off = off;
23
23
  return $(on).add(off).click(click);
@@ -4,7 +4,7 @@ Spontaneous.Field.Date = (function($, S) {
4
4
  var DateField = new JS.Class(Spontaneous.Field.String, {
5
5
  input: function() {
6
6
  var input = this.callSuper();
7
- input.datepicker({ "dateFormat": "DD, d MM yy" });
7
+ input.datepicker({ 'dateFormat': 'DD, d MM yy' });
8
8
  return input;
9
9
  },
10
10
  dateFormat: function() {
@@ -6,29 +6,29 @@ Spontaneous.Field.File = (function($, S) {
6
6
 
7
7
  currentValue: function() {
8
8
  var pending, v = this.get('value');
9
- if ((pending = v['__pending__'])) {
10
- return pending['value'];
9
+ if ((pending = v.__pending__)) {
10
+ return pending.value;
11
11
  }
12
12
  return v;
13
13
  },
14
14
 
15
15
  currentFilename: function() {
16
- return this.currentValue()['filename'];
16
+ return this.currentValue().filename;
17
17
  },
18
18
 
19
19
  currentFilesize: function() {
20
- return this.currentValue()['filesize'];
20
+ return this.currentValue().filesize;
21
21
  },
22
22
 
23
23
  currentEditValue: function() {
24
24
  var value, pending, ui, v = this.get('value');
25
- if ((pending = v['__pending__'])) {
26
- return pending['value'];
25
+ if ((pending = v.__pending__)) {
26
+ return pending.value;
27
27
  }
28
- value = v['original'];
29
- if ((ui = v['__ui__'])) {
30
- value['path'] = value['src'];
31
- value['src'] = ui['src'];
28
+ value = v.original;
29
+ if ((ui = v.__ui__)) {
30
+ value.path = value.src;
31
+ value.src = ui.src;
32
32
  }
33
33
  return value;
34
34
  },
@@ -36,7 +36,7 @@ Spontaneous.Field.File = (function($, S) {
36
36
  preview: function() {
37
37
  Spontaneous.UploadManager.register(this);
38
38
  var self = this
39
- , value = this.currentValue()
39
+ , value = this.currentValue()
40
40
  , filename = this.currentFilename();
41
41
  var wrap = dom.div('.file-field');
42
42
  var dropper = dom.div('.file-drop');
@@ -98,7 +98,7 @@ Spontaneous.Field.File = (function($, S) {
98
98
  wrap.append(dropper, filename_info, filesize_info);
99
99
 
100
100
  this.drop_target = dropper;
101
- this.value_wrap = wrap;
101
+ this.value_wrap = wrap;
102
102
 
103
103
  return wrap;
104
104
  },
@@ -133,7 +133,7 @@ Spontaneous.Field.File = (function($, S) {
133
133
  },
134
134
  disable_progress: function() {
135
135
  this.progress_bar().parent().hide();
136
- this.drop_target.add(this.value_wrap).removeClass('uploading')
136
+ this.drop_target.add(this.value_wrap).removeClass('uploading');
137
137
  },
138
138
  upload_progress: function(position, total) {
139
139
  if (!this.drop_target.hasClass('uploading')) {
@@ -148,12 +148,12 @@ Spontaneous.Field.File = (function($, S) {
148
148
 
149
149
  edit: function() {
150
150
  var self = this;
151
- var wrap = dom.div(".file-field", {'style':'position:relative;'});
151
+ var wrap = dom.div('.file-field', {'style':'position:relative;'});
152
152
  var value = this.value();
153
153
  var input = this.input();
154
154
  var filename_info = dom.div('.filename');
155
155
  var filesize_info = dom.div('.filesize');
156
- var choose_files = dom.a('.choose').text("Choose file...");
156
+ var choose_files = dom.a('.choose').text('Choose file...');
157
157
 
158
158
  var set_info = function(filename, filesize) {
159
159
  filename_info.text(filename);
@@ -168,7 +168,7 @@ Spontaneous.Field.File = (function($, S) {
168
168
  this.selected_files = files;
169
169
  this._edited_value = url;
170
170
  window.URL.revokeObjectURL(url);
171
- set_info(File.filename(file), file.fileSize)
171
+ set_info(File.filename(file), file.fileSize);
172
172
  }
173
173
  }.bind(this);
174
174
 
@@ -240,7 +240,7 @@ Spontaneous.Field.File = (function($, S) {
240
240
  return filename;
241
241
  },
242
242
 
243
- accept_mimetype: "*/*",
243
+ accept_mimetype: '*/*',
244
244
  generate_input: function() {
245
245
  return dom.input({'type':'file', 'name':this.form_name(), 'accept':this.accept_mimetype});
246
246
  },
@@ -1,6 +1,6 @@
1
1
  // console.log('Loading ImageField...')
2
2
  Spontaneous.Field.Image = (function($, S) {
3
- "use strict";
3
+ 'use strict';
4
4
  var dom = S.Dom;
5
5
  var ImageFieldConflictView = new JS.Class(S.Field.String.ConflictView, {
6
6
 
@@ -10,8 +10,8 @@ Spontaneous.Field.Image = (function($, S) {
10
10
  image_outer = dom.div('.image-field-conflict.changes.differences'),
11
11
  original = dom.div('.original.diff'),
12
12
  edited = dom.div('.final.diff');
13
- var local_label = dom.div('.diff').text("Server version");
14
- var server_label = dom.div('.diff').text("Your version");
13
+ var local_label = dom.div('.diff').text('Server version');
14
+ var server_label = dom.div('.diff').text('Your version');
15
15
  original.append(dom.img().attr('src', this.values.server_original)).click(function() {
16
16
  this.useValue(this.values.server_original);
17
17
  edited.add(original).removeClass('selected');
@@ -60,29 +60,29 @@ Spontaneous.Field.Image = (function($, S) {
60
60
 
61
61
  currentValue: function() {
62
62
  var pending, v = this.get('value');
63
- if ((pending = v['__pending__'])) {
64
- pending['path'] = pending['src'];
65
- return pending['value'];
63
+ if ((pending = v.__pending__)) {
64
+ pending.path = pending.src;
65
+ return pending.value;
66
66
  }
67
- return v['__ui__'] || v['original'] || {};
67
+ return v.__ui__ || v.original || {};
68
68
  },
69
69
 
70
70
  currentEditValue: function() {
71
71
  var value, pending, ui, v = this.get('value');
72
- if ((pending = v['__pending__'])) {
73
- return pending['value'];
72
+ if ((pending = v.__pending__)) {
73
+ return pending.value;
74
74
  }
75
- value = v['original'];
76
- if ((ui = v['__ui__'])) {
77
- value['path'] = value['src'];
78
- value['src'] = ui['src'];
75
+ value = v.original;
76
+ if ((ui = v.__ui__)) {
77
+ value.path = value.src;
78
+ value.src = ui.src;
79
79
  }
80
80
  return value;
81
81
  },
82
82
 
83
83
  currentFilename: function() {
84
84
  var v = this.get('value');
85
- return (v['__pending__'] || v['original'])['filename'];
85
+ return (v.__pending__ || v.original).filename;
86
86
  },
87
87
  /*
88
88
  * HACK: The async nature of image updates means that the version setting
@@ -99,9 +99,9 @@ Spontaneous.Field.Image = (function($, S) {
99
99
  * weird problems with simultaneous updates.
100
100
  */
101
101
  version: function() {
102
- var pending, value = this.get("value");
103
- if ((pending = value["__pending__"])) {
104
- return pending["version"];
102
+ var pending, value = this.get('value');
103
+ if ((pending = value.__pending__)) {
104
+ return pending.version;
105
105
  }
106
106
  return this.data.version;
107
107
  },
@@ -109,13 +109,13 @@ Spontaneous.Field.Image = (function($, S) {
109
109
  preview: function() {
110
110
  Spontaneous.UploadManager.register(this);
111
111
  var self = this
112
- , value = this.currentValue()
112
+ , value = this.currentValue()
113
113
  , src = value.src
114
- , img = null
115
- , dim = 45;
114
+ , img = null
115
+ , dim = 45;
116
116
  // , container = container.parent('li');
117
117
 
118
- if (src === "") {
118
+ if (src === '') {
119
119
  img = dom.img('.missing-image', {'src':''});
120
120
  } else {
121
121
  img = dom.img();
@@ -175,8 +175,8 @@ Spontaneous.Field.Image = (function($, S) {
175
175
  } else {
176
176
  // container.removeClass('landscape');
177
177
  }
178
- }.bind(this))
179
- image.attr('src', url)
178
+ }.bind(this));
179
+ image.attr('src', url);
180
180
  // see http://www.htmlfivewow.com/slide25
181
181
  window.URL.revokeObjectURL(url);
182
182
  }
@@ -237,11 +237,11 @@ Spontaneous.Field.Image = (function($, S) {
237
237
  },
238
238
  upload_complete: function(values) {
239
239
  this.mark_unmodified();
240
- this.callSuper(values)
240
+ this.callSuper(values);
241
241
  if (values) {
242
242
  var value = this.currentValue();
243
243
  if (this.image) {
244
- var img = new Image()
244
+ var img = new Image();
245
245
  img.onload = function() {
246
246
  this.image.attr('src', value.src);
247
247
  }.bind(this);
@@ -297,7 +297,7 @@ Spontaneous.Field.Image = (function($, S) {
297
297
  filename_info.text(filename);
298
298
  if (filesize) {
299
299
  filesize_info.text(parseFloat(filesize, 10).to_filesize());
300
- } else if (filesize === 0 || filesize === "0") {
300
+ } else if (filesize === 0 || filesize === '0') {
301
301
  filesize_info.text('');
302
302
  }
303
303
 
@@ -411,7 +411,7 @@ Spontaneous.Field.Image = (function($, S) {
411
411
  this.preview_img.attr('src', value);
412
412
  this.callSuper(value);
413
413
  },
414
- accept_mimetype: "image/*"
414
+ accept_mimetype: 'image/*'
415
415
  });
416
416
 
417
417
  ImageField.ConflictView = ImageFieldConflictView;