binda 0.0.7 → 0.1.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 +850 -18
- data/Rakefile +1 -13
- data/app/assets/javascripts/binda/application.js +23 -0
- data/app/assets/javascripts/binda/components/bootstrap.js +9 -0
- data/app/assets/javascripts/binda/components/field_group_editor.js +18 -0
- data/app/assets/javascripts/binda/components/fileupload.js +182 -0
- data/app/assets/javascripts/binda/components/form_item.js +91 -23
- data/app/assets/javascripts/binda/components/form_item_choice.js +15 -8
- data/app/assets/javascripts/binda/components/form_item_editor.js +6 -6
- data/app/assets/javascripts/binda/components/form_item_image.js +23 -0
- data/app/assets/javascripts/binda/components/form_item_repeater.js +70 -23
- data/app/assets/javascripts/binda/components/login-shader.js +193 -0
- data/app/assets/javascripts/binda/components/login_form.js +116 -0
- data/app/assets/javascripts/binda/components/radio-toggle.js +18 -0
- data/app/assets/javascripts/binda/components/select2.js +22 -0
- data/app/assets/javascripts/binda/components/sortable.js +53 -8
- data/app/assets/javascripts/binda/dist/binda.bundle.js +914 -107
- data/app/assets/javascripts/binda/index.js +26 -3
- data/app/assets/stylesheets/binda/application.scss +6 -0
- data/app/assets/stylesheets/binda/components/assets_manager.scss +46 -36
- data/app/assets/stylesheets/binda/components/b-btn.scss +114 -0
- data/app/assets/stylesheets/binda/components/button.scss +4 -1
- data/app/assets/stylesheets/binda/components/fileupload.scss +134 -0
- data/app/assets/stylesheets/binda/components/form_item.scss +233 -168
- data/app/assets/stylesheets/binda/components/form_item_image.scss +0 -0
- data/app/assets/stylesheets/binda/components/form_item_video.scss +25 -0
- data/app/assets/stylesheets/binda/components/main_container.scss +3 -0
- data/app/assets/stylesheets/binda/components/main_content.scss +1 -2
- data/app/assets/stylesheets/binda/components/main_header.scss +21 -20
- data/app/assets/stylesheets/binda/components/main_sidebar.scss +121 -0
- data/app/assets/stylesheets/binda/components/main_table.scss +84 -28
- data/app/assets/stylesheets/binda/components/popup_warning.scss +71 -0
- data/app/assets/stylesheets/binda/components/select2.scss +126 -0
- data/app/assets/stylesheets/binda/components/sortable.scss +83 -56
- data/app/assets/stylesheets/binda/components/standard-form.scss +228 -0
- data/app/assets/stylesheets/binda/components/texts.scss +6 -0
- data/app/assets/stylesheets/binda/controllers/components_index.scss +3 -0
- data/app/assets/stylesheets/binda/controllers/users_sessions_new.scss +309 -0
- data/app/assets/stylesheets/binda/index.scss +16 -8
- data/app/assets/stylesheets/binda/settings/bootstrap_overrides.scss +0 -0
- data/app/assets/stylesheets/binda/settings/buttons.scss +36 -0
- data/app/assets/stylesheets/binda/settings/common.scss +36 -79
- data/app/assets/stylesheets/binda/settings/fonts.scss +88 -31
- data/app/assets/stylesheets/binda/settings/tiny_mce_overrides.scss +82 -0
- data/app/assets/stylesheets/binda/settings/variables.scss +36 -31
- data/app/controllers/binda/application_controller.rb +0 -2
- data/app/controllers/binda/assets_controller.rb +1 -1
- data/app/controllers/binda/boards_controller.rb +15 -4
- data/app/controllers/binda/components_controller.rb +30 -15
- data/app/controllers/binda/field_groups_controller.rb +19 -4
- data/app/controllers/binda/images_controller.rb +68 -0
- data/app/controllers/binda/repeaters_controller.rb +3 -12
- data/app/controllers/binda/structures_controller.rb +8 -1
- data/app/controllers/binda/videos_controller.rb +68 -0
- data/app/controllers/concerns/binda/fieldable_helpers.rb +113 -28
- data/app/controllers/concerns/binda/maintenance_helpers.rb +34 -0
- data/app/helpers/binda/components_helper.rb +26 -2
- data/app/helpers/binda/field_groups_helper.rb +16 -0
- data/app/helpers/binda/structures_helper.rb +6 -0
- data/app/models/binda/asset.rb +0 -4
- data/app/models/binda/b.rb +5 -0
- data/app/models/binda/board.rb +1 -18
- data/app/models/binda/choice.rb +48 -12
- data/app/models/binda/component.rb +20 -0
- data/app/models/binda/field_group.rb +2 -2
- data/app/models/binda/field_setting.rb +61 -28
- data/app/models/binda/gallery.rb +0 -2
- data/app/models/binda/image.rb +7 -0
- data/app/models/binda/relation.rb +79 -0
- data/app/models/binda/relation_link.rb +11 -0
- data/app/models/binda/repeater.rb +1 -1
- data/app/models/binda/selection.rb +0 -9
- data/app/models/binda/structure.rb +41 -39
- data/app/models/binda/video.rb +7 -0
- data/app/models/concerns/binda/default_helpers.rb +186 -0
- data/app/models/concerns/binda/fieldable_associations.rb +276 -30
- data/app/uploaders/binda/{asset → image}/image_uploader.rb +27 -9
- data/app/uploaders/binda/video/video_uploader.rb +51 -0
- data/app/views/binda/boards/edit.html.erb +6 -1
- data/app/views/binda/categories/_form.html.erb +41 -40
- data/app/views/binda/categories/edit.html.erb +1 -1
- data/app/views/binda/categories/index.html.erb +16 -13
- data/app/views/binda/components/edit.html.erb +6 -3
- data/app/views/binda/components/index.html.erb +69 -28
- data/app/views/binda/components/new.html.erb +1 -1
- data/app/views/binda/components/sort_index.html.erb +46 -0
- data/app/views/binda/field_groups/_form_body.html.erb +65 -44
- data/app/views/binda/field_groups/_form_item.html.erb +66 -23
- data/app/views/binda/field_groups/_form_item_choice.erb +34 -15
- data/app/views/binda/field_groups/_form_section.html.erb +6 -10
- data/app/views/binda/field_groups/_form_section_repeater.html.erb +3 -3
- data/app/views/binda/field_groups/edit.html.erb +1 -1
- data/app/views/binda/field_settings/_form_body.html.erb +5 -5
- data/app/views/binda/field_settings/edit.html.erb +1 -1
- data/app/views/binda/fieldable/_form_body.html.erb +93 -79
- data/app/views/binda/fieldable/_form_item_date.html.erb +14 -14
- data/app/views/binda/fieldable/_form_item_image.html.erb +35 -0
- data/app/views/binda/fieldable/_form_item_new_repeater.html.erb +12 -5
- data/app/views/binda/fieldable/_form_item_relation.html.erb +44 -0
- data/app/views/binda/fieldable/_form_item_repeater.html.erb +80 -58
- data/app/views/binda/fieldable/_form_item_selections.html.erb +109 -87
- data/app/views/binda/fieldable/_form_item_string.html.erb +19 -17
- data/app/views/binda/fieldable/_form_item_text.html.erb +19 -16
- data/app/views/binda/fieldable/_form_item_video.html.erb +32 -0
- data/app/views/binda/fieldable/_form_section.html.erb +27 -5
- data/app/views/binda/fieldable/_form_section_repeater.html.erb +30 -10
- data/app/views/binda/fieldable/_form_sidebar.html.erb +44 -20
- data/app/views/binda/manage/users/_form_body.html.erb +42 -37
- data/app/views/binda/manage/users/edit.html.erb +1 -1
- data/app/views/binda/manage/users/index.html.erb +21 -21
- data/app/views/binda/structures/_form_body.html.erb +54 -60
- data/app/views/binda/structures/_form_section.html.erb +32 -18
- data/app/views/binda/structures/_form_sidebar.html.erb +35 -0
- data/app/views/binda/structures/edit.html.erb +2 -2
- data/app/views/binda/structures/index.html.erb +21 -16
- data/app/views/binda/structures/sort_index.html.erb +36 -0
- data/app/views/{users → binda/users}/confirmations/new.html.erb +1 -1
- data/app/views/{users → binda/users}/mailer/confirmation_instructions.html.erb +0 -0
- data/app/views/{users → binda/users}/mailer/password_change.html.erb +0 -0
- data/app/views/{users → binda/users}/mailer/reset_password_instructions.html.erb +0 -0
- data/app/views/{users → binda/users}/mailer/unlock_instructions.html.erb +0 -0
- data/app/views/{users → binda/users}/passwords/edit.html.erb +1 -1
- data/app/views/{users → binda/users}/passwords/new.html.erb +1 -1
- data/app/views/{users → binda/users}/registrations/edit.html.erb +0 -0
- data/app/views/{users → binda/users}/registrations/new.html.erb +1 -1
- data/app/views/binda/users/sessions/_background.html.erb +139 -0
- data/app/views/binda/users/sessions/new.html.erb +62 -0
- data/app/views/{users → binda/users}/shared/_links.html.erb +3 -3
- data/app/views/{users → binda/users}/unlocks/new.html.erb +1 -1
- data/app/views/kaminari/_first_page.html.erb +11 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +11 -0
- data/app/views/kaminari/_next_page.html.erb +11 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +19 -0
- data/app/views/kaminari/_prev_page.html.erb +11 -0
- data/app/views/layouts/binda/_flash.html.erb +1 -1
- data/app/views/layouts/binda/_header.html.erb +2 -6
- data/app/views/layouts/binda/_sidebar.html.erb +11 -4
- data/app/views/layouts/binda/application.html.erb +15 -7
- data/config/autoprefixer.yml +5 -0
- data/config/database.yml.travis +3 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/autoprefixer.yml +5 -0
- data/config/initializers/carrierwave.rb +32 -0
- data/config/initializers/devise.rb +14 -10
- data/config/initializers/devise_patch.rb +8 -8
- data/config/initializers/simple_form.rb +4 -0
- data/config/initializers/simple_form__fileupload.rb +121 -0
- data/config/initializers/{simple_form_bootstrap.rb → simple_form_custom.rb} +79 -50
- data/config/locales/en.yml +61 -3
- data/config/locales/it.yml +51 -0
- data/config/locales/simple_form.en.yml +3 -3
- data/config/routes.rb +41 -24
- data/db/migrate/1_create_binda_tables.rb +18 -7
- data/db/migrate/20171214140451_add_preview_mode.rb +5 -0
- data/lib/binda.rb +1 -1
- data/lib/binda/engine.rb +19 -23
- data/lib/binda/version.rb +2 -2
- data/lib/generators/binda/install/install_generator.rb +59 -54
- data/lib/generators/binda/install/templates/config/initializers/carrierwave.rb +11 -2
- data/lib/generators/binda/maintenance/USAGE +8 -0
- data/lib/generators/binda/maintenance/maintenance_generator.rb +50 -0
- data/lib/generators/binda/maintenance/templates/app/assets/javascripts/maintenance.js +0 -0
- data/lib/generators/binda/maintenance/templates/app/assets/stylesheets/maintenance.scss +0 -0
- data/lib/generators/binda/maintenance/templates/app/views/layouts/maintenance.html.erb +16 -0
- data/lib/generators/binda/maintenance/templates/config/initializers/maintenance.rb +1 -0
- data/lib/generators/binda/setup/setup_generator.rb +41 -30
- data/lib/tasks/add_default_helpers_class_task.rake +11 -0
- data/lib/tasks/add_video_feature_task.rake +15 -0
- data/lib/tasks/remove_orphan_fields_task.rake +16 -0
- data/lib/tasks/set_repeater_position_task.rake +13 -0
- data/lib/tasks/upgrade_to_v007_task.rake +72 -0
- data/lib/tasks/user_tasks.rake +14 -0
- data/vendor/assets/fonts/font-awesome/fa-brands-400.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fa-brands-400.svg +978 -0
- data/vendor/assets/fonts/font-awesome/fa-brands-400.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fa-brands-400.woff +0 -0
- data/vendor/assets/fonts/font-awesome/fa-brands-400.woff2 +0 -0
- data/vendor/assets/fonts/font-awesome/fa-regular-400.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fa-regular-400.svg +363 -0
- data/vendor/assets/fonts/font-awesome/fa-regular-400.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fa-regular-400.woff +0 -0
- data/vendor/assets/fonts/font-awesome/fa-regular-400.woff2 +0 -0
- data/vendor/assets/fonts/font-awesome/fa-solid-900.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fa-solid-900.svg +1410 -0
- data/vendor/assets/fonts/font-awesome/fa-solid-900.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fa-solid-900.woff +0 -0
- data/vendor/assets/fonts/font-awesome/fa-solid-900.woff2 +0 -0
- data/vendor/assets/javascripts/GSAP/CSSPlugin.min.js +13 -0
- data/vendor/assets/javascripts/GSAP/EasePack.min.js +12 -0
- data/vendor/assets/javascripts/GSAP/ScrollToPlugin.min.js +12 -0
- data/vendor/assets/javascripts/GSAP/TweenLite.min.js +12 -0
- data/vendor/assets/javascripts/select2/i18n/af.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ar.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/az.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/bg.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/bs.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ca.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/cs.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/da.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/de.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/dsb.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/el.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/en.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/es.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/et.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/eu.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/fa.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/fi.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/fr.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/gl.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/he.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/hi.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/hr.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/hsb.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/hu.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/hy.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/id.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/is.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/it.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ja.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/km.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ko.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/lt.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/lv.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/mk.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ms.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/nb.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/nl.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/pl.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ps.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/pt-BR.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/pt.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ro.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/ru.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/sk.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/sl.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/sr-Cyrl.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/sr.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/sv.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/th.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/tr.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/uk.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/vi.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/zh-CN.js +3 -0
- data/vendor/assets/javascripts/select2/i18n/zh-TW.js +3 -0
- data/vendor/assets/javascripts/select2/select2.full.min.js +1 -0
- data/vendor/assets/javascripts/select2/select2.min.js +1 -0
- data/vendor/assets/javascripts/tether.min.js +1 -0
- data/vendor/assets/stylesheets/{bootstrap-select.css → bootstrap/bootstrap-select.css} +0 -0
- data/vendor/assets/stylesheets/font-awesome/_animated.scss +6 -20
- data/vendor/assets/stylesheets/font-awesome/_bordered-pulled.scss +6 -11
- data/vendor/assets/stylesheets/font-awesome/_core.scss +11 -7
- data/vendor/assets/stylesheets/font-awesome/_fixed-width.scss +1 -1
- data/vendor/assets/stylesheets/font-awesome/_icons.scss +785 -787
- data/vendor/assets/stylesheets/font-awesome/_larger.scss +16 -6
- data/vendor/assets/stylesheets/font-awesome/_list.scss +7 -8
- data/vendor/assets/stylesheets/font-awesome/_mixins.scss +17 -20
- data/vendor/assets/stylesheets/font-awesome/_rotated-flipped.scss +9 -6
- data/vendor/assets/stylesheets/font-awesome/_screen-reader.scss +2 -2
- data/vendor/assets/stylesheets/font-awesome/_stacked.scss +19 -8
- data/vendor/assets/stylesheets/font-awesome/_variables.scss +795 -795
- data/vendor/assets/stylesheets/font-awesome/fa-brands.scss +21 -0
- data/vendor/assets/stylesheets/font-awesome/fa-regular.scss +22 -0
- data/vendor/assets/stylesheets/font-awesome/fa-solid.scss +23 -0
- data/vendor/assets/stylesheets/font-awesome/fontawesome.scss +20 -0
- data/vendor/assets/stylesheets/select2/select2.min.css +1 -0
- metadata +278 -125
- data/app/assets/javascripts/binda/components/form_item_asset.js +0 -25
- data/app/assets/stylesheets/binda/application.css +0 -6
- data/app/assets/stylesheets/binda/components/form_body.scss +0 -2
- data/app/assets/stylesheets/binda/components/form_item_asset.scss +0 -20
- data/app/assets/stylesheets/binda/components/form_section.scss +0 -40
- data/app/assets/stylesheets/binda/components/sidebar.scss +0 -131
- data/app/assets/stylesheets/binda/layout/components_index.scss +0 -9
- data/app/assets/stylesheets/binda/layout/dashboard.scss +0 -7
- data/app/assets/stylesheets/binda/layout/users_sign_in.scss +0 -29
- data/app/controllers/binda/bindings_controller.rb +0 -62
- data/app/controllers/concerns/binda/default_helpers.rb +0 -226
- data/app/helpers/binda/bindings_helper.rb +0 -4
- data/app/models/binda/binda.rb +0 -7
- data/app/models/binda/binding.rb +0 -24
- data/app/views/binda/bindings/_form.html.erb +0 -32
- data/app/views/binda/bindings/edit.html.erb +0 -6
- data/app/views/binda/bindings/index.html.erb +0 -31
- data/app/views/binda/bindings/new.html.erb +0 -5
- data/app/views/binda/bindings/show.html.erb +0 -19
- data/app/views/binda/field_groups/index.html.erb +0 -34
- data/app/views/binda/fieldable/_form_item_asset.html.erb +0 -20
- data/app/views/users/sessions/new.html.erb +0 -27
- data/lib/tasks/binda.rake +0 -79
- data/vendor/assets/fonts/font-awesome/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.svg +0 -2671
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/font-awesome/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/stylesheets/font-awesome/_path.scss +0 -15
- data/vendor/assets/stylesheets/font-awesome/font-awesome.scss +0 -18
@@ -0,0 +1,18 @@
|
|
1
|
+
export default function()
|
2
|
+
{
|
3
|
+
$('input[name="login"]').click(function(){
|
4
|
+
let $radio = $(this);
|
5
|
+
|
6
|
+
// if this was previously checked
|
7
|
+
if ($radio.data('waschecked') === true)
|
8
|
+
{
|
9
|
+
$radio.prop('checked', false);
|
10
|
+
$radio.data('waschecked', false);
|
11
|
+
}
|
12
|
+
else
|
13
|
+
$radio.data('waschecked', true);
|
14
|
+
|
15
|
+
// remove was checked from other radios
|
16
|
+
$radio.siblings('input[name="login"]').data('waschecked', false);
|
17
|
+
});
|
18
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
* OPTIONAL (SELECT2 PLUGIN)
|
3
|
+
*/
|
4
|
+
|
5
|
+
export default function ()
|
6
|
+
{
|
7
|
+
setupSelect2('.select2-item')
|
8
|
+
}
|
9
|
+
|
10
|
+
export function setupSelect2(target)
|
11
|
+
{
|
12
|
+
$(target).each(function()
|
13
|
+
{
|
14
|
+
let placeholder = $(this).attr('placeholder')
|
15
|
+
if ( typeof placeholder == 'undefined' ) { placeholder = 'Select a option' }
|
16
|
+
|
17
|
+
$(this).select2({
|
18
|
+
minimumResultsForSearch: 32, // 31 are max number of day in a month, which you don't want to be searchable
|
19
|
+
placeholder: placeholder
|
20
|
+
})
|
21
|
+
})
|
22
|
+
}
|
@@ -1,3 +1,7 @@
|
|
1
|
+
/**
|
2
|
+
* SORTABLE
|
3
|
+
*/
|
4
|
+
|
1
5
|
export default function()
|
2
6
|
{
|
3
7
|
if ( $('.sortable').length > 0 )
|
@@ -5,12 +9,21 @@ export default function()
|
|
5
9
|
// Initialize sortable item
|
6
10
|
$('.sortable')
|
7
11
|
.sortable({
|
12
|
+
stop: function(event, ui){
|
13
|
+
ui.item.css('z-index', 0)
|
14
|
+
},
|
8
15
|
placeholder: "ui-state-highlight",
|
9
16
|
update: function () {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
if ( $('.popup-warning').length > 0 ) {
|
18
|
+
$('.sortable').addClass('sortable--disabled')
|
19
|
+
$('.popup-warning').removeClass('popup-warning--hidden')
|
20
|
+
$(this).sortable('option','disabled', true)
|
21
|
+
}
|
22
|
+
let url = $(this).data('update-url')
|
23
|
+
let data = $(this).sortable('serialize')
|
24
|
+
// If there is a pagination update accordingly
|
25
|
+
data = data.concat(`&id=${$(this).attr('id')}`)
|
26
|
+
$.post( url, data )
|
14
27
|
}
|
15
28
|
})
|
16
29
|
|
@@ -26,18 +39,50 @@ export default function()
|
|
26
39
|
$('.sortable--disabled').sortable('disable')
|
27
40
|
}
|
28
41
|
|
29
|
-
|
42
|
+
// If there is a sortable toggle button prepare the sortable items accordingly
|
43
|
+
if ( $('.sortable--toggle').length > 0 ) { setupSortableToggle() }
|
44
|
+
|
45
|
+
// Add event to any sortable toggle button
|
46
|
+
// TODO: make this event available to element which aren't standard form repeaters
|
47
|
+
$(document).on('click', '.standard-form--repeater .sortable--toggle', function( event )
|
30
48
|
{
|
31
49
|
event.preventDefault()
|
32
|
-
let id = '#' + $( this ).data(
|
50
|
+
let id = '#' + $( this ).data('repeater-id')
|
33
51
|
|
34
52
|
if ( $( id ).hasClass('sortable--disabled') )
|
35
|
-
|
53
|
+
{
|
54
|
+
$( id ).sortable('enable')
|
55
|
+
$( id ).find('.form-item--repeater-fields').each(close)
|
56
|
+
$( id ).find('.form-item--collapsable').addClass('form-item--collapsed')
|
57
|
+
}
|
36
58
|
else
|
37
|
-
|
59
|
+
{
|
60
|
+
$( id ).sortable('disable')
|
61
|
+
}
|
38
62
|
|
39
63
|
$( id ).toggleClass('sortable--disabled')
|
40
64
|
$( id ).toggleClass('sortable--enabled')
|
41
65
|
$( this ).children('.sortable--toggle-text').toggle()
|
42
66
|
})
|
67
|
+
}
|
68
|
+
|
69
|
+
|
70
|
+
function setupSortableToggle()
|
71
|
+
{
|
72
|
+
$('.sortable--toggle').each(function()
|
73
|
+
{
|
74
|
+
let id = '#' + $( this ).data('repeater-id')
|
75
|
+
$( id ).find('.form-item--collapsable').addClass('form-item--collapsed')
|
76
|
+
$( id ).find('.form-item--repeater-fields').each(close)
|
77
|
+
})
|
78
|
+
}
|
79
|
+
|
80
|
+
function close()
|
81
|
+
{
|
82
|
+
this.style.maxHeight = '0px'
|
83
|
+
}
|
84
|
+
|
85
|
+
function open()
|
86
|
+
{
|
87
|
+
this.style.maxHeight = this.scrollHeight + "px";
|
43
88
|
}
|
@@ -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 = 13);
|
67
67
|
/******/ })
|
68
68
|
/************************************************************************/
|
69
69
|
/******/ ([
|
@@ -76,9 +76,9 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
76
76
|
|
77
77
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
|
79
|
+
/**
|
80
|
+
* FORM ITEM EDITOR
|
81
|
+
*/
|
82
82
|
|
83
83
|
var FormItemEditor = function () {
|
84
84
|
function FormItemEditor() {
|
@@ -112,11 +112,12 @@ var FormItemEditor = function () {
|
|
112
112
|
key: 'resize',
|
113
113
|
value: function resize() {
|
114
114
|
$(this.target).each(function () {
|
115
|
-
// If the form item
|
115
|
+
// If the form item editor is closed don't go any further
|
116
116
|
if ($(this).height() === 0) return;
|
117
117
|
// otherwise update the max-height which is needed for the CSS transition
|
118
118
|
// NOTE you need to remove the max-height (inside 'style' attribute) to get the real height
|
119
|
-
$(this).
|
119
|
+
$(this).get(0).style.height = 'auto';
|
120
|
+
$(this).get(0).style.maxHeight = $(this).get(0).scrollHeight + "px";
|
120
121
|
});
|
121
122
|
}
|
122
123
|
}]);
|
@@ -130,30 +131,285 @@ var _FormItemEditor = new FormItemEditor();
|
|
130
131
|
/* 1 */
|
131
132
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
132
133
|
|
134
|
+
"use strict";
|
135
|
+
/* harmony export (immutable) */ __webpack_exports__["b"] = setupSelect2;
|
136
|
+
/**
|
137
|
+
* OPTIONAL (SELECT2 PLUGIN)
|
138
|
+
*/
|
139
|
+
|
140
|
+
/* harmony default export */ __webpack_exports__["a"] = function () {
|
141
|
+
setupSelect2('.select2-item');
|
142
|
+
};
|
143
|
+
|
144
|
+
function setupSelect2(target) {
|
145
|
+
$(target).each(function () {
|
146
|
+
var placeholder = $(this).attr('placeholder');
|
147
|
+
if (typeof placeholder == 'undefined') {
|
148
|
+
placeholder = 'Select a option';
|
149
|
+
}
|
150
|
+
|
151
|
+
$(this).select2({
|
152
|
+
minimumResultsForSearch: 32, // 31 are max number of day in a month, which you don't want to be searchable
|
153
|
+
placeholder: placeholder
|
154
|
+
});
|
155
|
+
});
|
156
|
+
}
|
157
|
+
|
158
|
+
/***/ }),
|
159
|
+
/* 2 */
|
160
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
161
|
+
|
162
|
+
"use strict";
|
163
|
+
/**
|
164
|
+
* BOOSTRAP SCRIPT
|
165
|
+
*/
|
166
|
+
|
167
|
+
/* harmony default export */ __webpack_exports__["a"] = function () {
|
168
|
+
// See https://v4-alpha.getbootstrap.com/components/tooltips/#example-enable-tooltips-everywhere
|
169
|
+
$('[data-toggle="tooltip"]').tooltip();
|
170
|
+
};
|
171
|
+
|
172
|
+
/***/ }),
|
173
|
+
/* 3 */
|
174
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
175
|
+
|
176
|
+
"use strict";
|
177
|
+
/**
|
178
|
+
* FIELD GROUP EDITOR
|
179
|
+
*/
|
180
|
+
|
181
|
+
/* harmony default export */ __webpack_exports__["a"] = function () {
|
182
|
+
$('.field_groups-edit #save').on('click', function (event) {
|
183
|
+
var instanceType = $(this).data('instance-type');
|
184
|
+
var entriesNumber = $(this).data('entries-number');
|
185
|
+
|
186
|
+
// If the current structure have many entries updating the field group
|
187
|
+
// might be a slow operation, therefore it's good practice to inform the user
|
188
|
+
if (entriesNumber > 500) {
|
189
|
+
alert('You have ' + entriesNumber + ' ' + instanceType + '. This operation might take some time to complete. To avoid unexpected behaviour don\'t leave or refresh the page');
|
190
|
+
}
|
191
|
+
});
|
192
|
+
};
|
193
|
+
|
194
|
+
/***/ }),
|
195
|
+
/* 4 */
|
196
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
197
|
+
|
198
|
+
"use strict";
|
199
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FileUpload; });
|
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
|
+
* FILE UPLOAD
|
206
|
+
*
|
207
|
+
* see https://tympanus.net/codrops/2015/09/15/styling-customizing-file-inputs-smart-way/
|
208
|
+
*
|
209
|
+
*/
|
210
|
+
|
211
|
+
var FileUpload = function () {
|
212
|
+
function FileUpload() {
|
213
|
+
_classCallCheck(this, FileUpload);
|
214
|
+
|
215
|
+
this.target = '.fileupload';
|
216
|
+
}
|
217
|
+
|
218
|
+
_createClass(FileUpload, [{
|
219
|
+
key: 'isSet',
|
220
|
+
value: function isSet() {
|
221
|
+
if ($(this.target).length > 0) {
|
222
|
+
return true;
|
223
|
+
} else {
|
224
|
+
return false;
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}, {
|
228
|
+
key: 'setEvents',
|
229
|
+
value: function setEvents() {
|
230
|
+
var self = this;
|
231
|
+
|
232
|
+
$(document).on('click', '.fileupload--remove-image-btn', remove_preview);
|
233
|
+
|
234
|
+
$(document).on('change', this.target + ' input.file', handle_file);
|
235
|
+
}
|
236
|
+
}]);
|
237
|
+
|
238
|
+
return FileUpload;
|
239
|
+
}();
|
240
|
+
|
241
|
+
var _FileUpload = new FileUpload();
|
242
|
+
|
243
|
+
/**
|
244
|
+
* HELPER FUNCTIONS
|
245
|
+
*/
|
246
|
+
|
247
|
+
// Reference --> http://blog.teamtreehouse.com/uploading-files-ajax
|
248
|
+
function handle_file(event) {
|
249
|
+
var id = event.target.getAttribute('data-id');
|
250
|
+
var $parent = $('#fileupload-' + id);
|
251
|
+
var $preview = $('#fileupload-' + id + ' .fileupload--preview');
|
252
|
+
|
253
|
+
// Get the selected file from the input
|
254
|
+
// This script doesn't consider multiple files upload
|
255
|
+
var file = event.target.files[0];
|
256
|
+
|
257
|
+
// Don't go any further if no file has been selected
|
258
|
+
if (typeof file === 'undefined') {
|
259
|
+
return;
|
260
|
+
}
|
261
|
+
|
262
|
+
// Create a new FormData object which will be sent to the server
|
263
|
+
var formData = new FormData();
|
264
|
+
|
265
|
+
// Get data from the input element
|
266
|
+
$parent.find('input').each(function () {
|
267
|
+
if (this.isSameNode(event.target)) {
|
268
|
+
// Add the file to the request
|
269
|
+
formData.append(this.getAttribute('name'), file, file.name);
|
270
|
+
} else {
|
271
|
+
// Add secondary values to the request
|
272
|
+
formData.append(this.getAttribute('name'), this.getAttribute('value'));
|
273
|
+
}
|
274
|
+
});
|
275
|
+
|
276
|
+
// If it's inside a repeater add repeater parameters
|
277
|
+
var $parent_repeater = $parent.closest('.form-item--repeater-fields');
|
278
|
+
if ($parent.closest('.form-item--repeater-fields').length > 0) {
|
279
|
+
$parent_repeater.children('.form-group').find('input').each(function () {
|
280
|
+
formData.append(this.getAttribute('name'), this.getAttribute('value'));
|
281
|
+
});
|
282
|
+
}
|
283
|
+
|
284
|
+
// Is this needed? Apparently it works without it. Is it a security issue?
|
285
|
+
// let token = document.querySelector('meta[name="csrf-token"]').content
|
286
|
+
// formData.append('authenticity_token', token)
|
287
|
+
|
288
|
+
// Display loader
|
289
|
+
$('.popup-warning').removeClass('popup-warning--hidden');
|
290
|
+
|
291
|
+
// Open the connection
|
292
|
+
$.ajax({
|
293
|
+
url: event.target.getAttribute('data-url'),
|
294
|
+
type: 'PATCH',
|
295
|
+
processData: false, // needed to pass formData with the current format
|
296
|
+
contentType: false, // needed to pass formData with the current format
|
297
|
+
data: formData
|
298
|
+
}).done(function (data) {
|
299
|
+
if (data.type == 'image') {
|
300
|
+
setup_image_preview(data, id);
|
301
|
+
} else if (data.type == 'video') {
|
302
|
+
setup_video_preview(data, id);
|
303
|
+
} else {
|
304
|
+
alert('Something went wrong. No preview has been received.');
|
305
|
+
}
|
306
|
+
|
307
|
+
// Hide loaded
|
308
|
+
$('.popup-warning').addClass('popup-warning--hidden');
|
309
|
+
|
310
|
+
// Display details and buttons
|
311
|
+
$parent.find('.fileupload--details').removeClass('fileupload--details--hidden');
|
312
|
+
$parent.find('.fileupload--remove-image-btn').removeClass('fileupload--remove-image-btn--hidden');
|
313
|
+
}).fail(function () {
|
314
|
+
// Hide loaded
|
315
|
+
$('.popup-warning').addClass('popup-warning--hidden');
|
316
|
+
alert('Something went wrong. Upload process failed.');
|
317
|
+
});
|
318
|
+
}
|
319
|
+
|
320
|
+
function reset_file(event) {
|
321
|
+
var input = event.target;
|
322
|
+
|
323
|
+
input.value = '';
|
324
|
+
|
325
|
+
if (!/safari/i.test(navigator.userAgent)) {
|
326
|
+
input.type = '';
|
327
|
+
input.type = 'file';
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
function remove_preview(event) {
|
332
|
+
var id = event.target.getAttribute('data-id');
|
333
|
+
var $parent = $('#fileupload-' + id);
|
334
|
+
|
335
|
+
// Reset previews (either image or video)
|
336
|
+
$parent.find('.fileupload--preview').css('background-image', '').removeClass('fileupload--preview--uploaded');
|
337
|
+
$parent.find('video source').attr('src', '');
|
338
|
+
|
339
|
+
// Reset buttons to initial state
|
340
|
+
$parent.find('.fileupload--remove-image-btn').addClass('fileupload--remove-image-btn--hidden');
|
341
|
+
$parent.find('.fileupload--details').addClass('fileupload--details--hidden');
|
342
|
+
}
|
343
|
+
|
344
|
+
function setup_image_preview(data, id) {
|
345
|
+
var $parent = $('#fileupload-' + id);
|
346
|
+
var $preview = $('#fileupload-' + id + ' .fileupload--preview');
|
347
|
+
|
348
|
+
// Update thumbnail
|
349
|
+
$preview.css('background-image', 'url(' + data.thumbnailUrl + ')');
|
350
|
+
|
351
|
+
// Remove and add class to trigger css animation
|
352
|
+
var uploadedClass = 'fileupload--preview--uploaded';
|
353
|
+
$preview.removeClass(uploadedClass).addClass(uploadedClass);
|
354
|
+
|
355
|
+
// Update details
|
356
|
+
$parent.find('.fileupload--width').text(data.width);
|
357
|
+
$parent.find('.fileupload--height').text(data.height);
|
358
|
+
$parent.find('.fileupload--filesize').text(data.size);
|
359
|
+
$parent.find('.fileupload--filename').text(data.name);
|
360
|
+
}
|
361
|
+
|
362
|
+
function setup_video_preview(data, id) {
|
363
|
+
var $parent = $('#fileupload-' + id);
|
364
|
+
var $preview = $('#fileupload-' + id + ' .fileupload--preview');
|
365
|
+
|
366
|
+
$preview.removeClass('fileupload--preview--uploaded').find('video').attr('id', 'video-' + id).find('source').attr('src', data.url).attr('type', 'video/' + data.ext);
|
367
|
+
|
368
|
+
// If video source isn't blank load it (consider that a video tag is always present)
|
369
|
+
if ($preview.find('video source').attr('src').length > 0) {
|
370
|
+
$preview.find('video').get(0).load();
|
371
|
+
}
|
372
|
+
|
373
|
+
// Remove and add class to trigger css animation
|
374
|
+
var uploadedClass = 'fileupload--preview--uploaded';
|
375
|
+
$preview.removeClass(uploadedClass).addClass(uploadedClass);
|
376
|
+
|
377
|
+
// Update details
|
378
|
+
$parent.find('.fileupload--filesize').text(data.size);
|
379
|
+
$parent.find('.fileupload--filename').text(data.name);
|
380
|
+
}
|
381
|
+
|
382
|
+
/***/ }),
|
383
|
+
/* 5 */
|
384
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
385
|
+
|
133
386
|
"use strict";
|
134
387
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
|
388
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select2__ = __webpack_require__(1);
|
135
389
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItem; });
|
136
390
|
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; }; }();
|
137
391
|
|
138
392
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
139
393
|
|
140
|
-
|
141
|
-
|
142
|
-
|
394
|
+
/**
|
395
|
+
* FORM ITEM
|
396
|
+
*/
|
397
|
+
|
143
398
|
|
144
399
|
|
145
400
|
|
401
|
+
// Component Global Variables
|
402
|
+
var newFormItemId = 1;
|
403
|
+
|
146
404
|
var FormItem = function () {
|
147
405
|
function FormItem() {
|
148
406
|
_classCallCheck(this, FormItem);
|
149
|
-
|
150
|
-
this.target = '.form-item';
|
151
407
|
}
|
152
408
|
|
153
409
|
_createClass(FormItem, [{
|
154
410
|
key: 'isSet',
|
155
411
|
value: function isSet() {
|
156
|
-
if ($(
|
412
|
+
if ($('.form-item').length > 0) {
|
157
413
|
return true;
|
158
414
|
} else {
|
159
415
|
return false;
|
@@ -162,26 +418,50 @@ var FormItem = function () {
|
|
162
418
|
}, {
|
163
419
|
key: 'setEvents',
|
164
420
|
value: function setEvents() {
|
165
|
-
$(document).on('click',
|
421
|
+
$(document).on('click', '.form-item--add-new', addNewItem);
|
166
422
|
|
167
423
|
$(document).on('click', '.form-item--remove-item-with-js', function (event) {
|
168
424
|
// Stop default behaviour
|
169
425
|
event.preventDefault();
|
170
|
-
$(this).
|
426
|
+
$(this).closest('.form-item').remove();
|
171
427
|
});
|
172
428
|
|
173
|
-
$(document).on('click', '.form-item--
|
174
|
-
|
429
|
+
$(document).on('click', '.form-item--collapse-btn', function (event) {
|
430
|
+
// This function is temporarely just set for repeaters.
|
431
|
+
// TODO: Need refactoring in order to be available also for generic form items
|
175
432
|
|
176
|
-
//
|
177
|
-
|
178
|
-
|
179
|
-
|
433
|
+
// Stop default behaviour
|
434
|
+
event.preventDefault();
|
435
|
+
|
436
|
+
var $collapsable = $(this).closest('.form-item--collapsable');
|
437
|
+
|
438
|
+
if ($collapsable.hasClass('form-item--collapsed')) {
|
439
|
+
$collapsable.find('.form-item--repeater-fields').each(open);
|
440
|
+
$collapsable.removeClass('form-item--collapsed');
|
441
|
+
} else {
|
442
|
+
$collapsable.find('.form-item--repeater-fields').each(close);
|
443
|
+
$collapsable.addClass('form-item--collapsed');
|
180
444
|
}
|
445
|
+
});
|
181
446
|
|
182
|
-
|
183
|
-
|
184
|
-
$(this).
|
447
|
+
$(document).on('click', '.form-item--toggle-button', function () {
|
448
|
+
|
449
|
+
var $formItem = $(this).closest('.form-item');
|
450
|
+
var $formItemEditor = $formItem.children('.form-item--editor');
|
451
|
+
|
452
|
+
if ($formItemEditor.get(0).style.maxHeight === '') {
|
453
|
+
// Update height
|
454
|
+
$formItemEditor.get(0).style.maxHeight = $formItemEditor.get(0).scrollHeight + "px";
|
455
|
+
|
456
|
+
// Add class to trigger animation
|
457
|
+
$formItem.children('.form-item--toggle-button').removeClass('form-item--toggle-button-closed');
|
458
|
+
} else {
|
459
|
+
// Zero height
|
460
|
+
$formItemEditor.get(0).style.maxHeight = null;
|
461
|
+
|
462
|
+
// Add class to trigger animation
|
463
|
+
$formItem.children('.form-item--toggle-button').addClass('form-item--toggle-button-closed');
|
464
|
+
}
|
185
465
|
});
|
186
466
|
}
|
187
467
|
}]);
|
@@ -195,63 +475,55 @@ var _FormItem = new FormItem();
|
|
195
475
|
/// COMPONENT HELPER FUNCTIONS
|
196
476
|
///- - - - - - - - - - - - - - - - - - - -
|
197
477
|
|
478
|
+
// This function could be improved as it generates an issue with
|
479
|
+
// input ids which are duplicated after the entire target has been cloned
|
198
480
|
function addNewItem(event) {
|
199
481
|
// Stop default behaviour
|
200
482
|
event.preventDefault();
|
201
|
-
// Get the child to clone
|
202
|
-
|
483
|
+
// Get the child to clone
|
484
|
+
// (`this` always refers to the second argument of the $(document).on() method, in this case '.form-item--add-new')
|
485
|
+
var id = $(this).data('new-form-item-id');
|
203
486
|
var $newChild = $('#' + id);
|
204
487
|
// Clone child and remove id and styles from cloned child
|
205
488
|
$newChild.clone().insertAfter($newChild);
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
489
|
+
// Remove class in order to remove styles, and change id so it's reachable when testing
|
490
|
+
$newChild.removeClass('form-item--new').attr('id', 'new-form-item-' + newFormItemId);
|
491
|
+
|
492
|
+
// // Update all ids to avoid duplication
|
493
|
+
$newChild.find('[id]').each(function () {
|
494
|
+
var oldId = $(this).attr('id');
|
495
|
+
var newId = oldId + '-' + newFormItemId;
|
496
|
+
$(this).attr('id', newId);
|
497
|
+
var $forId = $newChild.find('[for=' + oldId + ']');
|
498
|
+
if ($forId.length > 0) {
|
499
|
+
$forId.attr('for', newId);
|
500
|
+
}
|
501
|
+
});
|
213
502
|
|
214
|
-
|
215
|
-
|
216
|
-
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; }; }();
|
503
|
+
// Update height (max-height) of the new element
|
504
|
+
var $formItemEditor = $('#new-form-item-' + newFormItemId).find('.form-item--editor');
|
217
505
|
|
218
|
-
|
506
|
+
// override current max-height which is set to 0
|
507
|
+
$formItemEditor.get(0).style.maxHeight = $formItemEditor.get(0).scrollHeight + "px";
|
219
508
|
|
220
|
-
|
221
|
-
/// FORM ITEM ASSET
|
222
|
-
///- - - - - - - - - - - - - - - - - - - -
|
223
|
-
|
224
|
-
var FormItemAsset = function () {
|
225
|
-
function FormItemAsset() {
|
226
|
-
_classCallCheck(this, FormItemAsset);
|
509
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
227
510
|
|
228
|
-
|
229
|
-
|
511
|
+
// Increment global id variable `newFormItemId` in case needs to be used again
|
512
|
+
newFormItemId++;
|
230
513
|
|
231
|
-
|
232
|
-
|
233
|
-
value: function isSet() {
|
234
|
-
if ($(this.target).length > 0) {
|
235
|
-
return true;
|
236
|
-
} else {
|
237
|
-
return false;
|
238
|
-
}
|
239
|
-
}
|
240
|
-
}, {
|
241
|
-
key: 'setEvents',
|
242
|
-
value: function setEvents() {
|
243
|
-
// here code to setup assets via ajax
|
244
|
-
//
|
245
|
-
}
|
246
|
-
}]);
|
514
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($formItemEditor.find('select'));
|
515
|
+
}
|
247
516
|
|
248
|
-
|
249
|
-
|
517
|
+
function close() {
|
518
|
+
this.style.maxHeight = '0px';
|
519
|
+
}
|
250
520
|
|
251
|
-
|
521
|
+
function open() {
|
522
|
+
this.style.maxHeight = this.scrollHeight + "px";
|
523
|
+
}
|
252
524
|
|
253
525
|
/***/ }),
|
254
|
-
/*
|
526
|
+
/* 6 */
|
255
527
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
256
528
|
|
257
529
|
"use strict";
|
@@ -261,9 +533,9 @@ var _createClass = function () { function defineProperties(target, props) { for
|
|
261
533
|
|
262
534
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
263
535
|
|
264
|
-
|
265
|
-
|
266
|
-
|
536
|
+
/**
|
537
|
+
* FORM ITEM CHOICE
|
538
|
+
*/
|
267
539
|
|
268
540
|
|
269
541
|
|
@@ -289,7 +561,7 @@ var FormItemChoice = function () {
|
|
289
561
|
$(document).on('click', '.form-item--add-choice', function (event) {
|
290
562
|
event.preventDefault();
|
291
563
|
// Clone the new choice field
|
292
|
-
var choices = $(this).
|
564
|
+
var choices = $(this).closest('.form-item--choices');
|
293
565
|
var newchoice = choices.find('.form-item--new-choice');
|
294
566
|
var clone = newchoice.clone().removeClass('form-item--new-choice').toggle();
|
295
567
|
clone.find('.form-item--toggle-choice').toggle();
|
@@ -302,20 +574,25 @@ var FormItemChoice = function () {
|
|
302
574
|
$(document).on('click', '.form-item--delete-choice', function (event) {
|
303
575
|
event.preventDefault();
|
304
576
|
|
305
|
-
var choice = $(this).
|
577
|
+
var choice = $(this).closest('.form-item--choice');
|
306
578
|
var destination = $(this).attr('href');
|
579
|
+
var self = this;
|
307
580
|
|
308
581
|
$.ajax({
|
309
582
|
url: destination,
|
310
583
|
type: 'DELETE',
|
311
584
|
success: function success() {
|
312
585
|
choice.remove();
|
586
|
+
// Update form item editor size
|
587
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
313
588
|
}
|
314
589
|
});
|
315
590
|
});
|
316
591
|
$(document).on('click', '.form-item--js-delete-choice', function (event) {
|
317
592
|
event.preventDefault();
|
318
|
-
$(this).
|
593
|
+
$(this).closest('.form-item--choice').remove();
|
594
|
+
// Update form item editor size
|
595
|
+
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
319
596
|
});
|
320
597
|
}
|
321
598
|
}]);
|
@@ -326,33 +603,73 @@ var FormItemChoice = function () {
|
|
326
603
|
var _FormItemChoice = new FormItemChoice();
|
327
604
|
|
328
605
|
/***/ }),
|
329
|
-
/*
|
606
|
+
/* 7 */
|
607
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
608
|
+
|
609
|
+
"use strict";
|
610
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemImage; });
|
611
|
+
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; }; }();
|
612
|
+
|
613
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
614
|
+
|
615
|
+
/**
|
616
|
+
* FORM ITEM IMAGE
|
617
|
+
*/
|
618
|
+
|
619
|
+
var FormItemImage = function () {
|
620
|
+
function FormItemImage() {
|
621
|
+
_classCallCheck(this, FormItemImage);
|
622
|
+
|
623
|
+
this.target = '.form-item--image--uploader';
|
624
|
+
}
|
625
|
+
|
626
|
+
_createClass(FormItemImage, [{
|
627
|
+
key: 'isSet',
|
628
|
+
value: function isSet() {
|
629
|
+
if ($(this.target).length > 0) {
|
630
|
+
return true;
|
631
|
+
} else {
|
632
|
+
return false;
|
633
|
+
}
|
634
|
+
}
|
635
|
+
}, {
|
636
|
+
key: 'setEvents',
|
637
|
+
value: function setEvents() {}
|
638
|
+
}]);
|
639
|
+
|
640
|
+
return FormItemImage;
|
641
|
+
}();
|
642
|
+
|
643
|
+
var _FormItemImage = new FormItemImage();
|
644
|
+
|
645
|
+
/***/ }),
|
646
|
+
/* 8 */
|
330
647
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
331
648
|
|
332
649
|
"use strict";
|
333
650
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__form_item_editor__ = __webpack_require__(0);
|
651
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__select2__ = __webpack_require__(1);
|
334
652
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _FormItemRepeater; });
|
335
653
|
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; }; }();
|
336
654
|
|
337
655
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
338
656
|
|
339
|
-
|
340
|
-
|
341
|
-
|
657
|
+
/**
|
658
|
+
* FORM ITEM REPEATER
|
659
|
+
*/
|
660
|
+
|
342
661
|
|
343
662
|
|
344
663
|
|
345
664
|
var FormItemRepeater = function () {
|
346
665
|
function FormItemRepeater() {
|
347
666
|
_classCallCheck(this, FormItemRepeater);
|
348
|
-
|
349
|
-
this.target = '.form-item--repeater-section';
|
350
667
|
}
|
351
668
|
|
352
669
|
_createClass(FormItemRepeater, [{
|
353
670
|
key: 'isSet',
|
354
671
|
value: function isSet() {
|
355
|
-
if ($(
|
672
|
+
if ($('.form-item--repeater-section').length > 0) {
|
356
673
|
return true;
|
357
674
|
} else {
|
358
675
|
return false;
|
@@ -361,28 +678,43 @@ var FormItemRepeater = function () {
|
|
361
678
|
}, {
|
362
679
|
key: 'setEvents',
|
363
680
|
value: function setEvents() {
|
364
|
-
$(document).on('click',
|
681
|
+
$(document).on('click', '.form-item--repeater-section--add-new', function (event) {
|
682
|
+
addNewItem(this, event);
|
683
|
+
});
|
365
684
|
|
366
685
|
$(document).on('click', '.form-item--remove-item-with-js', function (event) {
|
367
686
|
// Stop default behaviour
|
368
687
|
event.preventDefault();
|
369
|
-
$(this).parent(
|
688
|
+
$(this).parent('.form-item--repeater-section').remove();
|
370
689
|
__WEBPACK_IMPORTED_MODULE_0__form_item_editor__["a" /* _FormItemEditor */].resize();
|
371
690
|
});
|
372
691
|
|
373
692
|
$(document).on('click', '.form-item--delete-repeater-item', function (event) {
|
374
|
-
var _this = this;
|
375
|
-
|
376
693
|
// Stop default behaviour
|
377
694
|
event.preventDefault();
|
378
695
|
|
696
|
+
// if ( !confirm($(this).data('confirm')) ) return
|
697
|
+
|
698
|
+
var record_id = $(this).data('id');
|
699
|
+
var target = $('#repeater_' + record_id).get(0);
|
700
|
+
// As max-height isn't set you need to set it manually before changing it,
|
701
|
+
// otherwise the animation doesn't get triggered
|
702
|
+
target.style.maxHeight = target.scrollHeight + 'px';
|
703
|
+
// Change max-height after 50ms to trigger css animation
|
704
|
+
setTimeout(function () {
|
705
|
+
target.style.maxHeight = 0 + 'px';
|
706
|
+
}, 50);
|
707
|
+
|
379
708
|
$.ajax({
|
380
709
|
url: $(this).attr('href'),
|
381
|
-
data: { id:
|
710
|
+
data: { id: record_id, isAjax: true },
|
382
711
|
method: "DELETE"
|
383
712
|
}).done(function () {
|
384
|
-
|
385
|
-
|
713
|
+
// Make sure the animation completes before removing the item (it should last 600ms + 50ms)
|
714
|
+
setTimeout(function () {
|
715
|
+
$(target).remove();
|
716
|
+
}, 700);
|
717
|
+
// _FormItemEditor.resize()
|
386
718
|
});
|
387
719
|
});
|
388
720
|
}
|
@@ -393,39 +725,454 @@ var FormItemRepeater = function () {
|
|
393
725
|
|
394
726
|
var _FormItemRepeater = new FormItemRepeater();
|
395
727
|
|
396
|
-
|
397
|
-
|
398
|
-
|
728
|
+
/**
|
729
|
+
* COMPONENT HELPER FUNCTIONS
|
730
|
+
*
|
731
|
+
* @param {string} target The target
|
732
|
+
* @param {object} event The event
|
733
|
+
*/
|
399
734
|
|
400
|
-
function addNewItem(event) {
|
735
|
+
function addNewItem(target, event) {
|
401
736
|
// Stop default behaviour
|
402
737
|
event.preventDefault();
|
403
738
|
// Get the child to clone
|
404
|
-
var id = $(
|
739
|
+
var id = $(target).data('id');
|
405
740
|
var $list = $('#form-item--repeater-setting-' + id);
|
406
|
-
var url = $(
|
741
|
+
var url = $(target).data('url');
|
407
742
|
$.post(url, { repeater_setting_id: id }, function (data) {
|
743
|
+
// Get repaeter code from Rails
|
744
|
+
// Due to the Rails way of creating nested forms it's necessary to
|
745
|
+
// create the nested item inside a different new form, then get just
|
746
|
+
// the code contained between the two SPLIT comments
|
408
747
|
var parts = data.split('<!-- SPLIT -->');
|
409
748
|
var newRepeater = parts[1];
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
749
|
+
|
750
|
+
// Append the item
|
751
|
+
$list.prepend(newRepeater);
|
752
|
+
var new_repeater_item = $list.find('.form-item--repeater').get(0);
|
753
|
+
|
754
|
+
// Prepare animation
|
755
|
+
new_repeater_item.style.maxHeight = 0;
|
756
|
+
|
757
|
+
// Group fields if sotrable is enabled
|
758
|
+
if ($list.hasClass('sortable--enabled')) {
|
759
|
+
$(new_repeater_item).find('.form-item--repeater-fields').each(function () {
|
760
|
+
this.style.maxHeight = 0 + 'px';
|
761
|
+
});
|
762
|
+
}
|
763
|
+
|
764
|
+
// Setup TinyMCE for the newly created item
|
765
|
+
var textarea_editor_id = $list.find('textarea').last('textarea').attr('id');
|
766
|
+
tinyMCE.EditorManager.execCommand('mceAddEditor', true, textarea_editor_id);
|
767
|
+
|
768
|
+
// Resize the editor (is it needed with the new configuration?)
|
769
|
+
// _FormItemEditor.resize()
|
770
|
+
|
771
|
+
// Update select input for Select2 plugin
|
772
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1__select2__["b" /* setupSelect2 */])($list.find('select'));
|
773
|
+
|
774
|
+
// Refresh Sortable to update the added item with Sortable features
|
775
|
+
$list.sortable('refresh');
|
776
|
+
|
777
|
+
// Run animation 50ms after previous style declaration (see above) otherwise animation doesn't get triggered
|
778
|
+
setTimeout(function () {
|
779
|
+
new_repeater_item.style.maxHeight = new_repeater_item.scrollHeight + 'px';
|
780
|
+
}, 50);
|
414
781
|
});
|
415
782
|
}
|
416
783
|
|
417
784
|
/***/ }),
|
418
|
-
/*
|
785
|
+
/* 9 */
|
419
786
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
420
787
|
|
421
788
|
"use strict";
|
789
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _Shader; });
|
790
|
+
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; }; }();
|
791
|
+
|
792
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
793
|
+
|
794
|
+
var Shader = function () {
|
795
|
+
function Shader() {
|
796
|
+
_classCallCheck(this, Shader);
|
797
|
+
}
|
798
|
+
|
799
|
+
_createClass(Shader, [{
|
800
|
+
key: 'isSet',
|
801
|
+
value: function isSet() {
|
802
|
+
if ($('#background-shader').length > 0) {
|
803
|
+
return true;
|
804
|
+
} else {
|
805
|
+
return false;
|
806
|
+
}
|
807
|
+
}
|
808
|
+
|
809
|
+
// SETUP SHADER
|
810
|
+
|
811
|
+
}, {
|
812
|
+
key: 'setup',
|
813
|
+
value: function setup() {
|
814
|
+
|
815
|
+
var Container = PIXI.Container,
|
816
|
+
autoDetectRenderer = PIXI.autoDetectRenderer,
|
817
|
+
loader = PIXI.loader,
|
818
|
+
resources = PIXI.loader.resources,
|
819
|
+
Sprite = PIXI.Sprite;
|
820
|
+
|
821
|
+
// Create a container object called the `stage`
|
822
|
+
this.stage = new Container();
|
823
|
+
|
824
|
+
// Create 'renderer'
|
825
|
+
this.renderer = PIXI.autoDetectRenderer(window.innerWidth, window.innerHeight);
|
826
|
+
|
827
|
+
// //Add the canvas to the HTML document
|
828
|
+
|
829
|
+
document.getElementById('background-shader').appendChild(this.renderer.view);
|
830
|
+
|
831
|
+
this.renderer.backgroundColor = 0xFF00FF;
|
832
|
+
|
833
|
+
// canvas full window
|
834
|
+
this.renderer.view.style.position = "fixed";
|
835
|
+
this.renderer.view.style.display = "block";
|
836
|
+
|
837
|
+
var fragmentShader = document.getElementById("fragmentShader").innerHTML;
|
838
|
+
|
839
|
+
var currentTime = Math.sin(Date.now()) + 0.5;
|
840
|
+
|
841
|
+
this.uniforms = {
|
842
|
+
uTime: { type: '1f', value: 0.0 },
|
843
|
+
uCurrentTime: { type: '1f', value: currentTime },
|
844
|
+
uMouse: { type: '2f', value: [window.innerWidth, window.innerHeight] },
|
845
|
+
uWindowSize: { type: '2f', value: [window.innerWidth, window.innerHeight] }
|
846
|
+
};
|
847
|
+
|
848
|
+
this.customShader = new PIXI.AbstractFilter(null, fragmentShader, this.uniforms);
|
849
|
+
this.drawRectagle();
|
850
|
+
}
|
851
|
+
|
852
|
+
// DRAW RECTANGLE
|
853
|
+
|
854
|
+
}, {
|
855
|
+
key: 'drawRectagle',
|
856
|
+
value: function drawRectagle() {
|
857
|
+
|
858
|
+
this.rectangle = new PIXI.Graphics();
|
859
|
+
|
860
|
+
// Set the default background color wo if browser doesn't support the filter we still see the primary color
|
861
|
+
var colorWithHash = '#FF00FF';
|
862
|
+
var colorWith0x = '0x' + colorWithHash.slice(1, 7);
|
863
|
+
this.rectangle.beginFill(colorWith0x);
|
864
|
+
|
865
|
+
// Create the background rectanlge
|
866
|
+
this.rectangle.drawRect(0, 0, window.innerWidth, window.innerHeight);
|
867
|
+
this.rectangle.endFill();
|
868
|
+
|
869
|
+
// Setup the filter (shader)
|
870
|
+
this.rectangle.filters = [this.customShader];
|
871
|
+
|
872
|
+
// Add background to stage
|
873
|
+
this.stage.addChild(this.rectangle);
|
874
|
+
}
|
875
|
+
|
876
|
+
// START ANIMATION
|
877
|
+
|
878
|
+
}, {
|
879
|
+
key: 'start',
|
880
|
+
value: function start() {
|
881
|
+
animate();
|
882
|
+
}
|
883
|
+
|
884
|
+
// MOUSE UPDATE
|
885
|
+
|
886
|
+
}, {
|
887
|
+
key: 'mouseUpdate',
|
888
|
+
value: function mouseUpdate(event) {
|
889
|
+
|
890
|
+
// If uniforms haven't been set yet don't do anything and exit
|
891
|
+
if (typeof this.uniforms === 'undefined') return;
|
892
|
+
|
893
|
+
// udpate mouse coordinates for the shader
|
894
|
+
this.customShader.uniforms.uMouse = [event.pageX, event.pageY];
|
895
|
+
}
|
896
|
+
|
897
|
+
// RESIZE
|
898
|
+
|
899
|
+
}, {
|
900
|
+
key: 'resize',
|
901
|
+
value: function resize() {
|
902
|
+
|
903
|
+
// let scale = scaleToWindow( this.renderer.view )
|
904
|
+
var prevWidth = this.renderer.view.style.width;
|
905
|
+
var prevHeight = this.renderer.view.style.height;
|
906
|
+
this.renderer.view.style.width = window.innerWidth + "px";
|
907
|
+
this.renderer.view.style.height = window.innerHeight + "px";
|
908
|
+
this.customShader.uniforms.uWindowSize = [window.innerWidth, window.innerHeight];
|
909
|
+
|
910
|
+
// Plese check this out ↴↴↴
|
911
|
+
// this.rectangle.scale.x = window.innerWidth / prevWidth
|
912
|
+
// this.rectangle.scale.y = window.innerHeight / prevHeight
|
913
|
+
}
|
914
|
+
}]);
|
915
|
+
|
916
|
+
return Shader;
|
917
|
+
}();
|
918
|
+
|
919
|
+
var _Shader = new Shader();
|
920
|
+
|
921
|
+
// ANIMATE
|
922
|
+
// -------
|
923
|
+
function animate() {
|
924
|
+
|
925
|
+
// start the timer for the next animation loop
|
926
|
+
requestAnimationFrame(animate);
|
927
|
+
_Shader.customShader.uniforms.uTime += 0.01;
|
928
|
+
// this is the main render call that makes pixi draw your container and its children.
|
929
|
+
_Shader.renderer.render(_Shader.stage);
|
930
|
+
}
|
931
|
+
|
932
|
+
// CONVERT HEX TO RGB COLORS
|
933
|
+
// -------------------------
|
934
|
+
function hexToShaderRgb(hex) {
|
935
|
+
|
936
|
+
// Precision of the float number
|
937
|
+
var precision = 100;
|
938
|
+
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
|
939
|
+
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
|
940
|
+
hex = hex.replace(shorthandRegex, function (m, r, g, b) {
|
941
|
+
return r + r + g + g + b + b;
|
942
|
+
});
|
943
|
+
|
944
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
|
945
|
+
return result ? {
|
946
|
+
// Get a number between 0.00 and 1.00
|
947
|
+
r: Math.round(parseInt(result[1], 16) * precision / 255) / precision,
|
948
|
+
g: Math.round(parseInt(result[2], 16) * precision / 255) / precision,
|
949
|
+
b: Math.round(parseInt(result[3], 16) * precision / 255) / precision
|
950
|
+
} : null;
|
951
|
+
}
|
952
|
+
|
953
|
+
// REQUEST ANIMATION POLYFILL
|
954
|
+
// --------------------------
|
955
|
+
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
956
|
+
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
957
|
+
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
|
958
|
+
// MIT license
|
959
|
+
(function () {
|
960
|
+
var lastTime = 0;
|
961
|
+
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
962
|
+
for (var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
963
|
+
window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
964
|
+
window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
|
965
|
+
}
|
966
|
+
|
967
|
+
if (!window.requestAnimationFrame) window.requestAnimationFrame = function (callback, element) {
|
968
|
+
var currTime = new Date().getTime();
|
969
|
+
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
970
|
+
var id = window.setTimeout(function () {
|
971
|
+
callback(currTime + timeToCall);
|
972
|
+
}, timeToCall);
|
973
|
+
lastTime = currTime + timeToCall;
|
974
|
+
return id;
|
975
|
+
};
|
976
|
+
|
977
|
+
if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function (id) {
|
978
|
+
clearTimeout(id);
|
979
|
+
};
|
980
|
+
})();
|
981
|
+
|
982
|
+
// Mozilla MDN optimized resize
|
983
|
+
// https://developer.mozilla.org/en-US/docs/Web/Events/resize
|
984
|
+
(function () {
|
985
|
+
var throttle = function throttle(type, name, obj) {
|
986
|
+
obj = obj || window;
|
987
|
+
var running = false;
|
988
|
+
var func = function func() {
|
989
|
+
if (running) {
|
990
|
+
return;
|
991
|
+
}
|
992
|
+
running = true;
|
993
|
+
requestAnimationFrame(function () {
|
994
|
+
obj.dispatchEvent(new CustomEvent(name));
|
995
|
+
running = false;
|
996
|
+
});
|
997
|
+
};
|
998
|
+
obj.addEventListener(type, func);
|
999
|
+
};
|
1000
|
+
|
1001
|
+
/* init - you can init any event */
|
1002
|
+
throttle("resize", "optimizedResize");
|
1003
|
+
})();
|
1004
|
+
|
1005
|
+
/***/ }),
|
1006
|
+
/* 10 */
|
1007
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1008
|
+
|
1009
|
+
"use strict";
|
1010
|
+
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _LoginForm; });
|
1011
|
+
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; }; }();
|
1012
|
+
|
1013
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
1014
|
+
|
1015
|
+
/**
|
1016
|
+
* LOGIN FORM
|
1017
|
+
*
|
1018
|
+
* https://tympanus.net/Development/MinimalForm/
|
1019
|
+
* https://github.com/codrops/MinimalForm/blob/master/js/stepsForm.js
|
1020
|
+
*/
|
1021
|
+
|
1022
|
+
var LoginForm = function () {
|
1023
|
+
function LoginForm() {
|
1024
|
+
_classCallCheck(this, LoginForm);
|
1025
|
+
|
1026
|
+
this.current = 0;
|
1027
|
+
this.isFilled = false;
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
_createClass(LoginForm, [{
|
1031
|
+
key: 'isSet',
|
1032
|
+
value: function isSet() {
|
1033
|
+
if ($('.login--form').length > 0) {
|
1034
|
+
return true;
|
1035
|
+
} else {
|
1036
|
+
return false;
|
1037
|
+
}
|
1038
|
+
}
|
1039
|
+
}, {
|
1040
|
+
key: 'setEvents',
|
1041
|
+
value: function setEvents() {
|
1042
|
+
this.$form = $('.login--form');
|
1043
|
+
this.$questions = $('ol.login--questions > li');
|
1044
|
+
this.questionsCount = this.$questions.length;
|
1045
|
+
this.$nextButton = $('button.login--next');
|
1046
|
+
|
1047
|
+
// Mark the first question as the current one
|
1048
|
+
this.$questions.first().addClass('login--current');
|
1049
|
+
|
1050
|
+
//disable form autocomplete
|
1051
|
+
this.$form.attr('autocomplete', 'off');
|
1052
|
+
|
1053
|
+
var self = this;
|
1054
|
+
|
1055
|
+
// first input
|
1056
|
+
var firstInput = this.$questions.get(this.current).querySelector('input, textarea, select');
|
1057
|
+
|
1058
|
+
// focus
|
1059
|
+
var onFocusStart = function onFocusStart() {
|
1060
|
+
firstInput.removeEventListener('focus', onFocusStart);
|
1061
|
+
self.$nextButton.addClass('login--show');
|
1062
|
+
};
|
1063
|
+
// show the next question control first time the input gets focused
|
1064
|
+
firstInput.addEventListener('focus', onFocusStart);
|
1065
|
+
|
1066
|
+
// show next question
|
1067
|
+
this.$nextButton.on('click', function (event) {
|
1068
|
+
event.preventDefault();
|
1069
|
+
self._nextQuestion();
|
1070
|
+
});
|
1071
|
+
|
1072
|
+
// pressing enter will jump to next question
|
1073
|
+
this.$form.on('keydown', function (event) {
|
1074
|
+
var keyCode = event.keyCode || event.which;
|
1075
|
+
// enter
|
1076
|
+
if (keyCode === 13) {
|
1077
|
+
event.preventDefault();
|
1078
|
+
self._nextQuestion();
|
1079
|
+
}
|
1080
|
+
});
|
1081
|
+
}
|
1082
|
+
}, {
|
1083
|
+
key: '_nextQuestion',
|
1084
|
+
value: function _nextQuestion() {
|
1085
|
+
// check if form is filled
|
1086
|
+
if (this.current === this.questionsCount - 1) {
|
1087
|
+
this.isFilled = true;
|
1088
|
+
}
|
1089
|
+
|
1090
|
+
// current question
|
1091
|
+
var currentQuestion = this.$questions.get(this.current);
|
1092
|
+
|
1093
|
+
// increment current question iterator
|
1094
|
+
++this.current;
|
1095
|
+
|
1096
|
+
if (!this.isFilled) {
|
1097
|
+
// add class "show-next" to form element (start animations)
|
1098
|
+
this.$form.addClass('login--show-next');
|
1099
|
+
|
1100
|
+
// remove class "current" from current question and add it to the next one
|
1101
|
+
// current question
|
1102
|
+
var nextQuestion = this.$questions.get(this.current);
|
1103
|
+
$(currentQuestion).removeClass('login--current');
|
1104
|
+
$(nextQuestion).addClass('login--current');
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
// after animation ends, remove class "show-next" from form element and change current question placeholder
|
1108
|
+
var self = this;
|
1109
|
+
var onEndTransition = function onEndTransition() {
|
1110
|
+
if (self.isFilled) {
|
1111
|
+
self.$form.submit();
|
1112
|
+
} else {
|
1113
|
+
self.$form.removeClass('login--show-next');
|
1114
|
+
// force the focus on the next input
|
1115
|
+
nextQuestion.querySelector('input, textarea, select').focus();
|
1116
|
+
}
|
1117
|
+
};
|
1118
|
+
|
1119
|
+
setTimeout(onEndTransition, 400); // Wait for CSS transition to complete
|
1120
|
+
}
|
1121
|
+
}]);
|
1122
|
+
|
1123
|
+
return LoginForm;
|
1124
|
+
}();
|
1125
|
+
|
1126
|
+
var _LoginForm = new LoginForm();
|
1127
|
+
|
1128
|
+
/***/ }),
|
1129
|
+
/* 11 */
|
1130
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1131
|
+
|
1132
|
+
"use strict";
|
1133
|
+
/* harmony default export */ __webpack_exports__["a"] = function () {
|
1134
|
+
$('input[name="login"]').click(function () {
|
1135
|
+
var $radio = $(this);
|
1136
|
+
|
1137
|
+
// if this was previously checked
|
1138
|
+
if ($radio.data('waschecked') === true) {
|
1139
|
+
$radio.prop('checked', false);
|
1140
|
+
$radio.data('waschecked', false);
|
1141
|
+
} else $radio.data('waschecked', true);
|
1142
|
+
|
1143
|
+
// remove was checked from other radios
|
1144
|
+
$radio.siblings('input[name="login"]').data('waschecked', false);
|
1145
|
+
});
|
1146
|
+
};
|
1147
|
+
|
1148
|
+
/***/ }),
|
1149
|
+
/* 12 */
|
1150
|
+
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
1151
|
+
|
1152
|
+
"use strict";
|
1153
|
+
/**
|
1154
|
+
* SORTABLE
|
1155
|
+
*/
|
1156
|
+
|
422
1157
|
/* harmony default export */ __webpack_exports__["a"] = function () {
|
423
1158
|
if ($('.sortable').length > 0) {
|
424
1159
|
// Initialize sortable item
|
425
1160
|
$('.sortable').sortable({
|
1161
|
+
stop: function stop(event, ui) {
|
1162
|
+
ui.item.css('z-index', 0);
|
1163
|
+
},
|
426
1164
|
placeholder: "ui-state-highlight",
|
427
1165
|
update: function update() {
|
428
|
-
|
1166
|
+
if ($('.popup-warning').length > 0) {
|
1167
|
+
$('.sortable').addClass('sortable--disabled');
|
1168
|
+
$('.popup-warning').removeClass('popup-warning--hidden');
|
1169
|
+
$(this).sortable('option', 'disabled', true);
|
1170
|
+
}
|
1171
|
+
var url = $(this).data('update-url');
|
1172
|
+
var data = $(this).sortable('serialize');
|
1173
|
+
// If there is a pagination update accordingly
|
1174
|
+
data = data.concat('&id=' + $(this).attr('id'));
|
1175
|
+
$.post(url, data);
|
429
1176
|
}
|
430
1177
|
});
|
431
1178
|
|
@@ -441,12 +1188,21 @@ function addNewItem(event) {
|
|
441
1188
|
$('.sortable--disabled').sortable('disable');
|
442
1189
|
}
|
443
1190
|
|
444
|
-
|
1191
|
+
// If there is a sortable toggle button prepare the sortable items accordingly
|
1192
|
+
if ($('.sortable--toggle').length > 0) {
|
1193
|
+
setupSortableToggle();
|
1194
|
+
}
|
1195
|
+
|
1196
|
+
// Add event to any sortable toggle button
|
1197
|
+
// TODO: make this event available to element which aren't standard form repeaters
|
1198
|
+
$(document).on('click', '.standard-form--repeater .sortable--toggle', function (event) {
|
445
1199
|
event.preventDefault();
|
446
1200
|
var id = '#' + $(this).data('repeater-id');
|
447
1201
|
|
448
1202
|
if ($(id).hasClass('sortable--disabled')) {
|
449
1203
|
$(id).sortable('enable');
|
1204
|
+
$(id).find('.form-item--repeater-fields').each(close);
|
1205
|
+
$(id).find('.form-item--collapsable').addClass('form-item--collapsed');
|
450
1206
|
} else {
|
451
1207
|
$(id).sortable('disable');
|
452
1208
|
}
|
@@ -457,18 +1213,41 @@ function addNewItem(event) {
|
|
457
1213
|
});
|
458
1214
|
};
|
459
1215
|
|
1216
|
+
function setupSortableToggle() {
|
1217
|
+
$('.sortable--toggle').each(function () {
|
1218
|
+
var id = '#' + $(this).data('repeater-id');
|
1219
|
+
$(id).find('.form-item--collapsable').addClass('form-item--collapsed');
|
1220
|
+
$(id).find('.form-item--repeater-fields').each(close);
|
1221
|
+
});
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
function close() {
|
1225
|
+
this.style.maxHeight = '0px';
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
function open() {
|
1229
|
+
this.style.maxHeight = this.scrollHeight + "px";
|
1230
|
+
}
|
1231
|
+
|
460
1232
|
/***/ }),
|
461
|
-
/*
|
1233
|
+
/* 13 */
|
462
1234
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
463
1235
|
|
464
1236
|
"use strict";
|
465
1237
|
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
466
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(
|
467
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(
|
468
|
-
/* harmony import */ var
|
469
|
-
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__ = __webpack_require__(
|
1238
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__components_form_item__ = __webpack_require__(5);
|
1239
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__ = __webpack_require__(8);
|
1240
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__components_form_item_image__ = __webpack_require__(7);
|
1241
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__ = __webpack_require__(6);
|
470
1242
|
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__ = __webpack_require__(0);
|
471
|
-
/* harmony import */ var
|
1243
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__components_fileupload__ = __webpack_require__(4);
|
1244
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__components_login_shader__ = __webpack_require__(9);
|
1245
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__components_login_form__ = __webpack_require__(10);
|
1246
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__components_sortable__ = __webpack_require__(12);
|
1247
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__ = __webpack_require__(3);
|
1248
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__components_bootstrap__ = __webpack_require__(2);
|
1249
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__components_select2__ = __webpack_require__(1);
|
1250
|
+
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__ = __webpack_require__(11);
|
472
1251
|
///- - - - - - - - - - - - - - - - - - - -
|
473
1252
|
/// INDEX OF BINDA'S SCRIPTS
|
474
1253
|
///- - - - - - - - - - - - - - - - - - - -
|
@@ -480,6 +1259,13 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
|
480
1259
|
|
481
1260
|
|
482
1261
|
|
1262
|
+
|
1263
|
+
|
1264
|
+
|
1265
|
+
|
1266
|
+
|
1267
|
+
|
1268
|
+
|
483
1269
|
$(document).ready(function () {
|
484
1270
|
if (__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].isSet()) {
|
485
1271
|
__WEBPACK_IMPORTED_MODULE_0__components_form_item__["a" /* _FormItem */].setEvents();
|
@@ -487,8 +1273,8 @@ $(document).ready(function () {
|
|
487
1273
|
if (__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].isSet()) {
|
488
1274
|
__WEBPACK_IMPORTED_MODULE_1__components_form_item_repeater__["a" /* _FormItemRepeater */].setEvents();
|
489
1275
|
}
|
490
|
-
if (
|
491
|
-
|
1276
|
+
if (__WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].isSet()) {
|
1277
|
+
__WEBPACK_IMPORTED_MODULE_2__components_form_item_image__["a" /* _FormItemImage */].setEvents();
|
492
1278
|
}
|
493
1279
|
if (__WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__["a" /* _FormItemChoice */].isSet()) {
|
494
1280
|
__WEBPACK_IMPORTED_MODULE_3__components_form_item_choice__["a" /* _FormItemChoice */].setEvents();
|
@@ -496,7 +1282,28 @@ $(document).ready(function () {
|
|
496
1282
|
if (__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].isSet()) {
|
497
1283
|
__WEBPACK_IMPORTED_MODULE_4__components_form_item_editor__["a" /* _FormItemEditor */].setEvents();
|
498
1284
|
}
|
499
|
-
|
1285
|
+
if (__WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].isSet()) {
|
1286
|
+
__WEBPACK_IMPORTED_MODULE_5__components_fileupload__["a" /* _FileUpload */].setEvents();
|
1287
|
+
}
|
1288
|
+
if (__WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].isSet()) {
|
1289
|
+
__WEBPACK_IMPORTED_MODULE_7__components_login_form__["a" /* _LoginForm */].setEvents();
|
1290
|
+
}
|
1291
|
+
if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
|
1292
|
+
__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].setup();
|
1293
|
+
__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].start();
|
1294
|
+
}
|
1295
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_12__components_radio_toggle__["a" /* default */])();
|
1296
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_8__components_sortable__["a" /* default */])();
|
1297
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_9__components_field_group_editor__["a" /* default */])();
|
1298
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_10__components_bootstrap__["a" /* default */])();
|
1299
|
+
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_11__components_select2__["a" /* default */])();
|
1300
|
+
});
|
1301
|
+
|
1302
|
+
// handle event
|
1303
|
+
window.addEventListener("optimizedResize", function () {
|
1304
|
+
if (__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].isSet()) {
|
1305
|
+
__WEBPACK_IMPORTED_MODULE_6__components_login_shader__["a" /* _Shader */].resize();
|
1306
|
+
}
|
500
1307
|
});
|
501
1308
|
|
502
1309
|
/***/ })
|