rails_admin 2.1.0 → 3.0.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of rails_admin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile +9 -11
- data/README.md +37 -31
- data/Rakefile +2 -2
- data/app/assets/javascripts/rails_admin.js +21 -0
- data/app/assets/stylesheets/rails_admin/custom/mixins.scss +1 -1
- data/app/assets/stylesheets/rails_admin/custom/variables.scss +1 -1
- data/app/assets/stylesheets/rails_admin.scss.erb +76 -0
- data/app/controllers/rails_admin/application_controller.rb +4 -3
- data/app/controllers/rails_admin/main_controller.rb +43 -24
- data/app/helpers/rails_admin/application_helper.rb +69 -52
- data/app/helpers/rails_admin/form_builder.rb +7 -4
- data/app/helpers/rails_admin/main_helper.rb +27 -43
- data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb +5 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb +13 -0
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb +9 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb +6 -0
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb +9 -0
- data/app/views/layouts/rails_admin/_head.html.erb +17 -0
- data/app/views/layouts/rails_admin/_navigation.html.erb +21 -0
- data/app/views/layouts/rails_admin/_secondary_navigation.html.erb +24 -0
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +9 -0
- data/app/views/layouts/rails_admin/application.html.erb +27 -0
- data/app/views/layouts/rails_admin/modal.js.erb +7 -0
- data/app/views/layouts/rails_admin/pjax.html.erb +20 -0
- data/app/views/rails_admin/main/_dashboard_history.html.erb +45 -0
- data/app/views/rails_admin/main/_delete_notice.html.erb +35 -0
- data/app/views/rails_admin/main/_form_action_text.html.erb +7 -0
- data/app/views/rails_admin/main/_form_boolean.html.erb +16 -0
- data/app/views/rails_admin/main/{_form_ck_editor.html.haml → _form_ck_editor.html.erb} +3 -3
- data/app/views/rails_admin/main/_form_code_mirror.html.erb +9 -0
- data/app/views/rails_admin/main/_form_colorpicker.html.erb +1 -0
- data/app/views/rails_admin/main/_form_datetime.html.erb +9 -0
- data/app/views/rails_admin/main/_form_enumeration.html.erb +21 -0
- data/app/views/rails_admin/main/_form_field.html.erb +1 -0
- data/app/views/rails_admin/main/_form_file_upload.html.erb +17 -0
- data/app/views/rails_admin/main/{_form_filtering_multiselect.html.haml → _form_filtering_multiselect.html.erb} +11 -11
- data/app/views/rails_admin/main/{_form_filtering_select.html.haml → _form_filtering_select.html.erb} +13 -12
- data/app/views/rails_admin/main/_form_froala.html.erb +8 -0
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.erb +20 -0
- data/app/views/rails_admin/main/_form_nested_many.html.erb +21 -0
- data/app/views/rails_admin/main/_form_nested_one.html.erb +21 -0
- data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +27 -0
- data/app/views/rails_admin/main/_form_simple_mde.html.erb +8 -0
- data/app/views/rails_admin/main/_form_text.html.erb +1 -0
- data/app/views/rails_admin/main/_form_wysihtml5.html.erb +8 -0
- data/app/views/rails_admin/main/_submit_buttons.html.erb +25 -0
- data/app/views/rails_admin/main/bulk_delete.html.erb +19 -0
- data/app/views/rails_admin/main/dashboard.html.erb +64 -0
- data/app/views/rails_admin/main/delete.html.erb +21 -0
- data/app/views/rails_admin/main/edit.html.erb +3 -0
- data/app/views/rails_admin/main/export.html.erb +146 -0
- data/app/views/rails_admin/main/history.html.erb +78 -0
- data/app/views/rails_admin/main/index.html.erb +193 -0
- data/app/views/rails_admin/main/new.html.erb +3 -0
- data/app/views/rails_admin/main/show.html.erb +28 -0
- data/config/initializers/active_record_extensions.rb +3 -1
- data/config/initializers/mongoid_extensions.rb +1 -1
- data/config/locales/rails_admin.en.yml +6 -1
- data/lib/generators/rails_admin/install_generator.rb +51 -3
- data/lib/generators/rails_admin/templates/environment.js +6 -0
- data/lib/generators/rails_admin/templates/initializer.erb +2 -1
- data/lib/generators/rails_admin/templates/rails_admin.js.erb +2 -0
- data/lib/generators/rails_admin/templates/rails_admin.scss +1 -0
- data/lib/generators/rails_admin/templates/webpack.config.js +32 -0
- data/lib/rails_admin/abstract_model.rb +24 -10
- data/lib/rails_admin/adapters/active_record/association.rb +20 -1
- data/lib/rails_admin/adapters/active_record/object_extension.rb +29 -0
- data/lib/rails_admin/adapters/active_record/property.rb +1 -1
- data/lib/rails_admin/adapters/active_record.rb +27 -23
- data/lib/rails_admin/adapters/mongoid/association.rb +38 -9
- data/lib/rails_admin/adapters/mongoid/bson.rb +4 -5
- data/lib/rails_admin/adapters/mongoid/extension.rb +3 -1
- data/lib/rails_admin/adapters/mongoid/object_extension.rb +32 -0
- data/lib/rails_admin/adapters/mongoid/property.rb +2 -2
- data/lib/rails_admin/adapters/mongoid.rb +27 -19
- data/lib/rails_admin/config/actions/base.rb +7 -2
- data/lib/rails_admin/config/actions/bulk_delete.rb +2 -2
- data/lib/rails_admin/config/actions/dashboard.rb +4 -3
- data/lib/rails_admin/config/actions/delete.rb +5 -9
- data/lib/rails_admin/config/actions/edit.rb +7 -7
- data/lib/rails_admin/config/actions/export.rb +2 -2
- data/lib/rails_admin/config/actions/history_index.rb +2 -2
- data/lib/rails_admin/config/actions/history_show.rb +2 -2
- data/lib/rails_admin/config/actions/index.rb +5 -7
- data/lib/rails_admin/config/actions/new.rb +9 -9
- data/lib/rails_admin/config/actions/show.rb +1 -1
- data/lib/rails_admin/config/actions/show_in_app.rb +6 -2
- data/lib/rails_admin/config/actions.rb +4 -4
- data/lib/rails_admin/config/configurable.rb +2 -2
- data/lib/rails_admin/config/fields/association.rb +15 -12
- data/lib/rails_admin/config/fields/base.rb +44 -24
- data/lib/rails_admin/config/fields/factories/active_storage.rb +1 -0
- data/lib/rails_admin/config/fields/factories/association.rb +6 -8
- data/lib/rails_admin/config/fields/factories/carrierwave.rb +2 -1
- data/lib/rails_admin/config/fields/factories/devise.rb +2 -1
- data/lib/rails_admin/config/fields/factories/dragonfly.rb +2 -1
- data/lib/rails_admin/config/fields/factories/paperclip.rb +2 -1
- data/lib/rails_admin/config/fields/factories/shrine.rb +1 -1
- data/lib/rails_admin/config/fields/group.rb +1 -2
- data/lib/rails_admin/config/fields/types/active_record_enum.rb +2 -0
- data/lib/rails_admin/config/fields/types/active_storage.rb +9 -7
- data/lib/rails_admin/config/fields/types/all.rb +1 -0
- data/lib/rails_admin/config/fields/types/belongs_to_association.rb +4 -12
- data/lib/rails_admin/config/fields/types/boolean.rb +32 -8
- data/lib/rails_admin/config/fields/types/carrierwave.rb +1 -0
- data/lib/rails_admin/config/fields/types/citext.rb +13 -0
- data/lib/rails_admin/config/fields/types/color.rb +6 -2
- data/lib/rails_admin/config/fields/types/date.rb +5 -8
- data/lib/rails_admin/config/fields/types/datetime.rb +18 -21
- data/lib/rails_admin/config/fields/types/decimal.rb +9 -2
- data/lib/rails_admin/config/fields/types/dragonfly.rb +3 -1
- data/lib/rails_admin/config/fields/types/enum.rb +1 -1
- data/lib/rails_admin/config/fields/types/file_upload.rb +4 -3
- data/lib/rails_admin/config/fields/types/float.rb +9 -2
- data/lib/rails_admin/config/fields/types/has_many_association.rb +1 -5
- data/lib/rails_admin/config/fields/types/has_one_association.rb +1 -13
- data/lib/rails_admin/config/fields/types/integer.rb +2 -6
- data/lib/rails_admin/config/fields/types/multiple_active_storage.rb +8 -6
- data/lib/rails_admin/config/fields/types/multiple_carrierwave.rb +1 -0
- data/lib/rails_admin/config/fields/types/multiple_file_upload.rb +4 -3
- data/lib/rails_admin/config/fields/types/numeric.rb +18 -0
- data/lib/rails_admin/config/fields/types/polymorphic_association.rb +3 -2
- data/lib/rails_admin/config/fields/types/string.rb +1 -1
- data/lib/rails_admin/config/fields/types/time.rb +1 -4
- data/lib/rails_admin/config/fields/types/timestamp.rb +0 -4
- data/lib/rails_admin/config/fields/types.rb +1 -1
- data/lib/rails_admin/config/fields.rb +3 -1
- data/lib/rails_admin/config/has_fields.rb +5 -6
- data/lib/rails_admin/config/hideable.rb +1 -1
- data/lib/rails_admin/config/inspectable.rb +1 -3
- data/lib/rails_admin/config/model.rb +10 -10
- data/lib/rails_admin/config/sections/base.rb +2 -3
- data/lib/rails_admin/config/sections/list.rb +4 -15
- data/lib/rails_admin/config/sections.rb +1 -1
- data/lib/rails_admin/config.rb +73 -38
- data/lib/rails_admin/engine.rb +36 -23
- data/lib/rails_admin/extension.rb +6 -14
- data/lib/rails_admin/extensions/cancancan/authorization_adapter.rb +4 -2
- data/lib/rails_admin/extensions/paper_trail/auditing_adapter.rb +13 -8
- data/lib/rails_admin/extensions/pundit/authorization_adapter.rb +6 -7
- data/lib/rails_admin/support/csv_converter.rb +12 -13
- data/lib/rails_admin/support/datetime.rb +40 -74
- data/lib/rails_admin/support/esmodule_preprocessor.rb +32 -0
- data/lib/rails_admin/support/hash_helper.rb +6 -5
- data/lib/rails_admin/version.rb +7 -3
- data/lib/rails_admin.rb +1 -4
- data/lib/tasks/rails_admin.rake +3 -3
- data/package.json +28 -0
- data/src/rails_admin/base.js +21 -0
- data/src/rails_admin/filter-box.js +405 -0
- data/src/rails_admin/filtering-multiselect.js +394 -0
- data/src/rails_admin/filtering-select.js +302 -0
- data/src/rails_admin/i18n.js +19 -0
- data/src/rails_admin/nested-form-hooks.js +100 -0
- data/src/rails_admin/remote-form.js +190 -0
- data/src/rails_admin/sidescroll.js +20 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/README.txt +0 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/mixins.scss +0 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/theming.scss +93 -34
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/base/variables.scss +0 -0
- data/src/rails_admin/styles/base.scss +64 -0
- data/src/rails_admin/styles/filtering-multiselect.scss +53 -0
- data/src/rails_admin/styles/filtering-select.scss +70 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/mixins.scss +0 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/cerulean/theming.scss +23 -21
- data/src/rails_admin/styles/themes/cerulean/variables.scss +830 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/mixins.scss +1 -1
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/theming.scss +0 -0
- data/{app/assets/stylesheets/rails_admin → src/rails_admin/styles}/themes/default/variables.scss +1 -1
- data/src/rails_admin/styles/widgets.scss +35 -0
- data/src/rails_admin/ui.js +172 -0
- data/src/rails_admin/vendor/jquery.pjax.js +899 -0
- data/src/rails_admin/vendor/jquery_nested_form.js +122 -0
- data/src/rails_admin/widgets.js +512 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.eot +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.svg +5034 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.ttf +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.woff +0 -0
- data/vendor/assets/fonts/rails_admin/fa-solid-900.woff2 +0 -0
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-affix.js +50 -28
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-alert.js +10 -7
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-button.js +35 -20
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-carousel.js +48 -25
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-collapse.js +70 -28
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-dropdown.js +56 -42
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-modal.js +118 -40
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-popover.js +26 -16
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-scrollspy.js +29 -27
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tab.js +46 -19
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-tooltip.js +280 -60
- data/vendor/assets/javascripts/rails_admin/bootstrap/bootstrap-transition.js +5 -5
- data/vendor/assets/javascripts/rails_admin/bootstrap-datetimepicker.js +317 -150
- data/vendor/assets/javascripts/rails_admin/jquery-ui/data.js +41 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/effect.js +1637 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/ie.js +17 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/keycode.js +47 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/position.js +500 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/safe-active-element.js +42 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/scroll-parent.js +47 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/unique-id.js +51 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/version.js +17 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widget.js +735 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/autocomplete.js +689 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/menu.js +680 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/mouse.js +230 -0
- data/vendor/assets/javascripts/rails_admin/jquery-ui/widgets/sortable.js +1561 -0
- data/vendor/assets/javascripts/rails_admin/jquery.pjax.js +317 -160
- data/vendor/assets/javascripts/rails_admin/jquery3.js +10872 -0
- data/vendor/assets/javascripts/rails_admin/moment-with-locales.js +11210 -9290
- data/vendor/assets/stylesheets/rails_admin/font-awesome.scss +4476 -2216
- metadata +118 -262
- data/app/assets/images/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/images/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/images/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/images/rails_admin/bullet_black.png +0 -0
- data/app/assets/images/rails_admin/bullet_white.png +0 -0
- data/app/assets/images/rails_admin/calendar.png +0 -0
- data/app/assets/images/rails_admin/clock.png +0 -0
- data/app/assets/images/rails_admin/logo.png +0 -0
- data/app/assets/images/rails_admin/magnifier.png +0 -0
- data/app/assets/images/rails_admin/multiselect/icon_sprite.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-n-light.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png +0 -0
- data/app/assets/images/rails_admin/multiselect/ui-icon-circle-triangle-s-light.png +0 -0
- data/app/assets/javascripts/rails_admin/jquery-ui.js.erb +0 -8
- data/app/assets/javascripts/rails_admin/ra.filter-box.js +0 -248
- data/app/assets/javascripts/rails_admin/ra.filtering-multiselect.js +0 -331
- data/app/assets/javascripts/rails_admin/ra.filtering-select.js +0 -294
- data/app/assets/javascripts/rails_admin/ra.i18n.js +0 -28
- data/app/assets/javascripts/rails_admin/ra.nested-form-hooks.js +0 -59
- data/app/assets/javascripts/rails_admin/ra.remote-form.js +0 -155
- data/app/assets/javascripts/rails_admin/ra.sidescroll.js +0 -31
- data/app/assets/javascripts/rails_admin/ra.widgets.js +0 -379
- data/app/assets/javascripts/rails_admin/rails_admin.js +0 -20
- data/app/assets/javascripts/rails_admin/ui.js +0 -135
- data/app/assets/stylesheets/rails_admin/aristo/images/bg_fallback.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/icon_sprite.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/progress_bar.gif +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/slider_handles.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_222222_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/images/ui-icons_454545_256x240.png +0 -0
- data/app/assets/stylesheets/rails_admin/aristo/jquery-ui-1.8.7.custom.scss +0 -733
- data/app/assets/stylesheets/rails_admin/base/font-awesome-4-compability.scss +0 -153
- data/app/assets/stylesheets/rails_admin/ra.filtering-multiselect.scss +0 -88
- data/app/assets/stylesheets/rails_admin/ra.sidescroll.scss +0 -29
- data/app/assets/stylesheets/rails_admin/ra.widgets.scss +0 -17
- data/app/assets/stylesheets/rails_admin/rails_admin.scss.erb +0 -110
- data/app/assets/stylesheets/rails_admin/themes/cerulean/variables.scss +0 -857
- data/app/views/kaminari/ra-twitter-bootstrap/_gap.html.haml +0 -2
- data/app/views/kaminari/ra-twitter-bootstrap/_next_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/_paginator.html.haml +0 -9
- data/app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.haml +0 -4
- data/app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.haml +0 -4
- data/app/views/layouts/rails_admin/_head.html.haml +0 -7
- data/app/views/layouts/rails_admin/_navigation.html.haml +0 -12
- data/app/views/layouts/rails_admin/_secondary_navigation.html.haml +0 -10
- data/app/views/layouts/rails_admin/_sidebar_navigation.html.haml +0 -3
- data/app/views/layouts/rails_admin/application.html.haml +0 -16
- data/app/views/layouts/rails_admin/pjax.html.haml +0 -12
- data/app/views/rails_admin/main/_dashboard_history.html.haml +0 -21
- data/app/views/rails_admin/main/_delete_notice.html.haml +0 -24
- data/app/views/rails_admin/main/_form_action_text.html.haml +0 -7
- data/app/views/rails_admin/main/_form_boolean.html.haml +0 -3
- data/app/views/rails_admin/main/_form_code_mirror.html.haml +0 -9
- data/app/views/rails_admin/main/_form_colorpicker.html.haml +0 -1
- data/app/views/rails_admin/main/_form_datetime.html.haml +0 -5
- data/app/views/rails_admin/main/_form_enumeration.html.haml +0 -19
- data/app/views/rails_admin/main/_form_field.html.haml +0 -1
- data/app/views/rails_admin/main/_form_file_upload.html.haml +0 -17
- data/app/views/rails_admin/main/_form_froala.html.haml +0 -8
- data/app/views/rails_admin/main/_form_multiple_file_upload.html.haml +0 -16
- data/app/views/rails_admin/main/_form_nested_many.html.haml +0 -15
- data/app/views/rails_admin/main/_form_nested_one.html.haml +0 -17
- data/app/views/rails_admin/main/_form_polymorphic_association.html.haml +0 -26
- data/app/views/rails_admin/main/_form_simple_mde.haml +0 -8
- data/app/views/rails_admin/main/_form_text.html.haml +0 -1
- data/app/views/rails_admin/main/_form_wysihtml5.html.haml +0 -8
- data/app/views/rails_admin/main/_submit_buttons.html.haml +0 -16
- data/app/views/rails_admin/main/bulk_delete.html.haml +0 -11
- data/app/views/rails_admin/main/dashboard.html.haml +0 -34
- data/app/views/rails_admin/main/delete.html.haml +0 -18
- data/app/views/rails_admin/main/edit.html.haml +0 -2
- data/app/views/rails_admin/main/export.html.haml +0 -92
- data/app/views/rails_admin/main/history.html.haml +0 -51
- data/app/views/rails_admin/main/index.html.haml +0 -126
- data/app/views/rails_admin/main/new.html.haml +0 -2
- data/app/views/rails_admin/main/show.html.haml +0 -15
- data/config/initializers/devise_patch.rb +0 -9
- data/config/initializers/haml.rb +0 -5
- data/lib/rails_admin/adapters/active_record/abstract_object.rb +0 -32
- data/lib/rails_admin/adapters/mongoid/abstract_object.rb +0 -42
- data/lib/rails_admin/bootstrap-sass/compass_functions.rb +0 -28
- data/lib/rails_admin/bootstrap-sass/sass_functions.rb +0 -16
- data/lib/rails_admin/bootstrap-sass.rb +0 -49
- data/lib/rails_admin/config/lazy_model.rb +0 -68
- data/lib/rails_admin/extensions/history/auditing_adapter.rb +0 -37
- data/lib/rails_admin/extensions/history/history.rb +0 -44
- data/lib/rails_admin/extensions/history.rb +0 -3
- data/lib/rails_admin/support/i18n.rb +0 -43
- data/vendor/assets/fonts/rails_admin/FontAwesome.otf +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.eot +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.svg +0 -2671
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.ttf +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff +0 -0
- data/vendor/assets/fonts/rails_admin/fontawesome-webfont.woff2 +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_background.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hex.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_h.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_hsb_s.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_indic.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_overlay.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_g.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_rgb_r.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_select.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/colorpicker_submit.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_background.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hex.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_h.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_hsb_s.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_indic.gif +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_b.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_g.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_rgb_r.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/custom_submit.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/select.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/select2.png +0 -0
- data/vendor/assets/images/rails_admin/colorpicker/slider.png +0 -0
- data/vendor/assets/javascripts/rails_admin/jquery.colorpicker.js +0 -484
- data/vendor/assets/stylesheets/rails_admin/jquery.colorpicker.scss +0 -182
@@ -0,0 +1,899 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2012, Chris Wanstrath
|
3
|
+
* Released under the MIT License
|
4
|
+
* https://github.com/defunkt/jquery-pjax
|
5
|
+
*/
|
6
|
+
import jQuery from 'jquery';
|
7
|
+
|
8
|
+
(function($){
|
9
|
+
|
10
|
+
// When called on a container with a selector, fetches the href with
|
11
|
+
// ajax into the container or with the data-pjax attribute on the link
|
12
|
+
// itself.
|
13
|
+
//
|
14
|
+
// Tries to make sure the back button and ctrl+click work the way
|
15
|
+
// you'd expect.
|
16
|
+
//
|
17
|
+
// Exported as $.fn.pjax
|
18
|
+
//
|
19
|
+
// Accepts a jQuery ajax options object that may include these
|
20
|
+
// pjax specific options:
|
21
|
+
//
|
22
|
+
//
|
23
|
+
// container - String selector for the element where to place the response body.
|
24
|
+
// push - Whether to pushState the URL. Defaults to true (of course).
|
25
|
+
// replace - Want to use replaceState instead? That's cool.
|
26
|
+
//
|
27
|
+
// For convenience the second parameter can be either the container or
|
28
|
+
// the options object.
|
29
|
+
//
|
30
|
+
// Returns the jQuery object
|
31
|
+
function fnPjax(selector, container, options) {
|
32
|
+
options = optionsFor(container, options)
|
33
|
+
return this.on('click.pjax', selector, function(event) {
|
34
|
+
var opts = options
|
35
|
+
if (!opts.container) {
|
36
|
+
opts = $.extend({}, options)
|
37
|
+
opts.container = $(this).attr('data-pjax')
|
38
|
+
}
|
39
|
+
handleClick(event, opts)
|
40
|
+
})
|
41
|
+
}
|
42
|
+
|
43
|
+
// Public: pjax on click handler
|
44
|
+
//
|
45
|
+
// Exported as $.pjax.click.
|
46
|
+
//
|
47
|
+
// event - "click" jQuery.Event
|
48
|
+
// options - pjax options
|
49
|
+
//
|
50
|
+
// Examples
|
51
|
+
//
|
52
|
+
// $(document).on('click', 'a', $.pjax.click)
|
53
|
+
// // is the same as
|
54
|
+
// $(document).pjax('a')
|
55
|
+
//
|
56
|
+
// Returns nothing.
|
57
|
+
function handleClick(event, container, options) {
|
58
|
+
options = optionsFor(container, options)
|
59
|
+
|
60
|
+
var link = event.currentTarget
|
61
|
+
var $link = $(link)
|
62
|
+
|
63
|
+
if (link.tagName.toUpperCase() !== 'A')
|
64
|
+
throw "$.fn.pjax or $.pjax.click requires an anchor element"
|
65
|
+
|
66
|
+
// Middle click, cmd click, and ctrl click should open
|
67
|
+
// links in a new tab as normal.
|
68
|
+
if ( event.which > 1 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey )
|
69
|
+
return
|
70
|
+
|
71
|
+
// Ignore cross origin links
|
72
|
+
if ( location.protocol !== link.protocol || location.hostname !== link.hostname )
|
73
|
+
return
|
74
|
+
|
75
|
+
// Ignore case when a hash is being tacked on the current URL
|
76
|
+
if ( link.href.indexOf('#') > -1 && stripHash(link) == stripHash(location) )
|
77
|
+
return
|
78
|
+
|
79
|
+
// Ignore event with default prevented
|
80
|
+
if (event.isDefaultPrevented())
|
81
|
+
return
|
82
|
+
|
83
|
+
var defaults = {
|
84
|
+
url: link.href,
|
85
|
+
container: $link.attr('data-pjax'),
|
86
|
+
target: link
|
87
|
+
}
|
88
|
+
|
89
|
+
var opts = $.extend({}, defaults, options)
|
90
|
+
var clickEvent = $.Event('pjax:click')
|
91
|
+
$link.trigger(clickEvent, [opts])
|
92
|
+
|
93
|
+
if (!clickEvent.isDefaultPrevented()) {
|
94
|
+
pjax(opts)
|
95
|
+
event.preventDefault()
|
96
|
+
$link.trigger('pjax:clicked', [opts])
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
// Public: pjax on form submit handler
|
101
|
+
//
|
102
|
+
// Exported as $.pjax.submit
|
103
|
+
//
|
104
|
+
// event - "click" jQuery.Event
|
105
|
+
// options - pjax options
|
106
|
+
//
|
107
|
+
// Examples
|
108
|
+
//
|
109
|
+
// $(document).on('submit', 'form', function(event) {
|
110
|
+
// $.pjax.submit(event, '[data-pjax-container]')
|
111
|
+
// })
|
112
|
+
//
|
113
|
+
// Returns nothing.
|
114
|
+
function handleSubmit(event, container, options) {
|
115
|
+
options = optionsFor(container, options)
|
116
|
+
|
117
|
+
var form = event.currentTarget
|
118
|
+
var $form = $(form)
|
119
|
+
|
120
|
+
if (form.tagName.toUpperCase() !== 'FORM')
|
121
|
+
throw "$.pjax.submit requires a form element"
|
122
|
+
|
123
|
+
var defaults = {
|
124
|
+
type: ($form.attr('method') || 'GET').toUpperCase(),
|
125
|
+
url: $form.attr('action'),
|
126
|
+
container: $form.attr('data-pjax'),
|
127
|
+
target: form
|
128
|
+
}
|
129
|
+
|
130
|
+
if (defaults.type !== 'GET' && window.FormData !== undefined) {
|
131
|
+
defaults.data = new FormData(form)
|
132
|
+
defaults.processData = false
|
133
|
+
defaults.contentType = false
|
134
|
+
} else {
|
135
|
+
// Can't handle file uploads, exit
|
136
|
+
if ($form.find(':file').length) {
|
137
|
+
return
|
138
|
+
}
|
139
|
+
|
140
|
+
// Fallback to manually serializing the fields
|
141
|
+
defaults.data = $form.serializeArray()
|
142
|
+
}
|
143
|
+
|
144
|
+
pjax($.extend({}, defaults, options))
|
145
|
+
|
146
|
+
event.preventDefault()
|
147
|
+
}
|
148
|
+
|
149
|
+
// Loads a URL with ajax, puts the response body inside a container,
|
150
|
+
// then pushState()'s the loaded URL.
|
151
|
+
//
|
152
|
+
// Works just like $.ajax in that it accepts a jQuery ajax
|
153
|
+
// settings object (with keys like url, type, data, etc).
|
154
|
+
//
|
155
|
+
// Accepts these extra keys:
|
156
|
+
//
|
157
|
+
// container - String selector for where to stick the response body.
|
158
|
+
// push - Whether to pushState the URL. Defaults to true (of course).
|
159
|
+
// replace - Want to use replaceState instead? That's cool.
|
160
|
+
//
|
161
|
+
// Use it just like $.ajax:
|
162
|
+
//
|
163
|
+
// var xhr = $.pjax({ url: this.href, container: '#main' })
|
164
|
+
// console.log( xhr.readyState )
|
165
|
+
//
|
166
|
+
// Returns whatever $.ajax returns.
|
167
|
+
function pjax(options) {
|
168
|
+
options = $.extend(true, {}, $.ajaxSettings, pjax.defaults, options)
|
169
|
+
|
170
|
+
if ($.isFunction(options.url)) {
|
171
|
+
options.url = options.url()
|
172
|
+
}
|
173
|
+
|
174
|
+
var hash = parseURL(options.url).hash
|
175
|
+
|
176
|
+
var containerType = $.type(options.container)
|
177
|
+
if (containerType !== 'string') {
|
178
|
+
throw "expected string value for 'container' option; got " + containerType
|
179
|
+
}
|
180
|
+
var context = options.context = $(options.container)
|
181
|
+
if (!context.length) {
|
182
|
+
throw "the container selector '" + options.container + "' did not match anything"
|
183
|
+
}
|
184
|
+
|
185
|
+
// We want the browser to maintain two separate internal caches: one
|
186
|
+
// for pjax'd partial page loads and one for normal page loads.
|
187
|
+
// Without adding this secret parameter, some browsers will often
|
188
|
+
// confuse the two.
|
189
|
+
if (!options.data) options.data = {}
|
190
|
+
if ($.isArray(options.data)) {
|
191
|
+
options.data.push({name: '_pjax', value: options.container})
|
192
|
+
} else {
|
193
|
+
options.data._pjax = options.container
|
194
|
+
}
|
195
|
+
|
196
|
+
function fire(type, args, props) {
|
197
|
+
if (!props) props = {}
|
198
|
+
props.relatedTarget = options.target
|
199
|
+
var event = $.Event(type, props)
|
200
|
+
context.trigger(event, args)
|
201
|
+
return !event.isDefaultPrevented()
|
202
|
+
}
|
203
|
+
|
204
|
+
var timeoutTimer
|
205
|
+
|
206
|
+
options.beforeSend = function(xhr, settings) {
|
207
|
+
// No timeout for non-GET requests
|
208
|
+
// Its not safe to request the resource again with a fallback method.
|
209
|
+
if (settings.type !== 'GET') {
|
210
|
+
settings.timeout = 0
|
211
|
+
}
|
212
|
+
|
213
|
+
xhr.setRequestHeader('X-PJAX', 'true')
|
214
|
+
xhr.setRequestHeader('X-PJAX-Container', options.container)
|
215
|
+
|
216
|
+
if (!fire('pjax:beforeSend', [xhr, settings]))
|
217
|
+
return false
|
218
|
+
|
219
|
+
if (settings.timeout > 0) {
|
220
|
+
timeoutTimer = setTimeout(function() {
|
221
|
+
if (fire('pjax:timeout', [xhr, options]))
|
222
|
+
xhr.abort('timeout')
|
223
|
+
}, settings.timeout)
|
224
|
+
|
225
|
+
// Clear timeout setting so jquerys internal timeout isn't invoked
|
226
|
+
settings.timeout = 0
|
227
|
+
}
|
228
|
+
|
229
|
+
var url = parseURL(settings.url)
|
230
|
+
if (hash) url.hash = hash
|
231
|
+
options.requestUrl = stripInternalParams(url)
|
232
|
+
}
|
233
|
+
|
234
|
+
options.complete = function(xhr, textStatus) {
|
235
|
+
if (timeoutTimer)
|
236
|
+
clearTimeout(timeoutTimer)
|
237
|
+
|
238
|
+
fire('pjax:complete', [xhr, textStatus, options])
|
239
|
+
|
240
|
+
fire('pjax:end', [xhr, options])
|
241
|
+
}
|
242
|
+
|
243
|
+
options.error = function(xhr, textStatus, errorThrown) {
|
244
|
+
var container = extractContainer("", xhr, options)
|
245
|
+
|
246
|
+
var allowed = fire('pjax:error', [xhr, textStatus, errorThrown, options])
|
247
|
+
if (options.type == 'GET' && textStatus !== 'abort' && allowed) {
|
248
|
+
locationReplace(container.url)
|
249
|
+
}
|
250
|
+
}
|
251
|
+
|
252
|
+
options.success = function(data, status, xhr) {
|
253
|
+
var previousState = pjax.state
|
254
|
+
|
255
|
+
// If $.pjax.defaults.version is a function, invoke it first.
|
256
|
+
// Otherwise it can be a static string.
|
257
|
+
var currentVersion = (typeof $.pjax.defaults.version === 'function') ?
|
258
|
+
$.pjax.defaults.version() :
|
259
|
+
$.pjax.defaults.version
|
260
|
+
|
261
|
+
var latestVersion = xhr.getResponseHeader('X-PJAX-Version')
|
262
|
+
|
263
|
+
var container = extractContainer(data, xhr, options)
|
264
|
+
|
265
|
+
var url = parseURL(container.url)
|
266
|
+
if (hash) {
|
267
|
+
url.hash = hash
|
268
|
+
container.url = url.href
|
269
|
+
}
|
270
|
+
|
271
|
+
// If there is a layout version mismatch, hard load the new url
|
272
|
+
if (currentVersion && latestVersion && currentVersion !== latestVersion) {
|
273
|
+
locationReplace(container.url)
|
274
|
+
return
|
275
|
+
}
|
276
|
+
|
277
|
+
// If the new response is missing a body, hard load the page
|
278
|
+
if (!container.contents) {
|
279
|
+
locationReplace(container.url)
|
280
|
+
return
|
281
|
+
}
|
282
|
+
|
283
|
+
pjax.state = {
|
284
|
+
id: options.id || uniqueId(),
|
285
|
+
url: container.url,
|
286
|
+
title: container.title,
|
287
|
+
container: options.container,
|
288
|
+
fragment: options.fragment,
|
289
|
+
timeout: options.timeout
|
290
|
+
}
|
291
|
+
|
292
|
+
if (options.push || options.replace) {
|
293
|
+
window.history.replaceState(pjax.state, container.title, container.url)
|
294
|
+
}
|
295
|
+
|
296
|
+
// Only blur the focus if the focused element is within the container.
|
297
|
+
var blurFocus = $.contains(options.container, document.activeElement)
|
298
|
+
|
299
|
+
// Clear out any focused controls before inserting new page contents.
|
300
|
+
if (blurFocus) {
|
301
|
+
try {
|
302
|
+
document.activeElement.blur()
|
303
|
+
} catch (e) { }
|
304
|
+
}
|
305
|
+
|
306
|
+
if (container.title) document.title = container.title
|
307
|
+
|
308
|
+
fire('pjax:beforeReplace', [container.contents, options], {
|
309
|
+
state: pjax.state,
|
310
|
+
previousState: previousState
|
311
|
+
})
|
312
|
+
context.html(container.contents)
|
313
|
+
|
314
|
+
// FF bug: Won't autofocus fields that are inserted via JS.
|
315
|
+
// This behavior is incorrect. So if theres no current focus, autofocus
|
316
|
+
// the last field.
|
317
|
+
//
|
318
|
+
// http://www.w3.org/html/wg/drafts/html/master/forms.html
|
319
|
+
var autofocusEl = context.find('input[autofocus], textarea[autofocus]').last()[0]
|
320
|
+
if (autofocusEl && document.activeElement !== autofocusEl) {
|
321
|
+
autofocusEl.focus()
|
322
|
+
}
|
323
|
+
|
324
|
+
executeScriptTags(container.scripts)
|
325
|
+
|
326
|
+
var scrollTo = options.scrollTo
|
327
|
+
|
328
|
+
// Ensure browser scrolls to the element referenced by the URL anchor
|
329
|
+
if (hash) {
|
330
|
+
var name = decodeURIComponent(hash.slice(1))
|
331
|
+
var target = document.getElementById(name) || document.getElementsByName(name)[0]
|
332
|
+
if (target) scrollTo = $(target).offset().top
|
333
|
+
}
|
334
|
+
|
335
|
+
if (typeof scrollTo == 'number') $(window).scrollTop(scrollTo)
|
336
|
+
|
337
|
+
fire('pjax:success', [data, status, xhr, options])
|
338
|
+
}
|
339
|
+
|
340
|
+
|
341
|
+
// Initialize pjax.state for the initial page load. Assume we're
|
342
|
+
// using the container and options of the link we're loading for the
|
343
|
+
// back button to the initial page. This ensures good back button
|
344
|
+
// behavior.
|
345
|
+
if (!pjax.state) {
|
346
|
+
pjax.state = {
|
347
|
+
id: uniqueId(),
|
348
|
+
url: window.location.href,
|
349
|
+
title: document.title,
|
350
|
+
container: options.container,
|
351
|
+
fragment: options.fragment,
|
352
|
+
timeout: options.timeout
|
353
|
+
}
|
354
|
+
window.history.replaceState(pjax.state, document.title)
|
355
|
+
}
|
356
|
+
|
357
|
+
// Cancel the current request if we're already pjaxing
|
358
|
+
abortXHR(pjax.xhr)
|
359
|
+
|
360
|
+
pjax.options = options
|
361
|
+
var xhr = pjax.xhr = $.ajax(options)
|
362
|
+
|
363
|
+
if (xhr.readyState > 0) {
|
364
|
+
if (options.push && !options.replace) {
|
365
|
+
// Cache current container element before replacing it
|
366
|
+
cachePush(pjax.state.id, [options.container, cloneContents(context)])
|
367
|
+
|
368
|
+
window.history.pushState(null, "", options.requestUrl)
|
369
|
+
}
|
370
|
+
|
371
|
+
fire('pjax:start', [xhr, options])
|
372
|
+
fire('pjax:send', [xhr, options])
|
373
|
+
}
|
374
|
+
|
375
|
+
return pjax.xhr
|
376
|
+
}
|
377
|
+
|
378
|
+
// Public: Reload current page with pjax.
|
379
|
+
//
|
380
|
+
// Returns whatever $.pjax returns.
|
381
|
+
function pjaxReload(container, options) {
|
382
|
+
var defaults = {
|
383
|
+
url: window.location.href,
|
384
|
+
push: false,
|
385
|
+
replace: true,
|
386
|
+
scrollTo: false
|
387
|
+
}
|
388
|
+
|
389
|
+
return pjax($.extend(defaults, optionsFor(container, options)))
|
390
|
+
}
|
391
|
+
|
392
|
+
// Internal: Hard replace current state with url.
|
393
|
+
//
|
394
|
+
// Work for around WebKit
|
395
|
+
// https://bugs.webkit.org/show_bug.cgi?id=93506
|
396
|
+
//
|
397
|
+
// Returns nothing.
|
398
|
+
function locationReplace(url) {
|
399
|
+
window.history.replaceState(null, "", pjax.state.url)
|
400
|
+
window.location.replace(url)
|
401
|
+
}
|
402
|
+
|
403
|
+
|
404
|
+
var initialPop = true
|
405
|
+
var initialURL = window.location.href
|
406
|
+
var initialState = window.history.state
|
407
|
+
|
408
|
+
// Initialize $.pjax.state if possible
|
409
|
+
// Happens when reloading a page and coming forward from a different
|
410
|
+
// session history.
|
411
|
+
if (initialState && initialState.container) {
|
412
|
+
pjax.state = initialState
|
413
|
+
}
|
414
|
+
|
415
|
+
// Non-webkit browsers don't fire an initial popstate event
|
416
|
+
if ('state' in window.history) {
|
417
|
+
initialPop = false
|
418
|
+
}
|
419
|
+
|
420
|
+
// popstate handler takes care of the back and forward buttons
|
421
|
+
//
|
422
|
+
// You probably shouldn't use pjax on pages with other pushState
|
423
|
+
// stuff yet.
|
424
|
+
function onPjaxPopstate(event) {
|
425
|
+
|
426
|
+
// Hitting back or forward should override any pending PJAX request.
|
427
|
+
if (!initialPop) {
|
428
|
+
abortXHR(pjax.xhr)
|
429
|
+
}
|
430
|
+
|
431
|
+
var previousState = pjax.state
|
432
|
+
var state = event.state
|
433
|
+
var direction
|
434
|
+
|
435
|
+
if (state && state.container) {
|
436
|
+
// When coming forward from a separate history session, will get an
|
437
|
+
// initial pop with a state we are already at. Skip reloading the current
|
438
|
+
// page.
|
439
|
+
if (initialPop && initialURL == state.url) return
|
440
|
+
|
441
|
+
if (previousState) {
|
442
|
+
// If popping back to the same state, just skip.
|
443
|
+
// Could be clicking back from hashchange rather than a pushState.
|
444
|
+
if (previousState.id === state.id) return
|
445
|
+
|
446
|
+
// Since state IDs always increase, we can deduce the navigation direction
|
447
|
+
direction = previousState.id < state.id ? 'forward' : 'back'
|
448
|
+
}
|
449
|
+
|
450
|
+
var cache = cacheMapping[state.id] || []
|
451
|
+
var containerSelector = cache[0] || state.container
|
452
|
+
var container = $(containerSelector), contents = cache[1]
|
453
|
+
|
454
|
+
if (container.length) {
|
455
|
+
if (previousState) {
|
456
|
+
// Cache current container before replacement and inform the
|
457
|
+
// cache which direction the history shifted.
|
458
|
+
cachePop(direction, previousState.id, [containerSelector, cloneContents(container)])
|
459
|
+
}
|
460
|
+
|
461
|
+
var popstateEvent = $.Event('pjax:popstate', {
|
462
|
+
state: state,
|
463
|
+
direction: direction
|
464
|
+
})
|
465
|
+
container.trigger(popstateEvent)
|
466
|
+
|
467
|
+
var options = {
|
468
|
+
id: state.id,
|
469
|
+
url: state.url,
|
470
|
+
container: containerSelector,
|
471
|
+
push: false,
|
472
|
+
fragment: state.fragment,
|
473
|
+
timeout: state.timeout,
|
474
|
+
scrollTo: false
|
475
|
+
}
|
476
|
+
|
477
|
+
if (contents) {
|
478
|
+
container.trigger('pjax:start', [null, options])
|
479
|
+
|
480
|
+
pjax.state = state
|
481
|
+
if (state.title) document.title = state.title
|
482
|
+
var beforeReplaceEvent = $.Event('pjax:beforeReplace', {
|
483
|
+
state: state,
|
484
|
+
previousState: previousState
|
485
|
+
})
|
486
|
+
container.trigger(beforeReplaceEvent, [contents, options])
|
487
|
+
container.html(contents)
|
488
|
+
|
489
|
+
container.trigger('pjax:end', [null, options])
|
490
|
+
} else {
|
491
|
+
pjax(options)
|
492
|
+
}
|
493
|
+
|
494
|
+
// Force reflow/relayout before the browser tries to restore the
|
495
|
+
// scroll position.
|
496
|
+
container[0].offsetHeight
|
497
|
+
} else {
|
498
|
+
locationReplace(location.href)
|
499
|
+
}
|
500
|
+
}
|
501
|
+
initialPop = false
|
502
|
+
}
|
503
|
+
|
504
|
+
// Fallback version of main pjax function for browsers that don't
|
505
|
+
// support pushState.
|
506
|
+
//
|
507
|
+
// Returns nothing since it retriggers a hard form submission.
|
508
|
+
function fallbackPjax(options) {
|
509
|
+
var url = $.isFunction(options.url) ? options.url() : options.url,
|
510
|
+
method = options.type ? options.type.toUpperCase() : 'GET'
|
511
|
+
|
512
|
+
var form = $('<form>', {
|
513
|
+
method: method === 'GET' ? 'GET' : 'POST',
|
514
|
+
action: url,
|
515
|
+
style: 'display:none'
|
516
|
+
})
|
517
|
+
|
518
|
+
if (method !== 'GET' && method !== 'POST') {
|
519
|
+
form.append($('<input>', {
|
520
|
+
type: 'hidden',
|
521
|
+
name: '_method',
|
522
|
+
value: method.toLowerCase()
|
523
|
+
}))
|
524
|
+
}
|
525
|
+
|
526
|
+
var data = options.data
|
527
|
+
if (typeof data === 'string') {
|
528
|
+
$.each(data.split('&'), function(index, value) {
|
529
|
+
var pair = value.split('=')
|
530
|
+
form.append($('<input>', {type: 'hidden', name: pair[0], value: pair[1]}))
|
531
|
+
})
|
532
|
+
} else if ($.isArray(data)) {
|
533
|
+
$.each(data, function(index, value) {
|
534
|
+
form.append($('<input>', {type: 'hidden', name: value.name, value: value.value}))
|
535
|
+
})
|
536
|
+
} else if (typeof data === 'object') {
|
537
|
+
var key
|
538
|
+
for (key in data)
|
539
|
+
form.append($('<input>', {type: 'hidden', name: key, value: data[key]}))
|
540
|
+
}
|
541
|
+
|
542
|
+
$(document.body).append(form)
|
543
|
+
form.submit()
|
544
|
+
}
|
545
|
+
|
546
|
+
// Internal: Abort an XmlHttpRequest if it hasn't been completed,
|
547
|
+
// also removing its event handlers.
|
548
|
+
function abortXHR(xhr) {
|
549
|
+
if ( xhr && xhr.readyState < 4) {
|
550
|
+
xhr.onreadystatechange = $.noop
|
551
|
+
xhr.abort()
|
552
|
+
}
|
553
|
+
}
|
554
|
+
|
555
|
+
// Internal: Generate unique id for state object.
|
556
|
+
//
|
557
|
+
// Use a timestamp instead of a counter since ids should still be
|
558
|
+
// unique across page loads.
|
559
|
+
//
|
560
|
+
// Returns Number.
|
561
|
+
function uniqueId() {
|
562
|
+
return (new Date).getTime()
|
563
|
+
}
|
564
|
+
|
565
|
+
function cloneContents(container) {
|
566
|
+
var cloned = container.clone()
|
567
|
+
// Unmark script tags as already being eval'd so they can get executed again
|
568
|
+
// when restored from cache. HAXX: Uses jQuery internal method.
|
569
|
+
cloned.find('script').each(function(){
|
570
|
+
if (!this.src) jQuery._data(this, 'globalEval', false)
|
571
|
+
})
|
572
|
+
return cloned.contents()
|
573
|
+
}
|
574
|
+
|
575
|
+
// Internal: Strip internal query params from parsed URL.
|
576
|
+
//
|
577
|
+
// Returns sanitized url.href String.
|
578
|
+
function stripInternalParams(url) {
|
579
|
+
url.search = url.search.replace(/([?&])(_pjax|_)=[^&]*/g, '')
|
580
|
+
return url.href.replace(/\?($|#)/, '$1')
|
581
|
+
}
|
582
|
+
|
583
|
+
// Internal: Parse URL components and returns a Locationish object.
|
584
|
+
//
|
585
|
+
// url - String URL
|
586
|
+
//
|
587
|
+
// Returns HTMLAnchorElement that acts like Location.
|
588
|
+
function parseURL(url) {
|
589
|
+
var a = document.createElement('a')
|
590
|
+
a.href = url
|
591
|
+
return a
|
592
|
+
}
|
593
|
+
|
594
|
+
// Internal: Return the `href` component of given URL object with the hash
|
595
|
+
// portion removed.
|
596
|
+
//
|
597
|
+
// location - Location or HTMLAnchorElement
|
598
|
+
//
|
599
|
+
// Returns String
|
600
|
+
function stripHash(location) {
|
601
|
+
return location.href.replace(/#.*/, '')
|
602
|
+
}
|
603
|
+
|
604
|
+
// Internal: Build options Object for arguments.
|
605
|
+
//
|
606
|
+
// For convenience the first parameter can be either the container or
|
607
|
+
// the options object.
|
608
|
+
//
|
609
|
+
// Examples
|
610
|
+
//
|
611
|
+
// optionsFor('#container')
|
612
|
+
// // => {container: '#container'}
|
613
|
+
//
|
614
|
+
// optionsFor('#container', {push: true})
|
615
|
+
// // => {container: '#container', push: true}
|
616
|
+
//
|
617
|
+
// optionsFor({container: '#container', push: true})
|
618
|
+
// // => {container: '#container', push: true}
|
619
|
+
//
|
620
|
+
// Returns options Object.
|
621
|
+
function optionsFor(container, options) {
|
622
|
+
if (container && options) {
|
623
|
+
options = $.extend({}, options)
|
624
|
+
options.container = container
|
625
|
+
return options
|
626
|
+
} else if ($.isPlainObject(container)) {
|
627
|
+
return container
|
628
|
+
} else {
|
629
|
+
return {container: container}
|
630
|
+
}
|
631
|
+
}
|
632
|
+
|
633
|
+
// Internal: Filter and find all elements matching the selector.
|
634
|
+
//
|
635
|
+
// Where $.fn.find only matches descendants, findAll will test all the
|
636
|
+
// top level elements in the jQuery object as well.
|
637
|
+
//
|
638
|
+
// elems - jQuery object of Elements
|
639
|
+
// selector - String selector to match
|
640
|
+
//
|
641
|
+
// Returns a jQuery object.
|
642
|
+
function findAll(elems, selector) {
|
643
|
+
return elems.filter(selector).add(elems.find(selector))
|
644
|
+
}
|
645
|
+
|
646
|
+
function parseHTML(html) {
|
647
|
+
return $.parseHTML(html, document, true)
|
648
|
+
}
|
649
|
+
|
650
|
+
// Internal: Extracts container and metadata from response.
|
651
|
+
//
|
652
|
+
// 1. Extracts X-PJAX-URL header if set
|
653
|
+
// 2. Extracts inline <title> tags
|
654
|
+
// 3. Builds response Element and extracts fragment if set
|
655
|
+
//
|
656
|
+
// data - String response data
|
657
|
+
// xhr - XHR response
|
658
|
+
// options - pjax options Object
|
659
|
+
//
|
660
|
+
// Returns an Object with url, title, and contents keys.
|
661
|
+
function extractContainer(data, xhr, options) {
|
662
|
+
var obj = {}, fullDocument = /<html/i.test(data)
|
663
|
+
|
664
|
+
// Prefer X-PJAX-URL header if it was set, otherwise fallback to
|
665
|
+
// using the original requested url.
|
666
|
+
var serverUrl = xhr.getResponseHeader('X-PJAX-URL')
|
667
|
+
obj.url = serverUrl ? stripInternalParams(parseURL(serverUrl)) : options.requestUrl
|
668
|
+
|
669
|
+
// Attempt to parse response html into elements
|
670
|
+
if (fullDocument) {
|
671
|
+
var $head = $(parseHTML(data.match(/<head[^>]*>([\s\S.]*)<\/head>/i)[0]))
|
672
|
+
var $body = $(parseHTML(data.match(/<body[^>]*>([\s\S.]*)<\/body>/i)[0]))
|
673
|
+
} else {
|
674
|
+
var $head = $body = $(parseHTML(data))
|
675
|
+
}
|
676
|
+
|
677
|
+
// If response data is empty, return fast
|
678
|
+
if ($body.length === 0)
|
679
|
+
return obj
|
680
|
+
|
681
|
+
// If there's a <title> tag in the header, use it as
|
682
|
+
// the page's title.
|
683
|
+
obj.title = findAll($head, 'title').last().text()
|
684
|
+
|
685
|
+
if (options.fragment) {
|
686
|
+
// If they specified a fragment, look for it in the response
|
687
|
+
// and pull it out.
|
688
|
+
if (options.fragment === 'body') {
|
689
|
+
var $fragment = $body
|
690
|
+
} else {
|
691
|
+
var $fragment = findAll($body, options.fragment).first()
|
692
|
+
}
|
693
|
+
|
694
|
+
if ($fragment.length) {
|
695
|
+
obj.contents = options.fragment === 'body' ? $fragment : $fragment.contents()
|
696
|
+
|
697
|
+
// If there's no title, look for data-title and title attributes
|
698
|
+
// on the fragment
|
699
|
+
if (!obj.title)
|
700
|
+
obj.title = $fragment.attr('title') || $fragment.data('title')
|
701
|
+
}
|
702
|
+
|
703
|
+
} else if (!fullDocument) {
|
704
|
+
obj.contents = $body
|
705
|
+
}
|
706
|
+
|
707
|
+
// Clean up any <title> tags
|
708
|
+
if (obj.contents) {
|
709
|
+
// Remove any parent title elements
|
710
|
+
obj.contents = obj.contents.not(function() { return $(this).is('title') })
|
711
|
+
|
712
|
+
// Then scrub any titles from their descendants
|
713
|
+
obj.contents.find('title').remove()
|
714
|
+
|
715
|
+
// Gather all script[src] elements
|
716
|
+
obj.scripts = findAll(obj.contents, 'script[src]').remove()
|
717
|
+
obj.contents = obj.contents.not(obj.scripts)
|
718
|
+
}
|
719
|
+
|
720
|
+
// Trim any whitespace off the title
|
721
|
+
if (obj.title) obj.title = $.trim(obj.title)
|
722
|
+
|
723
|
+
return obj
|
724
|
+
}
|
725
|
+
|
726
|
+
// Load an execute scripts using standard script request.
|
727
|
+
//
|
728
|
+
// Avoids jQuery's traditional $.getScript which does a XHR request and
|
729
|
+
// globalEval.
|
730
|
+
//
|
731
|
+
// scripts - jQuery object of script Elements
|
732
|
+
//
|
733
|
+
// Returns nothing.
|
734
|
+
function executeScriptTags(scripts) {
|
735
|
+
if (!scripts) return
|
736
|
+
|
737
|
+
var existingScripts = $('script[src]')
|
738
|
+
|
739
|
+
scripts.each(function() {
|
740
|
+
var src = this.src
|
741
|
+
var matchedScripts = existingScripts.filter(function() {
|
742
|
+
return this.src === src
|
743
|
+
})
|
744
|
+
if (matchedScripts.length) return
|
745
|
+
|
746
|
+
var script = document.createElement('script')
|
747
|
+
var type = $(this).attr('type')
|
748
|
+
if (type) script.type = type
|
749
|
+
script.src = $(this).attr('src')
|
750
|
+
document.head.appendChild(script)
|
751
|
+
})
|
752
|
+
}
|
753
|
+
|
754
|
+
// Internal: History DOM caching class.
|
755
|
+
var cacheMapping = {}
|
756
|
+
var cacheForwardStack = []
|
757
|
+
var cacheBackStack = []
|
758
|
+
|
759
|
+
// Push previous state id and container contents into the history
|
760
|
+
// cache. Should be called in conjunction with `pushState` to save the
|
761
|
+
// previous container contents.
|
762
|
+
//
|
763
|
+
// id - State ID Number
|
764
|
+
// value - DOM Element to cache
|
765
|
+
//
|
766
|
+
// Returns nothing.
|
767
|
+
function cachePush(id, value) {
|
768
|
+
cacheMapping[id] = value
|
769
|
+
cacheBackStack.push(id)
|
770
|
+
|
771
|
+
// Remove all entries in forward history stack after pushing a new page.
|
772
|
+
trimCacheStack(cacheForwardStack, 0)
|
773
|
+
|
774
|
+
// Trim back history stack to max cache length.
|
775
|
+
trimCacheStack(cacheBackStack, pjax.defaults.maxCacheLength)
|
776
|
+
}
|
777
|
+
|
778
|
+
// Shifts cache from directional history cache. Should be
|
779
|
+
// called on `popstate` with the previous state id and container
|
780
|
+
// contents.
|
781
|
+
//
|
782
|
+
// direction - "forward" or "back" String
|
783
|
+
// id - State ID Number
|
784
|
+
// value - DOM Element to cache
|
785
|
+
//
|
786
|
+
// Returns nothing.
|
787
|
+
function cachePop(direction, id, value) {
|
788
|
+
var pushStack, popStack
|
789
|
+
cacheMapping[id] = value
|
790
|
+
|
791
|
+
if (direction === 'forward') {
|
792
|
+
pushStack = cacheBackStack
|
793
|
+
popStack = cacheForwardStack
|
794
|
+
} else {
|
795
|
+
pushStack = cacheForwardStack
|
796
|
+
popStack = cacheBackStack
|
797
|
+
}
|
798
|
+
|
799
|
+
pushStack.push(id)
|
800
|
+
if (id = popStack.pop())
|
801
|
+
delete cacheMapping[id]
|
802
|
+
|
803
|
+
// Trim whichever stack we just pushed to to max cache length.
|
804
|
+
trimCacheStack(pushStack, pjax.defaults.maxCacheLength)
|
805
|
+
}
|
806
|
+
|
807
|
+
// Trim a cache stack (either cacheBackStack or cacheForwardStack) to be no
|
808
|
+
// longer than the specified length, deleting cached DOM elements as necessary.
|
809
|
+
//
|
810
|
+
// stack - Array of state IDs
|
811
|
+
// length - Maximum length to trim to
|
812
|
+
//
|
813
|
+
// Returns nothing.
|
814
|
+
function trimCacheStack(stack, length) {
|
815
|
+
while (stack.length > length)
|
816
|
+
delete cacheMapping[stack.shift()]
|
817
|
+
}
|
818
|
+
|
819
|
+
// Public: Find version identifier for the initial page load.
|
820
|
+
//
|
821
|
+
// Returns String version or undefined.
|
822
|
+
function findVersion() {
|
823
|
+
return $('meta').filter(function() {
|
824
|
+
var name = $(this).attr('http-equiv')
|
825
|
+
return name && name.toUpperCase() === 'X-PJAX-VERSION'
|
826
|
+
}).attr('content')
|
827
|
+
}
|
828
|
+
|
829
|
+
// Install pjax functions on $.pjax to enable pushState behavior.
|
830
|
+
//
|
831
|
+
// Does nothing if already enabled.
|
832
|
+
//
|
833
|
+
// Examples
|
834
|
+
//
|
835
|
+
// $.pjax.enable()
|
836
|
+
//
|
837
|
+
// Returns nothing.
|
838
|
+
function enable() {
|
839
|
+
$.fn.pjax = fnPjax
|
840
|
+
$.pjax = pjax
|
841
|
+
$.pjax.enable = $.noop
|
842
|
+
$.pjax.disable = disable
|
843
|
+
$.pjax.click = handleClick
|
844
|
+
$.pjax.submit = handleSubmit
|
845
|
+
$.pjax.reload = pjaxReload
|
846
|
+
$.pjax.defaults = {
|
847
|
+
timeout: 650,
|
848
|
+
push: true,
|
849
|
+
replace: false,
|
850
|
+
type: 'GET',
|
851
|
+
dataType: 'html',
|
852
|
+
scrollTo: 0,
|
853
|
+
maxCacheLength: 20,
|
854
|
+
version: findVersion
|
855
|
+
}
|
856
|
+
$(window).on('popstate.pjax', onPjaxPopstate)
|
857
|
+
}
|
858
|
+
|
859
|
+
// Disable pushState behavior.
|
860
|
+
//
|
861
|
+
// This is the case when a browser doesn't support pushState. It is
|
862
|
+
// sometimes useful to disable pushState for debugging on a modern
|
863
|
+
// browser.
|
864
|
+
//
|
865
|
+
// Examples
|
866
|
+
//
|
867
|
+
// $.pjax.disable()
|
868
|
+
//
|
869
|
+
// Returns nothing.
|
870
|
+
function disable() {
|
871
|
+
$.fn.pjax = function() { return this }
|
872
|
+
$.pjax = fallbackPjax
|
873
|
+
$.pjax.enable = enable
|
874
|
+
$.pjax.disable = $.noop
|
875
|
+
$.pjax.click = $.noop
|
876
|
+
$.pjax.submit = $.noop
|
877
|
+
$.pjax.reload = function() { window.location.reload() }
|
878
|
+
|
879
|
+
$(window).off('popstate.pjax', onPjaxPopstate)
|
880
|
+
}
|
881
|
+
|
882
|
+
|
883
|
+
// Add the state property to jQuery's event object so we can use it in
|
884
|
+
// $(window).bind('popstate')
|
885
|
+
if ($.event.props && $.inArray('state', $.event.props) < 0) {
|
886
|
+
$.event.props.push('state')
|
887
|
+
} else if (!('state' in $.Event.prototype)) {
|
888
|
+
$.event.addProp('state')
|
889
|
+
}
|
890
|
+
|
891
|
+
// Is pjax supported by this browser?
|
892
|
+
$.support.pjax =
|
893
|
+
window.history && window.history.pushState && window.history.replaceState &&
|
894
|
+
// pushState isn't reliable on iOS until 5.
|
895
|
+
!navigator.userAgent.match(/((iPod|iPhone|iPad).+\bOS\s+[1-4]\D|WebApps\/.+CFNetwork)/)
|
896
|
+
|
897
|
+
$.support.pjax ? enable() : disable()
|
898
|
+
|
899
|
+
})(jQuery)
|