binda 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +63 -0
- data/Rakefile +37 -0
- data/app/assets/config/binda_manifest.js +2 -0
- data/app/assets/javascripts/binda/application.js +18 -0
- data/app/assets/javascripts/binda/components/form_item.js +54 -0
- data/app/assets/javascripts/binda/components/form_item_asset.js +24 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +66 -0
- data/app/assets/javascripts/binda/components/sortable.js +44 -0
- data/app/assets/javascripts/binda/dist/binda.bundle.js +336 -0
- data/app/assets/javascripts/binda/index.js +16 -0
- data/app/assets/stylesheets/binda/application.css +6 -0
- data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -0
- data/app/assets/stylesheets/binda/components/button.scss +7 -0
- data/app/assets/stylesheets/binda/components/form_body.scss +2 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +169 -0
- data/app/assets/stylesheets/binda/components/form_item_asset.scss +20 -0
- data/app/assets/stylesheets/binda/components/form_section.scss +40 -0
- data/app/assets/stylesheets/binda/components/login.scss +6 -0
- data/app/assets/stylesheets/binda/components/main_container.scss +0 -0
- data/app/assets/stylesheets/binda/components/main_content.scss +5 -0
- data/app/assets/stylesheets/binda/components/main_header.scss +25 -0
- data/app/assets/stylesheets/binda/components/main_table.scss +28 -0
- data/app/assets/stylesheets/binda/components/sidebar.scss +131 -0
- data/app/assets/stylesheets/binda/components/sortable.scss +98 -0
- data/app/assets/stylesheets/binda/index.scss +24 -0
- data/app/assets/stylesheets/binda/layout/components_index.scss +9 -0
- data/app/assets/stylesheets/binda/layout/dashboard.scss +7 -0
- data/app/assets/stylesheets/binda/layout/users_sign_in.scss +29 -0
- data/app/assets/stylesheets/binda/settings/common.scss +93 -0
- data/app/assets/stylesheets/binda/settings/fonts.scss +90 -0
- data/app/assets/stylesheets/binda/settings/variables.scss +83 -0
- data/app/assets/stylesheets/scaffolds.scss +89 -0
- data/app/controllers/binda/application_controller.rb +29 -0
- data/app/controllers/binda/assets_controller.rb +62 -0
- data/app/controllers/binda/bindings_controller.rb +62 -0
- data/app/controllers/binda/categories_controller.rb +60 -0
- data/app/controllers/binda/components_controller.rb +223 -0
- data/app/controllers/binda/dates_controller.rb +62 -0
- data/app/controllers/binda/field_groups_controller.rb +114 -0
- data/app/controllers/binda/field_settings_controller.rb +66 -0
- data/app/controllers/binda/galleries_controller.rb +62 -0
- data/app/controllers/binda/manage/users_controller.rb +97 -0
- data/app/controllers/binda/repeaters_controller.rb +67 -0
- data/app/controllers/binda/settings_controller.rb +75 -0
- data/app/controllers/binda/structures_controller.rb +89 -0
- data/app/controllers/binda/texts_controller.rb +62 -0
- data/app/controllers/binda/users/confirmations_controller.rb +33 -0
- data/app/controllers/binda/users/omniauth_callbacks_controller.rb +33 -0
- data/app/controllers/binda/users/passwords_controller.rb +37 -0
- data/app/controllers/binda/users/registrations_controller.rb +89 -0
- data/app/controllers/binda/users/sessions_controller.rb +30 -0
- data/app/controllers/binda/users/unlocks_controller.rb +33 -0
- data/app/helpers/binda/application_helper.rb +25 -0
- data/app/helpers/binda/assets_helper.rb +4 -0
- data/app/helpers/binda/bindings_helper.rb +4 -0
- data/app/helpers/binda/categories_helper.rb +10 -0
- data/app/helpers/binda/components_helper.rb +10 -0
- data/app/helpers/binda/dates_helper.rb +4 -0
- data/app/helpers/binda/field_groups_helper.rb +10 -0
- data/app/helpers/binda/field_settings_helper.rb +14 -0
- data/app/helpers/binda/galleries_helper.rb +4 -0
- data/app/helpers/binda/repeaters_helper.rb +4 -0
- data/app/helpers/binda/settings_helper.rb +13 -0
- data/app/helpers/binda/structures_helper.rb +4 -0
- data/app/helpers/binda/texts_helper.rb +4 -0
- data/app/jobs/binda/application_job.rb +4 -0
- data/app/mailers/binda/application_mailer.rb +6 -0
- data/app/models/binda/application_record.rb +5 -0
- data/app/models/binda/asset.rb +21 -0
- data/app/models/binda/binding.rb +24 -0
- data/app/models/binda/category.rb +31 -0
- data/app/models/binda/component.rb +186 -0
- data/app/models/binda/date.rb +9 -0
- data/app/models/binda/field_group.rb +40 -0
- data/app/models/binda/field_setting.rb +95 -0
- data/app/models/binda/gallery.rb +18 -0
- data/app/models/binda/repeater.rb +108 -0
- data/app/models/binda/setting.rb +42 -0
- data/app/models/binda/structure.rb +31 -0
- data/app/models/binda/text.rb +9 -0
- data/app/models/binda/user.rb +8 -0
- data/app/uploaders/binda/asset/image_uploader.rb +76 -0
- data/app/views/binda/assets/_form.html.erb +22 -0
- data/app/views/binda/assets/edit.html.erb +6 -0
- data/app/views/binda/assets/index.html.erb +29 -0
- data/app/views/binda/assets/new.html.erb +5 -0
- data/app/views/binda/assets/show.html.erb +19 -0
- data/app/views/binda/bindings/_form.html.erb +32 -0
- data/app/views/binda/bindings/edit.html.erb +6 -0
- data/app/views/binda/bindings/index.html.erb +31 -0
- data/app/views/binda/bindings/new.html.erb +5 -0
- data/app/views/binda/bindings/show.html.erb +19 -0
- data/app/views/binda/categories/_form.html.erb +58 -0
- data/app/views/binda/categories/edit.html.erb +8 -0
- data/app/views/binda/categories/index.html.erb +34 -0
- data/app/views/binda/categories/new.html.erb +8 -0
- data/app/views/binda/components/_form_body.html.erb +86 -0
- data/app/views/binda/components/_form_item_asset.html.erb +20 -0
- data/app/views/binda/components/_form_item_date.html.erb +16 -0
- data/app/views/binda/components/_form_item_gallery.html.erb +0 -0
- data/app/views/binda/components/_form_item_new_repeater.html.erb +33 -0
- data/app/views/binda/components/_form_item_repeater.html.erb +81 -0
- data/app/views/binda/components/_form_item_text.html.erb +28 -0
- data/app/views/binda/components/_form_section.html.erb +37 -0
- data/app/views/binda/components/_form_section_repeater.html.erb +31 -0
- data/app/views/binda/components/_form_sidebar.html.erb +34 -0
- data/app/views/binda/components/edit.html.erb +8 -0
- data/app/views/binda/components/index.html.erb +43 -0
- data/app/views/binda/components/new.html.erb +8 -0
- data/app/views/binda/dates/_form.html.erb +22 -0
- data/app/views/binda/dates/edit.html.erb +6 -0
- data/app/views/binda/dates/index.html.erb +27 -0
- data/app/views/binda/dates/new.html.erb +5 -0
- data/app/views/binda/dates/show.html.erb +9 -0
- data/app/views/binda/field_groups/_form_body.html.erb +71 -0
- data/app/views/binda/field_groups/_form_item.html.erb +62 -0
- data/app/views/binda/field_groups/_form_section.html.erb +37 -0
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +25 -0
- data/app/views/binda/field_groups/edit.html.erb +8 -0
- data/app/views/binda/field_groups/index.html.erb +34 -0
- data/app/views/binda/field_groups/new.html.erb +8 -0
- data/app/views/binda/field_settings/_form_body.html.erb +60 -0
- data/app/views/binda/field_settings/edit.html.erb +8 -0
- data/app/views/binda/field_settings/index.html.erb +31 -0
- data/app/views/binda/field_settings/new.html.erb +8 -0
- data/app/views/binda/galleries/_form.html.erb +27 -0
- data/app/views/binda/galleries/edit.html.erb +6 -0
- data/app/views/binda/galleries/index.html.erb +29 -0
- data/app/views/binda/galleries/new.html.erb +5 -0
- data/app/views/binda/galleries/show.html.erb +14 -0
- data/app/views/binda/manage/users/_admin_manage_user.json.jbuilder +2 -0
- data/app/views/binda/manage/users/_form_body.html.erb +58 -0
- data/app/views/binda/manage/users/edit.html.erb +8 -0
- data/app/views/binda/manage/users/index.html.erb +38 -0
- data/app/views/binda/manage/users/index.json.jbuilder +1 -0
- data/app/views/binda/manage/users/new.html.erb +8 -0
- data/app/views/binda/manage/users/show.json.jbuilder +1 -0
- data/app/views/binda/repeaters/_form.html.erb +27 -0
- data/app/views/binda/repeaters/edit.html.erb +6 -0
- data/app/views/binda/repeaters/index.html.erb +29 -0
- data/app/views/binda/repeaters/new.html.erb +5 -0
- data/app/views/binda/repeaters/show.html.erb +14 -0
- data/app/views/binda/settings/_dashboard_form.html.erb +51 -0
- data/app/views/binda/settings/_form.html.erb +52 -0
- data/app/views/binda/settings/dashboard.html.erb +9 -0
- data/app/views/binda/settings/edit.html.erb +8 -0
- data/app/views/binda/settings/index.html.erb +34 -0
- data/app/views/binda/settings/new.html.erb +8 -0
- data/app/views/binda/structures/_form_body.html.erb +56 -0
- data/app/views/binda/structures/_form_section.html.erb +64 -0
- data/app/views/binda/structures/add_child.html.erb +0 -0
- data/app/views/binda/structures/edit.html.erb +8 -0
- data/app/views/binda/structures/index.html.erb +34 -0
- data/app/views/binda/structures/new.html.erb +8 -0
- data/app/views/binda/texts/_form.html.erb +22 -0
- data/app/views/binda/texts/edit.html.erb +6 -0
- data/app/views/binda/texts/index.html.erb +27 -0
- data/app/views/binda/texts/new.html.erb +5 -0
- data/app/views/binda/texts/show.html.erb +9 -0
- data/app/views/layouts/binda/_flash.html.erb +26 -0
- data/app/views/layouts/binda/_header.html.erb +9 -0
- data/app/views/layouts/binda/_sidebar.html.erb +50 -0
- data/app/views/layouts/binda/application.html.erb +29 -0
- data/app/views/users/confirmations/new.html.erb +16 -0
- data/app/views/users/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/users/mailer/password_change.html.erb +3 -0
- data/app/views/users/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/users/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/users/passwords/edit.html.erb +31 -0
- data/app/views/users/passwords/new.html.erb +28 -0
- data/app/views/users/registrations/edit.html.erb +27 -0
- data/app/views/users/registrations/new.html.erb +17 -0
- data/app/views/users/sessions/new.html.erb +27 -0
- data/app/views/users/shared/_links.html.erb +25 -0
- data/app/views/users/unlocks/new.html.erb +16 -0
- data/config/initializers/assets.rb +3 -0
- data/config/initializers/devise.rb +278 -0
- data/config/initializers/devise_patch.rb +50 -0
- data/config/initializers/friendly_id.rb +88 -0
- data/config/initializers/simple_form.rb +165 -0
- data/config/initializers/simple_form_bootstrap.rb +149 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/locales/en.yml +37 -0
- data/config/locales/simple_form.en.yml +31 -0
- data/config/routes.rb +67 -0
- data/config/tinymce.yml +15 -0
- data/db/migrate/1_create_binda_tables.rb +172 -0
- data/lib/binda.rb +5 -0
- data/lib/binda/engine.rb +30 -0
- data/lib/binda/version.rb +3 -0
- data/lib/generators/binda/install/USAGE +9 -0
- data/lib/generators/binda/install/install_generator.rb +107 -0
- data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +32 -0
- data/lib/generators/binda/install/templates/config/initializers/devise.rb +280 -0
- data/lib/generators/binda/setup/USAGE +8 -0
- data/lib/generators/binda/setup/setup_generator.rb +43 -0
- data/lib/tasks/binda.rake +25 -0
- data/lib/templates/erb/scaffold/_form.html.erb +13 -0
- metadata +637 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: eef4906f896329bcbd079ef899e43b47b0e774b7
|
4
|
+
data.tar.gz: d0c98e7a97e93eb68606b2ffd215abc1ffb2b194
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 23217a54d417beb3ce7ffd7de899af77b11dd3a6e7d1fdf6e1227e69c42c5b16835deea6b0c7d06f6e3461b92ff03d316c44dc922aa6240ff4385a40c5a44086
|
7
|
+
data.tar.gz: da1c82664ae3f8fc7a880d98f364e26ab28d8b3089152e1b8f1b6ae53f212e71f88bde11b8d10d3d156e356f5586e3164dd7ddacbe109146a93aa4a670a04424
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Alessandro Barbieri
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# Binda
|
2
|
+
A lightweight CMS for Ruby on Rails 5, inspired by [Spina](http://www.spinacms.com).
|
3
|
+
|
4
|
+
[![Code Climate](https://codeclimate.com/github/lacolonia/binda/badges/gpa.svg)](https://codeclimate.com/github/lacolonia/binda)
|
5
|
+
[![Issue Count](https://codeclimate.com/github/lacolonia/binda/badges/issue_count.svg)](https://codeclimate.com/github/lacolonia/binda)
|
6
|
+
[![Test Coverage](https://codeclimate.com/github/lacolonia/binda/badges/coverage.svg)](https://codeclimate.com/github/lacolonia/binda/coverage)
|
7
|
+
[![Slack](https://binda.herokuapp.com/badge.svg)](https://binda.herokuapp.com)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'binda', github: 'lacolonia/binda'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
```bash
|
18
|
+
$ bundle
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
```bash
|
23
|
+
$ gem install binda
|
24
|
+
$ rails generate binda:install
|
25
|
+
```
|
26
|
+
|
27
|
+
## Requirements
|
28
|
+
Binda has some dependencies which you might need to update if you have a very specific environment.
|
29
|
+
|
30
|
+
If you are not going to use Rails default ORM please check [Carrierwave documentation](https://github.com/carrierwaveuploader/carrierwave#datamapper-mongoid-sequel) and [Devise documentation](https://github.com/plataformatec/devise#other-orms).
|
31
|
+
|
32
|
+
In order to use Carrierwave to process images you need to run MiniMagik. Please refer to [Carrierwave documentation](https://github.com/carrierwaveuploader/carrierwave#using-minimagick) to find more information.
|
33
|
+
|
34
|
+
## Bug reporting
|
35
|
+
Please refer to this [guide](http://yourbugreportneedsmore.info).
|
36
|
+
|
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
|
+
|
57
|
+
## License
|
58
|
+
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
|
+
|
60
|
+
## Who is Binda?
|
61
|
+
Is [this guy here](https://en.wikipedia.org/wiki/Alfredo_Binda).
|
62
|
+
|
63
|
+
![Alfredo Binda 1927](./Alfredo_Binda_1927.jpg)
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Binda'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
require 'bundler/gem_tasks'
|
26
|
+
|
27
|
+
require 'rake/testtask'
|
28
|
+
|
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
|
+
|
36
|
+
|
37
|
+
task default: :test
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
|
14
|
+
//= require jquery
|
15
|
+
//= require jquery_ujs
|
16
|
+
//= require jquery-ui/widgets/sortable
|
17
|
+
//= require tinymce-jquery
|
18
|
+
//= require binda/dist/binda.bundle.js
|
@@ -0,0 +1,54 @@
|
|
1
|
+
///- - - - - - - - - - - - - - - - - - - -
|
2
|
+
/// FORM ITEM
|
3
|
+
///- - - - - - - - - - - - - - - - - - - -
|
4
|
+
|
5
|
+
class FormItem {
|
6
|
+
|
7
|
+
constructor()
|
8
|
+
{
|
9
|
+
this.target = '.form-item'
|
10
|
+
}
|
11
|
+
|
12
|
+
isSet()
|
13
|
+
{
|
14
|
+
if ( $( this.target ).length > 0 ) { return true }
|
15
|
+
else { return false }
|
16
|
+
}
|
17
|
+
|
18
|
+
setEvents()
|
19
|
+
{
|
20
|
+
$(document).on('click', this.target + '--add-new', addNewItem )
|
21
|
+
|
22
|
+
$(document).on('click', '.form-item--remove-item-with-js', function( event )
|
23
|
+
{
|
24
|
+
// Stop default behaviour
|
25
|
+
event.preventDefault()
|
26
|
+
$( this ).parent( this.target ).remove()
|
27
|
+
})
|
28
|
+
|
29
|
+
$(document).on('click', '.form-item--open-button, .form-item--close-button', function()
|
30
|
+
{
|
31
|
+
$( this ).parent('.form-item').children('.form-item--editor').toggleClass('form-item--editor-close')
|
32
|
+
$( this ).parent('.form-item').children('.form-item--open-button, .form-item--close-button').toggle()
|
33
|
+
})
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
export let _FormItem = new FormItem()
|
38
|
+
|
39
|
+
|
40
|
+
///- - - - - - - - - - - - - - - - - - - -
|
41
|
+
/// COMPONENT HELPER FUNCTIONS
|
42
|
+
///- - - - - - - - - - - - - - - - - - - -
|
43
|
+
|
44
|
+
function addNewItem( event )
|
45
|
+
{
|
46
|
+
// Stop default behaviour
|
47
|
+
event.preventDefault()
|
48
|
+
// Get the child to clone
|
49
|
+
let id = $( event.target ).data( 'new-child-id' )
|
50
|
+
let $newChild = $( '#' + id )
|
51
|
+
// Clone child and remove id and styles from cloned child
|
52
|
+
$newChild.clone().insertAfter( $newChild )
|
53
|
+
$newChild.removeClass( 'form-item--new' ).removeAttr( 'id' )
|
54
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
///- - - - - - - - - - - - - - - - - - - -
|
2
|
+
/// FORM ITEM ASSET
|
3
|
+
///- - - - - - - - - - - - - - - - - - - -
|
4
|
+
|
5
|
+
class FormItemAsset
|
6
|
+
{
|
7
|
+
constructor()
|
8
|
+
{
|
9
|
+
this.target = '.form-item--asset'
|
10
|
+
}
|
11
|
+
|
12
|
+
isSet()
|
13
|
+
{
|
14
|
+
if ( $( this.target ).length > 0 ) { return true }
|
15
|
+
else { return false }
|
16
|
+
}
|
17
|
+
|
18
|
+
setEvents()
|
19
|
+
{
|
20
|
+
// here code to setup assets via ajax
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
export var _FormItemAsset = new FormItemAsset()
|
@@ -0,0 +1,66 @@
|
|
1
|
+
///- - - - - - - - - - - - - - - - - - - -
|
2
|
+
/// FORM ITEM
|
3
|
+
///- - - - - - - - - - - - - - - - - - - -
|
4
|
+
|
5
|
+
class FormItemRepeater {
|
6
|
+
|
7
|
+
constructor()
|
8
|
+
{
|
9
|
+
this.target = '.form-item--repeater-section'
|
10
|
+
}
|
11
|
+
|
12
|
+
isSet()
|
13
|
+
{
|
14
|
+
if ( $( this.target ).length > 0 ) { return true }
|
15
|
+
else { return false }
|
16
|
+
}
|
17
|
+
|
18
|
+
setEvents()
|
19
|
+
{
|
20
|
+
$(document).on('click', this.target + '--add-new', addNewItem )
|
21
|
+
$(document).on('click', '.form-item--remove-item-with-js', function( event )
|
22
|
+
{
|
23
|
+
// Stop default behaviour
|
24
|
+
event.preventDefault()
|
25
|
+
$( this ).parent( this.target ).remove()
|
26
|
+
})
|
27
|
+
$(document).on('click', '.form-item--delete-repeater-item', function( event )
|
28
|
+
{
|
29
|
+
// Stop default behaviour
|
30
|
+
event.preventDefault()
|
31
|
+
|
32
|
+
$.ajax({
|
33
|
+
url: $( this ).attr('href'),
|
34
|
+
data: { id: $( this ).data('id'), isAjax: true },
|
35
|
+
method: "DELETE"
|
36
|
+
}).done( ()=>{
|
37
|
+
$( this ).parent('li').remove()
|
38
|
+
})
|
39
|
+
})
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
export let _FormItemRepeater = new FormItemRepeater()
|
44
|
+
|
45
|
+
|
46
|
+
///- - - - - - - - - - - - - - - - - - - -
|
47
|
+
/// COMPONENT HELPER FUNCTIONS
|
48
|
+
///- - - - - - - - - - - - - - - - - - - -
|
49
|
+
|
50
|
+
function addNewItem( event )
|
51
|
+
{
|
52
|
+
// Stop default behaviour
|
53
|
+
event.preventDefault()
|
54
|
+
// Get the child to clone
|
55
|
+
let id = $( event.target ).data( 'id' )
|
56
|
+
let $list = $('#form-item--repeater-setting-' + id )
|
57
|
+
let url = $( event.target ).data( 'url' )
|
58
|
+
$.post( url, { repeater_setting_id: id }, function( data )
|
59
|
+
{
|
60
|
+
let parts = data.split('<!-- SPLIT -->')
|
61
|
+
let newRepeater = parts[1]
|
62
|
+
$list.append( newRepeater )
|
63
|
+
var editor_id = $list.find('textarea').last('textarea').attr('id')
|
64
|
+
tinyMCE.EditorManager.execCommand('mceAddEditor',true, editor_id);
|
65
|
+
})
|
66
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
export default function()
|
2
|
+
{
|
3
|
+
if ( $('.sortable').length > 0 )
|
4
|
+
{
|
5
|
+
// Initialize sortable item
|
6
|
+
$('.sortable')
|
7
|
+
.sortable({
|
8
|
+
placeholder: "ui-state-highlight",
|
9
|
+
update: function () {
|
10
|
+
$.post(
|
11
|
+
$(this).data('update-url'),
|
12
|
+
$(this).sortable('serialize')
|
13
|
+
)
|
14
|
+
}
|
15
|
+
})
|
16
|
+
.disableSelection()
|
17
|
+
|
18
|
+
// Check if sortable item needs handles
|
19
|
+
$('.sortable').each( function()
|
20
|
+
{
|
21
|
+
if ( $(this).find('.sortable--handle').length > 0 )
|
22
|
+
{ $(this).sortable('option', 'handle', '.sortable--handle') }
|
23
|
+
else
|
24
|
+
{ $(this).addClass('sortable--no-handle') }
|
25
|
+
})
|
26
|
+
|
27
|
+
$('.sortable--disabled').sortable('disable')
|
28
|
+
}
|
29
|
+
|
30
|
+
$(document).on( 'click', '.sortable--toggle', function( event )
|
31
|
+
{
|
32
|
+
event.preventDefault()
|
33
|
+
let id = '#' + $( this ).data( 'repeater-id' )
|
34
|
+
|
35
|
+
if ( $( id ).hasClass('sortable--disabled') )
|
36
|
+
{ $( id ).sortable('enable') }
|
37
|
+
else
|
38
|
+
{ $( id ).sortable('disable') }
|
39
|
+
|
40
|
+
$( id ).toggleClass('sortable--disabled')
|
41
|
+
$( id ).toggleClass('sortable--enabled')
|
42
|
+
$( this ).children('.sortable--toggle-text').toggle()
|
43
|
+
})
|
44
|
+
}
|
@@ -0,0 +1,336 @@
|
|
1
|
+
/******/ (function(modules) { // webpackBootstrap
|
2
|
+
/******/ // The module cache
|
3
|
+
/******/ var installedModules = {};
|
4
|
+
/******/
|
5
|
+
/******/ // The require function
|
6
|
+
/******/ function __webpack_require__(moduleId) {
|
7
|
+
/******/
|
8
|
+
/******/ // Check if module is in cache
|
9
|
+
/******/ if(installedModules[moduleId])
|
10
|
+
/******/ return installedModules[moduleId].exports;
|
11
|
+
/******/
|
12
|
+
/******/ // Create a new module (and put it into the cache)
|
13
|
+
/******/ var module = installedModules[moduleId] = {
|
14
|
+
/******/ i: moduleId,
|
15
|
+
/******/ l: false,
|
16
|
+
/******/ exports: {}
|
17
|
+
/******/ };
|
18
|
+
/******/
|
19
|
+
/******/ // Execute the module function
|
20
|
+
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21
|
+
/******/
|
22
|
+
/******/ // Flag the module as loaded
|
23
|
+
/******/ module.l = true;
|
24
|
+
/******/
|
25
|
+
/******/ // Return the exports of the module
|
26
|
+
/******/ return module.exports;
|
27
|
+
/******/ }
|
28
|
+
/******/
|
29
|
+
/******/
|
30
|
+
/******/ // expose the modules object (__webpack_modules__)
|
31
|
+
/******/ __webpack_require__.m = modules;
|
32
|
+
/******/
|
33
|
+
/******/ // expose the module cache
|
34
|
+
/******/ __webpack_require__.c = installedModules;
|
35
|
+
/******/
|
36
|
+
/******/ // identity function for calling harmony imports with the correct context
|
37
|
+
/******/ __webpack_require__.i = function(value) { return value; };
|
38
|
+
/******/
|
39
|
+
/******/ // define getter function for harmony exports
|
40
|
+
/******/ __webpack_require__.d = function(exports, name, getter) {
|
41
|
+
/******/ if(!__webpack_require__.o(exports, name)) {
|
42
|
+
/******/ Object.defineProperty(exports, name, {
|
43
|
+
/******/ configurable: false,
|
44
|
+
/******/ enumerable: true,
|
45
|
+
/******/ get: getter
|
46
|
+
/******/ });
|
47
|
+
/******/ }
|
48
|
+
/******/ };
|
49
|
+
/******/
|
50
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
51
|
+
/******/ __webpack_require__.n = function(module) {
|
52
|
+
/******/ var getter = module && module.__esModule ?
|
53
|
+
/******/ function getDefault() { return module['default']; } :
|
54
|
+
/******/ function getModuleExports() { return module; };
|
55
|
+
/******/ __webpack_require__.d(getter, 'a', getter);
|
56
|
+
/******/ return getter;
|
57
|
+
/******/ };
|
58
|
+
/******/
|
59
|
+
/******/ // Object.prototype.hasOwnProperty.call
|
60
|
+
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
61
|
+
/******/
|
62
|
+
/******/ // __webpack_public_path__
|
63
|
+
/******/ __webpack_require__.p = "";
|
64
|
+
/******/
|
65
|
+
/******/ // Load entry module and return exports
|
66
|
+
/******/ return __webpack_require__(__webpack_require__.s = 4);
|
67
|
+
/******/ })
|
68
|
+
/************************************************************************/
|
69
|
+
/******/ ([
|
70
|
+
/* 0 */
|
71
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
72
|
+
|
73
|
+
"use strict";
|
74
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
|
75
|
+
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
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
78
|
+
|
79
|
+
///- - - - - - - - - - - - - - - - - - - -
|
80
|
+
/// FORM ITEM
|
81
|
+
///- - - - - - - - - - - - - - - - - - - -
|
82
|
+
|
83
|
+
var FormItem = function () {
|
84
|
+
function FormItem() {
|
85
|
+
_classCallCheck(this, FormItem);
|
86
|
+
|
87
|
+
this.target = '.form-item';
|
88
|
+
}
|
89
|
+
|
90
|
+
_createClass(FormItem, [{
|
91
|
+
key: 'isSet',
|
92
|
+
value: function isSet() {
|
93
|
+
if ($(this.target).length > 0) {
|
94
|
+
return true;
|
95
|
+
} else {
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}, {
|
100
|
+
key: 'setEvents',
|
101
|
+
value: function setEvents() {
|
102
|
+
$(document).on('click', this.target + '--add-new', addNewItem);
|
103
|
+
|
104
|
+
$(document).on('click', '.form-item--remove-item-with-js', function (event) {
|
105
|
+
// Stop default behaviour
|
106
|
+
event.preventDefault();
|
107
|
+
$(this).parent(this.target).remove();
|
108
|
+
});
|
109
|
+
|
110
|
+
$(document).on('click', '.form-item--open-button, .form-item--close-button', function () {
|
111
|
+
$(this).parent('.form-item').children('.form-item--editor').toggleClass('form-item--editor-close');
|
112
|
+
$(this).parent('.form-item').children('.form-item--open-button, .form-item--close-button').toggle();
|
113
|
+
});
|
114
|
+
}
|
115
|
+
}]);
|
116
|
+
|
117
|
+
return FormItem;
|
118
|
+
}();
|
119
|
+
|
120
|
+
var _FormItem = new FormItem();
|
121
|
+
|
122
|
+
///- - - - - - - - - - - - - - - - - - - -
|
123
|
+
/// COMPONENT HELPER FUNCTIONS
|
124
|
+
///- - - - - - - - - - - - - - - - - - - -
|
125
|
+
|
126
|
+
function addNewItem(event) {
|
127
|
+
// Stop default behaviour
|
128
|
+
event.preventDefault();
|
129
|
+
// Get the child to clone
|
130
|
+
var id = $(event.target).data('new-child-id');
|
131
|
+
var $newChild = $('#' + id);
|
132
|
+
// Clone child and remove id and styles from cloned child
|
133
|
+
$newChild.clone().insertAfter($newChild);
|
134
|
+
$newChild.removeClass('form-item--new').removeAttr('id');
|
135
|
+
}
|
136
|
+
|
137
|
+
/***/ }),
|
138
|
+
/* 1 */
|
139
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
140
|
+
|
141
|
+
"use strict";
|
142
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemAsset; });
|
143
|
+
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; }; }();
|
144
|
+
|
145
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
146
|
+
|
147
|
+
///- - - - - - - - - - - - - - - - - - - -
|
148
|
+
/// FORM ITEM ASSET
|
149
|
+
///- - - - - - - - - - - - - - - - - - - -
|
150
|
+
|
151
|
+
var FormItemAsset = function () {
|
152
|
+
function FormItemAsset() {
|
153
|
+
_classCallCheck(this, FormItemAsset);
|
154
|
+
|
155
|
+
this.target = '.form-item--asset';
|
156
|
+
}
|
157
|
+
|
158
|
+
_createClass(FormItemAsset, [{
|
159
|
+
key: 'isSet',
|
160
|
+
value: function isSet() {
|
161
|
+
if ($(this.target).length > 0) {
|
162
|
+
return true;
|
163
|
+
} else {
|
164
|
+
return false;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
}, {
|
168
|
+
key: 'setEvents',
|
169
|
+
value: function setEvents() {
|
170
|
+
// here code to setup assets via ajax
|
171
|
+
}
|
172
|
+
}]);
|
173
|
+
|
174
|
+
return FormItemAsset;
|
175
|
+
}();
|
176
|
+
|
177
|
+
var _FormItemAsset = new FormItemAsset();
|
178
|
+
|
179
|
+
/***/ }),
|
180
|
+
/* 2 */
|
181
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
182
|
+
|
183
|
+
"use strict";
|
184
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
|
185
|
+
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
|
+
|
187
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
188
|
+
|
189
|
+
///- - - - - - - - - - - - - - - - - - - -
|
190
|
+
/// FORM ITEM
|
191
|
+
///- - - - - - - - - - - - - - - - - - - -
|
192
|
+
|
193
|
+
var FormItemRepeater = function () {
|
194
|
+
function FormItemRepeater() {
|
195
|
+
_classCallCheck(this, FormItemRepeater);
|
196
|
+
|
197
|
+
this.target = '.form-item--repeater-section';
|
198
|
+
}
|
199
|
+
|
200
|
+
_createClass(FormItemRepeater, [{
|
201
|
+
key: 'isSet',
|
202
|
+
value: function isSet() {
|
203
|
+
if ($(this.target).length > 0) {
|
204
|
+
return true;
|
205
|
+
} else {
|
206
|
+
return false;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}, {
|
210
|
+
key: 'setEvents',
|
211
|
+
value: function setEvents() {
|
212
|
+
$(document).on('click', this.target + '--add-new', addNewItem);
|
213
|
+
$(document).on('click', '.form-item--remove-item-with-js', function (event) {
|
214
|
+
// Stop default behaviour
|
215
|
+
event.preventDefault();
|
216
|
+
$(this).parent(this.target).remove();
|
217
|
+
});
|
218
|
+
$(document).on('click', '.form-item--delete-repeater-item', function (event) {
|
219
|
+
var _this = this;
|
220
|
+
|
221
|
+
// Stop default behaviour
|
222
|
+
event.preventDefault();
|
223
|
+
|
224
|
+
$.ajax({
|
225
|
+
url: $(this).attr('href'),
|
226
|
+
data: { id: $(this).data('id'), isAjax: true },
|
227
|
+
method: "DELETE"
|
228
|
+
}).done(function () {
|
229
|
+
$(_this).parent('li').remove();
|
230
|
+
});
|
231
|
+
});
|
232
|
+
}
|
233
|
+
}]);
|
234
|
+
|
235
|
+
return FormItemRepeater;
|
236
|
+
}();
|
237
|
+
|
238
|
+
var _FormItemRepeater = new FormItemRepeater();
|
239
|
+
|
240
|
+
///- - - - - - - - - - - - - - - - - - - -
|
241
|
+
/// COMPONENT HELPER FUNCTIONS
|
242
|
+
///- - - - - - - - - - - - - - - - - - - -
|
243
|
+
|
244
|
+
function addNewItem(event) {
|
245
|
+
// Stop default behaviour
|
246
|
+
event.preventDefault();
|
247
|
+
// Get the child to clone
|
248
|
+
var id = $(event.target).data('id');
|
249
|
+
var $list = $('#form-item--repeater-setting-' + id);
|
250
|
+
var url = $(event.target).data('url');
|
251
|
+
$.post(url, { repeater_setting_id: id }, function (data) {
|
252
|
+
var parts = data.split('<!-- SPLIT -->');
|
253
|
+
var newRepeater = parts[1];
|
254
|
+
$list.append(newRepeater);
|
255
|
+
var editor_id = $list.find('textarea').last('textarea').attr('id');
|
256
|
+
tinyMCE.EditorManager.execCommand('mceAddEditor', true, editor_id);
|
257
|
+
});
|
258
|
+
}
|
259
|
+
|
260
|
+
/***/ }),
|
261
|
+
/* 3 */
|
262
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
263
|
+
|
264
|
+
"use strict";
|
265
|
+
/* harmony default export */ __webpack_exports__["a"] = function () {
|
266
|
+
if ($('.sortable').length > 0) {
|
267
|
+
// Initialize sortable item
|
268
|
+
$('.sortable').sortable({
|
269
|
+
placeholder: "ui-state-highlight",
|
270
|
+
update: function update() {
|
271
|
+
$.post($(this).data('update-url'), $(this).sortable('serialize'));
|
272
|
+
}
|
273
|
+
}).disableSelection();
|
274
|
+
|
275
|
+
// Check if sortable item needs handles
|
276
|
+
$('.sortable').each(function () {
|
277
|
+
if ($(this).find('.sortable--handle').length > 0) {
|
278
|
+
$(this).sortable('option', 'handle', '.sortable--handle');
|
279
|
+
} else {
|
280
|
+
$(this).addClass('sortable--no-handle');
|
281
|
+
}
|
282
|
+
});
|
283
|
+
|
284
|
+
$('.sortable--disabled').sortable('disable');
|
285
|
+
}
|
286
|
+
|
287
|
+
$(document).on('click', '.sortable--toggle', function (event) {
|
288
|
+
event.preventDefault();
|
289
|
+
var id = '#' + $(this).data('repeater-id');
|
290
|
+
|
291
|
+
if ($(id).hasClass('sortable--disabled')) {
|
292
|
+
$(id).sortable('enable');
|
293
|
+
} else {
|
294
|
+
$(id).sortable('disable');
|
295
|
+
}
|
296
|
+
|
297
|
+
$(id).toggleClass('sortable--disabled');
|
298
|
+
$(id).toggleClass('sortable--enabled');
|
299
|
+
$(this).children('.sortable--toggle-text').toggle();
|
300
|
+
});
|
301
|
+
};
|
302
|
+
|
303
|
+
/***/ }),
|
304
|
+
/* 4 */
|
305
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
306
|
+
|
307
|
+
"use strict";
|
308
|
+
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
309
|
+
/* 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__(2);
|
311
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__ = __webpack_require__(1);
|
312
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_sortable__ = __webpack_require__(3);
|
313
|
+
///- - - - - - - - - - - - - - - - - - - -
|
314
|
+
/// INDEX OF BINDA'S SCRIPTS
|
315
|
+
///- - - - - - - - - - - - - - - - - - - -
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
$(document).ready(function () {
|
323
|
+
if (__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].isSet()) {
|
324
|
+
__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].setEvents();
|
325
|
+
}
|
326
|
+
if (__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].isSet()) {
|
327
|
+
__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].setEvents();
|
328
|
+
}
|
329
|
+
if (__WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__["a" /* _FormItemAsset */].isSet()) {
|
330
|
+
__WEBPACK_IMPORTED_MODULE_2__components_form_item_asset__["a" /* _FormItemAsset */].setEvents();
|
331
|
+
}
|
332
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_3__components_sortable__["a" /* default */])();
|
333
|
+
});
|
334
|
+
|
335
|
+
/***/ })
|
336
|
+
/******/ ]);
|