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,534 @@
|
|
1
|
+
/*
|
2
|
+
* MultiSelect v0.9.11
|
3
|
+
* Copyright (c) 2012 Louis Cuny
|
4
|
+
*
|
5
|
+
* This program is free software. It comes without any warranty, to
|
6
|
+
* the extent permitted by applicable law. You can redistribute it
|
7
|
+
* and/or modify it under the terms of the Do What The Fuck You Want
|
8
|
+
* To Public License, Version 2, as published by Sam Hocevar. See
|
9
|
+
* http://sam.zoy.org/wtfpl/COPYING for more details.
|
10
|
+
*/
|
11
|
+
|
12
|
+
!function ($) {
|
13
|
+
|
14
|
+
"use strict";
|
15
|
+
|
16
|
+
|
17
|
+
/* MULTISELECT CLASS DEFINITION
|
18
|
+
* ====================== */
|
19
|
+
|
20
|
+
var MultiSelect = function (element, options) {
|
21
|
+
this.options = options;
|
22
|
+
this.$element = $(element);
|
23
|
+
this.$container = $('<div/>', { 'class': "ms-container" });
|
24
|
+
this.$selectableContainer = $('<div/>', { 'class': 'ms-selectable' });
|
25
|
+
this.$selectionContainer = $('<div/>', { 'class': 'ms-selection' });
|
26
|
+
this.$selectableUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
|
27
|
+
this.$selectionUl = $('<ul/>', { 'class': "ms-list", 'tabindex' : '-1' });
|
28
|
+
this.scrollTo = 0;
|
29
|
+
this.elemsSelector = 'li:visible:not(.ms-optgroup-label,.ms-optgroup-container,.'+options.disabledClass+')';
|
30
|
+
};
|
31
|
+
|
32
|
+
MultiSelect.prototype = {
|
33
|
+
constructor: MultiSelect,
|
34
|
+
|
35
|
+
init: function(){
|
36
|
+
var that = this,
|
37
|
+
ms = this.$element;
|
38
|
+
|
39
|
+
if (ms.next('.ms-container').length === 0){
|
40
|
+
ms.css({ position: 'absolute', left: '-9999px' });
|
41
|
+
ms.attr('id', ms.attr('id') ? ms.attr('id') : Math.ceil(Math.random()*1000)+'multiselect');
|
42
|
+
this.$container.attr('id', 'ms-'+ms.attr('id'));
|
43
|
+
this.$container.addClass(that.options.cssClass);
|
44
|
+
ms.find('option').each(function(){
|
45
|
+
that.generateLisFromOption(this);
|
46
|
+
});
|
47
|
+
|
48
|
+
this.$selectionUl.find('.ms-optgroup-label').hide();
|
49
|
+
|
50
|
+
if (that.options.selectableHeader){
|
51
|
+
that.$selectableContainer.append(that.options.selectableHeader);
|
52
|
+
}
|
53
|
+
that.$selectableContainer.append(that.$selectableUl);
|
54
|
+
if (that.options.selectableFooter){
|
55
|
+
that.$selectableContainer.append(that.options.selectableFooter);
|
56
|
+
}
|
57
|
+
|
58
|
+
if (that.options.selectionHeader){
|
59
|
+
that.$selectionContainer.append(that.options.selectionHeader);
|
60
|
+
}
|
61
|
+
that.$selectionContainer.append(that.$selectionUl);
|
62
|
+
if (that.options.selectionFooter){
|
63
|
+
that.$selectionContainer.append(that.options.selectionFooter);
|
64
|
+
}
|
65
|
+
|
66
|
+
that.$container.append(that.$selectableContainer);
|
67
|
+
that.$container.append(that.$selectionContainer);
|
68
|
+
ms.after(that.$container);
|
69
|
+
|
70
|
+
that.activeMouse(that.$selectableUl);
|
71
|
+
that.activeKeyboard(that.$selectableUl);
|
72
|
+
|
73
|
+
var action = that.options.dblClick ? 'dblclick' : 'click';
|
74
|
+
|
75
|
+
that.$selectableUl.on(action, '.ms-elem-selectable', function(){
|
76
|
+
that.select($(this).data('ms-value'));
|
77
|
+
});
|
78
|
+
that.$selectionUl.on(action, '.ms-elem-selection', function(){
|
79
|
+
that.deselect($(this).data('ms-value'));
|
80
|
+
});
|
81
|
+
|
82
|
+
that.activeMouse(that.$selectionUl);
|
83
|
+
that.activeKeyboard(that.$selectionUl);
|
84
|
+
|
85
|
+
ms.on('focus', function(){
|
86
|
+
that.$selectableUl.focus();
|
87
|
+
})
|
88
|
+
}
|
89
|
+
|
90
|
+
var selectedValues = ms.find('option:selected').map(function(){ return $(this).val(); }).get();
|
91
|
+
that.select(selectedValues, 'init');
|
92
|
+
|
93
|
+
if (typeof that.options.afterInit === 'function') {
|
94
|
+
that.options.afterInit.call(this, this.$container);
|
95
|
+
}
|
96
|
+
},
|
97
|
+
|
98
|
+
'generateLisFromOption' : function(option, index, $container){
|
99
|
+
var that = this,
|
100
|
+
ms = that.$element,
|
101
|
+
attributes = "",
|
102
|
+
$option = $(option);
|
103
|
+
|
104
|
+
for (var cpt = 0; cpt < option.attributes.length; cpt++){
|
105
|
+
var attr = option.attributes[cpt];
|
106
|
+
|
107
|
+
if(attr.name !== 'value' && attr.name !== 'disabled'){
|
108
|
+
attributes += attr.name+'="'+attr.value+'" ';
|
109
|
+
}
|
110
|
+
}
|
111
|
+
var selectableLi = $('<li '+attributes+'><span>'+that.escapeHTML($option.text())+'</span></li>'),
|
112
|
+
selectedLi = selectableLi.clone(),
|
113
|
+
value = $option.val(),
|
114
|
+
elementId = that.sanitize(value);
|
115
|
+
|
116
|
+
selectableLi
|
117
|
+
.data('ms-value', value)
|
118
|
+
.addClass('ms-elem-selectable')
|
119
|
+
.attr('id', elementId+'-selectable');
|
120
|
+
|
121
|
+
selectedLi
|
122
|
+
.data('ms-value', value)
|
123
|
+
.addClass('ms-elem-selection')
|
124
|
+
.attr('id', elementId+'-selection')
|
125
|
+
.hide();
|
126
|
+
|
127
|
+
if ($option.prop('disabled') || ms.prop('disabled')){
|
128
|
+
selectedLi.addClass(that.options.disabledClass);
|
129
|
+
selectableLi.addClass(that.options.disabledClass);
|
130
|
+
}
|
131
|
+
|
132
|
+
var $optgroup = $option.parent('optgroup');
|
133
|
+
|
134
|
+
if ($optgroup.length > 0){
|
135
|
+
var optgroupLabel = $optgroup.attr('label'),
|
136
|
+
optgroupId = that.sanitize(optgroupLabel),
|
137
|
+
$selectableOptgroup = that.$selectableUl.find('#optgroup-selectable-'+optgroupId),
|
138
|
+
$selectionOptgroup = that.$selectionUl.find('#optgroup-selection-'+optgroupId);
|
139
|
+
|
140
|
+
if ($selectableOptgroup.length === 0){
|
141
|
+
var optgroupContainerTpl = '<li class="ms-optgroup-container"></li>',
|
142
|
+
optgroupTpl = '<ul class="ms-optgroup"><li class="ms-optgroup-label"><span>'+optgroupLabel+'</span></li></ul>';
|
143
|
+
|
144
|
+
$selectableOptgroup = $(optgroupContainerTpl);
|
145
|
+
$selectionOptgroup = $(optgroupContainerTpl);
|
146
|
+
$selectableOptgroup.attr('id', 'optgroup-selectable-'+optgroupId);
|
147
|
+
$selectionOptgroup.attr('id', 'optgroup-selection-'+optgroupId);
|
148
|
+
$selectableOptgroup.append($(optgroupTpl));
|
149
|
+
$selectionOptgroup.append($(optgroupTpl));
|
150
|
+
if (that.options.selectableOptgroup){
|
151
|
+
$selectableOptgroup.find('.ms-optgroup-label').on('click', function(){
|
152
|
+
var values = $optgroup.children(':not(:selected, :disabled)').map(function(){ return $(this).val() }).get();
|
153
|
+
that.select(values);
|
154
|
+
});
|
155
|
+
$selectionOptgroup.find('.ms-optgroup-label').on('click', function(){
|
156
|
+
var values = $optgroup.children(':selected:not(:disabled)').map(function(){ return $(this).val() }).get();
|
157
|
+
that.deselect(values);
|
158
|
+
});
|
159
|
+
}
|
160
|
+
that.$selectableUl.append($selectableOptgroup);
|
161
|
+
that.$selectionUl.append($selectionOptgroup);
|
162
|
+
}
|
163
|
+
index = index == undefined ? $selectableOptgroup.find('ul').children().length : index + 1;
|
164
|
+
selectableLi.insertAt(index, $selectableOptgroup.children());
|
165
|
+
selectedLi.insertAt(index, $selectionOptgroup.children());
|
166
|
+
} else {
|
167
|
+
index = index == undefined ? that.$selectableUl.children().length : index;
|
168
|
+
|
169
|
+
selectableLi.insertAt(index, that.$selectableUl);
|
170
|
+
selectedLi.insertAt(index, that.$selectionUl);
|
171
|
+
}
|
172
|
+
},
|
173
|
+
|
174
|
+
'addOption' : function(options){
|
175
|
+
var that = this;
|
176
|
+
|
177
|
+
if (options.value) options = [options];
|
178
|
+
$.each(options, function(index, option){
|
179
|
+
if (option.value && that.$element.find("option[value='"+option.value+"']").length === 0){
|
180
|
+
var $option = $('<option value="'+option.value+'">'+option.text+'</option>'),
|
181
|
+
index = parseInt((typeof option.index === 'undefined' ? that.$element.children().length : option.index)),
|
182
|
+
$container = option.nested == undefined ? that.$element : $("optgroup[label='"+option.nested+"']")
|
183
|
+
|
184
|
+
$option.insertAt(index, $container);
|
185
|
+
that.generateLisFromOption($option.get(0), index, option.nested);
|
186
|
+
}
|
187
|
+
})
|
188
|
+
},
|
189
|
+
|
190
|
+
'escapeHTML' : function(text){
|
191
|
+
return $("<div>").text(text).html();
|
192
|
+
},
|
193
|
+
|
194
|
+
'activeKeyboard' : function($list){
|
195
|
+
var that = this;
|
196
|
+
|
197
|
+
$list.on('focus', function(){
|
198
|
+
$(this).addClass('ms-focus');
|
199
|
+
})
|
200
|
+
.on('blur', function(){
|
201
|
+
$(this).removeClass('ms-focus');
|
202
|
+
})
|
203
|
+
.on('keydown', function(e){
|
204
|
+
switch (e.which) {
|
205
|
+
case 40:
|
206
|
+
case 38:
|
207
|
+
e.preventDefault();
|
208
|
+
e.stopPropagation();
|
209
|
+
that.moveHighlight($(this), (e.which === 38) ? -1 : 1);
|
210
|
+
return;
|
211
|
+
case 37:
|
212
|
+
case 39:
|
213
|
+
e.preventDefault();
|
214
|
+
e.stopPropagation();
|
215
|
+
that.switchList($list);
|
216
|
+
return;
|
217
|
+
case 9:
|
218
|
+
if(that.$element.is('[tabindex]')){
|
219
|
+
e.preventDefault();
|
220
|
+
var tabindex = parseInt(that.$element.attr('tabindex'), 10);
|
221
|
+
tabindex = (e.shiftKey) ? tabindex-1 : tabindex+1;
|
222
|
+
$('[tabindex="'+(tabindex)+'"]').focus();
|
223
|
+
return;
|
224
|
+
} else {
|
225
|
+
// @hack Disable key capture on shift+tab
|
226
|
+
// @author Aaron Ransley, 12/12/16
|
227
|
+
// if(e.shiftKey){
|
228
|
+
// that.$element.trigger('focus');
|
229
|
+
// }
|
230
|
+
}
|
231
|
+
}
|
232
|
+
if($.inArray(e.which, that.options.keySelect) > -1){
|
233
|
+
e.preventDefault();
|
234
|
+
e.stopPropagation();
|
235
|
+
that.selectHighlighted($list);
|
236
|
+
return;
|
237
|
+
}
|
238
|
+
});
|
239
|
+
},
|
240
|
+
|
241
|
+
'moveHighlight': function($list, direction){
|
242
|
+
var $elems = $list.find(this.elemsSelector),
|
243
|
+
$currElem = $elems.filter('.ms-hover'),
|
244
|
+
$nextElem = null,
|
245
|
+
elemHeight = $elems.first().outerHeight(),
|
246
|
+
containerHeight = $list.height(),
|
247
|
+
containerSelector = '#'+this.$container.prop('id');
|
248
|
+
|
249
|
+
$elems.removeClass('ms-hover');
|
250
|
+
if (direction === 1){ // DOWN
|
251
|
+
|
252
|
+
$nextElem = $currElem.nextAll(this.elemsSelector).first();
|
253
|
+
if ($nextElem.length === 0){
|
254
|
+
var $optgroupUl = $currElem.parent();
|
255
|
+
|
256
|
+
if ($optgroupUl.hasClass('ms-optgroup')){
|
257
|
+
var $optgroupLi = $optgroupUl.parent(),
|
258
|
+
$nextOptgroupLi = $optgroupLi.next(':visible');
|
259
|
+
|
260
|
+
if ($nextOptgroupLi.length > 0){
|
261
|
+
$nextElem = $nextOptgroupLi.find(this.elemsSelector).first();
|
262
|
+
} else {
|
263
|
+
$nextElem = $elems.first();
|
264
|
+
}
|
265
|
+
} else {
|
266
|
+
$nextElem = $elems.first();
|
267
|
+
}
|
268
|
+
}
|
269
|
+
} else if (direction === -1){ // UP
|
270
|
+
|
271
|
+
$nextElem = $currElem.prevAll(this.elemsSelector).first();
|
272
|
+
if ($nextElem.length === 0){
|
273
|
+
var $optgroupUl = $currElem.parent();
|
274
|
+
|
275
|
+
if ($optgroupUl.hasClass('ms-optgroup')){
|
276
|
+
var $optgroupLi = $optgroupUl.parent(),
|
277
|
+
$prevOptgroupLi = $optgroupLi.prev(':visible');
|
278
|
+
|
279
|
+
if ($prevOptgroupLi.length > 0){
|
280
|
+
$nextElem = $prevOptgroupLi.find(this.elemsSelector).last();
|
281
|
+
} else {
|
282
|
+
$nextElem = $elems.last();
|
283
|
+
}
|
284
|
+
} else {
|
285
|
+
$nextElem = $elems.last();
|
286
|
+
}
|
287
|
+
}
|
288
|
+
}
|
289
|
+
if ($nextElem.length > 0){
|
290
|
+
$nextElem.addClass('ms-hover');
|
291
|
+
var scrollTo = $list.scrollTop() + $nextElem.position().top -
|
292
|
+
containerHeight / 2 + elemHeight / 2;
|
293
|
+
|
294
|
+
$list.scrollTop(scrollTo);
|
295
|
+
}
|
296
|
+
},
|
297
|
+
|
298
|
+
'selectHighlighted' : function($list){
|
299
|
+
var $elems = $list.find(this.elemsSelector),
|
300
|
+
$highlightedElem = $elems.filter('.ms-hover').first();
|
301
|
+
|
302
|
+
if ($highlightedElem.length > 0){
|
303
|
+
if ($list.parent().hasClass('ms-selectable')){
|
304
|
+
this.select($highlightedElem.data('ms-value'));
|
305
|
+
} else {
|
306
|
+
this.deselect($highlightedElem.data('ms-value'));
|
307
|
+
}
|
308
|
+
$elems.removeClass('ms-hover');
|
309
|
+
}
|
310
|
+
},
|
311
|
+
|
312
|
+
'switchList' : function($list){
|
313
|
+
$list.blur();
|
314
|
+
this.$container.find(this.elemsSelector).removeClass('ms-hover');
|
315
|
+
if ($list.parent().hasClass('ms-selectable')){
|
316
|
+
this.$selectionUl.focus();
|
317
|
+
} else {
|
318
|
+
this.$selectableUl.focus();
|
319
|
+
}
|
320
|
+
},
|
321
|
+
|
322
|
+
'activeMouse' : function($list){
|
323
|
+
var that = this;
|
324
|
+
|
325
|
+
$('body').on('mouseenter', that.elemsSelector, function(){
|
326
|
+
$(this).parents('.ms-container').find(that.elemsSelector).removeClass('ms-hover');
|
327
|
+
$(this).addClass('ms-hover');
|
328
|
+
});
|
329
|
+
|
330
|
+
$('body').on('mouseleave', that.elemsSelector, function () {
|
331
|
+
$(this).parents('.ms-container').find(that.elemsSelector).removeClass('ms-hover');;
|
332
|
+
});
|
333
|
+
},
|
334
|
+
|
335
|
+
'refresh' : function() {
|
336
|
+
this.destroy();
|
337
|
+
this.$element.multiSelect(this.options);
|
338
|
+
},
|
339
|
+
|
340
|
+
'destroy' : function(){
|
341
|
+
$("#ms-"+this.$element.attr("id")).remove();
|
342
|
+
this.$element.css('position', '').css('left', '')
|
343
|
+
this.$element.removeData('multiselect');
|
344
|
+
},
|
345
|
+
|
346
|
+
'select' : function(value, method){
|
347
|
+
if (typeof value === 'string'){ value = [value]; }
|
348
|
+
|
349
|
+
var that = this,
|
350
|
+
ms = this.$element,
|
351
|
+
msIds = $.map(value, function(val){ return(that.sanitize(val)); }),
|
352
|
+
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable').filter(':not(.'+that.options.disabledClass+')'),
|
353
|
+
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection').filter(':not(.'+that.options.disabledClass+')'),
|
354
|
+
options = ms.find('option:not(:disabled)').filter(function(){ return($.inArray(this.value, value) > -1); });
|
355
|
+
|
356
|
+
if (method === 'init'){
|
357
|
+
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
|
358
|
+
selections = this.$selectionUl.find('#' + msIds.join('-selection, #') + '-selection');
|
359
|
+
}
|
360
|
+
|
361
|
+
if (selectables.length > 0){
|
362
|
+
selectables.addClass('ms-selected').hide();
|
363
|
+
selections.addClass('ms-selected').show();
|
364
|
+
|
365
|
+
options.prop('selected', true);
|
366
|
+
|
367
|
+
that.$container.find(that.elemsSelector).removeClass('ms-hover');
|
368
|
+
|
369
|
+
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
|
370
|
+
if (selectableOptgroups.length > 0){
|
371
|
+
selectableOptgroups.each(function(){
|
372
|
+
var selectablesLi = $(this).find('.ms-elem-selectable');
|
373
|
+
if (selectablesLi.length === selectablesLi.filter('.ms-selected').length){
|
374
|
+
$(this).find('.ms-optgroup-label').hide();
|
375
|
+
}
|
376
|
+
});
|
377
|
+
|
378
|
+
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
|
379
|
+
selectionOptgroups.each(function(){
|
380
|
+
var selectionsLi = $(this).find('.ms-elem-selection');
|
381
|
+
if (selectionsLi.filter('.ms-selected').length > 0){
|
382
|
+
$(this).find('.ms-optgroup-label').show();
|
383
|
+
}
|
384
|
+
});
|
385
|
+
} else {
|
386
|
+
if (that.options.keepOrder && method !== 'init'){
|
387
|
+
var selectionLiLast = that.$selectionUl.find('.ms-selected');
|
388
|
+
if((selectionLiLast.length > 1) && (selectionLiLast.last().get(0) != selections.get(0))) {
|
389
|
+
selections.insertAfter(selectionLiLast.last());
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
if (method !== 'init'){
|
394
|
+
ms.trigger('change');
|
395
|
+
if (typeof that.options.afterSelect === 'function') {
|
396
|
+
that.options.afterSelect.call(this, value);
|
397
|
+
}
|
398
|
+
}
|
399
|
+
}
|
400
|
+
},
|
401
|
+
|
402
|
+
'deselect' : function(value){
|
403
|
+
if (typeof value === 'string'){ value = [value]; }
|
404
|
+
|
405
|
+
var that = this,
|
406
|
+
ms = this.$element,
|
407
|
+
msIds = $.map(value, function(val){ return(that.sanitize(val)); }),
|
408
|
+
selectables = this.$selectableUl.find('#' + msIds.join('-selectable, #')+'-selectable'),
|
409
|
+
selections = this.$selectionUl.find('#' + msIds.join('-selection, #')+'-selection').filter('.ms-selected').filter(':not(.'+that.options.disabledClass+')'),
|
410
|
+
options = ms.find('option').filter(function(){ return($.inArray(this.value, value) > -1); });
|
411
|
+
|
412
|
+
if (selections.length > 0){
|
413
|
+
selectables.removeClass('ms-selected').show();
|
414
|
+
selections.removeClass('ms-selected').hide();
|
415
|
+
options.prop('selected', false);
|
416
|
+
|
417
|
+
that.$container.find(that.elemsSelector).removeClass('ms-hover');
|
418
|
+
|
419
|
+
var selectableOptgroups = that.$selectableUl.children('.ms-optgroup-container');
|
420
|
+
if (selectableOptgroups.length > 0){
|
421
|
+
selectableOptgroups.each(function(){
|
422
|
+
var selectablesLi = $(this).find('.ms-elem-selectable');
|
423
|
+
if (selectablesLi.filter(':not(.ms-selected)').length > 0){
|
424
|
+
$(this).find('.ms-optgroup-label').show();
|
425
|
+
}
|
426
|
+
});
|
427
|
+
|
428
|
+
var selectionOptgroups = that.$selectionUl.children('.ms-optgroup-container');
|
429
|
+
selectionOptgroups.each(function(){
|
430
|
+
var selectionsLi = $(this).find('.ms-elem-selection');
|
431
|
+
if (selectionsLi.filter('.ms-selected').length === 0){
|
432
|
+
$(this).find('.ms-optgroup-label').hide();
|
433
|
+
}
|
434
|
+
});
|
435
|
+
}
|
436
|
+
ms.trigger('change');
|
437
|
+
if (typeof that.options.afterDeselect === 'function') {
|
438
|
+
that.options.afterDeselect.call(this, value);
|
439
|
+
}
|
440
|
+
}
|
441
|
+
},
|
442
|
+
|
443
|
+
'select_all' : function(){
|
444
|
+
var ms = this.$element,
|
445
|
+
values = ms.val();
|
446
|
+
|
447
|
+
ms.find('option:not(":disabled")').prop('selected', true);
|
448
|
+
this.$selectableUl.find('.ms-elem-selectable').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').hide();
|
449
|
+
this.$selectionUl.find('.ms-optgroup-label').show();
|
450
|
+
this.$selectableUl.find('.ms-optgroup-label').hide();
|
451
|
+
this.$selectionUl.find('.ms-elem-selection').filter(':not(.'+this.options.disabledClass+')').addClass('ms-selected').show();
|
452
|
+
this.$selectionUl.focus();
|
453
|
+
ms.trigger('change');
|
454
|
+
if (typeof this.options.afterSelect === 'function') {
|
455
|
+
var selectedValues = $.grep(ms.val(), function(item){
|
456
|
+
return $.inArray(item, values) < 0;
|
457
|
+
});
|
458
|
+
this.options.afterSelect.call(this, selectedValues);
|
459
|
+
}
|
460
|
+
},
|
461
|
+
|
462
|
+
'deselect_all' : function(){
|
463
|
+
var ms = this.$element,
|
464
|
+
values = ms.val();
|
465
|
+
|
466
|
+
ms.find('option').prop('selected', false);
|
467
|
+
this.$selectableUl.find('.ms-elem-selectable').removeClass('ms-selected').show();
|
468
|
+
this.$selectionUl.find('.ms-optgroup-label').hide();
|
469
|
+
this.$selectableUl.find('.ms-optgroup-label').show();
|
470
|
+
this.$selectionUl.find('.ms-elem-selection').removeClass('ms-selected').hide();
|
471
|
+
this.$selectableUl.focus();
|
472
|
+
ms.trigger('change');
|
473
|
+
if (typeof this.options.afterDeselect === 'function') {
|
474
|
+
this.options.afterDeselect.call(this, values);
|
475
|
+
}
|
476
|
+
},
|
477
|
+
|
478
|
+
sanitize: function(value){
|
479
|
+
var hash = 0, i, character;
|
480
|
+
if (value.length == 0) return hash;
|
481
|
+
var ls = 0;
|
482
|
+
for (i = 0, ls = value.length; i < ls; i++) {
|
483
|
+
character = value.charCodeAt(i);
|
484
|
+
hash = ((hash<<5)-hash)+character;
|
485
|
+
hash |= 0; // Convert to 32bit integer
|
486
|
+
}
|
487
|
+
return hash;
|
488
|
+
}
|
489
|
+
};
|
490
|
+
|
491
|
+
/* MULTISELECT PLUGIN DEFINITION
|
492
|
+
* ======================= */
|
493
|
+
|
494
|
+
$.fn.multiSelect = function () {
|
495
|
+
var option = arguments[0],
|
496
|
+
args = arguments;
|
497
|
+
|
498
|
+
return this.each(function () {
|
499
|
+
var $this = $(this),
|
500
|
+
data = $this.data('multiselect'),
|
501
|
+
options = $.extend({}, $.fn.multiSelect.defaults, $this.data(), typeof option === 'object' && option);
|
502
|
+
|
503
|
+
if (!data){ $this.data('multiselect', (data = new MultiSelect(this, options))); }
|
504
|
+
|
505
|
+
if (typeof option === 'string'){
|
506
|
+
data[option](args[1]);
|
507
|
+
} else {
|
508
|
+
data.init();
|
509
|
+
}
|
510
|
+
});
|
511
|
+
};
|
512
|
+
|
513
|
+
$.fn.multiSelect.defaults = {
|
514
|
+
keySelect: [32],
|
515
|
+
selectableOptgroup: false,
|
516
|
+
disabledClass : 'disabled',
|
517
|
+
dblClick : false,
|
518
|
+
keepOrder: false,
|
519
|
+
cssClass: ''
|
520
|
+
};
|
521
|
+
|
522
|
+
$.fn.multiSelect.Constructor = MultiSelect;
|
523
|
+
|
524
|
+
$.fn.insertAt = function(index, $parent) {
|
525
|
+
return this.each(function() {
|
526
|
+
if (index === 0) {
|
527
|
+
$parent.prepend(this);
|
528
|
+
} else {
|
529
|
+
$parent.children().eq(index - 1).after(this);
|
530
|
+
}
|
531
|
+
});
|
532
|
+
}
|
533
|
+
|
534
|
+
}(window.jQuery);
|