effective_form_inputs 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +66 -3
- data/app/assets/javascripts/effective_ckeditor_text_area/initialize.js.coffee +77 -0
- data/app/assets/javascripts/effective_ckeditor_text_area/input.js +1 -0
- data/app/assets/javascripts/effective_form_inputs.js +1 -0
- data/app/models/effective/form_builder_inputs.rb +4 -0
- data/app/models/inputs/effective_ckeditor_text_area/input.rb +20 -0
- data/app/models/inputs/effective_ckeditor_text_area_input.rb +12 -0
- data/app/views/effective/style_guide/{_form_default.html.haml → _effective_form_inputs.html.haml} +8 -0
- data/lib/effective_form_inputs/version.rb +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4084b5079c6d29cd3f98010bd091adb6786ce685
|
4
|
+
data.tar.gz: e31931a190b06729b54a2d10093d4ae12f9f6b9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69358afe7a55687546787a30a1336fc41a4f4ca4631d2afe8287f771b34fb24b38e4c83cf9eba03ad55fc2f60deea75fbcf9ca1b88420118bebc929562a2358b
|
7
|
+
data.tar.gz: ecfbf949418dfa89dbd92df199a794c9b97313f391f54eb4ab53f2e50319c13f4a557681379cba465442ca48e7e357c98681384d39d5ef20df6d917b742bf19f
|
data/README.md
CHANGED
@@ -377,9 +377,7 @@ There is currently no support for using AJAX to load remote data. This feature
|
|
377
377
|
|
378
378
|
This custom form input uses a jQuery maskedInput plugin from the following awesome project:
|
379
379
|
|
380
|
-
|
381
|
-
|
382
|
-
https://github.com/digitalBush/jquery.maskedinput
|
380
|
+
jQuery Masked Input Plugin (https://github.com/digitalBush/jquery.maskedinput)
|
383
381
|
|
384
382
|
|
385
383
|
### Installation
|
@@ -473,6 +471,71 @@ There are no javascript options for this input.
|
|
473
471
|
This input also installs a rails view helper `price_to_currency` that takes a value like `10000` and displays it as `$100.00`
|
474
472
|
|
475
473
|
|
474
|
+
## Effective CKEditor Text Area
|
475
|
+
|
476
|
+
This custom form input replaces a standard textarea with a CKEditor html rich text area.
|
477
|
+
|
478
|
+
It is based on the widely used:
|
479
|
+
|
480
|
+
CKEditor (http://ckeditor.com/)
|
481
|
+
|
482
|
+
and built ontop of
|
483
|
+
|
484
|
+
effective_ckeditor (https://github.com/code-and-effect/effective_ckeditor/)
|
485
|
+
|
486
|
+
### Installation
|
487
|
+
|
488
|
+
You must first install [effective_ckeditor](https://github.com/code-and-effect/effective_ckeditor/)
|
489
|
+
|
490
|
+
```ruby
|
491
|
+
gem 'effective_ckeditor'
|
492
|
+
```
|
493
|
+
|
494
|
+
Depending on how often you're going to display this form input, you now have two options:
|
495
|
+
|
496
|
+
- You can do nothing, and when this form input is displayed it will use javascript to load the ckeditor .js and .css file on $(ready). It will make 2 additional requests, slowing down your page load by a moment.
|
497
|
+
|
498
|
+
- Or, when you intend to use the input quite a bit, it's faster to add the effective_ckeditor resources to the asset pipeline. However, it will increase the asset payload by around 200kb.
|
499
|
+
|
500
|
+
To add it to the asset pipeline, put the following to your application.js:
|
501
|
+
|
502
|
+
```ruby
|
503
|
+
//= require effective_ckeditor
|
504
|
+
```
|
505
|
+
|
506
|
+
and in your application.css, add:
|
507
|
+
|
508
|
+
```ruby
|
509
|
+
*= require effective_ckeditor
|
510
|
+
```
|
511
|
+
|
512
|
+
There are no additional effective_ckeditor installation steps.
|
513
|
+
|
514
|
+
|
515
|
+
If you've already installed the 'All Form Inputs' assets (see above), there are no additional installation steps.
|
516
|
+
|
517
|
+
To install this form input individually, add the following to your application.js:
|
518
|
+
|
519
|
+
```ruby
|
520
|
+
//= require effective_ckeditor_text_area/input
|
521
|
+
```
|
522
|
+
|
523
|
+
### Usage
|
524
|
+
|
525
|
+
As a Rails Form Helper input:
|
526
|
+
|
527
|
+
```ruby
|
528
|
+
= form_for @post do |f|
|
529
|
+
= f.effective_ckeditor_text_area :body
|
530
|
+
```
|
531
|
+
|
532
|
+
As a SimpleForm input:
|
533
|
+
|
534
|
+
```ruby
|
535
|
+
= simple_form_for @post do |f|
|
536
|
+
= f.input :body, :as => :effective_ckeditor_text_area
|
537
|
+
```
|
538
|
+
|
476
539
|
## License
|
477
540
|
|
478
541
|
MIT License. Copyright [Code and Effect Inc.](http://www.codeandeffect.com/)
|
@@ -0,0 +1,77 @@
|
|
1
|
+
initialize = ->
|
2
|
+
$inputs = $('textarea.effective_ckeditor_text_area:not(.initialized)')
|
3
|
+
setupCkeditor($inputs)
|
4
|
+
|
5
|
+
$inputs.each (i, element) ->
|
6
|
+
element = $(element)
|
7
|
+
element.addClass('initialized')
|
8
|
+
initCkeditor(element)
|
9
|
+
|
10
|
+
# This is a one-time initialization that is done to check that all the scripts are properly set up
|
11
|
+
setupCkeditor = ($inputs) ->
|
12
|
+
return unless $inputs.length > 0
|
13
|
+
|
14
|
+
ckeditor_present = ((try CKEDITOR.version) || '').length > 0
|
15
|
+
use_effective_assets = ($inputs.first().data('input-js-options') || {})['effective_assets'] == true
|
16
|
+
$head = $('head')
|
17
|
+
|
18
|
+
unless ckeditor_present
|
19
|
+
$head.append("<script src='/assets/effective_ckeditor.js' />")
|
20
|
+
$head.append("<link href='/assets/effective_ckeditor.css' type='text/css', media='screen' rel='stylesheet' />")
|
21
|
+
|
22
|
+
if use_effective_assets
|
23
|
+
$head.append("
|
24
|
+
<script>
|
25
|
+
CKEDITOR.config['effective_regions'] = {
|
26
|
+
'snippets': {
|
27
|
+
'effective_asset': {
|
28
|
+
'dialog_url':'/assets/effective/snippets/effective_asset.js',
|
29
|
+
'label':'Effective asset',
|
30
|
+
'description':'Insert Effective asset',
|
31
|
+
'inline':true,
|
32
|
+
'editables':false,
|
33
|
+
'tag':'span'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
};
|
37
|
+
</script>
|
38
|
+
");
|
39
|
+
|
40
|
+
initCkeditor = (textarea) ->
|
41
|
+
CKEDITOR.replace(textarea.attr('id'),
|
42
|
+
toolbar: 'full'
|
43
|
+
effectiveRegionType: 'full'
|
44
|
+
customConfig: ''
|
45
|
+
enterMode: CKEDITOR.ENTER_P
|
46
|
+
shiftEnterMode: CKEDITOR.ENTER_BR
|
47
|
+
startupOutlineBlocks: false
|
48
|
+
startupShowBorders: true
|
49
|
+
disableNativeTableHandles: true
|
50
|
+
extraPlugins: 'effective_regions,effective_assets'
|
51
|
+
removePlugins: 'elementspath'
|
52
|
+
format_tags: 'p;h1;h2;h3;h4;h5;h6;pre;div'
|
53
|
+
templates: 'effective_regions'
|
54
|
+
templates_files: []
|
55
|
+
templates_replaceContent: false
|
56
|
+
filebrowserWindowHeight: 600
|
57
|
+
filebrowserWindowWidth: 800
|
58
|
+
filebrowserBrowseUrl: '/effective/assets?only=images'
|
59
|
+
toolbar_full: [
|
60
|
+
{ name: 'save', items: ['NewPage'] },
|
61
|
+
{ name: 'html', items: ['Sourcedialog', '-', 'ShowBlocks'] },
|
62
|
+
{ name: 'editing', items: ['Undo', 'Redo'] },
|
63
|
+
{ name: 'clipboard', items: ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'] },
|
64
|
+
{ name: 'justify', items: ['JustifyLeft', 'JustifyCenter', 'JustifyRight']}
|
65
|
+
{ name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat'] },
|
66
|
+
'/',
|
67
|
+
{ name: 'definedstyles', items: ['Format'] },
|
68
|
+
{ name: 'links', items: ['Link', 'Unlink', '-', 'Anchor'] },
|
69
|
+
{ name: 'insert', items: ['Image', 'oembed', 'EffectiveAssets'] },
|
70
|
+
{ name: 'lists', items: ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent'] },
|
71
|
+
{ name: 'insert2', items: ['Table', 'EffectiveReferences', 'Blockquote', 'HorizontalRule', 'PageBreak'] }
|
72
|
+
]
|
73
|
+
)
|
74
|
+
|
75
|
+
$ -> initialize()
|
76
|
+
$(document).on 'page:change', -> initialize()
|
77
|
+
$(document).on 'cocoon:after-insert', -> initialize()
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./initialize
|
@@ -1,5 +1,9 @@
|
|
1
1
|
module Effective
|
2
2
|
module FormBuilderInputs
|
3
|
+
def effective_ckeditor_text_area(method, options_tag = nil, options = {}, html_options = {})
|
4
|
+
Inputs::EffectiveCkeditorTextArea::Input.new(@object, @object_name, @template, method, options, html_options).to_html
|
5
|
+
end
|
6
|
+
|
3
7
|
def effective_date_time_picker(method, options = {})
|
4
8
|
Inputs::EffectiveDateTimePicker::Input.new(@object, @object_name, @template, method, options, options).to_html
|
5
9
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Inputs
|
2
|
+
module EffectiveCkeditorTextArea
|
3
|
+
class Input < Effective::FormInput
|
4
|
+
delegate :content_tag, :text_area_tag, :to => :@template
|
5
|
+
|
6
|
+
def default_input_js
|
7
|
+
{effective_assets: defined?(EffectiveAssets).present? }
|
8
|
+
end
|
9
|
+
|
10
|
+
def default_input_html
|
11
|
+
{class: 'effective_ckeditor_text_area text'}
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_html
|
15
|
+
text_area_tag(field_name, value, tag_options)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# = simple_form_for @thing do |f|
|
2
|
+
# = f.input :body_content, :as => :effective_ckeditor_text_area
|
3
|
+
|
4
|
+
if defined?(SimpleForm)
|
5
|
+
|
6
|
+
class EffectiveCkeditorTextAreaInput < SimpleForm::Inputs::StringInput
|
7
|
+
def input(wrapper_options = nil)
|
8
|
+
Inputs::EffectiveCkeditorTextarea::Input.new(object, object_name, template, attribute_name, input_options, (merge_wrapper_options(input_html_options, wrapper_options) || {})).to_html
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
data/app/views/effective/style_guide/{_form_default.html.haml → _effective_form_inputs.html.haml}
RENAMED
@@ -1,6 +1,14 @@
|
|
1
1
|
/ this gives me a mechanism to test the inputs easily on a site with effective style_guide installed
|
2
2
|
|
3
3
|
= form_for Effective::StyleGuide.new(:category => 'Category 2'), :url => '/' do |f|
|
4
|
+
= f.effective_ckeditor_text_area :content
|
5
|
+
|
6
|
+
/ = f.input :updated_at, as: :effective_date_picker
|
7
|
+
/ = f.input :updated_at, as: :effective_date_time_picker
|
8
|
+
/ = f.input :price, as: :effective_price
|
9
|
+
/ = f.input :category, as: :effective_select, collection: 10.times.map { |x| "Category #{x}"}
|
10
|
+
/ = f.input :number, as: :effective_tel
|
11
|
+
|
4
12
|
/ = f.date_field :updated_at, :class => 'my-class'
|
5
13
|
/ = f.effective_date_picker :updated_at, :class => 'my-class'
|
6
14
|
/ %hr
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_form_inputs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -48,6 +48,8 @@ files:
|
|
48
48
|
- MIT-LICENSE
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
|
+
- app/assets/javascripts/effective_ckeditor_text_area/initialize.js.coffee
|
52
|
+
- app/assets/javascripts/effective_ckeditor_text_area/input.js
|
51
53
|
- app/assets/javascripts/effective_date_picker/initialize.js.coffee
|
52
54
|
- app/assets/javascripts/effective_date_picker/input.js
|
53
55
|
- app/assets/javascripts/effective_date_time_picker/bootstrap-datetimepicker.js
|
@@ -77,6 +79,8 @@ files:
|
|
77
79
|
- app/helpers/effective_form_inputs_helper.rb
|
78
80
|
- app/models/effective/form_builder_inputs.rb
|
79
81
|
- app/models/effective/form_input.rb
|
82
|
+
- app/models/inputs/effective_ckeditor_text_area/input.rb
|
83
|
+
- app/models/inputs/effective_ckeditor_text_area_input.rb
|
80
84
|
- app/models/inputs/effective_date_picker/input.rb
|
81
85
|
- app/models/inputs/effective_date_picker_input.rb
|
82
86
|
- app/models/inputs/effective_date_time_picker/input.rb
|
@@ -89,7 +93,7 @@ files:
|
|
89
93
|
- app/models/inputs/effective_static_control_input.rb
|
90
94
|
- app/models/inputs/effective_tel/input.rb
|
91
95
|
- app/models/inputs/effective_tel_input.rb
|
92
|
-
- app/views/effective/style_guide/
|
96
|
+
- app/views/effective/style_guide/_effective_form_inputs.html.haml
|
93
97
|
- lib/effective_form_inputs.rb
|
94
98
|
- lib/effective_form_inputs/engine.rb
|
95
99
|
- lib/effective_form_inputs/version.rb
|