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,2 @@
|
|
1
|
+
/* Chosen v1.0.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
|
2
|
+
!function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),children:0,disabled:a.disabled}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"<",">":">",'"':""","'":"'","`":"`"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.result_single_selected=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0},AbstractChosen.prototype.set_default_text=function(){return this.default_text=this.form_field.getAttribute("data-placeholder")?this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(){var a=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return a.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(){var a=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return a.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f;for(b="",f=this.results_data,d=0,e=f.length;e>d;d++)c=f[d],b+=c.group?this.result_add_group(c):this.result_add_option(c),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(c.text));return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match?this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=""!==a.style.cssText?' style="'+a.style+'"':"",'<li class="'+b.join(" ")+'"'+c+' data-option-array-index="'+a.array_index+'">'+a.search_text+"</li>"):"":""},AbstractChosen.prototype.result_add_group=function(a){return a.search_match||a.group_match?a.active_options>0?'<li class="group-result">'+a.search_text+"</li>":"":""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.result_single_selected=null,this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l,m;for(this.no_results_clear(),e=0,g=this.get_search_text(),a=g.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),d=this.search_contains?"":"^",c=new RegExp(d+a,"i"),j=new RegExp(a,"i"),m=this.results_data,k=0,l=m.length;l>k;k++)b=m[k],b.search_match=!1,f=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(f=this.results_data[b.group_array_index],0===f.active_options&&f.search_match&&(e+=1),f.active_options+=1),(!b.group||this.group_search)&&(b.search_text=b.group?b.label:b.html,b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(e+=1),b.search_match?(g.length&&(h=b.search_text.search(j),i=b.search_text.substr(0,h+g.length)+"</em>"+b.search_text.substr(h+g.length),b.search_text=i.substr(0,h)+"<em>"+i.substr(h)),null!=f&&(f.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>e&&g.length?(this.update_results_content(""),this.no_results(g)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:break;default:return this.results_search()}},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.browser_is_supported=function(){return"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(){var c,d;c=a(this),d=c.data("chosen"),"destroy"===b&&d?d.destroy():d||c.data("chosen",new Chosen(this,b))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default" tabindex="-1"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior(),this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(document).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(document).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b,c,d;return b=-(null!=(c=a.originalEvent)?c.wheelDelta:void 0)||(null!=(d=a.originialEvent)?d.detail:void 0),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(document).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){return this.container.is(a(b.target).closest(".chosen-container"))?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results())},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(){var a;return this.form_field.tabIndex?(a=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=a):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+b.html+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.form_field.options[0].selected=!0,this.selected_option_count=null,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c,d;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):(this.result_single_selected&&(this.result_single_selected.removeClass("result-selected"),d=this.result_single_selected[0].getAttribute("data-option-array-index"),this.results_data[d].selected=!1),this.result_single_selected=b),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(c.text),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.search_field.val(""),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").text(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return this.search_field.val()===this.default_text?"":a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c)},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}.call(this);
|
@@ -0,0 +1,587 @@
|
|
1
|
+
/*!
|
2
|
+
* FrobCoreHelpers v1.1
|
3
|
+
* A framework for front (frob) enders (tenders) everywhere
|
4
|
+
* MIT License
|
5
|
+
*/
|
6
|
+
|
7
|
+
(function (window, factory) {
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
define([], factory(window));
|
12
|
+
} else if (typeof exports === 'object') {
|
13
|
+
module.exports = factory(window);
|
14
|
+
} else {
|
15
|
+
window.FrobCoreHelpers = factory(window);
|
16
|
+
}
|
17
|
+
|
18
|
+
})(window, function factory(window) {
|
19
|
+
'use strict';
|
20
|
+
|
21
|
+
var custom_breakpoints;
|
22
|
+
|
23
|
+
var defaults = {
|
24
|
+
mobile_fps: true,
|
25
|
+
breakpoints: null,
|
26
|
+
preserve_breakpoints: true
|
27
|
+
};
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Holder for responsive breakpoints, set on load and reset on resize
|
31
|
+
* @property {Boolean} small - Window width is less than 768
|
32
|
+
* @property {Boolean} small_up - Window width is greater than 767
|
33
|
+
* @property {Boolean} medium_portrait - Window width is between 767 and 960
|
34
|
+
* @property {Boolean} medium - Window width is between 767 and 1025
|
35
|
+
* @property {Boolean} large_down - Window width is less than 1024
|
36
|
+
* @property {Boolean} large - Window width is greater than 1024
|
37
|
+
* @return {Object}
|
38
|
+
*/
|
39
|
+
function defaultBreakpoints(ww) {
|
40
|
+
return {
|
41
|
+
small: ww < 768,
|
42
|
+
small_up: ww > 767,
|
43
|
+
medium_portrait: ww > 767 && ww < 960,
|
44
|
+
medium: ww > 767 && ww < 1025,
|
45
|
+
large_down: ww < 1024,
|
46
|
+
large: ww > 1024
|
47
|
+
};
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Set a callback that merges the default and original breakpoint listeners
|
52
|
+
* @protected
|
53
|
+
* @param {Integer} ww - Window width as called back in this.screenSizes
|
54
|
+
* @param {Integer} wh - Window height as called back in this.screenSizes
|
55
|
+
* @see FrobCoreHelpers#screenSizes
|
56
|
+
* @return {Object}
|
57
|
+
*/
|
58
|
+
function mergeBreakpoints(ww, wh) {
|
59
|
+
var breakpoints_combined = [defaultBreakpoints(ww, wh), custom_breakpoints(ww, wh)];
|
60
|
+
|
61
|
+
// Empty object to hold combined keys. Custom will override default if using same key
|
62
|
+
var new_breakpoints = {};
|
63
|
+
|
64
|
+
// Loop through both functions and their keys
|
65
|
+
for(var i = 0; i < breakpoints_combined.length; i++) {
|
66
|
+
var breakpoint_wrapper = breakpoints_combined[i];
|
67
|
+
var keys = Object.keys(breakpoint_wrapper);
|
68
|
+
|
69
|
+
for(var x = 0; x < keys.length; x++) {
|
70
|
+
var key = keys[x];
|
71
|
+
|
72
|
+
// Add to object
|
73
|
+
new_breakpoints[key] = breakpoint_wrapper[key];
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
return new_breakpoints;
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Combine default options with custom ones
|
82
|
+
* @private
|
83
|
+
* @param {Object} options - Key/value object to override `defaults` object
|
84
|
+
* @return {Object}
|
85
|
+
*/
|
86
|
+
function applyDefaults(options) {
|
87
|
+
var default_keys = Object.keys(defaults);
|
88
|
+
|
89
|
+
// Loop through default params
|
90
|
+
for(var i = 0; i < default_keys.length; i++) {
|
91
|
+
var key = default_keys[i];
|
92
|
+
|
93
|
+
// If options does not have the default key, apply it
|
94
|
+
if(!options.hasOwnProperty(key)) {
|
95
|
+
options[key] = defaults[key];
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
return options;
|
100
|
+
}
|
101
|
+
|
102
|
+
/**
|
103
|
+
* Attach hooks on child objects to the listener arrays
|
104
|
+
* @private
|
105
|
+
* @param {String} listener - Such as 'resize' or 'load'
|
106
|
+
* @param {Object} jsHolder - The main JavaScript object being queried; adds functionality for DOM callbacks to all children
|
107
|
+
* @see {@link FCH.init}
|
108
|
+
*/
|
109
|
+
function attachChildListeners(listener, jsHolder) {
|
110
|
+
var kids = Object.keys(jsHolder);
|
111
|
+
|
112
|
+
// Go through all child objects on the holder
|
113
|
+
for(var i = 0; i < kids.length; i++) {
|
114
|
+
var kid = kids[i];
|
115
|
+
var child = jsHolder[kid];
|
116
|
+
|
117
|
+
if( child.hasOwnProperty(listener) ) {
|
118
|
+
var child_func = child[listener];
|
119
|
+
|
120
|
+
child_func.prototype = child;
|
121
|
+
this[listener].push( child_func );
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
/**
|
127
|
+
* Fire events more efficiently
|
128
|
+
* @private
|
129
|
+
* @param {String} type - Listener function to trump
|
130
|
+
* @param {String} name - New name for listener
|
131
|
+
* @param {Object} obj - Object to bind/watch (defaults to window)
|
132
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/Events/scroll}
|
133
|
+
*/
|
134
|
+
function throttle(type, name, obj) {
|
135
|
+
obj = obj || window;
|
136
|
+
var running = false;
|
137
|
+
|
138
|
+
var func = function() {
|
139
|
+
if (running) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
running = true;
|
143
|
+
requestAnimationFrame(function() {
|
144
|
+
obj.dispatchEvent(new CustomEvent(name));
|
145
|
+
running = false;
|
146
|
+
});
|
147
|
+
};
|
148
|
+
|
149
|
+
obj.addEventListener(type, func);
|
150
|
+
}
|
151
|
+
|
152
|
+
/**
|
153
|
+
* Execute listeners using the bundled arrays
|
154
|
+
* @private
|
155
|
+
* @param {String} listener - What to hear for, i.e. scroll, resize
|
156
|
+
*/
|
157
|
+
function callListener(listener) {
|
158
|
+
var listener_array = this[listener];
|
159
|
+
|
160
|
+
for(var x = 0; x < listener_array.length; x++) {
|
161
|
+
listener_array[x].call( listener_array[x].prototype );
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
/**
|
166
|
+
* Actually bind the listeners to objects
|
167
|
+
* @private
|
168
|
+
*/
|
169
|
+
function attachListeners() {
|
170
|
+
var listener = 'optimized';
|
171
|
+
var _this = this;
|
172
|
+
|
173
|
+
// Optimized fires a more effective listener but the method isn't supported in all browsers
|
174
|
+
if(typeof CustomEvent === 'function') {
|
175
|
+
throttle('resize', 'optimizedresize');
|
176
|
+
throttle('scroll', 'optimizedscroll');
|
177
|
+
} else {
|
178
|
+
listener = '';
|
179
|
+
}
|
180
|
+
|
181
|
+
window.addEventListener(listener + 'scroll', function() {
|
182
|
+
callListener.call(_this, 'scroll');
|
183
|
+
});
|
184
|
+
window.addEventListener(listener + 'resize', function() {
|
185
|
+
callListener.call(_this, 'resize');
|
186
|
+
});
|
187
|
+
document.addEventListener('DOMContentLoaded', function() {
|
188
|
+
callListener.call(_this, 'ready');
|
189
|
+
});
|
190
|
+
window.addEventListener('load', function() {
|
191
|
+
callListener.call(_this, 'load');
|
192
|
+
});
|
193
|
+
}
|
194
|
+
|
195
|
+
/**
|
196
|
+
* @private
|
197
|
+
* @see {@link FrobCoreHelpers#hasClass documentation in the public `hasClass` function}
|
198
|
+
*/
|
199
|
+
function hasClass(el, cls) {
|
200
|
+
return !!el.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
|
201
|
+
}
|
202
|
+
|
203
|
+
/**
|
204
|
+
* @private
|
205
|
+
* @see {@link FrobCoreHelpers#addClass documentation in the public `addClass` function}
|
206
|
+
*/
|
207
|
+
function addClass(el, cls) {
|
208
|
+
if (!hasClass(el, cls)) {
|
209
|
+
el.className = el.className.trim();
|
210
|
+
el.className += ' ' + cls;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
/**
|
215
|
+
* @private
|
216
|
+
* @see {@link FrobCoreHelpers#removeClass documentation in the public `removeClass` function}
|
217
|
+
*/
|
218
|
+
function removeClass(el, cls) {
|
219
|
+
if (hasClass(el, cls)) {
|
220
|
+
var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
|
221
|
+
el.className = el.className.replace(reg, ' ');
|
222
|
+
}
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Start everything up
|
227
|
+
* @class
|
228
|
+
* @param {Object} jsHolder - The main JavaScript object being queried; adds functionality for DOM callbacks to all children
|
229
|
+
* @param {Object} [options={}] - Custom options
|
230
|
+
* @property {Boolean} [mobile_fps=true] - Attach the scroll listener for `u-disable-hover`
|
231
|
+
* @property {Function} [breakpoints=null] - To set custom breakpoint, pass a function with two args and return a `string: boolean` object
|
232
|
+
* @property {Integer} ww - Window width
|
233
|
+
* @property {Integer} wh - Window height
|
234
|
+
* @return {Object} - key is identifier, i.e. small; value is a comparison, i.e. ww < 767
|
235
|
+
* @property {Boolean} [preserve_breakpoints=true] - Merge custom breakpoints with default breakpoints
|
236
|
+
* @example
|
237
|
+
* var FC = {
|
238
|
+
* ui: {
|
239
|
+
* resize: function() { ... }
|
240
|
+
* }
|
241
|
+
* }
|
242
|
+
* new FrobCoreHelpers(FC);
|
243
|
+
* @return {FrobCoreHelpers}
|
244
|
+
*/
|
245
|
+
function FrobCoreHelpers(jsHolder, options) {
|
246
|
+
options = this.setDefault(options, {});
|
247
|
+
|
248
|
+
var dimensionsBreakpointsListener = this.screenSizes();
|
249
|
+
|
250
|
+
/** @type {Object} */
|
251
|
+
this.options = applyDefaults(options);
|
252
|
+
|
253
|
+
/* Listener Arrays */
|
254
|
+
/** @type {Array.<function>} */
|
255
|
+
this.resize = [];
|
256
|
+
/** @type {Array.<function>} */
|
257
|
+
this.scroll = [];
|
258
|
+
/** @type {Array.<function>} */
|
259
|
+
this.ready = [];
|
260
|
+
/** @type {Array.<function>} */
|
261
|
+
this.load = [];
|
262
|
+
|
263
|
+
// IE detection
|
264
|
+
this.IE10 = this.isIE(10);
|
265
|
+
this.IE9 = this.isIE(9);
|
266
|
+
this.anyIE = (this.IE10 || this.IE9);
|
267
|
+
|
268
|
+
// If we're merging the breakpoints, ensure breakpoints option object exists
|
269
|
+
if(this.options.preserve_breakpoints && this.options.breakpoints) {
|
270
|
+
custom_breakpoints = this.options.breakpoints;
|
271
|
+
|
272
|
+
// Set the callback
|
273
|
+
this.breakpoints = mergeBreakpoints;
|
274
|
+
} else {
|
275
|
+
|
276
|
+
// Fallback to the override or the default breakpoints
|
277
|
+
this.breakpoints = this.options.breakpoints || defaultBreakpoints;
|
278
|
+
}
|
279
|
+
|
280
|
+
// Init this.dimensions and this.bp
|
281
|
+
dimensionsBreakpointsListener();
|
282
|
+
this.resize.push( dimensionsBreakpointsListener );
|
283
|
+
|
284
|
+
if(this.options.mobile_fps) {
|
285
|
+
this.scroll.push( this.mobileFPS() );
|
286
|
+
}
|
287
|
+
|
288
|
+
/* Cached jQuery variables */
|
289
|
+
if(typeof jQuery !== 'undefined') {
|
290
|
+
/** @type {jQuery} */
|
291
|
+
this.$body = jQuery('body');
|
292
|
+
/** @type {jQuery} */
|
293
|
+
this.$window = jQuery(window);
|
294
|
+
/** @type {jQuery} */
|
295
|
+
this.$document = jQuery(document);
|
296
|
+
}
|
297
|
+
|
298
|
+
var listeners = ['resize', 'scroll', 'ready', 'load'];
|
299
|
+
for(var i = 0; i < listeners.length; i++) {
|
300
|
+
var listener = listeners[i];
|
301
|
+
attachChildListeners.call(this, listener, jsHolder);
|
302
|
+
}
|
303
|
+
|
304
|
+
attachListeners.call(this);
|
305
|
+
|
306
|
+
return this;
|
307
|
+
}
|
308
|
+
|
309
|
+
FrobCoreHelpers.prototype = {
|
310
|
+
|
311
|
+
/**
|
312
|
+
* Apply value to variable if it has none
|
313
|
+
* @param {var} variable - variable to set default to
|
314
|
+
* @param {*} value - default value to attribute to variable
|
315
|
+
* @return {*} Existing value or passed value argument
|
316
|
+
*/
|
317
|
+
setDefault: function(variable, value){
|
318
|
+
return (typeof variable === 'undefined') ? value : variable;
|
319
|
+
},
|
320
|
+
|
321
|
+
/**
|
322
|
+
* Nice, unjanky scroll to element
|
323
|
+
* @param {jQuery} $target - Scroll to the top of this object
|
324
|
+
* @param {Number} [duration=2000] - How long the scroll lasts
|
325
|
+
* @param {Number} [delay=100] - How long to wait after trigger
|
326
|
+
* @param {Number} [offset=0] - Additional offset to add to the scrollTop
|
327
|
+
*/
|
328
|
+
smoothScroll: function($target, duration, delay, offset){
|
329
|
+
var _this = this;
|
330
|
+
|
331
|
+
duration = this.setDefault(duration, 2000);
|
332
|
+
delay = this.setDefault(delay, 100);
|
333
|
+
offset = this.setDefault(offset, 0);
|
334
|
+
|
335
|
+
setTimeout(function(){
|
336
|
+
var target_offset = $target.offset().top + offset;
|
337
|
+
|
338
|
+
// Ensure we scroll to bottom of page if target doesn't have enough space below for viewing
|
339
|
+
if (_this.$document.outerHeight() < target_offset + _this.dimensions.wh) {
|
340
|
+
target_offset = _this.$document.outerHeight() - _this.dimensions.wh;
|
341
|
+
}
|
342
|
+
|
343
|
+
$('html, body').animate({
|
344
|
+
scrollTop: target_offset
|
345
|
+
}, duration);
|
346
|
+
}, delay);
|
347
|
+
},
|
348
|
+
|
349
|
+
/**
|
350
|
+
* Clear value of localstorage object. If no key is passed, clear all objects
|
351
|
+
* @param {String} [key] - Accessible identifier
|
352
|
+
* @return {Undefined|Boolean} Result of clear or removeItem action
|
353
|
+
*/
|
354
|
+
localClear: function(key){
|
355
|
+
try {
|
356
|
+
if(typeof key === 'undefined') {
|
357
|
+
localStorage.clear();
|
358
|
+
} else {
|
359
|
+
localStorage.removeItem(key);
|
360
|
+
}
|
361
|
+
} catch(e) {
|
362
|
+
return false;
|
363
|
+
}
|
364
|
+
},
|
365
|
+
|
366
|
+
/**
|
367
|
+
* Retrieve localstorage object value
|
368
|
+
* @param {String} key - Accessible identifier
|
369
|
+
* @return {String|Object|Boolean} Value of localStorage object or false if key is undefined
|
370
|
+
*/
|
371
|
+
localGet: function(key) {
|
372
|
+
// localStorage is unavailable in some incognito/private browsers
|
373
|
+
try {
|
374
|
+
if(localStorage.getItem(key)) {
|
375
|
+
var value = localStorage.getItem(key);
|
376
|
+
|
377
|
+
if(value.indexOf('{') === 0) {
|
378
|
+
return JSON.parse( value );
|
379
|
+
} else {
|
380
|
+
return value;
|
381
|
+
}
|
382
|
+
} else {
|
383
|
+
return false;
|
384
|
+
}
|
385
|
+
} catch(e) {
|
386
|
+
return false;
|
387
|
+
}
|
388
|
+
},
|
389
|
+
|
390
|
+
/**
|
391
|
+
* Store a string locally
|
392
|
+
* @param {String} key - Accessible identifier
|
393
|
+
* @param {String|Object} obj - Value of identifier
|
394
|
+
* @return {String} Value of key in localStorage
|
395
|
+
*/
|
396
|
+
localSet: function(key, obj) {
|
397
|
+
var value;
|
398
|
+
|
399
|
+
if(obj.constructor === String) {
|
400
|
+
value = obj;
|
401
|
+
} else {
|
402
|
+
value = JSON.stringify(obj);
|
403
|
+
}
|
404
|
+
|
405
|
+
try {
|
406
|
+
localStorage.setItem(key, value);
|
407
|
+
} catch(e) {
|
408
|
+
// noop
|
409
|
+
}
|
410
|
+
|
411
|
+
return value;
|
412
|
+
},
|
413
|
+
|
414
|
+
/**
|
415
|
+
* Check if IE is current browser
|
416
|
+
* @param {Number|String} version
|
417
|
+
* @return {Boolean}
|
418
|
+
*/
|
419
|
+
isIE: function(version) {
|
420
|
+
var regex = new RegExp('msie' + (!isNaN(version)?('\\s' + version) : ''), 'i');
|
421
|
+
return regex.test(navigator.userAgent);
|
422
|
+
},
|
423
|
+
|
424
|
+
/**
|
425
|
+
* Check for existence of element on page
|
426
|
+
* @param {String} query - JavaScript object
|
427
|
+
* @return {Boolean}
|
428
|
+
*/
|
429
|
+
exists: function(query) {
|
430
|
+
return !!document.querySelector(query);
|
431
|
+
},
|
432
|
+
|
433
|
+
/**
|
434
|
+
* Provides accessible booleans for fluctuating screensizes; only fire when queried
|
435
|
+
* @sets this.dimensions
|
436
|
+
* @sets this.bp
|
437
|
+
* @fires this.breakpoints
|
438
|
+
*/
|
439
|
+
screenSizes: function() {
|
440
|
+
var _this = this;
|
441
|
+
|
442
|
+
return function() {
|
443
|
+
var ww = window.innerWidth;
|
444
|
+
var wh = window.innerHeight;
|
445
|
+
|
446
|
+
/**
|
447
|
+
* dimensions
|
448
|
+
* @namespace
|
449
|
+
* @description Holder for screen size numbers, set on load and reset on resize
|
450
|
+
* @property {Number} ww - Window width
|
451
|
+
* @property {Number} wh - Window height
|
452
|
+
*/
|
453
|
+
_this.dimensions = {
|
454
|
+
ww: ww,
|
455
|
+
wh: wh
|
456
|
+
};
|
457
|
+
|
458
|
+
/**
|
459
|
+
* bp
|
460
|
+
* @namespace
|
461
|
+
* @description Sets boolean values for screen size ranges
|
462
|
+
* @fires this.breakpoints
|
463
|
+
* @see {@link defaultBreakpoints}
|
464
|
+
* @see {@link mergeBreakpoints}
|
465
|
+
*/
|
466
|
+
_this.bp = _this.breakpoints.call(null, ww, wh);
|
467
|
+
};
|
468
|
+
},
|
469
|
+
|
470
|
+
/**
|
471
|
+
* Determine if element has class with vanilla JS
|
472
|
+
* @param {Object} el - JavaScript element
|
473
|
+
* @param {String} cls - Class name
|
474
|
+
* @see {@link http://jaketrent.com/post/addremove-classes-raw-javascript/}
|
475
|
+
* @return {Boolean}
|
476
|
+
*/
|
477
|
+
hasClass: function(el, cls) {
|
478
|
+
return hasClass(el, cls);
|
479
|
+
},
|
480
|
+
|
481
|
+
/**
|
482
|
+
* Add class to element with vanilla JS
|
483
|
+
* @param {Object} el - JavaScript element
|
484
|
+
* @param {String} cls - Class name
|
485
|
+
* @see {@link http://jaketrent.com/post/addremove-classes-raw-javascript/}
|
486
|
+
*/
|
487
|
+
addClass: function(el, cls) {
|
488
|
+
return addClass(el, cls);
|
489
|
+
},
|
490
|
+
|
491
|
+
/**
|
492
|
+
* Remove class from element with vanilla JS
|
493
|
+
* @param {Object} el - JavaScript element
|
494
|
+
* @param {String} cls - Class name
|
495
|
+
* @see {@link http://jaketrent.com/post/addremove-classes-raw-javascript/}
|
496
|
+
*/
|
497
|
+
removeClass: function(el, cls) {
|
498
|
+
return removeClass(el, cls)
|
499
|
+
},
|
500
|
+
|
501
|
+
/**
|
502
|
+
* Goes through all elements and performs function for each item
|
503
|
+
* @private
|
504
|
+
* @param {Array|String} selector - Array, NodeList or DOM selector
|
505
|
+
* @param {Function} callback
|
506
|
+
* @param {Node} item - Current looped item
|
507
|
+
* @param {Integer} index - Index of current looped item
|
508
|
+
*/
|
509
|
+
loop: function(selector, callback) {
|
510
|
+
var items;
|
511
|
+
|
512
|
+
if(selector.constructor === Array || selector.constructor === NodeList) {
|
513
|
+
items = selector;
|
514
|
+
} else {
|
515
|
+
items = document.querySelectorAll(selector);
|
516
|
+
}
|
517
|
+
|
518
|
+
for(var i = 0; i < items.length; i++) {
|
519
|
+
callback( items[i], i );
|
520
|
+
}
|
521
|
+
},
|
522
|
+
|
523
|
+
/**
|
524
|
+
* Increase screen performance and frames per second by diasbling pointer events on scroll
|
525
|
+
* @see {@link http://www.thecssninja.com/css/pointer-events-60fps}
|
526
|
+
*/
|
527
|
+
mobileFPS: function(){
|
528
|
+
var scroll_timer;
|
529
|
+
var body = document.getElementsByTagName('body')[0];
|
530
|
+
|
531
|
+
function allowHover() {
|
532
|
+
return removeClass(body, 'u-disable_hover');
|
533
|
+
}
|
534
|
+
|
535
|
+
return function() {
|
536
|
+
clearTimeout(scroll_timer),
|
537
|
+
hasClass(body, 'u-disable_hover') || addClass(body, 'u-disable_hover'),
|
538
|
+
scroll_timer = setTimeout(allowHover, 500 );
|
539
|
+
};
|
540
|
+
},
|
541
|
+
|
542
|
+
/**
|
543
|
+
* Fire event only once
|
544
|
+
* @param {Function} func - Function to execute on debounced
|
545
|
+
* @param {Integer} [threshold=250] - Delay to check if func has been executed
|
546
|
+
* @see {@link http://unscriptable.com/2009/03/20/debouncing-javascript-methods/}
|
547
|
+
* @example
|
548
|
+
* FCH.resize.push( FCH.debounce( this.resourceConsumingFunction.bind(this) ) );
|
549
|
+
* @return {Function} Called func, either now or later
|
550
|
+
*/
|
551
|
+
debounce: function(func, threshold) {
|
552
|
+
var timeout;
|
553
|
+
|
554
|
+
return function() {
|
555
|
+
var obj = this, args = arguments;
|
556
|
+
|
557
|
+
function delayed () {
|
558
|
+
timeout = null;
|
559
|
+
func.apply(obj, args);
|
560
|
+
}
|
561
|
+
|
562
|
+
if (timeout) {
|
563
|
+
clearTimeout(timeout);
|
564
|
+
} else {
|
565
|
+
func.apply(obj, args);
|
566
|
+
}
|
567
|
+
|
568
|
+
timeout = setTimeout(delayed, threshold || 250);
|
569
|
+
};
|
570
|
+
},
|
571
|
+
|
572
|
+
/**
|
573
|
+
* Check for external links, set target blank if external
|
574
|
+
*/
|
575
|
+
blankit: function() {
|
576
|
+
var links = document.getElementsByTagName('a');
|
577
|
+
|
578
|
+
for (var i = 0; i < links.length; i++) {
|
579
|
+
if ( /^http/.test(links[i].getAttribute('href')) ) {
|
580
|
+
links[i].setAttribute('target', '_blank');
|
581
|
+
}
|
582
|
+
}
|
583
|
+
}
|
584
|
+
};
|
585
|
+
|
586
|
+
return FrobCoreHelpers;
|
587
|
+
});
|