fae-railsz 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +5 -0
- data/Rakefile +37 -0
- data/app/assets/fonts/fae/icons.eot +0 -0
- data/app/assets/fonts/fae/icons.svg +56 -0
- data/app/assets/fonts/fae/icons.ttf +0 -0
- data/app/assets/fonts/fae/icons.woff +0 -0
- data/app/assets/fonts/fae/lato-bold-webfont.eot +0 -0
- data/app/assets/fonts/fae/lato-bold-webfont.svg +4551 -0
- data/app/assets/fonts/fae/lato-bold-webfont.ttf +0 -0
- data/app/assets/fonts/fae/lato-bold-webfont.woff +0 -0
- data/app/assets/fonts/fae/lato-light-webfont.eot +0 -0
- data/app/assets/fonts/fae/lato-light-webfont.svg +4241 -0
- data/app/assets/fonts/fae/lato-light-webfont.ttf +0 -0
- data/app/assets/fonts/fae/lato-light-webfont.woff +0 -0
- data/app/assets/fonts/fae/lato-regular-webfont.eot +0 -0
- data/app/assets/fonts/fae/lato-regular-webfont.svg +4241 -0
- data/app/assets/fonts/fae/lato-regular-webfont.ttf +0 -0
- data/app/assets/fonts/fae/lato-regular-webfont.woff +0 -0
- data/app/assets/fonts/fae/selection.json +1334 -0
- data/app/assets/images/fae/error_bg.jpg +0 -0
- data/app/assets/images/fae/error_sad_face.png +0 -0
- data/app/assets/images/fae/icons/alert.svg +9 -0
- data/app/assets/images/fae/icons/arrow_down.svg +8 -0
- data/app/assets/images/fae/icons/arrow_left.svg +9 -0
- data/app/assets/images/fae/icons/arrow_right.svg +9 -0
- data/app/assets/images/fae/icons/arrow_stacked.svg +8 -0
- data/app/assets/images/fae/icons/arrow_up.svg +8 -0
- data/app/assets/images/fae/icons/calendar.svg +17 -0
- data/app/assets/images/fae/icons/check.svg +7 -0
- data/app/assets/images/fae/icons/checkmark.svg +8 -0
- data/app/assets/images/fae/icons/chevron_down.svg +7 -0
- data/app/assets/images/fae/icons/chevron_left.svg +10 -0
- data/app/assets/images/fae/icons/chevron_right.svg +10 -0
- data/app/assets/images/fae/icons/chevron_up.svg +7 -0
- data/app/assets/images/fae/icons/delete.svg +8 -0
- data/app/assets/images/fae/icons/delete_x.svg +8 -0
- data/app/assets/images/fae/icons/edit.svg +11 -0
- data/app/assets/images/fae/icons/handle.svg +13 -0
- data/app/assets/images/fae/icons/home.svg +10 -0
- data/app/assets/images/fae/icons/logout.svg +12 -0
- data/app/assets/images/fae/icons/magnifying_glass.svg +10 -0
- data/app/assets/images/fae/icons/menu.svg +11 -0
- data/app/assets/images/fae/icons/offlink.svg +25 -0
- data/app/assets/images/fae/icons/plus.svg +8 -0
- data/app/assets/images/fae/icons/pulldown.svg +11 -0
- data/app/assets/images/fae/icons/search.svg +11 -0
- data/app/assets/images/fae/icons/settings.svg +12 -0
- data/app/assets/images/fae/icons/sort.svg +11 -0
- data/app/assets/images/fae/icons/support.svg +15 -0
- data/app/assets/images/fae/icons/trash.svg +10 -0
- data/app/assets/images/fae/icons/trumbowyg.svg +1 -0
- data/app/assets/images/fae/icons/user.svg +13 -0
- data/app/assets/images/fae/icons/users.svg +19 -0
- data/app/assets/images/fae/icons/zoom.svg +12 -0
- data/app/assets/images/fae/tutorial_model_location.png +0 -0
- data/app/assets/images/fae/youtube_helper.jpg +0 -0
- data/app/assets/javascripts/fae/_modals.js +60 -0
- data/app/assets/javascripts/fae/_tables.js +403 -0
- data/app/assets/javascripts/fae/admin.js.erb +11 -0
- data/app/assets/javascripts/fae/application.js +63 -0
- data/app/assets/javascripts/fae/fae_init.js +8 -0
- data/app/assets/javascripts/fae/form/_ajax.js +380 -0
- data/app/assets/javascripts/fae/form/_cancel.js +38 -0
- data/app/assets/javascripts/fae/form/_filtering.js +276 -0
- data/app/assets/javascripts/fae/form/_form.js +60 -0
- data/app/assets/javascripts/fae/form/_slugger.js.erb +100 -0
- data/app/assets/javascripts/fae/form/_validator.js +459 -0
- data/app/assets/javascripts/fae/form/fae_chosen.js +44 -0
- data/app/assets/javascripts/fae/form/fileinputer.js +178 -0
- data/app/assets/javascripts/fae/form/hinter.js +111 -0
- data/app/assets/javascripts/fae/form/inputs/_checkbox.js +27 -0
- data/app/assets/javascripts/fae/form/inputs/_color.js +42 -0
- data/app/assets/javascripts/fae/form/inputs/_dates.js +78 -0
- data/app/assets/javascripts/fae/form/inputs/_select.js +162 -0
- data/app/assets/javascripts/fae/form/inputs/_text.js +118 -0
- data/app/assets/javascripts/fae/navigation/_global_search.js +184 -0
- data/app/assets/javascripts/fae/navigation/_language.js +89 -0
- data/app/assets/javascripts/fae/navigation/_navigation.js +206 -0
- data/app/assets/javascripts/fae/navigation/_subnav_highlighter.js +81 -0
- data/app/assets/javascripts/fae/navigation/sticky.js +186 -0
- data/app/assets/javascripts/fae/vendor/chosen.jquery.min.js +2 -0
- data/app/assets/javascripts/fae/vendor/frob_core_helpers.js +587 -0
- data/app/assets/javascripts/fae/vendor/fryr.js +437 -0
- data/app/assets/javascripts/fae/vendor/jqColorPicker.min.js +4 -0
- data/app/assets/javascripts/fae/vendor/jquery.daterangepicker.js +1292 -0
- data/app/assets/javascripts/fae/vendor/jquery.multi-select.js +534 -0
- data/app/assets/javascripts/fae/vendor/jquery.simplemodal.1.4.4.js +719 -0
- data/app/assets/javascripts/fae/vendor/jquery.tablesorter.js +1901 -0
- data/app/assets/javascripts/fae/vendor/js.cookie.js +139 -0
- data/app/assets/javascripts/fae/vendor/moment.min.js +7 -0
- data/app/assets/javascripts/fae/vendor/simplemde.min.js +13 -0
- data/app/assets/javascripts/fae/vendor/touch_punch.js +11 -0
- data/app/assets/javascripts/fae/vendor/trumbowyg.js.erb +4 -0
- data/app/assets/javascripts/fae/vendor/trumbowyg/plugins/upload/trumbowyg.upload.js +223 -0
- data/app/assets/javascripts/fae/vendor/trumbowyg/trumbowyg.js +1603 -0
- data/app/assets/stylesheets/fae/application.css +8 -0
- data/app/assets/stylesheets/fae/base.scss +82 -0
- data/app/assets/stylesheets/fae/globals/_fonts.scss +43 -0
- data/app/assets/stylesheets/fae/globals/_icons.scss +15 -0
- data/app/assets/stylesheets/fae/globals/_plugins.scss +51 -0
- data/app/assets/stylesheets/fae/globals/_tags.scss +68 -0
- data/app/assets/stylesheets/fae/globals/imports/_extends.scss +53 -0
- data/app/assets/stylesheets/fae/globals/imports/_mixins.scss +58 -0
- data/app/assets/stylesheets/fae/globals/imports/_variables.scss +165 -0
- data/app/assets/stylesheets/fae/globals/imports/finescss/_fine.scss +7 -0
- data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_functions.scss +88 -0
- data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_mixins.scss +280 -0
- data/app/assets/stylesheets/fae/globals/imports/finescss/_fine_variables.scss +30 -0
- data/app/assets/stylesheets/fae/globals/layout/_base.scss +48 -0
- data/app/assets/stylesheets/fae/globals/layout/_breadcrumbs.scss +45 -0
- data/app/assets/stylesheets/fae/globals/layout/_content-header.scss +99 -0
- data/app/assets/stylesheets/fae/globals/legacy/_pre-1.3.scss +659 -0
- data/app/assets/stylesheets/fae/globals/navigation/_base.scss +22 -0
- data/app/assets/stylesheets/fae/globals/navigation/_footer.scss +50 -0
- data/app/assets/stylesheets/fae/globals/navigation/_header.scss +149 -0
- data/app/assets/stylesheets/fae/globals/navigation/_mobilenav.scss +149 -0
- data/app/assets/stylesheets/fae/globals/navigation/_search.scss +76 -0
- data/app/assets/stylesheets/fae/globals/navigation/_sidenav.scss +142 -0
- data/app/assets/stylesheets/fae/globals/navigation/_utility.scss +95 -0
- data/app/assets/stylesheets/fae/modules/_alerts.scss +50 -0
- data/app/assets/stylesheets/fae/modules/_buttons.scss +62 -0
- data/app/assets/stylesheets/fae/modules/_modal.scss +78 -0
- data/app/assets/stylesheets/fae/modules/_toggles.scss +48 -0
- data/app/assets/stylesheets/fae/modules/forms/_asset-actions.scss +83 -0
- data/app/assets/stylesheets/fae/modules/forms/_base.scss +100 -0
- data/app/assets/stylesheets/fae/modules/forms/_checkbox.scss +87 -0
- data/app/assets/stylesheets/fae/modules/forms/_colorpicker.scss +57 -0
- data/app/assets/stylesheets/fae/modules/forms/_date.scss +335 -0
- data/app/assets/stylesheets/fae/modules/forms/_hints.scss +40 -0
- data/app/assets/stylesheets/fae/modules/forms/_label.scss +57 -0
- data/app/assets/stylesheets/fae/modules/forms/_radio.scss +69 -0
- data/app/assets/stylesheets/fae/modules/forms/_select.scss +317 -0
- data/app/assets/stylesheets/fae/modules/forms/_simple-mde.scss +29 -0
- data/app/assets/stylesheets/fae/modules/forms/_text.scss +62 -0
- data/app/assets/stylesheets/fae/modules/forms/_textarea.scss +16 -0
- data/app/assets/stylesheets/fae/modules/forms/_validation.scss +63 -0
- data/app/assets/stylesheets/fae/modules/tables/_actions.scss +41 -0
- data/app/assets/stylesheets/fae/modules/tables/_base.scss +63 -0
- data/app/assets/stylesheets/fae/modules/tables/_collapsible.scss +76 -0
- data/app/assets/stylesheets/fae/modules/tables/_filters.scss +61 -0
- data/app/assets/stylesheets/fae/modules/tables/_image.scss +21 -0
- data/app/assets/stylesheets/fae/modules/tables/_pagination.scss +34 -0
- data/app/assets/stylesheets/fae/modules/tables/_sorting.scss +58 -0
- data/app/assets/stylesheets/fae/modules/tables/_sticky.scss +9 -0
- data/app/assets/stylesheets/fae/modules/tables/_tooltips.scss +24 -0
- data/app/assets/stylesheets/fae/pages/_error.scss +35 -0
- data/app/assets/stylesheets/fae/pages/_help.scss +28 -0
- data/app/assets/stylesheets/fae/pages/_home.scss +18 -0
- data/app/assets/stylesheets/fae/pages/_login.scss +137 -0
- data/app/assets/stylesheets/fae/vendor/chosen.css +377 -0
- data/app/assets/stylesheets/fae/vendor/daterangepicker.css +227 -0
- data/app/assets/stylesheets/fae/vendor/reset.css +48 -0
- data/app/assets/stylesheets/fae/vendor/simplemde.min.css +7 -0
- data/app/assets/stylesheets/fae/vendor/trumbowyg.css +584 -0
- data/app/controllers/concerns/fae/application_controller_concern.rb +1 -0
- data/app/controllers/concerns/fae/asset_cloner.rb +46 -0
- data/app/controllers/concerns/fae/cloneable.rb +136 -0
- data/app/controllers/fae/application_controller.rb +123 -0
- data/app/controllers/fae/base_controller.rb +117 -0
- data/app/controllers/fae/files_controller.rb +26 -0
- data/app/controllers/fae/images_controller.rb +37 -0
- data/app/controllers/fae/nested_base_controller.rb +100 -0
- data/app/controllers/fae/options_controller.rb +29 -0
- data/app/controllers/fae/pages_controller.rb +44 -0
- data/app/controllers/fae/setup_controller.rb +54 -0
- data/app/controllers/fae/static_pages_controller.rb +54 -0
- data/app/controllers/fae/users_controller.rb +71 -0
- data/app/controllers/fae/utilities_controller.rb +61 -0
- data/app/helpers/fae/application_helper.rb +114 -0
- data/app/helpers/fae/fae_helper.rb +6 -0
- data/app/helpers/fae/form_helper.rb +240 -0
- data/app/helpers/fae/nested_form_helper.rb +39 -0
- data/app/helpers/fae/view_helper.rb +175 -0
- data/app/inputs/date_range_input.rb +17 -0
- data/app/inputs/radio_collection_input.rb +17 -0
- data/app/inputs/symbol_input.rb +5 -0
- data/app/models/concerns/fae/assets_validatable.rb +12 -0
- data/app/models/concerns/fae/authorization_concern.rb +12 -0
- data/app/models/concerns/fae/base_model_concern.rb +105 -0
- data/app/models/concerns/fae/change_concern.rb +1 -0
- data/app/models/concerns/fae/file_concern.rb +1 -0
- data/app/models/concerns/fae/image_concern.rb +1 -0
- data/app/models/concerns/fae/navigation_concern.rb +10 -0
- data/app/models/concerns/fae/option_concern.rb +1 -0
- data/app/models/concerns/fae/page_validatable.rb +26 -0
- data/app/models/concerns/fae/paper_trailer.rb +8 -0
- data/app/models/concerns/fae/role_concern.rb +1 -0
- data/app/models/concerns/fae/sortable.rb +51 -0
- data/app/models/concerns/fae/static_page_concern.rb +1 -0
- data/app/models/concerns/fae/text_area_concern.rb +1 -0
- data/app/models/concerns/fae/text_field_concern.rb +1 -0
- data/app/models/concerns/fae/trackable.rb +124 -0
- data/app/models/concerns/fae/user_concern.rb +7 -0
- data/app/models/fae/authorization.rb +8 -0
- data/app/models/fae/change.rb +53 -0
- data/app/models/fae/file.rb +24 -0
- data/app/models/fae/image.rb +33 -0
- data/app/models/fae/navigation.rb +132 -0
- data/app/models/fae/option.rb +38 -0
- data/app/models/fae/role.rb +18 -0
- data/app/models/fae/static_page.rb +109 -0
- data/app/models/fae/text_area.rb +14 -0
- data/app/models/fae/text_field.rb +14 -0
- data/app/models/fae/user.rb +67 -0
- data/app/uploaders/fae/file_uploader.rb +26 -0
- data/app/uploaders/fae/image_uploader.rb +28 -0
- data/app/validators/fae/cross_model_uniqueness_validator.rb +14 -0
- data/app/views/devise/confirmations/new.html.slim +13 -0
- data/app/views/devise/mailer/confirmation_instructions.html.slim +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.slim +5 -0
- data/app/views/devise/mailer/unlock_instructions.html.slim +4 -0
- data/app/views/devise/passwords/edit.html.slim +10 -0
- data/app/views/devise/passwords/new.html.slim +10 -0
- data/app/views/devise/registrations/edit.html.slim +22 -0
- data/app/views/devise/registrations/new.html.slim +15 -0
- data/app/views/devise/sessions/new.html.slim +7 -0
- data/app/views/devise/shared/_links.slim +25 -0
- data/app/views/devise/unlocks/new.html.slim +13 -0
- data/app/views/fae/application/_breadcrumb.html.slim +19 -0
- data/app/views/fae/application/_content_form.html.slim +55 -0
- data/app/views/fae/application/_credit.slim +6 -0
- data/app/views/fae/application/_file_uploader.html.slim +36 -0
- data/app/views/fae/application/_flash_messages.slim +2 -0
- data/app/views/fae/application/_global_search_results.html.slim +37 -0
- data/app/views/fae/application/_header.slim +50 -0
- data/app/views/fae/application/_markdown_helper.slim +41 -0
- data/app/views/fae/application/_mobilenav.slim +66 -0
- data/app/views/fae/application/_sidenav.slim +23 -0
- data/app/views/fae/application/_user_log.html.slim +36 -0
- data/app/views/fae/images/_image_uploader.html.slim +66 -0
- data/app/views/fae/options/_form.html.slim +16 -0
- data/app/views/fae/options/edit.html.slim +1 -0
- data/app/views/fae/pages/activity_log.html.slim +32 -0
- data/app/views/fae/pages/disabled_environment.html.slim +4 -0
- data/app/views/fae/pages/error404.html.slim +7 -0
- data/app/views/fae/pages/help.html.slim +35 -0
- data/app/views/fae/pages/home.html.slim +36 -0
- data/app/views/fae/setup/first_user.html.slim +11 -0
- data/app/views/fae/shared/_errors.slim +4 -0
- data/app/views/fae/shared/_form_header.html.slim +40 -0
- data/app/views/fae/shared/_index_header.html.slim +26 -0
- data/app/views/fae/shared/_nested_table.html.slim +49 -0
- data/app/views/fae/shared/_recent_changes.html.slim +22 -0
- data/app/views/fae/shared/_shared_nested_table.html.slim +46 -0
- data/app/views/fae/static_pages/index.html.slim +13 -0
- data/app/views/fae/users/_form.html.slim +19 -0
- data/app/views/fae/users/edit.html.slim +1 -0
- data/app/views/fae/users/index.html.slim +23 -0
- data/app/views/fae/users/new.html.slim +1 -0
- data/app/views/fae/users/settings.html.slim +1 -0
- data/app/views/kaminari/fae/_gap.html.slim +8 -0
- data/app/views/kaminari/fae/_next_page.html.slim +9 -0
- data/app/views/kaminari/fae/_page.html.slim +15 -0
- data/app/views/kaminari/fae/_paginator.html.slim +15 -0
- data/app/views/kaminari/fae/_prev_page.html.slim +9 -0
- data/app/views/layouts/devise.html.slim +29 -0
- data/app/views/layouts/fae/application.html.slim +23 -0
- data/app/views/layouts/fae/error.html.slim +11 -0
- data/config/deploy.rb +73 -0
- data/config/deploy/dev.rb +19 -0
- data/config/deploy/prod.rb +19 -0
- data/config/deploy/stage.rb +19 -0
- data/config/initializers/assets.rb +1 -0
- data/config/initializers/carrierwave.rb +3 -0
- data/config/initializers/devise.rb +258 -0
- data/config/initializers/devise_monkeypatch.rb +11 -0
- data/config/initializers/fae_judge.rb +3 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/kaminari_config.rb +10 -0
- data/config/initializers/simple_form.rb +147 -0
- data/config/initializers/time_formats.rb +3 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/devise.zh-CN.yml +59 -0
- data/config/locales/fae.en.yml +10 -0
- data/config/locales/fae.zh-CN.yml +10 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/simple_form.zh-CN.yml +26 -0
- data/config/routes.rb +46 -0
- data/db/migrate/20140809222030_add_user_table.rb +49 -0
- data/db/migrate/20140822224029_create_fae_roles.rb +10 -0
- data/db/migrate/20141008180718_create_fae_images_table.rb +19 -0
- data/db/migrate/20141017194616_create_fae_options.rb +16 -0
- data/db/migrate/20141021181327_create_fae_files.rb +17 -0
- data/db/migrate/20141021183047_create_fae_text_areas.rb +16 -0
- data/db/migrate/20141021184311_create_fae_pages.rb +13 -0
- data/db/migrate/20141105214814_create_fae_text_fields.rb +15 -0
- data/db/migrate/20150930224821_create_fae_changes.rb +17 -0
- data/lib/fae-rails.rb +6 -0
- data/lib/fae/concerns/models/base.rb +8 -0
- data/lib/fae/engine.rb +37 -0
- data/lib/fae/options.rb +35 -0
- data/lib/fae/validation_helper_collection.rb +76 -0
- data/lib/fae/version.rb +3 -0
- data/lib/file_size_validator.rb +71 -0
- data/lib/generators/fae/base_generator.rb +156 -0
- data/lib/generators/fae/controller_generator.rb +13 -0
- data/lib/generators/fae/install_generator.rb +61 -0
- data/lib/generators/fae/model_generator.rb +11 -0
- data/lib/generators/fae/nested_index_scaffold_generator.rb +36 -0
- data/lib/generators/fae/nested_scaffold_generator.rb +51 -0
- data/lib/generators/fae/page_generator.rb +65 -0
- data/lib/generators/fae/scaffold_generator.rb +15 -0
- data/lib/generators/fae/templates/assets/fae.js +6 -0
- data/lib/generators/fae/templates/assets/fae.scss +2 -0
- data/lib/generators/fae/templates/controllers/nested_index_scaffold_controller.rb +81 -0
- data/lib/generators/fae/templates/controllers/nested_scaffold_controller.rb +13 -0
- data/lib/generators/fae/templates/controllers/scaffold_controller.rb +13 -0
- data/lib/generators/fae/templates/controllers/static_pages_controller.rb +10 -0
- data/lib/generators/fae/templates/initializers/fae.rb +63 -0
- data/lib/generators/fae/templates/initializers/fae_fine.rb +51 -0
- data/lib/generators/fae/templates/initializers/judge.rb +6 -0
- data/lib/generators/fae/templates/models/concerns/authorization_concern.rb +27 -0
- data/lib/generators/fae/templates/models/concerns/navigation_concern.rb +33 -0
- data/lib/generators/fae/templates/models/pages_model.rb +14 -0
- data/lib/generators/fae/templates/tasks/fae_tasks.rake +19 -0
- data/lib/generators/fae/templates/views/_form.html.slim +18 -0
- data/lib/generators/fae/templates/views/_form_index_nested.html.slim +13 -0
- data/lib/generators/fae/templates/views/_form_nested.html.slim +17 -0
- data/lib/generators/fae/templates/views/edit.html.slim +1 -0
- data/lib/generators/fae/templates/views/edit_nested.html.slim +3 -0
- data/lib/generators/fae/templates/views/index.html.slim +35 -0
- data/lib/generators/fae/templates/views/index_nested.html.slim +8 -0
- data/lib/generators/fae/templates/views/new.html.slim +1 -0
- data/lib/generators/fae/templates/views/new_nested.html.slim +3 -0
- data/lib/generators/fae/templates/views/static_page_form.html.slim +15 -0
- data/lib/generators/fae/templates/views/table_nested.html.slim +4 -0
- metadata +692 -0
@@ -0,0 +1,89 @@
|
|
1
|
+
/* global Fae */
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Fae navigation language
|
5
|
+
* @namespace navigation.language
|
6
|
+
* @memberof navigation
|
7
|
+
*/
|
8
|
+
Fae.navigation.language = {
|
9
|
+
|
10
|
+
el: {},
|
11
|
+
|
12
|
+
init: function(options, elm){
|
13
|
+
/** Stores shared jQuery objects in Fae.navigation.language.el */
|
14
|
+
this.el.$select = $('#js-language');
|
15
|
+
this.el.$lang_divs = $('div[data-language]');
|
16
|
+
|
17
|
+
if (this.el.$select.length) {
|
18
|
+
this.setInitialState();
|
19
|
+
this.addNavEvents();
|
20
|
+
}
|
21
|
+
},
|
22
|
+
|
23
|
+
/**
|
24
|
+
* Reads the language of the active toggle on load and shows the corresponding fields
|
25
|
+
*/
|
26
|
+
setInitialState: function() {
|
27
|
+
var lang = this.el.$select.find('option[selected]').val();
|
28
|
+
this._toggleLanguageFields(lang, 0);
|
29
|
+
},
|
30
|
+
|
31
|
+
/**
|
32
|
+
* On change of the select field, change the language displayed
|
33
|
+
* @has_test {spec/features/language_nav_spec.rb}
|
34
|
+
*/
|
35
|
+
addNavEvents: function() {
|
36
|
+
var _this = this;
|
37
|
+
|
38
|
+
_this.el.$select.on('change', function(ev) {
|
39
|
+
ev.preventDefault();
|
40
|
+
|
41
|
+
var $this = $(this);
|
42
|
+
var lang = $this.val();
|
43
|
+
|
44
|
+
_this._toggleLanguageFields(lang, 200);
|
45
|
+
|
46
|
+
// POSTs to Utilities#language_preference to save user's language preference
|
47
|
+
lang = lang || 'all'
|
48
|
+
var post_url = Fae.path + '/language_preference/' + lang;
|
49
|
+
$.post(post_url);
|
50
|
+
|
51
|
+
// Fade out extra error messages
|
52
|
+
$('.hidden_errors').fadeOut(200, function() {
|
53
|
+
$(this).remove();
|
54
|
+
});
|
55
|
+
});
|
56
|
+
},
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Hides all language fields and fades in ones according to language
|
60
|
+
* @protected
|
61
|
+
* @param {String} lang - Language of fields to fade in
|
62
|
+
* @param {Number} speed - Speed of the fade transitions in ms
|
63
|
+
* @has_test {spec/features/language_nav_spec.rb}
|
64
|
+
*/
|
65
|
+
_toggleLanguageFields: function(lang, speed) {
|
66
|
+
var _this = this;
|
67
|
+
|
68
|
+
_this.el.$lang_divs
|
69
|
+
.fadeOut(speed)
|
70
|
+
.promise()
|
71
|
+
.done(function() {
|
72
|
+
if (lang) {
|
73
|
+
$('div[data-language='+lang+']').fadeIn(speed);
|
74
|
+
} else {
|
75
|
+
_this.el.$lang_divs.fadeIn(speed);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
},
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Called on form validation; checks for hidden fields with errors and displays a message
|
82
|
+
* @see {@link form.validator.formValidate}
|
83
|
+
*/
|
84
|
+
checkForHiddenErrors: function() {
|
85
|
+
if (this.el.$select.length && $('div.field_with_errors:hidden').length && !FCH.exists('.hidden_errors')) {
|
86
|
+
$('.content').prepend('<div class="hidden_errors field_with_errors"><span class="error">There are hidden errors. Click "All Languages" in the language nav to view all errors.</span></div>');
|
87
|
+
}
|
88
|
+
}
|
89
|
+
};
|
@@ -0,0 +1,206 @@
|
|
1
|
+
/* global Fae, FCH */
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Fae navigation
|
5
|
+
* @namespace navigation
|
6
|
+
* @memberof Fae
|
7
|
+
*/
|
8
|
+
Fae.navigation = {
|
9
|
+
|
10
|
+
ready: function() {
|
11
|
+
this.fadeNotices();
|
12
|
+
this.openDrawer();
|
13
|
+
this.clickBack();
|
14
|
+
this.accordionClickEventListener();
|
15
|
+
|
16
|
+
this.language.init();
|
17
|
+
this.subnav_highlighter.init();
|
18
|
+
this.global_search.init();
|
19
|
+
},
|
20
|
+
|
21
|
+
load: function() {
|
22
|
+
this.stickyHeaders();
|
23
|
+
this.lockFooter();
|
24
|
+
},
|
25
|
+
|
26
|
+
resize: function() {
|
27
|
+
this.closeAll(false);
|
28
|
+
this.lockFooter();
|
29
|
+
},
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Attach click listener to main and sub links
|
33
|
+
* @has_test {features/nav_spec.rb}
|
34
|
+
*/
|
35
|
+
accordionClickEventListener: function() {
|
36
|
+
var _this = this;
|
37
|
+
|
38
|
+
$('.js-accordion > a').click(function(e) {
|
39
|
+
e.preventDefault();
|
40
|
+
|
41
|
+
var $parent = $(this).closest('.js-accordion');
|
42
|
+
var was_open = $parent.hasClass('-open');
|
43
|
+
|
44
|
+
// close all first
|
45
|
+
// only get the first class name and add a leading period
|
46
|
+
$parent.siblings().each(function() {
|
47
|
+
_this.close($(this));
|
48
|
+
});
|
49
|
+
|
50
|
+
if (was_open) {
|
51
|
+
var $sub_accordions = $parent.find('.js-accordion');
|
52
|
+
|
53
|
+
// Close all nested accordions
|
54
|
+
if($sub_accordions.length) {
|
55
|
+
$sub_accordions.each(function() {
|
56
|
+
_this.close($(this));
|
57
|
+
});
|
58
|
+
}
|
59
|
+
|
60
|
+
// Close original accordion
|
61
|
+
_this.close($parent);
|
62
|
+
|
63
|
+
} else {
|
64
|
+
// open the clicked item if it was not just opened
|
65
|
+
_this.open($parent);
|
66
|
+
}
|
67
|
+
|
68
|
+
});
|
69
|
+
},
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Open accordion panel
|
73
|
+
* @protected
|
74
|
+
* @param {jQuery} $el - Accordion wrapper
|
75
|
+
*/
|
76
|
+
open: function($el) {
|
77
|
+
$el.addClass('-open');
|
78
|
+
|
79
|
+
if(FCH.bp.large) {
|
80
|
+
$el.find('.js-subnav').first().stop().slideDown();
|
81
|
+
}
|
82
|
+
},
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Close accordion panel
|
86
|
+
* @protected
|
87
|
+
* @param {jQuery} $el - Accordion wrapper
|
88
|
+
*/
|
89
|
+
close: function($el) {
|
90
|
+
if(FCH.bp.large) {
|
91
|
+
$el.find('.js-subnav')
|
92
|
+
.first()
|
93
|
+
.stop()
|
94
|
+
.slideUp()
|
95
|
+
.queue(function() {
|
96
|
+
// Remove class after animation
|
97
|
+
$el.removeClass('-open');
|
98
|
+
$.dequeue( this );
|
99
|
+
});
|
100
|
+
} else {
|
101
|
+
$el.removeClass('-open');
|
102
|
+
}
|
103
|
+
},
|
104
|
+
|
105
|
+
/**
|
106
|
+
* Close main level navs
|
107
|
+
* @param {Boolean} nuclear - Slide up drawers too
|
108
|
+
* @see {@link resize}
|
109
|
+
* @see {@link openDrawer}
|
110
|
+
*/
|
111
|
+
closeAll: function(nuclear) {
|
112
|
+
var _this = this;
|
113
|
+
$('html').removeClass( 'mobile-active' );
|
114
|
+
|
115
|
+
$('.js-accordion').each(function(){
|
116
|
+
var $this = $(this);
|
117
|
+
|
118
|
+
$this.removeClass('-open');
|
119
|
+
|
120
|
+
if(nuclear) {
|
121
|
+
_this.close( $this );
|
122
|
+
}
|
123
|
+
});
|
124
|
+
},
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Mobile - Push body over and display nav
|
128
|
+
*/
|
129
|
+
openDrawer: function() {
|
130
|
+
var $html = $('html');
|
131
|
+
|
132
|
+
$('#js-mobilenav-toggle').click(function(e){
|
133
|
+
e.preventDefault();
|
134
|
+
|
135
|
+
if ($html.hasClass( 'mobile-active' )) {
|
136
|
+
Fae.navigation.closeAll(true);
|
137
|
+
} else {
|
138
|
+
$html.addClass( 'mobile-active' );
|
139
|
+
}
|
140
|
+
});
|
141
|
+
},
|
142
|
+
|
143
|
+
/**
|
144
|
+
* Mobile - Collapse sub headers on sub nav click
|
145
|
+
*/
|
146
|
+
clickBack: function() {
|
147
|
+
$('.js-mobile-back').click(function(e){
|
148
|
+
e.preventDefault();
|
149
|
+
|
150
|
+
$(this)
|
151
|
+
.closest('.js-accordion')
|
152
|
+
.removeClass('-open');
|
153
|
+
});
|
154
|
+
},
|
155
|
+
|
156
|
+
/**
|
157
|
+
* Hide main-page alerts after 3 seconds
|
158
|
+
*/
|
159
|
+
fadeNotices: function() {
|
160
|
+
$('.notice, .alert, .error, .warning').not('.input .error, .form_alert').delay(3000).slideUp('fast');
|
161
|
+
},
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Stick the header in the content area
|
165
|
+
* @param {Boolean} [just_headers=false] Only initialize stickiness for `.js-content-header`
|
166
|
+
*/
|
167
|
+
stickyHeaders: function(just_headers) {
|
168
|
+
just_headers = FCH.setDefault(just_headers, false);
|
169
|
+
|
170
|
+
var $header = $('.js-content-header');
|
171
|
+
var sidebar_top_offset = (parseInt( $header.outerHeight(), 10) + 30) + 'px';
|
172
|
+
$('#js-sidenav').css('padding-top', sidebar_top_offset );
|
173
|
+
|
174
|
+
$header.sticky({
|
175
|
+
placeholder: true,
|
176
|
+
perpetual_placeholder: true,
|
177
|
+
ignore_placeholder_offsets: true
|
178
|
+
});
|
179
|
+
|
180
|
+
if (!just_headers) {
|
181
|
+
$('#js-sidenav').sticky();
|
182
|
+
}
|
183
|
+
},
|
184
|
+
|
185
|
+
/**
|
186
|
+
* Fix footer to bottom of screen if viewport extends beyond content. Display after calculation has been performed
|
187
|
+
*/
|
188
|
+
lockFooter: function() {
|
189
|
+
if(FCH.exists('#js-footer')) {
|
190
|
+
var $footer = $('#js-footer');
|
191
|
+
|
192
|
+
// Reset
|
193
|
+
$footer.removeClass('active');
|
194
|
+
|
195
|
+
// Lock or unlock
|
196
|
+
if ($footer.offset().top < (FCH.dimensions.wh - $footer.outerHeight()) ) {
|
197
|
+
$footer.addClass('-locked');
|
198
|
+
} else {
|
199
|
+
$footer.removeClass('-locked');
|
200
|
+
}
|
201
|
+
|
202
|
+
$footer.addClass('active');
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
};
|
@@ -0,0 +1,81 @@
|
|
1
|
+
/* global Fae, FCH */
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Fae navigation subnav highlighter
|
5
|
+
* @namespace navigation.subnav_highlighter
|
6
|
+
* @memberof navigation
|
7
|
+
*/
|
8
|
+
Fae.navigation.subnav_highlighter = {
|
9
|
+
init: function() {
|
10
|
+
//only run everything if there is a subnav area
|
11
|
+
if (FCH.exists('.content-header-subnav')) {
|
12
|
+
this.FCHListeners();
|
13
|
+
|
14
|
+
//makes the subnav clicks
|
15
|
+
this.anchorClickListener();
|
16
|
+
}
|
17
|
+
},
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Since subnavHighlighter is not a direct child of Fae and therefore unknown to FCH, these listeners are saved in private functions in this method
|
21
|
+
*/
|
22
|
+
FCHListeners: function() {
|
23
|
+
/**
|
24
|
+
* On scroll, change highlight of nav item. Bread and butter of this subclass.
|
25
|
+
* @private
|
26
|
+
*/
|
27
|
+
function scrollCallback() {
|
28
|
+
var scroll_top = FCH.$window.scrollTop();
|
29
|
+
|
30
|
+
$('.content').each(function(index) {
|
31
|
+
var $this = $(this);
|
32
|
+
var position = $this.position().top - scroll_top;
|
33
|
+
var $link = $('a[href="#' + $this.attr('id') + '"]').parent();
|
34
|
+
var is_scrolled_to_bottom = scroll_top >= (FCH.$document.outerHeight() - FCH.dimensions.wh);
|
35
|
+
|
36
|
+
$link.removeClass('-active');
|
37
|
+
if (position <= 0 || index === 0 || is_scrolled_to_bottom) {
|
38
|
+
$link.addClass('js-highlighter');
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
$('.js-highlighter').last().addClass('-active').removeClass('js-highlighter');
|
43
|
+
}
|
44
|
+
|
45
|
+
// highlight the first one on page load
|
46
|
+
scrollCallback();
|
47
|
+
FCH.scroll.push(scrollCallback);
|
48
|
+
},
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Smooth scrolling on anchor links in the tab area.
|
52
|
+
*/
|
53
|
+
anchorClickListener: function() {
|
54
|
+
var scroll_offset = parseInt( $('.content-header').css('height'), 10 );
|
55
|
+
|
56
|
+
/**
|
57
|
+
* Smoothly scroll to destination if it's a link to the current page
|
58
|
+
* @private
|
59
|
+
* @param {Object} el - JavaScript element to scroll to
|
60
|
+
*/
|
61
|
+
function scroller(e) {
|
62
|
+
e.preventDefault();
|
63
|
+
|
64
|
+
if (location.pathname.replace(/^\//,'') === this.pathname.replace(/^\//,'') && location.hostname === this.hostname) {
|
65
|
+
var $target = $(this.hash);
|
66
|
+
$target = $target.length ? $target : $('[name=' + this.hash.slice(1) + ']');
|
67
|
+
|
68
|
+
if($target.find('h2').length) {
|
69
|
+
$target = $target.find('h2');
|
70
|
+
scroll_offset -= 2;
|
71
|
+
}
|
72
|
+
|
73
|
+
if ($target.length) {
|
74
|
+
FCH.smoothScroll($target, 500, 0, -scroll_offset);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
|
79
|
+
$('#js-content-header-subnav a').on('click', scroller);
|
80
|
+
},
|
81
|
+
};
|
@@ -0,0 +1,186 @@
|
|
1
|
+
/* global FCH */
|
2
|
+
|
3
|
+
(function ( $ ) {
|
4
|
+
'use strict';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* Adjust offsets
|
8
|
+
* @private
|
9
|
+
* @param {jQuery} $el
|
10
|
+
* @see Sticky.windowListeners
|
11
|
+
*/
|
12
|
+
function setDimensionsTopLeft($el) {
|
13
|
+
this.dimensions.top = $el.offset().top - this.options.offset;
|
14
|
+
this.dimensions.left = $el.offset().left;
|
15
|
+
}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* Private initialization of Sticky object.
|
19
|
+
* @class
|
20
|
+
*/
|
21
|
+
function Sticky($el, options) {
|
22
|
+
/** @type {jQuery} */
|
23
|
+
this.$el = $el;
|
24
|
+
|
25
|
+
/** Inherited settings from jQuery initialization */
|
26
|
+
this.options = options;
|
27
|
+
|
28
|
+
// capture dimensions
|
29
|
+
// If a placeholder exists, use it
|
30
|
+
this.dimensions = {
|
31
|
+
top: $el.offset().top - this.options.offset,
|
32
|
+
left: $el.offset().left
|
33
|
+
};
|
34
|
+
|
35
|
+
var height = $el.outerHeight();
|
36
|
+
$el.addClass('js-will-be-sticky');
|
37
|
+
|
38
|
+
// create a placeholder
|
39
|
+
if (this.options.placeholder) {
|
40
|
+
this.createPlaceholder(height);
|
41
|
+
}
|
42
|
+
|
43
|
+
// run the initial stickIt
|
44
|
+
this.stickIt();
|
45
|
+
|
46
|
+
// bind events
|
47
|
+
this.windowListeners();
|
48
|
+
|
49
|
+
return this;
|
50
|
+
}
|
51
|
+
|
52
|
+
/**
|
53
|
+
* Create a placeholder element to use to keep the top spacing
|
54
|
+
* @param {Number} height - Size of stuck element
|
55
|
+
*/
|
56
|
+
Sticky.prototype.createPlaceholder = function(height) {
|
57
|
+
var css_properties = {
|
58
|
+
height: height,
|
59
|
+
visibility: 'hidden'
|
60
|
+
};
|
61
|
+
|
62
|
+
if(!this.options.perpetual_placeholder) {
|
63
|
+
css_properties.display = 'none';
|
64
|
+
}
|
65
|
+
|
66
|
+
var $placeholder = $('<div />', {
|
67
|
+
class: this.options.placeholder_class,
|
68
|
+
css: css_properties
|
69
|
+
});
|
70
|
+
|
71
|
+
$placeholder.insertAfter(this.$el);
|
72
|
+
|
73
|
+
// save for reference later
|
74
|
+
this.$placeholder = $placeholder;
|
75
|
+
};
|
76
|
+
|
77
|
+
/**
|
78
|
+
* On window scroll, check to make sure the screen is larger than table and if it isn't, unstick it
|
79
|
+
* @fires stickItLogic (Conditionally)
|
80
|
+
* @fires _unStick (Conditionally)
|
81
|
+
*/
|
82
|
+
Sticky.prototype.stickIt = function() {
|
83
|
+
if (FCH.bp.large) {
|
84
|
+
this._stickItLogic();
|
85
|
+
} else {
|
86
|
+
this._unStick();
|
87
|
+
}
|
88
|
+
};
|
89
|
+
|
90
|
+
/**
|
91
|
+
* Fix sticky element to top of page if it's past originally-set boundary.
|
92
|
+
* @access protected
|
93
|
+
* @fires _unStick (Conditionally)
|
94
|
+
* @see stickIt
|
95
|
+
*/
|
96
|
+
Sticky.prototype._stickItLogic = function() {
|
97
|
+
if (FCH.$window.scrollTop() >= this.dimensions.top) {
|
98
|
+
if (this.options.placeholder) {
|
99
|
+
this.$placeholder.show();
|
100
|
+
}
|
101
|
+
|
102
|
+
this.$el
|
103
|
+
.addClass(this.options.class_name)
|
104
|
+
.css({
|
105
|
+
left: this.dimensions.left,
|
106
|
+
position: 'fixed'
|
107
|
+
});
|
108
|
+
} else {
|
109
|
+
this._unStick();
|
110
|
+
}
|
111
|
+
};
|
112
|
+
|
113
|
+
/**
|
114
|
+
* Remove active class and fixed styles from targeted element; hide placeholder
|
115
|
+
*/
|
116
|
+
Sticky.prototype._unStick = function() {
|
117
|
+
this.$el
|
118
|
+
.removeClass(this.options.class_name)
|
119
|
+
.css({
|
120
|
+
left: '',
|
121
|
+
position: ''
|
122
|
+
});
|
123
|
+
|
124
|
+
if (this.options.placeholder && !this.options.perpetual_placeholder) {
|
125
|
+
this.$placeholder.hide();
|
126
|
+
}
|
127
|
+
};
|
128
|
+
|
129
|
+
/**
|
130
|
+
* Listen for scroll and smartresize to stick or unstick element
|
131
|
+
*/
|
132
|
+
Sticky.prototype.windowListeners = function() {
|
133
|
+
var _this = this;
|
134
|
+
|
135
|
+
function scrollCallback() {
|
136
|
+
_this.stickIt();
|
137
|
+
}
|
138
|
+
|
139
|
+
function resizePlaceholder() {
|
140
|
+
_this.$placeholder.css( 'height', _this.$el.outerHeight() );
|
141
|
+
}
|
142
|
+
|
143
|
+
function debounceResizeCallback() {
|
144
|
+
if ( _this.$placeholder && !_this.options.ignore_placeholder_offsets && _this.$placeholder.is(':visible')) {
|
145
|
+
setDimensionsTopLeft.call(_this, _this.$placeholder);
|
146
|
+
} else {
|
147
|
+
setDimensionsTopLeft.call(_this, _this.$el);
|
148
|
+
}
|
149
|
+
|
150
|
+
_this.stickIt();
|
151
|
+
}
|
152
|
+
|
153
|
+
FCH.scroll.push( scrollCallback );
|
154
|
+
FCH.resize.push( FCH.debounce( debounceResizeCallback ) );
|
155
|
+
|
156
|
+
debounceResizeCallback();
|
157
|
+
|
158
|
+
if (this.options.placeholder) {
|
159
|
+
FCH.resize.push( resizePlaceholder );
|
160
|
+
}
|
161
|
+
};
|
162
|
+
|
163
|
+
/**
|
164
|
+
* Stick elements within the viewport
|
165
|
+
* @function external:'jQuery.fn'.sticky
|
166
|
+
*/
|
167
|
+
$.fn.sticky = function( options ) {
|
168
|
+
var defaults = {
|
169
|
+
class_name: 'js-sticky',
|
170
|
+
placeholder_class: 'js-sticky-placeholder',
|
171
|
+
placeholder: false,
|
172
|
+
ignore_placeholder_offsets: false,
|
173
|
+
offset: 0,
|
174
|
+
perpetual_placeholder: false
|
175
|
+
};
|
176
|
+
|
177
|
+
// unite the default options with the passed-in ones
|
178
|
+
var settings = $.extend( {}, defaults, options );
|
179
|
+
|
180
|
+
return this.each(function() {
|
181
|
+
var sticker = new Sticky($(this), settings);
|
182
|
+
});
|
183
|
+
|
184
|
+
};
|
185
|
+
|
186
|
+
}( jQuery ));
|