refinerycms 0.9.8 → 0.9.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +6 -6
- data/app/controllers/application_controller.rb +2 -1
- data/bin/refinerycms +36 -32
- data/changelog.md +471 -0
- data/config/environments/production.rb +1 -1
- data/db/migrate/20100606135207_change_thumbnail_sizes_for_dragonfly.rb +4 -4
- data/db/migrate/20100826232810_move_inquiry_settings_to_refinery_settings.rb +2 -2
- data/db/migrate/20100831122919_move_page_to_nested_set.rb +28 -0
- data/db/schema.rb +7 -1
- data/db/seeds/refinery_settings.rb +2 -4
- data/license.md +21 -0
- data/readme.md +97 -0
- data/todo.md +61 -0
- data/vendor/refinerycms/authentication/app/views/admin/users/index.html.erb +5 -13
- data/vendor/refinerycms/authentication/app/views/layouts/login.html.erb +1 -1
- data/vendor/refinerycms/authentication/config/locales/de.yml +53 -56
- data/vendor/refinerycms/authentication/config/locales/en.yml +1 -2
- data/vendor/refinerycms/authentication/config/locales/lv.yml +38 -38
- data/vendor/refinerycms/authentication/config/locales/pt-BR.yml +21 -48
- data/vendor/refinerycms/authentication/features/lost_password.feature +40 -0
- data/vendor/refinerycms/authentication/features/manage_users.feature +57 -0
- data/vendor/refinerycms/authentication/features/step_definitions/lost_password.rb +8 -0
- data/vendor/refinerycms/authentication/features/step_definitions/user_steps.rb +32 -0
- data/vendor/refinerycms/authentication/features/support/factories.rb +17 -0
- data/vendor/refinerycms/authentication/features/support/paths.rb +24 -0
- data/vendor/refinerycms/authentication/lib/authenticated_system.rb +1 -1
- data/vendor/refinerycms/authentication/lib/authentication.rb +1 -1
- data/vendor/refinerycms/core/app/views/admin/_head.html.erb +4 -4
- data/vendor/refinerycms/core/app/views/admin/_menu_tab.html.erb +2 -2
- data/vendor/refinerycms/core/app/views/layouts/admin.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/layouts/admin_dialog.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_footer.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_google_analytics.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_header.html.erb +1 -1
- data/vendor/refinerycms/core/app/views/shared/_menu.html.erb +5 -2
- data/vendor/refinerycms/core/app/views/shared/_menu_branch.html.erb +6 -3
- data/vendor/refinerycms/core/app/views/shared/_site_bar.html.erb +11 -15
- data/vendor/refinerycms/core/app/views/shared/admin/_form_actions.html.erb +1 -0
- data/vendor/refinerycms/core/app/views/shared/admin/_image_picker.html.erb +3 -3
- data/vendor/refinerycms/core/app/views/shared/admin/_make_sortable.html.erb +2 -1
- data/vendor/refinerycms/core/app/views/shared/admin/_resource_picker.html.erb +24 -17
- data/vendor/refinerycms/core/app/views/wymiframe.html.erb +1 -1
- data/vendor/refinerycms/core/config/locales/de.yml +50 -51
- data/vendor/refinerycms/core/config/locales/en.yml +5 -2
- data/vendor/refinerycms/core/config/locales/lv.yml +6 -3
- data/vendor/refinerycms/core/config/locales/pt-BR.yml +34 -38
- data/vendor/refinerycms/core/crud.md +12 -12
- data/vendor/refinerycms/core/features/engine_generator.feature +27 -0
- data/vendor/refinerycms/core/features/search.feature +56 -0
- data/vendor/refinerycms/core/features/site_bar.feature +24 -0
- data/vendor/refinerycms/core/features/step_definitions/core_steps.rb +61 -0
- data/vendor/refinerycms/core/features/step_definitions/engine_generator_steps.rb +19 -0
- data/vendor/refinerycms/core/features/step_definitions/generator_steps.rb +11 -0
- data/vendor/refinerycms/core/features/support/paths.rb +14 -0
- data/vendor/refinerycms/core/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/core/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/core/lib/core.rb +52 -53
- data/vendor/refinerycms/core/lib/generators/refinery_engine/refinery_engine_generator.rb +14 -3
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/controllers/admin/plural_name_controller.rb +3 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/models/singular_name.rb +4 -3
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_form.html.erb +2 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/_singular_name.html.erb +6 -2
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/index.html.erb +3 -1
- data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/plural_name/show.html.erb +7 -3
- data/vendor/refinerycms/core/lib/refinery/application_controller.rb +85 -75
- data/vendor/refinerycms/core/lib/refinery/application_helper.rb +10 -190
- data/vendor/refinerycms/core/lib/refinery/crud.rb +283 -0
- data/vendor/refinerycms/core/lib/refinery/{form_helpers.rb → helpers/form_helper.rb} +0 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/html_truncation_helper.rb +26 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/image_helper.rb +37 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/menu_helper.rb +38 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/meta_helper.rb +67 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/script_helper.rb +36 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/site_bar_helper.rb +26 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/tag_helper.rb +19 -0
- data/vendor/refinerycms/core/lib/refinery/helpers/translation_helper.rb +17 -0
- data/vendor/refinerycms/core/lib/refinery/plugin.rb +3 -3
- data/vendor/refinerycms/core/lib/tasks/refinery.rake +4 -3
- data/vendor/refinerycms/core/public/javascripts/refinery/admin.js +93 -101
- data/vendor/refinerycms/core/public/javascripts/refinery/core.js +3 -0
- data/vendor/refinerycms/core/public/javascripts/refinery/nestedsortables.js +164 -0
- data/vendor/refinerycms/core/public/javascripts/refinery/serializelist.js +66 -0
- data/vendor/refinerycms/core/public/stylesheets/refinery/refinery.css +11 -73
- data/vendor/refinerycms/dashboard/config/locales/de.yml +6 -6
- data/vendor/refinerycms/dashboard/config/locales/pt-BR.yml +3 -5
- data/vendor/refinerycms/dashboard/features/dashboard.feature +54 -0
- data/vendor/refinerycms/dashboard/features/support/paths.rb +14 -0
- data/vendor/refinerycms/images/app/controllers/admin/images_controller.rb +6 -6
- data/vendor/refinerycms/images/app/helpers/admin/images_helper.rb +1 -1
- data/vendor/refinerycms/images/app/views/admin/images/_existing_image.html.erb +15 -13
- data/vendor/refinerycms/images/app/views/admin/images/_grid_view.html.erb +1 -1
- data/vendor/refinerycms/images/app/views/admin/images/_list_view_image.html.erb +1 -1
- data/vendor/refinerycms/images/config/locales/de.yml +21 -25
- data/vendor/refinerycms/images/config/locales/pt-BR.yml +13 -23
- data/vendor/refinerycms/images/features/manage_images.feature +48 -0
- data/vendor/refinerycms/images/features/step_definitions/image_steps.rb +37 -0
- data/vendor/refinerycms/images/features/support/paths.rb +17 -0
- data/vendor/refinerycms/images/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/images/features/uploads/id-rather-be-here.jpg +0 -0
- data/vendor/refinerycms/images/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/images/lib/images.rb +6 -0
- data/vendor/refinerycms/images/readme.md +12 -36
- data/vendor/refinerycms/pages/app/controllers/admin/pages_controller.rb +4 -42
- data/vendor/refinerycms/pages/app/controllers/pages_controller.rb +1 -1
- data/vendor/refinerycms/pages/app/models/page.rb +3 -4
- data/vendor/refinerycms/pages/app/sweepers/page_sweeper.rb +18 -0
- data/vendor/refinerycms/pages/app/views/admin/pages/_form_advanced_options.html.erb +1 -1
- data/vendor/refinerycms/pages/app/views/admin/pages/_page.html.erb +6 -5
- data/vendor/refinerycms/pages/config/locales/de.yml +66 -36
- data/vendor/refinerycms/pages/config/locales/pt-BR.yml +29 -57
- data/vendor/refinerycms/pages/features/manage_pages.feature +45 -0
- data/vendor/refinerycms/pages/features/step_definitions/page_steps.rb +29 -0
- data/vendor/refinerycms/pages/features/support/paths.rb +18 -0
- data/vendor/refinerycms/pages/lib/pages.rb +5 -0
- data/vendor/refinerycms/pages/spec/models/page_spec.rb +13 -0
- data/vendor/refinerycms/refinery.rb +1 -1
- data/vendor/refinerycms/resources/app/views/admin/resources/_existing_resource.html.erb +2 -2
- data/vendor/refinerycms/resources/config/locales/de.yml +16 -17
- data/vendor/refinerycms/resources/config/locales/pt-BR.yml +15 -17
- data/vendor/refinerycms/resources/features/manage_files.feature +39 -0
- data/vendor/refinerycms/resources/features/step_definitions/file_steps.rb +21 -0
- data/vendor/refinerycms/resources/features/support/paths.rb +17 -0
- data/vendor/refinerycms/resources/features/uploads/beach.jpeg +0 -0
- data/vendor/refinerycms/resources/features/uploads/refinery_is_awesome.txt +1 -0
- data/vendor/refinerycms/resources/lib/resources.rb +17 -1
- data/vendor/refinerycms/settings/app/models/refinery_setting.rb +82 -64
- data/vendor/refinerycms/settings/config/locales/de.yml +36 -16
- data/vendor/refinerycms/settings/config/locales/pt-BR.yml +32 -34
- data/vendor/refinerycms/settings/features/manage_refinery_settings.feature +5 -0
- data/vendor/refinerycms/settings/lib/settings.rb +1 -1
- metadata +86 -53
- data/vendor/refinerycms/core/lib/crud.rb +0 -265
- data/vendor/refinerycms/core/lib/refinery/html_truncation_helper.rb +0 -22
- data/vendor/refinerycms/core/public/javascripts/jquery/jquery.nestedsortables.js +0 -186
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module Helpers
|
|
3
|
+
module ScriptHelper
|
|
4
|
+
|
|
5
|
+
# This function helps when including both the jquery and jqueryui libraries.
|
|
6
|
+
# If you use this function then whenever we update or relocate the version of jquery or jquery ui in use
|
|
7
|
+
# we will update the reference here and your existing application starts to use it.
|
|
8
|
+
# Use <%= jquery_include_tags %> to include it in your <head> section.
|
|
9
|
+
def jquery_include_tags(options={})
|
|
10
|
+
# Merge in options
|
|
11
|
+
options = {
|
|
12
|
+
:caching => RefinerySetting.find_or_set(:use_resource_caching, Rails.root.writable?),
|
|
13
|
+
:google => RefinerySetting.find_or_set(:use_google_ajax_libraries, false),
|
|
14
|
+
:jquery_ui => true
|
|
15
|
+
}.merge(options)
|
|
16
|
+
|
|
17
|
+
# render the tags normally unless
|
|
18
|
+
unless options[:google] and !local_request?
|
|
19
|
+
if options[:jquery_ui]
|
|
20
|
+
javascript_include_tag "jquery#{"-min" if Rails.env.production?}", "jquery-ui-custom-min",
|
|
21
|
+
:cache => (options[:caching] ? "cache/jquery" : nil)
|
|
22
|
+
else
|
|
23
|
+
javascript_include_tag "jquery#{"-min" if Rails.env.production?}"
|
|
24
|
+
end
|
|
25
|
+
else
|
|
26
|
+
"#{javascript_include_tag("http://www.google.com/jsapi").gsub(".js", "")}
|
|
27
|
+
<script type='text/javascript'>
|
|
28
|
+
google.load('jquery', '1.4');
|
|
29
|
+
#{"google.load('jqueryui', '1.8');" if options[:jquery_ui]}
|
|
30
|
+
</script>".html_safe
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module Helpers
|
|
3
|
+
module SiteBarHelper
|
|
4
|
+
|
|
5
|
+
# Generates the link to determine where the site bar switch button returns to.
|
|
6
|
+
def site_bar_switch_link
|
|
7
|
+
link_to_if(admin?, t('.switch_to_your_website'),
|
|
8
|
+
(if session.keys.include?(:website_return_to) and session[:website_return_to].present?
|
|
9
|
+
session[:website_return_to]
|
|
10
|
+
else
|
|
11
|
+
root_url(:only_path => true)
|
|
12
|
+
end)) do
|
|
13
|
+
link_to t('.switch_to_your_website_editor'),
|
|
14
|
+
(if session.keys.include?(:refinery_return_to) and session[:refinery_return_to].present?
|
|
15
|
+
session[:refinery_return_to]
|
|
16
|
+
elsif defined?(@page) and @page.present? and !@page.home?
|
|
17
|
+
edit_admin_page_url(@page, :only_path => true)
|
|
18
|
+
else
|
|
19
|
+
(request.fullpath.to_s == '/') ? admin_root_url(:only_path => true) : "/admin#{request.request_uri}/edit"
|
|
20
|
+
end rescue admin_root_url(:only_path => true))
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module Helpers
|
|
3
|
+
module TagHelper
|
|
4
|
+
|
|
5
|
+
# Returns <span class='help' title='Your Input'>(help)</span>
|
|
6
|
+
# Remember to wrap your block with <span class='label_with_help'></span> if you're using a label next to the help tag.
|
|
7
|
+
def refinery_help_tag(title='')
|
|
8
|
+
"<span class='help' title='#{title}'>(#{t('shared.admin.help')})</span>".html_safe
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# This is just a quick wrapper to render an image tag that lives inside refinery/icons.
|
|
12
|
+
# They are all 16x16 so this is the default but is able to be overriden with supplied options.
|
|
13
|
+
def refinery_icon_tag(filename, options = {})
|
|
14
|
+
image_tag "refinery/icons/#{filename}", {:width => 16, :height => 16}.merge(options)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Refinery
|
|
2
|
+
module Helpers
|
|
3
|
+
module TranslationHelper
|
|
4
|
+
|
|
5
|
+
# Overrides Rails' core I18n.t() function to produce a more helpful error message.
|
|
6
|
+
# The default one wreaks havoc with CSS and makes it hard to understand the problem.
|
|
7
|
+
def t(key, options = {})
|
|
8
|
+
if (val = super) =~ /class.+?translation_missing/
|
|
9
|
+
val = val.to_s.gsub(/<span[^>]*>/, 'i18n: ').gsub('</span>', '').gsub(', ', '.')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
val
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -96,11 +96,11 @@ module Refinery
|
|
|
96
96
|
return @url if defined?(@url)
|
|
97
97
|
|
|
98
98
|
if self.controller.present?
|
|
99
|
-
@url = {:controller => "admin/#{self.controller}"}
|
|
99
|
+
@url = {:controller => "/admin/#{self.controller}"}
|
|
100
100
|
elsif self.directory.present?
|
|
101
|
-
@url = {:controller => "admin/#{self.directory.split('/').pop}"}
|
|
101
|
+
@url = {:controller => "/admin/#{self.directory.split('/').pop}"}
|
|
102
102
|
else
|
|
103
|
-
@url = {:controller => "admin/#{self.name}"}
|
|
103
|
+
@url = {:controller => "/admin/#{self.name}"}
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -118,11 +118,12 @@ end
|
|
|
118
118
|
|
|
119
119
|
desc 'Removes trailing whitespace across the entire application.'
|
|
120
120
|
task :whitespace do
|
|
121
|
-
|
|
121
|
+
require 'rbconfig'
|
|
122
|
+
if Config::CONFIG['host_os'] =~ /linux/
|
|
122
123
|
sh %{find . -name '*.*rb' -exec sed -i 's/\t/ /g' {} \\; -exec sed -i 's/ *$//g' {} \\; }
|
|
123
|
-
elsif
|
|
124
|
+
elsif Config::CONFIG['host_os'] =~ /darwin/
|
|
124
125
|
sh %{find . -name '*.*rb' -exec sed -i '' 's/\t/ /g' {} \\; -exec sed -i '' 's/ *$//g' {} \\; }
|
|
125
126
|
else
|
|
126
|
-
puts "This doesn't work on systems other than OSX or Linux. Please use a custom whitespace tool for your platform '#{
|
|
127
|
+
puts "This doesn't work on systems other than OSX or Linux. Please use a custom whitespace tool for your platform '#{Config::CONFIG["host_os"]}'."
|
|
127
128
|
end
|
|
128
129
|
end
|
|
@@ -53,9 +53,6 @@ init_interface = function() {
|
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
// focus first field in an admin form.
|
|
57
|
-
$('form input[type=text]:first').focus();
|
|
58
|
-
|
|
59
56
|
// ensure that the menu isn't wider than the page_container or else it looks silly to round that corner.
|
|
60
57
|
if (($menu = $('#menu')).length > 0) {
|
|
61
58
|
$menu.jcarousel({
|
|
@@ -344,9 +341,6 @@ var link_dialog = {
|
|
|
344
341
|
if((resource_selected = $('#existing_resource_area_content ul li.linked a')).length > 0) {
|
|
345
342
|
resourceUrl = parseURL(resource_selected.attr('href'));
|
|
346
343
|
relevant_href = resourceUrl.pathname;
|
|
347
|
-
if (resourceUrl.protocol == "" && resourceUrl.hostname == "assets") {
|
|
348
|
-
relevant_href = "/assets" + relevant_href;
|
|
349
|
-
}
|
|
350
344
|
|
|
351
345
|
// Add any alternate resource stores that need a absolute URL in the regex below
|
|
352
346
|
if(resourceUrl.hostname.match(/s3.amazonaws.com/)) {
|
|
@@ -674,26 +668,34 @@ var image_dialog = {
|
|
|
674
668
|
var imageThumbnailSize = $('#existing_image_size_area li.selected a').attr('data-size');
|
|
675
669
|
var resize = $("#wants_to_resize_image").is(':checked');
|
|
676
670
|
|
|
671
|
+
var url = '/refinery/images/'+imageId+'/url';
|
|
677
672
|
if (resize) {
|
|
678
|
-
|
|
679
|
-
} else {
|
|
680
|
-
var url = '/refinery/images/'+imageId+'/url'
|
|
673
|
+
url += '?size='+imageThumbnailSize;
|
|
681
674
|
}
|
|
682
675
|
|
|
683
676
|
var data;
|
|
684
|
-
$.ajax({
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
677
|
+
$.ajax({
|
|
678
|
+
async: false,
|
|
679
|
+
url: url,
|
|
680
|
+
success: function (result, status, xhr) {
|
|
681
|
+
if (result.error) {
|
|
682
|
+
if (console && console.log) {
|
|
683
|
+
console.log("Something went wrong with the image insertion!");
|
|
684
|
+
console.log(result);
|
|
685
|
+
}
|
|
686
|
+
} else {
|
|
687
|
+
data = result;
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
error: function(xhr, txt, status) {
|
|
691
|
+
if (console && console.log) {
|
|
692
|
+
console.log("Something went wrong with the image insertion!");
|
|
693
|
+
console.log(xhr);
|
|
694
|
+
console.log(txt);
|
|
695
|
+
console.log(status);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
});
|
|
697
699
|
|
|
698
700
|
if (parent) {
|
|
699
701
|
if ((wym_src = parent.document.getElementById('wym_src')) != null) {
|
|
@@ -706,7 +708,7 @@ var image_dialog = {
|
|
|
706
708
|
wym_alt.value = $(img).attr('alt');
|
|
707
709
|
}
|
|
708
710
|
if ((wym_size = parent.document.getElementById('wym_size')) != null) {
|
|
709
|
-
wym_size.value = imageThumbnailSize;
|
|
711
|
+
wym_size.value = imageThumbnailSize.replace(/[<>=]/g, '');
|
|
710
712
|
}
|
|
711
713
|
}
|
|
712
714
|
}
|
|
@@ -757,101 +759,68 @@ var list_reorder = {
|
|
|
757
759
|
init: function() {
|
|
758
760
|
$('#reorder_action').click(list_reorder.enable_reordering);
|
|
759
761
|
$('#reorder_action_done').click(list_reorder.disable_reordering);
|
|
762
|
+
list_reorder.sortable_list.nestedSortable({
|
|
763
|
+
disableNesting: 'no-nest',
|
|
764
|
+
forcePlaceholderSize: true,
|
|
765
|
+
handle: 'div',
|
|
766
|
+
items: 'li',
|
|
767
|
+
opacity: .6,
|
|
768
|
+
placeholder: 'placeholder',
|
|
769
|
+
tabSize: 25,
|
|
770
|
+
tolerance: 'pointer',
|
|
771
|
+
toleranceElement: '> div',
|
|
772
|
+
disabled: true,
|
|
773
|
+
start: function () {
|
|
774
|
+
},
|
|
775
|
+
change: function () {
|
|
776
|
+
list_reorder.reset_branch_classes(this);
|
|
777
|
+
},
|
|
778
|
+
stop: function () {
|
|
779
|
+
list_reorder.reset_branch_classes(this);
|
|
780
|
+
}
|
|
781
|
+
});
|
|
782
|
+
list_reorder.reset_branch_classes(list_reorder.sortable_list);
|
|
760
783
|
}
|
|
761
784
|
|
|
762
|
-
,
|
|
763
|
-
|
|
785
|
+
,reset_branch_classes: function (ul) {
|
|
786
|
+
$("li.ui-sortable-helper", this).removeClass("record").removeClass("branch_start").removeClass("branch_end");
|
|
787
|
+
$("li", ul).removeClass("branch_start").removeClass("branch_end");
|
|
764
788
|
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
, 'placeholder': 'placeholder'
|
|
768
|
-
, 'cursor': 'drag'
|
|
769
|
-
, 'items': 'li'
|
|
770
|
-
, 'axis': 'y'
|
|
771
|
-
, 'connectWith' : '.nested'
|
|
772
|
-
};
|
|
773
|
-
|
|
774
|
-
$(list_reorder.sortable_list).find('li').each(function(index, li) {
|
|
775
|
-
if ($('ul', li).length) { return; }
|
|
776
|
-
$("<ul></ul>").appendTo(li);
|
|
777
|
-
});
|
|
789
|
+
$("> li:first", ul).addClass("branch_start")
|
|
790
|
+
$("> li:last", ul).addClass("branch_end")
|
|
778
791
|
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
, 'placeholderElement': 'li'
|
|
783
|
-
}));
|
|
784
|
-
$(list_reorder.sortable_list).addClass('ui-sortable');
|
|
785
|
-
} else {
|
|
786
|
-
$(list_reorder.sortable_list).sortable(sortable_options);
|
|
787
|
-
}
|
|
792
|
+
var nested_ul = $("ul", ul);
|
|
793
|
+
$("> li:last", nested_ul).addClass("branch_end");
|
|
794
|
+
}
|
|
788
795
|
|
|
789
|
-
|
|
796
|
+
,enable_reordering: function(e) {
|
|
797
|
+
if(e) { e.preventDefault(); }
|
|
798
|
+
$('#sortable_list').addClass("reordering");
|
|
799
|
+
|
|
800
|
+
$('#sortable_list .actions, #site_bar, header > *:not(script)').fadeTo(500, 0.3);
|
|
790
801
|
$('#actions *:not("#reorder_action_done, #reorder_action")').not($('#reorder_action_done').parents('li, ul')).fadeTo(500, 0.55);
|
|
791
802
|
|
|
803
|
+
list_reorder.sortable_list.nestedSortable("enable");
|
|
792
804
|
$('#reorder_action').hide();
|
|
793
805
|
$('#reorder_action_done').show();
|
|
794
806
|
}
|
|
795
807
|
|
|
796
|
-
, parse_branch: function(indexes, li) {
|
|
797
|
-
branch = "&sortable_list";
|
|
798
|
-
$.each(indexes, function(i, index) {
|
|
799
|
-
branch += "[" + index + "]";
|
|
800
|
-
});
|
|
801
|
-
branch += "[id]=" + $($(li).attr('id').split('_')).last().get(0);
|
|
802
|
-
|
|
803
|
-
// parse any children branches too.
|
|
804
|
-
$(li).find('> li[id], > ul li[id]').each(function(i, child) {
|
|
805
|
-
current_indexes = $.merge($.merge([], indexes), [i]);
|
|
806
|
-
branch += list_reorder.parse_branch(current_indexes, child);
|
|
807
|
-
});
|
|
808
|
-
|
|
809
|
-
return branch;
|
|
810
|
-
}
|
|
811
|
-
|
|
812
808
|
, disable_reordering: function(e) {
|
|
813
809
|
if($('#reorder_action_done').hasClass('loading')){
|
|
814
810
|
return false;
|
|
815
811
|
}
|
|
816
812
|
if(e) { e.preventDefault(); }
|
|
817
813
|
$('#reorder_action_done').addClass('loading');
|
|
814
|
+
list_reorder.sortable_list.nestedSortable("disable");
|
|
815
|
+
|
|
816
|
+
$('#sortable_list').removeClass("reordering");
|
|
817
|
+
|
|
818
818
|
if (list_reorder.update_url != null) {
|
|
819
|
-
serialized = "";
|
|
820
|
-
list_reorder.sortable_list.find('> li[id]').each(function(index, li) {
|
|
821
|
-
if (list_reorder.tree) {
|
|
822
|
-
serialized += list_reorder.parse_branch([index], li);
|
|
823
|
-
}
|
|
824
|
-
else {
|
|
825
|
-
serialized += "&sortable_list[]=" + $($(li).attr('id').split('_')).last().get(0);
|
|
826
|
-
}
|
|
827
|
-
});
|
|
828
|
-
serialized += "&tree=" + list_reorder.tree;
|
|
829
|
-
serialized += "&authenticity_token=" + encodeURIComponent($('#reorder_authenticity_token').val());
|
|
830
|
-
serialized += "&continue_reordering=false";
|
|
831
819
|
|
|
832
|
-
|
|
833
|
-
// handle the case where we get the whole list back including the <ul> or whatever.
|
|
834
|
-
if ((matches = data.match(new RegExp("^<" + list_reorder.sortable_list.get(0).tagName.toLowerCase()
|
|
835
|
-
+ "[^>]+" + list_reorder.sortable_list.attr('id') + "[^>]>"))) != null)
|
|
836
|
-
{
|
|
837
|
-
// replace reorder authenticity token's value.
|
|
838
|
-
$('#reorder_authenticity_token').val(
|
|
839
|
-
$($(data.split('reorder_authenticity_token')).last().get(0).split('value=\''))
|
|
840
|
-
.last().get(0).split('\'')[0]);
|
|
841
|
-
// replace actual list content.
|
|
842
|
-
$(list_reorder.sortable_list).html($(data).html());
|
|
843
|
-
} else {
|
|
844
|
-
$(list_reorder.sortable_list).html(data);
|
|
845
|
-
}
|
|
820
|
+
var serialized = list_reorder.sortable_list.serializelist();
|
|
846
821
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
.match(/<script\ type='text\/javascript'>([^<]*)<\/script>/im);
|
|
850
|
-
if (matches != null && matches.length > 1) {
|
|
851
|
-
list_reorder.enable_reordering();
|
|
852
|
-
} else {
|
|
853
|
-
list_reorder.restore_controls(e);
|
|
854
|
-
}
|
|
822
|
+
$.post(list_reorder.update_url, serialized, function(data) {
|
|
823
|
+
list_reorder.restore_controls(e);
|
|
855
824
|
});
|
|
856
825
|
} else {
|
|
857
826
|
list_reorder.restore_controls(e);
|
|
@@ -866,7 +835,7 @@ var list_reorder = {
|
|
|
866
835
|
}
|
|
867
836
|
$(list_reorder.sortable_list).removeClass('reordering, ui-sortable');
|
|
868
837
|
|
|
869
|
-
$('#site_bar, header > *:not(script)').fadeTo(250, 1);
|
|
838
|
+
$('#sortable_list .actions, #site_bar, header > *:not(script)').fadeTo(250, 1);
|
|
870
839
|
$('#actions *:not("#reorder_action_done, #reorder_action")').not($('#reorder_action_done').parents('li, ul')).fadeTo(250, 1, function() {
|
|
871
840
|
$('#reorder_action_done').hide().removeClass('loading');
|
|
872
841
|
$('#reorder_action').show();
|
|
@@ -913,7 +882,28 @@ var image_picker = {
|
|
|
913
882
|
, changed: function(image) {
|
|
914
883
|
$(this.options.field).val(image.id.replace("image_", ""));
|
|
915
884
|
|
|
916
|
-
|
|
885
|
+
$.ajax({
|
|
886
|
+
async: false,
|
|
887
|
+
url: '/refinery/images/'+$(image).attr('data-id')+'/url?size='+this.options.thumbnail,
|
|
888
|
+
success: function (result, status, xhr) {
|
|
889
|
+
if (result.error) {
|
|
890
|
+
if (console && console.log) {
|
|
891
|
+
console.log("Something went wrong with the image insertion!");
|
|
892
|
+
console.log(result);
|
|
893
|
+
}
|
|
894
|
+
} else {
|
|
895
|
+
image.src = result.url;
|
|
896
|
+
}
|
|
897
|
+
},
|
|
898
|
+
error: function(xhr, txt, status) {
|
|
899
|
+
if (console && console.log) {
|
|
900
|
+
console.log("Something went wrong with the image insertion!");
|
|
901
|
+
console.log(xhr);
|
|
902
|
+
console.log(txt);
|
|
903
|
+
console.log(status);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
});
|
|
917
907
|
|
|
918
908
|
current_image = $(this.options.image_display);
|
|
919
909
|
current_image.replaceWith($("<img src='"+image.src+"?"+Math.floor(Math.random() * 1000000000)+"' id='"+current_image.attr('id')+"' class='brown_border' />"));
|
|
@@ -969,7 +959,9 @@ parseURL = function(url)
|
|
|
969
959
|
|
|
970
960
|
//splice and join the remainder to get the pathname
|
|
971
961
|
parts.splice(0, 2);
|
|
972
|
-
|
|
962
|
+
// ensure we don't destroy absolute urls like /system/images/whatever.jpg
|
|
963
|
+
loc.pathname = (loc.href[0] == '/' ? ("/" + loc.host) : '');
|
|
964
|
+
loc.pathname += '/' + parts.join('/');
|
|
973
965
|
|
|
974
966
|
//extract any hash and remove from the pathname
|
|
975
967
|
loc.pathname = loc.pathname.split('#');
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* jQuery UI Nested Sortable 1.0.1
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2010, Manuele J Sarfatti
|
|
5
|
+
*
|
|
6
|
+
* http://mjsarfatti.com/sandbox/nestedSortable
|
|
7
|
+
*
|
|
8
|
+
* Depends:
|
|
9
|
+
* jquery.ui.core.js 1.8+
|
|
10
|
+
* jquery.ui.widget.js 1.8+
|
|
11
|
+
* jquery.ui.sortable.js 1.8+
|
|
12
|
+
*/
|
|
13
|
+
(function($) {
|
|
14
|
+
$.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
|
15
|
+
options: {
|
|
16
|
+
tabSize: 20,
|
|
17
|
+
disableNesting: 'ui-nestedSortable-no-nesting',
|
|
18
|
+
errorClass: 'ui-nestedSortable-error'
|
|
19
|
+
},
|
|
20
|
+
_create: function(){
|
|
21
|
+
this.element.data('sortable', this.element.data('sortableTree'));
|
|
22
|
+
return $.ui.sortable.prototype._create.apply(this, arguments);
|
|
23
|
+
},
|
|
24
|
+
_mouseDrag: function(event) {
|
|
25
|
+
|
|
26
|
+
//Compute the helpers position
|
|
27
|
+
this.position = this._generatePosition(event);
|
|
28
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
|
29
|
+
|
|
30
|
+
if (!this.lastPositionAbs) {
|
|
31
|
+
this.lastPositionAbs = this.positionAbs;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//Do scrolling
|
|
35
|
+
if(this.options.scroll) {
|
|
36
|
+
var o = this.options, scrolled = false;
|
|
37
|
+
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
|
38
|
+
|
|
39
|
+
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
|
40
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
|
41
|
+
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
|
42
|
+
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
|
43
|
+
|
|
44
|
+
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
|
45
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
|
46
|
+
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
|
47
|
+
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
|
48
|
+
|
|
49
|
+
} else {
|
|
50
|
+
|
|
51
|
+
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
|
52
|
+
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
|
53
|
+
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
|
54
|
+
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
|
55
|
+
|
|
56
|
+
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
|
57
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
|
58
|
+
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
|
59
|
+
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
|
60
|
+
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
|
64
|
+
$.ui.ddmanager.prepareOffsets(this, event);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//Regenerate the absolute position used for position checks
|
|
68
|
+
this.positionAbs = this._convertPositionTo("absolute");
|
|
69
|
+
|
|
70
|
+
//Set the helper position
|
|
71
|
+
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
|
72
|
+
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
|
73
|
+
|
|
74
|
+
//Rearrange
|
|
75
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
|
76
|
+
|
|
77
|
+
//Cache variables and intersection, continue if no intersection
|
|
78
|
+
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
|
79
|
+
if (!intersection) continue;
|
|
80
|
+
|
|
81
|
+
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
|
82
|
+
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
|
83
|
+
&& !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
|
84
|
+
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
|
|
85
|
+
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
|
86
|
+
) {
|
|
87
|
+
|
|
88
|
+
this.direction = intersection == 1 ? "down" : "up";
|
|
89
|
+
|
|
90
|
+
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
|
91
|
+
this._rearrange(event, item);
|
|
92
|
+
} else {
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Clear emtpy ul's
|
|
97
|
+
this._clearUls(itemElement);
|
|
98
|
+
|
|
99
|
+
this._trigger("change", event, this._uiHash());
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Get the real previous item
|
|
105
|
+
itemBefore = this.placeholder[0].previousSibling;
|
|
106
|
+
while (itemBefore != null) {
|
|
107
|
+
if (itemBefore.nodeType == 1 && itemBefore != this.currentItem[0]) {
|
|
108
|
+
break;
|
|
109
|
+
} else {
|
|
110
|
+
itemBefore = itemBefore.previousSibling;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
parentItem = this.placeholder[0].parentNode.parentNode;
|
|
115
|
+
newUl = document.createElement('ul');
|
|
116
|
+
|
|
117
|
+
// Make/delete nested ul's
|
|
118
|
+
if (parentItem != null && parentItem.nodeName == 'LI' && this.positionAbs.left < parentItem.offsetLeft) {
|
|
119
|
+
$(parentItem).after(this.placeholder[0]);
|
|
120
|
+
this._clearUls(parentItem);
|
|
121
|
+
} else if (itemBefore != null && itemBefore.nodeName == 'LI' && this.position.left > itemBefore.offsetLeft + this.options.tabSize) {
|
|
122
|
+
if (!($(itemBefore).hasClass(this.options.disableNesting))) {
|
|
123
|
+
if ($(this.placeholder[0]).hasClass(this.options.errorClass)) {
|
|
124
|
+
$(this.placeholder[0]).css('marginLeft', 0).removeClass(this.options.errorClass);
|
|
125
|
+
}
|
|
126
|
+
if (itemBefore.children[1] == null) {
|
|
127
|
+
itemBefore.appendChild(newUl);
|
|
128
|
+
}
|
|
129
|
+
itemBefore.children[1].appendChild(this.placeholder[0]);
|
|
130
|
+
} else {
|
|
131
|
+
$(this.placeholder[0]).addClass(this.options.errorClass).css('marginLeft', this.options.tabSize);
|
|
132
|
+
}
|
|
133
|
+
} else if (itemBefore != null) {
|
|
134
|
+
if ($(this.placeholder[0]).hasClass(this.options.errorClass)) {
|
|
135
|
+
$(this.placeholder[0]).css('marginLeft', 0).removeClass(this.options.errorClass);
|
|
136
|
+
}
|
|
137
|
+
$(itemBefore).after(this.placeholder[0]);
|
|
138
|
+
}
|
|
139
|
+
//Post events to containers
|
|
140
|
+
this._contactContainers(event);
|
|
141
|
+
//Interconnect with droppables
|
|
142
|
+
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
|
143
|
+
//Call callbacks
|
|
144
|
+
this._trigger('sort', event, this._uiHash());
|
|
145
|
+
this.lastPositionAbs = this.positionAbs;
|
|
146
|
+
return false;
|
|
147
|
+
},
|
|
148
|
+
_clear: function(event, noPropagation) {
|
|
149
|
+
$.ui.sortable.prototype._clear.apply(this, arguments);
|
|
150
|
+
// Clean last empty ul
|
|
151
|
+
for (var i = this.items.length - 1; i >= 0; i--) {
|
|
152
|
+
var item = this.items[i].item[0];
|
|
153
|
+
this._clearUls(item);
|
|
154
|
+
}
|
|
155
|
+
return true;
|
|
156
|
+
},
|
|
157
|
+
_clearUls: function(item) {
|
|
158
|
+
if (item.children[1] && item.children[1].children.length == 0) {
|
|
159
|
+
item.removeChild(item.children[1]);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}));
|
|
163
|
+
$.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
|
|
164
|
+
})(jQuery);
|