slices 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +3 -0
- data/README.md +51 -0
- data/Rakefile +9 -0
- data/app/assets/images/slices/ajax-loader.gif +0 -0
- data/app/assets/images/slices/asset-background.png +0 -0
- data/app/assets/images/slices/asset-spinner.gif +0 -0
- data/app/assets/images/slices/bg_header.gif +0 -0
- data/app/assets/images/slices/black-Linen.png +0 -0
- data/app/assets/images/slices/calendar.svg +68 -0
- data/app/assets/images/slices/chosen-sprite.png +0 -0
- data/app/assets/images/slices/drag-handle.svg +9 -0
- data/app/assets/images/slices/icon_admins.png +0 -0
- data/app/assets/images/slices/icon_app.png +0 -0
- data/app/assets/images/slices/icon_assets.png +0 -0
- data/app/assets/images/slices/icon_collapse.png +0 -0
- data/app/assets/images/slices/icon_drag.png +0 -0
- data/app/assets/images/slices/icon_files.png +0 -0
- data/app/assets/images/slices/icon_generic_file.png +0 -0
- data/app/assets/images/slices/icon_images.png +0 -0
- data/app/assets/images/slices/icon_padlock.png +0 -0
- data/app/assets/images/slices/icon_page.png +0 -0
- data/app/assets/images/slices/icon_search.png +0 -0
- data/app/assets/images/slices/icon_set-link.png +0 -0
- data/app/assets/images/slices/icon_set.png +0 -0
- data/app/assets/images/slices/icon_sitemap.png +0 -0
- data/app/assets/images/slices/icon_snippets.png +0 -0
- data/app/assets/images/slices/icon_template.jpg +0 -0
- data/app/assets/images/slices/icon_upload_happy.png +0 -0
- data/app/assets/images/slices/icon_upload_sad.png +0 -0
- data/app/assets/images/slices/icon_upload_thinking.png +0 -0
- data/app/assets/images/slices/noise.png +0 -0
- data/app/assets/images/slices/sitemap_icon_ghost.png +0 -0
- data/app/assets/images/slices/sitemap_icon_home.png +0 -0
- data/app/assets/images/slices/sitemap_icon_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_set_page.png +0 -0
- data/app/assets/images/slices/sitemap_icon_virtual_page.png +0 -0
- data/app/assets/images/slices/sitemap_overlay.png +0 -0
- data/app/assets/images/slices/spinner.gif +0 -0
- data/app/assets/images/slices/trash.png +0 -0
- data/app/assets/javascripts/admin.js.erb +18 -0
- data/app/assets/javascripts/slices/app/backbones/admins.js +114 -0
- data/app/assets/javascripts/slices/app/backbones/entries.js +172 -0
- data/app/assets/javascripts/slices/app/backbones/generic.js +101 -0
- data/app/assets/javascripts/slices/app/backbones/snippets.js +113 -0
- data/app/assets/javascripts/slices/app/helpers/assets.js +61 -0
- data/app/assets/javascripts/slices/app/helpers/breadcrumbs.js +30 -0
- data/app/assets/javascripts/slices/app/helpers/composer.js +26 -0
- data/app/assets/javascripts/slices/app/helpers/date_field.js +16 -0
- data/app/assets/javascripts/slices/app/helpers/get_value.js +31 -0
- data/app/assets/javascripts/slices/app/helpers/icon_upload_names.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/layout.js +20 -0
- data/app/assets/javascripts/slices/app/helpers/sitemap.js +150 -0
- data/app/assets/javascripts/slices/app/helpers/slice_preview.js +48 -0
- data/app/assets/javascripts/slices/app/helpers/tagging.js +73 -0
- data/app/assets/javascripts/slices/app/helpers/token_field.js +17 -0
- data/app/assets/javascripts/slices/app/helpers/upload_icons.js.erb +5 -0
- data/app/assets/javascripts/slices/app/helpers/uploader.js +127 -0
- data/app/assets/javascripts/slices/app/models/asset.js +29 -0
- data/app/assets/javascripts/slices/app/models/asset_collection.js +41 -0
- data/app/assets/javascripts/slices/app/models/attachment.js +29 -0
- data/app/assets/javascripts/slices/app/models/attachment_collection.js +7 -0
- data/app/assets/javascripts/slices/app/models/composer_item.js +1 -0
- data/app/assets/javascripts/slices/app/models/composer_item_collection.js +3 -0
- data/app/assets/javascripts/slices/app/models/file.js +103 -0
- data/app/assets/javascripts/slices/app/models/page.js +186 -0
- data/app/assets/javascripts/slices/app/models/s3_file.js +64 -0
- data/app/assets/javascripts/slices/app/slices.js +661 -0
- data/app/assets/javascripts/slices/app/views/asset_editor_view.js.erb +209 -0
- data/app/assets/javascripts/slices/app/views/asset_library_view.js +720 -0
- data/app/assets/javascripts/slices/app/views/asset_thumb_view.js.erb +191 -0
- data/app/assets/javascripts/slices/app/views/attachment_composer_view.js +350 -0
- data/app/assets/javascripts/slices/app/views/attachment_view.js +101 -0
- data/app/assets/javascripts/slices/app/views/calendar_view.js +198 -0
- data/app/assets/javascripts/slices/app/views/composer_item_view.js +54 -0
- data/app/assets/javascripts/slices/app/views/composer_view.js +130 -0
- data/app/assets/javascripts/slices/app/views/date_field_view.js +177 -0
- data/app/assets/javascripts/slices/app/views/file_view.js +142 -0
- data/app/assets/javascripts/slices/app/views/token_field_view.js +253 -0
- data/app/assets/javascripts/slices/lib/freeze.js +14 -0
- data/app/assets/javascripts/slices/lib/human_file_size.js +16 -0
- data/app/assets/javascripts/slices/lib/json_patch.js +9 -0
- data/app/assets/javascripts/slices/lib/moment.js +47 -0
- data/app/assets/javascripts/slices/lib/plugins.js +101 -0
- data/app/assets/javascripts/slices/lib/sortable.js +14 -0
- data/app/assets/javascripts/slices/slices.js +27 -0
- data/app/assets/javascripts/slices/vendor/autoscroll.js +188 -0
- data/app/assets/javascripts/slices/vendor/backbone.js +38 -0
- data/app/assets/javascripts/slices/vendor/handlebars.js +1920 -0
- data/app/assets/javascripts/slices/vendor/jqmodal.js +69 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui.js +274 -0
- data/app/assets/javascripts/slices/vendor/jquery-ui_nested-sortable.js +357 -0
- data/app/assets/javascripts/slices/vendor/jquery.ajaxprogress.js +76 -0
- data/app/assets/javascripts/slices/vendor/jquery.js +2 -0
- data/app/assets/javascripts/slices/vendor/livefield.js +459 -0
- data/app/assets/javascripts/slices/vendor/moment.js +6 -0
- data/app/assets/javascripts/slices/vendor/rails.js +315 -0
- data/app/assets/javascripts/slices/vendor/underscore-string.js +1 -0
- data/app/assets/javascripts/slices/vendor/underscore.js +5 -0
- data/app/assets/stylesheets/admin.css +1 -0
- data/app/assets/stylesheets/slices/admin.css.erb +2237 -0
- data/app/assets/stylesheets/slices/reset_html5.css +106 -0
- data/app/assets/stylesheets/slices/slices.css +7 -0
- data/app/controllers/admin/admin_controller.rb +10 -0
- data/app/controllers/admin/admins_controller.rb +76 -0
- data/app/controllers/admin/assets_controller.rb +53 -0
- data/app/controllers/admin/auth/omniauth_callbacks_controller.rb +15 -0
- data/app/controllers/admin/auth/passwords_controller.rb +4 -0
- data/app/controllers/admin/auth/sessions_controller.rb +4 -0
- data/app/controllers/admin/entries_controller.rb +88 -0
- data/app/controllers/admin/page_search_controller.rb +12 -0
- data/app/controllers/admin/pages_controller.rb +103 -0
- data/app/controllers/admin/site_maps_controller.rb +15 -0
- data/app/controllers/admin/snippets_controller.rb +33 -0
- data/app/controllers/application_controller.rb +4 -0
- data/app/controllers/pages_controller.rb +45 -0
- data/app/controllers/slices_controller.rb +63 -0
- data/app/controllers/static_assets_controller.rb +52 -0
- data/app/helpers/admin/admin_helper.rb +63 -0
- data/app/helpers/admin/assets_helper.rb +36 -0
- data/app/helpers/admin/entries_helper.rb +13 -0
- data/app/helpers/admin/site_maps_helper.rb +104 -0
- data/app/helpers/assets_helper.rb +64 -0
- data/app/helpers/navigation_helper.rb +195 -0
- data/app/helpers/pages_helper.rb +119 -0
- data/app/models/admin.rb +34 -0
- data/app/models/asset.rb +211 -0
- data/app/models/attachment.rb +11 -0
- data/app/models/layout.rb +44 -0
- data/app/models/page.rb +214 -0
- data/app/models/placeholder_slice.rb +8 -0
- data/app/models/set_page.rb +12 -0
- data/app/models/set_slice.rb +57 -0
- data/app/models/site_map.rb +24 -0
- data/app/models/slice.rb +80 -0
- data/app/models/snippet.rb +21 -0
- data/app/observers/asset_observer.rb +6 -0
- data/app/observers/page_observer.rb +37 -0
- data/app/presenters/entry_presenter.rb +17 -0
- data/app/presenters/page_presenter.rb +67 -0
- data/app/presenters/presenter.rb +9 -0
- data/app/presenters/set_page_presenter.rb +2 -0
- data/app/views/admin/admins/index.html.erb +26 -0
- data/app/views/admin/admins/show.html.erb +27 -0
- data/app/views/admin/assets/index.html.erb +1 -0
- data/app/views/admin/auth/passwords/edit.html.erb +20 -0
- data/app/views/admin/auth/passwords/new.html.erb +14 -0
- data/app/views/admin/auth/sessions/_form.html.erb +35 -0
- data/app/views/admin/auth/sessions/new.html.erb +14 -0
- data/app/views/admin/entries/index.html.erb +32 -0
- data/app/views/admin/pages/_breadcrumbs.html.erb +32 -0
- data/app/views/admin/pages/_slices.html.erb +27 -0
- data/app/views/admin/pages/new.html.erb +14 -0
- data/app/views/admin/pages/show.html.erb +50 -0
- data/app/views/admin/shared/_asset_storage.html.erb +17 -0
- data/app/views/admin/shared/_custom_links.html.erb +1 -0
- data/app/views/admin/shared/_custom_navigation.html.erb +1 -0
- data/app/views/admin/shared/_navigation.html.erb +5 -0
- data/app/views/admin/site_maps/_page_li.html.erb +20 -0
- data/app/views/admin/site_maps/_set_page_li.html.erb +23 -0
- data/app/views/admin/site_maps/index.html.erb +29 -0
- data/app/views/admin/snippets/form.html.erb +12 -0
- data/app/views/admin/snippets/index.html.erb +20 -0
- data/app/views/admin/snippets/update.html.erb +0 -0
- data/app/views/layouts/admin.html.erb +72 -0
- data/lib/ext/file_store_cache.rb +18 -0
- data/lib/generators/humans/USAGE +8 -0
- data/lib/generators/humans/humans_generator.rb +10 -0
- data/lib/generators/humans/templates/humans.txt +6 -0
- data/lib/generators/slice/USAGE +28 -0
- data/lib/generators/slice/slice_generator.rb +123 -0
- data/lib/generators/slice/templates/main_fields.hbs +11 -0
- data/lib/generators/slice/templates/meta_fields.hbs +11 -0
- data/lib/generators/slice/templates/page.rb +19 -0
- data/lib/generators/slice/templates/presenter.rb +53 -0
- data/lib/generators/slice/templates/set.html.erb +8 -0
- data/lib/generators/slice/templates/set_slice.rb +14 -0
- data/lib/generators/slice/templates/set_slice_fields.hbs +5 -0
- data/lib/generators/slice/templates/show.html.erb +48 -0
- data/lib/generators/slice/templates/show_slice.rb +20 -0
- data/lib/generators/slice/templates/slice.rb +58 -0
- data/lib/generators/slice/templates/slice_fields.hbs +74 -0
- data/lib/generators/templates/slices.rb +211 -0
- data/lib/mongo_search.rb +84 -0
- data/lib/paperclip_validator.rb +5 -0
- data/lib/rack_utf8_fix.rb +10 -0
- data/lib/sRGB.icc +0 -0
- data/lib/set_link_renderer.rb +31 -0
- data/lib/slices.rb +68 -0
- data/lib/slices/asset/maker.rb +55 -0
- data/lib/slices/asset/rename.rb +67 -0
- data/lib/slices/available_slices.rb +43 -0
- data/lib/slices/cms_form_builder.rb +42 -0
- data/lib/slices/config.rb +93 -0
- data/lib/slices/container_parser.rb +70 -0
- data/lib/slices/generator_macros.rb +36 -0
- data/lib/slices/has_attachments.rb +111 -0
- data/lib/slices/has_slices.rb +88 -0
- data/lib/slices/i18n.rb +6 -0
- data/lib/slices/i18n/backend.rb +32 -0
- data/lib/slices/i18n_backend.rb +24 -0
- data/lib/slices/paperclip.rb +13 -0
- data/lib/slices/position_helper.rb +98 -0
- data/lib/slices/renderer.rb +52 -0
- data/lib/slices/slices_engine.rb +51 -0
- data/lib/slices/split_date_time_field.rb +14 -0
- data/lib/slices/tasks/assets.rake +35 -0
- data/lib/slices/tasks/db.rake +50 -0
- data/lib/slices/tasks/seeds.rake +93 -0
- data/lib/slices/tasks/validate.rake +62 -0
- data/lib/slices/tree.rb +306 -0
- data/lib/slices/version.rb +4 -0
- data/lib/slices/will_paginate.rb +12 -0
- data/lib/slices/will_paginate_mongoid.rb +45 -0
- data/lib/standard_tree.rb +193 -0
- metadata +483 -0
@@ -0,0 +1,101 @@
|
|
1
|
+
var GenericBackbone = {
|
2
|
+
collection_prototype: {
|
3
|
+
page: 1,
|
4
|
+
total_pages: 1,
|
5
|
+
search_term: '',
|
6
|
+
search: function() {
|
7
|
+
var self = this;
|
8
|
+
$.get(self.search_url, this.search_data(), function(results) {
|
9
|
+
self.page = results.current_page;
|
10
|
+
self.total_pages = results.total_pages;
|
11
|
+
self.reset(results.items);
|
12
|
+
}, 'json');
|
13
|
+
}
|
14
|
+
|
15
|
+
},
|
16
|
+
|
17
|
+
model_prototype: {
|
18
|
+
idAttribute: '_id',
|
19
|
+
|
20
|
+
clear: function() {
|
21
|
+
this.view.remove();
|
22
|
+
this.destroy();
|
23
|
+
}
|
24
|
+
},
|
25
|
+
|
26
|
+
view_prototype: {
|
27
|
+
initialize: function() {
|
28
|
+
this.model.view = this;
|
29
|
+
},
|
30
|
+
|
31
|
+
remove: function() {
|
32
|
+
$(this.el).remove();
|
33
|
+
},
|
34
|
+
|
35
|
+
clear: function() {
|
36
|
+
this.model.clear();
|
37
|
+
return false;
|
38
|
+
},
|
39
|
+
|
40
|
+
render: function() {
|
41
|
+
$(this.el).html(this.template(this.model.for_template()));
|
42
|
+
return this;
|
43
|
+
},
|
44
|
+
},
|
45
|
+
|
46
|
+
app_view_prototype: {
|
47
|
+
render_pagination: function() {
|
48
|
+
$pagination = this.$('#pagination');
|
49
|
+
if (this.collection.total_pages === 1) {
|
50
|
+
$pagination.empty();
|
51
|
+
return
|
52
|
+
}
|
53
|
+
var self = this;
|
54
|
+
var pages = [];
|
55
|
+
for (var page = 1; page <= self.collection.total_pages; page++) {
|
56
|
+
if (page === this.collection.page) {
|
57
|
+
pages.push({num: page, klass: 'active'});
|
58
|
+
} else if ((page === this.collection.page + 1) || (page === this.collection.page -1)) {
|
59
|
+
pages.push({num: page, klass: ''})
|
60
|
+
} else if ((page <= 2) || (page > (this.collection.total_pages - 2))) {
|
61
|
+
pages.push({num: page, klass: ''})
|
62
|
+
}
|
63
|
+
}
|
64
|
+
$pagination.empty();
|
65
|
+
_.each(pages, function(page, index) {
|
66
|
+
$pagination.append($("<a />", {text: page.num, className: page.klass, href: '#'}));
|
67
|
+
if ((pages[index+1]) && (pages[index+1].num != page.num+1)) {
|
68
|
+
$pagination.append($('<span>...</span>').wrap('<li />'));
|
69
|
+
}
|
70
|
+
});
|
71
|
+
$pagination.find("a, span").wrap(document.createElement('li'));
|
72
|
+
},
|
73
|
+
|
74
|
+
paginate: function(e) {
|
75
|
+
var page_num = $(e.target).text();
|
76
|
+
this.collection.page = page_num;
|
77
|
+
this.search();
|
78
|
+
},
|
79
|
+
|
80
|
+
setup_search: function() {
|
81
|
+
var self = this;
|
82
|
+
setInterval(function() {
|
83
|
+
if ( self.search_now ) {
|
84
|
+
self.search_now = false;
|
85
|
+
self.collection.page = 1;
|
86
|
+
self.search();
|
87
|
+
}
|
88
|
+
}, 250);
|
89
|
+
},
|
90
|
+
|
91
|
+
call_search: function() {
|
92
|
+
this.search_now = true;
|
93
|
+
},
|
94
|
+
|
95
|
+
search: function() {
|
96
|
+
this.collection.search_term = this.$('#entries-search').val();
|
97
|
+
this.collection.search();
|
98
|
+
}
|
99
|
+
|
100
|
+
}
|
101
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
var SnippetsBackbone = $.extend(true, {}, GenericBackbone, {
|
2
|
+
collection_prototype: {
|
3
|
+
search_url: '/admin/snippets',
|
4
|
+
search_data: function() {
|
5
|
+
return { search: this.search_term, page: this.page }
|
6
|
+
}
|
7
|
+
},
|
8
|
+
|
9
|
+
model_prototype: {
|
10
|
+
for_template: function() {
|
11
|
+
return this.toJSON();
|
12
|
+
},
|
13
|
+
|
14
|
+
url: function() {
|
15
|
+
return "/admin/snippets/" + this.get('id');
|
16
|
+
},
|
17
|
+
},
|
18
|
+
|
19
|
+
view_prototype: {
|
20
|
+
events: {
|
21
|
+
"click a.edit": "edit"
|
22
|
+
},
|
23
|
+
|
24
|
+
edit: function(event) {
|
25
|
+
event.preventDefault();
|
26
|
+
$('#general-modal').jqm({
|
27
|
+
ajax: '/admin/snippets/' + this.model.get('id') + '/edit',
|
28
|
+
modal: false,
|
29
|
+
onHide: function (h) { h.w.fadeOut(100); h.o.fadeOut(100); },
|
30
|
+
onShow: function (h) {},
|
31
|
+
onLoad: function (h) { h.w.fadeIn(50); h.o.fadeIn(100); },
|
32
|
+
overlay: 40
|
33
|
+
}).jqmShow();
|
34
|
+
},
|
35
|
+
|
36
|
+
tagName: 'tr',
|
37
|
+
template: Handlebars.compile(
|
38
|
+
"<td>{{key}}</td>" +
|
39
|
+
"<td>{{value}}</td>" +
|
40
|
+
"<td class='action right'><a href='#' rel='nofollow' id='edit-{{id}}' class='edit button small-button'>Edit</a></td>"
|
41
|
+
)
|
42
|
+
|
43
|
+
},
|
44
|
+
|
45
|
+
app_view_prototype: {
|
46
|
+
|
47
|
+
events: {
|
48
|
+
"click #add-snippet": "create",
|
49
|
+
},
|
50
|
+
|
51
|
+
initialize: function() {
|
52
|
+
this.collection = this.options.collection;
|
53
|
+
this.view_prototype = this.options.view_prototype;
|
54
|
+
_.bindAll(this, "render");
|
55
|
+
this.collection.bind('reset', this.render);
|
56
|
+
this.bind_create();
|
57
|
+
this.search();
|
58
|
+
},
|
59
|
+
|
60
|
+
create: function() {
|
61
|
+
$('#general-modal').jqm({
|
62
|
+
ajax: '/admin/snippets/new',
|
63
|
+
modal: false,
|
64
|
+
onHide: function (h) { h.w.fadeOut(100); h.o.fadeOut(100); },
|
65
|
+
onShow: function (h) {},
|
66
|
+
onLoad: function (h) { h.w.fadeIn(50); h.o.fadeIn(100); },
|
67
|
+
overlay: 20
|
68
|
+
}).jqmShow();
|
69
|
+
},
|
70
|
+
|
71
|
+
bind_create: function() {
|
72
|
+
var self = this;
|
73
|
+
$('#general-modal').bind('ajax:success', function (event, data) {
|
74
|
+
if (_.isEmpty(data.errors)) {
|
75
|
+
self.search();
|
76
|
+
$('#general-modal').jqmHide();
|
77
|
+
} else {
|
78
|
+
_.each(data.errors, function (error, field) {
|
79
|
+
$('#snippet_' + field).parent().addClass('field_with_errors');
|
80
|
+
$('#snippet_' + field).parent().append($('<span>' + error + '</span>'));
|
81
|
+
});
|
82
|
+
}
|
83
|
+
})
|
84
|
+
},
|
85
|
+
|
86
|
+
render: function() {
|
87
|
+
var self = this;
|
88
|
+
this.$('#snippets-list tbody').empty();
|
89
|
+
_.each(this.collection.models, function(snippet) {
|
90
|
+
var view = new self.view_prototype({model: snippet});
|
91
|
+
this.$("#snippets-list tbody").append(view.render().el);
|
92
|
+
});
|
93
|
+
this.render_pagination();
|
94
|
+
}
|
95
|
+
|
96
|
+
},
|
97
|
+
|
98
|
+
bind_prototypes: function() {
|
99
|
+
this.collection_prototype = Backbone.Collection.extend(this.collection_prototype);
|
100
|
+
this.model_prototype = Backbone.Model.extend(this.model_prototype);
|
101
|
+
this.app_view_prototype.el = $('#container');
|
102
|
+
this.app_view_prototype = Backbone.View.extend(this.app_view_prototype);
|
103
|
+
this.view_prototype = Backbone.View.extend(this.view_prototype);
|
104
|
+
},
|
105
|
+
|
106
|
+
boot: function() {
|
107
|
+
this.bind_prototypes();
|
108
|
+
this.collection = new this.collection_prototype
|
109
|
+
this.collection.model = this.model_prototype
|
110
|
+
this.view = new this.app_view_prototype({collection: this.collection, view_prototype: this.view_prototype})
|
111
|
+
}
|
112
|
+
|
113
|
+
});
|
@@ -0,0 +1,61 @@
|
|
1
|
+
// Create an attachment composer for a collection
|
2
|
+
//
|
3
|
+
// Within the attachmentComposer, define the html for the fields the composer
|
4
|
+
// should display. Here, we’re assuming there’s a field on the slice called
|
5
|
+
// `myAttachments`.
|
6
|
+
//
|
7
|
+
// {{#attachmentComposer myAttachments}}
|
8
|
+
// <textarea name="caption" class="full-height">{{caption}}</textarea>
|
9
|
+
// {{/attachmentComposer}}
|
10
|
+
//
|
11
|
+
Handlebars.registerHelper('attachmentComposer', function(options) {
|
12
|
+
if (!options.hash) {
|
13
|
+
return new Handlebars.SafeString(
|
14
|
+
'<code style="color: red">' +
|
15
|
+
'DEPRECATION: Please use the new attachmentComposer syntax: ' +
|
16
|
+
'{{attachmentComposer field="example"}}' +
|
17
|
+
'</code>'
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
// Instantiate an AssetComposerView.
|
22
|
+
var composer = new slices.AttachmentComposerView({
|
23
|
+
id : slices.fieldId(this, options.hash.field),
|
24
|
+
collection : this[options.hash.field],
|
25
|
+
fields : options.fn,
|
26
|
+
autoAttach : true
|
27
|
+
});
|
28
|
+
|
29
|
+
// Return the placeholder. Don’t worry, this is replaced automatically later.
|
30
|
+
return new Handlebars.SafeString(composer.placeholder());
|
31
|
+
});
|
32
|
+
|
33
|
+
// Create a new AssetLibraryView and append it to the given `el`.
|
34
|
+
// If no `el` is given, render will write one in-place to the dom,
|
35
|
+
// and render it there.
|
36
|
+
//
|
37
|
+
// Rendering asset library at the current point in html
|
38
|
+
//
|
39
|
+
// <script>slices.renderAssetLibrary({ mode: 'full' })</script>
|
40
|
+
//
|
41
|
+
slices.renderAssetLibrary = function(options) {
|
42
|
+
options = options || {};
|
43
|
+
if (!options.el) {
|
44
|
+
document.write('<div id="asset-library" class="asset-library">');
|
45
|
+
options.el = '#asset-library';
|
46
|
+
}
|
47
|
+
return new slices.AssetLibraryView(options);
|
48
|
+
}
|
49
|
+
|
50
|
+
// Returns the singlton asset drawer, which we’d normally just send close/open.
|
51
|
+
//
|
52
|
+
// slices.assetDrawer().open();
|
53
|
+
//
|
54
|
+
slices.assetDrawer = function() {
|
55
|
+
if (!slices._assetDrawer) {
|
56
|
+
var el = $('<div id="asset-drawer" class="asset-library">').appendTo('body');
|
57
|
+
slices._assetDrawer = slices.renderAssetLibrary({ el: el, mode: 'drawer' });
|
58
|
+
}
|
59
|
+
return slices._assetDrawer;
|
60
|
+
}
|
61
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$(function() {
|
2
|
+
$('#children').on('change', function(e) {
|
3
|
+
e.preventDefault();
|
4
|
+
e.stopPropagation();
|
5
|
+
|
6
|
+
var val = $(this).val();
|
7
|
+
|
8
|
+
$(this).find('option:selected').removeAttr('selected');
|
9
|
+
$(this).find('option:first').attr('selected', 'selected');
|
10
|
+
|
11
|
+
if (val.match(/pages\/new/)) {
|
12
|
+
$('#general-modal').jqm({
|
13
|
+
ajax: val,
|
14
|
+
modal: false,
|
15
|
+
onHide: function (h) {
|
16
|
+
h.w.fadeOut(100);
|
17
|
+
h.o.fadeOut(100);
|
18
|
+
},
|
19
|
+
onShow: function (h) {},
|
20
|
+
onLoad: function (h) {
|
21
|
+
h.w.fadeIn(50);
|
22
|
+
h.o.fadeIn(100);
|
23
|
+
},
|
24
|
+
overlay: 40
|
25
|
+
}).jqmShow();
|
26
|
+
} else if (val.length > 0) {
|
27
|
+
window.location.pathname = val;
|
28
|
+
}
|
29
|
+
});
|
30
|
+
});
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// Create a composer for a given field on the model.
|
2
|
+
//
|
3
|
+
// Example:
|
4
|
+
//
|
5
|
+
// {{#composer field="ingredients"}}
|
6
|
+
// <input type="text"
|
7
|
+
// name="name"
|
8
|
+
// placeholder="Name (e.g. Cheese)..."
|
9
|
+
// value="{{name}}">
|
10
|
+
// <input type="text"
|
11
|
+
// name="amount"
|
12
|
+
// placeholder="Amount (e.g. 10kg)..."
|
13
|
+
// value="{{amount}}">
|
14
|
+
// {{/composer}}
|
15
|
+
//
|
16
|
+
Handlebars.registerHelper('composer', function(options) {
|
17
|
+
var view = new slices.ComposerView({
|
18
|
+
id : slices.fieldId(this, options.hash.field),
|
19
|
+
value : this[options.hash.field],
|
20
|
+
fields : options.fn,
|
21
|
+
addLabel : options.hash.addLabel,
|
22
|
+
autoAttach : true
|
23
|
+
});
|
24
|
+
|
25
|
+
return new Handlebars.SafeString(view.placeholder());
|
26
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
// Creates a date field.
|
2
|
+
//
|
3
|
+
// Example:
|
4
|
+
//
|
5
|
+
// {{dateField field="example"}}
|
6
|
+
//
|
7
|
+
Handlebars.registerHelper('dateField', function(options) {
|
8
|
+
var view = new slices.DateFieldView({
|
9
|
+
id : slices.fieldId(this, options.hash.field),
|
10
|
+
name : options.hash.field,
|
11
|
+
value : this[options.hash.field],
|
12
|
+
autoAttach : true
|
13
|
+
});
|
14
|
+
|
15
|
+
return new Handlebars.SafeString(view.placeholder());
|
16
|
+
});
|
@@ -0,0 +1,31 @@
|
|
1
|
+
// An all-purpose value-grabber. This method has been extracted from a couple
|
2
|
+
// of different places in the codebase, and could do with a haircut.
|
3
|
+
slices.getValue = function(inp) {
|
4
|
+
inp = $(inp);
|
5
|
+
|
6
|
+
// If the input has a computed value assigned, return it.
|
7
|
+
if (inp.data('computed-value')) {
|
8
|
+
return inp.data('computed-value');
|
9
|
+
|
10
|
+
// If the input is a special array type, return concatenated value.
|
11
|
+
} else if (inp.data('type') === 'array') {
|
12
|
+
return inp.val().split('||');
|
13
|
+
|
14
|
+
// If the input is a checkbox, return true/false for checked/unchecked.
|
15
|
+
} else if (inp.is(':checkbox')) {
|
16
|
+
return inp.is(':checked');
|
17
|
+
|
18
|
+
// If field contains a set of radio buttons, find checked and return value.
|
19
|
+
} else if (inp.is(':has(:radio)')) {
|
20
|
+
return inp.find(':checked').val();
|
21
|
+
|
22
|
+
// Otherwise, this is simple input and we just take its value normally.
|
23
|
+
} else {
|
24
|
+
return inp.val();
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
// Returns the value for a particular id.
|
29
|
+
slices.getValueForId = function(id) {
|
30
|
+
return slices.getValue('#' + id);
|
31
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
$(function() {
|
2
|
+
|
3
|
+
$(window).scroll(function() {
|
4
|
+
if ($(window).scrollTop() >= 40) {
|
5
|
+
$('#container-actions').css({
|
6
|
+
position : 'fixed',
|
7
|
+
top : '0',
|
8
|
+
width : '100%'
|
9
|
+
});
|
10
|
+
} else {
|
11
|
+
$('#container-actions').css({
|
12
|
+
position : 'absolute',
|
13
|
+
top : '40px',
|
14
|
+
width : '100%'
|
15
|
+
});
|
16
|
+
}
|
17
|
+
});
|
18
|
+
|
19
|
+
});
|
20
|
+
|
@@ -0,0 +1,150 @@
|
|
1
|
+
$(function () {
|
2
|
+
|
3
|
+
var KEY_ESC = 27;
|
4
|
+
|
5
|
+
var locked = true;
|
6
|
+
|
7
|
+
function serialiseSitemap(ul) {
|
8
|
+
var children = [];
|
9
|
+
ul.find('>li:not(.set-link)').each(
|
10
|
+
|
11
|
+
function () {
|
12
|
+
var li = $(this);
|
13
|
+
var item = { id: li.attr('rel') }
|
14
|
+
var childHolder = li.find('>ol');
|
15
|
+
if (childHolder.length && childHolder.find('>li:not(.set-link)').length) {
|
16
|
+
item.children = serialiseSitemap(childHolder);
|
17
|
+
}
|
18
|
+
children.push(item);
|
19
|
+
}
|
20
|
+
);
|
21
|
+
return children;
|
22
|
+
}
|
23
|
+
|
24
|
+
function filterSitemap(needle){
|
25
|
+
|
26
|
+
var show = [];
|
27
|
+
var hide = [];
|
28
|
+
|
29
|
+
$('#sitemap li h2, #virtual-pages li h2').each(function(){
|
30
|
+
if ($(this).text().search(new RegExp(needle, "i")) > -1) {
|
31
|
+
show.push( $(this).closest('li')[0] );
|
32
|
+
} else {
|
33
|
+
hide.push( $(this).closest('li')[0] );
|
34
|
+
}
|
35
|
+
});
|
36
|
+
|
37
|
+
$(hide).find('div').hide();
|
38
|
+
$(show).find('div').show();
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
var searchField = $('#sitemap-search');
|
43
|
+
|
44
|
+
if (searchField.length) {
|
45
|
+
|
46
|
+
searchField.on('keyup click', function(event) {
|
47
|
+
// ESC key handing
|
48
|
+
if (event.which === KEY_ESC) {
|
49
|
+
if ($(this).val() !== '') {
|
50
|
+
$(this).val('');
|
51
|
+
} else {
|
52
|
+
$(this).blur();
|
53
|
+
return;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
filterSitemap($(this).val());
|
58
|
+
});
|
59
|
+
|
60
|
+
// Cmd/ctrl + F focuses the search field.
|
61
|
+
$(document).on('keypress', function(event) {
|
62
|
+
if (
|
63
|
+
(event.which === 102 && event.metaKey) || // cmd + F
|
64
|
+
(event.which === 6 && event.ctrlKey) // ctrl + F
|
65
|
+
) {
|
66
|
+
event.preventDefault();
|
67
|
+
searchField.focus();
|
68
|
+
}
|
69
|
+
});
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
$('#sitemap-form').bind('submit', function (e) {
|
74
|
+
if (locked) { return false; }
|
75
|
+
var sitemap = serialiseSitemap($('#sitemap'));
|
76
|
+
$.ajax({
|
77
|
+
url: '/admin/site_maps/update',
|
78
|
+
type: 'PUT',
|
79
|
+
data: JSON.stringify({ sitemap: sitemap }),
|
80
|
+
contentType: 'application/json',
|
81
|
+
dataType: 'json',
|
82
|
+
success: function (data, statusText, xhr) {
|
83
|
+
// TODO:
|
84
|
+
},
|
85
|
+
error: function (xhr, textStatus, errorThrown) {
|
86
|
+
// TODO:
|
87
|
+
}
|
88
|
+
});
|
89
|
+
return false;
|
90
|
+
});
|
91
|
+
|
92
|
+
$('.add-child').bind('click', function () {
|
93
|
+
$('#general-modal').jqm({
|
94
|
+
ajax: this.href,
|
95
|
+
modal: false,
|
96
|
+
onHide: function (h) {
|
97
|
+
h.w.fadeOut(100);
|
98
|
+
h.o.fadeOut(100);
|
99
|
+
},
|
100
|
+
onShow: function (h) {},
|
101
|
+
onLoad: function (h) {
|
102
|
+
h.w.fadeIn(50);
|
103
|
+
h.o.fadeIn(100);
|
104
|
+
},
|
105
|
+
overlay: 40
|
106
|
+
}).jqmShow();
|
107
|
+
return false;
|
108
|
+
});
|
109
|
+
|
110
|
+
$('a.delete').toggle();
|
111
|
+
$('#structure-locked a').bind('click', function() {
|
112
|
+
locked = !locked;
|
113
|
+
$('#sitemap').toggleClass('unlocked');
|
114
|
+
$('#structure-locked, #structure-unlocked').toggle();
|
115
|
+
$('a.delete').toggle();
|
116
|
+
if (!locked) {
|
117
|
+
$('html').addClass('sitemap-unlocked');
|
118
|
+
} else {
|
119
|
+
$('html').removeClass('sitemap-unlocked');
|
120
|
+
}
|
121
|
+
|
122
|
+
$sitemap = $('#sitemap > li > ol');
|
123
|
+
$sitemap.nestedSortable({
|
124
|
+
forcePlaceholderSize : true,
|
125
|
+
toleranceElement : '> div',
|
126
|
+
disableNesting : 'no-nest',
|
127
|
+
placeholder : 'placeholder',
|
128
|
+
errorClass : 'nested-error',
|
129
|
+
tolerance : 'pointer',
|
130
|
+
tabSize : 25,
|
131
|
+
opacity : 0.6,
|
132
|
+
scroll : false,
|
133
|
+
handle : 'div',
|
134
|
+
items : 'li',
|
135
|
+
|
136
|
+
beforeStart: function() {
|
137
|
+
$sitemap.freezeHeight();
|
138
|
+
window.autoscroll.start();
|
139
|
+
},
|
140
|
+
stop: function() {
|
141
|
+
$sitemap.thawHeight();
|
142
|
+
window.autoscroll.stop();
|
143
|
+
}
|
144
|
+
});
|
145
|
+
|
146
|
+
return false;
|
147
|
+
});
|
148
|
+
|
149
|
+
});
|
150
|
+
|