spontaneous 0.2.0.beta1 → 0.2.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/.locat +42 -0
- data/.travis/gemfiles/Gemfile.empty +7 -0
- data/.travis.yml +18 -0
- data/Gemfile +12 -8
- data/LICENSE +1 -1
- data/Rakefile +15 -157
- data/Readme.markdown +1 -1
- data/application/css/core.css.scss +22 -146
- data/application/css/definitions.css.scss +7 -3
- data/application/css/dialogue.css.scss +26 -1
- data/application/css/editing.css.scss +70 -28
- data/application/css/font.css.scss +1 -1
- data/application/css/popover.css.scss +2 -0
- data/application/css/top.css.scss +231 -0
- data/application/js/add_alias_dialogue.js +1 -1
- data/application/js/add_home_dialogue.js +1 -1
- data/application/js/ajax.js +61 -31
- data/application/js/box.js +4 -4
- data/application/js/conflicted_field_dialogue.js +1 -1
- data/application/js/content.js +5 -5
- data/application/js/dom.js +5 -0
- data/application/js/edit_panel.js +1 -0
- data/application/js/editing.js +1 -1
- data/application/js/extensions.js +8 -0
- data/application/js/field/boolean.js +31 -0
- data/application/js/field/file.js +32 -4
- data/application/js/field/image.js +24 -9
- data/application/js/field/markdown.js +87 -59
- data/application/js/field/select.js +1 -1
- data/application/js/field/webvideo.js +6 -1
- data/application/js/init.js +2 -2
- data/application/js/jquery-selection-position.js +130 -0
- data/application/js/location.js +4 -25
- data/application/js/meta_view/user_admin.js +2 -2
- data/application/js/metadata.js +2 -2
- data/application/js/page_browser.js +1 -1
- data/application/js/panel/root_menu.js +0 -1
- data/application/js/popover.js +27 -12
- data/application/js/popover_view.js +20 -4
- data/application/js/preview.js +31 -16
- data/application/js/progress.js +22 -21
- data/application/js/publish.js +18 -7
- data/application/js/sharded_upload.js +9 -6
- data/application/js/spontaneous.js +3 -1
- data/application/js/top_bar.js +264 -173
- data/application/js/upload.js +12 -5
- data/application/js/upload_manager.js +4 -3
- data/application/js/user.js +1 -2
- data/application/js/views/box_view.js +1 -1
- data/application/js/views/page_view.js +16 -5
- data/application/js/views/piece_view.js +5 -4
- data/application/static/font/fontawesome-webfont-1c66a4738b40ef0f6b1abca0ba9a796d.ttf +0 -0
- data/application/views/index.erb +6 -14
- data/application/views/login.erb +6 -25
- data/application/views/schema_modification_error.html.erb +3 -7
- data/db/migrations/20130114120000_create_revision_tables.rb +2 -2
- data/db/migrations/20130813111009_increase_path_length.rb +14 -0
- data/gem-public_cert.pem +20 -0
- data/lib/spontaneous/asset/app_compiler.rb +44 -0
- data/lib/spontaneous/asset/environment.rb +225 -0
- data/lib/spontaneous/asset.rb +2 -67
- data/lib/spontaneous/box.rb +0 -1
- data/lib/spontaneous/capistrano/deploy.rb +2 -2
- data/lib/spontaneous/capistrano/sync.rb +1 -1
- data/lib/spontaneous/cli/init.rb +36 -13
- data/lib/spontaneous/cli/server.rb +0 -1
- data/lib/spontaneous/cli/site.rb +2 -1
- data/lib/spontaneous/cli.rb +3 -1
- data/lib/spontaneous/collections/entry_set.rb +4 -12
- data/lib/spontaneous/collections/hash_with_fallback.rb +20 -0
- data/lib/spontaneous/collections/prototype_set.rb +6 -5
- data/lib/spontaneous/crypt.rb +2 -2
- data/lib/spontaneous/data_mapper/content_model/associations.rb +115 -63
- data/lib/spontaneous/data_mapper.rb +1 -1
- data/lib/spontaneous/errors.rb +6 -0
- data/lib/spontaneous/extensions/object_space.rb +6 -0
- data/lib/spontaneous/facet.rb +1 -0
- data/lib/spontaneous/field/base.rb +86 -13
- data/lib/spontaneous/field/boolean.rb +65 -0
- data/lib/spontaneous/field/file.rb +17 -6
- data/lib/spontaneous/field/html.rb +13 -0
- data/lib/spontaneous/field/image/size.rb +76 -0
- data/lib/spontaneous/field/image.rb +99 -414
- data/lib/spontaneous/field/tags.rb +36 -0
- data/lib/spontaneous/field/update.rb +1 -1
- data/lib/spontaneous/field/webvideo/fallback.rb +41 -0
- data/lib/spontaneous/field/webvideo/vimeo.rb +113 -0
- data/lib/spontaneous/field/webvideo/vine.rb +94 -0
- data/lib/spontaneous/field/webvideo/youtube.rb +133 -0
- data/lib/spontaneous/field/webvideo.rb +100 -250
- data/lib/spontaneous/field.rb +1 -1
- data/lib/spontaneous/generators/site/Gemfile.tt +5 -14
- data/lib/spontaneous/generators/site/assets/README.md +20 -0
- data/lib/spontaneous/generators/site/assets/css/site.scss +8 -0
- data/lib/spontaneous/generators/site/assets/js/site.js +6 -0
- data/lib/spontaneous/generators/site/config/deploy.rb.tt +9 -0
- data/lib/spontaneous/generators/site/config/user_levels.yml +14 -3
- data/lib/spontaneous/generators/site/public/README.md +12 -0
- data/lib/spontaneous/generators/site/templates/layouts/standard.html.cut.tt +2 -2
- data/lib/spontaneous/generators/site.rb +77 -35
- data/lib/spontaneous/layout.rb +6 -7
- data/lib/spontaneous/loader.rb +21 -13
- data/lib/spontaneous/media/file.rb +22 -9
- data/lib/spontaneous/media/image/attributes.rb +33 -0
- data/lib/spontaneous/media/image/format/gif.rb +4 -0
- data/lib/spontaneous/media/image/format/jpg.rb +17 -0
- data/lib/spontaneous/media/image/format/png.rb +4 -0
- data/lib/spontaneous/media/image/format/webp.rb +26 -0
- data/lib/spontaneous/media/image/format.rb +79 -0
- data/lib/spontaneous/media/image/optimizer.rb +69 -0
- data/lib/spontaneous/media/image/processor.rb +17 -0
- data/lib/spontaneous/media/image/renderable.rb +52 -0
- data/lib/spontaneous/media/image/skeptick.rb +70 -0
- data/lib/spontaneous/media/image.rb +50 -0
- data/lib/spontaneous/media/temp_file.rb +4 -0
- data/lib/spontaneous/media.rb +1 -0
- data/lib/spontaneous/model/core/aliases.rb +14 -8
- data/lib/spontaneous/model/core/boxes.rb +5 -2
- data/lib/spontaneous/model/core/entries.rb +4 -0
- data/lib/spontaneous/model/core/entry.rb +1 -0
- data/lib/spontaneous/model/core/fields.rb +5 -2
- data/lib/spontaneous/model/core/locks.rb +16 -0
- data/lib/spontaneous/model/core/media.rb +1 -15
- data/lib/spontaneous/model/core.rb +31 -1
- data/lib/spontaneous/model/page/controllers.rb +2 -2
- data/lib/spontaneous/model/page/formats.rb +1 -4
- data/lib/spontaneous/model/page/layouts.rb +6 -2
- data/lib/spontaneous/model/page/locks.rb +8 -2
- data/lib/spontaneous/model/page/page_tree.rb +2 -2
- data/lib/spontaneous/model/page/paths.rb +74 -9
- data/lib/spontaneous/model/page.rb +11 -3
- data/lib/spontaneous/model.rb +6 -6
- data/lib/spontaneous/output/context/render_cache.rb +23 -0
- data/lib/spontaneous/output/context.rb +56 -30
- data/lib/spontaneous/output/helpers/script_helper.rb +9 -53
- data/lib/spontaneous/output/helpers/stylesheet_helper.rb +8 -40
- data/lib/spontaneous/output/template/renderer.rb +17 -5
- data/lib/spontaneous/output.rb +0 -1
- data/lib/spontaneous/paths.rb +6 -2
- data/lib/spontaneous/permissions/access_key.rb +18 -0
- data/lib/spontaneous/permissions/user.rb +1 -1
- data/lib/spontaneous/permissions.rb +4 -1
- data/lib/spontaneous/plugins/application/state.rb +19 -12
- data/lib/spontaneous/prototypes/field_prototype.rb +14 -8
- data/lib/spontaneous/published_revision.rb +7 -0
- data/lib/spontaneous/publishing/immediate.rb +43 -34
- data/lib/spontaneous/publishing/revision.rb +9 -6
- data/lib/spontaneous/rack/asset_server.rb +20 -0
- data/lib/spontaneous/rack/back/alias.rb +46 -0
- data/lib/spontaneous/rack/back/application_assets.rb +28 -0
- data/lib/spontaneous/rack/back/base.rb +34 -0
- data/lib/spontaneous/rack/back/changes.rb +19 -0
- data/lib/spontaneous/rack/back/content.rb +54 -0
- data/lib/spontaneous/rack/back/events.rb +38 -0
- data/lib/spontaneous/rack/back/field.rb +37 -0
- data/lib/spontaneous/rack/back/file.rb +118 -0
- data/lib/spontaneous/rack/back/helpers.rb +71 -0
- data/lib/spontaneous/rack/back/index.rb +16 -0
- data/lib/spontaneous/rack/back/login.rb +47 -0
- data/lib/spontaneous/rack/back/map.rb +24 -0
- data/lib/spontaneous/rack/back/page.rb +46 -0
- data/lib/spontaneous/rack/back/preview.rb +43 -0
- data/lib/spontaneous/rack/back/schema.rb +30 -0
- data/lib/spontaneous/rack/back/site.rb +25 -0
- data/lib/spontaneous/rack/back/site_assets.rb +13 -0
- data/lib/spontaneous/rack/back/unsupported_browser.rb +7 -0
- data/lib/spontaneous/rack/{user_admin.rb → back/user_admin.rb} +2 -5
- data/lib/spontaneous/rack/back.rb +85 -764
- data/lib/spontaneous/rack/cacheable_file.rb +3 -3
- data/lib/spontaneous/rack/front.rb +16 -9
- data/lib/spontaneous/rack/middleware/authenticate.rb +65 -0
- data/lib/spontaneous/rack/middleware/csrf.rb +66 -0
- data/lib/spontaneous/rack/middleware/reloader.rb +52 -0
- data/lib/spontaneous/rack/middleware/scope.rb +60 -0
- data/lib/spontaneous/rack/middleware.rb +6 -0
- data/lib/spontaneous/rack/page_controller.rb +18 -5
- data/lib/spontaneous/rack/public.rb +17 -11
- data/lib/spontaneous/rack.rb +34 -24
- data/lib/spontaneous/revision.rb +29 -2
- data/lib/spontaneous/schema/uid.rb +4 -3
- data/lib/spontaneous/schema/uid_map.rb +5 -24
- data/lib/spontaneous/schema.rb +1 -0
- data/lib/spontaneous/search/database.rb +8 -0
- data/lib/spontaneous/search/field.rb +1 -1
- data/lib/spontaneous/search/index.rb +3 -5
- data/lib/spontaneous/server.rb +1 -1
- data/lib/spontaneous/simultaneous.rb +1 -1
- data/lib/spontaneous/site/features.rb +4 -5
- data/lib/spontaneous/site/helpers.rb +22 -5
- data/lib/spontaneous/site/instance.rb +2 -2
- data/lib/spontaneous/site/selectors.rb +22 -3
- data/lib/spontaneous/storage/cloud.rb +13 -9
- data/lib/spontaneous/storage/local.rb +11 -6
- data/lib/spontaneous/style.rb +40 -23
- data/lib/spontaneous/utils/database/mysql_dumper.rb +1 -1
- data/lib/spontaneous/utils/smush_it.rb +1 -1
- data/lib/spontaneous/version.rb +1 -1
- data/lib/spontaneous.rb +35 -33
- data/spontaneous.gemspec +53 -787
- data/test/experimental/test_crypt.rb +56 -56
- data/test/experimental/test_features.rb +16 -27
- data/test/fixtures/assets/public1/css/data.css.scss +3 -0
- data/test/fixtures/assets/public1/css/image1.css.scss +4 -0
- data/test/fixtures/assets/public1/css/import.css.scss +1 -0
- data/test/fixtures/assets/public1/css/urlhash.css.scss +3 -0
- data/test/fixtures/assets/public1/js/a.js +1 -1
- data/test/fixtures/assets/public1/js/all.js +4 -0
- data/test/fixtures/assets/public1/js/{m.coffee → m.js.coffee} +1 -0
- data/test/fixtures/assets/public1/x.js +1 -0
- data/test/fixtures/assets/public2/css/all.css +4 -0
- data/test/fixtures/assets/public2/css/missing.css.scss +3 -0
- data/test/fixtures/assets/public2/i/y.png +0 -0
- data/test/fixtures/assets/public2/js/b.js +1 -1
- data/test/fixtures/assets/public2/js/c.js +1 -1
- data/test/fixtures/images/size.extended.webp +0 -0
- data/test/fixtures/images/size.lossless.webp +0 -0
- data/test/fixtures/images/size.lossy.webp +0 -0
- data/test/fixtures/schema/before.yml +4 -4
- data/test/fixtures/schema/schema.yml +1 -1
- data/test/fixtures/templates/aliases/aaa.html.cut +0 -0
- data/test/fixtures/templates/extended/partial_with_renderer.html.cut +1 -0
- data/test/fixtures/templates/extended/with_includes_and_renderer.html.cut +2 -0
- data/test/functional/test_application.rb +108 -106
- data/test/functional/test_back.rb +924 -930
- data/test/functional/test_front.rb +285 -238
- data/test/functional/test_user_manager.rb +75 -100
- data/test/integration/test_installation.rb +1 -1
- data/test/support/matchers.rb +12 -0
- data/test/support/minitest.rb +121 -0
- data/test/support/rack.rb +45 -0
- data/test/support/test_start_finish.rb +103 -0
- data/test/test_helper.rb +21 -68
- data/test/test_integration_helper.rb +1 -3
- data/test/unit/test_alias.rb +432 -408
- data/test/unit/test_asset_bundler.rb +58 -58
- data/test/unit/test_assets.rb +485 -155
- data/test/unit/test_async.rb +16 -37
- data/test/unit/test_authentication.rb +425 -457
- data/test/unit/test_boxes.rb +191 -191
- data/test/unit/test_changesets.rb +244 -254
- data/test/unit/test_config.rb +128 -142
- data/test/unit/test_content.rb +313 -359
- data/test/unit/test_content_inheritance.rb +29 -30
- data/test/unit/test_datamapper.rb +1205 -1080
- data/test/unit/test_datamapper_content.rb +49 -51
- data/test/unit/test_extensions.rb +23 -23
- data/test/unit/test_fields.rb +1488 -1180
- data/test/unit/test_formats.rb +158 -158
- data/test/unit/test_generators.rb +98 -40
- data/test/unit/test_helpers.rb +73 -76
- data/test/unit/test_image_size.rb +53 -22
- data/test/unit/test_images.rb +164 -165
- data/test/unit/test_layouts.rb +133 -122
- data/test/unit/test_logger.rb +14 -17
- data/test/unit/test_media.rb +69 -84
- data/test/unit/test_modifications.rb +513 -525
- data/test/unit/test_page.rb +462 -361
- data/test/unit/test_permissions.rb +379 -364
- data/test/unit/test_piece.rb +67 -75
- data/test/unit/test_plugins.rb +82 -89
- data/test/unit/test_prototype_set.rb +215 -216
- data/test/unit/test_prototypes.rb +114 -124
- data/test/unit/test_publishing.rb +252 -289
- data/test/unit/test_render.rb +167 -115
- data/test/unit/test_revisions.rb +436 -444
- data/test/unit/test_schema.rb +339 -309
- data/test/unit/test_search.rb +577 -574
- data/test/unit/test_serialisation.rb +136 -147
- data/test/unit/test_site.rb +252 -227
- data/test/unit/test_skeptick.rb +130 -0
- data/test/unit/test_storage.rb +46 -40
- data/test/unit/test_structure.rb +57 -66
- data/test/unit/test_styles.rb +104 -104
- data/test/unit/test_templates.rb +72 -57
- data/test/unit/test_type_hierarchy.rb +15 -16
- data/test/unit/test_visibility.rb +239 -257
- metadata +455 -326
- data/application/js/vendor/JS.Class-2.1.5/CHANGELOG +0 -283
- data/application/js/vendor/JS.Class-2.1.5/MIT-LICENSE +0 -30
- data/application/js/vendor/JS.Class-2.1.5/README +0 -30
- data/application/js/vendor/JS.Class-2.1.5/min/command.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/comparable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/constant_scope.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/decorator.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/enumerable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/forwardable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/hash.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/linked_list.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/loader.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/method_chain.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/observable.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/package.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/proxy.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/ruby.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/set.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/stack_trace.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/state.js +0 -1
- data/application/js/vendor/JS.Class-2.1.5/min/stdlib.js +0 -16
- data/application/js/vendor/jquery-1.6.2.min.js +0 -18
- data/application/js/vendor/jquery-ui-1.8.16.custom.min.js +0 -791
- data/application/js/vendor/jquery-ui-1.8.9.custom.min.js +0 -415
- data/application/static/font/fontawesome-webfont-5c5c21100a346972a82c34c5e96ffcfe.ttf +0 -0
- data/application/static/select-arrow-6e7dd3745b00e934b0d7a3250c46558b.png +0 -0
- data/bin/limit-upload +0 -5
- data/bin/unlimit-upload +0 -3
- data/lib/spontaneous/asset/file.rb +0 -25
- data/lib/spontaneous/asset/source.rb +0 -28
- data/lib/spontaneous/image_size.rb +0 -123
- data/lib/spontaneous/output/assets/compression.rb +0 -58
- data/lib/spontaneous/output/assets.rb +0 -32
- data/lib/spontaneous/rack/around_back.rb +0 -20
- data/lib/spontaneous/rack/around_front.rb +0 -27
- data/lib/spontaneous/rack/around_preview.rb +0 -22
- data/lib/spontaneous/rack/assets.rb +0 -126
- data/lib/spontaneous/rack/authentication.rb +0 -20
- data/lib/spontaneous/rack/cookie_authentication.rb +0 -38
- data/lib/spontaneous/rack/helpers.rb +0 -52
- data/lib/spontaneous/rack/http.rb +0 -18
- data/lib/spontaneous/rack/media.rb +0 -30
- data/lib/spontaneous/rack/query_authentication.rb +0 -35
- data/lib/spontaneous/rack/reloader.rb +0 -45
- data/lib/spontaneous/rack/user_helpers.rb +0 -28
- /data/{README → application/js/field/markdown/text_command.js} +0 -0
- /data/application/js/vendor/{JS.Class-2.1.5/min/core.js → js.class-2.1.5.min.js} +0 -0
- /data/test/fixtures/assets/public1/css/{a.scss → a.css.scss} +0 -0
- /data/{lib/spontaneous/generators/site/public/css/site.scss → test/fixtures/assets/public1/x.css} +0 -0
- /data/{lib/spontaneous/generators/site/public/js/.empty_directory → test/fixtures/assets/public1/x.png} +0 -0
- /data/test/fixtures/assets/public2/css/{b.scss → b.css.scss} +0 -0
- /data/test/fixtures/assets/public2/js/{n.coffee → n.js.coffee} +0 -0
- /data/test/fixtures/back/{public → assets}/css/sass_include.scss +0 -0
- /data/test/fixtures/back/{public → assets}/css/sass_template.scss +0 -0
- /data/test/fixtures/back/{public → assets}/js/coffeescript.coffee +0 -0
- /data/{lib/spontaneous/generators/site/public/js/site.js → test/fixtures/templates/aliases/aa_alias.html.cut} +0 -0
data/application/js/top_bar.js
CHANGED
@@ -1,23 +1,177 @@
|
|
1
1
|
// console.log("Loading TopBar...")
|
2
2
|
|
3
3
|
Spontaneous.TopBar = (function($, S) {
|
4
|
-
var dom = S.Dom;
|
4
|
+
var dom = S.Dom, Ajax = S.Ajax;
|
5
5
|
|
6
|
-
var
|
6
|
+
var disableParent = function(el) {
|
7
|
+
el.hover(function() {
|
8
|
+
$(this).parent().addClass("disabled");
|
9
|
+
}, function() {
|
10
|
+
$(this).parent().removeClass("disabled");
|
11
|
+
});
|
12
|
+
return el;
|
13
|
+
};
|
14
|
+
|
15
|
+
var slugComparator = function(a, b) {
|
16
|
+
var at = a.slug, bt = b.slug;
|
17
|
+
if (at > bt) { return 1; }
|
18
|
+
if (at < bt) { return -1; }
|
19
|
+
return 0;
|
20
|
+
};
|
21
|
+
|
22
|
+
var RootBrowser = new JS.Class(Spontaneous.PopoverView, {
|
23
|
+
initialize: function(roots) {
|
24
|
+
this.roots = roots;
|
25
|
+
},
|
26
|
+
width: function() { return 300; },
|
27
|
+
title: function() { return "Choose Root"; },
|
28
|
+
view: function() {
|
29
|
+
var self = this, w = dom.div('#navigation-page-browser.pop-root-browser'), list = dom.div(".pages"), roots = this.roots.roots;
|
30
|
+
var click = function(page_id) {
|
31
|
+
return function() { self.close(); S.Location.load_id(page_id); };
|
32
|
+
};
|
33
|
+
for (var key in roots) {
|
34
|
+
if (roots.hasOwnProperty(key)) {
|
35
|
+
var r = dom.div(".page").text(key).click(click(roots[key]));
|
36
|
+
list.append(r);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
frame.append(list);
|
40
|
+
this.wrapper = w;
|
41
|
+
return w;
|
42
|
+
}
|
43
|
+
});
|
44
|
+
|
45
|
+
var PageBrowser = new JS.Class(Spontaneous.PopoverView, {
|
46
|
+
initialize: function(origin, pages) {
|
47
|
+
this.origin = origin;
|
48
|
+
this.pages = pages;
|
49
|
+
},
|
50
|
+
width: function() { return 300; },
|
51
|
+
title: function() { return "Go to Page"; },
|
52
|
+
view: function() {
|
53
|
+
var self = this, w = dom.div('#navigation-page-browser.pop-root-browser')
|
54
|
+
, list = dom.div(".pages")
|
55
|
+
, frame = dom.div(".frame")
|
56
|
+
, searchArea = dom.div(".search")
|
57
|
+
, searchInput = dom.input({type: "search", placeholder:"Search"});
|
58
|
+
searchArea.append(searchInput);
|
59
|
+
searchInput.bind("change keyup search", self.updateSearch.bind(self, searchInput));
|
60
|
+
self.wrapper = w;
|
61
|
+
self.list = list;
|
62
|
+
frame.append(list);
|
63
|
+
w.append(searchArea, frame)
|
64
|
+
this.loadPages();
|
65
|
+
return w;
|
66
|
+
},
|
67
|
+
updateSearch: function(input) {
|
68
|
+
if (!this.pages) { return; }
|
69
|
+
|
70
|
+
var self = this, boxes = {}, query = input.val(), search = new RegExp(query, "i");
|
71
|
+
// need to bubble up the event if the query is identical as this event
|
72
|
+
// is also triggered on input blur when a page is clicked.
|
73
|
+
if (query === this.query) {
|
74
|
+
return true;
|
75
|
+
}
|
76
|
+
|
77
|
+
this.query = query;
|
78
|
+
if (query === "") {
|
79
|
+
self.listPages(this.pages);
|
80
|
+
return;
|
81
|
+
}
|
82
|
+
$.each(self.pages, function(boxname, pages) {
|
83
|
+
var box = [];
|
84
|
+
for (var i = 0, ii = pages.length; i < ii; i++) {
|
85
|
+
var page = pages[i];
|
86
|
+
if (search.test(page.slug) || search.test(page.title)) {
|
87
|
+
box.push(page);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
if (box.length > 0) {
|
91
|
+
boxes[boxname] = box;
|
92
|
+
}
|
93
|
+
});
|
94
|
+
self.listPages(boxes, query);
|
95
|
+
},
|
96
|
+
clearList: function() {
|
97
|
+
this.list.empty();
|
98
|
+
},
|
99
|
+
loadPages: function() {
|
100
|
+
if (this.pages) {
|
101
|
+
this.listPages(this.pages);
|
102
|
+
} else {
|
103
|
+
var path = ["/map", this.origin.id].join("/")
|
104
|
+
S.Location.retrieve(path, this.pagesLoaded.bind(this));
|
105
|
+
}
|
106
|
+
},
|
107
|
+
pagesLoaded: function(pages) {
|
108
|
+
this.pages = pages.generation;
|
109
|
+
this.listPages(pages.generation);
|
110
|
+
},
|
111
|
+
listPages: function(generation, filter) {
|
112
|
+
var self = this, origin = self.origin, load_page = function(p) {
|
113
|
+
return function() {
|
114
|
+
self.close();
|
115
|
+
S.Location.load_id(p.id);
|
116
|
+
}
|
117
|
+
};
|
118
|
+
self.clearList();
|
119
|
+
if (Object.keys(generation).length === 0) {
|
120
|
+
var msg = filter ? "No matches for ‘"+filter+"’" : "No pages";
|
121
|
+
self.list.append(dom.h3().text(msg))
|
122
|
+
return;
|
123
|
+
}
|
124
|
+
$.each(generation, function(boxname, pages) {
|
125
|
+
pages.sort(slugComparator);
|
126
|
+
var box = dom.div(".box").append(dom.h4().text(boxname));
|
127
|
+
for (var i = 0, ii = pages.length; i < ii; i++) {
|
128
|
+
var p = pages[i], page = dom.div(".page").text(p.slug).data('page', p);
|
129
|
+
if (origin && p.id === origin.id) {
|
130
|
+
page.addClass("current");
|
131
|
+
}
|
132
|
+
page.click(load_page(p));
|
133
|
+
box.append(page);
|
134
|
+
}
|
135
|
+
self.list.append(box);
|
136
|
+
});
|
137
|
+
}
|
138
|
+
});
|
139
|
+
|
140
|
+
var RootNode = function(page, roots) {
|
7
141
|
this.page = page;
|
142
|
+
this.roots = roots;
|
8
143
|
this.id = page.id;
|
9
144
|
this.url = page.url;
|
10
|
-
this.title = S.site_domain;
|
11
|
-
}
|
145
|
+
this.title = this.title(); //page.title; //S.site_domain;
|
146
|
+
};
|
12
147
|
RootNode.prototype = {
|
148
|
+
title: function() {
|
149
|
+
var roots = this.roots.roots;
|
150
|
+
|
151
|
+
for (var key in roots) {
|
152
|
+
if (roots.hasOwnProperty(key)) {
|
153
|
+
if (roots[key] === this.id) { return key; }
|
154
|
+
}
|
155
|
+
}
|
156
|
+
return S.site_domain;
|
157
|
+
},
|
13
158
|
element: function() {
|
14
|
-
var li = dom.li('.root');
|
159
|
+
var self = this, li = dom.li('.root');
|
15
160
|
var link = dom.a({'href': this.url}).text(this.title).data('page', this.page);
|
161
|
+
if (Object.keys(this.roots.roots).length === 1) {
|
162
|
+
li.addClass("singluar");
|
163
|
+
} else {
|
164
|
+
li.click(function(event) {
|
165
|
+
var browser = new RootBrowser(self.roots);
|
166
|
+
Spontaneous.Popover.open(event, browser);
|
167
|
+
});
|
168
|
+
}
|
16
169
|
link.click(function() {
|
17
170
|
var page = $(this).data('page');
|
18
171
|
S.Location.load_id(page.id);
|
19
172
|
return false;
|
20
173
|
});
|
174
|
+
disableParent(link);
|
21
175
|
li.append(link);
|
22
176
|
this.link = link;
|
23
177
|
return li;
|
@@ -25,7 +179,7 @@ Spontaneous.TopBar = (function($, S) {
|
|
25
179
|
set_title: function(new_title) {
|
26
180
|
this.link.text(new_title);
|
27
181
|
}
|
28
|
-
}
|
182
|
+
};
|
29
183
|
|
30
184
|
var AncestorNode = function(page) {
|
31
185
|
this.page = page;
|
@@ -35,12 +189,21 @@ Spontaneous.TopBar = (function($, S) {
|
|
35
189
|
};
|
36
190
|
AncestorNode.prototype = {
|
37
191
|
element: function() {
|
38
|
-
var
|
192
|
+
var page = this.page, li = dom.li(), link = $('<a/>').data('page', page).click(function() {
|
39
193
|
var page = $(this).data('page');
|
40
194
|
S.Location.load_id(page.id);
|
41
|
-
|
195
|
+
return false;
|
196
|
+
}).text(this.title);
|
42
197
|
|
43
|
-
|
198
|
+
disableParent(link);
|
199
|
+
li.append(link);
|
200
|
+
|
201
|
+
li.click(function() {
|
202
|
+
var browser = new PageBrowser(page);
|
203
|
+
Spontaneous.Popover.open(event, browser);
|
204
|
+
});
|
205
|
+
|
206
|
+
return li;
|
44
207
|
}
|
45
208
|
};
|
46
209
|
var CurrentNode = function(page) {
|
@@ -50,164 +213,115 @@ Spontaneous.TopBar = (function($, S) {
|
|
50
213
|
self.path = page.path;
|
51
214
|
self.title = page.slug;
|
52
215
|
self.pages = page.generation;
|
53
|
-
}
|
216
|
+
};
|
54
217
|
|
55
218
|
CurrentNode.prototype = {
|
56
219
|
element: function() {
|
57
220
|
var self = this
|
58
221
|
, li = dom.li()
|
59
|
-
,
|
60
|
-
|
61
|
-
var
|
62
|
-
|
63
|
-
if (at < bt) { return -1; }
|
64
|
-
return 0;
|
65
|
-
};
|
66
|
-
select.change(function() {
|
67
|
-
var page = $(this.options[this.selectedIndex]).data('page');
|
68
|
-
S.Location.load_id(page.id);
|
69
|
-
return false;
|
222
|
+
, link = dom.a().text(self.title);
|
223
|
+
li.click(function(event) {
|
224
|
+
var browser = new PageBrowser(self.page, self.pages);
|
225
|
+
Spontaneous.Popover.open(event, browser);
|
70
226
|
});
|
71
|
-
|
72
|
-
|
73
|
-
pages.sort(comparator);
|
74
|
-
var optgroup = dom.optgroup().attr('label', boxname);
|
75
|
-
for (var i = 0, ii = pages.length; i < ii; i++) {
|
76
|
-
var p = pages[i],
|
77
|
-
option = dom.option({'value': p.id, 'selected':(p.id == self.id) }).text(p.slug).data('page', p);
|
78
|
-
if (p.id === self.id) {
|
79
|
-
self.title_option = option;
|
80
|
-
}
|
81
|
-
optgroup.append(option);
|
82
|
-
};
|
83
|
-
select.append(optgroup);
|
84
|
-
});
|
85
|
-
li.append(select);
|
227
|
+
li.append(link);
|
228
|
+
this.title_element = link;
|
86
229
|
return li;
|
87
230
|
},
|
88
231
|
set_title: function(new_title) {
|
89
|
-
this.
|
232
|
+
this.title_element.text(new_title);
|
90
233
|
}
|
91
|
-
}
|
234
|
+
};
|
92
235
|
|
93
|
-
var ChildrenNode = function(
|
94
|
-
this.
|
95
|
-
}
|
236
|
+
var ChildrenNode = function(origin) {
|
237
|
+
this.origin = origin;
|
238
|
+
};
|
96
239
|
|
97
240
|
ChildrenNode.prototype = {
|
98
241
|
element: function() {
|
99
|
-
var li = dom.li('.children')
|
100
|
-
, select = dom.select('.unselected')
|
101
|
-
, children = this.children;
|
242
|
+
var self = this, li = dom.li('.children'), link = dom.a('.unselected'), children = this.children;
|
102
243
|
this.li = li;
|
103
|
-
this.
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
if (p) {
|
109
|
-
S.Location.load_id(p.id());
|
110
|
-
}
|
111
|
-
return false;
|
244
|
+
this.link = link.text(this.status_text());
|
245
|
+
li.append(link);
|
246
|
+
li.click(function(event) {
|
247
|
+
var browser = new PageBrowser(self.origin, self.children());
|
248
|
+
Spontaneous.Popover.open(event, browser);
|
112
249
|
});
|
250
|
+
return li;
|
251
|
+
}.cache(),
|
252
|
+
|
253
|
+
each: function(block) {
|
254
|
+
var self = this, children = this.origin.children;
|
113
255
|
for (var boxname in children) {
|
114
256
|
if (children.hasOwnProperty(boxname)) {
|
115
|
-
var
|
116
|
-
|
117
|
-
|
118
|
-
optgroup.append(this.option_for_entry(p));
|
119
|
-
};
|
120
|
-
select.append(optgroup)
|
257
|
+
for (var i = 0, box = children[boxname], ii = box.length; i < ii; ++i) {
|
258
|
+
block(box[i])
|
259
|
+
}
|
121
260
|
}
|
122
261
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
sort_children: function(children) {
|
128
|
-
var comparator = function(a, b) {
|
129
|
-
var at = a.slug(), bt = b.slug();
|
130
|
-
if (at > bt) { return 1; }
|
131
|
-
if (at < bt) { return -1; }
|
132
|
-
return 0;
|
133
|
-
};
|
134
|
-
return children.sort(comparator);
|
262
|
+
},
|
263
|
+
children: function() {
|
264
|
+
return this.origin.children;
|
135
265
|
},
|
136
266
|
|
137
267
|
status_text: function() {
|
138
|
-
var children = this.children, count = 0;
|
268
|
+
var children = this.origin.children, count = 0;
|
139
269
|
for (var boxname in children) {
|
140
270
|
if (children.hasOwnProperty(boxname)) { count += children[boxname].length; }
|
141
271
|
}
|
142
272
|
if (count === 0) {
|
143
|
-
this.
|
273
|
+
this.li.hide();
|
144
274
|
} else {
|
145
|
-
this.
|
275
|
+
this.li.show();
|
146
276
|
}
|
147
277
|
return '('+(count)+' page'+(count === 1 ? '' : 's')+')';
|
148
278
|
},
|
149
|
-
optgroup: function(boxname) {
|
150
|
-
return dom.optgroup().attr('label', boxname);
|
151
|
-
},
|
152
|
-
option_for_entry: function(p) {
|
153
|
-
var opt = dom.option({'value': p.id()}).text(p.slug()).data('page', p);
|
154
|
-
if (p.watch) {
|
155
|
-
p.watch('slug', function(value) {
|
156
|
-
opt.text(value);
|
157
|
-
}.bind(this));
|
158
|
-
}
|
159
|
-
return opt;
|
160
|
-
},
|
161
279
|
update_status: function() {
|
162
|
-
this.
|
163
|
-
return this.
|
280
|
+
this.link.text(this.status_text());
|
281
|
+
return this.link;
|
164
282
|
},
|
165
283
|
add_page: function(page, position) {
|
166
284
|
var self = this
|
167
|
-
, option = self.option_for_entry(page)
|
168
285
|
, container = page.container
|
169
286
|
, name = container.name()
|
170
|
-
, children = self.children
|
171
|
-
,
|
172
|
-
if (optgroup.length === 0) {
|
173
|
-
optgroup = this.optgroup(name);
|
174
|
-
this.select.append(optgroup);
|
175
|
-
}
|
176
|
-
optgroup.prepend(option);
|
177
|
-
// since the navigation lists are ordered differently from the entries, it's
|
178
|
-
// difficult to insert into the right position
|
179
|
-
// TODO: re-sort the this.children entries and use this list to find the position in the select
|
287
|
+
, children = self.origin.children
|
288
|
+
, box = children[name];
|
180
289
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
if (position === -1) {
|
185
|
-
children[name].push(page)
|
186
|
-
} else {
|
187
|
-
children[name].splice(position, 0, page)
|
290
|
+
if (!box) {
|
291
|
+
box = [];
|
292
|
+
self.origin.children[name] = box;
|
188
293
|
}
|
294
|
+
// make the new entry as much like the originals as possible
|
295
|
+
var entry = {
|
296
|
+
id: page.id(),
|
297
|
+
children: 0,
|
298
|
+
slug: page.slug(),
|
299
|
+
title: page.title(),
|
300
|
+
type_id: page.content.type_id
|
301
|
+
};
|
302
|
+
box.push(entry);
|
189
303
|
self.update_status();
|
190
304
|
},
|
191
305
|
|
192
306
|
remove_page: function(page) {
|
193
307
|
var self = this
|
308
|
+
, children = self.origin.children
|
194
309
|
, container = page.container.name()
|
310
|
+
, page_id = page.id()
|
195
311
|
, index = (function(children) {
|
196
312
|
for (var boxname in children) {
|
197
313
|
if (children.hasOwnProperty(boxname)) {
|
198
314
|
var cc = children[boxname];
|
199
315
|
for (var i = 0, ii = cc.length; i < ii; i++) {
|
200
|
-
if (cc[i].id
|
316
|
+
if (cc[i].id === page_id) { return i; }
|
201
317
|
}
|
202
318
|
}
|
203
319
|
}
|
204
|
-
}(
|
205
|
-
|
206
|
-
|
207
|
-
this.children[container].splice(index, 1);
|
208
|
-
this.update_status();
|
320
|
+
}(children));
|
321
|
+
children[container].splice(index, 1);
|
322
|
+
self.update_status();
|
209
323
|
}
|
210
|
-
}
|
324
|
+
};
|
211
325
|
|
212
326
|
var PublishButton = new JS.Class({
|
213
327
|
rapid_check: 2000,
|
@@ -216,31 +330,20 @@ Spontaneous.TopBar = (function($, S) {
|
|
216
330
|
this.status = false;
|
217
331
|
this.disabled = true;
|
218
332
|
this.set_interval(this.normal_check);
|
219
|
-
// this.check_status();
|
220
333
|
var update_status = this.update_status.bind(this);
|
221
334
|
S.EventSource.addEventListener('publish_progress', function(event) {
|
222
|
-
update_status($.parseJSON(event.data))
|
335
|
+
update_status($.parseJSON(event.data));
|
223
336
|
});
|
224
337
|
},
|
225
338
|
user_loaded: function(user) {
|
226
|
-
console.log("user loaded", user)
|
227
339
|
if (user.can_publish()) {
|
228
340
|
this.disabled = false;
|
229
341
|
this.button().removeClass("disabled").fadeIn();
|
230
342
|
}
|
231
343
|
},
|
232
|
-
check_status: function() {
|
233
|
-
S.Ajax.get('/publish/status', this.status_recieved.bind(this));
|
234
|
-
},
|
235
|
-
status_recieved: function(status, response_code) {
|
236
|
-
if (response_code === 'success' && status != this.status) {
|
237
|
-
this.update_status(status);
|
238
|
-
}
|
239
|
-
window.setTimeout(this.check_status.bind(this), this.timer_interval);
|
240
|
-
},
|
241
344
|
update_status: function(status) {
|
242
345
|
if (status === null || status === '') { return; }
|
243
|
-
var state = status.state, progress = status.progress
|
346
|
+
var state = status.state, progress = status.progress;
|
244
347
|
// if (this.in_progress && (state == this.current_action && progress == this.current_progress)) { return; }
|
245
348
|
this.current_action = state;
|
246
349
|
this.current_progress = progress;
|
@@ -250,11 +353,11 @@ Spontaneous.TopBar = (function($, S) {
|
|
250
353
|
this.progress().stop();
|
251
354
|
// this.set_interval(this.normal_check);
|
252
355
|
this.set_label("Publish");
|
253
|
-
this.button().switchClass('progress', '')
|
356
|
+
this.button().switchClass('progress', '');
|
254
357
|
this.current_action = this.current_progress = null;
|
255
358
|
// }
|
256
359
|
if (state === 'error') {
|
257
|
-
alert('There was a problem publishing: ' + progress)
|
360
|
+
alert('There was a problem publishing: ' + progress);
|
258
361
|
}
|
259
362
|
} else {
|
260
363
|
this.publishing_state();
|
@@ -297,7 +400,7 @@ Spontaneous.TopBar = (function($, S) {
|
|
297
400
|
}
|
298
401
|
}.bind(this));
|
299
402
|
}
|
300
|
-
return this._button
|
403
|
+
return this._button;
|
301
404
|
},
|
302
405
|
progress: function() {
|
303
406
|
if (!this._progress) {
|
@@ -341,37 +444,28 @@ Spontaneous.TopBar = (function($, S) {
|
|
341
444
|
self.wrap.append(self.location);
|
342
445
|
self.wrap.append(self.publish_button.button());
|
343
446
|
self.wrap.append(self.mode_switch);
|
344
|
-
S.User.watch("user", function(user) { self.publish_button.user_loaded(user); })
|
447
|
+
S.User.watch("user", function(user) { self.publish_button.user_loaded(user); });
|
345
448
|
}
|
346
449
|
return self.wrap;
|
347
450
|
},
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
for (var boxname in location.children) {
|
352
|
-
if (location.children.hasOwnProperty(boxname)) {
|
353
|
-
children[boxname] = [];
|
354
|
-
for (var i = 0, cc = location.children[boxname], ii = cc.length; i < ii; i++) {
|
355
|
-
children[boxname].push(new LocationChildProxy(cc[i]));
|
356
|
-
}
|
357
|
-
}
|
358
|
-
}
|
359
|
-
var children_node = new ChildrenNode(children);
|
360
|
-
this.location.append(children_node.element());
|
361
|
-
this.children_node = children_node;
|
451
|
+
roots: function(roots) {
|
452
|
+
this.roots = roots;
|
362
453
|
},
|
363
|
-
|
454
|
+
location_loaded: function(location) {
|
364
455
|
var self = this;
|
365
|
-
|
366
|
-
self.children_node.element().remove();
|
367
|
-
}
|
368
|
-
var children_node = new ChildrenNode(page.children());
|
456
|
+
var children_node = new ChildrenNode(location);
|
369
457
|
self.location.append(children_node.element());
|
458
|
+
self.children_node = children_node;
|
459
|
+
},
|
460
|
+
page_loaded: function(page) {
|
461
|
+
var self = this, children_node = self.children_node;
|
462
|
+
|
370
463
|
page.bind('entry_added', function(entry, position) {
|
371
464
|
if (entry.is_page()) {
|
372
465
|
children_node.add_page(entry, position);
|
373
466
|
}
|
374
467
|
});
|
468
|
+
|
375
469
|
page.bind('removed_entry', function(entry) {
|
376
470
|
if (entry.is_page()) {
|
377
471
|
children_node.remove_page(entry);
|
@@ -387,43 +481,41 @@ Spontaneous.TopBar = (function($, S) {
|
|
387
481
|
page.title_field().watch('value', function(title) {
|
388
482
|
Spontaneous.set_browser_title(title);
|
389
483
|
});
|
390
|
-
|
391
|
-
self.children_node = children_node;
|
392
484
|
},
|
393
485
|
update_navigation: function(location) {
|
394
486
|
var nodes = [];
|
395
487
|
// var location = this.get('location');
|
396
488
|
var $location_bar = this.location;
|
397
489
|
var ancestors = location.ancestors.slice(0);
|
398
|
-
var root, is_root = false, root_node, children_node, current_node;
|
490
|
+
var i, node, root, is_root = false, root_node, children_node, current_node;
|
399
491
|
if (ancestors.length === 0) {
|
400
492
|
root = location;
|
401
493
|
is_root = true;
|
402
494
|
} else {
|
403
495
|
root = ancestors.shift();
|
404
496
|
}
|
405
|
-
root_node = new RootNode(root);
|
497
|
+
root_node = new RootNode(root, this.roots);
|
406
498
|
nodes.push(root_node);
|
407
|
-
for (
|
499
|
+
for (i=0, ii=ancestors.length; i < ii; i++) {
|
408
500
|
var page = ancestors[i];
|
409
|
-
|
501
|
+
node = new AncestorNode(page);
|
410
502
|
nodes.push(node);
|
411
|
-
}
|
503
|
+
}
|
412
504
|
if (!is_root) {
|
413
|
-
current_node = new CurrentNode(location)
|
505
|
+
current_node = new CurrentNode(location);
|
414
506
|
nodes.push(current_node);
|
415
507
|
} else {
|
416
508
|
current_node = root_node;
|
417
509
|
}
|
418
510
|
$('li', $location_bar).remove();
|
419
|
-
|
511
|
+
|
420
512
|
if (location.children.length > 0) {
|
421
513
|
// children_node = new ChildrenNode(location.children);
|
422
514
|
// $location_bar.append(children_node.element())
|
423
515
|
}
|
424
|
-
for (
|
425
|
-
|
426
|
-
$location_bar.append(node.element())
|
516
|
+
for (i = 0, ii = nodes.length; i < ii; i++) {
|
517
|
+
node = nodes[i];
|
518
|
+
$location_bar.append(node.element());
|
427
519
|
}
|
428
520
|
this.navigation_current = current_node;
|
429
521
|
},
|
@@ -447,12 +539,12 @@ Spontaneous.TopBar = (function($, S) {
|
|
447
539
|
},
|
448
540
|
panel: function() {
|
449
541
|
var self = this;
|
450
|
-
this.wrap = dom.div("#service-navigation")
|
542
|
+
this.wrap = dom.div("#service-navigation");
|
451
543
|
var title = dom.h2().text(this.service.title);
|
452
544
|
var close = dom.a(".button").text("Close").click(function() {
|
453
545
|
S.Services.close();
|
454
|
-
})
|
455
|
-
this.wrap.append(title, close)
|
546
|
+
});
|
547
|
+
this.wrap.append(title, close);
|
456
548
|
return this.wrap;
|
457
549
|
}
|
458
550
|
});
|
@@ -462,8 +554,8 @@ Spontaneous.TopBar = (function($, S) {
|
|
462
554
|
panel: function() {
|
463
555
|
this.wrap = dom.div('#top');
|
464
556
|
// this.icon = dom.div('#spontaneous-root');
|
465
|
-
this.icon = this.rootMenu()
|
466
|
-
this.holder = dom.div('#service-outer')
|
557
|
+
this.icon = this.rootMenu();
|
558
|
+
this.holder = dom.div('#service-outer');
|
467
559
|
this.navigationView = new CMSNavigationView();
|
468
560
|
this.serviceStation = dom.div("#service-inner");
|
469
561
|
this.holder.append(this.navigationView.panel(), this.serviceStation);
|
@@ -479,10 +571,11 @@ Spontaneous.TopBar = (function($, S) {
|
|
479
571
|
});
|
480
572
|
return li.append(dom.span());
|
481
573
|
},
|
482
|
-
init: function() {
|
574
|
+
init: function(metadata) {
|
483
575
|
if (!this.get('mode')) {
|
484
576
|
this.set('mode', S.ContentArea.mode);
|
485
577
|
}
|
578
|
+
this.navigationView.roots(metadata.roots)
|
486
579
|
S.Editing.watch('page', this.page_loaded.bind(this));
|
487
580
|
S.Location.watch('location', this.location_loaded.bind(this));
|
488
581
|
},
|
@@ -502,7 +595,7 @@ Spontaneous.TopBar = (function($, S) {
|
|
502
595
|
this.navigationView.publishing_started();
|
503
596
|
},
|
504
597
|
location_changed: function(new_location) {
|
505
|
-
Spontaneous.set_browser_title(new_location.title)
|
598
|
+
Spontaneous.set_browser_title(new_location.title);
|
506
599
|
this.set('location', new_location);
|
507
600
|
this.navigationView.update_navigation(new_location);
|
508
601
|
this.page_loaded = function(page) {
|
@@ -520,12 +613,12 @@ Spontaneous.TopBar = (function($, S) {
|
|
520
613
|
},
|
521
614
|
set_mode: function(mode) {
|
522
615
|
this.set('mode', mode);
|
523
|
-
this.navigationView.mode_set(mode)
|
616
|
+
this.navigationView.mode_set(mode);
|
524
617
|
},
|
525
618
|
showService: function(service) {
|
526
619
|
this.navigationView.hide();
|
527
620
|
this.serviceView = new ServiceNavigationView(service);
|
528
|
-
this.serviceStation.empty().append(this.serviceView.panel())
|
621
|
+
this.serviceStation.empty().append(this.serviceView.panel());
|
529
622
|
},
|
530
623
|
showNavigationView: function() {
|
531
624
|
this.serviceStation.empty();
|
@@ -533,6 +626,4 @@ Spontaneous.TopBar = (function($, S) {
|
|
533
626
|
}
|
534
627
|
});
|
535
628
|
return TopBar;
|
536
|
-
}
|
537
|
-
|
538
|
-
|
629
|
+
}(jQuery, Spontaneous));
|
data/application/js/upload.js
CHANGED
@@ -34,13 +34,20 @@ Spontaneous.Upload = (function($, S) {
|
|
34
34
|
if (this.target_version) {
|
35
35
|
form.append('version', this.target_version);
|
36
36
|
}
|
37
|
-
this.
|
37
|
+
this.put("/file/"+this.target_id, form);
|
38
38
|
},
|
39
39
|
|
40
40
|
post: function(url, form_data) {
|
41
|
-
this.
|
41
|
+
this.request("POST", url, form_data)
|
42
|
+
},
|
43
|
+
put: function(url, form_data) {
|
44
|
+
this.request("PUT", url, form_data)
|
45
|
+
},
|
46
|
+
request: function(verb, url, form_data) {
|
47
|
+
this.xhr = S.Ajax.authenticatedRequest();
|
42
48
|
this.upload = this.xhr.upload;
|
43
|
-
this.xhr.open(
|
49
|
+
this.xhr.open(verb, this.namespaced_path(url), true);
|
50
|
+
// S.Ajax.authenticateRequest(this.xhr);
|
44
51
|
this.upload.onprogress = this.onprogress.bind(this);
|
45
52
|
this.upload.onload = this.onload.bind(this);
|
46
53
|
this.upload.onloadend = this.onloadend.bind(this);
|
@@ -48,9 +55,9 @@ Spontaneous.Upload = (function($, S) {
|
|
48
55
|
this.xhr.onreadystatechange = this.onreadystatechange.bind(this);
|
49
56
|
this.started = (new Date()).valueOf();
|
50
57
|
this.xhr.send(form_data);
|
51
|
-
|
58
|
+
},
|
52
59
|
namespaced_path: function(path) {
|
53
|
-
return S.Ajax.request_url(path
|
60
|
+
return S.Ajax.request_url(path);
|
54
61
|
},
|
55
62
|
// While loading and sending data.
|
56
63
|
onprogress: function(event) {
|