vapid 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.gitmodules +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +133 -0
- data/.travis.yml +5 -0
- data/Gemfile +10 -0
- data/README.md +37 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/vapid +7 -0
- data/lib/vapid.rb +24 -0
- data/lib/vapid/assets/javascripts/vapid/admin.coffee +2 -0
- data/lib/vapid/assets/stylesheets/vapid/admin.scss +72 -0
- data/lib/vapid/builder.rb +70 -0
- data/lib/vapid/cli.rb +96 -0
- data/lib/vapid/controllers/admin_controller.rb +282 -0
- data/lib/vapid/controllers/project_controller.rb +41 -0
- data/lib/vapid/db/migrate/20170202182310_create_groups.rb +12 -0
- data/lib/vapid/db/migrate/20170202183017_create_records.rb +11 -0
- data/lib/vapid/db/migrate/20170202185150_create_users.rb +11 -0
- data/lib/vapid/directive.rb +168 -0
- data/lib/vapid/directives.rb +30 -0
- data/lib/vapid/directives/audio.rb +27 -0
- data/lib/vapid/directives/group.rb +71 -0
- data/lib/vapid/directives/hide.rb +11 -0
- data/lib/vapid/directives/href.rb +11 -0
- data/lib/vapid/directives/image.rb +14 -0
- data/lib/vapid/directives/richtext.rb +15 -0
- data/lib/vapid/directives/show.rb +11 -0
- data/lib/vapid/directives/text.rb +24 -0
- data/lib/vapid/directives/video.rb +28 -0
- data/lib/vapid/generator_template/.gitignore +21 -0
- data/lib/vapid/generator_template/Gemfile.tt +13 -0
- data/lib/vapid/generator_template/README.md +0 -0
- data/lib/vapid/generator_template/assets/favicon.ico +0 -0
- data/lib/vapid/generator_template/assets/images/.keep +0 -0
- data/lib/vapid/generator_template/assets/javascripts/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/.keep +0 -0
- data/lib/vapid/generator_template/assets/stylesheets/application.css +120 -0
- data/lib/vapid/generator_template/config.ru +3 -0
- data/lib/vapid/generator_template/config/database.yml +12 -0
- data/lib/vapid/generator_template/config/settings.yml.tt +11 -0
- data/lib/vapid/generator_template/templates/index.html.erb +25 -0
- data/lib/vapid/generator_template/templates/layouts/default.html.erb +22 -0
- data/lib/vapid/models.rb +18 -0
- data/lib/vapid/models/group.rb +36 -0
- data/lib/vapid/models/record.rb +30 -0
- data/lib/vapid/models/user.rb +16 -0
- data/lib/vapid/server.rb +93 -0
- data/lib/vapid/settings.rb +13 -0
- data/lib/vapid/template.rb +79 -0
- data/lib/vapid/template/node.rb +91 -0
- data/lib/vapid/template/parser.rb +50 -0
- data/lib/vapid/vendor/semantic-ui/.versions +4 -0
- data/lib/vapid/vendor/semantic-ui/LICENSE +22 -0
- data/lib/vapid/vendor/semantic-ui/README.md +7 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.css +252 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.js +610 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/accordion.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.css +275 -0
- data/lib/vapid/vendor/semantic-ui/components/ad.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/api.js +1167 -0
- data/lib/vapid/vendor/semantic-ui/components/api.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.css +124 -0
- data/lib/vapid/vendor/semantic-ui/components/breadcrumb.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/button.css +3450 -0
- data/lib/vapid/vendor/semantic-ui/components/button.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/card.css +964 -0
- data/lib/vapid/vendor/semantic-ui/components/card.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.css +625 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.js +831 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/checkbox.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.js +274 -0
- data/lib/vapid/vendor/semantic-ui/components/colorize.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.css +270 -0
- data/lib/vapid/vendor/semantic-ui/components/comment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/container.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/container.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.css +200 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dimmer.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.css +260 -0
- data/lib/vapid/vendor/semantic-ui/components/divider.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.css +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.js +3767 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/dropdown.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.css +166 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.js +696 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/embed.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.css +296 -0
- data/lib/vapid/vendor/semantic-ui/components/feed.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.css +1031 -0
- data/lib/vapid/vendor/semantic-ui/components/flag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.css +1067 -0
- data/lib/vapid/vendor/semantic-ui/components/form.js +1603 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/form.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/grid.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/header.css +721 -0
- data/lib/vapid/vendor/semantic-ui/components/header.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.css +3292 -0
- data/lib/vapid/vendor/semantic-ui/components/icon.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/image.css +306 -0
- data/lib/vapid/vendor/semantic-ui/components/image.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/input.css +510 -0
- data/lib/vapid/vendor/semantic-ui/components/input.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/item.css +486 -0
- data/lib/vapid/vendor/semantic-ui/components/item.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/label.css +1307 -0
- data/lib/vapid/vendor/semantic-ui/components/label.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/list.css +951 -0
- data/lib/vapid/vendor/semantic-ui/components/list.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.css +347 -0
- data/lib/vapid/vendor/semantic-ui/components/loader.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.css +2002 -0
- data/lib/vapid/vendor/semantic-ui/components/menu.min.css +1 -0
- data/lib/vapid/vendor/semantic-ui/components/message.css +477 -0
- data/lib/vapid/vendor/semantic-ui/components/message.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.css +502 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.js +913 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/modal.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.css +147 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.js +507 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/nag.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.css +733 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.js +1475 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/popup.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.css +516 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.js +931 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/progress.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.css +152 -0
- data/lib/vapid/vendor/semantic-ui/components/rail.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.css +263 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.js +508 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/rating.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.css +424 -0
- data/lib/vapid/vendor/semantic-ui/components/reset.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.css +284 -0
- data/lib/vapid/vendor/semantic-ui/components/reveal.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.css +408 -0
- data/lib/vapid/vendor/semantic-ui/components/search.js +1442 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/search.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.css +798 -0
- data/lib/vapid/vendor/semantic-ui/components/segment.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.css +157 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.js +921 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/shape.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.css +634 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.js +1036 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sidebar.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/site.css +160 -0
- data/lib/vapid/vendor/semantic-ui/components/site.js +487 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/site.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/state.js +708 -0
- data/lib/vapid/vendor/semantic-ui/components/state.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.css +569 -0
- data/lib/vapid/vendor/semantic-ui/components/statistic.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/step.css +623 -0
- data/lib/vapid/vendor/semantic-ui/components/step.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.css +78 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.js +942 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/sticky.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.css +91 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.js +952 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/tab.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/table.css +1108 -0
- data/lib/vapid/vendor/semantic-ui/components/table.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.css +1964 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.js +1095 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.css +9 -0
- data/lib/vapid/vendor/semantic-ui/components/transition.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.css +125 -0
- data/lib/vapid/vendor/semantic-ui/components/video.js +532 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.css +10 -0
- data/lib/vapid/vendor/semantic-ui/components/video.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.js +1288 -0
- data/lib/vapid/vendor/semantic-ui/components/visibility.min.js +10 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.js +517 -0
- data/lib/vapid/vendor/semantic-ui/components/visit.min.js +11 -0
- data/lib/vapid/vendor/semantic-ui/package.js +34 -0
- data/lib/vapid/vendor/semantic-ui/package.json +20 -0
- data/lib/vapid/vendor/semantic-ui/semantic.css +36844 -0
- data/lib/vapid/vendor/semantic-ui/semantic.js +22617 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.css +364 -0
- data/lib/vapid/vendor/semantic-ui/semantic.min.js +19 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.eot +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.otf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.svg +2671 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.ttf +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/fonts/icons.woff2 +0 -0
- data/lib/vapid/vendor/semantic-ui/themes/default/assets/images/flags.png +0 -0
- data/lib/vapid/vendor/trix/.blade.yml +45 -0
- data/lib/vapid/vendor/trix/.github/ISSUE_TEMPLATE.md +13 -0
- data/lib/vapid/vendor/trix/.gitignore +3 -0
- data/lib/vapid/vendor/trix/.ruby-version +1 -0
- data/lib/vapid/vendor/trix/.travis.yml +6 -0
- data/lib/vapid/vendor/trix/CONDUCT.md +79 -0
- data/lib/vapid/vendor/trix/Gemfile +17 -0
- data/lib/vapid/vendor/trix/Gemfile.lock +152 -0
- data/lib/vapid/vendor/trix/LICENSE +20 -0
- data/lib/vapid/vendor/trix/README.md +382 -0
- data/lib/vapid/vendor/trix/assets/index.html +55 -0
- data/lib/vapid/vendor/trix/assets/trix-core.coffee +2 -0
- data/lib/vapid/vendor/trix/assets/trix.coffee +3 -0
- data/lib/vapid/vendor/trix/assets/trix.scss +5 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.coffee.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.scss.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/banner/index.txt.erb +3 -0
- data/lib/vapid/vendor/trix/assets/trix/images/README.md +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/attach.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bold.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/bullets.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/code.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/heading_1.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/italic.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/link.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_decrease.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/nesting_level_increase.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/numbers.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/quote.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/redo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/remove.svg +4 -0
- data/lib/vapid/vendor/trix/assets/trix/images/strike.svg +6 -0
- data/lib/vapid/vendor/trix/assets/trix/images/trash.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/images/undo.svg +5 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/attachments.scss +112 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/content.scss +88 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/editor.scss +8 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/icons.scss +14 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/media-queries.scss +7 -0
- data/lib/vapid/vendor/trix/assets/trix/stylesheets/toolbar.scss +194 -0
- data/lib/vapid/vendor/trix/bin/blade +16 -0
- data/lib/vapid/vendor/trix/bin/ci +21 -0
- data/lib/vapid/vendor/trix/bin/rackup +16 -0
- data/lib/vapid/vendor/trix/bin/rake +16 -0
- data/lib/vapid/vendor/trix/bin/release +139 -0
- data/lib/vapid/vendor/trix/bin/setup +69 -0
- data/lib/vapid/vendor/trix/bin/update-status-image +100 -0
- data/lib/vapid/vendor/trix/bower.json +34 -0
- data/lib/vapid/vendor/trix/config.ru +32 -0
- data/lib/vapid/vendor/trix/dist/trix-core.js +11 -0
- data/lib/vapid/vendor/trix/dist/trix.css +286 -0
- data/lib/vapid/vendor/trix/dist/trix.js +20 -0
- data/lib/vapid/vendor/trix/package.json +29 -0
- data/lib/vapid/vendor/trix/polyfills/polyfills.coffee +3 -0
- data/lib/vapid/vendor/trix/polyfills/set.coffee +24 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/CustomElements.js +1029 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/README.md +2 -0
- data/lib/vapid/vendor/trix/polyfills/vendor/promise.js +228 -0
- data/lib/vapid/vendor/trix/src/trix/VERSION +1 -0
- data/lib/vapid/vendor/trix/src/trix/config/block_attributes.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/config/css.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/config/file_size_formatting.coffee +22 -0
- data/lib/vapid/vendor/trix/src/trix/config/index.coffee +9 -0
- data/lib/vapid/vendor/trix/src/trix/config/lang.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/selection_elements.coffee +26 -0
- data/lib/vapid/vendor/trix/src/trix/config/serialization.coffee +63 -0
- data/lib/vapid/vendor/trix/src/trix/config/text_attributes.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/config/toolbar.coffee +41 -0
- data/lib/vapid/vendor/trix/src/trix/config/undo_interval.coffee +7 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/attachment_editor_controller.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/composition_controller.coffee +117 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/controller.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/editor_controller.coffee +369 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input/composition_input.coffee +57 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/input_controller.coffee +473 -0
- data/lib/vapid/vendor/trix/src/trix/controllers/toolbar_controller.coffee +173 -0
- data/lib/vapid/vendor/trix/src/trix/core/basic_object.coffee +44 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/element_store.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/hash.coffee +98 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_group.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/collections/object_map.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/arrays.coffee +34 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/config.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/custom_elements.coffee +45 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/dom.coffee +185 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/extend.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/functions.coffee +3 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/global.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/index.coffee +10 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/objects.coffee +11 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/ranges.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/selection.coffee +25 -0
- data/lib/vapid/vendor/trix/src/trix/core/helpers/strings.coffee +46 -0
- data/lib/vapid/vendor/trix/src/trix/core/index.coffee +4 -0
- data/lib/vapid/vendor/trix/src/trix/core/object.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/index.coffee +2 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/operation.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/core/utilities/utf16_string.coffee +93 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_editor_element.coffee +166 -0
- data/lib/vapid/vendor/trix/src/trix/elements/trix_toolbar_element.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/index.coffee.erb +14 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/control_element.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/debugger.coffee +104 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/element.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/index.coffee +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/polyfills/vendor/details-element-polyfill.js +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/debug.jst.eco +17 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/document.jst.eco +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/performance.jst.eco +10 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/render.jst.eco +1 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/selection.jst.eco +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/templates/undo.jst.eco +13 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/view.coffee +58 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/debug_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/document_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/performance_view.coffee +51 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/render_view.coffee +21 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/selection_view.coffee +33 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/views/undo_view.coffee +12 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/deserializer.coffee +55 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/index.coffee +5 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player.coffee +60 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_controller.coffee +43 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_element.coffee +32 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/player_view.coffee +133 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recorder.coffee +82 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/recording.coffee +54 -0
- data/lib/vapid/vendor/trix/src/trix/inspector/watchdog/serializer.coffee +61 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment.coffee +157 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_manager.coffee +24 -0
- data/lib/vapid/vendor/trix/src/trix/models/attachment_piece.coffee +47 -0
- data/lib/vapid/vendor/trix/src/trix/models/block.coffee +230 -0
- data/lib/vapid/vendor/trix/src/trix/models/composition.coffee +521 -0
- data/lib/vapid/vendor/trix/src/trix/models/document.coffee +538 -0
- data/lib/vapid/vendor/trix/src/trix/models/editor.coffee +141 -0
- data/lib/vapid/vendor/trix/src/trix/models/html_parser.coffee +335 -0
- data/lib/vapid/vendor/trix/src/trix/models/line_break_insertion.coffee +31 -0
- data/lib/vapid/vendor/trix/src/trix/models/location_mapper.coffee +156 -0
- data/lib/vapid/vendor/trix/src/trix/models/managed_attachment.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/piece.coffee +95 -0
- data/lib/vapid/vendor/trix/src/trix/models/point_mapper.coffee +28 -0
- data/lib/vapid/vendor/trix/src/trix/models/selection_manager.coffee +129 -0
- data/lib/vapid/vendor/trix/src/trix/models/splittable_list.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/string_piece.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/models/text.coffee +168 -0
- data/lib/vapid/vendor/trix/src/trix/models/undo_manager.coffee +40 -0
- data/lib/vapid/vendor/trix/src/trix/observers/mutation_observer.coffee +131 -0
- data/lib/vapid/vendor/trix/src/trix/observers/selection_change_observer.coffee +56 -0
- data/lib/vapid/vendor/trix/src/trix/operations/file_verification_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/operations/image_preload_operation.coffee +15 -0
- data/lib/vapid/vendor/trix/src/trix/views/attachment_view.coffee +99 -0
- data/lib/vapid/vendor/trix/src/trix/views/block_view.coffee +37 -0
- data/lib/vapid/vendor/trix/src/trix/views/document_view.coffee +68 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_group_view.coffee +23 -0
- data/lib/vapid/vendor/trix/src/trix/views/object_view.coffee +86 -0
- data/lib/vapid/vendor/trix/src/trix/views/piece_view.coffee +97 -0
- data/lib/vapid/vendor/trix/src/trix/views/previewable_attachment_view.coffee +49 -0
- data/lib/vapid/vendor/trix/src/trix/views/text_view.coffee +30 -0
- data/lib/vapid/vendor/trix/test/.gitignore +1 -0
- data/lib/vapid/vendor/trix/test/src/system/attachment_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/basic_input_test.coffee +68 -0
- data/lib/vapid/vendor/trix/test/src/system/block_formatting_test.coffee +602 -0
- data/lib/vapid/vendor/trix/test/src/system/caching_test.coffee +21 -0
- data/lib/vapid/vendor/trix/test/src/system/composition_input_test.coffee +138 -0
- data/lib/vapid/vendor/trix/test/src/system/cursor_movement_test.coffee +54 -0
- data/lib/vapid/vendor/trix/test/src/system/custom_element_test.coffee +314 -0
- data/lib/vapid/vendor/trix/test/src/system/html_loading_test.coffee +62 -0
- data/lib/vapid/vendor/trix/test/src/system/html_replacement_test.coffee +101 -0
- data/lib/vapid/vendor/trix/test/src/system/installation_process_test.coffee +59 -0
- data/lib/vapid/vendor/trix/test/src/system/list_formatting_test.coffee +70 -0
- data/lib/vapid/vendor/trix/test/src/system/mutation_input_test.coffee +73 -0
- data/lib/vapid/vendor/trix/test/src/system/pasting_test.coffee +215 -0
- data/lib/vapid/vendor/trix/test/src/system/text_formatting_test.coffee +151 -0
- data/lib/vapid/vendor/trix/test/src/system/undo_test.coffee +48 -0
- data/lib/vapid/vendor/trix/test/src/test.coffee +16 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/assertions.coffee +38 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/editor_helpers.coffee +37 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_empty.jst.eco +1 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_html.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_in_table.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_block_styles.jst.eco +6 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_bold_styles.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_image.jst.eco +2 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_styled_content.jst.eco +7 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/editor_with_toolbar_and_input.jst.eco +5 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/fixtures.coffee +536 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/fixtures/logo.png +0 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/index.coffee +18 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/input_helpers.coffee +183 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/selection_helpers.coffee +91 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_helpers.coffee +72 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/test_stubs.coffee +31 -0
- data/lib/vapid/vendor/trix/test/src/test_helpers/toolbar_helpers.coffee +45 -0
- data/lib/vapid/vendor/trix/test/src/unit/attachment_test.coffee +23 -0
- data/lib/vapid/vendor/trix/test/src/unit/block_test.coffee +22 -0
- data/lib/vapid/vendor/trix/test/src/unit/composition_test.coffee +13 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_test.coffee +11 -0
- data/lib/vapid/vendor/trix/test/src/unit/document_view_test.coffee +6 -0
- data/lib/vapid/vendor/trix/test/src/unit/html_parser_test.coffee +162 -0
- data/lib/vapid/vendor/trix/test/src/unit/location_mapper_test.coffee +185 -0
- data/lib/vapid/vendor/trix/test/src/unit/mutation_observer_test.coffee +84 -0
- data/lib/vapid/vendor/trix/test/src/unit/serialization_test.coffee +7 -0
- data/lib/vapid/vendor/trix/test/src/unit/string_change_summary_test.coffee +57 -0
- data/lib/vapid/vendor/trix/test/src/unit/text_test.coffee +19 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-core.js +3845 -0
- data/lib/vapid/vendor/trix/test/vendor/rangy-textrange.js +1930 -0
- data/lib/vapid/version.rb +4 -0
- data/lib/vapid/views/admin/install.html.erb +19 -0
- data/lib/vapid/views/admin/login.html.erb +11 -0
- data/lib/vapid/views/admin/overview/index.html.erb +1 -0
- data/lib/vapid/views/admin/records/_form.erb +9 -0
- data/lib/vapid/views/admin/records/edit.html.erb +5 -0
- data/lib/vapid/views/admin/records/index.html.erb +38 -0
- data/lib/vapid/views/admin/records/new.html.erb +3 -0
- data/lib/vapid/views/errors/404.html.erb +1 -0
- data/lib/vapid/views/errors/500.html.erb +1 -0
- data/lib/vapid/views/layouts/admin.html.erb +41 -0
- data/lib/vapid/views/layouts/admin_form.html.erb +22 -0
- data/lib/vapid/views/layouts/error.html.erb +11 -0
- data/vapid.gemspec +48 -0
- metadata +811 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 2.2.9 - Accordion
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/.ui.accordion,.ui.accordion .accordion{max-width:100%}.ui.accordion .accordion{margin:1em 0 0;padding:0}.ui.accordion .accordion .title,.ui.accordion .title{cursor:pointer}.ui.accordion .title:not(.ui){padding:.5em 0;font-family:Lato,'Helvetica Neue',Arial,Helvetica,sans-serif;font-size:1em;color:rgba(0,0,0,.87)}.ui.accordion .accordion .title~.content,.ui.accordion .title~.content{display:none}.ui.accordion:not(.styled) .accordion .title~.content:not(.ui),.ui.accordion:not(.styled) .title~.content:not(.ui){margin:'';padding:.5em 0 1em}.ui.accordion:not(.styled) .title~.content:not(.ui):last-child{padding-bottom:0}.ui.accordion .accordion .title .dropdown.icon,.ui.accordion .title .dropdown.icon{display:inline-block;float:none;opacity:1;width:1.25em;height:1em;margin:0 .25rem 0 0;padding:0;font-size:1em;-webkit-transition:opacity .1s ease,-webkit-transform .1s ease;transition:opacity .1s ease,-webkit-transform .1s ease;transition:transform .1s ease,opacity .1s ease;transition:transform .1s ease,opacity .1s ease,-webkit-transform .1s ease;vertical-align:baseline;-webkit-transform:none;transform:none}.ui.accordion.menu .item .title{display:block;padding:0}.ui.accordion.menu .item .title>.dropdown.icon{float:right;margin:.21425em 0 0 1em;-webkit-transform:rotate(180deg);transform:rotate(180deg)}.ui.accordion .ui.header .dropdown.icon{font-size:1em;margin:0 .25rem 0 0}.ui.accordion .accordion .active.title .dropdown.icon,.ui.accordion .active.title .dropdown.icon{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ui.accordion.menu .item .active.title>.dropdown.icon{-webkit-transform:rotate(90deg);transform:rotate(90deg)}.ui.styled.accordion{width:600px}.ui.styled.accordion,.ui.styled.accordion .accordion{border-radius:.28571429rem;background:#fff;box-shadow:0 1px 2px 0 rgba(34,36,38,.15),0 0 0 1px rgba(34,36,38,.15)}.ui.styled.accordion .accordion .title,.ui.styled.accordion .title{margin:0;padding:.75em 1em;color:rgba(0,0,0,.4);font-weight:700;border-top:1px solid rgba(34,36,38,.15);-webkit-transition:background .1s ease,color .1s ease;transition:background .1s ease,color .1s ease}.ui.styled.accordion .accordion .title:first-child,.ui.styled.accordion>.title:first-child{border-top:none}.ui.styled.accordion .accordion .content,.ui.styled.accordion .content{margin:0;padding:.5em 1em 1.5em}.ui.styled.accordion .accordion .content{padding:0;padding:.5em 1em 1.5em}.ui.styled.accordion .accordion .active.title,.ui.styled.accordion .accordion .title:hover,.ui.styled.accordion .active.title,.ui.styled.accordion .title:hover{background:0 0;color:rgba(0,0,0,.87)}.ui.styled.accordion .accordion .active.title,.ui.styled.accordion .accordion .title:hover{background:0 0;color:rgba(0,0,0,.87)}.ui.styled.accordion .active.title{background:0 0;color:rgba(0,0,0,.95)}.ui.styled.accordion .accordion .active.title{background:0 0;color:rgba(0,0,0,.95)}.ui.accordion .accordion .active.content,.ui.accordion .active.content{display:block}.ui.fluid.accordion,.ui.fluid.accordion .accordion{width:100%}.ui.inverted.accordion .title:not(.ui){color:rgba(255,255,255,.9)}@font-face{font-family:Accordion;src:url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMggjB5AAAAC8AAAAYGNtYXAPfOIKAAABHAAAAExnYXNwAAAAEAAAAWgAAAAIZ2x5Zryj6HgAAAFwAAAAyGhlYWT/0IhHAAACOAAAADZoaGVhApkB5wAAAnAAAAAkaG10eAJuABIAAAKUAAAAGGxvY2EAjABWAAACrAAAAA5tYXhwAAgAFgAAArwAAAAgbmFtZfC1n04AAALcAAABPHBvc3QAAwAAAAAEGAAAACAAAwIAAZAABQAAAUwBZgAAAEcBTAFmAAAA9QAZAIQAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADw2gHg/+D/4AHgACAAAAABAAAAAAAAAAAAAAAgAAAAAAACAAAAAwAAABQAAwABAAAAFAAEADgAAAAKAAgAAgACAAEAIPDa//3//wAAAAAAIPDZ//3//wAB/+MPKwADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAEAAAAAAAAAAAACAAA3OQEAAAAAAQASAEkAtwFuABMAADc0PwE2FzYXFh0BFAcGJwYvASY1EgaABQgHBQYGBQcIBYAG2wcGfwcBAQcECf8IBAcBAQd/BgYAAAAAAQAAAEkApQFuABMAADcRNDc2MzIfARYVFA8BBiMiJyY1AAUGBwgFgAYGgAUIBwYFWwEACAUGBoAFCAcFgAYGBQcAAAABAAAAAQAAqWYls18PPPUACwIAAAAAAM/9o+4AAAAAz/2j7gAAAAAAtwFuAAAACAACAAAAAAAAAAEAAAHg/+AAAAIAAAAAAAC3AAEAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAQAAAAC3ABIAtwAAAAAAAAAKABQAHgBCAGQAAAABAAAABgAUAAEAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAADgCuAAEAAAAAAAEADAAAAAEAAAAAAAIADgBAAAEAAAAAAAMADAAiAAEAAAAAAAQADABOAAEAAAAAAAUAFgAMAAEAAAAAAAYABgAuAAEAAAAAAAoANABaAAMAAQQJAAEADAAAAAMAAQQJAAIADgBAAAMAAQQJAAMADAAiAAMAAQQJAAQADABOAAMAAQQJAAUAFgAMAAMAAQQJAAYADAA0AAMAAQQJAAoANABaAHIAYQB0AGkAbgBnAFYAZQByAHMAaQBvAG4AIAAxAC4AMAByAGEAdABpAG4AZ3JhdGluZwByAGEAdABpAG4AZwBSAGUAZwB1AGwAYQByAHIAYQB0AGkAbgBnAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) format('truetype'),url(data:application/font-woff;charset=utf-8;base64,d09GRk9UVE8AAASwAAoAAAAABGgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABDRkYgAAAA9AAAAS0AAAEtFpovuE9TLzIAAAIkAAAAYAAAAGAIIweQY21hcAAAAoQAAABMAAAATA984gpnYXNwAAAC0AAAAAgAAAAIAAAAEGhlYWQAAALYAAAANgAAADb/0IhHaGhlYQAAAxAAAAAkAAAAJAKZAedobXR4AAADNAAAABgAAAAYAm4AEm1heHAAAANMAAAABgAAAAYABlAAbmFtZQAAA1QAAAE8AAABPPC1n05wb3N0AAAEkAAAACAAAAAgAAMAAAEABAQAAQEBB3JhdGluZwABAgABADr4HAL4GwP4GAQeCgAZU/+Lix4KABlT/4uLDAeLa/iU+HQFHQAAAHkPHQAAAH4RHQAAAAkdAAABJBIABwEBBw0PERQZHnJhdGluZ3JhdGluZ3UwdTF1MjB1RjBEOXVGMERBAAACAYkABAAGAQEEBwoNVp38lA78lA78lA77lA773Z33bxWLkI2Qj44I9xT3FAWOj5CNkIuQi4+JjoePiI2Gi4YIi/uUBYuGiYeHiIiHh4mGi4aLho2Ijwj7FPcUBYeOiY+LkAgO+92L5hWL95QFi5CNkI6Oj4+PjZCLkIuQiY6HCPcU+xQFj4iNhouGi4aJh4eICPsU+xQFiIeGiYaLhouHjYePiI6Jj4uQCA74lBT4lBWLDAoAAAAAAwIAAZAABQAAAUwBZgAAAEcBTAFmAAAA9QAZAIQAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADw2gHg/+D/4AHgACAAAAABAAAAAAAAAAAAAAAgAAAAAAACAAAAAwAAABQAAwABAAAAFAAEADgAAAAKAAgAAgACAAEAIPDa//3//wAAAAAAIPDZ//3//wAB/+MPKwADAAEAAAAAAAAAAAAAAAEAAf//AA8AAQAAAAEAADfYOJZfDzz1AAsCAAAAAADP/aPuAAAAAM/9o+4AAAAAALcBbgAAAAgAAgAAAAAAAAABAAAB4P/gAAACAAAAAAAAtwABAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAAAAAAAAEAAAAAtwASALcAAAAAUAAABgAAAAAADgCuAAEAAAAAAAEADAAAAAEAAAAAAAIADgBAAAEAAAAAAAMADAAiAAEAAAAAAAQADABOAAEAAAAAAAUAFgAMAAEAAAAAAAYABgAuAAEAAAAAAAoANABaAAMAAQQJAAEADAAAAAMAAQQJAAIADgBAAAMAAQQJAAMADAAiAAMAAQQJAAQADABOAAMAAQQJAAUAFgAMAAMAAQQJAAYADAA0AAMAAQQJAAoANABaAHIAYQB0AGkAbgBnAFYAZQByAHMAaQBvAG4AIAAxAC4AMAByAGEAdABpAG4AZ3JhdGluZwByAGEAdABpAG4AZwBSAGUAZwB1AGwAYQByAHIAYQB0AGkAbgBnAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA) format('woff');font-weight:400;font-style:normal}.ui.accordion .accordion .title .dropdown.icon,.ui.accordion .title .dropdown.icon{font-family:Accordion;line-height:1;-webkit-backface-visibility:hidden;backface-visibility:hidden;font-weight:400;font-style:normal;text-align:center}.ui.accordion .accordion .title .dropdown.icon:before,.ui.accordion .title .dropdown.icon:before{content:'\f0da'}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 2.2.9 - Accordion
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
!function(e,n,t,i){"use strict";n="undefined"!=typeof n&&n.Math==Math?n:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),e.fn.accordion=function(t){var o,a=e(this),s=(new Date).getTime(),r=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);n.requestAnimationFrame||n.mozRequestAnimationFrame||n.webkitRequestAnimationFrame||n.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var d,g,f=e.isPlainObject(t)?e.extend(!0,{},e.fn.accordion.settings,t):e.extend({},e.fn.accordion.settings),m=f.className,p=f.namespace,h=f.selector,v=f.error,b="."+p,y="module-"+p,C=a.selector||"",O=e(this),x=O.find(h.title),F=O.find(h.content),A=this,T=O.data(y);g={initialize:function(){g.debug("Initializing",O),g.bind.events(),f.observeChanges&&g.observeChanges(),g.instantiate()},instantiate:function(){T=g,O.data(y,g)},destroy:function(){g.debug("Destroying previous instance",O),O.off(b).removeData(y)},refresh:function(){x=O.find(h.title),F=O.find(h.content)},observeChanges:function(){"MutationObserver"in n&&(d=new MutationObserver(function(e){g.debug("DOM tree modified, updating selector cache"),g.refresh()}),d.observe(A,{childList:!0,subtree:!0}),g.debug("Setting up mutation observer",d))},bind:{events:function(){g.debug("Binding delegated events"),O.on(f.on+b,h.trigger,g.event.click)}},event:{click:function(){g.toggle.call(this)}},toggle:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=s&&!a,c=!s&&a;g.debug("Toggling visibility of content",t),r||c?f.collapsible?g.close.call(t):g.debug("Cannot close accordion content collapsing is disabled"):g.open.call(t)},open:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=s||a;return r?void g.debug("Accordion already open, skipping",o):(g.debug("Opening accordion content",t),f.onOpening.call(o),f.exclusive&&g.closeOthers.call(t),t.addClass(m.active),o.stop(!0,!0).addClass(m.animating),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:1},f.duration,g.resetOpacity)),void o.slideDown(f.duration,f.easing,function(){o.removeClass(m.animating).addClass(m.active),g.reset.display.call(this),f.onOpen.call(this),f.onChange.call(this)}))},close:function(n){var t=n!==i?"number"==typeof n?x.eq(n):e(n).closest(h.title):e(this).closest(h.title),o=t.next(F),a=o.hasClass(m.animating),s=o.hasClass(m.active),r=!s&&a,c=s&&a;!s&&!r||c||(g.debug("Closing accordion content",o),f.onClosing.call(o),t.removeClass(m.active),o.stop(!0,!0).addClass(m.animating),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:0},f.duration,g.resetOpacity)),o.slideUp(f.duration,f.easing,function(){o.removeClass(m.animating).removeClass(m.active),g.reset.display.call(this),f.onClose.call(this),f.onChange.call(this)}))},closeOthers:function(n){var t,o,a,s=n!==i?x.eq(n):e(this).closest(h.title),r=s.parents(h.content).prev(h.title),c=s.closest(h.accordion),l=h.title+"."+m.active+":visible",u=h.content+"."+m.active+":visible";f.closeNested?(t=c.find(l).not(r),a=t.next(F)):(t=c.find(l).not(r),o=c.find(u).find(l).not(r),t=t.not(o),a=t.next(F)),t.length>0&&(g.debug("Exclusive enabled, closing other content",t),t.removeClass(m.active),a.removeClass(m.animating).stop(!0,!0),f.animateChildren&&(e.fn.transition!==i&&O.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop(!0,!0).animate({opacity:0},f.duration,g.resetOpacity)),a.slideUp(f.duration,f.easing,function(){e(this).removeClass(m.active),g.reset.display.call(this)}))},reset:{display:function(){g.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){g.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(n,t){if(g.debug("Changing setting",n,t),e.isPlainObject(n))e.extend(!0,f,n);else{if(t===i)return f[n];e.isPlainObject(f[n])?e.extend(!0,f[n],t):f[n]=t}},internal:function(n,t){return g.debug("Changing internal",n,t),t===i?g[n]:void(e.isPlainObject(n)?e.extend(!0,g,n):g[n]=t)},debug:function(){!f.silent&&f.debug&&(f.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,f.name+":"),g.debug.apply(console,arguments)))},verbose:function(){!f.silent&&f.verbose&&f.debug&&(f.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),g.verbose.apply(console,arguments)))},error:function(){f.silent||(g.error=Function.prototype.bind.call(console.error,console,f.name+":"),g.error.apply(console,arguments))},performance:{log:function(e){var n,t,i;f.performance&&(n=(new Date).getTime(),i=s||n,t=n-i,s=n,r.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:A,"Execution Time":t})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var n=f.name+":",t=0;s=!1,clearTimeout(g.performance.timer),e.each(r,function(e,n){t+=n["Execution Time"]}),n+=" "+t+"ms",C&&(n+=" '"+C+"'"),(console.group!==i||console.table!==i)&&r.length>0&&(console.groupCollapsed(n),console.table?console.table(r):e.each(r,function(e,n){console.log(n.Name+": "+n["Execution Time"]+"ms")}),console.groupEnd()),r=[]}},invoke:function(n,t,a){var s,r,c,l=T;return t=t||u,a=A||a,"string"==typeof n&&l!==i&&(n=n.split(/[\. ]/),s=n.length-1,e.each(n,function(t,o){var a=t!=s?o+n[t+1].charAt(0).toUpperCase()+n[t+1].slice(1):n;if(e.isPlainObject(l[a])&&t!=s)l=l[a];else{if(l[a]!==i)return r=l[a],!1;if(!e.isPlainObject(l[o])||t==s)return l[o]!==i?(r=l[o],!1):(g.error(v.method,n),!1);l=l[o]}})),e.isFunction(r)?c=r.apply(a,t):r!==i&&(c=r),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),r}},l?(T===i&&g.initialize(),g.invoke(c)):(T!==i&&T.invoke("destroy"),g.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",silent:!1,debug:!1,verbose:!1,performance:!0,on:"click",observeChanges:!0,exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",onOpening:function(){},onOpen:function(){},onClosing:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating"},selector:{accordion:".accordion",title:".title",trigger:".title",content:".content"}},e.extend(e.easing,{easeOutQuad:function(e,n,t,i,o){return-i*(n/=o)*(n-2)+t}})}(jQuery,window,document);
|
@@ -0,0 +1,275 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 2.2.9 - Ad
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Copyright 2013 Contributors
|
7
|
+
* Released under the MIT license
|
8
|
+
* http://opensource.org/licenses/MIT
|
9
|
+
*
|
10
|
+
*/
|
11
|
+
|
12
|
+
|
13
|
+
/*******************************
|
14
|
+
Advertisement
|
15
|
+
*******************************/
|
16
|
+
|
17
|
+
.ui.ad {
|
18
|
+
display: block;
|
19
|
+
overflow: hidden;
|
20
|
+
margin: 1em 0em;
|
21
|
+
}
|
22
|
+
.ui.ad:first-child {
|
23
|
+
margin: 0em;
|
24
|
+
}
|
25
|
+
.ui.ad:last-child {
|
26
|
+
margin: 0em;
|
27
|
+
}
|
28
|
+
.ui.ad iframe {
|
29
|
+
margin: 0em;
|
30
|
+
padding: 0em;
|
31
|
+
border: none;
|
32
|
+
overflow: hidden;
|
33
|
+
}
|
34
|
+
|
35
|
+
/*--------------
|
36
|
+
Common
|
37
|
+
---------------*/
|
38
|
+
|
39
|
+
|
40
|
+
/* Leaderboard */
|
41
|
+
.ui.leaderboard.ad {
|
42
|
+
width: 728px;
|
43
|
+
height: 90px;
|
44
|
+
}
|
45
|
+
|
46
|
+
/* Medium Rectangle */
|
47
|
+
.ui[class*="medium rectangle"].ad {
|
48
|
+
width: 300px;
|
49
|
+
height: 250px;
|
50
|
+
}
|
51
|
+
|
52
|
+
/* Large Rectangle */
|
53
|
+
.ui[class*="large rectangle"].ad {
|
54
|
+
width: 336px;
|
55
|
+
height: 280px;
|
56
|
+
}
|
57
|
+
|
58
|
+
/* Half Page */
|
59
|
+
.ui[class*="half page"].ad {
|
60
|
+
width: 300px;
|
61
|
+
height: 600px;
|
62
|
+
}
|
63
|
+
|
64
|
+
/*--------------
|
65
|
+
Square
|
66
|
+
---------------*/
|
67
|
+
|
68
|
+
|
69
|
+
/* Square */
|
70
|
+
.ui.square.ad {
|
71
|
+
width: 250px;
|
72
|
+
height: 250px;
|
73
|
+
}
|
74
|
+
|
75
|
+
/* Small Square */
|
76
|
+
.ui[class*="small square"].ad {
|
77
|
+
width: 200px;
|
78
|
+
height: 200px;
|
79
|
+
}
|
80
|
+
|
81
|
+
/*--------------
|
82
|
+
Rectangle
|
83
|
+
---------------*/
|
84
|
+
|
85
|
+
|
86
|
+
/* Small Rectangle */
|
87
|
+
.ui[class*="small rectangle"].ad {
|
88
|
+
width: 180px;
|
89
|
+
height: 150px;
|
90
|
+
}
|
91
|
+
|
92
|
+
/* Vertical Rectangle */
|
93
|
+
.ui[class*="vertical rectangle"].ad {
|
94
|
+
width: 240px;
|
95
|
+
height: 400px;
|
96
|
+
}
|
97
|
+
|
98
|
+
/*--------------
|
99
|
+
Button
|
100
|
+
---------------*/
|
101
|
+
|
102
|
+
.ui.button.ad {
|
103
|
+
width: 120px;
|
104
|
+
height: 90px;
|
105
|
+
}
|
106
|
+
.ui[class*="square button"].ad {
|
107
|
+
width: 125px;
|
108
|
+
height: 125px;
|
109
|
+
}
|
110
|
+
.ui[class*="small button"].ad {
|
111
|
+
width: 120px;
|
112
|
+
height: 60px;
|
113
|
+
}
|
114
|
+
|
115
|
+
/*--------------
|
116
|
+
Skyscrapers
|
117
|
+
---------------*/
|
118
|
+
|
119
|
+
|
120
|
+
/* Skyscraper */
|
121
|
+
.ui.skyscraper.ad {
|
122
|
+
width: 120px;
|
123
|
+
height: 600px;
|
124
|
+
}
|
125
|
+
|
126
|
+
/* Wide Skyscraper */
|
127
|
+
.ui[class*="wide skyscraper"].ad {
|
128
|
+
width: 160px;
|
129
|
+
}
|
130
|
+
|
131
|
+
/*--------------
|
132
|
+
Banners
|
133
|
+
---------------*/
|
134
|
+
|
135
|
+
|
136
|
+
/* Banner */
|
137
|
+
.ui.banner.ad {
|
138
|
+
width: 468px;
|
139
|
+
height: 60px;
|
140
|
+
}
|
141
|
+
|
142
|
+
/* Vertical Banner */
|
143
|
+
.ui[class*="vertical banner"].ad {
|
144
|
+
width: 120px;
|
145
|
+
height: 240px;
|
146
|
+
}
|
147
|
+
|
148
|
+
/* Top Banner */
|
149
|
+
.ui[class*="top banner"].ad {
|
150
|
+
width: 930px;
|
151
|
+
height: 180px;
|
152
|
+
}
|
153
|
+
|
154
|
+
/* Half Banner */
|
155
|
+
.ui[class*="half banner"].ad {
|
156
|
+
width: 234px;
|
157
|
+
height: 60px;
|
158
|
+
}
|
159
|
+
|
160
|
+
/*--------------
|
161
|
+
Boards
|
162
|
+
---------------*/
|
163
|
+
|
164
|
+
|
165
|
+
/* Leaderboard */
|
166
|
+
.ui[class*="large leaderboard"].ad {
|
167
|
+
width: 970px;
|
168
|
+
height: 90px;
|
169
|
+
}
|
170
|
+
|
171
|
+
/* Billboard */
|
172
|
+
.ui.billboard.ad {
|
173
|
+
width: 970px;
|
174
|
+
height: 250px;
|
175
|
+
}
|
176
|
+
|
177
|
+
/*--------------
|
178
|
+
Panorama
|
179
|
+
---------------*/
|
180
|
+
|
181
|
+
|
182
|
+
/* Panorama */
|
183
|
+
.ui.panorama.ad {
|
184
|
+
width: 980px;
|
185
|
+
height: 120px;
|
186
|
+
}
|
187
|
+
|
188
|
+
/*--------------
|
189
|
+
Netboard
|
190
|
+
---------------*/
|
191
|
+
|
192
|
+
|
193
|
+
/* Netboard */
|
194
|
+
.ui.netboard.ad {
|
195
|
+
width: 580px;
|
196
|
+
height: 400px;
|
197
|
+
}
|
198
|
+
|
199
|
+
/*--------------
|
200
|
+
Mobile
|
201
|
+
---------------*/
|
202
|
+
|
203
|
+
|
204
|
+
/* Large Mobile Banner */
|
205
|
+
.ui[class*="large mobile banner"].ad {
|
206
|
+
width: 320px;
|
207
|
+
height: 100px;
|
208
|
+
}
|
209
|
+
|
210
|
+
/* Mobile Leaderboard */
|
211
|
+
.ui[class*="mobile leaderboard"].ad {
|
212
|
+
width: 320px;
|
213
|
+
height: 50px;
|
214
|
+
}
|
215
|
+
|
216
|
+
|
217
|
+
/*******************************
|
218
|
+
Types
|
219
|
+
*******************************/
|
220
|
+
|
221
|
+
|
222
|
+
/* Mobile Sizes */
|
223
|
+
.ui.mobile.ad {
|
224
|
+
display: none;
|
225
|
+
}
|
226
|
+
@media only screen and (max-width: 767px) {
|
227
|
+
.ui.mobile.ad {
|
228
|
+
display: block;
|
229
|
+
}
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
/*******************************
|
234
|
+
Variations
|
235
|
+
*******************************/
|
236
|
+
|
237
|
+
.ui.centered.ad {
|
238
|
+
margin-left: auto;
|
239
|
+
margin-right: auto;
|
240
|
+
}
|
241
|
+
.ui.test.ad {
|
242
|
+
position: relative;
|
243
|
+
background: #545454;
|
244
|
+
}
|
245
|
+
.ui.test.ad:after {
|
246
|
+
position: absolute;
|
247
|
+
top: 50%;
|
248
|
+
left: 50%;
|
249
|
+
width: 100%;
|
250
|
+
text-align: center;
|
251
|
+
-webkit-transform: translateX(-50%) translateY(-50%);
|
252
|
+
transform: translateX(-50%) translateY(-50%);
|
253
|
+
content: 'Ad';
|
254
|
+
color: #FFFFFF;
|
255
|
+
font-size: 1em;
|
256
|
+
font-weight: bold;
|
257
|
+
}
|
258
|
+
.ui.mobile.test.ad:after {
|
259
|
+
font-size: 0.85714286em;
|
260
|
+
}
|
261
|
+
.ui.test.ad[data-text]:after {
|
262
|
+
content: attr(data-text);
|
263
|
+
}
|
264
|
+
|
265
|
+
|
266
|
+
/*******************************
|
267
|
+
Theme Overrides
|
268
|
+
*******************************/
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
/*******************************
|
273
|
+
User Variable Overrides
|
274
|
+
*******************************/
|
275
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 2.2.9 - Ad
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Copyright 2013 Contributors
|
7
|
+
* Released under the MIT license
|
8
|
+
* http://opensource.org/licenses/MIT
|
9
|
+
*
|
10
|
+
*/.ui.ad{display:block;overflow:hidden;margin:1em 0}.ui.ad:first-child{margin:0}.ui.ad:last-child{margin:0}.ui.ad iframe{margin:0;padding:0;border:none;overflow:hidden}.ui.leaderboard.ad{width:728px;height:90px}.ui[class*="medium rectangle"].ad{width:300px;height:250px}.ui[class*="large rectangle"].ad{width:336px;height:280px}.ui[class*="half page"].ad{width:300px;height:600px}.ui.square.ad{width:250px;height:250px}.ui[class*="small square"].ad{width:200px;height:200px}.ui[class*="small rectangle"].ad{width:180px;height:150px}.ui[class*="vertical rectangle"].ad{width:240px;height:400px}.ui.button.ad{width:120px;height:90px}.ui[class*="square button"].ad{width:125px;height:125px}.ui[class*="small button"].ad{width:120px;height:60px}.ui.skyscraper.ad{width:120px;height:600px}.ui[class*="wide skyscraper"].ad{width:160px}.ui.banner.ad{width:468px;height:60px}.ui[class*="vertical banner"].ad{width:120px;height:240px}.ui[class*="top banner"].ad{width:930px;height:180px}.ui[class*="half banner"].ad{width:234px;height:60px}.ui[class*="large leaderboard"].ad{width:970px;height:90px}.ui.billboard.ad{width:970px;height:250px}.ui.panorama.ad{width:980px;height:120px}.ui.netboard.ad{width:580px;height:400px}.ui[class*="large mobile banner"].ad{width:320px;height:100px}.ui[class*="mobile leaderboard"].ad{width:320px;height:50px}.ui.mobile.ad{display:none}@media only screen and (max-width:767px){.ui.mobile.ad{display:block}}.ui.centered.ad{margin-left:auto;margin-right:auto}.ui.test.ad{position:relative;background:#545454}.ui.test.ad:after{position:absolute;top:50%;left:50%;width:100%;text-align:center;-webkit-transform:translateX(-50%) translateY(-50%);transform:translateX(-50%) translateY(-50%);content:'Ad';color:#fff;font-size:1em;font-weight:700}.ui.mobile.test.ad:after{font-size:.85714286em}.ui.test.ad[data-text]:after{content:attr(data-text)}
|
@@ -0,0 +1,1167 @@
|
|
1
|
+
/*!
|
2
|
+
* # Semantic UI 2.2.9 - API
|
3
|
+
* http://github.com/semantic-org/semantic-ui/
|
4
|
+
*
|
5
|
+
*
|
6
|
+
* Released under the MIT license
|
7
|
+
* http://opensource.org/licenses/MIT
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
;(function ($, window, document, undefined) {
|
12
|
+
|
13
|
+
"use strict";
|
14
|
+
|
15
|
+
var
|
16
|
+
window = (typeof window != 'undefined' && window.Math == Math)
|
17
|
+
? window
|
18
|
+
: (typeof self != 'undefined' && self.Math == Math)
|
19
|
+
? self
|
20
|
+
: Function('return this')()
|
21
|
+
;
|
22
|
+
|
23
|
+
$.api = $.fn.api = function(parameters) {
|
24
|
+
|
25
|
+
var
|
26
|
+
// use window context if none specified
|
27
|
+
$allModules = $.isFunction(this)
|
28
|
+
? $(window)
|
29
|
+
: $(this),
|
30
|
+
moduleSelector = $allModules.selector || '',
|
31
|
+
time = new Date().getTime(),
|
32
|
+
performance = [],
|
33
|
+
|
34
|
+
query = arguments[0],
|
35
|
+
methodInvoked = (typeof query == 'string'),
|
36
|
+
queryArguments = [].slice.call(arguments, 1),
|
37
|
+
|
38
|
+
returnedValue
|
39
|
+
;
|
40
|
+
|
41
|
+
$allModules
|
42
|
+
.each(function() {
|
43
|
+
var
|
44
|
+
settings = ( $.isPlainObject(parameters) )
|
45
|
+
? $.extend(true, {}, $.fn.api.settings, parameters)
|
46
|
+
: $.extend({}, $.fn.api.settings),
|
47
|
+
|
48
|
+
// internal aliases
|
49
|
+
namespace = settings.namespace,
|
50
|
+
metadata = settings.metadata,
|
51
|
+
selector = settings.selector,
|
52
|
+
error = settings.error,
|
53
|
+
className = settings.className,
|
54
|
+
|
55
|
+
// define namespaces for modules
|
56
|
+
eventNamespace = '.' + namespace,
|
57
|
+
moduleNamespace = 'module-' + namespace,
|
58
|
+
|
59
|
+
// element that creates request
|
60
|
+
$module = $(this),
|
61
|
+
$form = $module.closest(selector.form),
|
62
|
+
|
63
|
+
// context used for state
|
64
|
+
$context = (settings.stateContext)
|
65
|
+
? $(settings.stateContext)
|
66
|
+
: $module,
|
67
|
+
|
68
|
+
// request details
|
69
|
+
ajaxSettings,
|
70
|
+
requestSettings,
|
71
|
+
url,
|
72
|
+
data,
|
73
|
+
requestStartTime,
|
74
|
+
|
75
|
+
// standard module
|
76
|
+
element = this,
|
77
|
+
context = $context[0],
|
78
|
+
instance = $module.data(moduleNamespace),
|
79
|
+
module
|
80
|
+
;
|
81
|
+
|
82
|
+
module = {
|
83
|
+
|
84
|
+
initialize: function() {
|
85
|
+
if(!methodInvoked) {
|
86
|
+
module.bind.events();
|
87
|
+
}
|
88
|
+
module.instantiate();
|
89
|
+
},
|
90
|
+
|
91
|
+
instantiate: function() {
|
92
|
+
module.verbose('Storing instance of module', module);
|
93
|
+
instance = module;
|
94
|
+
$module
|
95
|
+
.data(moduleNamespace, instance)
|
96
|
+
;
|
97
|
+
},
|
98
|
+
|
99
|
+
destroy: function() {
|
100
|
+
module.verbose('Destroying previous module for', element);
|
101
|
+
$module
|
102
|
+
.removeData(moduleNamespace)
|
103
|
+
.off(eventNamespace)
|
104
|
+
;
|
105
|
+
},
|
106
|
+
|
107
|
+
bind: {
|
108
|
+
events: function() {
|
109
|
+
var
|
110
|
+
triggerEvent = module.get.event()
|
111
|
+
;
|
112
|
+
if( triggerEvent ) {
|
113
|
+
module.verbose('Attaching API events to element', triggerEvent);
|
114
|
+
$module
|
115
|
+
.on(triggerEvent + eventNamespace, module.event.trigger)
|
116
|
+
;
|
117
|
+
}
|
118
|
+
else if(settings.on == 'now') {
|
119
|
+
module.debug('Querying API endpoint immediately');
|
120
|
+
module.query();
|
121
|
+
}
|
122
|
+
}
|
123
|
+
},
|
124
|
+
|
125
|
+
decode: {
|
126
|
+
json: function(response) {
|
127
|
+
if(response !== undefined && typeof response == 'string') {
|
128
|
+
try {
|
129
|
+
response = JSON.parse(response);
|
130
|
+
}
|
131
|
+
catch(e) {
|
132
|
+
// isnt json string
|
133
|
+
}
|
134
|
+
}
|
135
|
+
return response;
|
136
|
+
}
|
137
|
+
},
|
138
|
+
|
139
|
+
read: {
|
140
|
+
cachedResponse: function(url) {
|
141
|
+
var
|
142
|
+
response
|
143
|
+
;
|
144
|
+
if(window.Storage === undefined) {
|
145
|
+
module.error(error.noStorage);
|
146
|
+
return;
|
147
|
+
}
|
148
|
+
response = sessionStorage.getItem(url);
|
149
|
+
module.debug('Using cached response', url, response);
|
150
|
+
response = module.decode.json(response);
|
151
|
+
return response;
|
152
|
+
}
|
153
|
+
},
|
154
|
+
write: {
|
155
|
+
cachedResponse: function(url, response) {
|
156
|
+
if(response && response === '') {
|
157
|
+
module.debug('Response empty, not caching', response);
|
158
|
+
return;
|
159
|
+
}
|
160
|
+
if(window.Storage === undefined) {
|
161
|
+
module.error(error.noStorage);
|
162
|
+
return;
|
163
|
+
}
|
164
|
+
if( $.isPlainObject(response) ) {
|
165
|
+
response = JSON.stringify(response);
|
166
|
+
}
|
167
|
+
sessionStorage.setItem(url, response);
|
168
|
+
module.verbose('Storing cached response for url', url, response);
|
169
|
+
}
|
170
|
+
},
|
171
|
+
|
172
|
+
query: function() {
|
173
|
+
|
174
|
+
if(module.is.disabled()) {
|
175
|
+
module.debug('Element is disabled API request aborted');
|
176
|
+
return;
|
177
|
+
}
|
178
|
+
|
179
|
+
if(module.is.loading()) {
|
180
|
+
if(settings.interruptRequests) {
|
181
|
+
module.debug('Interrupting previous request');
|
182
|
+
module.abort();
|
183
|
+
}
|
184
|
+
else {
|
185
|
+
module.debug('Cancelling request, previous request is still pending');
|
186
|
+
return;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
// pass element metadata to url (value, text)
|
191
|
+
if(settings.defaultData) {
|
192
|
+
$.extend(true, settings.urlData, module.get.defaultData());
|
193
|
+
}
|
194
|
+
|
195
|
+
// Add form content
|
196
|
+
if(settings.serializeForm) {
|
197
|
+
settings.data = module.add.formData(settings.data);
|
198
|
+
}
|
199
|
+
|
200
|
+
// call beforesend and get any settings changes
|
201
|
+
requestSettings = module.get.settings();
|
202
|
+
|
203
|
+
// check if before send cancelled request
|
204
|
+
if(requestSettings === false) {
|
205
|
+
module.cancelled = true;
|
206
|
+
module.error(error.beforeSend);
|
207
|
+
return;
|
208
|
+
}
|
209
|
+
else {
|
210
|
+
module.cancelled = false;
|
211
|
+
}
|
212
|
+
|
213
|
+
// get url
|
214
|
+
url = module.get.templatedURL();
|
215
|
+
|
216
|
+
if(!url && !module.is.mocked()) {
|
217
|
+
module.error(error.missingURL);
|
218
|
+
return;
|
219
|
+
}
|
220
|
+
|
221
|
+
// replace variables
|
222
|
+
url = module.add.urlData( url );
|
223
|
+
// missing url parameters
|
224
|
+
if( !url && !module.is.mocked()) {
|
225
|
+
return;
|
226
|
+
}
|
227
|
+
|
228
|
+
requestSettings.url = settings.base + url;
|
229
|
+
|
230
|
+
// look for jQuery ajax parameters in settings
|
231
|
+
ajaxSettings = $.extend(true, {}, settings, {
|
232
|
+
type : settings.method || settings.type,
|
233
|
+
data : data,
|
234
|
+
url : settings.base + url,
|
235
|
+
beforeSend : settings.beforeXHR,
|
236
|
+
success : function() {},
|
237
|
+
failure : function() {},
|
238
|
+
complete : function() {}
|
239
|
+
});
|
240
|
+
|
241
|
+
module.debug('Querying URL', ajaxSettings.url);
|
242
|
+
module.verbose('Using AJAX settings', ajaxSettings);
|
243
|
+
if(settings.cache === 'local' && module.read.cachedResponse(url)) {
|
244
|
+
module.debug('Response returned from local cache');
|
245
|
+
module.request = module.create.request();
|
246
|
+
module.request.resolveWith(context, [ module.read.cachedResponse(url) ]);
|
247
|
+
return;
|
248
|
+
}
|
249
|
+
|
250
|
+
if( !settings.throttle ) {
|
251
|
+
module.debug('Sending request', data, ajaxSettings.method);
|
252
|
+
module.send.request();
|
253
|
+
}
|
254
|
+
else {
|
255
|
+
if(!settings.throttleFirstRequest && !module.timer) {
|
256
|
+
module.debug('Sending request', data, ajaxSettings.method);
|
257
|
+
module.send.request();
|
258
|
+
module.timer = setTimeout(function(){}, settings.throttle);
|
259
|
+
}
|
260
|
+
else {
|
261
|
+
module.debug('Throttling request', settings.throttle);
|
262
|
+
clearTimeout(module.timer);
|
263
|
+
module.timer = setTimeout(function() {
|
264
|
+
if(module.timer) {
|
265
|
+
delete module.timer;
|
266
|
+
}
|
267
|
+
module.debug('Sending throttled request', data, ajaxSettings.method);
|
268
|
+
module.send.request();
|
269
|
+
}, settings.throttle);
|
270
|
+
}
|
271
|
+
}
|
272
|
+
|
273
|
+
},
|
274
|
+
|
275
|
+
should: {
|
276
|
+
removeError: function() {
|
277
|
+
return ( settings.hideError === true || (settings.hideError === 'auto' && !module.is.form()) );
|
278
|
+
}
|
279
|
+
},
|
280
|
+
|
281
|
+
is: {
|
282
|
+
disabled: function() {
|
283
|
+
return ($module.filter(selector.disabled).length > 0);
|
284
|
+
},
|
285
|
+
expectingJSON: function() {
|
286
|
+
return settings.dataType === 'json' || settings.dataType === 'jsonp';
|
287
|
+
},
|
288
|
+
form: function() {
|
289
|
+
return $module.is('form') || $context.is('form');
|
290
|
+
},
|
291
|
+
mocked: function() {
|
292
|
+
return (settings.mockResponse || settings.mockResponseAsync || settings.response || settings.responseAsync);
|
293
|
+
},
|
294
|
+
input: function() {
|
295
|
+
return $module.is('input');
|
296
|
+
},
|
297
|
+
loading: function() {
|
298
|
+
return (module.request)
|
299
|
+
? (module.request.state() == 'pending')
|
300
|
+
: false
|
301
|
+
;
|
302
|
+
},
|
303
|
+
abortedRequest: function(xhr) {
|
304
|
+
if(xhr && xhr.readyState !== undefined && xhr.readyState === 0) {
|
305
|
+
module.verbose('XHR request determined to be aborted');
|
306
|
+
return true;
|
307
|
+
}
|
308
|
+
else {
|
309
|
+
module.verbose('XHR request was not aborted');
|
310
|
+
return false;
|
311
|
+
}
|
312
|
+
},
|
313
|
+
validResponse: function(response) {
|
314
|
+
if( (!module.is.expectingJSON()) || !$.isFunction(settings.successTest) ) {
|
315
|
+
module.verbose('Response is not JSON, skipping validation', settings.successTest, response);
|
316
|
+
return true;
|
317
|
+
}
|
318
|
+
module.debug('Checking JSON returned success', settings.successTest, response);
|
319
|
+
if( settings.successTest(response) ) {
|
320
|
+
module.debug('Response passed success test', response);
|
321
|
+
return true;
|
322
|
+
}
|
323
|
+
else {
|
324
|
+
module.debug('Response failed success test', response);
|
325
|
+
return false;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
},
|
329
|
+
|
330
|
+
was: {
|
331
|
+
cancelled: function() {
|
332
|
+
return (module.cancelled || false);
|
333
|
+
},
|
334
|
+
succesful: function() {
|
335
|
+
return (module.request && module.request.state() == 'resolved');
|
336
|
+
},
|
337
|
+
failure: function() {
|
338
|
+
return (module.request && module.request.state() == 'rejected');
|
339
|
+
},
|
340
|
+
complete: function() {
|
341
|
+
return (module.request && (module.request.state() == 'resolved' || module.request.state() == 'rejected') );
|
342
|
+
}
|
343
|
+
},
|
344
|
+
|
345
|
+
add: {
|
346
|
+
urlData: function(url, urlData) {
|
347
|
+
var
|
348
|
+
requiredVariables,
|
349
|
+
optionalVariables
|
350
|
+
;
|
351
|
+
if(url) {
|
352
|
+
requiredVariables = url.match(settings.regExp.required);
|
353
|
+
optionalVariables = url.match(settings.regExp.optional);
|
354
|
+
urlData = urlData || settings.urlData;
|
355
|
+
if(requiredVariables) {
|
356
|
+
module.debug('Looking for required URL variables', requiredVariables);
|
357
|
+
$.each(requiredVariables, function(index, templatedString) {
|
358
|
+
var
|
359
|
+
// allow legacy {$var} style
|
360
|
+
variable = (templatedString.indexOf('$') !== -1)
|
361
|
+
? templatedString.substr(2, templatedString.length - 3)
|
362
|
+
: templatedString.substr(1, templatedString.length - 2),
|
363
|
+
value = ($.isPlainObject(urlData) && urlData[variable] !== undefined)
|
364
|
+
? urlData[variable]
|
365
|
+
: ($module.data(variable) !== undefined)
|
366
|
+
? $module.data(variable)
|
367
|
+
: ($context.data(variable) !== undefined)
|
368
|
+
? $context.data(variable)
|
369
|
+
: urlData[variable]
|
370
|
+
;
|
371
|
+
// remove value
|
372
|
+
if(value === undefined) {
|
373
|
+
module.error(error.requiredParameter, variable, url);
|
374
|
+
url = false;
|
375
|
+
return false;
|
376
|
+
}
|
377
|
+
else {
|
378
|
+
module.verbose('Found required variable', variable, value);
|
379
|
+
value = (settings.encodeParameters)
|
380
|
+
? module.get.urlEncodedValue(value)
|
381
|
+
: value
|
382
|
+
;
|
383
|
+
url = url.replace(templatedString, value);
|
384
|
+
}
|
385
|
+
});
|
386
|
+
}
|
387
|
+
if(optionalVariables) {
|
388
|
+
module.debug('Looking for optional URL variables', requiredVariables);
|
389
|
+
$.each(optionalVariables, function(index, templatedString) {
|
390
|
+
var
|
391
|
+
// allow legacy {/$var} style
|
392
|
+
variable = (templatedString.indexOf('$') !== -1)
|
393
|
+
? templatedString.substr(3, templatedString.length - 4)
|
394
|
+
: templatedString.substr(2, templatedString.length - 3),
|
395
|
+
value = ($.isPlainObject(urlData) && urlData[variable] !== undefined)
|
396
|
+
? urlData[variable]
|
397
|
+
: ($module.data(variable) !== undefined)
|
398
|
+
? $module.data(variable)
|
399
|
+
: ($context.data(variable) !== undefined)
|
400
|
+
? $context.data(variable)
|
401
|
+
: urlData[variable]
|
402
|
+
;
|
403
|
+
// optional replacement
|
404
|
+
if(value !== undefined) {
|
405
|
+
module.verbose('Optional variable Found', variable, value);
|
406
|
+
url = url.replace(templatedString, value);
|
407
|
+
}
|
408
|
+
else {
|
409
|
+
module.verbose('Optional variable not found', variable);
|
410
|
+
// remove preceding slash if set
|
411
|
+
if(url.indexOf('/' + templatedString) !== -1) {
|
412
|
+
url = url.replace('/' + templatedString, '');
|
413
|
+
}
|
414
|
+
else {
|
415
|
+
url = url.replace(templatedString, '');
|
416
|
+
}
|
417
|
+
}
|
418
|
+
});
|
419
|
+
}
|
420
|
+
}
|
421
|
+
return url;
|
422
|
+
},
|
423
|
+
formData: function(data) {
|
424
|
+
var
|
425
|
+
canSerialize = ($.fn.serializeObject !== undefined),
|
426
|
+
formData = (canSerialize)
|
427
|
+
? $form.serializeObject()
|
428
|
+
: $form.serialize(),
|
429
|
+
hasOtherData
|
430
|
+
;
|
431
|
+
data = data || settings.data;
|
432
|
+
hasOtherData = $.isPlainObject(data);
|
433
|
+
|
434
|
+
if(hasOtherData) {
|
435
|
+
if(canSerialize) {
|
436
|
+
module.debug('Extending existing data with form data', data, formData);
|
437
|
+
data = $.extend(true, {}, data, formData);
|
438
|
+
}
|
439
|
+
else {
|
440
|
+
module.error(error.missingSerialize);
|
441
|
+
module.debug('Cant extend data. Replacing data with form data', data, formData);
|
442
|
+
data = formData;
|
443
|
+
}
|
444
|
+
}
|
445
|
+
else {
|
446
|
+
module.debug('Adding form data', formData);
|
447
|
+
data = formData;
|
448
|
+
}
|
449
|
+
return data;
|
450
|
+
}
|
451
|
+
},
|
452
|
+
|
453
|
+
send: {
|
454
|
+
request: function() {
|
455
|
+
module.set.loading();
|
456
|
+
module.request = module.create.request();
|
457
|
+
if( module.is.mocked() ) {
|
458
|
+
module.mockedXHR = module.create.mockedXHR();
|
459
|
+
}
|
460
|
+
else {
|
461
|
+
module.xhr = module.create.xhr();
|
462
|
+
}
|
463
|
+
settings.onRequest.call(context, module.request, module.xhr);
|
464
|
+
}
|
465
|
+
},
|
466
|
+
|
467
|
+
event: {
|
468
|
+
trigger: function(event) {
|
469
|
+
module.query();
|
470
|
+
if(event.type == 'submit' || event.type == 'click') {
|
471
|
+
event.preventDefault();
|
472
|
+
}
|
473
|
+
},
|
474
|
+
xhr: {
|
475
|
+
always: function() {
|
476
|
+
// nothing special
|
477
|
+
},
|
478
|
+
done: function(response, textStatus, xhr) {
|
479
|
+
var
|
480
|
+
context = this,
|
481
|
+
elapsedTime = (new Date().getTime() - requestStartTime),
|
482
|
+
timeLeft = (settings.loadingDuration - elapsedTime),
|
483
|
+
translatedResponse = ( $.isFunction(settings.onResponse) )
|
484
|
+
? module.is.expectingJSON()
|
485
|
+
? settings.onResponse.call(context, $.extend(true, {}, response))
|
486
|
+
: settings.onResponse.call(context, response)
|
487
|
+
: false
|
488
|
+
;
|
489
|
+
timeLeft = (timeLeft > 0)
|
490
|
+
? timeLeft
|
491
|
+
: 0
|
492
|
+
;
|
493
|
+
if(translatedResponse) {
|
494
|
+
module.debug('Modified API response in onResponse callback', settings.onResponse, translatedResponse, response);
|
495
|
+
response = translatedResponse;
|
496
|
+
}
|
497
|
+
if(timeLeft > 0) {
|
498
|
+
module.debug('Response completed early delaying state change by', timeLeft);
|
499
|
+
}
|
500
|
+
setTimeout(function() {
|
501
|
+
if( module.is.validResponse(response) ) {
|
502
|
+
module.request.resolveWith(context, [response, xhr]);
|
503
|
+
}
|
504
|
+
else {
|
505
|
+
module.request.rejectWith(context, [xhr, 'invalid']);
|
506
|
+
}
|
507
|
+
}, timeLeft);
|
508
|
+
},
|
509
|
+
fail: function(xhr, status, httpMessage) {
|
510
|
+
var
|
511
|
+
context = this,
|
512
|
+
elapsedTime = (new Date().getTime() - requestStartTime),
|
513
|
+
timeLeft = (settings.loadingDuration - elapsedTime)
|
514
|
+
;
|
515
|
+
timeLeft = (timeLeft > 0)
|
516
|
+
? timeLeft
|
517
|
+
: 0
|
518
|
+
;
|
519
|
+
if(timeLeft > 0) {
|
520
|
+
module.debug('Response completed early delaying state change by', timeLeft);
|
521
|
+
}
|
522
|
+
setTimeout(function() {
|
523
|
+
if( module.is.abortedRequest(xhr) ) {
|
524
|
+
module.request.rejectWith(context, [xhr, 'aborted', httpMessage]);
|
525
|
+
}
|
526
|
+
else {
|
527
|
+
module.request.rejectWith(context, [xhr, 'error', status, httpMessage]);
|
528
|
+
}
|
529
|
+
}, timeLeft);
|
530
|
+
}
|
531
|
+
},
|
532
|
+
request: {
|
533
|
+
done: function(response, xhr) {
|
534
|
+
module.debug('Successful API Response', response);
|
535
|
+
if(settings.cache === 'local' && url) {
|
536
|
+
module.write.cachedResponse(url, response);
|
537
|
+
module.debug('Saving server response locally', module.cache);
|
538
|
+
}
|
539
|
+
settings.onSuccess.call(context, response, $module, xhr);
|
540
|
+
},
|
541
|
+
complete: function(firstParameter, secondParameter) {
|
542
|
+
var
|
543
|
+
xhr,
|
544
|
+
response
|
545
|
+
;
|
546
|
+
// have to guess callback parameters based on request success
|
547
|
+
if( module.was.succesful() ) {
|
548
|
+
response = firstParameter;
|
549
|
+
xhr = secondParameter;
|
550
|
+
}
|
551
|
+
else {
|
552
|
+
xhr = firstParameter;
|
553
|
+
response = module.get.responseFromXHR(xhr);
|
554
|
+
}
|
555
|
+
module.remove.loading();
|
556
|
+
settings.onComplete.call(context, response, $module, xhr);
|
557
|
+
},
|
558
|
+
fail: function(xhr, status, httpMessage) {
|
559
|
+
var
|
560
|
+
// pull response from xhr if available
|
561
|
+
response = module.get.responseFromXHR(xhr),
|
562
|
+
errorMessage = module.get.errorFromRequest(response, status, httpMessage)
|
563
|
+
;
|
564
|
+
if(status == 'aborted') {
|
565
|
+
module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage);
|
566
|
+
settings.onAbort.call(context, status, $module, xhr);
|
567
|
+
return true;
|
568
|
+
}
|
569
|
+
else if(status == 'invalid') {
|
570
|
+
module.debug('JSON did not pass success test. A server-side error has most likely occurred', response);
|
571
|
+
}
|
572
|
+
else if(status == 'error') {
|
573
|
+
if(xhr !== undefined) {
|
574
|
+
module.debug('XHR produced a server error', status, httpMessage);
|
575
|
+
// make sure we have an error to display to console
|
576
|
+
if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {
|
577
|
+
module.error(error.statusMessage + httpMessage, ajaxSettings.url);
|
578
|
+
}
|
579
|
+
settings.onError.call(context, errorMessage, $module, xhr);
|
580
|
+
}
|
581
|
+
}
|
582
|
+
|
583
|
+
if(settings.errorDuration && status !== 'aborted') {
|
584
|
+
module.debug('Adding error state');
|
585
|
+
module.set.error();
|
586
|
+
if( module.should.removeError() ) {
|
587
|
+
setTimeout(module.remove.error, settings.errorDuration);
|
588
|
+
}
|
589
|
+
}
|
590
|
+
module.debug('API Request failed', errorMessage, xhr);
|
591
|
+
settings.onFailure.call(context, response, $module, xhr);
|
592
|
+
}
|
593
|
+
}
|
594
|
+
},
|
595
|
+
|
596
|
+
create: {
|
597
|
+
|
598
|
+
request: function() {
|
599
|
+
// api request promise
|
600
|
+
return $.Deferred()
|
601
|
+
.always(module.event.request.complete)
|
602
|
+
.done(module.event.request.done)
|
603
|
+
.fail(module.event.request.fail)
|
604
|
+
;
|
605
|
+
},
|
606
|
+
|
607
|
+
mockedXHR: function () {
|
608
|
+
var
|
609
|
+
// xhr does not simulate these properties of xhr but must return them
|
610
|
+
textStatus = false,
|
611
|
+
status = false,
|
612
|
+
httpMessage = false,
|
613
|
+
responder = settings.mockResponse || settings.response,
|
614
|
+
asyncResponder = settings.mockResponseAsync || settings.responseAsync,
|
615
|
+
asyncCallback,
|
616
|
+
response,
|
617
|
+
mockedXHR
|
618
|
+
;
|
619
|
+
|
620
|
+
mockedXHR = $.Deferred()
|
621
|
+
.always(module.event.xhr.complete)
|
622
|
+
.done(module.event.xhr.done)
|
623
|
+
.fail(module.event.xhr.fail)
|
624
|
+
;
|
625
|
+
|
626
|
+
if(responder) {
|
627
|
+
if( $.isFunction(responder) ) {
|
628
|
+
module.debug('Using specified synchronous callback', responder);
|
629
|
+
response = responder.call(context, requestSettings);
|
630
|
+
}
|
631
|
+
else {
|
632
|
+
module.debug('Using settings specified response', responder);
|
633
|
+
response = responder;
|
634
|
+
}
|
635
|
+
// simulating response
|
636
|
+
mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);
|
637
|
+
}
|
638
|
+
else if( $.isFunction(asyncResponder) ) {
|
639
|
+
asyncCallback = function(response) {
|
640
|
+
module.debug('Async callback returned response', response);
|
641
|
+
|
642
|
+
if(response) {
|
643
|
+
mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);
|
644
|
+
}
|
645
|
+
else {
|
646
|
+
mockedXHR.rejectWith(context, [{ responseText: response }, status, httpMessage]);
|
647
|
+
}
|
648
|
+
};
|
649
|
+
module.debug('Using specified async response callback', asyncResponder);
|
650
|
+
asyncResponder.call(context, requestSettings, asyncCallback);
|
651
|
+
}
|
652
|
+
return mockedXHR;
|
653
|
+
},
|
654
|
+
|
655
|
+
xhr: function() {
|
656
|
+
var
|
657
|
+
xhr
|
658
|
+
;
|
659
|
+
// ajax request promise
|
660
|
+
xhr = $.ajax(ajaxSettings)
|
661
|
+
.always(module.event.xhr.always)
|
662
|
+
.done(module.event.xhr.done)
|
663
|
+
.fail(module.event.xhr.fail)
|
664
|
+
;
|
665
|
+
module.verbose('Created server request', xhr, ajaxSettings);
|
666
|
+
return xhr;
|
667
|
+
}
|
668
|
+
},
|
669
|
+
|
670
|
+
set: {
|
671
|
+
error: function() {
|
672
|
+
module.verbose('Adding error state to element', $context);
|
673
|
+
$context.addClass(className.error);
|
674
|
+
},
|
675
|
+
loading: function() {
|
676
|
+
module.verbose('Adding loading state to element', $context);
|
677
|
+
$context.addClass(className.loading);
|
678
|
+
requestStartTime = new Date().getTime();
|
679
|
+
}
|
680
|
+
},
|
681
|
+
|
682
|
+
remove: {
|
683
|
+
error: function() {
|
684
|
+
module.verbose('Removing error state from element', $context);
|
685
|
+
$context.removeClass(className.error);
|
686
|
+
},
|
687
|
+
loading: function() {
|
688
|
+
module.verbose('Removing loading state from element', $context);
|
689
|
+
$context.removeClass(className.loading);
|
690
|
+
}
|
691
|
+
},
|
692
|
+
|
693
|
+
get: {
|
694
|
+
responseFromXHR: function(xhr) {
|
695
|
+
return $.isPlainObject(xhr)
|
696
|
+
? (module.is.expectingJSON())
|
697
|
+
? module.decode.json(xhr.responseText)
|
698
|
+
: xhr.responseText
|
699
|
+
: false
|
700
|
+
;
|
701
|
+
},
|
702
|
+
errorFromRequest: function(response, status, httpMessage) {
|
703
|
+
return ($.isPlainObject(response) && response.error !== undefined)
|
704
|
+
? response.error // use json error message
|
705
|
+
: (settings.error[status] !== undefined) // use server error message
|
706
|
+
? settings.error[status]
|
707
|
+
: httpMessage
|
708
|
+
;
|
709
|
+
},
|
710
|
+
request: function() {
|
711
|
+
return module.request || false;
|
712
|
+
},
|
713
|
+
xhr: function() {
|
714
|
+
return module.xhr || false;
|
715
|
+
},
|
716
|
+
settings: function() {
|
717
|
+
var
|
718
|
+
runSettings
|
719
|
+
;
|
720
|
+
runSettings = settings.beforeSend.call(context, settings);
|
721
|
+
if(runSettings) {
|
722
|
+
if(runSettings.success !== undefined) {
|
723
|
+
module.debug('Legacy success callback detected', runSettings);
|
724
|
+
module.error(error.legacyParameters, runSettings.success);
|
725
|
+
runSettings.onSuccess = runSettings.success;
|
726
|
+
}
|
727
|
+
if(runSettings.failure !== undefined) {
|
728
|
+
module.debug('Legacy failure callback detected', runSettings);
|
729
|
+
module.error(error.legacyParameters, runSettings.failure);
|
730
|
+
runSettings.onFailure = runSettings.failure;
|
731
|
+
}
|
732
|
+
if(runSettings.complete !== undefined) {
|
733
|
+
module.debug('Legacy complete callback detected', runSettings);
|
734
|
+
module.error(error.legacyParameters, runSettings.complete);
|
735
|
+
runSettings.onComplete = runSettings.complete;
|
736
|
+
}
|
737
|
+
}
|
738
|
+
if(runSettings === undefined) {
|
739
|
+
module.error(error.noReturnedValue);
|
740
|
+
}
|
741
|
+
if(runSettings === false) {
|
742
|
+
return runSettings;
|
743
|
+
}
|
744
|
+
return (runSettings !== undefined)
|
745
|
+
? $.extend(true, {}, runSettings)
|
746
|
+
: $.extend(true, {}, settings)
|
747
|
+
;
|
748
|
+
},
|
749
|
+
urlEncodedValue: function(value) {
|
750
|
+
var
|
751
|
+
decodedValue = window.decodeURIComponent(value),
|
752
|
+
encodedValue = window.encodeURIComponent(value),
|
753
|
+
alreadyEncoded = (decodedValue !== value)
|
754
|
+
;
|
755
|
+
if(alreadyEncoded) {
|
756
|
+
module.debug('URL value is already encoded, avoiding double encoding', value);
|
757
|
+
return value;
|
758
|
+
}
|
759
|
+
module.verbose('Encoding value using encodeURIComponent', value, encodedValue);
|
760
|
+
return encodedValue;
|
761
|
+
},
|
762
|
+
defaultData: function() {
|
763
|
+
var
|
764
|
+
data = {}
|
765
|
+
;
|
766
|
+
if( !$.isWindow(element) ) {
|
767
|
+
if( module.is.input() ) {
|
768
|
+
data.value = $module.val();
|
769
|
+
}
|
770
|
+
else if( module.is.form() ) {
|
771
|
+
|
772
|
+
}
|
773
|
+
else {
|
774
|
+
data.text = $module.text();
|
775
|
+
}
|
776
|
+
}
|
777
|
+
return data;
|
778
|
+
},
|
779
|
+
event: function() {
|
780
|
+
if( $.isWindow(element) || settings.on == 'now' ) {
|
781
|
+
module.debug('API called without element, no events attached');
|
782
|
+
return false;
|
783
|
+
}
|
784
|
+
else if(settings.on == 'auto') {
|
785
|
+
if( $module.is('input') ) {
|
786
|
+
return (element.oninput !== undefined)
|
787
|
+
? 'input'
|
788
|
+
: (element.onpropertychange !== undefined)
|
789
|
+
? 'propertychange'
|
790
|
+
: 'keyup'
|
791
|
+
;
|
792
|
+
}
|
793
|
+
else if( $module.is('form') ) {
|
794
|
+
return 'submit';
|
795
|
+
}
|
796
|
+
else {
|
797
|
+
return 'click';
|
798
|
+
}
|
799
|
+
}
|
800
|
+
else {
|
801
|
+
return settings.on;
|
802
|
+
}
|
803
|
+
},
|
804
|
+
templatedURL: function(action) {
|
805
|
+
action = action || $module.data(metadata.action) || settings.action || false;
|
806
|
+
url = $module.data(metadata.url) || settings.url || false;
|
807
|
+
if(url) {
|
808
|
+
module.debug('Using specified url', url);
|
809
|
+
return url;
|
810
|
+
}
|
811
|
+
if(action) {
|
812
|
+
module.debug('Looking up url for action', action, settings.api);
|
813
|
+
if(settings.api[action] === undefined && !module.is.mocked()) {
|
814
|
+
module.error(error.missingAction, settings.action, settings.api);
|
815
|
+
return;
|
816
|
+
}
|
817
|
+
url = settings.api[action];
|
818
|
+
}
|
819
|
+
else if( module.is.form() ) {
|
820
|
+
url = $module.attr('action') || $context.attr('action') || false;
|
821
|
+
module.debug('No url or action specified, defaulting to form action', url);
|
822
|
+
}
|
823
|
+
return url;
|
824
|
+
}
|
825
|
+
},
|
826
|
+
|
827
|
+
abort: function() {
|
828
|
+
var
|
829
|
+
xhr = module.get.xhr()
|
830
|
+
;
|
831
|
+
if( xhr && xhr.state() !== 'resolved') {
|
832
|
+
module.debug('Cancelling API request');
|
833
|
+
xhr.abort();
|
834
|
+
}
|
835
|
+
},
|
836
|
+
|
837
|
+
// reset state
|
838
|
+
reset: function() {
|
839
|
+
module.remove.error();
|
840
|
+
module.remove.loading();
|
841
|
+
},
|
842
|
+
|
843
|
+
setting: function(name, value) {
|
844
|
+
module.debug('Changing setting', name, value);
|
845
|
+
if( $.isPlainObject(name) ) {
|
846
|
+
$.extend(true, settings, name);
|
847
|
+
}
|
848
|
+
else if(value !== undefined) {
|
849
|
+
if($.isPlainObject(settings[name])) {
|
850
|
+
$.extend(true, settings[name], value);
|
851
|
+
}
|
852
|
+
else {
|
853
|
+
settings[name] = value;
|
854
|
+
}
|
855
|
+
}
|
856
|
+
else {
|
857
|
+
return settings[name];
|
858
|
+
}
|
859
|
+
},
|
860
|
+
internal: function(name, value) {
|
861
|
+
if( $.isPlainObject(name) ) {
|
862
|
+
$.extend(true, module, name);
|
863
|
+
}
|
864
|
+
else if(value !== undefined) {
|
865
|
+
module[name] = value;
|
866
|
+
}
|
867
|
+
else {
|
868
|
+
return module[name];
|
869
|
+
}
|
870
|
+
},
|
871
|
+
debug: function() {
|
872
|
+
if(!settings.silent && settings.debug) {
|
873
|
+
if(settings.performance) {
|
874
|
+
module.performance.log(arguments);
|
875
|
+
}
|
876
|
+
else {
|
877
|
+
module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
878
|
+
module.debug.apply(console, arguments);
|
879
|
+
}
|
880
|
+
}
|
881
|
+
},
|
882
|
+
verbose: function() {
|
883
|
+
if(!settings.silent && settings.verbose && settings.debug) {
|
884
|
+
if(settings.performance) {
|
885
|
+
module.performance.log(arguments);
|
886
|
+
}
|
887
|
+
else {
|
888
|
+
module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
|
889
|
+
module.verbose.apply(console, arguments);
|
890
|
+
}
|
891
|
+
}
|
892
|
+
},
|
893
|
+
error: function() {
|
894
|
+
if(!settings.silent) {
|
895
|
+
module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
|
896
|
+
module.error.apply(console, arguments);
|
897
|
+
}
|
898
|
+
},
|
899
|
+
performance: {
|
900
|
+
log: function(message) {
|
901
|
+
var
|
902
|
+
currentTime,
|
903
|
+
executionTime,
|
904
|
+
previousTime
|
905
|
+
;
|
906
|
+
if(settings.performance) {
|
907
|
+
currentTime = new Date().getTime();
|
908
|
+
previousTime = time || currentTime;
|
909
|
+
executionTime = currentTime - previousTime;
|
910
|
+
time = currentTime;
|
911
|
+
performance.push({
|
912
|
+
'Name' : message[0],
|
913
|
+
'Arguments' : [].slice.call(message, 1) || '',
|
914
|
+
//'Element' : element,
|
915
|
+
'Execution Time' : executionTime
|
916
|
+
});
|
917
|
+
}
|
918
|
+
clearTimeout(module.performance.timer);
|
919
|
+
module.performance.timer = setTimeout(module.performance.display, 500);
|
920
|
+
},
|
921
|
+
display: function() {
|
922
|
+
var
|
923
|
+
title = settings.name + ':',
|
924
|
+
totalTime = 0
|
925
|
+
;
|
926
|
+
time = false;
|
927
|
+
clearTimeout(module.performance.timer);
|
928
|
+
$.each(performance, function(index, data) {
|
929
|
+
totalTime += data['Execution Time'];
|
930
|
+
});
|
931
|
+
title += ' ' + totalTime + 'ms';
|
932
|
+
if(moduleSelector) {
|
933
|
+
title += ' \'' + moduleSelector + '\'';
|
934
|
+
}
|
935
|
+
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
|
936
|
+
console.groupCollapsed(title);
|
937
|
+
if(console.table) {
|
938
|
+
console.table(performance);
|
939
|
+
}
|
940
|
+
else {
|
941
|
+
$.each(performance, function(index, data) {
|
942
|
+
console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
|
943
|
+
});
|
944
|
+
}
|
945
|
+
console.groupEnd();
|
946
|
+
}
|
947
|
+
performance = [];
|
948
|
+
}
|
949
|
+
},
|
950
|
+
invoke: function(query, passedArguments, context) {
|
951
|
+
var
|
952
|
+
object = instance,
|
953
|
+
maxDepth,
|
954
|
+
found,
|
955
|
+
response
|
956
|
+
;
|
957
|
+
passedArguments = passedArguments || queryArguments;
|
958
|
+
context = element || context;
|
959
|
+
if(typeof query == 'string' && object !== undefined) {
|
960
|
+
query = query.split(/[\. ]/);
|
961
|
+
maxDepth = query.length - 1;
|
962
|
+
$.each(query, function(depth, value) {
|
963
|
+
var camelCaseValue = (depth != maxDepth)
|
964
|
+
? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
|
965
|
+
: query
|
966
|
+
;
|
967
|
+
if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
|
968
|
+
object = object[camelCaseValue];
|
969
|
+
}
|
970
|
+
else if( object[camelCaseValue] !== undefined ) {
|
971
|
+
found = object[camelCaseValue];
|
972
|
+
return false;
|
973
|
+
}
|
974
|
+
else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
|
975
|
+
object = object[value];
|
976
|
+
}
|
977
|
+
else if( object[value] !== undefined ) {
|
978
|
+
found = object[value];
|
979
|
+
return false;
|
980
|
+
}
|
981
|
+
else {
|
982
|
+
module.error(error.method, query);
|
983
|
+
return false;
|
984
|
+
}
|
985
|
+
});
|
986
|
+
}
|
987
|
+
if ( $.isFunction( found ) ) {
|
988
|
+
response = found.apply(context, passedArguments);
|
989
|
+
}
|
990
|
+
else if(found !== undefined) {
|
991
|
+
response = found;
|
992
|
+
}
|
993
|
+
if($.isArray(returnedValue)) {
|
994
|
+
returnedValue.push(response);
|
995
|
+
}
|
996
|
+
else if(returnedValue !== undefined) {
|
997
|
+
returnedValue = [returnedValue, response];
|
998
|
+
}
|
999
|
+
else if(response !== undefined) {
|
1000
|
+
returnedValue = response;
|
1001
|
+
}
|
1002
|
+
return found;
|
1003
|
+
}
|
1004
|
+
};
|
1005
|
+
|
1006
|
+
if(methodInvoked) {
|
1007
|
+
if(instance === undefined) {
|
1008
|
+
module.initialize();
|
1009
|
+
}
|
1010
|
+
module.invoke(query);
|
1011
|
+
}
|
1012
|
+
else {
|
1013
|
+
if(instance !== undefined) {
|
1014
|
+
instance.invoke('destroy');
|
1015
|
+
}
|
1016
|
+
module.initialize();
|
1017
|
+
}
|
1018
|
+
})
|
1019
|
+
;
|
1020
|
+
|
1021
|
+
return (returnedValue !== undefined)
|
1022
|
+
? returnedValue
|
1023
|
+
: this
|
1024
|
+
;
|
1025
|
+
};
|
1026
|
+
|
1027
|
+
$.api.settings = {
|
1028
|
+
|
1029
|
+
name : 'API',
|
1030
|
+
namespace : 'api',
|
1031
|
+
|
1032
|
+
debug : false,
|
1033
|
+
verbose : false,
|
1034
|
+
performance : true,
|
1035
|
+
|
1036
|
+
// object containing all templates endpoints
|
1037
|
+
api : {},
|
1038
|
+
|
1039
|
+
// whether to cache responses
|
1040
|
+
cache : true,
|
1041
|
+
|
1042
|
+
// whether new requests should abort previous requests
|
1043
|
+
interruptRequests : true,
|
1044
|
+
|
1045
|
+
// event binding
|
1046
|
+
on : 'auto',
|
1047
|
+
|
1048
|
+
// context for applying state classes
|
1049
|
+
stateContext : false,
|
1050
|
+
|
1051
|
+
// duration for loading state
|
1052
|
+
loadingDuration : 0,
|
1053
|
+
|
1054
|
+
// whether to hide errors after a period of time
|
1055
|
+
hideError : 'auto',
|
1056
|
+
|
1057
|
+
// duration for error state
|
1058
|
+
errorDuration : 2000,
|
1059
|
+
|
1060
|
+
// whether parameters should be encoded with encodeURIComponent
|
1061
|
+
encodeParameters : true,
|
1062
|
+
|
1063
|
+
// API action to use
|
1064
|
+
action : false,
|
1065
|
+
|
1066
|
+
// templated URL to use
|
1067
|
+
url : false,
|
1068
|
+
|
1069
|
+
// base URL to apply to all endpoints
|
1070
|
+
base : '',
|
1071
|
+
|
1072
|
+
// data that will
|
1073
|
+
urlData : {},
|
1074
|
+
|
1075
|
+
// whether to add default data to url data
|
1076
|
+
defaultData : true,
|
1077
|
+
|
1078
|
+
// whether to serialize closest form
|
1079
|
+
serializeForm : false,
|
1080
|
+
|
1081
|
+
// how long to wait before request should occur
|
1082
|
+
throttle : 0,
|
1083
|
+
|
1084
|
+
// whether to throttle first request or only repeated
|
1085
|
+
throttleFirstRequest : true,
|
1086
|
+
|
1087
|
+
// standard ajax settings
|
1088
|
+
method : 'get',
|
1089
|
+
data : {},
|
1090
|
+
dataType : 'json',
|
1091
|
+
|
1092
|
+
// mock response
|
1093
|
+
mockResponse : false,
|
1094
|
+
mockResponseAsync : false,
|
1095
|
+
|
1096
|
+
// aliases for mock
|
1097
|
+
response : false,
|
1098
|
+
responseAsync : false,
|
1099
|
+
|
1100
|
+
// callbacks before request
|
1101
|
+
beforeSend : function(settings) { return settings; },
|
1102
|
+
beforeXHR : function(xhr) {},
|
1103
|
+
onRequest : function(promise, xhr) {},
|
1104
|
+
|
1105
|
+
// after request
|
1106
|
+
onResponse : false, // function(response) { },
|
1107
|
+
|
1108
|
+
// response was successful, if JSON passed validation
|
1109
|
+
onSuccess : function(response, $module) {},
|
1110
|
+
|
1111
|
+
// request finished without aborting
|
1112
|
+
onComplete : function(response, $module) {},
|
1113
|
+
|
1114
|
+
// failed JSON success test
|
1115
|
+
onFailure : function(response, $module) {},
|
1116
|
+
|
1117
|
+
// server error
|
1118
|
+
onError : function(errorMessage, $module) {},
|
1119
|
+
|
1120
|
+
// request aborted
|
1121
|
+
onAbort : function(errorMessage, $module) {},
|
1122
|
+
|
1123
|
+
successTest : false,
|
1124
|
+
|
1125
|
+
// errors
|
1126
|
+
error : {
|
1127
|
+
beforeSend : 'The before send function has aborted the request',
|
1128
|
+
error : 'There was an error with your request',
|
1129
|
+
exitConditions : 'API Request Aborted. Exit conditions met',
|
1130
|
+
JSONParse : 'JSON could not be parsed during error handling',
|
1131
|
+
legacyParameters : 'You are using legacy API success callback names',
|
1132
|
+
method : 'The method you called is not defined',
|
1133
|
+
missingAction : 'API action used but no url was defined',
|
1134
|
+
missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
|
1135
|
+
missingURL : 'No URL specified for api event',
|
1136
|
+
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
|
1137
|
+
noStorage : 'Caching responses locally requires session storage',
|
1138
|
+
parseError : 'There was an error parsing your request',
|
1139
|
+
requiredParameter : 'Missing a required URL parameter: ',
|
1140
|
+
statusMessage : 'Server gave an error: ',
|
1141
|
+
timeout : 'Your request timed out'
|
1142
|
+
},
|
1143
|
+
|
1144
|
+
regExp : {
|
1145
|
+
required : /\{\$*[A-z0-9]+\}/g,
|
1146
|
+
optional : /\{\/\$*[A-z0-9]+\}/g,
|
1147
|
+
},
|
1148
|
+
|
1149
|
+
className: {
|
1150
|
+
loading : 'loading',
|
1151
|
+
error : 'error'
|
1152
|
+
},
|
1153
|
+
|
1154
|
+
selector: {
|
1155
|
+
disabled : '.disabled',
|
1156
|
+
form : 'form'
|
1157
|
+
},
|
1158
|
+
|
1159
|
+
metadata: {
|
1160
|
+
action : 'action',
|
1161
|
+
url : 'url'
|
1162
|
+
}
|
1163
|
+
};
|
1164
|
+
|
1165
|
+
|
1166
|
+
|
1167
|
+
})( jQuery, window, document );
|