alchemy_cms 2.2.4 → 2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/.travis.yml +3 -4
- data/Gemfile +1 -0
- data/README.md +10 -6
- data/alchemy_cms.gemspec +5 -2
- data/app/assets/images/alchemy/icons.png +0 -0
- data/app/assets/images/sassy-ie-overlay.png +0 -0
- data/app/assets/javascripts/alchemy/alchemy.base.js +50 -59
- data/app/assets/javascripts/alchemy/alchemy.buttons.js +14 -4
- data/app/assets/javascripts/alchemy/alchemy.datepicker.js +8 -2
- data/app/assets/javascripts/alchemy/alchemy.elements_window.js +11 -3
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +1 -1
- data/app/assets/javascripts/alchemy/alchemy.link_overlay.js.coffee +14 -1
- data/app/assets/javascripts/alchemy/alchemy.preview.js +1 -1
- data/app/assets/javascripts/alchemy/alchemy.preview_window.js +12 -4
- data/app/assets/javascripts/alchemy/alchemy.uploader.js +4 -1
- data/app/assets/javascripts/alchemy/alchemy.windows.js +18 -8
- data/app/assets/stylesheets/alchemy/_defaults.scss +84 -120
- data/app/assets/stylesheets/alchemy/alchemy.css +2 -2
- data/app/assets/stylesheets/alchemy/archive.css.scss +288 -0
- data/app/assets/stylesheets/alchemy/base.css.scss +95 -390
- data/app/assets/stylesheets/alchemy/dashboard.css.scss +4 -4
- data/app/assets/stylesheets/alchemy/elements.css.scss +83 -118
- data/app/assets/stylesheets/alchemy/flash.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/form_elements.css.scss +528 -0
- data/app/assets/stylesheets/alchemy/frame.css.scss +13 -39
- data/app/assets/stylesheets/alchemy/icons.css.scss +217 -228
- data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +48 -50
- data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
- data/app/assets/stylesheets/alchemy/login.css.scss +1 -5
- data/app/assets/stylesheets/alchemy/menubar.css.scss +19 -29
- data/app/assets/stylesheets/alchemy/pagination.css.scss +3 -4
- data/app/assets/stylesheets/alchemy/sitemap.css.scss +81 -81
- data/app/assets/stylesheets/alchemy/tables.css.scss +63 -57
- data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +57 -57
- data/app/assets/stylesheets/alchemy/upload.css.scss +6 -6
- data/app/assets/stylesheets/tiny_mce/plugins/inlinepopups/skins/alchemy/window.css.scss +6 -10
- data/app/controllers/alchemy/admin/attachments_controller.rb +5 -4
- data/app/controllers/alchemy/admin/base_controller.rb +1 -9
- data/app/controllers/alchemy/admin/contents_controller.rb +4 -6
- data/app/controllers/alchemy/admin/elements_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pages_controller.rb +2 -2
- data/app/controllers/alchemy/admin/pictures_controller.rb +74 -15
- data/app/controllers/alchemy/attachments_controller.rb +8 -2
- data/app/controllers/alchemy/base_controller.rb +47 -5
- data/app/controllers/alchemy/elements_controller.rb +1 -1
- data/app/controllers/alchemy/messages_controller.rb +12 -12
- data/app/controllers/alchemy/pages_controller.rb +5 -1
- data/app/controllers/alchemy/pictures_controller.rb +9 -4
- data/app/controllers/alchemy/user_sessions_controller.rb +2 -4
- data/app/helpers/alchemy/admin/base_helper.rb +98 -19
- data/app/helpers/alchemy/admin/contents_helper.rb +2 -2
- data/app/helpers/alchemy/admin/elements_helper.rb +2 -3
- data/app/helpers/alchemy/base_helper.rb +6 -5
- data/app/helpers/alchemy/elements_helper.rb +2 -2
- data/app/helpers/alchemy/essences_helper.rb +4 -5
- data/app/helpers/alchemy/pages_helper.rb +15 -79
- data/app/helpers/alchemy/url_helper.rb +67 -0
- data/app/mailers/alchemy/messages.rb +1 -1
- data/app/mailers/alchemy/notifications.rb +1 -1
- data/app/models/alchemy/attachment.rb +11 -2
- data/app/models/alchemy/cell.rb +20 -10
- data/app/models/alchemy/content.rb +4 -3
- data/app/models/alchemy/element.rb +170 -178
- data/app/models/alchemy/language/code.rb +4 -1
- data/app/models/alchemy/message.rb +19 -3
- data/app/models/alchemy/page.rb +45 -40
- data/app/models/alchemy/picture.rb +24 -2
- data/app/models/alchemy/user.rb +2 -3
- data/app/views/alchemy/admin/attachments/_archive_overlay.html.erb +12 -12
- data/app/views/alchemy/admin/attachments/_attachment.html.erb +1 -1
- data/app/views/alchemy/admin/attachments/create.js.erb +1 -0
- data/app/views/alchemy/admin/attachments/edit.html.erb +9 -3
- data/app/views/alchemy/admin/attachments/index.html.erb +3 -2
- data/app/views/alchemy/admin/contents/_missing.html.erb +1 -1
- data/app/views/alchemy/admin/contents/create.js.erb +54 -0
- data/app/views/alchemy/admin/contents/new.html.erb +9 -4
- data/app/views/alchemy/admin/elements/{_add_content.html.erb → _add_picture.html.erb} +4 -4
- data/app/views/alchemy/admin/elements/_elements_select.html.erb +2 -1
- data/app/views/alchemy/admin/elements/_new_element_form.html.erb +1 -1
- data/app/views/alchemy/admin/elements/{_picture_editor.html.erb → _picture_gallery_editor.html.erb} +7 -11
- data/app/views/alchemy/admin/elements/fold.js.erb +46 -0
- data/app/views/alchemy/admin/elements/index.html.erb +24 -24
- data/app/views/alchemy/admin/elements/list.js.erb +11 -9
- data/app/views/alchemy/admin/essence_files/assign.js.erb +3 -1
- data/app/views/alchemy/admin/essence_pictures/destroy.js.erb +28 -0
- data/app/views/alchemy/admin/pages/_contactform_links.html.erb +8 -6
- data/app/views/alchemy/admin/pages/_external_link.html.erb +11 -9
- data/app/views/alchemy/admin/pages/_file_link.html.erb +10 -8
- data/app/views/alchemy/admin/pages/_internal_link.html.erb +14 -10
- data/app/views/alchemy/admin/pages/_new_page_form.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page.html.erb +1 -1
- data/app/views/alchemy/admin/pages/_page_for_links.html.erb +32 -21
- data/app/views/alchemy/admin/pages/configure.html.erb +2 -2
- data/app/views/alchemy/admin/pages/configure_external.html.erb +13 -13
- data/app/views/alchemy/admin/pages/edit.html.erb +2 -2
- data/app/views/alchemy/admin/pages/index.html.erb +26 -24
- data/app/views/alchemy/admin/pages/link.html.erb +2 -5
- data/app/views/alchemy/admin/partials/_upload_form.html.erb +28 -12
- data/app/views/alchemy/admin/pictures/_archive.html.erb +54 -0
- data/app/views/alchemy/admin/pictures/_archive_overlay.html.erb +10 -7
- data/app/views/alchemy/admin/pictures/_filter_and_size_bar.html.erb +21 -22
- data/app/views/alchemy/admin/pictures/_filter_bar.html.erb +31 -0
- data/app/views/alchemy/admin/pictures/_overlay_picture_list.html.erb +9 -0
- data/app/views/alchemy/admin/pictures/_picture.html.erb +36 -6
- data/app/views/alchemy/admin/pictures/_tag_list.html.erb +27 -0
- data/app/views/alchemy/admin/pictures/archive_overlay.js.erb +3 -1
- data/app/views/alchemy/admin/pictures/create.js.erb +4 -5
- data/app/views/alchemy/admin/pictures/edit.html.erb +26 -0
- data/app/views/alchemy/admin/pictures/edit_multiple.html.erb +39 -0
- data/app/views/alchemy/admin/pictures/index.html.erb +81 -70
- data/app/views/alchemy/admin/pictures/index.js.erb +3 -0
- data/app/views/alchemy/admin/pictures/new.html.erb +1 -0
- data/app/views/alchemy/admin/resources/index.html.erb +3 -1
- data/app/views/alchemy/admin/users/_table.html.erb +1 -1
- data/app/views/alchemy/admin/users/index.html.erb +27 -23
- data/app/views/alchemy/elements/_article_editor.html.erb +7 -2
- data/app/views/alchemy/elements/_bild_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_bild_text_editor.html.erb +6 -1
- data/app/views/alchemy/elements/_bild_text_view.html.erb +3 -3
- data/app/views/alchemy/elements/_image_mosaic_editor.html.erb +1 -1
- data/app/views/alchemy/elements/_image_mosaic_view.html.erb +2 -2
- data/app/views/alchemy/elements/_intro_image_text_view.html.erb +4 -4
- data/app/views/alchemy/elements/_searchresult_editor.html.erb +4 -1
- data/app/views/alchemy/essences/_essence_boolean_editor.html.erb +1 -1
- data/app/views/alchemy/essences/_essence_picture_editor.html.erb +2 -3
- data/app/views/alchemy/essences/_essence_picture_tools.html.erb +1 -1
- data/app/views/alchemy/search/_form.html.erb +8 -0
- data/app/views/alchemy/search/_result.html.erb +3 -2
- data/app/views/alchemy/search/_results.html.erb +28 -0
- data/app/views/alchemy/user_sessions/leave.html.erb +4 -4
- data/app/views/alchemy/user_sessions/login.html.erb +1 -2
- data/app/views/layouts/alchemy/admin.html.erb +30 -10
- data/app/views/layouts/alchemy/login.html.erb +2 -39
- data/config/alchemy/elements.yml +1 -2
- data/config/alchemy/page_layouts.yml +8 -5
- data/config/authorization_rules.rb +27 -18
- data/config/initializers/localeapp.rb +9 -0
- data/config/locales/alchemy.de.yml +93 -56
- data/config/locales/alchemy.en.yml +73 -50
- data/config/routes.rb +3 -1
- data/db/migrate/20120704181529_add_upload_hash_to_alchemy_picture.rb +5 -0
- data/db/migrate/20120705214247_acts_as_taggable_on_migration.rb +28 -0
- data/db/migrate/20120728185830_add_cached_tag_list_to_alchemy_pictures.rb +5 -0
- data/db/migrate/20120831135441_set_alchemy_languages_country_code_default_to_empty_string.rb +9 -0
- data/lib/alchemy/capistrano.rb +2 -2
- data/lib/alchemy/essence.rb +14 -0
- data/lib/alchemy/page_layout.rb +0 -6
- data/lib/alchemy/resource.rb +9 -15
- data/lib/alchemy/upgrader.rb +18 -3
- data/lib/alchemy/version.rb +5 -1
- data/lib/alchemy_cms.rb +4 -1
- data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +16 -6
- data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +17 -3
- data/lib/rails/generators/alchemy/elements/elements_generator.rb +6 -1
- data/lib/rails/generators/alchemy/elements/templates/editor.html.erb +10 -1
- data/lib/rails/generators/alchemy/elements/templates/view.html.erb +17 -18
- data/lib/rails/generators/alchemy/scaffold/files/pages.html.erb +4 -2
- data/lib/tasks/fleximage.rake +2 -2
- data/spec/controllers/admin/contents_controller_spec.rb +2 -2
- data/spec/controllers/admin/elements_controller_spec.rb +30 -1
- data/spec/controllers/admin/pages_controller_spec.rb +35 -18
- data/spec/controllers/admin/trash_controller_spec.rb +40 -16
- data/spec/controllers/attachments_controller_spec.rb +62 -0
- data/spec/controllers/base_controller_spec.rb +43 -42
- data/spec/controllers/elements_controller_spec.rb +30 -0
- data/spec/controllers/pages_controller_spec.rb +22 -5
- data/spec/controllers/pictures_controller_spec.rb +82 -0
- data/spec/dummy/app/models/event.rb +2 -1
- data/spec/dummy/config/database.yml +3 -2
- data/spec/dummy/db/schema.rb +51 -27
- data/spec/factories.rb +29 -8
- data/spec/helpers/admin/base_helper_spec.rb +134 -21
- data/spec/helpers/admin/contents_helper_spec.rb +2 -2
- data/spec/helpers/admin/elements_helper_spec.rb +17 -9
- data/spec/helpers/admin/essences_helper_spec.rb +7 -6
- data/spec/helpers/essences_helper_spec.rb +8 -7
- data/spec/helpers/pages_helper_spec.rb +208 -325
- data/spec/helpers/url_helper_spec.rb +171 -0
- data/spec/integration/admin/link_overlay_spec.rb +53 -0
- data/spec/integration/admin/modules_integration_spec.rb +22 -26
- data/spec/integration/admin/pages_controller_spec.rb +10 -19
- data/spec/integration/admin/picture_library_integration_spec.rb +52 -0
- data/spec/integration/admin/resources_integration_spec.rb +68 -75
- data/spec/integration/pages_controller_spec.rb +70 -61
- data/spec/integration/security_spec.rb +3 -5
- data/spec/integration/translation_integration_spec.rb +56 -0
- data/spec/libraries/essence_spec.rb +18 -0
- data/spec/libraries/resource_spec.rb +101 -79
- data/spec/libraries/resources_helper_spec.rb +3 -0
- data/spec/models/content_spec.rb +63 -60
- data/spec/models/element_spec.rb +203 -93
- data/spec/models/language_spec.rb +90 -65
- data/spec/models/page_layout_spec.rb +37 -0
- data/spec/models/page_spec.rb +181 -113
- data/spec/models/picture_spec.rb +73 -26
- data/spec/models/resource_spec.rb +52 -23
- data/spec/support/alchemy/specs_helpers.rb +2 -0
- data/spec/support/image.png +0 -0
- data/spec/{helpers/url_helpers_spec.rb → url_helpers_spec.rb} +0 -0
- data/vendor/assets/javascripts/jquery_plugins/jquery.selectBoxIt.js +1909 -0
- data/vendor/assets/javascripts/jquery_plugins/preloadCssImages.jQuery_v5.js +152 -0
- metadata +106 -33
- data/app/assets/stylesheets/alchemy/buttons.css.scss +0 -361
- data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +0 -260
- data/app/views/alchemy/admin/contents/create.js.coffee +0 -49
- data/app/views/alchemy/admin/elements/fold.js.coffee +0 -37
- data/app/views/alchemy/admin/essence_pictures/destroy.js.coffee +0 -19
- data/app/views/alchemy/admin/pictures/_pictures_list.html.erb +0 -16
- data/app/views/alchemy/admin/pictures/update.js.erb +0 -3
- data/spec/dummy/config/locales/en.yml +0 -5
- data/spec/dummy/config/locales/fo.yml +0 -5
- data/spec/page_layout_spec.rb +0 -35
- data/vendor/assets/javascripts/jquery_plugins/jquery.in-place-edit.js +0 -172
- data/vendor/assets/javascripts/jquery_plugins/jquery.sb.min.js +0 -14
@@ -1,49 +0,0 @@
|
|
1
|
-
<% if params[:was_missing] %>
|
2
|
-
|
3
|
-
$("#element_<%= @element.id %>_content_missing").replaceWith('<%= escape_javascript(
|
4
|
-
render(
|
5
|
-
:partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
|
6
|
-
:locals => @locals
|
7
|
-
)
|
8
|
-
) %>')
|
9
|
-
|
10
|
-
<% else %>
|
11
|
-
|
12
|
-
$("<%= @content_dom_id %>").before('<%= escape_javascript(
|
13
|
-
render(
|
14
|
-
:partial => "alchemy/essences/#{@content.essence_partial_name}_editor",
|
15
|
-
:locals => @locals
|
16
|
-
)
|
17
|
-
) %>')
|
18
|
-
Alchemy.enableButton('.disabled.button')
|
19
|
-
Alchemy.overlayObserver('#<%= content_dom_id(@content) %>')
|
20
|
-
|
21
|
-
<% end %>
|
22
|
-
|
23
|
-
<% if @content.essence_type == "Alchemy::EssencePicture" %>
|
24
|
-
|
25
|
-
$('#picture_to_assign_<%= @content.ingredient.id %> a').attr('href', '#').off('click')
|
26
|
-
|
27
|
-
<% if @contents_of_this_type.length > 1 %>
|
28
|
-
$('#element_<%= @element.id %>_contents .essence_picture_editor').addClass('dragable_picture')
|
29
|
-
<% end %>
|
30
|
-
|
31
|
-
<% if !max_image_count.blank? && @contents_of_this_type.length >= max_image_count %>
|
32
|
-
$("#add_content_<%= @element.id %>").remove()
|
33
|
-
<% end %>
|
34
|
-
|
35
|
-
Alchemy.SortableContents('#element_<%= @element.id %>_contents', '<%= form_authenticity_token %>')
|
36
|
-
|
37
|
-
<% elsif @content.essence_type == "Alchemy::EssenceDate" %>
|
38
|
-
|
39
|
-
Alchemy.Datepicker('#element_<%= @element.id %> input.date')
|
40
|
-
|
41
|
-
<% elsif @content.essence_type == "Alchemy::EssenceRichtext" %>
|
42
|
-
|
43
|
-
Alchemy.Tinymce.addEditor('contents_content_<%= @content.id %>_body')
|
44
|
-
|
45
|
-
<% end %>
|
46
|
-
|
47
|
-
Alchemy.reloadPreview()
|
48
|
-
Alchemy.closeCurrentWindow()
|
49
|
-
Alchemy.SelectBox("#element_<%= @element.id %> select.alchemy_selectbox")
|
@@ -1,37 +0,0 @@
|
|
1
|
-
$el = $('.element_editor[data-element-id="<%= @element.id %>"]')
|
2
|
-
|
3
|
-
<% if @error %>
|
4
|
-
|
5
|
-
$("#element_<%= @element.id -%>_folder_spinner").replaceWith("<span class='error_icon' title='<%= @error -%>'>!</span>")
|
6
|
-
|
7
|
-
<% else %>
|
8
|
-
|
9
|
-
$el = $el.replaceWith('<%= escape_javascript render(:partial => "element", :object => @element) -%>')
|
10
|
-
$('#element_area .sortable_cell').sortable('refresh')
|
11
|
-
Alchemy.ElementEditorSelector.reinit('.element_editor[data-element-id="<%= @element.id %>"]')
|
12
|
-
|
13
|
-
<% if @element.folded %>
|
14
|
-
|
15
|
-
<% @element.rtf_contents.each do |content| %>
|
16
|
-
rtf_<%= content.id -%> = tinymce.get '<%= content.form_field_id -%>'
|
17
|
-
rtf_<%= content.id -%>.remove() if rtf_<%= content.id %>
|
18
|
-
`delete rtf_<%= content.id -%>`
|
19
|
-
<%- end %>
|
20
|
-
|
21
|
-
<%- else %>
|
22
|
-
|
23
|
-
$el.trigger('Alchemy.SelectElementEditor')
|
24
|
-
Alchemy.SelectBox('select', $el)
|
25
|
-
|
26
|
-
<% @element.rtf_contents.each do |content| %>
|
27
|
-
Alchemy.Tinymce.addEditor '<%= content.form_field_id -%>'
|
28
|
-
<% end %>
|
29
|
-
|
30
|
-
Alchemy.ElementDirtyObserver $el
|
31
|
-
Alchemy.Datepicker('input[type="date"]', $el)
|
32
|
-
Alchemy.ButtonObserver('button.button', $el)
|
33
|
-
Alchemy.overlayObserver "#element_<%= @element.id -%>"
|
34
|
-
|
35
|
-
<% end %>
|
36
|
-
|
37
|
-
<% end %>
|
@@ -1,19 +0,0 @@
|
|
1
|
-
$('#essence_picture_<%= @content_id -%>').remove()
|
2
|
-
|
3
|
-
<% if max_image_count.present? && @essence_pictures.length < max_image_count.to_i %>
|
4
|
-
$picture_editor = $('#element_<%= @element.id -%>_contents')
|
5
|
-
if $('div.add_content', $picture_editor).length == 0
|
6
|
-
$('#element_<%= @element.id -%>_contents').append('<%= escape_javascript(
|
7
|
-
render(
|
8
|
-
:partial => "alchemy/admin/elements/add_content",
|
9
|
-
:locals => {
|
10
|
-
:element => @element,
|
11
|
-
:options => @options
|
12
|
-
}
|
13
|
-
)
|
14
|
-
) %>')
|
15
|
-
<% end %>
|
16
|
-
|
17
|
-
Alchemy.SortableContents '#element_<%= @element.id -%>_contents', '<%= form_authenticity_token -%>'
|
18
|
-
Alchemy.reloadPreview()
|
19
|
-
Alchemy.pleaseWaitOverlay(false)
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<%- if @pictures.blank? && params[:query].nil? -%>
|
2
|
-
<div class="info">
|
3
|
-
<%= render_icon('info') %>
|
4
|
-
<%= t("no_images_in_archive") %>
|
5
|
-
</div>
|
6
|
-
<%- elsif @pictures.blank? -%>
|
7
|
-
<div class="info">
|
8
|
-
<%= render_icon('info') %>
|
9
|
-
<%= t("no_search_results") %>
|
10
|
-
</div>
|
11
|
-
<%- else -%>
|
12
|
-
<div id="pictures">
|
13
|
-
<%= render :partial => 'picture', :collection => @pictures %>
|
14
|
-
<%= paginate @pictures %>
|
15
|
-
</div>
|
16
|
-
<%- end -%>
|
data/spec/page_layout_spec.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Alchemy::PageLayout do
|
4
|
-
|
5
|
-
context "method get_layouts" do
|
6
|
-
|
7
|
-
it "should generally return page_layouts, nothing else!" do
|
8
|
-
Alchemy::PageLayout.read_layouts_file.should be_instance_of(Array)
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
context "with custom page layouts" do
|
14
|
-
|
15
|
-
it "should return the users page_layouts if exists in the application" do
|
16
|
-
@config_path = Rails.root.join("config/alchemy")
|
17
|
-
FileUtils.mv(File.join(@config_path, 'page_layouts.yml'), File.join(@config_path, 'page_layouts.bak'))
|
18
|
-
layouts_file = File.join(@config_path, 'page_layouts.yml')
|
19
|
-
File.open(layouts_file, 'w') do |page_layouts|
|
20
|
-
page_layouts.puts "- name: testlayout\n elements:"
|
21
|
-
end
|
22
|
-
Alchemy::PageLayout.read_layouts_file.first.values.should include("testlayout")
|
23
|
-
end
|
24
|
-
|
25
|
-
after(:each) do
|
26
|
-
FileUtils.mv(File.join(@config_path, 'page_layouts.bak'), File.join(@config_path, 'page_layouts.yml'))
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should not display hidden page layouts" do
|
32
|
-
Alchemy::PageLayout.selectable_layouts(FactoryGirl.create(:language)).each { |e| e["hide"].should_not == true }
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
@@ -1,172 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* jquery-in-place-edit plugin
|
3
|
-
*
|
4
|
-
* Copyright (c) 2008 Christian Hellsten
|
5
|
-
*
|
6
|
-
* Plugin homepage:
|
7
|
-
* http://aktagon.com/projects/jquery/in-place-edit/
|
8
|
-
* http://github.com/christianhellsten/jquery-in-place-edit/
|
9
|
-
*
|
10
|
-
* Examples:
|
11
|
-
* http://aktagon.com/projects/jquery/in-place-edit/examples/
|
12
|
-
*
|
13
|
-
* Repository:
|
14
|
-
* git://github.com/christianhellsten/jquery-in-place-edit.git
|
15
|
-
*
|
16
|
-
* Version 1.0.2
|
17
|
-
*
|
18
|
-
* Tested with:
|
19
|
-
* Windows: Firefox 2, Firefox 3, Internet Explorer 6, Internet Explorer 7
|
20
|
-
* Linux: Firefox 2, Firefox 3, Opera
|
21
|
-
* Mac: Firefox 2, Firefox 3, Opera
|
22
|
-
*
|
23
|
-
*
|
24
|
-
* Licensed under the MIT license:
|
25
|
-
* http://www.opensource.org/licenses/mit-license.php
|
26
|
-
*
|
27
|
-
*/
|
28
|
-
(function ($) {
|
29
|
-
|
30
|
-
$.fn.inPlaceEdit = function (options) {
|
31
|
-
|
32
|
-
// Add click handler to all matching elements
|
33
|
-
return this.each(function () {
|
34
|
-
// Use default options, if necessary
|
35
|
-
var settings = $.extend({}, $.fn.inPlaceEdit.defaults, options);
|
36
|
-
|
37
|
-
var element = $(this);
|
38
|
-
|
39
|
-
element.click(function () {
|
40
|
-
element.data('skipBlur', false)
|
41
|
-
|
42
|
-
// Prevent multiple clicks, and check if inplace editing is disabled
|
43
|
-
if (element.hasClass("editing") || element.hasClass("disabled")) {
|
44
|
-
return;
|
45
|
-
}
|
46
|
-
|
47
|
-
element.addClass("editing");
|
48
|
-
|
49
|
-
element.old_value = element.html(); // Store old HTML so we can revert to it later
|
50
|
-
|
51
|
-
if (typeof(settings.html) == 'string') { // There are two types of form templates: strings and DOM elements
|
52
|
-
element.html(settings.html); // Replace current HTML with given HTML
|
53
|
-
}
|
54
|
-
else {
|
55
|
-
element.html(''); // Replace current HTML with given object's HTML
|
56
|
-
var form_template = settings.html.children(':first').clone(true);
|
57
|
-
form_template.appendTo(element); // Clone event handlers too
|
58
|
-
}
|
59
|
-
|
60
|
-
$('.field', element).val(element.old_value); // Set field value to old HTML
|
61
|
-
$('.field', element).focus(); // Set focus to input field
|
62
|
-
$('.field', element).select(); // Select all text in field
|
63
|
-
|
64
|
-
// On blur: cancel action
|
65
|
-
if (settings.onBlurDisabled == false) {
|
66
|
-
$('.field', element).blur(function () {
|
67
|
-
// Prevent cancel from being triggered when clicking Save & Cancel button
|
68
|
-
var skipBlur = element.data('skipBlur')
|
69
|
-
|
70
|
-
if (skipBlur != true) {
|
71
|
-
element.timeout = setTimeout(cancel, 50);
|
72
|
-
}
|
73
|
-
|
74
|
-
element.data('skipBlur', false)
|
75
|
-
});
|
76
|
-
}
|
77
|
-
|
78
|
-
// On save: revert to old HTML and submit
|
79
|
-
$('.save-button', element).click(function () {
|
80
|
-
return submit();
|
81
|
-
});
|
82
|
-
|
83
|
-
$('.save-button', element).mousedown(function () {
|
84
|
-
element.data('skipBlur', true)
|
85
|
-
});
|
86
|
-
|
87
|
-
$('.cancel-button', element).mousedown(function () {
|
88
|
-
element.data('skipBlur', true)
|
89
|
-
});
|
90
|
-
|
91
|
-
// On cancel: revert to old HTML
|
92
|
-
$('.cancel-button', element).click(function () {
|
93
|
-
return cancel();
|
94
|
-
});
|
95
|
-
|
96
|
-
// On keyup: submit (ESC) or cancel (enter)
|
97
|
-
if (settings.onKeyupDisabled == false) {
|
98
|
-
$('.field', element).keyup(function (event) {
|
99
|
-
var keycode = event.which;
|
100
|
-
var type = this.tagName.toLowerCase();
|
101
|
-
|
102
|
-
if (keycode == 27 && settings.escapeKeyDisabled == false) { // escape
|
103
|
-
return cancel();
|
104
|
-
}
|
105
|
-
else if (keycode == 13) { // enter
|
106
|
-
// Don't submit on enter if this is a textarea
|
107
|
-
if (type != "textarea") {
|
108
|
-
return submit();
|
109
|
-
}
|
110
|
-
}
|
111
|
-
return true;
|
112
|
-
});
|
113
|
-
}
|
114
|
-
});
|
115
|
-
|
116
|
-
// Add hover class on mouseover
|
117
|
-
element.mouseover(function () {
|
118
|
-
element.addClass("hover");
|
119
|
-
});
|
120
|
-
|
121
|
-
// Remove hover class on mouseout
|
122
|
-
element.mouseout(function () {
|
123
|
-
element.removeClass("hover");
|
124
|
-
});
|
125
|
-
|
126
|
-
function cancel() {
|
127
|
-
element.html(element.old_value);
|
128
|
-
|
129
|
-
element.removeClass("hover editing");
|
130
|
-
|
131
|
-
if (options.cancel) {
|
132
|
-
options.cancel.apply(element, [element]);
|
133
|
-
}
|
134
|
-
return false; // Stop propagation
|
135
|
-
}
|
136
|
-
|
137
|
-
function submit() {
|
138
|
-
clearTimeout(element.timeout);
|
139
|
-
|
140
|
-
var id = element.attr('id');
|
141
|
-
var value = $('.field', element).val();
|
142
|
-
|
143
|
-
if (options.submit) {
|
144
|
-
options.submit.apply(element, [element, id, value, element.old_value]);
|
145
|
-
}
|
146
|
-
|
147
|
-
element.removeClass("hover editing");
|
148
|
-
|
149
|
-
element.html(value);
|
150
|
-
|
151
|
-
return false; // Stop propagation
|
152
|
-
}
|
153
|
-
|
154
|
-
});
|
155
|
-
|
156
|
-
};
|
157
|
-
|
158
|
-
// Default (overridable) settings
|
159
|
-
$.fn.inPlaceEdit.defaults = {
|
160
|
-
onBlurDisabled:false,
|
161
|
-
onKeyupDisabled:false,
|
162
|
-
escapeKeyDisabled:false,
|
163
|
-
html:' \
|
164
|
-
<div class="inplace-edit"> \
|
165
|
-
<input type="text" value="" class="field" /> \
|
166
|
-
<div class="buttons"> \
|
167
|
-
<input type="button" value="Save" class="save-button" /> \
|
168
|
-
<input type="button" value="Cancel" class="cancel-button" /> \
|
169
|
-
</div> \
|
170
|
-
</div>'
|
171
|
-
};
|
172
|
-
})(jQuery);
|
@@ -1,14 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
jQuery-SelectBox
|
3
|
-
|
4
|
-
Traditional select elements are very difficult to style by themselves,
|
5
|
-
but they are also very usable and feature rich. This plugin attempts to
|
6
|
-
recreate all selectbox functionality and appearance while adding
|
7
|
-
animation and stylability.
|
8
|
-
|
9
|
-
This product includes software developed
|
10
|
-
by RevSystems, Inc (http://www.revsystems.com/) and its contributors
|
11
|
-
|
12
|
-
Please see the accompanying LICENSE.txt for licensing information.
|
13
|
-
*/
|
14
|
-
(function(e,d,g){e.fn.borderWidth=function(){return e(this).outerWidth()-e(this).innerWidth()};e.fn.paddingWidth=function(){return e(this).innerWidth()-e(this).width()};e.fn.extraWidth=function(){return e(this).outerWidth(true)-e(this).width()};e.fn.offsetFrom=function(i){var h=e(i);return{left:e(this).offset().left-h.offset().left,top:e(this).offset().top-h.offset().top}};e.fn.maxWidth=function(){var h=0;e(this).each(function(){if(e(this).width()>h){h=e(this).width()}});return h};e.fn.triggerAll=function(h,i){return e(this).each(function(){e(this).triggerHandler(h,i)})};var c=Array.prototype.slice,a=function(){return Math.floor(Math.random()*999999999)};e.proto=function(){var i=arguments[0],h=arguments[1],j=h,l={},k;opts=e.extend({elem:"elem",access:"access",init:"init",instantAccess:false},arguments[2]);if(h._super){l[opts.init]=function(){};j=h.extend(l)}e.fn[i]=function(){var m,n=arguments;e(this).each(function(){var p=e(this),q=p.data(i),o=!q;if(o){q=new j();if(h._super){q[opts.init]=h.prototype.init}q[opts.elem]=p[0];if(q[opts.init]){q[opts.init].apply(q,opts.instantAccess?[]:c.call(n,0))}p.data(i,q)}if(!o||opts.instantAccess){if(q[opts.access]){q[opts.access].apply(q,c.call(n,0))}if(n.length>0){if(e.isFunction(q[n[0]])){m=q[n[0]].apply(q,c.call(n,1))}else{if(n.length===1){if(e.getObject){m=e.getObject(n[0],q)}else{m=q[n[0]]}}else{if(e.setObject){e.setObject(n[0],n[1],q)}else{q[n[0]]=n[1]}}}}else{if(m===k){m=p.data(i)}}}});if(m===k){return e(this)}return m}};var b=function(){return false},f=function(){var q=this,U={},m=null,C=null,u=null,v=null,l=null,ac=null,W="",G=null,V=null,i=null,T,Z,n,af,s,ad,Y,M,aa,w,ae,h,ab,S,Q,L,y,z,j,X,R,J,I,P,H,O,E,B,k,N,p,A,F,x,t,r,K,D;T=function(){u=e("<div class='sb "+U.selectboxClass+" "+m.attr("class")+"' id='sb"+a()+"'></div>").attr("role","listbox").attr("aria-has-popup","true").attr("aria-labelledby",C.attr("id")?C.attr("id"):"");e("body").append(u);var ag=m.children().size()>0?U.displayFormat.call(m.find("option:selected")[0],0,0):" ";v=e("<div class='display "+m.attr("class")+"' id='sbd"+a()+"'></div>").append(e("<div class='text'></div>").append(ag)).append(U.arrowMarkup);u.append(v);l=e("<ul class='"+U.selectboxClass+" items "+m.attr("class")+"' role='menu' id='sbdd"+a()+"'></ul>").attr("aria-hidden","true");u.append(l).attr("aria-owns",l.attr("id"));if(m.children().size()===0){l.append(Z().addClass("selected"))}else{m.children().each(function(ah){var ai,aj,ak,al;if(e(this).is("optgroup")){aj=e(this);ak=e("<li class='optgroup'>"+U.optgroupFormat.call(aj[0],ah+1)+"</li>").addClass(aj.is(":disabled")?"disabled":"").attr("aria-disabled",aj.is(":disabled")?"true":"");al=e("<ul class='items'></ul>");ak.append(al);l.append(ak);aj.children("option").each(function(){ai=Z(e(this),ah).addClass(aj.is(":disabled")?"disabled":"").attr("aria-disabled",aj.is(":disabled")?"true":"");al.append(ai)})}else{l.append(Z(e(this),ah))}})}ac=l.find("li").not(".optgroup");u.attr("aria-active-descendant",ac.filter(".selected").attr("id"));l.children(":first").addClass("first");l.children(":last").addClass("last");if(!U.fixedWidth){var o=l.find(".text, .optgroup").maxWidth()+v.extraWidth()+1;u.width(U.maxWidth?Math.min(U.maxWidth,o):o)}else{if(U.maxWidth&&u.width()>U.maxWidth){u.width(U.maxWidth)}}m.before(u).addClass("has_sb").hide().show();ae();K();l.hide();if(!m.is(":disabled")){m.bind("blur.sb",af).bind("focus.sb",n);v.mouseup(J).mouseup(S).click(b).focus(z).blur(j).hover(X,R);O().click(Q).hover(X,R);l.find(".optgroup").hover(X,R).click(b);ac.filter(".disabled").click(b);if(!e.browser.msie||e.browser.version>=9){e(d).resize(e.throttle?e.throttle(100,h):ab)}}else{u.addClass("disabled").attr("aria-disabled");v.click(function(ah){ah.preventDefault()})}u.bind("close.sb",w).bind("destroy.sb",s);m.bind("reload.sb",ad);if(e.fn.tie&&U.useTie){m.bind("domupdate.sb",Y)}};ab=function(){clearTimeout(i);i=setTimeout(h,50)};h=function(){if(u.is(".open")){ae();M(true)}};Z=function(ah,o){if(!ah){ah=e("<option value=''> </option>");o=0}var aj=e("<li id='sbo"+a()+"'></li>").attr("role","option").data("orig",ah[0]).data("value",ah?ah.attr("value"):"").addClass(ah.is(":selected")?"selected":"").addClass(ah.is(":disabled")?"disabled":"").attr("aria-disabled",ah.is(":disabled")?"true":""),ai=e("<div class='item'></div>"),ag=e("<div class='text'></div>").html(U.optionFormat.call(ah[0],0,o+1));return aj.append(ai.append(ag))};n=function(){t();v.triggerHandler("focus")};af=function(){if(!u.is(".open")){v.triggerHandler("blur")}};s=function(o){u.remove();m.unbind(".sb").removeClass("has_sb");e(d).unbind("resize",ab);if(!o){m.removeData("sb")}};ad=function(){var ag=u.is(".open"),o=v.is(".focused");w(true);s(true);q.init(U);if(ag){m.focus();M(true)}else{if(o){m.focus()}}};Y=function(){clearTimeout(V);V=setTimeout(ad,30)};x=function(){u.removeClass("focused");w();D()};D=function(){e(document).unbind("click",x).unbind("keyup",L).unbind("keypress",r).unbind("keydown",r).unbind("keydown",y)};A=function(){e(".sb.open."+U.selectboxClass).triggerAll("close")};t=function(){e(".sb.focused."+U.selectboxClass).not(u[0]).find(".display").blur()};F=function(){e(".sb.open."+U.selectboxClass).not(u[0]).triggerAll("close")};w=function(o){if(u.is(".open")){v.blur();ac.removeClass("hover");D();l.attr("aria-hidden","true");if(o===true){l.hide();u.removeClass("open");u.append(l)}else{l.fadeOut(U.animDuration,function(){u.removeClass("open");u.append(l)})}}};P=function(){var o=null;if(U.ddCtx==="self"){o=u}else{if(e.isFunction(U.ddCtx)){o=e(U.ddCtx.call(m[0]))}else{o=e(U.ddCtx)}}return o};H=function(){return ac.filter(".selected")};O=function(){return ac.not(".disabled")};aa=function(){l.scrollTop(l.scrollTop()+H().offsetFrom(l).top-l.height()/2+H().outerHeight(true)/2)};K=function(){if(e.browser.msie&&e.browser.version<8){e("."+U.selectboxClass+" .display").hide().show()}};M=function(ag){var o,ah=P();t();u.addClass("open");ah.append(l);o=ae();l.attr("aria-hidden","false");if(ag===true){l.show();aa()}else{if(o==="down"){l.slideDown(U.animDuration,aa)}else{l.fadeIn(U.animDuration,aa)}}m.focus()};ae=function(){var aj=P(),aq=0,ah=v.offsetFrom(aj).left,ag=0,ak="",an,o,ap,ao,ai,ar,am,al;l.removeClass("above");l.show().css({maxHeight:"none",position:"relative",visibility:"hidden"});if(!U.fixedWidth){l.width(v.outerWidth()-l.extraWidth()+1)}ap=e(d).scrollTop()+e(d).height()-v.offset().top-v.outerHeight();ao=v.offset().top-e(d).scrollTop();ai=v.offsetFrom(aj).top+v.outerHeight();ar=ap-ao+U.dropupThreshold;if(l.outerHeight()<ap){aq=U.maxHeight?U.maxHeight:ap;ag=ai;ak="down"}else{if(l.outerHeight()<ao){aq=U.maxHeight?U.maxHeight:ao;ag=v.offsetFrom(aj).top-Math.min(aq,l.outerHeight());ak="up"}else{if(ar>=0){aq=U.maxHeight?U.maxHeight:ap;ag=ai;ak="down"}else{if(ar<0){aq=U.maxHeight?U.maxHeight:ao;ag=v.offsetFrom(aj).top-Math.min(aq,l.outerHeight());ak="up"}else{aq=U.maxHeight?U.maxHeight:"none";ag=ai;ak="down"}}}}an=(""+e("body").css("margin-left")).match(/^\d+/)?e("body").css("margin-left"):0;o=(""+e("body").css("margin-top")).match(/^\d+/)?e("body").css("margin-top"):0;am=e().jquery>="1.4.2"?parseInt(an):e("body").offset().left;al=e().jquery>="1.4.2"?parseInt(o):e("body").offset().top;l.hide().css({left:ah+(aj.is("body")?am:0),maxHeight:aq,position:"absolute",top:ag+(aj.is("body")?al:0),visibility:"visible"});if(ak==="up"){l.addClass("above")}return ak};S=function(o){if(u.is(".open")){w()}else{M()}return false};E=function(){var ag=e(this),o=m.val(),ah=ag.data("value");m.find("option").each(function(){this.selected=false});e(ag.data("orig")).each(function(){this.selected=true});ac.removeClass("selected");ag.addClass("selected");u.attr("aria-active-descendant",ag.attr("id"));v.find(".text").attr("title",ag.find(".text").html());v.find(".text").html(U.displayFormat.call(ag.data("orig")));if(o!==ah){m.change()}};Q=function(o){x();m.focus();E.call(this);return false};B=function(){W=""};k=function(aj){var ai,ah,o,ag=O();for(ai=0;ai<ag.size();ai++){o=ag.eq(ai).find(".text");ah=o.children().size()==0?o.text():o.find("*").text();if(aj.length>0&&ah.toLowerCase().match("^"+aj.toLowerCase())){return ag.eq(ai)}}return null};N=function(ag){var o=k(ag);if(o!==null){E.call(o[0]);return true}return false};r=function(o){if(o.ctrlKey||o.altKey){return}if(o.which===38||o.which===40||o.which===8||o.which===32){o.preventDefault()}};p=function(aj){var ai,ah,o=H(),ag=O();for(ai=ag.index(o)+1;ai<ag.size();ai++){ah=ag.eq(ai).find(".text").text();if(ah!==""&&ah.substring(0,1).toLowerCase()===aj.toLowerCase()){E.call(ag.eq(ai)[0]);return true}}return false};y=function(ah){if(ah.altKey||ah.ctrlKey){return false}var ag=H(),o=O();switch(ah.which){case 9:w();j();break;case 35:if(ag.size()>0){ah.preventDefault();E.call(o.filter(":last")[0]);aa()}break;case 36:if(ag.size()>0){ah.preventDefault();E.call(o.filter(":first")[0]);aa()}break;case 38:if(ag.size()>0){if(o.filter(":first")[0]!==ag[0]){ah.preventDefault();E.call(o.eq(o.index(ag)-1)[0])}aa()}break;case 40:if(ag.size()>0){if(o.filter(":last")[0]!==ag[0]){ah.preventDefault();E.call(o.eq(o.index(ag)+1)[0]);aa()}}else{if(ac.size()>1){ah.preventDefault();E.call(ac.eq(0)[0])}}break;default:break}};L=function(o){if(o.altKey||o.ctrlKey){return false}if(o.which!==38&&o.which!==40){W+=String.fromCharCode(o.keyCode);if(N(W)){clearTimeout(G);G=setTimeout(B,U.acTimeout)}else{if(p(String.fromCharCode(o.keyCode))){aa();clearTimeout(G);G=setTimeout(B,U.acTimeout)}else{B();clearTimeout(G)}}}};z=function(){F();u.addClass("focused");e(document).click(x).keyup(L).keypress(r).keydown(r).keydown(y)};j=function(){u.removeClass("focused");v.removeClass("active");e(document).unbind("keyup",L).unbind("keydown",r).unbind("keypress",r).unbind("keydown",y)};X=function(){e(this).addClass("hover")};R=function(){e(this).removeClass("hover")};J=function(){v.addClass("active");e(document).bind("mouseup",I)};I=function(){v.removeClass("active");e(document).unbind("mouseup",I)};this.init=function(o){if(e.browser.msie&&e.browser.version<7){return}m=e(this.elem);if(m.attr("id")){C=e("label[for='"+m.attr("id")+"']:first")}if(!C||C.size()===0){C=m.closest("label")}if(m.hasClass("has_sb")){return}U=e.extend({acTimeout:800,animDuration:200,ddCtx:"body",dropupThreshold:150,fixedWidth:false,maxHeight:false,maxWidth:false,selectboxClass:"selectbox",useTie:false,arrowMarkup:"<div class='arrow_btn'><span class='arrow'></span></div>",displayFormat:g,optionFormat:function(ag,ai){if(e(this).size()>0){var ah=e(this).attr("label");if(ah&&ah.length>0){return ah}return e(this).text()}else{return""}},optgroupFormat:function(ag){return"<span class='label'>"+e(this).attr("label")+"</span>"}},o);U.displayFormat=U.displayFormat||U.optionFormat;T()};this.open=M;this.close=w;this.refresh=ad;this.destroy=s;this.options=function(o){U=e.extend(U,o);ad()}};e.proto("sb",f)}(jQuery,window));
|