qbrick 2.5.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +423 -0
- data/Rakefile +82 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/LICENSE.txt +674 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/README.md +62 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/anchor.js.coffee +81 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/link.js.coffee +1353 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/images/hidpi/anchor.png +0 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/de.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/en.js +68 -0
- data/app/assets/javascripts/ckeditor/plugins/adv_link/plugin.js.coffee +282 -0
- data/app/assets/javascripts/kuhsaft/application.js.coffee +7 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +136 -0
- data/app/assets/javascripts/kuhsaft/views/read_more_view.js.coffee +17 -0
- data/app/assets/stylesheets/kuhsaft/application.css.sass +1 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +204 -0
- data/app/assets/stylesheets/kuhsaft/modules/_text_brick.css.sass +16 -0
- data/app/controllers/kuhsaft/api/pages_controller.rb +14 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +18 -0
- data/app/controllers/kuhsaft/cms/assets_controller.rb +38 -0
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +61 -0
- data/app/controllers/kuhsaft/cms/ckimages_controller.rb +26 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +71 -0
- data/app/controllers/kuhsaft/pages_controller.rb +38 -0
- data/app/controllers/kuhsaft/sitemaps_controller.rb +12 -0
- data/app/helpers/cms_helper.rb +27 -0
- data/app/helpers/kuhsaft/admin_helper.rb +20 -0
- data/app/helpers/kuhsaft/cms/admin_helper.rb +21 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +17 -0
- data/app/helpers/pages_helper.rb +49 -0
- data/app/helpers/sitemaps_helper.rb +12 -0
- data/app/models/kuhsaft/accordion_brick.rb +15 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +21 -0
- data/app/models/kuhsaft/anchor_brick.rb +17 -0
- data/app/models/kuhsaft/asset.rb +29 -0
- data/app/models/kuhsaft/asset_brick.rb +26 -0
- data/app/models/kuhsaft/brick.rb +137 -0
- data/app/models/kuhsaft/brick_type.rb +7 -0
- data/app/models/kuhsaft/brick_type_filter.rb +18 -0
- data/app/models/kuhsaft/ckimage.rb +5 -0
- data/app/models/kuhsaft/cms.rb +7 -0
- data/app/models/kuhsaft/column_brick.rb +22 -0
- data/app/models/kuhsaft/image_brick.rb +16 -0
- data/app/models/kuhsaft/image_size.rb +51 -0
- data/app/models/kuhsaft/link_brick.rb +21 -0
- data/app/models/kuhsaft/page.rb +160 -0
- data/app/models/kuhsaft/page_type.rb +11 -0
- data/app/models/kuhsaft/partition.rb +18 -0
- data/app/models/kuhsaft/placeholder_brick.rb +23 -0
- data/app/models/kuhsaft/publish_state.rb +24 -0
- data/app/models/kuhsaft/slider_brick.rb +18 -0
- data/app/models/kuhsaft/text_brick.rb +23 -0
- data/app/models/kuhsaft/two_column_brick.rb +46 -0
- data/app/models/kuhsaft/video_brick.rb +22 -0
- data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +43 -0
- data/app/uploaders/kuhsaft/asset_uploader.rb +50 -0
- data/app/uploaders/kuhsaft/ckimage_uploader.rb +16 -0
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +35 -0
- data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
- data/app/views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
- data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/anchor_bricks/_anchor_brick.html.haml +1 -0
- data/app/views/kuhsaft/anchor_bricks/anchor_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/asset_bricks/_asset_brick.html.haml +2 -0
- data/app/views/kuhsaft/asset_bricks/asset_brick/_edit.html.haml +8 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +14 -0
- data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
- data/app/views/kuhsaft/cms/admin/_flash.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
- data/app/views/kuhsaft/cms/assets/_form.html.haml +15 -0
- data/app/views/kuhsaft/cms/assets/_list.html.haml +11 -0
- data/app/views/kuhsaft/cms/assets/edit.html.haml +2 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +3 -0
- data/app/views/kuhsaft/cms/assets/new.html.haml +2 -0
- data/app/views/kuhsaft/cms/bricks/_brick_header.html.haml +43 -0
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +25 -0
- data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/_new.html.haml +41 -0
- data/app/views/kuhsaft/cms/bricks/_sort_form.html.haml +3 -0
- data/app/views/kuhsaft/cms/bricks/create.js.erb +11 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.erb +10 -0
- data/app/views/kuhsaft/cms/bricks/new.js.erb +14 -0
- data/app/views/kuhsaft/cms/bricks/update.js.erb +8 -0
- data/app/views/kuhsaft/cms/ckimages/create.html.haml +11 -0
- data/app/views/kuhsaft/cms/ckimages/destroy.js.erb +2 -0
- data/app/views/kuhsaft/cms/ckimages/index.html.haml +13 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +19 -0
- data/app/views/kuhsaft/cms/pages/_form.html.haml +45 -0
- data/app/views/kuhsaft/cms/pages/edit.html.haml +16 -0
- data/app/views/kuhsaft/cms/pages/index.html.haml +14 -0
- data/app/views/kuhsaft/cms/pages/new.html.haml +1 -0
- data/app/views/kuhsaft/cms/pages/show.html.haml +0 -0
- data/app/views/kuhsaft/cms/pages/sort.js.erb +0 -0
- data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/column_bricks/column_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +11 -0
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +13 -0
- data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +2 -0
- data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +4 -0
- data/app/views/kuhsaft/pages/index.html.haml +7 -0
- data/app/views/kuhsaft/pages/show.html.haml +11 -0
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
- data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/search/_form.html.haml +2 -0
- data/app/views/kuhsaft/search/_results.html.haml +8 -0
- data/app/views/kuhsaft/search/_results_entry.html.haml +13 -0
- data/app/views/kuhsaft/sitemaps/index.xml.haml +9 -0
- data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
- data/app/views/kuhsaft/slider_bricks/slider_brick/_edit.html.haml +0 -0
- data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +11 -0
- data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
- data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
- data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
- data/app/views/layouts/kuhsaft/cms/application.html.haml +25 -0
- data/app/views/layouts/kuhsaft/cms/ckimages.html.haml +18 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/de.yml +207 -0
- data/config/locales/en.yml +211 -0
- data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/anchor_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/anchor_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/asset_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/asset_brick/en.yml +9 -0
- data/config/locales/models/kuhsaft/brick/de.yml +5 -0
- data/config/locales/models/kuhsaft/brick/en.yml +5 -0
- data/config/locales/models/kuhsaft/column_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/column_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +11 -0
- data/config/locales/models/kuhsaft/image_brick/en.yml +11 -0
- data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
- data/config/locales/models/kuhsaft/image_size/en.yml +13 -0
- data/config/locales/models/kuhsaft/link_brick/de.yml +10 -0
- data/config/locales/models/kuhsaft/link_brick/en.yml +10 -0
- data/config/locales/models/kuhsaft/page/de.yml +19 -0
- data/config/locales/models/kuhsaft/page/en.yml +19 -0
- data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/placeholder_brick/en.yml +8 -0
- data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/slider_brick/en.yml +4 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +11 -0
- data/config/locales/models/kuhsaft/text_brick/en.yml +11 -0
- data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/two_column_brick/en.yml +7 -0
- data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/video_brick/en.yml +9 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +13 -0
- data/config/locales/views/kuhsaft/cms/admin/en.yml +12 -0
- data/config/locales/views/kuhsaft/cms/bricks/de.yml +18 -0
- data/config/locales/views/kuhsaft/cms/bricks/en.yml +18 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +31 -0
- data/config/locales/views/kuhsaft/cms/pages/en.yml +31 -0
- data/config/locales/views/kuhsaft/image_brick/de.yml +6 -0
- data/config/locales/views/kuhsaft/image_brick/en.yml +6 -0
- data/config/locales/views/kuhsaft/search/de.yml +12 -0
- data/config/locales/views/kuhsaft/search/en.yml +12 -0
- data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
- data/config/locales/views/kuhsaft/text_brick/en.yml +6 -0
- data/config/locales/views/kuhsaft/video_brick/de.yml +7 -0
- data/config/locales/views/kuhsaft/video_brick/en.yml +7 -0
- data/config/routes.rb +30 -0
- data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
- data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
- data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
- data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
- data/db/migrate/05_remove_cms_admin.rb +9 -0
- data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
- data/db/migrate/07_add_default_value_to_brick_type_enabled.rb +6 -0
- data/db/migrate/08_add_display_styles_to_bricks.rb +5 -0
- data/db/migrate/09_add_additional_fields_to_kuhsaft_bricks.rb +6 -0
- data/db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb +7 -0
- data/db/migrate/11_update_url_and_redirect_url_value.rb +45 -0
- data/db/migrate/12_regenerate_fulltext.rb +12 -0
- data/db/migrate/13_add_page_title_to_pages.rb +7 -0
- data/db/migrate/14_move_kuhsaft_assets.rb +22 -0
- data/db/migrate/15_add_alt_text_to_bricks.rb +5 -0
- data/db/migrate/16_update_default_value_for_page_type.rb +9 -0
- data/db/migrate/17_set_page_type_to_content_for_empty_fields.rb +7 -0
- data/db/migrate/18_add_identifier_to_kuhsaft_pages.rb +6 -0
- data/db/migrate/19_add_col_count_to_bricks.rb +5 -0
- data/db/migrate/20_create_kuhsaft_ckimages.rb +9 -0
- data/db/seeds.rb +20 -0
- data/lib/generators/kuhsaft/assets/install_generator.rb +25 -0
- data/lib/generators/kuhsaft/translations/add_generator.rb +41 -0
- data/lib/kuhsaft.rb +22 -0
- data/lib/kuhsaft/brick_list.rb +87 -0
- data/lib/kuhsaft/engine.rb +27 -0
- data/lib/kuhsaft/gridded.rb +20 -0
- data/lib/kuhsaft/image_uploader_mounting.rb +22 -0
- data/lib/kuhsaft/orderable.rb +71 -0
- data/lib/kuhsaft/page_tree.rb +14 -0
- data/lib/kuhsaft/partial_extractor.rb +21 -0
- data/lib/kuhsaft/searchable.rb +69 -0
- data/lib/kuhsaft/touch_placeholders.rb +31 -0
- data/lib/kuhsaft/translatable.rb +54 -0
- data/lib/kuhsaft/version.rb +3 -0
- data/lib/tasks/kuhsaft_tasks.rake +22 -0
- data/lib/templates/kuhsaft/assets/ck-config.js.coffee +48 -0
- data/lib/templates/kuhsaft/assets/customizations.css.sass +0 -0
- data/lib/templates/kuhsaft/assets/customizations.js.coffee +0 -0
- data/lib/templates/kuhsaft/translations/add_translation.erb +8 -0
- data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +70 -0
- data/spec/controllers/kuhsaft/pages_controller_spec.rb +90 -0
- data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +13 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/images/spec-image.png +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/javascripts/kuhsaft/cms/ck-config.js.coffee +48 -0
- data/spec/dummy/app/assets/javascripts/kuhsaft/cms/customizations.js.coffee +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +0 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +26 -0
- data/spec/dummy/config/boot.rb +3 -0
- data/spec/dummy/config/database.yml +19 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +81 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/kuhsaft.rb +5 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/.gitkeep +0 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/factories.rb +26 -0
- data/spec/features/cms_pages_spec.rb +76 -0
- data/spec/features/search_spec.rb +78 -0
- data/spec/helpers/kuhsaft/cms/admin_helper_spec.rb +25 -0
- data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +46 -0
- data/spec/helpers/kuhsaft/pages_helper_spec.rb +21 -0
- data/spec/kuhsaft_spec.rb +7 -0
- data/spec/lib/brick_list_spec.rb +50 -0
- data/spec/lib/engine_spec.rb +25 -0
- data/spec/lib/gridded_spec.rb +24 -0
- data/spec/lib/image_uploader_mounting_spec.rb +14 -0
- data/spec/lib/page_tree_spec.rb +38 -0
- data/spec/lib/searchable_spec.rb +30 -0
- data/spec/lib/touch_placeholders_spec.rb +44 -0
- data/spec/lib/translatable_spec.rb +155 -0
- data/spec/models/accordion_brick_spec.rb +38 -0
- data/spec/models/accordion_item_brick_spec.rb +50 -0
- data/spec/models/anchor_brick_spec.rb +26 -0
- data/spec/models/asset_brick_spec.rb +45 -0
- data/spec/models/asset_spec.rb +41 -0
- data/spec/models/brick_spec.rb +134 -0
- data/spec/models/brick_type_filter_spec.rb +64 -0
- data/spec/models/column_brick_spec.rb +32 -0
- data/spec/models/image_brick_spec.rb +49 -0
- data/spec/models/image_size_spec.rb +36 -0
- data/spec/models/link_brick_spec.rb +51 -0
- data/spec/models/page_spec.rb +472 -0
- data/spec/models/placeholder_brick_spec.rb +46 -0
- data/spec/models/publish_state_spec.rb +33 -0
- data/spec/models/slider_brick_spec.rb +26 -0
- data/spec/models/text_brick_spec.rb +30 -0
- data/spec/models/two_column_brick_spec.rb +82 -0
- data/spec/models/video_brick_spec.rb +32 -0
- data/spec/spec_helper.rb +81 -0
- data/spec/support/kuhsaft_spec_helper.rb +8 -0
- data/spec/support/write_expectation.rb +57 -0
- data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +67 -0
- data/vendor/assets/javascripts/bootstrap-modal-v2.js +376 -0
- data/vendor/assets/javascripts/bootstrap-modalmanager.js +423 -0
- data/vendor/assets/javascripts/jquery.nestable.js +485 -0
- data/vendor/assets/stylesheets/bootstrap_modal.css +214 -0
- data/vendor/assets/stylesheets/nestable.css +84 -0
- metadata +870 -0
@@ -0,0 +1,376 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modal.js v2.2.4
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
!function ($) {
|
20
|
+
|
21
|
+
"use strict"; // jshint ;_;
|
22
|
+
|
23
|
+
/* MODAL CLASS DEFINITION
|
24
|
+
* ====================== */
|
25
|
+
|
26
|
+
var Modal = function (element, options) {
|
27
|
+
this.init(element, options);
|
28
|
+
};
|
29
|
+
|
30
|
+
Modal.prototype = {
|
31
|
+
|
32
|
+
constructor: Modal,
|
33
|
+
|
34
|
+
init: function (element, options) {
|
35
|
+
var that = this;
|
36
|
+
|
37
|
+
this.options = options;
|
38
|
+
|
39
|
+
this.$element = $(element)
|
40
|
+
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this));
|
41
|
+
|
42
|
+
this.options.remote && this.$element.find('.modal-body').load(this.options.remote, function () {
|
43
|
+
var e = $.Event('loaded');
|
44
|
+
that.$element.trigger(e);
|
45
|
+
});
|
46
|
+
|
47
|
+
var manager = typeof this.options.manager === 'function' ?
|
48
|
+
this.options.manager.call(this) : this.options.manager;
|
49
|
+
|
50
|
+
manager = manager.appendModal ?
|
51
|
+
manager : $(manager).modalmanager().data('modalmanager');
|
52
|
+
|
53
|
+
manager.appendModal(this);
|
54
|
+
},
|
55
|
+
|
56
|
+
toggle: function () {
|
57
|
+
return this[!this.isShown ? 'show' : 'hide']();
|
58
|
+
},
|
59
|
+
|
60
|
+
show: function () {
|
61
|
+
var e = $.Event('show');
|
62
|
+
|
63
|
+
if (this.isShown) return;
|
64
|
+
|
65
|
+
this.$element.trigger(e);
|
66
|
+
|
67
|
+
if (e.isDefaultPrevented()) return;
|
68
|
+
|
69
|
+
this.escape();
|
70
|
+
|
71
|
+
this.tab();
|
72
|
+
|
73
|
+
this.options.loading && this.loading();
|
74
|
+
},
|
75
|
+
|
76
|
+
hide: function (e) {
|
77
|
+
e && e.preventDefault();
|
78
|
+
|
79
|
+
e = $.Event('hide');
|
80
|
+
|
81
|
+
this.$element.trigger(e);
|
82
|
+
|
83
|
+
if (!this.isShown || e.isDefaultPrevented()) return;
|
84
|
+
|
85
|
+
this.isShown = false;
|
86
|
+
|
87
|
+
this.escape();
|
88
|
+
|
89
|
+
this.tab();
|
90
|
+
|
91
|
+
this.isLoading && this.loading();
|
92
|
+
|
93
|
+
$(document).off('focusin.modal');
|
94
|
+
|
95
|
+
this.$element
|
96
|
+
.removeClass('in')
|
97
|
+
.removeClass('animated')
|
98
|
+
.removeClass(this.options.attentionAnimation)
|
99
|
+
.removeClass('modal-overflow')
|
100
|
+
.attr('aria-hidden', true);
|
101
|
+
|
102
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
103
|
+
this.hideWithTransition() :
|
104
|
+
this.hideModal();
|
105
|
+
},
|
106
|
+
|
107
|
+
layout: function () {
|
108
|
+
var prop = this.options.height ? 'height' : 'max-height',
|
109
|
+
value = this.options.height || this.options.maxHeight;
|
110
|
+
|
111
|
+
if (this.options.width){
|
112
|
+
this.$element.css('width', this.options.width);
|
113
|
+
|
114
|
+
var that = this;
|
115
|
+
this.$element.css('margin-left', function () {
|
116
|
+
if (/%/ig.test(that.options.width)){
|
117
|
+
return -(parseInt(that.options.width) / 2) + '%';
|
118
|
+
} else {
|
119
|
+
return -($(this).width() / 2) + 'px';
|
120
|
+
}
|
121
|
+
});
|
122
|
+
} else {
|
123
|
+
this.$element.css('width', '');
|
124
|
+
this.$element.css('margin-left', '');
|
125
|
+
}
|
126
|
+
|
127
|
+
this.$element.find('.modal-body')
|
128
|
+
.css('overflow', '')
|
129
|
+
.css(prop, '');
|
130
|
+
|
131
|
+
if (value){
|
132
|
+
this.$element.find('.modal-body')
|
133
|
+
.css('overflow', 'auto')
|
134
|
+
.css(prop, value);
|
135
|
+
}
|
136
|
+
|
137
|
+
var modalOverflow = $(window).height() - 10 < this.$element.height();
|
138
|
+
|
139
|
+
if (modalOverflow || this.options.modalOverflow) {
|
140
|
+
this.$element
|
141
|
+
.css('margin-top', 0)
|
142
|
+
.addClass('modal-overflow');
|
143
|
+
} else {
|
144
|
+
this.$element
|
145
|
+
.css('margin-top', 0 - this.$element.height() / 2)
|
146
|
+
.removeClass('modal-overflow');
|
147
|
+
}
|
148
|
+
},
|
149
|
+
|
150
|
+
tab: function () {
|
151
|
+
var that = this;
|
152
|
+
|
153
|
+
if (this.isShown && this.options.consumeTab) {
|
154
|
+
this.$element.on('keydown.tabindex.modal', '[data-tabindex]', function (e) {
|
155
|
+
if (e.keyCode && e.keyCode == 9){
|
156
|
+
var $next = $(this),
|
157
|
+
$rollover = $(this);
|
158
|
+
|
159
|
+
that.$element.find('[data-tabindex]:enabled:not([readonly])').each(function (e) {
|
160
|
+
if (!e.shiftKey){
|
161
|
+
$next = $next.data('tabindex') < $(this).data('tabindex') ?
|
162
|
+
$next = $(this) :
|
163
|
+
$rollover = $(this);
|
164
|
+
} else {
|
165
|
+
$next = $next.data('tabindex') > $(this).data('tabindex') ?
|
166
|
+
$next = $(this) :
|
167
|
+
$rollover = $(this);
|
168
|
+
}
|
169
|
+
});
|
170
|
+
|
171
|
+
$next[0] !== $(this)[0] ?
|
172
|
+
$next.focus() : $rollover.focus();
|
173
|
+
|
174
|
+
e.preventDefault();
|
175
|
+
}
|
176
|
+
});
|
177
|
+
} else if (!this.isShown) {
|
178
|
+
this.$element.off('keydown.tabindex.modal');
|
179
|
+
}
|
180
|
+
},
|
181
|
+
|
182
|
+
escape: function () {
|
183
|
+
var that = this;
|
184
|
+
if (this.isShown && this.options.keyboard) {
|
185
|
+
if (!this.$element.attr('tabindex')) this.$element.attr('tabindex', -1);
|
186
|
+
|
187
|
+
this.$element.on('keyup.dismiss.modal', function (e) {
|
188
|
+
e.which == 27 && that.hide();
|
189
|
+
});
|
190
|
+
} else if (!this.isShown) {
|
191
|
+
this.$element.off('keyup.dismiss.modal')
|
192
|
+
}
|
193
|
+
},
|
194
|
+
|
195
|
+
hideWithTransition: function () {
|
196
|
+
var that = this
|
197
|
+
, timeout = setTimeout(function () {
|
198
|
+
that.$element.off($.support.transition.end);
|
199
|
+
that.hideModal();
|
200
|
+
}, 500);
|
201
|
+
|
202
|
+
this.$element.one($.support.transition.end, function () {
|
203
|
+
clearTimeout(timeout);
|
204
|
+
that.hideModal();
|
205
|
+
});
|
206
|
+
},
|
207
|
+
|
208
|
+
hideModal: function () {
|
209
|
+
var prop = this.options.height ? 'height' : 'max-height';
|
210
|
+
var value = this.options.height || this.options.maxHeight;
|
211
|
+
|
212
|
+
if (value){
|
213
|
+
this.$element.find('.modal-body')
|
214
|
+
.css('overflow', '')
|
215
|
+
.css(prop, '');
|
216
|
+
}
|
217
|
+
|
218
|
+
this.$element
|
219
|
+
.hide()
|
220
|
+
.trigger('hidden');
|
221
|
+
},
|
222
|
+
|
223
|
+
removeLoading: function () {
|
224
|
+
this.$loading.remove();
|
225
|
+
this.$loading = null;
|
226
|
+
this.isLoading = false;
|
227
|
+
},
|
228
|
+
|
229
|
+
loading: function (callback) {
|
230
|
+
callback = callback || function () {};
|
231
|
+
|
232
|
+
var animate = this.$element.hasClass('fade') ? 'fade' : '';
|
233
|
+
|
234
|
+
if (!this.isLoading) {
|
235
|
+
var doAnimate = $.support.transition && animate;
|
236
|
+
|
237
|
+
this.$loading = $('<div class="loading-mask ' + animate + '">')
|
238
|
+
.append(this.options.spinner)
|
239
|
+
.appendTo(this.$element);
|
240
|
+
|
241
|
+
if (doAnimate) this.$loading[0].offsetWidth; // force reflow
|
242
|
+
|
243
|
+
this.$loading.addClass('in');
|
244
|
+
|
245
|
+
this.isLoading = true;
|
246
|
+
|
247
|
+
doAnimate ?
|
248
|
+
this.$loading.one($.support.transition.end, callback) :
|
249
|
+
callback();
|
250
|
+
|
251
|
+
} else if (this.isLoading && this.$loading) {
|
252
|
+
this.$loading.removeClass('in');
|
253
|
+
|
254
|
+
var that = this;
|
255
|
+
$.support.transition && this.$element.hasClass('fade')?
|
256
|
+
this.$loading.one($.support.transition.end, function () { that.removeLoading() }) :
|
257
|
+
that.removeLoading();
|
258
|
+
|
259
|
+
} else if (callback) {
|
260
|
+
callback(this.isLoading);
|
261
|
+
}
|
262
|
+
},
|
263
|
+
|
264
|
+
focus: function () {
|
265
|
+
var $focusElem = this.$element.find(this.options.focusOn);
|
266
|
+
|
267
|
+
$focusElem = $focusElem.length ? $focusElem : this.$element;
|
268
|
+
|
269
|
+
$focusElem.focus();
|
270
|
+
},
|
271
|
+
|
272
|
+
attention: function (){
|
273
|
+
// NOTE: transitionEnd with keyframes causes odd behaviour
|
274
|
+
|
275
|
+
if (this.options.attentionAnimation){
|
276
|
+
this.$element
|
277
|
+
.removeClass('animated')
|
278
|
+
.removeClass(this.options.attentionAnimation);
|
279
|
+
|
280
|
+
var that = this;
|
281
|
+
|
282
|
+
setTimeout(function () {
|
283
|
+
that.$element
|
284
|
+
.addClass('animated')
|
285
|
+
.addClass(that.options.attentionAnimation);
|
286
|
+
}, 0);
|
287
|
+
}
|
288
|
+
|
289
|
+
|
290
|
+
this.focus();
|
291
|
+
},
|
292
|
+
|
293
|
+
|
294
|
+
destroy: function () {
|
295
|
+
var e = $.Event('destroy');
|
296
|
+
|
297
|
+
this.$element.trigger(e);
|
298
|
+
|
299
|
+
if (e.isDefaultPrevented()) return;
|
300
|
+
|
301
|
+
this.$element
|
302
|
+
.off('.modal')
|
303
|
+
.removeData('modal')
|
304
|
+
.removeClass('in')
|
305
|
+
.attr('aria-hidden', true);
|
306
|
+
|
307
|
+
if (this.$parent !== this.$element.parent()) {
|
308
|
+
this.$element.appendTo(this.$parent);
|
309
|
+
} else if (!this.$parent.length) {
|
310
|
+
// modal is not part of the DOM so remove it.
|
311
|
+
this.$element.remove();
|
312
|
+
this.$element = null;
|
313
|
+
}
|
314
|
+
|
315
|
+
this.$element.trigger('destroyed');
|
316
|
+
}
|
317
|
+
};
|
318
|
+
|
319
|
+
|
320
|
+
/* MODAL PLUGIN DEFINITION
|
321
|
+
* ======================= */
|
322
|
+
|
323
|
+
$.fn.modal = function (option, args) {
|
324
|
+
return this.each(function () {
|
325
|
+
var $this = $(this),
|
326
|
+
data = $this.data('modal'),
|
327
|
+
options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option);
|
328
|
+
|
329
|
+
if (!data) $this.data('modal', (data = new Modal(this, options)));
|
330
|
+
if (typeof option == 'string') data[option].apply(data, [].concat(args));
|
331
|
+
else if (options.show) data.show()
|
332
|
+
})
|
333
|
+
};
|
334
|
+
|
335
|
+
$.fn.modal.defaults = {
|
336
|
+
keyboard: true,
|
337
|
+
backdrop: true,
|
338
|
+
loading: false,
|
339
|
+
show: true,
|
340
|
+
width: null,
|
341
|
+
height: null,
|
342
|
+
maxHeight: null,
|
343
|
+
modalOverflow: false,
|
344
|
+
consumeTab: true,
|
345
|
+
focusOn: null,
|
346
|
+
replace: false,
|
347
|
+
resize: false,
|
348
|
+
attentionAnimation: 'shake',
|
349
|
+
manager: 'body',
|
350
|
+
spinner: '<div class="loading-spinner" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
|
351
|
+
backdropTemplate: '<div class="modal-backdrop" />'
|
352
|
+
};
|
353
|
+
|
354
|
+
$.fn.modal.Constructor = Modal;
|
355
|
+
|
356
|
+
|
357
|
+
/* MODAL DATA-API
|
358
|
+
* ============== */
|
359
|
+
|
360
|
+
$(function () {
|
361
|
+
$(document).off('click.modal').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
362
|
+
var $this = $(this),
|
363
|
+
href = $this.attr('href'),
|
364
|
+
$target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))), //strip for ie7
|
365
|
+
option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data());
|
366
|
+
|
367
|
+
e.preventDefault();
|
368
|
+
$target
|
369
|
+
.modal(option)
|
370
|
+
.one('hide', function () {
|
371
|
+
$this.focus();
|
372
|
+
})
|
373
|
+
});
|
374
|
+
});
|
375
|
+
|
376
|
+
}(window.jQuery);
|
@@ -0,0 +1,423 @@
|
|
1
|
+
/* ===========================================================
|
2
|
+
* bootstrap-modalmanager.js v2.2.4
|
3
|
+
* ===========================================================
|
4
|
+
* Copyright 2012 Jordan Schroter.
|
5
|
+
*
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
* you may not use this file except in compliance with the License.
|
8
|
+
* You may obtain a copy of the License at
|
9
|
+
*
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
*
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
* See the License for the specific language governing permissions and
|
16
|
+
* limitations under the License.
|
17
|
+
* ========================================================== */
|
18
|
+
|
19
|
+
!function ($) {
|
20
|
+
|
21
|
+
"use strict"; // jshint ;_;
|
22
|
+
|
23
|
+
/* MODAL MANAGER CLASS DEFINITION
|
24
|
+
* ====================== */
|
25
|
+
|
26
|
+
var ModalManager = function (element, options) {
|
27
|
+
this.init(element, options);
|
28
|
+
};
|
29
|
+
|
30
|
+
ModalManager.prototype = {
|
31
|
+
|
32
|
+
constructor: ModalManager,
|
33
|
+
|
34
|
+
init: function (element, options) {
|
35
|
+
this.$element = $(element);
|
36
|
+
this.options = $.extend({}, $.fn.modalmanager.defaults, this.$element.data(), typeof options == 'object' && options);
|
37
|
+
this.stack = [];
|
38
|
+
this.backdropCount = 0;
|
39
|
+
|
40
|
+
if (this.options.resize) {
|
41
|
+
var resizeTimeout,
|
42
|
+
that = this;
|
43
|
+
|
44
|
+
$(window).on('resize.modal', function(){
|
45
|
+
resizeTimeout && clearTimeout(resizeTimeout);
|
46
|
+
resizeTimeout = setTimeout(function(){
|
47
|
+
for (var i = 0; i < that.stack.length; i++){
|
48
|
+
that.stack[i].isShown && that.stack[i].layout();
|
49
|
+
}
|
50
|
+
}, 10);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
},
|
54
|
+
|
55
|
+
createModal: function (element, options) {
|
56
|
+
$(element).modal($.extend({ manager: this }, options));
|
57
|
+
},
|
58
|
+
|
59
|
+
appendModal: function (modal) {
|
60
|
+
this.stack.push(modal);
|
61
|
+
|
62
|
+
var that = this;
|
63
|
+
|
64
|
+
modal.$element.on('show.modalmanager', targetIsSelf(function (e) {
|
65
|
+
|
66
|
+
var showModal = function(){
|
67
|
+
modal.isShown = true;
|
68
|
+
|
69
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
70
|
+
|
71
|
+
that.$element
|
72
|
+
.toggleClass('modal-open', that.hasOpenModal())
|
73
|
+
.toggleClass('page-overflow', $(window).height() < that.$element.height());
|
74
|
+
|
75
|
+
modal.$parent = modal.$element.parent();
|
76
|
+
|
77
|
+
modal.$container = that.createContainer(modal);
|
78
|
+
|
79
|
+
modal.$element.appendTo(modal.$container);
|
80
|
+
|
81
|
+
that.backdrop(modal, function () {
|
82
|
+
modal.$element.show();
|
83
|
+
|
84
|
+
if (transition) {
|
85
|
+
//modal.$element[0].style.display = 'run-in';
|
86
|
+
modal.$element[0].offsetWidth;
|
87
|
+
//modal.$element.one($.support.transition.end, function () { modal.$element[0].style.display = 'block' });
|
88
|
+
}
|
89
|
+
|
90
|
+
modal.layout();
|
91
|
+
|
92
|
+
modal.$element
|
93
|
+
.addClass('in')
|
94
|
+
.attr('aria-hidden', false);
|
95
|
+
|
96
|
+
var complete = function () {
|
97
|
+
that.setFocus();
|
98
|
+
modal.$element.trigger('shown');
|
99
|
+
};
|
100
|
+
|
101
|
+
transition ?
|
102
|
+
modal.$element.one($.support.transition.end, complete) :
|
103
|
+
complete();
|
104
|
+
});
|
105
|
+
};
|
106
|
+
|
107
|
+
modal.options.replace ?
|
108
|
+
that.replace(showModal) :
|
109
|
+
showModal();
|
110
|
+
}));
|
111
|
+
|
112
|
+
modal.$element.on('hidden.modalmanager', targetIsSelf(function (e) {
|
113
|
+
that.backdrop(modal);
|
114
|
+
// handle the case when a modal may have been removed from the dom before this callback executes
|
115
|
+
if (!modal.$element.parent().length) {
|
116
|
+
that.destroyModal(modal);
|
117
|
+
} else if (modal.$backdrop){
|
118
|
+
var transition = $.support.transition && modal.$element.hasClass('fade');
|
119
|
+
|
120
|
+
// trigger a relayout due to firebox's buggy transition end event
|
121
|
+
if (transition) { modal.$element[0].offsetWidth; }
|
122
|
+
$.support.transition && modal.$element.hasClass('fade') ?
|
123
|
+
modal.$backdrop.one($.support.transition.end, function () { modal.destroy(); }) :
|
124
|
+
modal.destroy();
|
125
|
+
} else {
|
126
|
+
modal.destroy();
|
127
|
+
}
|
128
|
+
|
129
|
+
}));
|
130
|
+
|
131
|
+
modal.$element.on('destroyed.modalmanager', targetIsSelf(function (e) {
|
132
|
+
that.destroyModal(modal);
|
133
|
+
}));
|
134
|
+
},
|
135
|
+
|
136
|
+
getOpenModals: function () {
|
137
|
+
var openModals = [];
|
138
|
+
for (var i = 0; i < this.stack.length; i++){
|
139
|
+
if (this.stack[i].isShown) openModals.push(this.stack[i]);
|
140
|
+
}
|
141
|
+
|
142
|
+
return openModals;
|
143
|
+
},
|
144
|
+
|
145
|
+
hasOpenModal: function () {
|
146
|
+
return this.getOpenModals().length > 0;
|
147
|
+
},
|
148
|
+
|
149
|
+
setFocus: function () {
|
150
|
+
var topModal;
|
151
|
+
|
152
|
+
for (var i = 0; i < this.stack.length; i++){
|
153
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
154
|
+
}
|
155
|
+
|
156
|
+
if (!topModal) return;
|
157
|
+
|
158
|
+
topModal.focus();
|
159
|
+
},
|
160
|
+
|
161
|
+
destroyModal: function (modal) {
|
162
|
+
modal.$element.off('.modalmanager');
|
163
|
+
if (modal.$backdrop) this.removeBackdrop(modal);
|
164
|
+
this.stack.splice(this.getIndexOfModal(modal), 1);
|
165
|
+
|
166
|
+
var hasOpenModal = this.hasOpenModal();
|
167
|
+
|
168
|
+
this.$element.toggleClass('modal-open', hasOpenModal);
|
169
|
+
|
170
|
+
if (!hasOpenModal){
|
171
|
+
this.$element.removeClass('page-overflow');
|
172
|
+
}
|
173
|
+
|
174
|
+
this.removeContainer(modal);
|
175
|
+
|
176
|
+
this.setFocus();
|
177
|
+
},
|
178
|
+
|
179
|
+
getModalAt: function (index) {
|
180
|
+
return this.stack[index];
|
181
|
+
},
|
182
|
+
|
183
|
+
getIndexOfModal: function (modal) {
|
184
|
+
for (var i = 0; i < this.stack.length; i++){
|
185
|
+
if (modal === this.stack[i]) return i;
|
186
|
+
}
|
187
|
+
},
|
188
|
+
|
189
|
+
replace: function (callback) {
|
190
|
+
var topModal;
|
191
|
+
|
192
|
+
for (var i = 0; i < this.stack.length; i++){
|
193
|
+
if (this.stack[i].isShown) topModal = this.stack[i];
|
194
|
+
}
|
195
|
+
|
196
|
+
if (topModal) {
|
197
|
+
this.$backdropHandle = topModal.$backdrop;
|
198
|
+
topModal.$backdrop = null;
|
199
|
+
|
200
|
+
callback && topModal.$element.one('hidden',
|
201
|
+
targetIsSelf( $.proxy(callback, this) ));
|
202
|
+
|
203
|
+
topModal.hide();
|
204
|
+
} else if (callback) {
|
205
|
+
callback();
|
206
|
+
}
|
207
|
+
},
|
208
|
+
|
209
|
+
removeBackdrop: function (modal) {
|
210
|
+
modal.$backdrop.remove();
|
211
|
+
modal.$backdrop = null;
|
212
|
+
},
|
213
|
+
|
214
|
+
createBackdrop: function (animate, tmpl) {
|
215
|
+
var $backdrop;
|
216
|
+
|
217
|
+
if (!this.$backdropHandle) {
|
218
|
+
$backdrop = $(tmpl)
|
219
|
+
.addClass(animate)
|
220
|
+
.appendTo(this.$element);
|
221
|
+
} else {
|
222
|
+
$backdrop = this.$backdropHandle;
|
223
|
+
$backdrop.off('.modalmanager');
|
224
|
+
this.$backdropHandle = null;
|
225
|
+
this.isLoading && this.removeSpinner();
|
226
|
+
}
|
227
|
+
|
228
|
+
return $backdrop;
|
229
|
+
},
|
230
|
+
|
231
|
+
removeContainer: function (modal) {
|
232
|
+
modal.$container.remove();
|
233
|
+
modal.$container = null;
|
234
|
+
},
|
235
|
+
|
236
|
+
createContainer: function (modal) {
|
237
|
+
var $container;
|
238
|
+
|
239
|
+
$container = $('<div class="modal-scrollable">')
|
240
|
+
.css('z-index', getzIndex('modal', this.getOpenModals().length))
|
241
|
+
.appendTo(this.$element);
|
242
|
+
|
243
|
+
if (modal && modal.options.backdrop != 'static') {
|
244
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
245
|
+
modal.hide();
|
246
|
+
}));
|
247
|
+
} else if (modal) {
|
248
|
+
$container.on('click.modal', targetIsSelf(function (e) {
|
249
|
+
modal.attention();
|
250
|
+
}));
|
251
|
+
}
|
252
|
+
|
253
|
+
return $container;
|
254
|
+
|
255
|
+
},
|
256
|
+
|
257
|
+
backdrop: function (modal, callback) {
|
258
|
+
var animate = modal.$element.hasClass('fade') ? 'fade' : '',
|
259
|
+
showBackdrop = modal.options.backdrop &&
|
260
|
+
this.backdropCount < this.options.backdropLimit;
|
261
|
+
|
262
|
+
if (modal.isShown && showBackdrop) {
|
263
|
+
var doAnimate = $.support.transition && animate && !this.$backdropHandle;
|
264
|
+
|
265
|
+
modal.$backdrop = this.createBackdrop(animate, modal.options.backdropTemplate);
|
266
|
+
|
267
|
+
modal.$backdrop.css('z-index', getzIndex( 'backdrop', this.getOpenModals().length ));
|
268
|
+
|
269
|
+
if (doAnimate) modal.$backdrop[0].offsetWidth; // force reflow
|
270
|
+
|
271
|
+
modal.$backdrop.addClass('in');
|
272
|
+
|
273
|
+
this.backdropCount += 1;
|
274
|
+
|
275
|
+
doAnimate ?
|
276
|
+
modal.$backdrop.one($.support.transition.end, callback) :
|
277
|
+
callback();
|
278
|
+
|
279
|
+
} else if (!modal.isShown && modal.$backdrop) {
|
280
|
+
modal.$backdrop.removeClass('in');
|
281
|
+
|
282
|
+
this.backdropCount -= 1;
|
283
|
+
|
284
|
+
var that = this;
|
285
|
+
|
286
|
+
$.support.transition && modal.$element.hasClass('fade')?
|
287
|
+
modal.$backdrop.one($.support.transition.end, function () { that.removeBackdrop(modal) }) :
|
288
|
+
that.removeBackdrop(modal);
|
289
|
+
|
290
|
+
} else if (callback) {
|
291
|
+
callback();
|
292
|
+
}
|
293
|
+
},
|
294
|
+
|
295
|
+
removeSpinner: function(){
|
296
|
+
this.$spinner && this.$spinner.remove();
|
297
|
+
this.$spinner = null;
|
298
|
+
this.isLoading = false;
|
299
|
+
},
|
300
|
+
|
301
|
+
removeLoading: function () {
|
302
|
+
this.$backdropHandle && this.$backdropHandle.remove();
|
303
|
+
this.$backdropHandle = null;
|
304
|
+
this.removeSpinner();
|
305
|
+
},
|
306
|
+
|
307
|
+
loading: function (callback) {
|
308
|
+
callback = callback || function () { };
|
309
|
+
|
310
|
+
this.$element
|
311
|
+
.toggleClass('modal-open', !this.isLoading || this.hasOpenModal())
|
312
|
+
.toggleClass('page-overflow', $(window).height() < this.$element.height());
|
313
|
+
|
314
|
+
if (!this.isLoading) {
|
315
|
+
|
316
|
+
this.$backdropHandle = this.createBackdrop('fade', this.options.backdropTemplate);
|
317
|
+
|
318
|
+
this.$backdropHandle[0].offsetWidth; // force reflow
|
319
|
+
|
320
|
+
var openModals = this.getOpenModals();
|
321
|
+
|
322
|
+
this.$backdropHandle
|
323
|
+
.css('z-index', getzIndex('backdrop', openModals.length + 1))
|
324
|
+
.addClass('in');
|
325
|
+
|
326
|
+
var $spinner = $(this.options.spinner)
|
327
|
+
.css('z-index', getzIndex('modal', openModals.length + 1))
|
328
|
+
.appendTo(this.$element)
|
329
|
+
.addClass('in');
|
330
|
+
|
331
|
+
this.$spinner = $(this.createContainer())
|
332
|
+
.append($spinner)
|
333
|
+
.on('click.modalmanager', $.proxy(this.loading, this));
|
334
|
+
|
335
|
+
this.isLoading = true;
|
336
|
+
|
337
|
+
$.support.transition ?
|
338
|
+
this.$backdropHandle.one($.support.transition.end, callback) :
|
339
|
+
callback();
|
340
|
+
|
341
|
+
} else if (this.isLoading && this.$backdropHandle) {
|
342
|
+
this.$backdropHandle.removeClass('in');
|
343
|
+
|
344
|
+
var that = this;
|
345
|
+
$.support.transition ?
|
346
|
+
this.$backdropHandle.one($.support.transition.end, function () { that.removeLoading() }) :
|
347
|
+
that.removeLoading();
|
348
|
+
|
349
|
+
} else if (callback) {
|
350
|
+
callback(this.isLoading);
|
351
|
+
}
|
352
|
+
}
|
353
|
+
};
|
354
|
+
|
355
|
+
/* PRIVATE METHODS
|
356
|
+
* ======================= */
|
357
|
+
|
358
|
+
// computes and caches the zindexes
|
359
|
+
var getzIndex = (function () {
|
360
|
+
var zIndexFactor,
|
361
|
+
baseIndex = {};
|
362
|
+
|
363
|
+
return function (type, pos) {
|
364
|
+
|
365
|
+
if (typeof zIndexFactor === 'undefined'){
|
366
|
+
var $baseModal = $('<div class="modal hide" />').appendTo('body'),
|
367
|
+
$baseBackdrop = $('<div class="modal-backdrop hide" />').appendTo('body');
|
368
|
+
|
369
|
+
baseIndex['modal'] = +$baseModal.css('z-index');
|
370
|
+
baseIndex['backdrop'] = +$baseBackdrop.css('z-index');
|
371
|
+
zIndexFactor = baseIndex['modal'] - baseIndex['backdrop'];
|
372
|
+
|
373
|
+
$baseModal.remove();
|
374
|
+
$baseBackdrop.remove();
|
375
|
+
$baseBackdrop = $baseModal = null;
|
376
|
+
}
|
377
|
+
|
378
|
+
return baseIndex[type] + (zIndexFactor * pos);
|
379
|
+
|
380
|
+
}
|
381
|
+
}());
|
382
|
+
|
383
|
+
// make sure the event target is the modal itself in order to prevent
|
384
|
+
// other components such as tabsfrom triggering the modal manager.
|
385
|
+
// if Boostsrap namespaced events, this would not be needed.
|
386
|
+
function targetIsSelf(callback){
|
387
|
+
return function (e) {
|
388
|
+
if (this === e.target){
|
389
|
+
return callback.apply(this, arguments);
|
390
|
+
}
|
391
|
+
}
|
392
|
+
}
|
393
|
+
|
394
|
+
|
395
|
+
/* MODAL MANAGER PLUGIN DEFINITION
|
396
|
+
* ======================= */
|
397
|
+
|
398
|
+
$.fn.modalmanager = function (option, args) {
|
399
|
+
return this.each(function () {
|
400
|
+
var $this = $(this),
|
401
|
+
data = $this.data('modalmanager');
|
402
|
+
|
403
|
+
if (!data) $this.data('modalmanager', (data = new ModalManager(this, option)));
|
404
|
+
if (typeof option === 'string') data[option].apply(data, [].concat(args))
|
405
|
+
})
|
406
|
+
};
|
407
|
+
|
408
|
+
$.fn.modalmanager.defaults = {
|
409
|
+
backdropLimit: 999,
|
410
|
+
resize: true,
|
411
|
+
spinner: '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><div class="progress progress-striped active"><div class="bar" style="width: 100%;"></div></div></div>',
|
412
|
+
backdropTemplate: '<div class="modal-backdrop" />'
|
413
|
+
};
|
414
|
+
|
415
|
+
$.fn.modalmanager.Constructor = ModalManager
|
416
|
+
|
417
|
+
// ModalManager handles the modal-open class so we need
|
418
|
+
// to remove conflicting bootstrap 3 event handlers
|
419
|
+
$(function () {
|
420
|
+
$(document).off('show.bs.modal').off('hidden.bs.modal');
|
421
|
+
});
|
422
|
+
|
423
|
+
}(jQuery);
|