pages_core 3.4.3 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +81 -15
- data/Rakefile +1 -1
- data/app/assets/javascripts/pages/admin.es6.jsx +19 -0
- data/app/assets/javascripts/pages/admin/components.es6.jsx +1 -0
- data/app/assets/javascripts/pages/admin/components/page_tree.es6.jsx +330 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_actions.es6.jsx +8 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_node.es6.jsx +374 -0
- data/app/assets/javascripts/pages/admin/components/page_tree_store.es6.jsx +161 -0
- data/app/assets/javascripts/pages/admin/features/content_tabs.es6.jsx +63 -0
- data/app/assets/javascripts/pages/admin/features/edit_page.es6.jsx +141 -0
- data/app/assets/javascripts/pages/admin/features/editable_image.es6.jsx +145 -0
- data/app/assets/javascripts/pages/admin/features/modal.es6.jsx +90 -0
- data/app/assets/javascripts/pages/admin/features/page_images.es6.jsx +338 -0
- data/app/assets/javascripts/pages/admin/features/rich_text.es6.jsx +124 -0
- data/app/assets/javascripts/pages/admin/features/tag_editor.es6.jsx +160 -0
- data/app/assets/javascripts/pages/admin/lib/ajax_extensions.es6.jsx +21 -0
- data/app/assets/javascripts/pages/admin/lib/center_on_screen.es6.jsx +22 -0
- data/app/assets/javascripts/pages/admin/lib/tree.es6.jsx +294 -0
- data/app/assets/javascripts/pages/login_form.es6.jsx +21 -0
- data/app/assets/stylesheets/pages/admin.scss +148 -0
- data/app/assets/stylesheets/pages/admin/components/buttons.scss +5 -0
- data/app/assets/stylesheets/pages/admin/{editable_image.css.erb → components/editable_image.scss} +7 -8
- data/app/assets/stylesheets/pages/admin/components/forms.scss +71 -0
- data/app/assets/stylesheets/pages/admin/components/header.scss +169 -0
- data/app/assets/stylesheets/pages/admin/{images.css.scss.erb → components/images.scss} +6 -11
- data/app/assets/stylesheets/pages/admin/components/layout.scss +44 -0
- data/app/assets/stylesheets/pages/admin/components/links.scss +43 -0
- data/app/assets/stylesheets/pages/admin/components/list_table.scss +58 -0
- data/app/assets/stylesheets/pages/admin/{login.css.scss.erb → components/login.scss} +1 -1
- data/app/assets/stylesheets/pages/admin/{modal.css.erb → components/modal.scss} +3 -2
- data/app/assets/stylesheets/pages/admin/components/page_tree.scss +173 -0
- data/app/assets/stylesheets/pages/admin/{pagination.css.scss → components/pagination.scss} +13 -4
- data/app/assets/stylesheets/pages/admin/components/sidebar.scss +25 -0
- data/app/assets/stylesheets/pages/admin/{tag_editor.css.scss.erb → components/tag_editor.scss} +6 -0
- data/app/assets/stylesheets/pages/admin/components/textarea.scss +76 -0
- data/app/assets/stylesheets/pages/admin/controllers/pages.scss +196 -0
- data/app/assets/stylesheets/pages/admin/controllers/{users.css.erb → users.scss} +0 -0
- data/app/assets/stylesheets/pages/admin/mixins/breakpoints.scss +21 -0
- data/app/assets/stylesheets/pages/admin/mixins/clearfix.scss +7 -0
- data/app/assets/stylesheets/pages/admin/mixins/gradients.scss +7 -0
- data/app/assets/stylesheets/pages/admin/{print.css.erb → print.scss} +0 -0
- data/app/assets/stylesheets/pages/admin/vars.scss +8 -0
- data/app/controllers/admin/invites_controller.rb +10 -6
- data/app/controllers/admin/page_files_controller.rb +6 -8
- data/app/controllers/admin/page_images_controller.rb +14 -19
- data/app/controllers/admin/pages_controller.rb +44 -97
- data/app/controllers/admin/password_resets_controller.rb +7 -2
- data/app/controllers/concerns/pages_core/add_comments_controller.rb +67 -0
- data/app/controllers/concerns/pages_core/admin/news_page_controller.rb +58 -0
- data/app/controllers/concerns/pages_core/authentication.rb +1 -1
- data/app/controllers/concerns/pages_core/exception_handler.rb +44 -21
- data/app/controllers/concerns/pages_core/policies_helper.rb +10 -6
- data/app/controllers/concerns/pages_core/preview_pages_controller.rb +43 -0
- data/app/controllers/concerns/pages_core/process_titler.rb +2 -2
- data/app/controllers/concerns/pages_core/rss_controller.rb +25 -0
- data/app/controllers/concerns/pages_core/search_pages_controller.rb +40 -0
- data/app/controllers/errors_controller.rb +14 -2
- data/app/controllers/pages_core/admin_controller.rb +7 -5
- data/app/controllers/pages_core/frontend/page_files_controller.rb +5 -7
- data/app/controllers/pages_core/frontend/pages_controller.rb +41 -219
- data/app/controllers/pages_core/frontend_controller.rb +8 -2
- data/app/controllers/pages_core/sitemaps_controller.rb +5 -4
- data/app/formatters/pages_core/html_formatter.rb +33 -23
- data/app/helpers/admin/menu_helper.rb +12 -9
- data/app/helpers/admin/pages_helper.rb +40 -28
- data/app/helpers/pages_core/admin/admin_helper.rb +58 -56
- data/app/helpers/pages_core/admin/labelled_field_helper.rb +6 -7
- data/app/helpers/pages_core/admin/tag_editor_helper.rb +11 -9
- data/app/helpers/pages_core/application_helper.rb +13 -26
- data/app/helpers/pages_core/form_builder.rb +71 -134
- data/app/helpers/pages_core/head_tags_helper.rb +26 -168
- data/app/helpers/pages_core/images_helper.rb +3 -3
- data/app/helpers/pages_core/meta_tags_helper.rb +96 -0
- data/app/helpers/pages_core/open_graph_tags_helper.rb +51 -0
- data/app/helpers/pages_core/page_path_helper.rb +40 -0
- data/app/mailers/admin_mailer.rb +14 -14
- data/app/models/autopublisher.rb +2 -2
- data/app/models/category.rb +8 -8
- data/app/models/concerns/pages_core/has_roles.rb +2 -2
- data/app/models/concerns/pages_core/humanizable_param.rb +5 -5
- data/app/models/concerns/pages_core/page_model/autopublishable.rb +25 -0
- data/app/models/concerns/pages_core/page_model/commentable.rb +29 -0
- data/app/models/concerns/pages_core/page_model/images.rb +50 -0
- data/app/models/concerns/pages_core/page_model/localizable.rb +29 -0
- data/app/models/concerns/pages_core/page_model/pathable.rb +115 -0
- data/app/models/concerns/pages_core/page_model/redirectable.rb +36 -0
- data/app/models/concerns/pages_core/page_model/searchable.rb +41 -0
- data/app/models/concerns/pages_core/page_model/sortable.rb +54 -0
- data/app/models/concerns/pages_core/page_model/status.rb +50 -0
- data/app/models/concerns/pages_core/page_model/templateable.rb +82 -0
- data/app/models/concerns/pages_core/page_model/tree.rb +108 -0
- data/app/models/page.rb +30 -212
- data/app/models/page_builder.rb +4 -6
- data/app/models/page_category.rb +7 -0
- data/app/models/page_comment.rb +1 -1
- data/app/models/page_file.rb +4 -6
- data/app/models/page_image.rb +6 -7
- data/app/models/page_path.rb +46 -0
- data/app/models/password_reset_token.rb +5 -5
- data/app/models/role.rb +1 -1
- data/app/models/tag.rb +14 -16
- data/app/models/tagging.rb +2 -1
- data/app/models/user.rb +6 -7
- data/app/policies/page_policy.rb +8 -4
- data/app/policies/user_policy.rb +1 -1
- data/app/serializers/page_tree_serializer.rb +15 -0
- data/app/views/admin/invites/new.html.erb +2 -1
- data/app/views/admin/invites/show.html.erb +3 -4
- data/app/views/admin/pages/_edit_comments.html.erb +22 -6
- data/app/views/admin/pages/_edit_content.html.erb +4 -2
- data/app/views/admin/pages/_edit_images.html.erb +86 -75
- data/app/views/admin/pages/_edit_metadata.html.erb +22 -0
- data/app/views/admin/pages/_edit_options.html.erb +23 -15
- data/app/views/admin/pages/_pagelisting.html.erb +6 -6
- data/app/views/admin/pages/edit.html.erb +11 -6
- data/app/views/admin/pages/index.html.erb +12 -53
- data/app/views/admin/pages/new.html.erb +3 -3
- data/app/views/admin/pages/news.html.erb +1 -1
- data/app/views/admin_mailer/invite.text.erb +1 -1
- data/app/views/admin_mailer/password_reset.text.erb +1 -1
- data/app/views/errors/422.html.erb +7 -0
- data/app/views/errors/500_critical.html.erb +1 -1
- data/app/views/layouts/admin.html.erb +36 -32
- data/app/views/layouts/admin/_header.html.erb +2 -2
- data/config/locales/en.yml +38 -1
- data/config/routes.rb +40 -23
- data/db/migrate/20111219033112_create_pages_tables.rb +25 -29
- data/db/migrate/20121010055412_drop_removed_tables.rb +3 -3
- data/db/migrate/20130823133208_update_page_redirect_to.rb +0 -13
- data/db/migrate/20140203183900_create_roles.rb +5 -2
- data/db/migrate/20140920231700_convert_images_to_dis.rb +4 -2
- data/db/migrate/20150401131300_localize_images.rb +7 -8
- data/db/migrate/20151002174800_create_page_paths.rb +10 -0
- data/db/migrate/20151021103400_drop_binaries_table.rb +7 -0
- data/db/migrate/20151204151000_remove_page_content_order.rb +5 -0
- data/db/migrate/20160330220900_rename_pages_categories.rb +6 -0
- data/db/migrate/20160405202700_change_localization_limit.rb +9 -0
- data/lib/pages_core.rb +22 -27
- data/lib/pages_core/admin_menu_item.rb +16 -3
- data/lib/pages_core/archive_finder.rb +40 -13
- data/lib/pages_core/cache_sweeper.rb +72 -45
- data/lib/pages_core/configuration.rb +2 -2
- data/lib/pages_core/configuration/base.rb +4 -8
- data/lib/pages_core/configuration/pages.rb +6 -3
- data/lib/pages_core/engine.rb +23 -1
- data/lib/pages_core/extensions.rb +2 -2
- data/lib/pages_core/file_embedder.rb +40 -0
- data/lib/pages_core/page_path_constraint.rb +23 -0
- data/lib/pages_core/pages_plugin.rb +11 -0
- data/lib/pages_core/paginates.rb +3 -3
- data/lib/pages_core/plugin.rb +14 -8
- data/lib/pages_core/templates.rb +6 -6
- data/lib/pages_core/templates/block_configuration.rb +1 -1
- data/lib/pages_core/templates/configuration.rb +23 -24
- data/lib/pages_core/templates/configuration_handler.rb +1 -1
- data/lib/pages_core/templates/configuration_proxy.rb +7 -11
- data/lib/pages_core/templates/template_configuration.rb +55 -61
- data/lib/pages_core/version.rb +1 -1
- data/lib/rails/generators/pages_core/install/install_generator.rb +22 -48
- data/lib/rails/generators/pages_core/install/templates/page_templates_initializer.rb +1 -1
- data/lib/rails/generators/pages_core/install/templates/pages_initializer.rb +6 -3
- data/lib/rails/generators/pages_core/rspec/rspec_generator.rb +4 -1
- data/lib/rails/generators/pages_core/rspec/templates/factories.rb +1 -1
- data/lib/tasks/pages.rake +4 -4
- data/lib/tasks/pages/page_paths.rake +12 -0
- data/template.rb +2 -2
- data/vendor/assets/javascripts/reflux.min.js +1 -0
- metadata +173 -85
- data/app/assets/images/pages/admin/description-bg.gif +0 -0
- data/app/assets/images/pages/admin/drag-handle.gif +0 -0
- data/app/assets/images/pages/admin/flash-error-bg.gif +0 -0
- data/app/assets/images/pages/admin/formelement-bg.gif +0 -0
- data/app/assets/images/pages/admin/header-tab-current-bg.gif +0 -0
- data/app/assets/images/pages/admin/list-table-td-bg.gif +0 -0
- data/app/assets/images/pages/admin/sidebar-bg.gif +0 -0
- data/app/assets/images/pages/admin/textarea_controls.gif +0 -0
- data/app/assets/javascripts/pages/admin.js.coffee +0 -54
- data/app/assets/javascripts/pages/admin/controllers/base.js.coffee +0 -4
- data/app/assets/javascripts/pages/admin/controllers/pages_controller.js.coffee +0 -139
- data/app/assets/javascripts/pages/admin/controllers/users_controller.js.coffee +0 -9
- data/app/assets/javascripts/pages/admin/features/content_tabs.js.coffee +0 -47
- data/app/assets/javascripts/pages/admin/features/editable_image.js.coffee.erb +0 -122
- data/app/assets/javascripts/pages/admin/features/modal.js.coffee +0 -66
- data/app/assets/javascripts/pages/admin/features/page_images.js +0 -329
- data/app/assets/javascripts/pages/admin/features/rich_text.js.coffee +0 -40
- data/app/assets/javascripts/pages/admin/features/tag_editor.js +0 -159
- data/app/assets/javascripts/pages/admin/lib/ajax_extensions.js.coffee +0 -17
- data/app/assets/javascripts/pages/admin/lib/center_on_screen.js.coffee +0 -21
- data/app/assets/javascripts/pages/admin/lib/jrichtextarea.js +0 -57
- data/app/assets/javascripts/pages/login_form.js.coffee +0 -17
- data/app/assets/stylesheets/pages/admin.css.erb +0 -404
- data/app/assets/stylesheets/pages/admin/buttons.css.erb +0 -5
- data/app/assets/stylesheets/pages/admin/controllers/artists.css.erb +0 -94
- data/app/assets/stylesheets/pages/admin/controllers/files.css.erb +0 -58
- data/app/assets/stylesheets/pages/admin/controllers/pages.css.scss.erb +0 -178
- data/app/assets/stylesheets/pages/admin/forms.css.scss.erb +0 -73
- data/app/assets/stylesheets/pages/admin/header.css.erb +0 -129
- data/app/assets/stylesheets/pages/admin/links.css.erb +0 -34
- data/app/assets/stylesheets/pages/admin/list_table.css.erb +0 -56
- data/app/assets/stylesheets/pages/admin/sidebar.css.erb +0 -39
- data/app/assets/stylesheets/pages/admin/sortable_images.css.erb +0 -18
- data/app/assets/stylesheets/pages/admin/textarea.css.erb +0 -55
- data/app/models/concerns/pages_core/page_tree.rb +0 -85
- data/app/models/concerns/pages_core/searchable_page.rb +0 -33
- data/app/models/concerns/pages_core/templateable.rb +0 -85
- data/app/models/localization.rb +0 -27
- data/db/migrate/20140515130100_remove_sphinx_deltas.rb +0 -15
- data/lib/pages_core/localizable.rb +0 -49
- data/lib/pages_core/localizable/active_record_extension.rb +0 -41
- data/lib/pages_core/localizable/class_methods.rb +0 -51
- data/lib/pages_core/localizable/configuration.rb +0 -50
- data/lib/pages_core/localizable/instance_methods.rb +0 -130
- data/lib/pages_core/localizable/localizer.rb +0 -72
- data/lib/pages_core/localizable/scope_extension.rb +0 -22
@@ -0,0 +1,63 @@
|
|
1
|
+
var ContentTabs = {
|
2
|
+
tabs: [],
|
3
|
+
ids: [],
|
4
|
+
|
5
|
+
show: function(id) {
|
6
|
+
let tabs = ContentTabs.tabs;
|
7
|
+
let tab = tabs[id];
|
8
|
+
if (tab) {
|
9
|
+
$.each(ContentTabs.ids, function(i) {
|
10
|
+
if (tabs[this]) {
|
11
|
+
$(tabs[this]).hide();
|
12
|
+
}
|
13
|
+
$("#content-tab-link-" + this).removeClass("current");
|
14
|
+
});
|
15
|
+
$(tab).show();
|
16
|
+
$("#content-tab-link-" + id).addClass("current");
|
17
|
+
}
|
18
|
+
},
|
19
|
+
|
20
|
+
showFromURL: function(url) {
|
21
|
+
let tab_expression = /#(.*)$/;
|
22
|
+
if (url.toString().match(tab_expression)) {
|
23
|
+
let id = url.toString().match(tab_expression)[1];
|
24
|
+
if (ContentTabs.tabs[id]) {
|
25
|
+
ContentTabs.show(id);
|
26
|
+
}
|
27
|
+
}
|
28
|
+
},
|
29
|
+
|
30
|
+
enable: function(ids) {
|
31
|
+
let tabs = ContentTabs.tabs;
|
32
|
+
ContentTabs.ids = ids;
|
33
|
+
$.each(ids, function(i) {
|
34
|
+
let id = this;
|
35
|
+
return $("#content-tab-" + this).each(function(i) {
|
36
|
+
this.id = id;
|
37
|
+
return tabs[id] = this;
|
38
|
+
});
|
39
|
+
});
|
40
|
+
ContentTabs.show(ids[0]);
|
41
|
+
ContentTabs.showFromURL(document.location);
|
42
|
+
},
|
43
|
+
|
44
|
+
init: function() {
|
45
|
+
if ($("#content-tabs").length > 0) {
|
46
|
+
let tabNames = $("#content-tabs li").map(function() {
|
47
|
+
return $(this).data("tab-name");
|
48
|
+
}).get();
|
49
|
+
ContentTabs.enable(tabNames);
|
50
|
+
$("#content-tabs a").each(function() {
|
51
|
+
$(this).click(function() {
|
52
|
+
ContentTabs.showFromURL(this.href);
|
53
|
+
return false;
|
54
|
+
});
|
55
|
+
});
|
56
|
+
}
|
57
|
+
window.showContentTab = ContentTabs.show;
|
58
|
+
}
|
59
|
+
};
|
60
|
+
|
61
|
+
$(function() {
|
62
|
+
ContentTabs.init();
|
63
|
+
});
|
@@ -0,0 +1,141 @@
|
|
1
|
+
class EditPage {
|
2
|
+
constructor() {
|
3
|
+
this.toggleAdvancedOptions();
|
4
|
+
this.replicateFormElements();
|
5
|
+
this.checkPublishedStatus();
|
6
|
+
this.checkPublishedDate();
|
7
|
+
this.uploadModals();
|
8
|
+
this.fileList();
|
9
|
+
this.previewButton();
|
10
|
+
}
|
11
|
+
|
12
|
+
checkPublishedStatus() {
|
13
|
+
let checkStatus = function() {
|
14
|
+
var pageStatus = $("#page-form-sidebar #page_status").val();
|
15
|
+
if (pageStatus === "2") {
|
16
|
+
return $("#page-form-sidebar .published-date").fadeIn();
|
17
|
+
} else {
|
18
|
+
return $("#page-form-sidebar .published-date").hide();
|
19
|
+
}
|
20
|
+
};
|
21
|
+
$("#page-form-sidebar #page_status").change(checkStatus);
|
22
|
+
checkStatus();
|
23
|
+
}
|
24
|
+
|
25
|
+
checkPublishedDate() {
|
26
|
+
$(".autopublish-notice").hide();
|
27
|
+
let publishedAt = function(i) {
|
28
|
+
return $(`#page-form-sidebar select[name="page[published_at(${i}i)]"]`)
|
29
|
+
.val();
|
30
|
+
}
|
31
|
+
let checkDate = function() {
|
32
|
+
var year = publishedAt(1);
|
33
|
+
var month = publishedAt(2);
|
34
|
+
var day = publishedAt(3);
|
35
|
+
var hour = publishedAt(4);
|
36
|
+
var minute = publishedAt(5);
|
37
|
+
var publishDate = new Date(year, (month - 1), day, hour, minute);
|
38
|
+
var now = new Date();
|
39
|
+
if (publishDate > now) {
|
40
|
+
return $(".autopublish-notice").fadeIn();
|
41
|
+
} else {
|
42
|
+
return $(".autopublish-notice").fadeOut();
|
43
|
+
}
|
44
|
+
};
|
45
|
+
$(".published-date").find("select").change(checkDate);
|
46
|
+
checkDate();
|
47
|
+
}
|
48
|
+
|
49
|
+
fileList() {
|
50
|
+
// Reordering files
|
51
|
+
$(".file-list").each(function() {
|
52
|
+
var list = this;
|
53
|
+
return $(list).sortable({
|
54
|
+
axis: "y",
|
55
|
+
cursor: "move",
|
56
|
+
distance: 10,
|
57
|
+
handle: ".drag-handle",
|
58
|
+
placeholder: "placeholder",
|
59
|
+
|
60
|
+
update() {
|
61
|
+
return $.post( $(list).data('url'), { ids: ((() => {
|
62
|
+
var result = [];
|
63
|
+
var iterable = $(list).find('li').get();
|
64
|
+
for (var i = 0, item; i < iterable.length; i++) {
|
65
|
+
item = iterable[i];
|
66
|
+
result.push($(item).data('file-id'));
|
67
|
+
}
|
68
|
+
return result;
|
69
|
+
})()) }, function() {
|
70
|
+
return $(list).effect("highlight", {}, 500);
|
71
|
+
}
|
72
|
+
);
|
73
|
+
}
|
74
|
+
});
|
75
|
+
});
|
76
|
+
}
|
77
|
+
|
78
|
+
previewButton() {
|
79
|
+
$("#previewButton").click(function() {
|
80
|
+
var button = this;
|
81
|
+
var form = $(button).closest("form").get(0);
|
82
|
+
var previewUrl = $(this).data('url');
|
83
|
+
|
84
|
+
// Rewrite the form and submit
|
85
|
+
form.oldAction = form.action;
|
86
|
+
form.target = "_blank";
|
87
|
+
form.action = previewUrl;
|
88
|
+
$(form).submit();
|
89
|
+
|
90
|
+
// Undo rewrite
|
91
|
+
form.action = form.oldAction;
|
92
|
+
form.target = "";
|
93
|
+
});
|
94
|
+
}
|
95
|
+
|
96
|
+
replicateFormElements() {
|
97
|
+
let replicateFormElement = function() {
|
98
|
+
var newValue = this;
|
99
|
+
$("#page-form").find("[name=\"" + newValue.name + "\"]")
|
100
|
+
.each(function() {
|
101
|
+
if (newValue.type === "checkbox") {
|
102
|
+
$(this).prop("checked", $(newValue).prop("checked"));
|
103
|
+
} else {
|
104
|
+
$(this).val($(newValue).val());
|
105
|
+
}
|
106
|
+
});
|
107
|
+
};
|
108
|
+
|
109
|
+
$("#page-form-sidebar")
|
110
|
+
.find("input,textarea,select")
|
111
|
+
.change(replicateFormElement);
|
112
|
+
}
|
113
|
+
|
114
|
+
toggleAdvancedOptions() {
|
115
|
+
$(".advanced-options").hide();
|
116
|
+
$(".advanced-toggle").click(function() {
|
117
|
+
return $(".advanced-options").slideToggle();
|
118
|
+
});
|
119
|
+
}
|
120
|
+
|
121
|
+
uploadModals() {
|
122
|
+
$("#new-image").hide();
|
123
|
+
$("#new-file").hide();
|
124
|
+
$(".upload-images-button").click(function() {
|
125
|
+
return Modal.show(
|
126
|
+
"<div class=\"uploadImages\">" + $("#new-image").html() + "</div>"
|
127
|
+
);
|
128
|
+
});
|
129
|
+
$(".upload-file-button").click(function() {
|
130
|
+
return Modal.show(
|
131
|
+
"<div class=\"uploadImages\">" + $("#new-file").html() + "</div>"
|
132
|
+
);
|
133
|
+
});
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
$(function () {
|
138
|
+
$('.edit-page').each(function() {
|
139
|
+
new EditPage(this)}
|
140
|
+
);
|
141
|
+
});
|
@@ -0,0 +1,145 @@
|
|
1
|
+
var EditableImage = function(link, options) {
|
2
|
+
let settings = $.extend({
|
3
|
+
resourceURL: link.href,
|
4
|
+
width: 800
|
5
|
+
}, options);
|
6
|
+
|
7
|
+
this.editableImage = {
|
8
|
+
settings: settings,
|
9
|
+
link: link,
|
10
|
+
linkedImage: $(link).children("img")[0],
|
11
|
+
resourceURL: settings.resourceURL,
|
12
|
+
editorDialog: false,
|
13
|
+
imageData: false,
|
14
|
+
previewURL: false,
|
15
|
+
cropStartX: false,
|
16
|
+
cropStartY: false,
|
17
|
+
cropWidth: false,
|
18
|
+
cropHeight: false,
|
19
|
+
|
20
|
+
getScale: function() {
|
21
|
+
return this.settings.width / this.imageData.real_width;
|
22
|
+
},
|
23
|
+
|
24
|
+
openEditor: function() {
|
25
|
+
$.dimScreen(200, 0.90);
|
26
|
+
$("body").append(
|
27
|
+
"<div id=\"modalLoadingNotice\">" +
|
28
|
+
"<img src=\"<%= image_path('pages/admin/loading-modal.gif') %>\" /> " +
|
29
|
+
"Loading image editor…</div>"
|
30
|
+
);
|
31
|
+
$("#modalLoadingNotice").centerOnScreen().hide().fadeIn(200);
|
32
|
+
$("#editableImageEditor").remove();
|
33
|
+
$("body").append(
|
34
|
+
"<div id=\"editableImageEditor\" class=\"modal-window\"></div>"
|
35
|
+
);
|
36
|
+
|
37
|
+
let binding = this;
|
38
|
+
if (!this.imageData) {
|
39
|
+
$.getJSON(this.resourceURL + ".js", function(json) {
|
40
|
+
binding.imageData = json;
|
41
|
+
binding.populateEditor();
|
42
|
+
});
|
43
|
+
} else {
|
44
|
+
this.populateEditor();
|
45
|
+
}
|
46
|
+
},
|
47
|
+
|
48
|
+
populateEditor: function() {
|
49
|
+
let binding = this;
|
50
|
+
|
51
|
+
let onCrop = function(coords) {
|
52
|
+
binding.cropStartX = coords.x;
|
53
|
+
binding.cropStartY = coords.y;
|
54
|
+
binding.cropWidth = coords.w;
|
55
|
+
return binding.cropHeight = coords.h;
|
56
|
+
};
|
57
|
+
|
58
|
+
$("#editableImageEditor").empty().append(
|
59
|
+
"<img id=\"editableImageEditorImage\" />"
|
60
|
+
).append(
|
61
|
+
"<div id=\"editableImageEditorControls\" class=\"controls\" />"
|
62
|
+
).hide();
|
63
|
+
|
64
|
+
$("#editableImageEditorControls").append(
|
65
|
+
"<input type=\"button\" id=\"editableImageEditorSubmit\" " +
|
66
|
+
"value=\"Save\" />"
|
67
|
+
).append(
|
68
|
+
"<input type=\"button\" id=\"editableImageEditorClose\" " +
|
69
|
+
"value=\"Cancel\" />"
|
70
|
+
);
|
71
|
+
|
72
|
+
this.previewURL = $(link).data('preview-url');
|
73
|
+
|
74
|
+
$("#editableImageEditorImage").each(function() {
|
75
|
+
return this.src = binding.previewURL;
|
76
|
+
});
|
77
|
+
$("#editableImageEditorSubmit").click(function() {
|
78
|
+
return binding.submit();
|
79
|
+
});
|
80
|
+
$("#editableImageEditorClose").click(function() {
|
81
|
+
return binding.closeEditor();
|
82
|
+
});
|
83
|
+
|
84
|
+
$("#editableImageEditorImage").load(function() {
|
85
|
+
let imageData = binding.imageData;
|
86
|
+
let cropStartX = Math.round(imageData.cropStartX * binding.getScale());
|
87
|
+
let cropStartY = Math.round(imageData.cropStartY * binding.getScale());
|
88
|
+
|
89
|
+
var cropEndX, cropEndY;
|
90
|
+
var jCropOptions = {
|
91
|
+
onChange: onCrop,
|
92
|
+
onSelect: onCrop
|
93
|
+
};
|
94
|
+
|
95
|
+
$("#modalLoadingNotice").fadeOut(100);
|
96
|
+
$("#editableImageEditor").show().centerOnScreen();
|
97
|
+
|
98
|
+
if (imageData.crop_width && imageData.crop_height) {
|
99
|
+
cropEndX = cropStartX +
|
100
|
+
Math.round(imageData.crop_width * binding.getScale());
|
101
|
+
cropEndY = cropStartY +
|
102
|
+
Math.round(imageData.crop_height * binding.getScale());
|
103
|
+
} else {
|
104
|
+
cropEndX = Math.round(imageData.real_width * binding.getScale());
|
105
|
+
cropEndY = Math.round(imageData.real_height * binding.getScale());
|
106
|
+
}
|
107
|
+
|
108
|
+
jCropOptions["setSelect"] = [cropStartX, cropStartY, cropEndX, cropEndY];
|
109
|
+
return $("#editableImageEditorImage").Jcrop(jCropOptions);
|
110
|
+
});
|
111
|
+
},
|
112
|
+
|
113
|
+
closeEditor: function() {
|
114
|
+
$("#modalLoadingNotice").remove();
|
115
|
+
$("#editableImageEditor").remove();
|
116
|
+
this.imageData = false;
|
117
|
+
$.dimScreenStop();
|
118
|
+
},
|
119
|
+
|
120
|
+
submit: function() {
|
121
|
+
let binding = this;
|
122
|
+
let data = {
|
123
|
+
"image[crop_start_x]": Math.floor(this.cropStartX / this.getScale()),
|
124
|
+
"image[crop_start_y]": Math.floor(this.cropStartY / this.getScale()),
|
125
|
+
"image[crop_width]": Math.floor(this.cropWidth / this.getScale()),
|
126
|
+
"image[crop_height]": Math.floor(this.cropHeight / this.getScale())
|
127
|
+
};
|
128
|
+
$.put(this.resourceURL + ".json", data, function(json) {
|
129
|
+
binding.closeEditor();
|
130
|
+
});
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
link.editableImage = this.editableImage;
|
135
|
+
$(link).click(function() {
|
136
|
+
this.editableImage.openEditor();
|
137
|
+
return false;
|
138
|
+
});
|
139
|
+
};
|
140
|
+
|
141
|
+
$(function() {
|
142
|
+
$("a.editableImage").each(function() {
|
143
|
+
new EditableImage(this);
|
144
|
+
});
|
145
|
+
});
|
@@ -0,0 +1,90 @@
|
|
1
|
+
window.Modal = {
|
2
|
+
container: false,
|
3
|
+
|
4
|
+
makeContainer: function() {
|
5
|
+
let modal = this;
|
6
|
+
if (!this.container) {
|
7
|
+
$(document.body).append("<div id=\"modal-container\"/>");
|
8
|
+
this.container = $("#modal-container").get(0);
|
9
|
+
$(this.container).hide();
|
10
|
+
$(window).scroll(function() {
|
11
|
+
return modal.position();
|
12
|
+
});
|
13
|
+
return $(window).resize(function() {
|
14
|
+
return modal.position();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
clear: function() {
|
20
|
+
return $(this.container).fadeOut(150, function() {
|
21
|
+
$(this).html();
|
22
|
+
return $("#modalOverlay").fadeOut(50);
|
23
|
+
});
|
24
|
+
},
|
25
|
+
|
26
|
+
draw: function(options) {
|
27
|
+
this.makeContainer();
|
28
|
+
$(this.container).show();
|
29
|
+
$(this.container).html(
|
30
|
+
"<div class=\"container\">" + options.text + "</div>"
|
31
|
+
);
|
32
|
+
this.position();
|
33
|
+
$(document.body).append("<div id=\"modalOverlay\"/>");
|
34
|
+
$("#modalOverlay").show().click(function() {
|
35
|
+
return Modal.clear();
|
36
|
+
}).css({
|
37
|
+
position: "absolute",
|
38
|
+
top: 0,
|
39
|
+
left: 0,
|
40
|
+
width: $(document).width() + "px",
|
41
|
+
height: $(document).height() + "px",
|
42
|
+
"z-index": 19,
|
43
|
+
"background-color": "#000000",
|
44
|
+
opacity: 0
|
45
|
+
}).animate({
|
46
|
+
opacity: 0.6
|
47
|
+
}, 100);
|
48
|
+
return $(this.container).find(".clear-modal").click(function() {
|
49
|
+
return Modal.clear();
|
50
|
+
});
|
51
|
+
},
|
52
|
+
|
53
|
+
position: function() {
|
54
|
+
let width = $(this.container).width();
|
55
|
+
let height = $(this.container).height();
|
56
|
+
let scrollTop = $(window).scrollTop();
|
57
|
+
let viewportWidth = (
|
58
|
+
window.innerWidth ? window.innerWidth : $(window).width()
|
59
|
+
);
|
60
|
+
let viewportHeight = (
|
61
|
+
window.innerHeight ? window.innerHeight : $(window).height()
|
62
|
+
);
|
63
|
+
|
64
|
+
var left = Math.round(viewportWidth / 2) - (width / 2);
|
65
|
+
var top = (Math.round(viewportHeight / 2) - (height / 2)) + scrollTop;
|
66
|
+
|
67
|
+
if (top < 5) {
|
68
|
+
top = 5;
|
69
|
+
}
|
70
|
+
if (left < 5) {
|
71
|
+
left = 5;
|
72
|
+
}
|
73
|
+
|
74
|
+
$("#modalOverlay").css({
|
75
|
+
top: 0,
|
76
|
+
left: 0,
|
77
|
+
width: $(document).width() + "px",
|
78
|
+
height: $(document).height() + "px"
|
79
|
+
});
|
80
|
+
return $(this.container).css("left", left).css("top", top);
|
81
|
+
},
|
82
|
+
|
83
|
+
alert: function(string) {
|
84
|
+
return this.draw({text: string});
|
85
|
+
},
|
86
|
+
|
87
|
+
show: function(string) {
|
88
|
+
return this.draw({text: string});
|
89
|
+
}
|
90
|
+
};
|
@@ -0,0 +1,338 @@
|
|
1
|
+
$(function () {
|
2
|
+
$('.page_images').each(function () {
|
3
|
+
var container = this;
|
4
|
+
var $editor = $(container).find('.editor');
|
5
|
+
|
6
|
+
$editor.hide();
|
7
|
+
|
8
|
+
var baseURL = $editor.closest('form').attr('action');
|
9
|
+
|
10
|
+
var selectedImage = false;
|
11
|
+
var selectedImageId = false;
|
12
|
+
var images = [];
|
13
|
+
var imagesData = false;
|
14
|
+
|
15
|
+
function loadImagesData () {
|
16
|
+
$.getJSON(baseURL + '/images.json', function (json) {
|
17
|
+
imagesData = json["page_images"];
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
function updateImageData(data) {
|
22
|
+
for (var a = 0; a < imagesData.length; a++) {
|
23
|
+
if (imagesData[a].id === data.id) {
|
24
|
+
imagesData[a] = data;
|
25
|
+
} else if (data.primary) {
|
26
|
+
imagesData[a].primary = false;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
function getImageData (imageId) {
|
32
|
+
var data = false;
|
33
|
+
for (var a = 0; a < imagesData.length; a++) {
|
34
|
+
if (imagesData[a].id === parseInt(imageId, 10)) {
|
35
|
+
data = imagesData[a];
|
36
|
+
}
|
37
|
+
}
|
38
|
+
return data;
|
39
|
+
}
|
40
|
+
|
41
|
+
function getImageSize (imageId) {
|
42
|
+
var imageData = getImageData(imageId).image;
|
43
|
+
return [imageData.real_width, imageData.real_height];
|
44
|
+
}
|
45
|
+
|
46
|
+
function getImageURL (imageId, maxWidth, maxHeight) {
|
47
|
+
return imageData;
|
48
|
+
}
|
49
|
+
|
50
|
+
function showEditor (image, imageData) {
|
51
|
+
// Show the editor
|
52
|
+
$('.page_images .uploadButton').hide();
|
53
|
+
$editor.find('.caption').val(imageData.image.caption);
|
54
|
+
$editor.find('.alternative').val(imageData.image.alternative);
|
55
|
+
$editor.find('.embed').val("[image:" + imageData.image.id + "]");
|
56
|
+
$editor.find('.image_id').val(imageData.image.id);
|
57
|
+
|
58
|
+
if (imageData.primary) {
|
59
|
+
$editor.find('#page_image_primary').attr('checked', 'checked');
|
60
|
+
} else {
|
61
|
+
$editor.find('#page_image_primary').attr('checked', false);
|
62
|
+
}
|
63
|
+
$(container).find('.image').removeClass('selected');
|
64
|
+
$(image).addClass('selected');
|
65
|
+
$editor.slideDown(400);
|
66
|
+
}
|
67
|
+
|
68
|
+
function cropImage (imageData, imageSize, scaleFactor) {
|
69
|
+
// Handle cropping
|
70
|
+
var cropStart = [
|
71
|
+
imageData.image.crop_start_x,
|
72
|
+
imageData.image.crop_start_y
|
73
|
+
];
|
74
|
+
|
75
|
+
var cropSize = [
|
76
|
+
(imageSize[0] - cropStart[0]),
|
77
|
+
(imageSize[1] - cropStart[1])
|
78
|
+
];
|
79
|
+
|
80
|
+
if (imageData.image.crop_width && imageData.image.crop_height) {
|
81
|
+
cropSize = [
|
82
|
+
imageData.image.crop_width,
|
83
|
+
imageData.image.crop_height
|
84
|
+
];
|
85
|
+
}
|
86
|
+
|
87
|
+
var scale = function (val) {
|
88
|
+
return Math.floor(val / scaleFactor);
|
89
|
+
};
|
90
|
+
|
91
|
+
var updateCrop = function (crop) {
|
92
|
+
var start = [0, 0];
|
93
|
+
var size = imageSize;
|
94
|
+
if (crop.w > 0 && crop.h > 0) {
|
95
|
+
start = [scale(crop.x), scale(crop.y)];
|
96
|
+
size = [scale(crop.w), scale(crop.h)];
|
97
|
+
}
|
98
|
+
$editor.find('.crop_start_x').val(start[0]);
|
99
|
+
$editor.find('.crop_start_y').val(start[1]);
|
100
|
+
$editor.find('.crop_width').val(size[0]);
|
101
|
+
$editor.find('.crop_height').val(size[1]);
|
102
|
+
};
|
103
|
+
|
104
|
+
$editor.find('.edit-image img').Jcrop({
|
105
|
+
setSelect: [
|
106
|
+
Math.floor(cropStart[0] * scaleFactor),
|
107
|
+
Math.floor(cropStart[1] * scaleFactor),
|
108
|
+
Math.floor(cropStart[0] * scaleFactor) + Math.floor(cropSize[0] * scaleFactor),
|
109
|
+
Math.floor(cropStart[1] * scaleFactor) + Math.floor(cropSize[1] * scaleFactor)
|
110
|
+
],
|
111
|
+
onSelect: updateCrop,
|
112
|
+
onChange: updateCrop
|
113
|
+
});
|
114
|
+
}
|
115
|
+
|
116
|
+
function showImage (image) {
|
117
|
+
// Delay execution if imageData is unavailable
|
118
|
+
if (imagesData === false) {
|
119
|
+
setTimeout(function () {
|
120
|
+
showImage(image);
|
121
|
+
}, 100);
|
122
|
+
return false;
|
123
|
+
}
|
124
|
+
|
125
|
+
if (image) {
|
126
|
+
var imageId = parseInt($(image).data('page-image-id'), 10);
|
127
|
+
var imageURL = $(image).data('uncropped-url');
|
128
|
+
var imageData = getImageData(imageId);
|
129
|
+
|
130
|
+
showEditor(image, imageData);
|
131
|
+
selectedImage = image;
|
132
|
+
selectedImageId = imageId;
|
133
|
+
|
134
|
+
// Determine resized size
|
135
|
+
var maxSize = [($editor.width() - 40), ($(window).height() - 200)];
|
136
|
+
var imageSize = getImageSize(imageId);
|
137
|
+
var scaleFactor = maxSize[1] / imageSize[1];
|
138
|
+
if ((imageSize[0] * scaleFactor) > maxSize[0]) {
|
139
|
+
scaleFactor = maxSize[0] / imageSize[0];
|
140
|
+
}
|
141
|
+
if (scaleFactor > 1.0) {
|
142
|
+
scaleFactor = 1.0;
|
143
|
+
}
|
144
|
+
var resizedSize = [
|
145
|
+
Math.floor(imageSize[0] * scaleFactor),
|
146
|
+
Math.floor(imageSize[1] * scaleFactor)
|
147
|
+
];
|
148
|
+
|
149
|
+
// Load the image
|
150
|
+
$editor.find('.edit-image').html(
|
151
|
+
'<img src="' +
|
152
|
+
imageURL + '" width="' + resizedSize[0] +
|
153
|
+
'" height="' + resizedSize[1] + '" />'
|
154
|
+
);
|
155
|
+
|
156
|
+
cropImage(imageData, imageSize, scaleFactor);
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
function closeEditor () {
|
161
|
+
$(container).find('.image').removeClass('selected');
|
162
|
+
selectedImage = false;
|
163
|
+
selectedImageId = false;
|
164
|
+
$editor.slideUp(400);
|
165
|
+
$('.page_images .uploadButton').slideDown(400);
|
166
|
+
return false;
|
167
|
+
}
|
168
|
+
|
169
|
+
function showNextImage () {
|
170
|
+
var nextIndex = false;
|
171
|
+
if (selectedImage) {
|
172
|
+
nextIndex = $.inArray(selectedImage, images) + 1;
|
173
|
+
}
|
174
|
+
if (nextIndex !== false) {
|
175
|
+
if (images[nextIndex]) {
|
176
|
+
showImage(images[nextIndex]);
|
177
|
+
} else {
|
178
|
+
showImage(images[0]);
|
179
|
+
}
|
180
|
+
}
|
181
|
+
return false;
|
182
|
+
}
|
183
|
+
|
184
|
+
function showPreviousImage () {
|
185
|
+
var nextIndex = false;
|
186
|
+
if (selectedImage) {
|
187
|
+
nextIndex = $.inArray(selectedImage, images) - 1;
|
188
|
+
}
|
189
|
+
if (nextIndex !== false) {
|
190
|
+
if (nextIndex < 0) {
|
191
|
+
nextIndex = images.length - 1;
|
192
|
+
}
|
193
|
+
if (images[nextIndex]) {
|
194
|
+
showImage(images[nextIndex]);
|
195
|
+
} else {
|
196
|
+
showImage(images[0]);
|
197
|
+
}
|
198
|
+
}
|
199
|
+
return false;
|
200
|
+
}
|
201
|
+
|
202
|
+
// Sorting images
|
203
|
+
function saveImageOrder () {
|
204
|
+
var ids = [];
|
205
|
+
images = [];
|
206
|
+
$('.page_images .images .image').each(function () {
|
207
|
+
images.push(this);
|
208
|
+
ids.push(parseInt($(this).data('page-image-id'), 10));
|
209
|
+
});
|
210
|
+
$('.page_images .images').animate({opacity: 0.8}, 300);
|
211
|
+
var url = baseURL + '/images/reorder.json';
|
212
|
+
var data = {
|
213
|
+
ids: ids,
|
214
|
+
authenticity_token: $("input[name=authenticity_token]").val()
|
215
|
+
};
|
216
|
+
$.put(url, data, function (json) {
|
217
|
+
$('.page_images .images').animate({opacity: 1.0}, 300);
|
218
|
+
});
|
219
|
+
}
|
220
|
+
|
221
|
+
function setPrimaryImage (newPrimary) {
|
222
|
+
var $previousPrimary = $(container).find('.primary');
|
223
|
+
if ($previousPrimary.length > 0) {
|
224
|
+
var thumbURL = $previousPrimary.find('img').attr('src').replace('220x220', '100x100');
|
225
|
+
$previousPrimary.find('img').attr('src', thumbURL);
|
226
|
+
$previousPrimary
|
227
|
+
.removeClass('primary')
|
228
|
+
.remove()
|
229
|
+
.appendTo($(container).find('.images'));
|
230
|
+
$previousPrimary.hide().fadeIn(400);
|
231
|
+
}
|
232
|
+
|
233
|
+
if (newPrimary) {
|
234
|
+
$(newPrimary)
|
235
|
+
.addClass('primary')
|
236
|
+
.remove()
|
237
|
+
.appendTo($(container).find('.primary_container'));
|
238
|
+
var bigURL = $(newPrimary).find('img').attr('src').replace('100x100', '220x220');
|
239
|
+
$(newPrimary).find('img').attr('src', bigURL);
|
240
|
+
$(newPrimary).hide().fadeIn(400);
|
241
|
+
}
|
242
|
+
saveImageOrder();
|
243
|
+
}
|
244
|
+
|
245
|
+
function saveImage () {
|
246
|
+
var savedId = selectedImageId;
|
247
|
+
var savedImage = selectedImage;
|
248
|
+
$editor.animate({opacity: 0.8}, 300);
|
249
|
+
var data = {
|
250
|
+
'page_image[primary]': $editor.find('#page_image_primary').is(':checked'),
|
251
|
+
'page_image[image_attributes][id]': $editor.find('.image_id').val(),
|
252
|
+
'page_image[image_attributes][caption]': $editor.find('.caption').val(),
|
253
|
+
'page_image[image_attributes][alternative]': $editor.find('.alternative').val(),
|
254
|
+
'page_image[image_attributes][crop_start_x]': $editor.find('.crop_start_x').val(),
|
255
|
+
'page_image[image_attributes][crop_start_y]': $editor.find('.crop_start_y').val(),
|
256
|
+
'page_image[image_attributes][crop_width]': $editor.find('.crop_width').val(),
|
257
|
+
'page_image[image_attributes][crop_height]': $editor.find('.crop_height').val(),
|
258
|
+
authenticity_token: $("input[name=authenticity_token]").val()
|
259
|
+
};
|
260
|
+
var url = baseURL + '/images/' + savedId + '.json';
|
261
|
+
$.put(url, data, function (json) {
|
262
|
+
updateImageData(json);
|
263
|
+
|
264
|
+
// Shuffle primary image around
|
265
|
+
if (json.primary && !$(savedImage).hasClass('primary')) {
|
266
|
+
setPrimaryImage(savedImage);
|
267
|
+
} else if (!json.primary && $(savedImage).hasClass('primary')) {
|
268
|
+
setPrimaryImage(false);
|
269
|
+
}
|
270
|
+
|
271
|
+
$editor.animate({opacity: 1.0}, 300);
|
272
|
+
});
|
273
|
+
return false;
|
274
|
+
}
|
275
|
+
|
276
|
+
function deleteImage () {
|
277
|
+
if (selectedImage && selectedImageId) {
|
278
|
+
if (confirm('Are you sure you want to delete this image?')) {
|
279
|
+
var url = baseURL + '/images/' + selectedImageId + '.json';
|
280
|
+
$.ajax(url, {
|
281
|
+
type: 'DELETE',
|
282
|
+
authenticity_token: $("input[name=authenticity_token]").val(),
|
283
|
+
success: function () {
|
284
|
+
var deletedImage = selectedImage;
|
285
|
+
if (images.length > 1) {
|
286
|
+
showNextImage();
|
287
|
+
} else {
|
288
|
+
$(container).find('.no_images').slideDown();
|
289
|
+
closeEditor();
|
290
|
+
}
|
291
|
+
images = _.reject(images, function (i) {
|
292
|
+
return i === deletedImage;
|
293
|
+
});
|
294
|
+
$(deletedImage).remove();
|
295
|
+
}
|
296
|
+
});
|
297
|
+
}
|
298
|
+
}
|
299
|
+
return false;
|
300
|
+
}
|
301
|
+
|
302
|
+
function applyButtonActions (container) {
|
303
|
+
container.find('a.next').click(showNextImage);
|
304
|
+
container.find('a.previous').click(showPreviousImage);
|
305
|
+
container.find('a.close').click(closeEditor);
|
306
|
+
container.find('button.save').click(saveImage);
|
307
|
+
container.find('a.delete').click(deleteImage);
|
308
|
+
}
|
309
|
+
|
310
|
+
function init() {
|
311
|
+
loadImagesData();
|
312
|
+
applyButtonActions($editor);
|
313
|
+
|
314
|
+
// Find images
|
315
|
+
$(container).find('.image').each(function () {
|
316
|
+
images.push(this);
|
317
|
+
$(this).find('img').removeAttr('width').removeAttr('height');
|
318
|
+
});
|
319
|
+
if (images.length > 0) {
|
320
|
+
$(container).find('.no_images').hide();
|
321
|
+
}
|
322
|
+
|
323
|
+
$(container).on('click', '.image', function () {
|
324
|
+
showImage(this);
|
325
|
+
return false;
|
326
|
+
});
|
327
|
+
|
328
|
+
$('.page_images .images').sortable({
|
329
|
+
forcePlaceholderSize: true,
|
330
|
+
update: saveImageOrder,
|
331
|
+
distance: 5
|
332
|
+
});
|
333
|
+
$('.page_images .image').disableSelection();
|
334
|
+
}
|
335
|
+
|
336
|
+
init();
|
337
|
+
});
|
338
|
+
});
|