binda 0.0.3 → 0.0.5
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.
- checksums.yaml +4 -4
- data/README.md +14 -29
- data/Rakefile +16 -10
- data/app/assets/javascripts/binda/components/form_item.js +12 -1
- data/app/assets/javascripts/binda/components/form_item_asset.js +1 -0
- data/app/assets/javascripts/binda/components/form_item_choice.js +58 -0
- data/app/assets/javascripts/binda/components/form_item_editor.js +39 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +7 -0
- data/app/assets/javascripts/binda/components/sortable.js +0 -1
- data/app/assets/javascripts/binda/dist/binda.bundle.js +175 -8
- data/app/assets/javascripts/binda/index.js +4 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +64 -2
- data/app/controllers/binda/application_controller.rb +2 -10
- data/app/controllers/binda/choices_controller.rb +19 -0
- data/app/controllers/binda/components_controller.rb +38 -134
- data/app/controllers/binda/field_groups_controller.rb +18 -30
- data/app/controllers/binda/structures_controller.rb +6 -6
- data/app/controllers/concerns/binda/component_controller_helper.rb +16 -0
- data/app/models/binda/checkbox.rb +7 -0
- data/app/models/binda/choice.rb +11 -0
- data/app/models/binda/component.rb +12 -136
- data/app/models/binda/field_group.rb +1 -1
- data/app/models/binda/field_setting.rb +40 -8
- data/app/models/binda/radio.rb +5 -0
- data/app/models/binda/repeater.rb +11 -79
- data/app/models/binda/select.rb +7 -0
- data/app/models/binda/structure.rb +13 -13
- data/app/models/concerns/binda/component_model_helper.rb +170 -0
- data/app/views/binda/components/_form_item_new_repeater.html.erb +3 -5
- data/app/views/binda/components/_form_item_selectable.html.erb +72 -0
- data/app/views/binda/components/_form_section.html.erb +7 -2
- data/app/views/binda/components/_form_section_repeater.html.erb +10 -0
- data/app/views/binda/field_groups/_form_item.html.erb +54 -26
- data/app/views/binda/field_groups/_form_item_choice.erb +96 -0
- data/app/views/binda/field_groups/_form_section.html.erb +2 -2
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +2 -2
- data/config/locales/en.yml +7 -0
- data/config/routes.rb +2 -1
- data/db/migrate/1_create_binda_tables.rb +17 -0
- data/lib/binda/engine.rb +6 -0
- data/lib/binda/version.rb +1 -1
- data/lib/generators/binda/install/install_generator.rb +6 -8
- data/lib/generators/binda/setup/setup_generator.rb +8 -4
- metadata +66 -42
- data/app/controllers/binda/dates_controller.rb +0 -62
- data/app/controllers/binda/texts_controller.rb +0 -62
- data/app/views/binda/dates/_form.html.erb +0 -22
- data/app/views/binda/dates/edit.html.erb +0 -6
- data/app/views/binda/dates/index.html.erb +0 -27
- data/app/views/binda/dates/new.html.erb +0 -5
- data/app/views/binda/dates/show.html.erb +0 -9
- data/app/views/binda/repeaters/_form.html.erb +0 -27
- data/app/views/binda/repeaters/edit.html.erb +0 -6
- data/app/views/binda/repeaters/index.html.erb +0 -29
- data/app/views/binda/repeaters/new.html.erb +0 -5
- data/app/views/binda/repeaters/show.html.erb +0 -14
- data/app/views/binda/structures/add_child.html.erb +0 -0
- data/app/views/binda/texts/_form.html.erb +0 -22
- data/app/views/binda/texts/edit.html.erb +0 -6
- data/app/views/binda/texts/index.html.erb +0 -27
- data/app/views/binda/texts/new.html.erb +0 -5
- data/app/views/binda/texts/show.html.erb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ed52b6a7c00c6370108c689ba3396a79f5e85b8
|
4
|
+
data.tar.gz: 72aaf34b07c36b78c832fe061c4beb35be278a9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2649f0eeeaa9265c349a303e981d44f459dad81d871cb730a8a5094224ab8212425659f31f80d56212d471cba466657d89fd361a6c793b30d44bc49f7a90e1e
|
7
|
+
data.tar.gz: 63e9fd484c883eac80fd00d3c8b5bff90222418df2290d55bc6bccec1a564371307441ae06827183b327a0f1eb85973a9e3132a62996f93f921afdf7233c8ab0
|
data/README.md
CHANGED
@@ -10,53 +10,38 @@ A modular CMS for Ruby on Rails 5.
|
|
10
10
|
Add this line to your application's Gemfile:
|
11
11
|
|
12
12
|
```ruby
|
13
|
-
gem 'binda',
|
13
|
+
gem 'binda', '~> 0.0.5'
|
14
14
|
```
|
15
15
|
|
16
|
-
|
16
|
+
Then execute:
|
17
17
|
```bash
|
18
18
|
$ bundle
|
19
19
|
```
|
20
20
|
|
21
|
-
|
22
|
-
```bash
|
23
|
-
$
|
24
|
-
$ rails generate binda:install
|
21
|
+
To install Binda run the installer from terminal.
|
22
|
+
``` bash
|
23
|
+
$ rails g binda:install
|
25
24
|
```
|
26
25
|
|
27
|
-
|
28
|
-
Binda has some dependencies which you might need to update if you have a very specific environment.
|
26
|
+
Now you are good to go. Run `rails s` and check the administration panel at `http://localhost:3000/admin_panel`.
|
29
27
|
|
30
|
-
|
28
|
+
To get into details read [Binda Guidelines](https://github.com/lacolonia/binda/wiki).
|
31
29
|
|
32
|
-
|
30
|
+
**Warning: run the installer once.** Running the installer for each application environment will cause issues with users' passwords. Also remember that if you need to re-install Binda you need to drop all Binda database tables first. More details [here](https://github.com/lacolonia/binda/wiki/Installation)
|
33
31
|
|
34
32
|
## Bug reporting
|
35
33
|
Please refer to this [guide](http://yourbugreportneedsmore.info).
|
34
|
+
If you need direct help you can join [Binda Slack Community](https://binda.herokuapp.com).
|
36
35
|
|
37
|
-
## Contributing
|
38
|
-
In order to contribute you need to have NodeJs and NPM installed.
|
39
|
-
|
40
|
-
If you are using NVM you can run the folloing command from the application root to detect the version specified on the repository.
|
41
|
-
|
42
|
-
```bash
|
43
|
-
$ nvm use .
|
44
|
-
```
|
45
|
-
|
46
|
-
If you are planning to work on the javascript files you need to open a terminal window and execute the following command. You need to keep that window open otherwise you will have to run the command every time you save a javascript file.
|
47
|
-
|
48
|
-
```bash
|
49
|
-
$ npm install
|
50
|
-
$ webpack
|
51
|
-
```
|
52
|
-
|
53
|
-
The main entry point is the `index.js`. To know more about how Webpack works please head to the [official documentation](https://webpack.js.org/).
|
54
|
-
|
55
|
-
Please comment your code as much as possible.
|
56
36
|
|
57
37
|
## License
|
58
38
|
The gem is available as open source under the terms of the [GNU General Public License v3.0](https://github.com/a-barbieri/binda/blob/master/LICENSE).
|
59
39
|
|
40
|
+
## Credits
|
41
|
+
Binda is inspired by [Spina CMS](https://github.com/denkGroot/Spina).
|
42
|
+
|
43
|
+
We give also credit to authors and contributors of the gems that Binda uses. Huge thank you to all of them.
|
44
|
+
|
60
45
|
## Who is Binda?
|
61
46
|
Is [this guy here](https://en.wikipedia.org/wiki/Alfredo_Binda).
|
62
47
|
|
data/Rakefile
CHANGED
@@ -14,24 +14,30 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
|
21
21
|
load 'rails/tasks/statistics.rake'
|
22
22
|
|
23
23
|
|
24
|
-
|
25
24
|
require 'bundler/gem_tasks'
|
26
25
|
|
27
|
-
require 'rake/testtask'
|
28
26
|
|
29
|
-
Rake::TestTask.new(:test) do |t|
|
30
|
-
t.libs << 'lib'
|
31
|
-
t.libs << 'test'
|
32
|
-
t.pattern = 'test/**/*_test.rb'
|
33
|
-
t.verbose = false
|
34
|
-
end
|
35
27
|
|
28
|
+
# # I guess this generate test file every time you use `rails g` command
|
29
|
+
# require 'rake/testtask'
|
30
|
+
# Rake::TestTask.new(:test) do |t|
|
31
|
+
# t.libs << 'lib'
|
32
|
+
# t.libs << 'test'
|
33
|
+
# t.pattern = 'test/**/*_test.rb'
|
34
|
+
# t.verbose = false
|
35
|
+
# end
|
36
|
+
# task default: :test
|
36
37
|
|
37
|
-
|
38
|
+
# This should ensure creation of spec instead of test (partially true)
|
39
|
+
# https://stackoverflow.com/a/4632188/1498118
|
40
|
+
require 'rspec/core/rake_task'
|
41
|
+
RSpec::Core::RakeTask.new('spec')
|
42
|
+
# If you want to make this the default task
|
43
|
+
task :default => :spec
|
@@ -2,6 +2,8 @@
|
|
2
2
|
/// FORM ITEM
|
3
3
|
///- - - - - - - - - - - - - - - - - - - -
|
4
4
|
|
5
|
+
import { _FormItemEditor } from './form_item_editor'
|
6
|
+
|
5
7
|
class FormItem {
|
6
8
|
|
7
9
|
constructor()
|
@@ -28,7 +30,15 @@ class FormItem {
|
|
28
30
|
|
29
31
|
$(document).on('click', '.form-item--open-button, .form-item--close-button', function()
|
30
32
|
{
|
31
|
-
$( this ).parent('.form-item').children('.form-item--editor')
|
33
|
+
var formItemEditor = $( this ).parent('.form-item').children('.form-item--editor')
|
34
|
+
|
35
|
+
// Make sure form-item--editor max-height correspond to the actual height
|
36
|
+
// this is needed for the CSS transition which is trigger clicking open/close button
|
37
|
+
if ( !formItemEditor.hasClass('form-item--editor-close') )
|
38
|
+
{ _FormItemEditor.resize() }
|
39
|
+
|
40
|
+
// Update classes
|
41
|
+
formItemEditor.toggleClass('form-item--editor-close')
|
32
42
|
$( this ).parent('.form-item').children('.form-item--open-button, .form-item--close-button').toggle()
|
33
43
|
})
|
34
44
|
}
|
@@ -51,4 +61,5 @@ function addNewItem( event )
|
|
51
61
|
// Clone child and remove id and styles from cloned child
|
52
62
|
$newChild.clone().insertAfter( $newChild )
|
53
63
|
$newChild.removeClass( 'form-item--new' ).removeAttr( 'id' )
|
64
|
+
_FormItemEditor.resize()
|
54
65
|
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
///- - - - - - - - - - - - - - - - - - - -
|
2
|
+
/// FORM ITEM
|
3
|
+
///- - - - - - - - - - - - - - - - - - - -
|
4
|
+
|
5
|
+
import { _FormItemEditor } from './form_item_editor'
|
6
|
+
|
7
|
+
|
8
|
+
class FormItemChoice {
|
9
|
+
|
10
|
+
constructor()
|
11
|
+
{
|
12
|
+
this.target = '.form-item--choice'
|
13
|
+
}
|
14
|
+
|
15
|
+
isSet()
|
16
|
+
{
|
17
|
+
if ( $( this.target ).length > 0 ) { return true }
|
18
|
+
else { return false }
|
19
|
+
}
|
20
|
+
|
21
|
+
setEvents()
|
22
|
+
{
|
23
|
+
$(document).on('click', '.form-item--add-choice', function( event )
|
24
|
+
{
|
25
|
+
event.preventDefault()
|
26
|
+
// Clone the new choice field
|
27
|
+
var choices = $( this ).parent('.form-item--choices')
|
28
|
+
var newchoice = choices.find('.form-item--new-choice')
|
29
|
+
var clone = newchoice.clone().removeClass('form-item--new-choice').toggle()
|
30
|
+
clone.find('.form-item--toggle-choice').toggle()
|
31
|
+
// Append the clone right after
|
32
|
+
choices.prepend( clone )
|
33
|
+
// Update form item editor size
|
34
|
+
_FormItemEditor.resize()
|
35
|
+
})
|
36
|
+
|
37
|
+
$(document).on('click', '.form-item--delete-choice', function( event )
|
38
|
+
{
|
39
|
+
event.preventDefault()
|
40
|
+
|
41
|
+
var choice = $( this ).parent('.form-item--choice')
|
42
|
+
var destination = $( this ).attr('href')
|
43
|
+
|
44
|
+
$.ajax({
|
45
|
+
url: destination,
|
46
|
+
type: 'DELETE',
|
47
|
+
success: function() { choice.remove() }
|
48
|
+
})
|
49
|
+
})
|
50
|
+
$(document).on('click', '.form-item--js-delete-choice', function( event )
|
51
|
+
{
|
52
|
+
event.preventDefault()
|
53
|
+
$( this ).parent('.form-item--choice').remove()
|
54
|
+
})
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
export let _FormItemChoice = new FormItemChoice()
|
@@ -0,0 +1,39 @@
|
|
1
|
+
///- - - - - - - - - - - - - - - - - - - -
|
2
|
+
/// FORM ITEM
|
3
|
+
///- - - - - - - - - - - - - - - - - - - -
|
4
|
+
|
5
|
+
class FormItemEditor {
|
6
|
+
|
7
|
+
constructor()
|
8
|
+
{
|
9
|
+
this.target = '.form-item--editor'
|
10
|
+
}
|
11
|
+
|
12
|
+
isSet()
|
13
|
+
{
|
14
|
+
if ( $( this.target ).length > 0 ) { return true }
|
15
|
+
else { return false }
|
16
|
+
}
|
17
|
+
|
18
|
+
setEvents()
|
19
|
+
{
|
20
|
+
// run resize to set initial size
|
21
|
+
this.resize()
|
22
|
+
// run resize on each of these events
|
23
|
+
$(window).resize( ()=>{ this.resize() } )
|
24
|
+
}
|
25
|
+
|
26
|
+
resize()
|
27
|
+
{
|
28
|
+
$( this.target ).each( function(){
|
29
|
+
// If the form item edito is closed don't go any further
|
30
|
+
if ( $(this).height() === 0 ) return
|
31
|
+
// otherwise update the max-height which is needed for the CSS transition
|
32
|
+
// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
|
33
|
+
$(this).css( "max-height", $(this).removeAttr('style').height() )
|
34
|
+
})
|
35
|
+
}
|
36
|
+
|
37
|
+
}
|
38
|
+
|
39
|
+
export let _FormItemEditor = new FormItemEditor()
|
@@ -2,6 +2,8 @@
|
|
2
2
|
/// FORM ITEM
|
3
3
|
///- - - - - - - - - - - - - - - - - - - -
|
4
4
|
|
5
|
+
import { _FormItemEditor } from './form_item_editor'
|
6
|
+
|
5
7
|
class FormItemRepeater {
|
6
8
|
|
7
9
|
constructor()
|
@@ -18,12 +20,15 @@ class FormItemRepeater {
|
|
18
20
|
setEvents()
|
19
21
|
{
|
20
22
|
$(document).on('click', this.target + '--add-new', addNewItem )
|
23
|
+
|
21
24
|
$(document).on('click', '.form-item--remove-item-with-js', function( event )
|
22
25
|
{
|
23
26
|
// Stop default behaviour
|
24
27
|
event.preventDefault()
|
25
28
|
$( this ).parent( this.target ).remove()
|
29
|
+
_FormItemEditor.resize()
|
26
30
|
})
|
31
|
+
|
27
32
|
$(document).on('click', '.form-item--delete-repeater-item', function( event )
|
28
33
|
{
|
29
34
|
// Stop default behaviour
|
@@ -35,6 +40,7 @@ class FormItemRepeater {
|
|
35
40
|
method: "DELETE"
|
36
41
|
}).done( ()=>{
|
37
42
|
$( this ).parent('li').remove()
|
43
|
+
_FormItemEditor.resize()
|
38
44
|
})
|
39
45
|
})
|
40
46
|
}
|
@@ -62,5 +68,6 @@ function addNewItem( event )
|
|
62
68
|
$list.append( newRepeater )
|
63
69
|
var editor_id = $list.find('textarea').last('textarea').attr('id')
|
64
70
|
tinyMCE.EditorManager.execCommand('mceAddEditor',true, editor_id);
|
71
|
+
_FormItemEditor.resize()
|
65
72
|
})
|
66
73
|
}
|
@@ -63,7 +63,7 @@
|
|
63
63
|
/******/ __webpack_require__.p = "";
|
64
64
|
/******/
|
65
65
|
/******/ // Load entry module and return exports
|
66
|
-
/******/ return __webpack_require__(__webpack_require__.s =
|
66
|
+
/******/ return __webpack_require__(__webpack_require__.s = 5);
|
67
67
|
/******/ })
|
68
68
|
/************************************************************************/
|
69
69
|
/******/ ([
|
@@ -71,6 +71,7 @@
|
|
71
71
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
72
72
|
|
73
73
|
"use strict";
|
74
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(6);
|
74
75
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
|
75
76
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
76
77
|
|
@@ -80,6 +81,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
80
81
|
/// FORM ITEM
|
81
82
|
///- - - - - - - - - - - - - - - - - - - -
|
82
83
|
|
84
|
+
|
85
|
+
|
83
86
|
var FormItem = function () {
|
84
87
|
function FormItem() {
|
85
88
|
_classCallCheck(this, FormItem);
|
@@ -108,7 +111,16 @@ var FormItem = function () {
|
|
108
111
|
});
|
109
112
|
|
110
113
|
$(document).on('click', '.form-item--open-button, .form-item--close-button', function () {
|
111
|
-
$(this).parent('.form-item').children('.form-item--editor')
|
114
|
+
var formItemEditor = $(this).parent('.form-item').children('.form-item--editor');
|
115
|
+
|
116
|
+
// Make sure form-item--editor max-height correspond to the actual height
|
117
|
+
// this is needed for the CSS transition which is trigger clicking open/close button
|
118
|
+
if (!formItemEditor.hasClass('form-item--editor-close')) {
|
119
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
120
|
+
}
|
121
|
+
|
122
|
+
// Update classes
|
123
|
+
formItemEditor.toggleClass('form-item--editor-close');
|
112
124
|
$(this).parent('.form-item').children('.form-item--open-button, .form-item--close-button').toggle();
|
113
125
|
});
|
114
126
|
}
|
@@ -132,6 +144,7 @@ function addNewItem(event) {
|
|
132
144
|
// Clone child and remove id and styles from cloned child
|
133
145
|
$newChild.clone().insertAfter($newChild);
|
134
146
|
$newChild.removeClass('form-item--new').removeAttr('id');
|
147
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
135
148
|
}
|
136
149
|
|
137
150
|
/***/ }),
|
@@ -168,6 +181,7 @@ var FormItemAsset = function () {
|
|
168
181
|
key: 'setEvents',
|
169
182
|
value: function setEvents() {
|
170
183
|
// here code to setup assets via ajax
|
184
|
+
//
|
171
185
|
}
|
172
186
|
}]);
|
173
187
|
|
@@ -181,6 +195,82 @@ var _FormItemAsset = new FormItemAsset();
|
|
181
195
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
182
196
|
|
183
197
|
"use strict";
|
198
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(6);
|
199
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemChoice; });
|
200
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
201
|
+
|
202
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
203
|
+
|
204
|
+
///- - - - - - - - - - - - - - - - - - - -
|
205
|
+
/// FORM ITEM
|
206
|
+
///- - - - - - - - - - - - - - - - - - - -
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
var FormItemChoice = function () {
|
211
|
+
function FormItemChoice() {
|
212
|
+
_classCallCheck(this, FormItemChoice);
|
213
|
+
|
214
|
+
this.target = '.form-item--choice';
|
215
|
+
}
|
216
|
+
|
217
|
+
_createClass(FormItemChoice, [{
|
218
|
+
key: 'isSet',
|
219
|
+
value: function isSet() {
|
220
|
+
if ($(this.target).length > 0) {
|
221
|
+
return true;
|
222
|
+
} else {
|
223
|
+
return false;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}, {
|
227
|
+
key: 'setEvents',
|
228
|
+
value: function setEvents() {
|
229
|
+
$(document).on('click', '.form-item--add-choice', function (event) {
|
230
|
+
event.preventDefault();
|
231
|
+
// Clone the new choice field
|
232
|
+
var choices = $(this).parent('.form-item--choices');
|
233
|
+
var newchoice = choices.find('.form-item--new-choice');
|
234
|
+
var clone = newchoice.clone().removeClass('form-item--new-choice').toggle();
|
235
|
+
clone.find('.form-item--toggle-choice').toggle();
|
236
|
+
// Append the clone right after
|
237
|
+
choices.prepend(clone);
|
238
|
+
// Update form item editor size
|
239
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
240
|
+
});
|
241
|
+
|
242
|
+
$(document).on('click', '.form-item--delete-choice', function (event) {
|
243
|
+
event.preventDefault();
|
244
|
+
|
245
|
+
var choice = $(this).parent('.form-item--choice');
|
246
|
+
var destination = $(this).attr('href');
|
247
|
+
|
248
|
+
$.ajax({
|
249
|
+
url: destination,
|
250
|
+
type: 'DELETE',
|
251
|
+
success: function success() {
|
252
|
+
choice.remove();
|
253
|
+
}
|
254
|
+
});
|
255
|
+
});
|
256
|
+
$(document).on('click', '.form-item--js-delete-choice', function (event) {
|
257
|
+
event.preventDefault();
|
258
|
+
$(this).parent('.form-item--choice').remove();
|
259
|
+
});
|
260
|
+
}
|
261
|
+
}]);
|
262
|
+
|
263
|
+
return FormItemChoice;
|
264
|
+
}();
|
265
|
+
|
266
|
+
var _FormItemChoice = new FormItemChoice();
|
267
|
+
|
268
|
+
/***/ }),
|
269
|
+
/* 3 */
|
270
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
271
|
+
|
272
|
+
"use strict";
|
273
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(6);
|
184
274
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
|
185
275
|
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
186
276
|
|
@@ -190,6 +280,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
190
280
|
/// FORM ITEM
|
191
281
|
///- - - - - - - - - - - - - - - - - - - -
|
192
282
|
|
283
|
+
|
284
|
+
|
193
285
|
var FormItemRepeater = function () {
|
194
286
|
function FormItemRepeater() {
|
195
287
|
_classCallCheck(this, FormItemRepeater);
|
@@ -210,11 +302,14 @@ var FormItemRepeater = function () {
|
|
210
302
|
key: 'setEvents',
|
211
303
|
value: function setEvents() {
|
212
304
|
$(document).on('click', this.target + '--add-new', addNewItem);
|
305
|
+
|
213
306
|
$(document).on('click', '.form-item--remove-item-with-js', function (event) {
|
214
307
|
// Stop default behaviour
|
215
308
|
event.preventDefault();
|
216
309
|
$(this).parent(this.target).remove();
|
310
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
217
311
|
});
|
312
|
+
|
218
313
|
$(document).on('click', '.form-item--delete-repeater-item', function (event) {
|
219
314
|
var _this = this;
|
220
315
|
|
@@ -227,6 +322,7 @@ var FormItemRepeater = function () {
|
|
227
322
|
method: "DELETE"
|
228
323
|
}).done(function () {
|
229
324
|
$(_this).parent('li').remove();
|
325
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
230
326
|
});
|
231
327
|
});
|
232
328
|
}
|
@@ -254,11 +350,12 @@ function addNewItem(event) {
|
|
254
350
|
$list.append(newRepeater);
|
255
351
|
var editor_id = $list.find('textarea').last('textarea').attr('id');
|
256
352
|
tinyMCE.EditorManager.execCommand('mceAddEditor', true, editor_id);
|
353
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
257
354
|
});
|
258
355
|
}
|
259
356
|
|
260
357
|
/***/ }),
|
261
|
-
/*
|
358
|
+
/* 4 */
|
262
359
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
263
360
|
|
264
361
|
"use strict";
|
@@ -270,7 +367,7 @@ function addNewItem(event) {
|
|
270
367
|
update: function update() {
|
271
368
|
$.post($(this).data('update-url'), $(this).sortable('serialize'));
|
272
369
|
}
|
273
|
-
})
|
370
|
+
});
|
274
371
|
|
275
372
|
// Check if sortable item needs handles
|
276
373
|
$('.sortable').each(function () {
|
@@ -301,15 +398,17 @@ function addNewItem(event) {
|
|
301
398
|
};
|
302
399
|
|
303
400
|
/***/ }),
|
304
|
-
/*
|
401
|
+
/* 5 */
|
305
402
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
306
403
|
|
307
404
|
"use strict";
|
308
405
|
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
309
406
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(0);
|
310
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(
|
407
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(3);
|
311
408
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__ = __webpack_require__(1);
|
312
|
-
/* harmony import */ var
|
409
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__ = __webpack_require__(2);
|
410
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(6);
|
411
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_sortable__ = __webpack_require__(4);
|
313
412
|
///- - - - - - - - - - - - - - - - - - - -
|
314
413
|
/// INDEX OF BINDA'S SCRIPTS
|
315
414
|
///- - - - - - - - - - - - - - - - - - - -
|
@@ -319,6 +418,8 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|
319
418
|
|
320
419
|
|
321
420
|
|
421
|
+
|
422
|
+
|
322
423
|
$(document).ready(function () {
|
323
424
|
if (__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].isSet()) {
|
324
425
|
__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].setEvents();
|
@@ -329,8 +430,74 @@ $(document).ready(function () {
|
|
329
430
|
if (__WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__["a" /* _FormItemAsset */].isSet()) {
|
330
431
|
__WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__["a" /* _FormItemAsset */].setEvents();
|
331
432
|
}
|
332
|
-
|
433
|
+
if (__WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__["a" /* _FormItemChoice */].isSet()) {
|
434
|
+
__WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__["a" /* _FormItemChoice */].setEvents();
|
435
|
+
}
|
436
|
+
if (__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].isSet()) {
|
437
|
+
__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].setEvents();
|
438
|
+
}
|
439
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_5__components_sortable__["a" /* default */])();
|
333
440
|
});
|
334
441
|
|
442
|
+
/***/ }),
|
443
|
+
/* 6 */
|
444
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
445
|
+
|
446
|
+
"use strict";
|
447
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemEditor; });
|
448
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
449
|
+
|
450
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
451
|
+
|
452
|
+
///- - - - - - - - - - - - - - - - - - - -
|
453
|
+
/// FORM ITEM
|
454
|
+
///- - - - - - - - - - - - - - - - - - - -
|
455
|
+
|
456
|
+
var FormItemEditor = function () {
|
457
|
+
function FormItemEditor() {
|
458
|
+
_classCallCheck(this, FormItemEditor);
|
459
|
+
|
460
|
+
this.target = '.form-item--editor';
|
461
|
+
}
|
462
|
+
|
463
|
+
_createClass(FormItemEditor, [{
|
464
|
+
key: 'isSet',
|
465
|
+
value: function isSet() {
|
466
|
+
if ($(this.target).length > 0) {
|
467
|
+
return true;
|
468
|
+
} else {
|
469
|
+
return false;
|
470
|
+
}
|
471
|
+
}
|
472
|
+
}, {
|
473
|
+
key: 'setEvents',
|
474
|
+
value: function setEvents() {
|
475
|
+
var _this = this;
|
476
|
+
|
477
|
+
// run resize to set initial size
|
478
|
+
this.resize();
|
479
|
+
// run resize on each of these events
|
480
|
+
$(window).resize(function () {
|
481
|
+
_this.resize();
|
482
|
+
});
|
483
|
+
}
|
484
|
+
}, {
|
485
|
+
key: 'resize',
|
486
|
+
value: function resize() {
|
487
|
+
$(this.target).each(function () {
|
488
|
+
// If the form item edito is closed don't go any further
|
489
|
+
if ($(this).height() === 0) return;
|
490
|
+
// otherwise update the max-height which is needed for the CSS transition
|
491
|
+
// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
|
492
|
+
$(this).css("max-height", $(this).removeAttr('style').height());
|
493
|
+
});
|
494
|
+
}
|
495
|
+
}]);
|
496
|
+
|
497
|
+
return FormItemEditor;
|
498
|
+
}();
|
499
|
+
|
500
|
+
var _FormItemEditor = new FormItemEditor();
|
501
|
+
|
335
502
|
/***/ })
|
336
503
|
/******/ ]);
|