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
|
@@ -1,265 +0,0 @@
|
|
|
1
|
-
# Base methods for CRUD actions
|
|
2
|
-
# Simply override any methods in your action controller you want to be customised
|
|
3
|
-
# Don't forget to add:
|
|
4
|
-
# resources :plural_model_name_here
|
|
5
|
-
# to your routes.rb file.
|
|
6
|
-
# Full documentation about CRUD and resources go here:
|
|
7
|
-
# -> http://caboo.se/doc/classes/ActionController/Resources.html#M003716
|
|
8
|
-
# Example (add to your controller):
|
|
9
|
-
# crudify :foo, {:title_attribute => 'name'}
|
|
10
|
-
|
|
11
|
-
module Crud
|
|
12
|
-
|
|
13
|
-
def self.append_features(base)
|
|
14
|
-
super
|
|
15
|
-
base.extend(ClassMethods)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
module ClassMethods
|
|
19
|
-
|
|
20
|
-
def crudify(model_name, new_options = {})
|
|
21
|
-
singular_name = model_name.to_s
|
|
22
|
-
class_name = singular_name.camelize
|
|
23
|
-
plural_name = singular_name.pluralize
|
|
24
|
-
|
|
25
|
-
options = {
|
|
26
|
-
:title_attribute => "title",
|
|
27
|
-
:order => 'position ASC',
|
|
28
|
-
:conditions => '',
|
|
29
|
-
:sortable => true,
|
|
30
|
-
:searchable => true,
|
|
31
|
-
:include => [],
|
|
32
|
-
:paging => true,
|
|
33
|
-
:search_conditions => '',
|
|
34
|
-
:redirect_to_url => "admin_#{plural_name}_url"
|
|
35
|
-
}.merge!(new_options)
|
|
36
|
-
|
|
37
|
-
module_eval %(
|
|
38
|
-
prepend_before_filter :find_#{singular_name},
|
|
39
|
-
:only => [:update, :destroy, :edit, :show]
|
|
40
|
-
|
|
41
|
-
def new
|
|
42
|
-
@#{singular_name} = #{class_name}.new
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def create
|
|
46
|
-
# if the position field exists, set this object as last object, given the conditions of this class.
|
|
47
|
-
if #{class_name}.column_names.include?("position")
|
|
48
|
-
params[:#{singular_name}].merge!({
|
|
49
|
-
:position => ((#{class_name}.maximum(:position, :conditions => "#{options[:conditions]}")||-1) + 1)
|
|
50
|
-
})
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
if (@#{singular_name} = #{class_name}.create(params[:#{singular_name}])).valid?
|
|
54
|
-
unless request.xhr?
|
|
55
|
-
flash[:notice] = t('refinery.crudify.created',
|
|
56
|
-
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
|
|
57
|
-
else
|
|
58
|
-
flash.now[:notice] = t('refinery.crudify.created',
|
|
59
|
-
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
|
|
60
|
-
end
|
|
61
|
-
unless from_dialog?
|
|
62
|
-
unless params[:continue_editing] =~ /true|on|1/
|
|
63
|
-
redirect_back_or_default(#{options[:redirect_to_url]})
|
|
64
|
-
else
|
|
65
|
-
unless request.xhr?
|
|
66
|
-
redirect_to :back
|
|
67
|
-
else
|
|
68
|
-
render :partial => "/shared/message"
|
|
69
|
-
end
|
|
70
|
-
end
|
|
71
|
-
else
|
|
72
|
-
render :text => "<script type='text/javascript'>parent.window.location = '\#{#{options[:redirect_to_url]}}';</script>"
|
|
73
|
-
end
|
|
74
|
-
else
|
|
75
|
-
unless request.xhr?
|
|
76
|
-
render :action => 'new'
|
|
77
|
-
else
|
|
78
|
-
render :partial => "/shared/admin/error_messages",
|
|
79
|
-
:locals => {
|
|
80
|
-
:object => @#{singular_name},
|
|
81
|
-
:include_object_name => true
|
|
82
|
-
}
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def edit
|
|
88
|
-
# object gets found by find_#{singular_name} function
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def update
|
|
92
|
-
if @#{singular_name}.update_attributes(params[:#{singular_name}])
|
|
93
|
-
unless request.xhr?
|
|
94
|
-
flash[:notice] = t('refinery.crudify.updated',
|
|
95
|
-
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
|
|
96
|
-
else
|
|
97
|
-
flash.now[:notice] = t('refinery.crudify.updated',
|
|
98
|
-
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
|
|
99
|
-
end
|
|
100
|
-
unless from_dialog?
|
|
101
|
-
unless params[:continue_editing] =~ /true|on|1/
|
|
102
|
-
redirect_back_or_default(#{options[:redirect_to_url]})
|
|
103
|
-
else
|
|
104
|
-
unless request.xhr?
|
|
105
|
-
redirect_to :back
|
|
106
|
-
else
|
|
107
|
-
render :partial => "/shared/message"
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
else
|
|
111
|
-
render :text => "<script type='text/javascript'>parent.window.location = '\#{#{options[:redirect_to_url]}}';</script>"
|
|
112
|
-
end
|
|
113
|
-
else
|
|
114
|
-
unless request.xhr?
|
|
115
|
-
render :action => 'edit'
|
|
116
|
-
else
|
|
117
|
-
render :partial => "/shared/admin/error_messages",
|
|
118
|
-
:locals => {
|
|
119
|
-
:object => @#{singular_name},
|
|
120
|
-
:include_object_name => true
|
|
121
|
-
}
|
|
122
|
-
end
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def destroy
|
|
127
|
-
if @#{singular_name}.destroy
|
|
128
|
-
flash[:notice] = t('refinery.crudify.destroyed',
|
|
129
|
-
:what => "'\#{@#{singular_name}.#{options[:title_attribute]}}'")
|
|
130
|
-
end
|
|
131
|
-
redirect_to #{options[:redirect_to_url]}
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def find_#{singular_name}
|
|
135
|
-
@#{singular_name} = #{class_name}.find(params[:id],
|
|
136
|
-
:include => %w(#{options[:include].join(' ')}))
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def find_all_#{plural_name}
|
|
140
|
-
@#{plural_name} = #{class_name}.find(
|
|
141
|
-
:all,
|
|
142
|
-
:order => "#{options[:order]}",
|
|
143
|
-
:conditions => "#{options[:conditions]}",
|
|
144
|
-
:include => %w(#{options[:include].join(' ')})
|
|
145
|
-
)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def paginate_all_#{plural_name}
|
|
149
|
-
@#{plural_name} = #{class_name}.paginate(
|
|
150
|
-
:page => params[:page],
|
|
151
|
-
:order => "#{options[:order]}",
|
|
152
|
-
:conditions => "#{options[:conditions]}",
|
|
153
|
-
:include => %w(#{options[:include].join(' ')})
|
|
154
|
-
)
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def search_all_#{plural_name}
|
|
158
|
-
@#{plural_name} = #{class_name}.with_query(params[:search]).find(
|
|
159
|
-
:all,
|
|
160
|
-
:order => "#{options[:order]}",
|
|
161
|
-
:conditions => "#{options[:search_conditions]}",
|
|
162
|
-
:include => %w(#{options[:include].join(' ')})
|
|
163
|
-
)
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
def search_and_paginate_all_#{plural_name}
|
|
167
|
-
@#{plural_name} = #{class_name}.with_query(params[:search]).paginate(
|
|
168
|
-
:page => params[:page],
|
|
169
|
-
:order => "#{options[:order]}",
|
|
170
|
-
:conditions => "#{options[:search_conditions]}",
|
|
171
|
-
:include => %w(#{options[:include].join(' ')})
|
|
172
|
-
)
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
protected :find_#{singular_name},
|
|
176
|
-
:find_all_#{plural_name},
|
|
177
|
-
:paginate_all_#{plural_name},
|
|
178
|
-
:search_all_#{plural_name},
|
|
179
|
-
:search_and_paginate_all_#{plural_name}
|
|
180
|
-
|
|
181
|
-
)
|
|
182
|
-
|
|
183
|
-
if options[:searchable]
|
|
184
|
-
if options[:paging]
|
|
185
|
-
module_eval %(
|
|
186
|
-
def index
|
|
187
|
-
if searching?
|
|
188
|
-
search_and_paginate_all_#{plural_name}
|
|
189
|
-
else
|
|
190
|
-
paginate_all_#{plural_name}
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
)
|
|
194
|
-
else
|
|
195
|
-
module_eval %(
|
|
196
|
-
def index
|
|
197
|
-
if searching?
|
|
198
|
-
search_all_#{plural_name}
|
|
199
|
-
else
|
|
200
|
-
find_all_#{plural_name}
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
)
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
else
|
|
207
|
-
if options[:paging]
|
|
208
|
-
module_eval %(
|
|
209
|
-
def index
|
|
210
|
-
paginate_all_#{plural_name}
|
|
211
|
-
end
|
|
212
|
-
)
|
|
213
|
-
else
|
|
214
|
-
module_eval %(
|
|
215
|
-
def index
|
|
216
|
-
find_all_#{plural_name}
|
|
217
|
-
end
|
|
218
|
-
)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
if options[:sortable]
|
|
224
|
-
module_eval %(
|
|
225
|
-
def reorder
|
|
226
|
-
find_all_#{plural_name}
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def update_positions
|
|
230
|
-
unless params[:tree] == "true"
|
|
231
|
-
params[:sortable_list].each_with_index do |i, index|
|
|
232
|
-
#{class_name}.find(i).update_attribute(:position, index)
|
|
233
|
-
end
|
|
234
|
-
else
|
|
235
|
-
params[:sortable_list].each do |position, id_hash|
|
|
236
|
-
parse_branch(position, id_hash, nil)
|
|
237
|
-
end
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
find_all_#{plural_name}
|
|
241
|
-
render :partial => 'sortable_list',
|
|
242
|
-
:layout => false,
|
|
243
|
-
:locals => {
|
|
244
|
-
:continue_reordering => params[:continue_reordering]
|
|
245
|
-
}
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
# takes in a single branch and saves the nodes inside it
|
|
249
|
-
def parse_branch(position, id_hash, parent_id)
|
|
250
|
-
id_hash.each do |pos, id|
|
|
251
|
-
parse_branch(pos, id, id_hash["id"]) unless pos == "id"
|
|
252
|
-
end if id_hash.include?('0')
|
|
253
|
-
|
|
254
|
-
#{class_name}.update_all(["parent_id = ?, position = ?", parent_id, position], ["id = ?", id_hash["id"]])
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
protected :parse_branch
|
|
258
|
-
)
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
end
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
require_dependency 'truncate_html'
|
|
2
|
-
|
|
3
|
-
module Refinery::HtmlTruncationHelper
|
|
4
|
-
|
|
5
|
-
# Like the Rails _truncate_ helper but doesn't break HTML tags, entities, and words.
|
|
6
|
-
# <script> tags pass through and are not counted in the total.
|
|
7
|
-
# the omission specified _does_ count toward the total length count.
|
|
8
|
-
# use :link => link_to('more', post_path), or something to that effect
|
|
9
|
-
def truncate(text, *args)
|
|
10
|
-
return unless text.present?
|
|
11
|
-
return super unless ((arguments = args.dup).extract_options![:preserve_html_tags] == true) # don't ruin the current args object
|
|
12
|
-
|
|
13
|
-
options = args.extract_options!
|
|
14
|
-
max_length = options[:length] || 30
|
|
15
|
-
omission = options[:omission] || "..."
|
|
16
|
-
|
|
17
|
-
return truncate_html(text,
|
|
18
|
-
:length => max_length,
|
|
19
|
-
:word_boundary => true,
|
|
20
|
-
:omission => omission)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
$.fn.nestedSortable = function(options) {
|
|
2
|
-
|
|
3
|
-
var settings = $.extend({
|
|
4
|
-
nestable: 'li'
|
|
5
|
-
, container: 'ul'
|
|
6
|
-
, indent: 30
|
|
7
|
-
, handle: null
|
|
8
|
-
, opacity: 1
|
|
9
|
-
, placeholderClass: 'placeholder'
|
|
10
|
-
, placeholderElement: 'div'
|
|
11
|
-
, helperClass: 'helper'
|
|
12
|
-
, appendTo: 'parent'
|
|
13
|
-
, start: function() {}
|
|
14
|
-
, stop: function() {}
|
|
15
|
-
, drag: function() {}
|
|
16
|
-
, maxDepth: null
|
|
17
|
-
}, options);
|
|
18
|
-
settings.snapTolerance = settings.indent * 0.4;
|
|
19
|
-
cursor = {x: 0, y: 0};
|
|
20
|
-
|
|
21
|
-
this.each(function() {
|
|
22
|
-
|
|
23
|
-
// The top level nestable list container
|
|
24
|
-
var $root = $(this);
|
|
25
|
-
|
|
26
|
-
// An element placed to preview the location of the dragged element in its new position
|
|
27
|
-
var $placeholder = $('<' + settings.placeholderElement + '></' + settings.placeholderElement + '>', {
|
|
28
|
-
"class": settings.placeholderClass
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
$root.find(settings.nestable).each(function() {
|
|
33
|
-
|
|
34
|
-
var $this = $(this);
|
|
35
|
-
|
|
36
|
-
// Check if the element has already been set up as a nestable
|
|
37
|
-
if (!$this.data("nestable")) {
|
|
38
|
-
|
|
39
|
-
// Make the element draggable
|
|
40
|
-
$this.draggable({
|
|
41
|
-
|
|
42
|
-
// Transfer over some settings to jQuery's draggable implementation
|
|
43
|
-
opacity: settings.opacity,
|
|
44
|
-
handle: settings.handle,
|
|
45
|
-
appendTo: settings.appendTo,
|
|
46
|
-
|
|
47
|
-
// Creates a helper element
|
|
48
|
-
helper: function() {
|
|
49
|
-
// Create a helper that is a clone of the original (with a few little tweaks)
|
|
50
|
-
return $this.clone().width($this.width()).addClass(settings.helperClass);
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
// When dragging starts
|
|
54
|
-
start: function() {
|
|
55
|
-
|
|
56
|
-
// Hide the original and initialize the placeholder ontop of the starting position
|
|
57
|
-
$this.addClass('ui-dragging').hide().after($placeholder);
|
|
58
|
-
|
|
59
|
-
// Find the deepest nested child
|
|
60
|
-
var maxChildDepth = 0;
|
|
61
|
-
$this.find(settings.nestable).each(function(index, child) {
|
|
62
|
-
var $child = $(child);
|
|
63
|
-
var childDepth = $child.parentsUntil($this).filter(settings.nestable).length;
|
|
64
|
-
if (childDepth > maxChildDepth) {
|
|
65
|
-
maxChildDepth = childDepth;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
$this.data("maxChildDepth", maxChildDepth);
|
|
69
|
-
|
|
70
|
-
// Run a custom start function specitifed in the settings
|
|
71
|
-
settings.start.apply(this);
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// When dragging ends
|
|
76
|
-
stop: function(event, ui) {
|
|
77
|
-
// Replace the placeholder with the original while protecting it from disappearing.
|
|
78
|
-
if ($.inArray($root.get(0), $placeholder.parents()) > -1) {
|
|
79
|
-
$placeholder.after($this.show()).remove();
|
|
80
|
-
} else {
|
|
81
|
-
$this.show();
|
|
82
|
-
$placeholder.remove();
|
|
83
|
-
}
|
|
84
|
-
// Run a custom stop function specitifed in the settings
|
|
85
|
-
settings.stop.apply(this);
|
|
86
|
-
$('.ui-dragging').removeClass('ui-dragging');
|
|
87
|
-
$('.below-placeholder').removeClass('below-placeholder').animate({'marginTop':'0px'}, 0);
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
// Each "step" during the drag
|
|
91
|
-
drag: function (event, ui) {
|
|
92
|
-
// reduce sensitivity
|
|
93
|
-
if (cursor.y == 0 || typeof(event.clientY) == 'undefined' || ((cursor.y - event.clientY) >= 15) || ((cursor.y - event.clientY) <= -15) ) {
|
|
94
|
-
// Cycle through all nestables to find the item directly underneath the helper
|
|
95
|
-
var largestY = 0;
|
|
96
|
-
var depth;
|
|
97
|
-
var maxChildDepth = $this.data("maxChildDepth");
|
|
98
|
-
var underItems = $.grep($root.find(settings.nestable), function(item) {
|
|
99
|
-
|
|
100
|
-
$item = $(item);
|
|
101
|
-
|
|
102
|
-
// Is the item being checked underneath the one being dragged?
|
|
103
|
-
if (!(($item.offset().top < ui.position.top) && ($item.offset().top > largestY))) {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// Is the item being checked on the same nesting level as the dragged item?
|
|
108
|
-
if ($item.offset().left - settings.snapTolerance >= ui.position.left) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
// Make sure the item being checked is not part of the helper
|
|
113
|
-
if (ui.helper.find($item).length) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Make sure the item complies with max depth rules
|
|
118
|
-
if (settings.maxDepth !== null) {
|
|
119
|
-
depth = $item.parentsUntil($root).filter(settings.container).length + maxChildDepth;
|
|
120
|
-
if (depth - 1 > settings.maxDepth) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// If we've got this far, its a match
|
|
126
|
-
largestY = $item.offset().top;
|
|
127
|
-
return true;
|
|
128
|
-
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
var underItem = underItems.length ? $(underItems.pop()) : null;
|
|
132
|
-
var nestedBeneath = null;
|
|
133
|
-
|
|
134
|
-
// If there is no item directly underneath the helper, check if the helper is over the first list item
|
|
135
|
-
if (underItem === null) {
|
|
136
|
-
var firstItem = $root.find(settings.nestable + ":first");
|
|
137
|
-
|
|
138
|
-
if ((firstItem.offset().top < ui.position.top + $(this).height()) && (firstItem.offset().top > ui.position.top)) {
|
|
139
|
-
underContainer = firstItem.closest(settings.container);
|
|
140
|
-
nestedBeneath = underContainer;
|
|
141
|
-
underContainer.prepend($placeholder);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
// Place the placeholder inside or after the item underneath, depending on their relative x coordinates
|
|
145
|
-
} else {
|
|
146
|
-
// Should the dragged item be nested?
|
|
147
|
-
if ((underItem.offset().left + settings.indent - settings.snapTolerance < ui.position.left) && (settings.maxDepth === null || depth <= settings.maxDepth)) {
|
|
148
|
-
underContainer = underItem.children(settings.container);
|
|
149
|
-
nestedBeneath = underContainer;
|
|
150
|
-
underContainer.prepend($placeholder);
|
|
151
|
-
}
|
|
152
|
-
// ... or should it just be placed after
|
|
153
|
-
else {
|
|
154
|
-
nestedBeneath = underItem;
|
|
155
|
-
underItem.after($placeholder);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
try{
|
|
159
|
-
$placeholder.css({'width': (w = nestedBeneath.width()) > 0 ? w : $placeholder.parent().width()});
|
|
160
|
-
} catch(e) {}
|
|
161
|
-
|
|
162
|
-
old_placeholder = $('.below-placeholder').removeClass('below-placeholder');
|
|
163
|
-
new_below_placeholder = $placeholder.nextAll('li.record:not(.ui-dragging):not(.ui-draggable-dragging):first').addClass('below-placeholder');
|
|
164
|
-
if (old_placeholder.attr('id') != new_below_placeholder.attr('id')) {
|
|
165
|
-
old_placeholder.animate({'marginTop':'0px'}, 125);
|
|
166
|
-
new_below_placeholder.addClass('below-placeholder').animate({'marginTop' : '20px'}, 125);
|
|
167
|
-
}
|
|
168
|
-
// Run a custom drag callback specifed in the settings
|
|
169
|
-
settings.drag.apply(this);
|
|
170
|
-
|
|
171
|
-
// save mouse co-ordinates.
|
|
172
|
-
if (typeof(event.clientX) != 'undefined') {
|
|
173
|
-
cursor.x = event.clientX;
|
|
174
|
-
}
|
|
175
|
-
if (typeof(event.clientY) != 'undefined') {
|
|
176
|
-
cursor.y = event.clientY;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
}).data("nestable", true);
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
});
|
|
185
|
-
return this;
|
|
186
|
-
};
|