locomotivecms 3.0.0.pre.alpha.2 → 3.0.0.pre.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +1 -1
- data/app/api/locomotive/api/forms/membership_form.rb +13 -0
- data/app/api/locomotive/api/resources/membership_resource.rb +5 -3
- data/app/assets/javascripts/locomotive.js +2 -0
- data/app/assets/javascripts/locomotive/utils/backbone_patches.js.coffee +15 -1
- data/app/assets/javascripts/locomotive/utils/file.js.coffee +20 -0
- data/app/assets/javascripts/locomotive/utils/nprogress.js.coffee +5 -0
- data/app/assets/javascripts/locomotive/utils/rails_ujs.js.coffee +36 -0
- data/app/assets/javascripts/locomotive/utils/wysihtml5.js.coffee +1 -1
- data/app/assets/javascripts/locomotive/views/content_assets/picker_view.js.coffee +9 -17
- data/app/assets/javascripts/locomotive/views/editable_elements/edit_view.js.coffee +39 -0
- data/app/assets/javascripts/locomotive/views/editable_elements/index_view.js.coffee +104 -1
- data/app/assets/javascripts/locomotive/views/inputs/file_view.js.coffee +79 -10
- data/app/assets/javascripts/locomotive/views/inputs/rte/file_view.js.coffee +24 -4
- data/app/assets/javascripts/locomotive/views/inputs/rte_view.js.coffee.erb +18 -0
- data/app/assets/javascripts/locomotive/views/pages/new_view.js.coffee +3 -6
- data/app/assets/javascripts/locomotive/views/shared/drawer_view.js.coffee +24 -8
- data/app/assets/javascripts/locomotive/views/shared/form_view.js.coffee +21 -148
- data/app/assets/stylesheets/locomotive/application.scss +6 -0
- data/app/assets/stylesheets/locomotive/base/_form.scss +1 -0
- data/app/assets/stylesheets/locomotive/base/form/_base.scss +9 -0
- data/app/assets/stylesheets/locomotive/base/form/_file_input.scss +1 -1
- data/app/assets/stylesheets/locomotive/base/form/_link.scss +13 -0
- data/app/assets/stylesheets/locomotive/base/form/_select2.scss +28 -1
- data/app/assets/stylesheets/locomotive/components/_drawer.scss +8 -18
- data/app/assets/stylesheets/locomotive/components/_live_editing.scss +83 -0
- data/app/assets/stylesheets/locomotive/components/_transitions.scss +63 -1
- data/app/assets/stylesheets/locomotive/components/header/_base.scss +5 -1
- data/app/assets/stylesheets/locomotive/components/misc/_notify.scss +5 -7
- data/app/assets/stylesheets/locomotive/globals/_bootstrap.scss +4 -4
- data/app/assets/stylesheets/locomotive/globals/_mixins.scss +16 -0
- data/app/assets/stylesheets/locomotive/globals/_nprogress.scss +3 -0
- data/app/assets/stylesheets/locomotive/globals/_variables.scss +57 -49
- data/app/assets/stylesheets/locomotive/layouts/_live_editing.scss +29 -0
- data/app/controllers/locomotive/editable_elements_controller.rb +49 -2
- data/app/controllers/locomotive/pages_controller.rb +2 -2
- data/app/helpers/locomotive/custom_fields_helper.rb +1 -1
- data/app/helpers/locomotive/editable_elements_helper.rb +40 -0
- data/app/helpers/locomotive/pages_helper.rb +0 -1
- data/app/inputs/locomotive/array_input.rb +1 -1
- data/app/inputs/locomotive/file_input.rb +35 -7
- data/app/inputs/locomotive/rte_input.rb +2 -1
- data/app/inputs/locomotive/toggle_input.rb +1 -1
- data/app/models/locomotive/concerns/content_entry/localized.rb +4 -4
- data/app/models/locomotive/concerns/content_type/sync.rb +0 -5
- data/app/models/locomotive/concerns/page/redirect.rb +1 -1
- data/app/models/locomotive/content_entry.rb +5 -11
- data/app/models/locomotive/content_type.rb +22 -0
- data/app/models/locomotive/editable_control.rb +12 -27
- data/app/models/locomotive/editable_element.rb +8 -0
- data/app/models/locomotive/editable_file.rb +0 -1
- data/app/models/locomotive/editable_text.rb +10 -10
- data/app/models/locomotive/page.rb +1 -1
- data/app/policies/locomotive/page_policy.rb +1 -1
- data/app/services/locomotive/editable_element_service.rb +47 -0
- data/app/services/locomotive/page_parsing_service.rb +85 -31
- data/app/uploaders/locomotive/editable_file_uploader.rb +5 -1
- data/app/views/locomotive/editable_elements/_edit.html.haml +49 -0
- data/app/views/locomotive/editable_elements/_edit_with_content_entry.html.haml +21 -0
- data/app/views/locomotive/editable_elements/_form.html.haml +23 -0
- data/app/views/locomotive/editable_elements/index.html.haml +8 -2
- data/app/views/locomotive/editable_elements/index_without_preview.html.haml +33 -0
- data/app/views/locomotive/layouts/{preview.html.haml → live_editing.html.haml} +9 -9
- data/app/views/locomotive/my_account/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_actions.html.haml +8 -1
- data/app/views/locomotive/pages/form/_main.html.haml +1 -1
- data/app/views/locomotive/pages/form/_tabs.html.haml +2 -2
- data/app/views/locomotive/pages/new.html.haml +1 -1
- data/app/views/locomotive/shared/header/_site.html.haml +1 -1
- data/app/views/locomotive/shared/rte/_image_popover.html.haml +2 -2
- data/app/views/locomotive/shared/rte/_link_popover.html.haml +1 -1
- data/app/views/locomotive/shared/sidebar/_page.html.haml +5 -2
- data/config/locales/admin_ui.en.yml +10 -16
- data/config/locales/inputs.en.yml +18 -11
- data/config/locales/simple_form.en.yml +13 -1
- data/config/routes.rb +3 -1
- data/lib/locomotive.rb +1 -1
- data/lib/locomotive/action_controller/responder.rb +16 -0
- data/lib/locomotive/carrierwave/patches.rb +54 -0
- data/lib/locomotive/dependencies.rb +1 -0
- data/lib/locomotive/engine.rb +9 -3
- data/lib/locomotive/middlewares.rb +1 -1
- data/lib/locomotive/middlewares/page_editing.rb +41 -0
- data/lib/locomotive/middlewares/site.rb +2 -0
- data/lib/locomotive/simple_form.rb +6 -5
- data/lib/locomotive/steam_adaptor.rb +2 -0
- data/lib/locomotive/version.rb +1 -1
- data/lib/tasks/development.rake +4 -0
- data/spec/dummy/config/environments/production.rb +2 -0
- data/spec/dummy/config/initializers/devise.rb +2 -0
- data/spec/dummy/config/mongoid.yml +2 -2
- data/spec/models/locomotive/content_entry_spec.rb +11 -2
- data/spec/support/factories.rb +0 -1
- data/vendor/assets/javascripts/locomotive/history.js +2122 -0
- data/vendor/assets/javascripts/locomotive/subscribe.js +206 -329
- metadata +44 -127
- data/lib/locomotive/middlewares/permalink.rb +0 -22
- data/lib/locomotive/previous_liquid/asset_host.rb +0 -51
- data/lib/locomotive/previous_liquid/drops/base.rb +0 -40
- data/lib/locomotive/previous_liquid/drops/content_entry.rb +0 -78
- data/lib/locomotive/previous_liquid/drops/content_types.rb +0 -119
- data/lib/locomotive/previous_liquid/drops/current_user.rb +0 -21
- data/lib/locomotive/previous_liquid/drops/page.rb +0 -115
- data/lib/locomotive/previous_liquid/drops/proxy_collection.rb +0 -64
- data/lib/locomotive/previous_liquid/drops/session_proxy.rb +0 -16
- data/lib/locomotive/previous_liquid/drops/site.rb +0 -29
- data/lib/locomotive/previous_liquid/drops/uploader.rb +0 -21
- data/lib/locomotive/previous_liquid/errors.rb +0 -8
- data/lib/locomotive/previous_liquid/filters/base.rb +0 -61
- data/lib/locomotive/previous_liquid/filters/date.rb +0 -82
- data/lib/locomotive/previous_liquid/filters/html.rb +0 -117
- data/lib/locomotive/previous_liquid/filters/misc.rb +0 -75
- data/lib/locomotive/previous_liquid/filters/resize.rb +0 -18
- data/lib/locomotive/previous_liquid/filters/text.rb +0 -53
- data/lib/locomotive/previous_liquid/filters/translate.rb +0 -38
- data/lib/locomotive/previous_liquid/patches.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/consume.rb +0 -104
- data/lib/locomotive/previous_liquid/tags/csrf.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/editable.rb +0 -4
- data/lib/locomotive/previous_liquid/tags/editable/base.rb +0 -88
- data/lib/locomotive/previous_liquid/tags/editable/control.rb +0 -41
- data/lib/locomotive/previous_liquid/tags/editable/file.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/editable/text.rb +0 -79
- data/lib/locomotive/previous_liquid/tags/extends.rb +0 -47
- data/lib/locomotive/previous_liquid/tags/fetch_page.rb +0 -36
- data/lib/locomotive/previous_liquid/tags/google_analytics.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/hybrid.rb +0 -25
- data/lib/locomotive/previous_liquid/tags/inherited_block.rb +0 -31
- data/lib/locomotive/previous_liquid/tags/inline_editor.rb +0 -40
- data/lib/locomotive/previous_liquid/tags/javascript.rb +0 -16
- data/lib/locomotive/previous_liquid/tags/link_to.rb +0 -43
- data/lib/locomotive/previous_liquid/tags/locale_switcher.rb +0 -83
- data/lib/locomotive/previous_liquid/tags/model_form.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/nav.rb +0 -164
- data/lib/locomotive/previous_liquid/tags/paginate.rb +0 -114
- data/lib/locomotive/previous_liquid/tags/path_helper.rb +0 -85
- data/lib/locomotive/previous_liquid/tags/path_to.rb +0 -21
- data/lib/locomotive/previous_liquid/tags/seo.rb +0 -72
- data/lib/locomotive/previous_liquid/tags/session_assign.rb +0 -39
- data/lib/locomotive/previous_liquid/tags/snippet.rb +0 -75
- data/lib/locomotive/previous_liquid/tags/with_scope.rb +0 -65
- data/spec/fixtures/portfolio/Gemfile +0 -21
- data/spec/fixtures/portfolio/app/content_types/messages.yml +0 -57
- data/spec/fixtures/portfolio/app/content_types/projects.yml +0 -74
- data/spec/fixtures/portfolio/app/views/pages/404.liquid.haml +0 -10
- data/spec/fixtures/portfolio/app/views/pages/index.liquid.haml +0 -213
- data/spec/fixtures/portfolio/app/views/snippets/footer.liquid.haml +0 -2
- data/spec/fixtures/portfolio/config.ru +0 -3
- data/spec/fixtures/portfolio/config/deploy.yml +0 -18
- data/spec/fixtures/portfolio/config/site.yml +0 -33
- data/spec/fixtures/portfolio/config/translations.yml +0 -8
- data/spec/fixtures/portfolio/data/messages.yml +0 -1
- data/spec/fixtures/portfolio/data/projects.yml +0 -41
- data/spec/fixtures/portfolio/icon.png +0 -0
- data/spec/fixtures/portfolio/public/javascripts/bootstrap.min.js +0 -6
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.js +0 -44
- data/spec/fixtures/portfolio/public/javascripts/cbpAnimatedHeader.min.js +0 -11
- data/spec/fixtures/portfolio/public/javascripts/classie.js +0 -80
- data/spec/fixtures/portfolio/public/javascripts/contact_me.js +0 -65
- data/spec/fixtures/portfolio/public/javascripts/freelancer.js +0 -37
- data/spec/fixtures/portfolio/public/javascripts/jqBootstrapValidation.js +0 -912
- data/spec/fixtures/portfolio/public/samples/portfolio/cabin.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/cake.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/circus.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/game.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/safe.png +0 -0
- data/spec/fixtures/portfolio/public/samples/portfolio/submarine.png +0 -0
- data/spec/fixtures/portfolio/public/samples/profile.png +0 -0
- data/spec/fixtures/portfolio/public/stylesheets/bootstrap.min.css +0 -7
- data/spec/fixtures/portfolio/public/stylesheets/freelancer.css +0 -445
- data/spec/lib/locomotive/liquid/tags/editable/file_spec.rb +0 -72
- data/spec/lib/locomotive/liquid/tags/editable/text_spec.rb +0 -85
- data/spec/lib/locomotive/liquid/tags/extends_spec.rb +0 -58
- data/vendor/assets/javascripts/locomotive/editable_field.js +0 -50
- data/vendor/assets/javascripts/locomotive/form_submit_notification.js +0 -39
- data/vendor/assets/javascripts/locomotive/slugify.js +0 -47
@@ -1,72 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::Liquid::Tags::Editable::File do
|
4
|
-
|
5
|
-
# before { Locomotive::Site.any_instance.stubs(:create_default_pages!).returns(true) }
|
6
|
-
|
7
|
-
# let(:asset_host) { CdnAssetHost.new }
|
8
|
-
# let(:page) { Locomotive::Page.new(updated_at: DateTime.parse('2007-06-29 21:00:00')) }
|
9
|
-
|
10
|
-
# subject { render("{% editable_file banner %}http://www.placehold.it/500x500{% endeditable_file %}") }
|
11
|
-
|
12
|
-
# describe 'no uploaded file' do
|
13
|
-
|
14
|
-
# let(:asset_host) { IsoAssetHost.new }
|
15
|
-
# before { add_editable_file({}) }
|
16
|
-
# it { is_expected.to eq 'http://www.placehold.it/500x500' }
|
17
|
-
|
18
|
-
# context 'a timestamp is not applicable' do
|
19
|
-
|
20
|
-
# let(:asset_host) { TimestampAssetHost.new }
|
21
|
-
# it { is_expected.to eq 'http://www.placehold.it/500x500' }
|
22
|
-
|
23
|
-
# end
|
24
|
-
|
25
|
-
# end
|
26
|
-
|
27
|
-
# describe 'with a default source url' do
|
28
|
-
|
29
|
-
# before { add_editable_file(default_source_url: '/assets/42/assets/1/foo.png') }
|
30
|
-
# it { is_expected.to eq 'http://cdn.locomotivecms.com/assets/42/assets/1/foo.png' }
|
31
|
-
|
32
|
-
# context 'has a timestamp' do
|
33
|
-
|
34
|
-
# let(:asset_host) { TimestampAssetHost.new }
|
35
|
-
# it { is_expected.to eq '/assets/42/assets/1/foo.png?1183150800' }
|
36
|
-
|
37
|
-
# end
|
38
|
-
|
39
|
-
# end
|
40
|
-
|
41
|
-
# describe 'with an uploaded file' do
|
42
|
-
|
43
|
-
# before { add_editable_file }
|
44
|
-
# it { is_expected.to match /^http:\/\/cdn\.locomotivecms\.com\/spec\/(.*)\/5k.png$/ }
|
45
|
-
|
46
|
-
# context 'has a timestamp' do
|
47
|
-
|
48
|
-
# let(:asset_host) { TimestampAssetHost.new }
|
49
|
-
# it { is_expected.to match /^\/spec\/(.*)\/5k.png\?1183150800$/ }
|
50
|
-
|
51
|
-
# end
|
52
|
-
|
53
|
-
# end
|
54
|
-
|
55
|
-
# def render(template, assigns = {})
|
56
|
-
# liquid_context = ::Liquid::Context.new(assigns, {}, {
|
57
|
-
# asset_host: asset_host,
|
58
|
-
# page: page
|
59
|
-
# }, true)
|
60
|
-
|
61
|
-
# output = ::Liquid::Template.parse(template).render(liquid_context)
|
62
|
-
# output.gsub(/\n\s{0,}/, '')
|
63
|
-
# end
|
64
|
-
|
65
|
-
# def add_editable_file(attributes = nil)
|
66
|
-
# attributes ||= { source: FixturedAsset.open('5k.png') }
|
67
|
-
|
68
|
-
# editable_file = Locomotive::EditableFile.new({ slug: 'banner' }.merge(attributes))
|
69
|
-
# page.editable_elements << editable_file
|
70
|
-
# end
|
71
|
-
|
72
|
-
# end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::Liquid::Tags::Editable::Text do
|
4
|
-
|
5
|
-
# let(:markup) { "'title', hint: 'Simple short text'" }
|
6
|
-
# subject { build_tag }
|
7
|
-
|
8
|
-
# context 'valid syntax' do
|
9
|
-
|
10
|
-
# it 'does not raise an error' do
|
11
|
-
# expect { subject }.to_not raise_error
|
12
|
-
# end
|
13
|
-
|
14
|
-
# end
|
15
|
-
|
16
|
-
# context 'without a slug' do
|
17
|
-
|
18
|
-
# let(:markup) { '' }
|
19
|
-
|
20
|
-
# it 'requires a slug' do
|
21
|
-
# expect { subject }.to raise_error(::Liquid::SyntaxError, "Syntax Error in 'editable_xxx' - Valid syntax: editable_xxx <slug>(, <options>)")
|
22
|
-
# end
|
23
|
-
|
24
|
-
# end
|
25
|
-
|
26
|
-
# describe '.default_element_attributes' do
|
27
|
-
|
28
|
-
# let(:content) { '' }
|
29
|
-
# subject { build_tag('text', content).send(:default_element_attributes) }
|
30
|
-
|
31
|
-
# it { is_expected.to include(slug: 'title') }
|
32
|
-
# it { is_expected.to include(hint: 'Simple short text') }
|
33
|
-
# it { is_expected.to include(_type: 'Locomotive::EditableText') }
|
34
|
-
# it { is_expected.to include(format: 'html') }
|
35
|
-
# it { is_expected.to include(rows: 10) }
|
36
|
-
# it { is_expected.to include(line_break: true) }
|
37
|
-
|
38
|
-
# describe 'default content' do
|
39
|
-
|
40
|
-
# context 'only text' do
|
41
|
-
|
42
|
-
# let(:content) { 'Lorem ipsum' }
|
43
|
-
# it { is_expected.to include(content_from_default: 'Lorem ipsum') }
|
44
|
-
|
45
|
-
# end
|
46
|
-
|
47
|
-
# context 'liquid tags' do
|
48
|
-
|
49
|
-
# let(:content) { ['hello ', ::Liquid::Variable.new("{{ 'world' }}")] }
|
50
|
-
# it { expect { subject }.to raise_error(::Liquid::SyntaxError, "Error in the default block for the title editable_element - No liquid tags are allowed inside.") }
|
51
|
-
|
52
|
-
# end
|
53
|
-
|
54
|
-
# end
|
55
|
-
|
56
|
-
# context 'editable_short_text' do
|
57
|
-
|
58
|
-
# subject { build_tag('short_text').send(:default_element_attributes) }
|
59
|
-
|
60
|
-
# it { is_expected.to include(format: 'raw') }
|
61
|
-
# it { is_expected.to include(rows: 2) }
|
62
|
-
# it { is_expected.to include(line_break: false) }
|
63
|
-
|
64
|
-
# end
|
65
|
-
|
66
|
-
# context 'editable_long_text' do
|
67
|
-
|
68
|
-
# subject { build_tag('long_text').send(:default_element_attributes) }
|
69
|
-
|
70
|
-
# it { is_expected.to include(format: 'html') }
|
71
|
-
# it { is_expected.to include(rows: 15) }
|
72
|
-
# it { is_expected.to include(line_break: true) }
|
73
|
-
|
74
|
-
# end
|
75
|
-
|
76
|
-
# end
|
77
|
-
|
78
|
-
# def build_tag(tag_name = 'text', content = nil)
|
79
|
-
# klass = "Locomotive::Liquid::Tags::Editable::#{tag_name.camelize}".constantize
|
80
|
-
# klass.new("editable_#{tag_name}", markup, ["{% endeditable_#{tag_name} %}"], {}).tap do |tag|
|
81
|
-
# tag.instance_variable_set(:@nodelist, [*content]) if content
|
82
|
-
# end
|
83
|
-
# end
|
84
|
-
|
85
|
-
# end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# require 'spec_helper'
|
2
|
-
|
3
|
-
# describe Locomotive::Liquid::Tags::Extends do
|
4
|
-
|
5
|
-
# before(:each) do
|
6
|
-
# @home = FactoryGirl.build(:page, raw_template: 'Hello world')
|
7
|
-
# @home.send :serialize_template
|
8
|
-
# @home.instance_variable_set(:@template, nil)
|
9
|
-
|
10
|
-
# @site = FactoryGirl.build(:site)
|
11
|
-
# @site.stubs(:pages).returns([@home])
|
12
|
-
# end
|
13
|
-
|
14
|
-
# it 'works' do
|
15
|
-
# page = FactoryGirl.build(:page, slug: 'sub_page_1', parent: @home)
|
16
|
-
# expect(parse('parent', page).render).to eq 'Hello world'
|
17
|
-
# end
|
18
|
-
|
19
|
-
# it 'looks for the index with the right locale' do
|
20
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
21
|
-
# @home.raw_template = 'Bonjour le monde'
|
22
|
-
# @home.send :serialize_template
|
23
|
-
# end
|
24
|
-
|
25
|
-
# @site.pages.expects(:where).with('fullpath.fr' => 'index').returns([@home])
|
26
|
-
|
27
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
28
|
-
# page = FactoryGirl.build(:page, slug: 'sub_page_1', parent: @home)
|
29
|
-
# expect(parse('index', page).render).to eq 'Bonjour le monde'
|
30
|
-
# end
|
31
|
-
# end
|
32
|
-
|
33
|
-
# context '#errors' do
|
34
|
-
|
35
|
-
# it 'raises an error if the source page does not exist' do
|
36
|
-
# expect {
|
37
|
-
# @site.pages.expects(:where).with('fullpath.en' => 'foo').returns([])
|
38
|
-
# parse('foo')
|
39
|
-
# }.to raise_error(Locomotive::Liquid::PageNotFound, "Page with fullpath 'foo' was not found")
|
40
|
-
# end
|
41
|
-
|
42
|
-
# it 'raises an error if the source page is not translated' do
|
43
|
-
# expect {
|
44
|
-
# ::Mongoid::Fields::I18n.with_locale 'fr' do
|
45
|
-
# page = FactoryGirl.build(:page, slug: 'sub_page_1', parent: @home)
|
46
|
-
# parse('parent', page)
|
47
|
-
# end
|
48
|
-
# }.to raise_error(Locomotive::Liquid::PageNotTranslated, "Page with fullpath 'parent' was not translated")
|
49
|
-
# end
|
50
|
-
|
51
|
-
# end
|
52
|
-
|
53
|
-
# def parse(source = 'index', page = nil)
|
54
|
-
# page ||= @home
|
55
|
-
# Liquid::Template.parse("{% extends #{source} %}", { site: @site, page: page })
|
56
|
-
# end
|
57
|
-
|
58
|
-
# end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Version 0.0.1
|
3
|
-
* tiny effect to display an input field when clicking on a label
|
4
|
-
* Didier Lafforgue
|
5
|
-
*/
|
6
|
-
$.fn.editableField = function(settings) {
|
7
|
-
|
8
|
-
var destroy = false;
|
9
|
-
|
10
|
-
if ('destroy' == settings) {
|
11
|
-
destroy = true
|
12
|
-
} else {
|
13
|
-
settings = $.extend({}, settings);
|
14
|
-
}
|
15
|
-
|
16
|
-
function getText(element) {
|
17
|
-
if (element.is('select')) {
|
18
|
-
return element[0].options[element[0].options.selectedIndex].text;
|
19
|
-
} else {
|
20
|
-
return element.val();
|
21
|
-
}
|
22
|
-
}
|
23
|
-
|
24
|
-
return this.each(function() {
|
25
|
-
if (destroy) {
|
26
|
-
$(this).unbind('mouseenter').unbind('mouseleave');
|
27
|
-
$(this).prev('.editable').unbind('click').remove();
|
28
|
-
} else {
|
29
|
-
var input = $(this).hide();
|
30
|
-
var label = $('<em></em>').addClass('editable').html(getText(input));
|
31
|
-
var timer = null;
|
32
|
-
|
33
|
-
input.before(label);
|
34
|
-
|
35
|
-
label.bind('click', function() {
|
36
|
-
label.hide();
|
37
|
-
input.show().focus();
|
38
|
-
});
|
39
|
-
|
40
|
-
input.hover(function() {
|
41
|
-
clearTimeout(timer);
|
42
|
-
}, function() {
|
43
|
-
timer = setTimeout(function() { input.hide(); label.show() }, 1000);
|
44
|
-
}).change(function() {
|
45
|
-
input.hide();
|
46
|
-
label.show().html(getText(input))
|
47
|
-
});
|
48
|
-
}
|
49
|
-
});
|
50
|
-
}
|
@@ -1,39 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Version 0.0.1
|
3
|
-
* Display a message letting the user know the form is being submitted
|
4
|
-
* Didier Lafforgue
|
5
|
-
*/
|
6
|
-
$.fn.formSubmitNotification = function(settings) {
|
7
|
-
|
8
|
-
function show() {
|
9
|
-
$('#form-submit-notification').fadeIn()
|
10
|
-
}
|
11
|
-
|
12
|
-
function hide() {
|
13
|
-
$('#form-submit-notification').fadeOut()
|
14
|
-
}
|
15
|
-
|
16
|
-
function create(message) {
|
17
|
-
if ($('#form-submit-notification').size() == 0) {
|
18
|
-
var element = $("<div id=\"form-submit-notification\"><div>" + message + "</div></div>").hide();
|
19
|
-
$('body').append(element);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
return this.each(function() {
|
24
|
-
var form = $(this);
|
25
|
-
var message = form.data('sending-form-message') || form.data('sending_form_message');
|
26
|
-
|
27
|
-
if (typeof(message) == 'undefined')
|
28
|
-
message = form.find('input[type=submit]').data('sending-form-message');
|
29
|
-
|
30
|
-
if (typeof(message) == 'undefined')
|
31
|
-
return ;
|
32
|
-
|
33
|
-
create(message);
|
34
|
-
|
35
|
-
form.bind('ajax:beforeSend', function(event) { show() });
|
36
|
-
form.bind('ajax:complete', function(event) { hide() });
|
37
|
-
|
38
|
-
});
|
39
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* Version 0.0.1
|
3
|
-
* Fill in an input field from another one (source)
|
4
|
-
* and apply a filter on the string (slugify)
|
5
|
-
* Didier Lafforgue
|
6
|
-
*/
|
7
|
-
$.fn.slugify = function(settings) {
|
8
|
-
|
9
|
-
settings = $.extend({
|
10
|
-
sep: '-',
|
11
|
-
url: null,
|
12
|
-
underscore: false
|
13
|
-
}, settings);
|
14
|
-
|
15
|
-
var target = $(settings.target);
|
16
|
-
target.data('touched', (target.val() != ''));
|
17
|
-
|
18
|
-
var makeSlug = function(event) {
|
19
|
-
var source = $(this);
|
20
|
-
|
21
|
-
if (settings.url != null) {
|
22
|
-
// Ajax call instead meaning rely on the server to get the slugified version of the field
|
23
|
-
params = { 'string': source.val(), 'underscore': (settings.underscore ? '1' : '0') };
|
24
|
-
jQuery.getJSON(settings.url, params, function(data, textStatus, jqXHR) {
|
25
|
-
var newVal = data['value']
|
26
|
-
|
27
|
-
if (!target.data('touched')) {
|
28
|
-
target.val(newVal);
|
29
|
-
target.trigger('change');
|
30
|
-
}
|
31
|
-
});
|
32
|
-
} else {
|
33
|
-
var newVal = source.val().slugify(settings.sep);
|
34
|
-
|
35
|
-
if (!target.data('touched')) {
|
36
|
-
target.val(newVal);
|
37
|
-
target.trigger('change');
|
38
|
-
}
|
39
|
-
}
|
40
|
-
}
|
41
|
-
|
42
|
-
target.bind('keyup', function(event) {
|
43
|
-
$(this).data('touched', ($(this).val() != ''));
|
44
|
-
});
|
45
|
-
|
46
|
-
return $(this).bind('keyup', makeSlug);
|
47
|
-
};
|