houston-core 0.5.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +46 -0
- data/.gitignore +23 -0
- data/.gitmodules +0 -0
- data/Gemfile +24 -0
- data/Gemfile.lock +354 -0
- data/README.md +133 -0
- data/Rakefile +8 -0
- data/app/adapters/houston/adapters.rb +51 -0
- data/app/adapters/houston/adapters/ci_server.rb +5 -0
- data/app/adapters/houston/adapters/ci_server/errors.rb +16 -0
- data/app/adapters/houston/adapters/ci_server/jenkins_adapter.rb +21 -0
- data/app/adapters/houston/adapters/ci_server/jenkins_adapter/job.rb +245 -0
- data/app/adapters/houston/adapters/ci_server/none_adapter.rb +21 -0
- data/app/adapters/houston/adapters/ci_server/none_adapter/job.rb +25 -0
- data/app/adapters/houston/adapters/deployment/engineyard.rb +107 -0
- data/app/adapters/houston/adapters/deployment/engineyard/config.rb +18 -0
- data/app/adapters/houston/adapters/error_tracker.rb +5 -0
- data/app/adapters/houston/adapters/error_tracker/errbit_adapter.rb +69 -0
- data/app/adapters/houston/adapters/error_tracker/errbit_adapter/app.rb +48 -0
- data/app/adapters/houston/adapters/error_tracker/errbit_adapter/connection.rb +153 -0
- data/app/adapters/houston/adapters/error_tracker/errbit_adapter/notice.rb +26 -0
- data/app/adapters/houston/adapters/error_tracker/errbit_adapter/problem.rb +98 -0
- data/app/adapters/houston/adapters/error_tracker/errors.rb +0 -0
- data/app/adapters/houston/adapters/error_tracker/none_adapter.rb +31 -0
- data/app/adapters/houston/adapters/error_tracker/null_app.rb +40 -0
- data/app/adapters/houston/adapters/ticket_tracker.rb +5 -0
- data/app/adapters/houston/adapters/ticket_tracker/errors.rb +23 -0
- data/app/adapters/houston/adapters/ticket_tracker/github_adapter.rb +27 -0
- data/app/adapters/houston/adapters/ticket_tracker/github_adapter/connection.rb +167 -0
- data/app/adapters/houston/adapters/ticket_tracker/github_adapter/issue.rb +99 -0
- data/app/adapters/houston/adapters/ticket_tracker/houston_adapter.rb +23 -0
- data/app/adapters/houston/adapters/ticket_tracker/houston_adapter/connection.rb +48 -0
- data/app/adapters/houston/adapters/ticket_tracker/houston_adapter/ticket.rb +65 -0
- data/app/adapters/houston/adapters/ticket_tracker/none_adapter.rb +21 -0
- data/app/adapters/houston/adapters/ticket_tracker/null_connection.rb +46 -0
- data/app/adapters/houston/adapters/ticket_tracker/null_ticket.rb +71 -0
- data/app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter.rb +43 -0
- data/app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/connection.rb +224 -0
- data/app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/milestone.rb +42 -0
- data/app/adapters/houston/adapters/ticket_tracker/unfuddle_adapter/ticket.rb +240 -0
- data/app/adapters/houston/adapters/version_control.rb +5 -0
- data/app/adapters/houston/adapters/version_control/commit.rb +29 -0
- data/app/adapters/houston/adapters/version_control/errors.rb +37 -0
- data/app/adapters/houston/adapters/version_control/git_adapter.rb +96 -0
- data/app/adapters/houston/adapters/version_control/git_adapter/diff_changes.rb +49 -0
- data/app/adapters/houston/adapters/version_control/git_adapter/github_repo.rb +65 -0
- data/app/adapters/houston/adapters/version_control/git_adapter/remote_repo.rb +104 -0
- data/app/adapters/houston/adapters/version_control/git_adapter/repo.rb +247 -0
- data/app/adapters/houston/adapters/version_control/none_adapter.rb +21 -0
- data/app/adapters/houston/adapters/version_control/null_commit.rb +21 -0
- data/app/adapters/houston/adapters/version_control/null_repo.rb +65 -0
- data/app/assets/font/octicons.eot +0 -0
- data/app/assets/font/octicons.svg +198 -0
- data/app/assets/font/octicons.ttf +0 -0
- data/app/assets/font/octicons.woff +0 -0
- data/app/assets/font/roboto-black-webfont.eot +0 -0
- data/app/assets/font/roboto-black-webfont.svg +675 -0
- data/app/assets/font/roboto-black-webfont.ttf +0 -0
- data/app/assets/font/roboto-black-webfont.woff +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.svg +677 -0
- data/app/assets/font/roboto-blackitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-blackitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-bold-webfont.eot +0 -0
- data/app/assets/font/roboto-bold-webfont.svg +675 -0
- data/app/assets/font/roboto-bold-webfont.ttf +0 -0
- data/app/assets/font/roboto-bold-webfont.woff +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.eot +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.svg +677 -0
- data/app/assets/font/roboto-bolditalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-bolditalic-webfont.woff +0 -0
- data/app/assets/font/roboto-italic-webfont.eot +0 -0
- data/app/assets/font/roboto-italic-webfont.svg +668 -0
- data/app/assets/font/roboto-italic-webfont.ttf +0 -0
- data/app/assets/font/roboto-italic-webfont.woff +0 -0
- data/app/assets/font/roboto-light-webfont.eot +0 -0
- data/app/assets/font/roboto-light-webfont.svg +666 -0
- data/app/assets/font/roboto-light-webfont.ttf +0 -0
- data/app/assets/font/roboto-light-webfont.woff +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.svg +668 -0
- data/app/assets/font/roboto-lightitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-lightitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-medium-webfont.eot +0 -0
- data/app/assets/font/roboto-medium-webfont.svg +675 -0
- data/app/assets/font/roboto-medium-webfont.ttf +0 -0
- data/app/assets/font/roboto-medium-webfont.woff +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.svg +677 -0
- data/app/assets/font/roboto-mediumitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-mediumitalic-webfont.woff +0 -0
- data/app/assets/font/roboto-regular-webfont.eot +0 -0
- data/app/assets/font/roboto-regular-webfont.svg +666 -0
- data/app/assets/font/roboto-regular-webfont.ttf +0 -0
- data/app/assets/font/roboto-regular-webfont.woff +0 -0
- data/app/assets/font/roboto-thin-webfont.eot +0 -0
- data/app/assets/font/roboto-thin-webfont.svg +666 -0
- data/app/assets/font/roboto-thin-webfont.ttf +0 -0
- data/app/assets/font/roboto-thin-webfont.woff +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.eot +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.svg +668 -0
- data/app/assets/font/roboto-thinitalic-webfont.ttf +0 -0
- data/app/assets/font/roboto-thinitalic-webfont.woff +0 -0
- data/app/assets/images/.keep +0 -0
- data/app/assets/images/bug-fixed-128.png +0 -0
- data/app/assets/images/bug-fixed-32.png +0 -0
- data/app/assets/images/bug-fixed-48.png +0 -0
- data/app/assets/images/bug-new-128.png +0 -0
- data/app/assets/images/bug-new-32.png +0 -0
- data/app/assets/images/bug-new-48.png +0 -0
- data/app/assets/images/bug-open-32.png +0 -0
- data/app/assets/images/bug-zero-128.png +0 -0
- data/app/assets/images/bug-zero-48.png +0 -0
- data/app/assets/javascripts/app/boot.coffee +22 -0
- data/app/assets/javascripts/app/emoji.coffee.erb +2 -0
- data/app/assets/javascripts/app/infinite_scroll.coffee +32 -0
- data/app/assets/javascripts/app/models/commit.coffee +9 -0
- data/app/assets/javascripts/app/models/release.coffee +9 -0
- data/app/assets/javascripts/app/models/task.coffee +5 -0
- data/app/assets/javascripts/app/models/tester.coffee +8 -0
- data/app/assets/javascripts/app/models/testing_note.coffee +18 -0
- data/app/assets/javascripts/app/models/ticket.coffee +165 -0
- data/app/assets/javascripts/app/models/user.coffee +3 -0
- data/app/assets/javascripts/app/mousetrap-bind-scoped.js +37 -0
- data/app/assets/javascripts/app/releases.coffee +55 -0
- data/app/assets/javascripts/app/stacked_area_graph.coffee +113 -0
- data/app/assets/javascripts/app/stacked_bar_graph.coffee +108 -0
- data/app/assets/javascripts/app/table_row_expander.coffee +52 -0
- data/app/assets/javascripts/app/ticket_tracker_refresh.coffee +73 -0
- data/app/assets/javascripts/app/views/_show_sprint_view.coffee +84 -0
- data/app/assets/javascripts/app/views/_tickets_view.coffee +62 -0
- data/app/assets/javascripts/app/views/all_tickets_view.coffee +29 -0
- data/app/assets/javascripts/app/views/commit_view.coffee +13 -0
- data/app/assets/javascripts/app/views/edit_sprint_view.coffee +327 -0
- data/app/assets/javascripts/app/views/edit_ticket_view.coffee +67 -0
- data/app/assets/javascripts/app/views/find_or_create_ticket_view.coffee +75 -0
- data/app/assets/javascripts/app/views/keyboard_shortcuts_modal.coffee +42 -0
- data/app/assets/javascripts/app/views/new_ticket_modal.coffee +24 -0
- data/app/assets/javascripts/app/views/new_ticket_view.coffee +207 -0
- data/app/assets/javascripts/app/views/problems_view.coffee +114 -0
- data/app/assets/javascripts/app/views/reports_view.coffee +51 -0
- data/app/assets/javascripts/app/views/testing_note_view.coffee +85 -0
- data/app/assets/javascripts/app/views/testing_report_view.coffee +29 -0
- data/app/assets/javascripts/app/views/testing_ticket_view.coffee +203 -0
- data/app/assets/javascripts/app/views/ticket_modal_view.coffee +77 -0
- data/app/assets/javascripts/application.js +18 -0
- data/app/assets/javascripts/core/app.coffee +169 -0
- data/app/assets/javascripts/core/burndown_chart.coffee +111 -0
- data/app/assets/javascripts/core/core_ext/number.coffee +48 -0
- data/app/assets/javascripts/core/errors.coffee +26 -0
- data/app/assets/javascripts/core/handlebars_helpers.coffee +164 -0
- data/app/assets/javascripts/core/helpers.coffee +18 -0
- data/app/assets/javascripts/core/jquery_extensions.coffee +176 -0
- data/app/assets/javascripts/dashboard.js +23 -0
- data/app/assets/javascripts/dashboard/refresher.coffee +120 -0
- data/app/assets/javascripts/vendor.js +26 -0
- data/app/assets/stylesheets/application.css +14 -0
- data/app/assets/stylesheets/application/ansi.scss +38 -0
- data/app/assets/stylesheets/application/commit.scss +6 -0
- data/app/assets/stylesheets/application/emoji.scss +5 -0
- data/app/assets/stylesheets/application/exceptions.scss +64 -0
- data/app/assets/stylesheets/application/find_or_create_ticket.scss +12 -0
- data/app/assets/stylesheets/application/follow_up.scss +44 -0
- data/app/assets/stylesheets/application/forms.scss +46 -0
- data/app/assets/stylesheets/application/freight_train.css.scss +46 -0
- data/app/assets/stylesheets/application/full_screen.scss +8 -0
- data/app/assets/stylesheets/application/infinite_scroll.scss +17 -0
- data/app/assets/stylesheets/application/keyboard_shortcuts.scss +31 -0
- data/app/assets/stylesheets/application/markdown.scss +27 -0
- data/app/assets/stylesheets/application/mobile.scss +3 -0
- data/app/assets/stylesheets/application/modals.scss +3 -0
- data/app/assets/stylesheets/application/navigation.scss +212 -0
- data/app/assets/stylesheets/application/new_ticket_view.scss +89 -0
- data/app/assets/stylesheets/application/omnibar.scss +55 -0
- data/app/assets/stylesheets/application/project_banner_buttons.scss +70 -0
- data/app/assets/stylesheets/application/project_tiles.scss +26 -0
- data/app/assets/stylesheets/application/projects.css.scss +96 -0
- data/app/assets/stylesheets/application/pull_requests.scss +68 -0
- data/app/assets/stylesheets/application/queue.scss +11 -0
- data/app/assets/stylesheets/application/release_form.scss +67 -0
- data/app/assets/stylesheets/application/releases.scss +164 -0
- data/app/assets/stylesheets/application/sortable_table.scss +26 -0
- data/app/assets/stylesheets/application/sprint.scss +83 -0
- data/app/assets/stylesheets/application/tables.scss +74 -0
- data/app/assets/stylesheets/application/test_run.scss +145 -0
- data/app/assets/stylesheets/application/testing_report.scss +279 -0
- data/app/assets/stylesheets/application/ticket.scss +156 -0
- data/app/assets/stylesheets/application/ticket_modal.scss +173 -0
- data/app/assets/stylesheets/application/tickets.scss +36 -0
- data/app/assets/stylesheets/application/timeline.scss +206 -0
- data/app/assets/stylesheets/application/tips.scss +5 -0
- data/app/assets/stylesheets/application/typeahead.scss +29 -0
- data/app/assets/stylesheets/application/uploading.scss +101 -0
- data/app/assets/stylesheets/application/user_wall.scss +4 -0
- data/app/assets/stylesheets/application/users.scss +22 -0
- data/app/assets/stylesheets/application/welcome.scss +48 -0
- data/app/assets/stylesheets/core/alerts.scss +14 -0
- data/app/assets/stylesheets/core/avatars.scss +22 -0
- data/app/assets/stylesheets/core/burndown_chart.scss +92 -0
- data/app/assets/stylesheets/core/colors.scss.erb +106 -0
- data/app/assets/stylesheets/core/misc.scss +165 -0
- data/app/assets/stylesheets/core/octicons-icons.scss +221 -0
- data/app/assets/stylesheets/core/octicons.scss.erb +9 -0
- data/app/assets/stylesheets/core/overrides.scss +48 -0
- data/app/assets/stylesheets/core/roboto.scss.erb +131 -0
- data/app/assets/stylesheets/core/scores.scss +123 -0
- data/app/assets/stylesheets/dashboard.css +14 -0
- data/app/assets/stylesheets/dashboard/dashboard.scss +110 -0
- data/app/assets/stylesheets/print.css.scss +22 -0
- data/app/assets/stylesheets/vendor.css +16 -0
- data/app/assets/templates/commit.hbs +9 -0
- data/app/assets/templates/keyboard_shortcuts.hbs +14 -0
- data/app/assets/templates/new_ticket/form.hbs +14 -0
- data/app/assets/templates/new_ticket/modal.hbs +9 -0
- data/app/assets/templates/new_ticket/suggestion.hbs +3 -0
- data/app/assets/templates/omnibar/commit.hbs +6 -0
- data/app/assets/templates/omnibar/modal.hbs +5 -0
- data/app/assets/templates/omnibar/project.hbs +5 -0
- data/app/assets/templates/omnibar/ticket.hbs +6 -0
- data/app/assets/templates/problems/index.hbs +3 -0
- data/app/assets/templates/problems/show.hbs +48 -0
- data/app/assets/templates/sprints/edit.hbs +50 -0
- data/app/assets/templates/sprints/show.hbs +1 -0
- data/app/assets/templates/sprints/task.hbs +17 -0
- data/app/assets/templates/sprints/typeahead.hbs +7 -0
- data/app/assets/templates/testing_notes/edit.hbs +20 -0
- data/app/assets/templates/testing_notes/new.hbs +27 -0
- data/app/assets/templates/testing_notes/show.hbs +11 -0
- data/app/assets/templates/testing_report/description.hbs +12 -0
- data/app/assets/templates/testing_report/ticket.hbs +21 -0
- data/app/assets/templates/testing_report/verdict.hbs +4 -0
- data/app/assets/templates/tickets/find_or_create.hbs +4 -0
- data/app/assets/templates/tickets/index.hbs +19 -0
- data/app/assets/templates/tickets/modal.hbs +5 -0
- data/app/assets/templates/tickets/show.hbs +62 -0
- data/app/assets/templates/tickets/typeahead.hbs +2 -0
- data/app/concerns/belongs_to_commit.rb +22 -0
- data/app/concerns/commit_synchronizer.rb +94 -0
- data/app/concerns/feature_state.rb +27 -0
- data/app/concerns/feature_support.rb +15 -0
- data/app/concerns/historical_weekly_stats.rb +15 -0
- data/app/concerns/milestone_synchronizer.rb +60 -0
- data/app/concerns/nosync.rb +21 -0
- data/app/concerns/project_adapter.rb +81 -0
- data/app/concerns/retirement.rb +28 -0
- data/app/concerns/ticket_synchronizer.rb +120 -0
- data/app/concerns/unique_add.rb +7 -0
- data/app/controllers/api/v1/sprint_tasks_controller.rb +97 -0
- data/app/controllers/api/v1/ticket_tasks_controller.rb +75 -0
- data/app/controllers/application_controller.rb +151 -0
- data/app/controllers/commits_controller.rb +33 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/controllers/deploys_controller.rb +43 -0
- data/app/controllers/home_controller.rb +9 -0
- data/app/controllers/hooks_controller.rb +31 -0
- data/app/controllers/jobs_controller.rb +13 -0
- data/app/controllers/oauth_consumers_controller.rb +68 -0
- data/app/controllers/omnibar_controller.rb +64 -0
- data/app/controllers/project_exceptions_controller.rb +36 -0
- data/app/controllers/project_hooks_controller.rb +30 -0
- data/app/controllers/project_options_controller.rb +27 -0
- data/app/controllers/project_pretickets_controller.rb +27 -0
- data/app/controllers/project_roles_controller.rb +22 -0
- data/app/controllers/project_tickets_controller.rb +153 -0
- data/app/controllers/project_tickets_sync_controller.rb +22 -0
- data/app/controllers/projects_controller.rb +97 -0
- data/app/controllers/releases_controller.rb +130 -0
- data/app/controllers/reports_controller.rb +215 -0
- data/app/controllers/sessions_controller.rb +8 -0
- data/app/controllers/settings_controller.rb +14 -0
- data/app/controllers/sprint_task_locks_controller.rb +47 -0
- data/app/controllers/sprints_controller.rb +99 -0
- data/app/controllers/tasks_controller.rb +40 -0
- data/app/controllers/test_runs_controller.rb +35 -0
- data/app/controllers/tester_bar_controller.rb +12 -0
- data/app/controllers/testing_notes_controller.rb +50 -0
- data/app/controllers/testing_report_controller.rb +38 -0
- data/app/controllers/tickets_controller.rb +48 -0
- data/app/controllers/uploads_controller.rb +56 -0
- data/app/controllers/user_credentials_controller.rb +24 -0
- data/app/controllers/user_options_controller.rb +19 -0
- data/app/controllers/users_controller.rb +115 -0
- data/app/controllers/welcome_controller.rb +28 -0
- data/app/helpers/ansi_helper.rb +46 -0
- data/app/helpers/application_helper.rb +97 -0
- data/app/helpers/avatar_helper.rb +32 -0
- data/app/helpers/backtrace_helper.rb +7 -0
- data/app/helpers/breadcrumbs_helper.rb +60 -0
- data/app/helpers/commit_helper.rb +60 -0
- data/app/helpers/demo_helper.rb +23 -0
- data/app/helpers/email_helper.rb +13 -0
- data/app/helpers/emoji_helper.rb +13 -0
- data/app/helpers/excel_helpers.rb +7 -0
- data/app/helpers/exposure_helper.rb +11 -0
- data/app/helpers/flash_message_helper.rb +22 -0
- data/app/helpers/maintenance_light_helper.rb +19 -0
- data/app/helpers/markdown_helper.rb +17 -0
- data/app/helpers/navigation_helper.rb +67 -0
- data/app/helpers/project_helper.rb +33 -0
- data/app/helpers/release_helper.rb +47 -0
- data/app/helpers/score_card_helper.rb +85 -0
- data/app/helpers/sprint_helper.rb +11 -0
- data/app/helpers/static_chart_helper.rb +7 -0
- data/app/helpers/test_run_helper.rb +36 -0
- data/app/helpers/ticket_helper.rb +70 -0
- data/app/helpers/timeline_helper.rb +39 -0
- data/app/helpers/url_helper.rb +75 -0
- data/app/helpers/user_helper.rb +15 -0
- data/app/helpers/version_helper.rb +9 -0
- data/app/interactors/push_gemfile_to_gemnasium.rb +88 -0
- data/app/interactors/test_run_comparer.rb +46 -0
- data/app/interactors/ticket_report.rb +66 -0
- data/app/jobs/sync_all_tickets_job.rb +48 -0
- data/app/jobs/sync_commits_job.rb +13 -0
- data/app/jobs/sync_project_tickets_job.rb +32 -0
- data/app/mailers/.gitkeep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/mailers/deploy_notification.rb +33 -0
- data/app/mailers/project_notification.rb +131 -0
- data/app/mailers/view_mailer.rb +117 -0
- data/app/models/.gitkeep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/ability.rb +53 -0
- data/app/models/activity_feed.rb +111 -0
- data/app/models/antecedent.rb +15 -0
- data/app/models/code_climate/coverage_report.rb +167 -0
- data/app/models/commit.rb +255 -0
- data/app/models/concerns/.keep +0 -0
- data/app/models/consumer_token.rb +13 -0
- data/app/models/deploy.rb +103 -0
- data/app/models/environment.rb +39 -0
- data/app/models/gemnasium/alert.rb +25 -0
- data/app/models/github/comment_event.rb +29 -0
- data/app/models/github/commit_comment_event.rb +7 -0
- data/app/models/github/commit_status_report.rb +73 -0
- data/app/models/github/diff_comment_event.rb +7 -0
- data/app/models/github/event.rb +20 -0
- data/app/models/github/issue_comment_event.rb +16 -0
- data/app/models/github/post_receive_event.rb +14 -0
- data/app/models/github/pull_request.rb +133 -0
- data/app/models/github/pull_request_event.rb +43 -0
- data/app/models/github/unauthorized.rb +4 -0
- data/app/models/github_token.rb +8 -0
- data/app/models/historical_head.rb +5 -0
- data/app/models/key_dependency.rb +45 -0
- data/app/models/maintenance_light.rb +12 -0
- data/app/models/measurement.rb +110 -0
- data/app/models/menu_item.rb +19 -0
- data/app/models/menu_item_divider.rb +11 -0
- data/app/models/milestone.rb +106 -0
- data/app/models/output_stream.rb +26 -0
- data/app/models/post_receive_payload.rb +30 -0
- data/app/models/project.rb +247 -0
- data/app/models/project_dependencies.rb +52 -0
- data/app/models/project_dependency.rb +108 -0
- data/app/models/project_menu_item.rb +12 -0
- data/app/models/release.rb +217 -0
- data/app/models/release_change.rb +54 -0
- data/app/models/role.rb +55 -0
- data/app/models/rubygems/gem.rb +76 -0
- data/app/models/run_tests_on_post_receive.rb +180 -0
- data/app/models/setting.rb +10 -0
- data/app/models/settings.rb +38 -0
- data/app/models/source_file_coverage.rb +10 -0
- data/app/models/sprint.rb +75 -0
- data/app/models/sprint_report.rb +56 -0
- data/app/models/sprint_task.rb +32 -0
- data/app/models/static_chart.rb +137 -0
- data/app/models/static_chart/area.rb +70 -0
- data/app/models/task.rb +217 -0
- data/app/models/test.rb +8 -0
- data/app/models/test_error.rb +8 -0
- data/app/models/test_result.rb +10 -0
- data/app/models/test_run.rb +366 -0
- data/app/models/test_run_statistics.rb +54 -0
- data/app/models/testing_note.rb +64 -0
- data/app/models/ticket.rb +368 -0
- data/app/models/ticket_antecedent.rb +39 -0
- data/app/models/ticket_comment.rb +21 -0
- data/app/models/ticket_committer.rb +11 -0
- data/app/models/ticket_tag.rb +25 -0
- data/app/models/user.rb +160 -0
- data/app/models/user_credentials.rb +48 -0
- data/app/models/value_statement.rb +9 -0
- data/app/presenters/commit_presenter.rb +52 -0
- data/app/presenters/full_ticket_presenter.rb +78 -0
- data/app/presenters/one_or_many.rb +22 -0
- data/app/presenters/problem_presenter.rb +49 -0
- data/app/presenters/release_presenter.rb +20 -0
- data/app/presenters/sprint_task_presenter.rb +49 -0
- data/app/presenters/task_presenter.rb +44 -0
- data/app/presenters/tasks_excel_presenter.rb +107 -0
- data/app/presenters/tester_presenter.rb +15 -0
- data/app/presenters/testing_note_presenter.rb +27 -0
- data/app/presenters/testing_report_ticket_presenter.rb +71 -0
- data/app/presenters/ticket_presenter.rb +36 -0
- data/app/views/activity/_events.html.erb +24 -0
- data/app/views/commits/show.html.erb +49 -0
- data/app/views/configuration_error/_invalid_repo.html.erb +7 -0
- data/app/views/configuration_error/_no_ticket_tracker.html.erb +7 -0
- data/app/views/configuration_error/_no_version_control.html.erb +7 -0
- data/app/views/deploys/show.html.erb +39 -0
- data/app/views/devise/_links.erb +25 -0
- data/app/views/devise/confirmations/new.html.erb +12 -0
- data/app/views/devise/invitations/edit.html.erb +26 -0
- data/app/views/devise/invitations/new.html.erb +12 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/invitation_instructions.html.erb +8 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.erb +28 -0
- data/app/views/devise/passwords/new.html.erb +19 -0
- data/app/views/devise/registrations/edit.html.erb +25 -0
- data/app/views/devise/registrations/new.html.erb +18 -0
- data/app/views/devise/sessions/new.html.erb +43 -0
- data/app/views/devise/unlocks/new.html.erb +12 -0
- data/app/views/home/index.html.erb +0 -0
- data/app/views/jobs/show.html.erb +82 -0
- data/app/views/layouts/_navigation.html.erb +96 -0
- data/app/views/layouts/_tester_bar.html.erb +6 -0
- data/app/views/layouts/application.html.erb +83 -0
- data/app/views/layouts/dashboard.html.erb +48 -0
- data/app/views/layouts/email.html.erb +217 -0
- data/app/views/layouts/minimal.html.erb +54 -0
- data/app/views/layouts/naked_dashboard.html.erb +46 -0
- data/app/views/oauth_consumers/error.html.erb +5 -0
- data/app/views/oauth_consumers/index.html.erb +29 -0
- data/app/views/oauth_consumers/show.html.erb +7 -0
- data/app/views/project_notification/ci_configuration_error.html.erb +15 -0
- data/app/views/project_notification/follow_up.html.erb +26 -0
- data/app/views/project_notification/new_release.html.erb +31 -0
- data/app/views/project_notification/test_run.html.erb +141 -0
- data/app/views/project_notification/testing_note.html.erb +9 -0
- data/app/views/project_pretickets/show.html.erb +49 -0
- data/app/views/project_tickets/_tickets.html.erb +37 -0
- data/app/views/project_tickets/bugs.html.erb +13 -0
- data/app/views/project_tickets/ideas.html.erb +13 -0
- data/app/views/project_tickets/index.html.erb +13 -0
- data/app/views/project_tickets/index.xls.erb +130 -0
- data/app/views/project_tickets/new.html.erb +18 -0
- data/app/views/project_tickets/no_ticket_tracker.html.erb +8 -0
- data/app/views/project_tickets/open.html.erb +13 -0
- data/app/views/project_tickets/open_bugs.html.erb +13 -0
- data/app/views/project_tickets/open_ideas.html.erb +13 -0
- data/app/views/project_tickets/show.html.erb +76 -0
- data/app/views/projects/_form.html.erb +174 -0
- data/app/views/projects/_header.html.erb +11 -0
- data/app/views/projects/_keyboard_shortcuts.html.erb +8 -0
- data/app/views/projects/_new_ticket.html.erb +8 -0
- data/app/views/projects/_ticket_tracker_refresh.html.erb +4 -0
- data/app/views/projects/edit.html.erb +3 -0
- data/app/views/projects/index.html.erb +157 -0
- data/app/views/projects/new.html.erb +7 -0
- data/app/views/releases/_antecedents.html.erb +12 -0
- data/app/views/releases/_changelog.html.erb +48 -0
- data/app/views/releases/_commits.html.erb +18 -0
- data/app/views/releases/_form.html.erb +126 -0
- data/app/views/releases/_new_release.html.erb +15 -0
- data/app/views/releases/_tickets.html.erb +12 -0
- data/app/views/releases/edit.html.erb +19 -0
- data/app/views/releases/index.html.erb +80 -0
- data/app/views/releases/new.html.erb +72 -0
- data/app/views/releases/show.html.erb +3 -0
- data/app/views/reports/index.html.erb +9 -0
- data/app/views/reports/sprint.html.erb +21 -0
- data/app/views/reports/velocity.html.erb +104 -0
- data/app/views/settings/show.html.erb +20 -0
- data/app/views/sprints/dashboard.html.erb +29 -0
- data/app/views/sprints/show.html.erb +39 -0
- data/app/views/test_runs/confirm_retry.html.erb +3 -0
- data/app/views/testing_report/_scripts.html.erb +12 -0
- data/app/views/testing_report/index.html.erb +31 -0
- data/app/views/testing_report/show.html.erb +29 -0
- data/app/views/tickets/new.html.erb +18 -0
- data/app/views/users/_form.html.erb +115 -0
- data/app/views/users/_header.html.erb +10 -0
- data/app/views/users/edit.html.erb +3 -0
- data/app/views/users/index.html.erb +80 -0
- data/app/views/users/new.html.erb +8 -0
- data/app/views/users/show.html.erb +13 -0
- data/app/views/welcome/_tdl.html.erb +31 -0
- data/app/views/welcome/index.html.erb +29 -0
- data/bin/bundle +3 -0
- data/bin/rails +4 -0
- data/bin/rake +4 -0
- data/config/application.rb +91 -0
- data/config/boot.rb +4 -0
- data/config/database.yml +21 -0
- data/config/environment.rb +5 -0
- data/config/environments/development.rb +48 -0
- data/config/environments/production.rb +86 -0
- data/config/environments/test.rb +45 -0
- data/config/initializers/action_view_field_error_proc.rb +30 -0
- data/config/initializers/add_navigation_renderers.rb +66 -0
- data/config/initializers/assets.rb +9 -0
- data/config/initializers/backtrace_silencers.rb +7 -0
- data/config/initializers/constants.rb +9 -0
- data/config/initializers/cookies_serializer.rb +3 -0
- data/config/initializers/devise.rb +287 -0
- data/config/initializers/filter_parameter_logging.rb +4 -0
- data/config/initializers/hard_coded_knowledge.rb +141 -0
- data/config/initializers/houston_async.rb +13 -0
- data/config/initializers/houston_benchmark.rb +11 -0
- data/config/initializers/houston_report_exception.rb +27 -0
- data/config/initializers/houston_scheduler.rb +23 -0
- data/config/initializers/houston_tdl.rb +104 -0
- data/config/initializers/houston_try.rb +24 -0
- data/config/initializers/inflections.rb +16 -0
- data/config/initializers/mime_types.rb +5 -0
- data/config/initializers/oauth_consumers.rb +18 -0
- data/config/initializers/profile_gc.rb +1 -0
- data/config/initializers/requirements.rb +4 -0
- data/config/initializers/run_tests_on_post_receive.rb +1 -0
- data/config/initializers/secret_token.rb +16 -0
- data/config/initializers/session_store.rb +3 -0
- data/config/initializers/sync_commits_on_post_receive.rb +8 -0
- data/config/initializers/unfuddle.rb +6 -0
- data/config/initializers/vestal_versions.rb +9 -0
- data/config/initializers/wrap_parameters.rb +14 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/devise_invitable.en.yml +10 -0
- data/config/locales/en.yml +23 -0
- data/config/routes.rb +279 -0
- data/db/fixtures/projects.yml +21 -0
- data/db/fixtures/roles.yml +9 -0
- data/db/fixtures/users.yml +36 -0
- data/db/migrate/20120324185914_create_projects.rb +12 -0
- data/db/migrate/20120324202224_create_environments.rb +11 -0
- data/db/migrate/20120324212848_create_releases.rb +12 -0
- data/db/migrate/20120324212946_create_changes.rb +11 -0
- data/db/migrate/20120324230038_create_commits.rb +13 -0
- data/db/migrate/20120406185643_add_initial_commit_to_environments.rb +5 -0
- data/db/migrate/20120408155047_add_kanban_fields_to_projects.rb +9 -0
- data/db/migrate/20120417175450_devise_create_users.rb +52 -0
- data/db/migrate/20120417175841_devise_invitable_add_to_users.rb +23 -0
- data/db/migrate/20120417190504_add_role_to_users.rb +5 -0
- data/db/migrate/20120417195313_create_tickets.rb +12 -0
- data/db/migrate/20120417195433_create_ticket_queues.rb +11 -0
- data/db/migrate/20120424212706_create_testing_notes.rb +14 -0
- data/db/migrate/20120501230243_add_unfuddle_id_to_tickets.rb +9 -0
- data/db/migrate/20120501231817_add_expires_at_to_testing_notes.rb +5 -0
- data/db/migrate/20120501231948_add_unfuddle_id_to_testing_notes.rb +5 -0
- data/db/migrate/20120504143615_link_tickets_and_releases.rb +19 -0
- data/db/migrate/20120525013703_add_health_fields_to_projects.rb +6 -0
- data/db/migrate/20120607124115_add_cached_queries_to_projects.rb +5 -0
- data/db/migrate/20120626140242_add_deployment_to_tickets.rb +5 -0
- data/db/migrate/20120626150333_add_last_release_at_to_tickets.rb +14 -0
- data/db/migrate/20120626151320_link_tickets_and_commits.rb +17 -0
- data/db/migrate/20120626152020_add_committer_email_to_commits.rb +13 -0
- data/db/migrate/20120626152949_replace_committer_info_with_author_info.rb +12 -0
- data/db/migrate/20120715230526_change_testing_notes_comment_to_text.rb +9 -0
- data/db/migrate/20120715230922_create_user_notifications.rb +19 -0
- data/db/migrate/20120716010743_add_user_to_releases.rb +14 -0
- data/db/migrate/20120726212620_add_message_to_release.rb +5 -0
- data/db/migrate/20120726231754_link_projects_and_maintainers.rb +22 -0
- data/db/migrate/20120804003344_add_goldmine_to_tickets.rb +5 -0
- data/db/migrate/20120823025935_add_errbit_app_id_to_projects.rb +5 -0
- data/db/migrate/20120826022643_add_authentication_token_to_users.rb +13 -0
- data/db/migrate/20120827190634_add_git_last_sync_at_to_projects.rb +5 -0
- data/db/migrate/20120913020218_add_new_relic_id_to_projects.rb +5 -0
- data/db/migrate/20120920023251_add_administrator_to_users.rb +17 -0
- data/db/migrate/20120922010212_add_unfuddle_id_to_users.rb +5 -0
- data/db/migrate/20121026014457_split_users_name_into_first_and_last.rb +22 -0
- data/db/migrate/20121027160548_create_deploys.rb +11 -0
- data/db/migrate/20121027171215_add_deploy_id_to_releases.rb +6 -0
- data/db/migrate/20121104233305_add_tag_slug_to_changes.rb +5 -0
- data/db/migrate/20121126005019_add_retired_at_to_projects.rb +5 -0
- data/db/migrate/20121214025558_add_estimated_effort_and_estimated_value_to_tickets.rb +6 -0
- data/db/migrate/20121219202734_add_category_to_projects.rb +5 -0
- data/db/migrate/20121220031008_add_expires_at_to_tickets.rb +5 -0
- data/db/migrate/20121222170917_add_version_control_adapter_to_projects.rb +17 -0
- data/db/migrate/20121222223325_remove_unused_fields_from_projects.rb +21 -0
- data/db/migrate/20121222223635_add_ticket_tracking_adapter_to_projects.rb +17 -0
- data/db/migrate/20121224212623_rename_environments.rb +29 -0
- data/db/migrate/20121225175106_replace_environment_id_with_environment_name.rb +39 -0
- data/db/migrate/20121230173644_setup_hstore.rb +9 -0
- data/db/migrate/20121230174234_create_test_runs.rb +22 -0
- data/db/migrate/20130105200429_add_c_i_adapter_to_projects.rb +5 -0
- data/db/migrate/20130106184327_replace_test_runs_details_with_tests.rb +11 -0
- data/db/migrate/20130106185425_add_total_count_to_test_runs.rb +5 -0
- data/db/migrate/20130119203853_remove_cached_queries_from_projects.rb +9 -0
- data/db/migrate/20130119204608_add_extended_attributes_to_tickets.rb +35 -0
- data/db/migrate/20130119211540_remove_estimated_effort_and_estimated_value_from_tickets.rb +11 -0
- data/db/migrate/20130119212008_rename_tickets_unfuddle_id_to_remote_id.rb +5 -0
- data/db/migrate/20130120182026_create_ticket_prerequisites.rb +13 -0
- data/db/migrate/20130211015046_add_min_passing_verdicts_to_projects.rb +5 -0
- data/db/migrate/20130302205014_change_default_role_for_users.rb +8 -0
- data/db/migrate/20130306023456_add_agent_email_to_test_runs.rb +5 -0
- data/db/migrate/20130306023613_add_branch_to_test_runs.rb +5 -0
- data/db/migrate/20130312224911_create_errors.rb +12 -0
- data/db/migrate/20130319003918_add_coverage_to_test_runs.rb +7 -0
- data/db/migrate/20130407195450_create_roles.rb +14 -0
- data/db/migrate/20130407200624_populate_roles.rb +43 -0
- data/db/migrate/20130407220039_add_project_id_to_testing_notes.rb +26 -0
- data/db/migrate/20130407220937_add_project_id_to_commits.rb +26 -0
- data/db/migrate/20130416020627_add_environments_subscribed_to_to_users.rb +17 -0
- data/db/migrate/20130420151334_rename_ticket_tracking_to_ticket_tracker.rb +6 -0
- data/db/migrate/20130420155332_rename_projects_version_control_adapter_to_version_control_name.rb +5 -0
- data/db/migrate/20130420172322_rename_projects_ci_adapter_to_ci_server_name.rb +5 -0
- data/db/migrate/20130420174002_rename_projects_errbit_app_id_to_error_tracker_id.rb +5 -0
- data/db/migrate/20130420174126_add_error_tracker_name_to_projects.rb +11 -0
- data/db/migrate/20130427223925_create_project_quotas.rb +14 -0
- data/db/migrate/20130428005808_create_settings.rb +8 -0
- data/db/migrate/20130504014802_add_extended_attributes_to_projects.rb +19 -0
- data/db/migrate/20130504135741_add_antecedents_to_tickets.rb +26 -0
- data/db/migrate/20130505144446_add_tags_to_tickets.rb +9 -0
- data/db/migrate/20130505162039_add_type_to_tickets.rb +9 -0
- data/db/migrate/20130505212838_add_closed_at_to_tickets.rb +9 -0
- data/db/migrate/20130518224352_drop_environments.rb +9 -0
- data/db/migrate/20130518224406_drop_projects_maintainers.rb +9 -0
- data/db/migrate/20130518224655_remove_goldmine_from_tickets.rb +9 -0
- data/db/migrate/20130518224722_remove_pre_adapter_fields_from_projects.rb +11 -0
- data/db/migrate/20130519163615_create_user_credentials.rb +18 -0
- data/db/migrate/20130525192607_add_reporter_email_and_reporter_id_to_tickets.rb +6 -0
- data/db/migrate/20130525222131_add_regression_count_to_test_runs.rb +5 -0
- data/db/migrate/20130526024851_give_default_values_for_counts_from_test_runs.rb +19 -0
- data/db/migrate/20130706141443_drop_deprecated_project_roles.rb +9 -0
- data/db/migrate/20130710233849_add_authored_at_to_commits.rb +52 -0
- data/db/migrate/20130711004558_downcase_commits_committer_emails.rb +10 -0
- data/db/migrate/20130711013156_link_commits_and_users.rb +35 -0
- data/db/migrate/20130728191005_add_retired_at_to_users.rb +5 -0
- data/db/migrate/20130806143651_link_commits_and_releases.rb +18 -0
- data/db/migrate/20130815232527_add_unreachable_to_commits.rb +6 -0
- data/db/migrate/20130914152419_rename_test_runs_commit_to_sha.rb +9 -0
- data/db/migrate/20130914155044_add_code_climate_repo_token_to_projects.rb +5 -0
- data/db/migrate/20130921141449_create_milestones.rb +19 -0
- data/db/migrate/20131002005512_add_last_ticket_tracker_sync_at_to_projects.rb +5 -0
- data/db/migrate/20131002015547_add_ticket_tracker_sync_started_at_to_projects.rb +5 -0
- data/db/migrate/20131002145620_add_destroyed_at_to_tickets.rb +6 -0
- data/db/migrate/20131003014023_add_destroyed_at_to_milestones.rb +6 -0
- data/db/migrate/20131004015452_add_resolution_to_tickets.rb +6 -0
- data/db/migrate/20131004185618_add_first_release_at_to_tickets.rb +14 -0
- data/db/migrate/20131012152403_create_sprints.rb +15 -0
- data/db/migrate/20131013185636_add_checked_out_to_tickets.rb +6 -0
- data/db/migrate/20131027214942_add_priority_to_tickets.rb +5 -0
- data/db/migrate/20131112010815_delete_duplicate_commits.rb +33 -0
- data/db/migrate/20131216014505_create_oauth_consumer_tokens.rb +20 -0
- data/db/migrate/20131223194246_add_reopened_at_to_tickets.rb +5 -0
- data/db/migrate/20140106212047_add_options_to_projects.rb +5 -0
- data/db/migrate/20140106212305_add_options_to_users.rb +5 -0
- data/db/migrate/20140114014144_add_deployer_to_deploys.rb +5 -0
- data/db/migrate/20140217150735_drop_table_user_notifications.rb +9 -0
- data/db/migrate/20140217160450_add_email_addresses_to_users.rb +18 -0
- data/db/migrate/20140217195942_add_prerequisites_to_tickets.rb +5 -0
- data/db/migrate/20140327020121_drop_ticket_prerequisites.rb +9 -0
- data/db/migrate/20140401234330_add_index_to_ticket_queues.rb +6 -0
- data/db/migrate/20140406183224_remove_new_relic_id_from_projects.rb +9 -0
- data/db/migrate/20140406230121_delete_automatically_generated_messages_for_releases.rb +12 -0
- data/db/migrate/20140407010111_drop_sprints_project_id.rb +9 -0
- data/db/migrate/20140411214022_add_invitation_created_at_to_user.rb +5 -0
- data/db/migrate/20140418133005_change_ticket_antecedents_to_text_array.rb +9 -0
- data/db/migrate/20140419152214_add_gemnasium_slug_to_projects.rb +5 -0
- data/db/migrate/20140425141946_embed_changes_in_releases.rb +19 -0
- data/db/migrate/20140427235508_prevent_release_changes_from_being_null.rb +6 -0
- data/db/migrate/20140428023146_prevent_ticket_number_from_being_null.rb +5 -0
- data/db/migrate/20140429000919_add_feature_states_to_projects.rb +5 -0
- data/db/migrate/20140506032958_add_locked_to_sprints.rb +5 -0
- data/db/migrate/20140506035755_create_value_statements.rb +9 -0
- data/db/migrate/20140511024021_rename_testing_notes_unfuddle_id_to_remote_id.rb +5 -0
- data/db/migrate/20140515174322_create_tasks.rb +20 -0
- data/db/migrate/20140515200824_link_tasks_and_commits.rb +8 -0
- data/db/migrate/20140516005310_link_tasks_and_releases.rb +8 -0
- data/db/migrate/20140516012049_create_tasks_for_existing_tickets.rb +33 -0
- data/db/migrate/20140517012626_prevent_hstore_fields_from_being_null.rb +22 -0
- data/db/migrate/20140521014652_allow_task_descriptions_to_be_null.rb +13 -0
- data/db/migrate/20140526155845_add_commit_id_to_deploys.rb +31 -0
- data/db/migrate/20140526162645_add_commit_before_id_and_commit_after_id_to_releases.rb +28 -0
- data/db/migrate/20140526180608_associate_remaining_deploys_and_releases.rb +60 -0
- data/db/migrate/20140606232907_create_vestal_versions.rb +28 -0
- data/db/migrate/20140724231918_create_sprints_tasks.rb +17 -0
- data/db/migrate/20140806233301_add_position_to_milestones.rb +5 -0
- data/db/migrate/20140810224209_add_size_and_units_to_milestones.rb +7 -0
- data/db/migrate/20140824194031_add_project_id_to_tasks.rb +11 -0
- data/db/migrate/20140824194526_add_completed_at_to_tasks.rb +20 -0
- data/db/migrate/20140824211249_require_sprints_to_be_unique.rb +9 -0
- data/db/migrate/20140907012329_drop_table_changes.rb +9 -0
- data/db/migrate/20140907013836_drop_table_errors.rb +9 -0
- data/db/migrate/20140921190022_add_checked_out_to_sprints_tasks.rb +19 -0
- data/db/migrate/20140921201441_drop_users_name.rb +9 -0
- data/db/migrate/20140925021043_rename_deploys_commit_to_sha.rb +17 -0
- data/db/migrate/20140929004347_create_historical_heads.rb +23 -0
- data/db/migrate/20141027194819_make_users_environments_subscribed_to_an_array.rb +18 -0
- data/db/migrate/20141202004123_add_duration_to_deploys.rb +5 -0
- data/db/migrate/20141226171730_create_measurements.rb +17 -0
- data/db/migrate/20150116153233_add_timestamps_to_measurements.rb +6 -0
- data/db/migrate/20150119154013_drop_unused_fields_from_milestones.rb +13 -0
- data/db/migrate/20150220215154_add_branch_to_deploys.rb +5 -0
- data/db/migrate/20150222205616_add_features_to_projects.rb +12 -0
- data/db/migrate/20150222214124_add_current_project_to_users.rb +5 -0
- data/db/migrate/20150223013721_add_nickname_to_users.rb +5 -0
- data/db/migrate/20150302153319_add_username_to_users.rb +5 -0
- data/db/migrate/20150323004452_add_deploys_completed_at.rb +10 -0
- data/db/migrate/20150323011050_add_output_to_deploy.rb +5 -0
- data/db/migrate/20150805180939_add_commit_id_to_test_runs.rb +30 -0
- data/db/migrate/20150805233946_add_user_id_to_test_runs.rb +23 -0
- data/db/migrate/20150806032230_create_tests.rb +33 -0
- data/db/migrate/20150808161729_create_test_errors.rb +10 -0
- data/db/migrate/20150808161805_create_test_results.rb +72 -0
- data/db/migrate/20150808162928_index_test_runs_on_commit_id.rb +5 -0
- data/db/migrate/20150808192103_index_commits_on_sha.rb +5 -0
- data/db/migrate/20150808193354_add_parent_sha_to_commits.rb +43 -0
- data/db/migrate/20150809132417_rename_test_results_regression_to_difference.rb +11 -0
- data/db/migrate/20150809201942_add_compared_to_test_runs.rb +5 -0
- data/db/migrate/20150817232311_create_pull_requests.rb +25 -0
- data/db/migrate/20150820023708_add_labels_to_pull_requests.rb +5 -0
- data/db/migrate/20150902005758_downcase_environment_names.rb +19 -0
- data/db/migrate/20150902010629_add_user_id_to_deploys.rb +5 -0
- data/db/migrate/20150902010853_populate_deploys_user.rb +13 -0
- data/db/seeds.rb +9 -0
- data/db/structure.sql +2282 -0
- data/houston.gemspec +99 -0
- data/lib/configuration.rb +764 -0
- data/lib/core_ext/duration.rb +21 -0
- data/lib/core_ext/exception.rb +7 -0
- data/lib/core_ext/hash.rb +51 -0
- data/lib/core_ext/kernel.rb +23 -0
- data/lib/houston/application.rb +1 -0
- data/lib/houston/version.rb +3 -0
- data/lib/houston_daemonize.rb +37 -0
- data/lib/houston_observer.rb +69 -0
- data/lib/houston_server.rb +31 -0
- data/lib/parallel_enumerable.rb +56 -0
- data/lib/patches/sprockets_output_path_for_assets.rb +29 -0
- data/lib/tasks/.gitkeep +0 -0
- data/lib/tasks/.keep +0 -0
- data/lib/tasks/config.rake +255 -0
- data/lib/tasks/keypair.rake +18 -0
- data/lib/unexpected_response.rb +22 -0
- data/log/.gitkeep +0 -0
- data/log/.keep +0 -0
- data/script/bootstrap +14 -0
- data/script/cibuild +9 -0
- data/support/award.ai +4409 -19
- data/support/badges.ai +4621 -19
- data/support/bugs-1.ai +1364 -1
- data/support/bugs-2.ai +806 -1
- data/support/chevron.ai +4431 -19
- data/support/favicon.psd +0 -0
- data/support/flask.ai +386 -1
- data/support/headings.ai +394 -0
- data/support/new-window-link-12.gif +0 -0
- data/support/newrelic.ai +204 -0
- data/support/newrelic.png +0 -0
- data/support/wrench.ai +4389 -20
- data/vendor/assets/javascripts/.gitkeep +0 -0
- data/vendor/assets/javascripts/.keep +0 -0
- data/vendor/assets/javascripts/Markdown.Converter.js +1412 -0
- data/vendor/assets/javascripts/alertify.js +1 -0
- data/vendor/assets/javascripts/bootstrap.js +2280 -0
- data/vendor/assets/javascripts/d3.v3.js +9274 -0
- data/vendor/assets/javascripts/dropzone.js +1728 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.accordion.js +572 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.autocomplete.js +608 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.button.js +419 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.core.js +324 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.datepicker.js +2050 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.dialog.js +799 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.draggable.js +943 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.droppable.js +371 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-blind.js +82 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-bounce.js +113 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-clip.js +67 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-drop.js +65 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-explode.js +97 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-fade.js +30 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-fold.js +76 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-highlight.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-pulsate.js +63 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-scale.js +318 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-shake.js +74 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-slide.js +64 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect-transfer.js +47 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.effect.js +1268 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.menu.js +621 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.mouse.js +169 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.position.js +497 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.progressbar.js +145 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.resizable.js +946 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.selectable.js +277 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.slider.js +672 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.sortable.js +1250 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.spinner.js +492 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.tabs.js +846 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.tooltip.js +402 -0
- data/vendor/assets/javascripts/jquery-ui-1.10.1/jquery.ui.widget.js +521 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery-ui-i18n.js +1379 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-af.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ar-DZ.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ar.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-az.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-bg.js +24 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-bs.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ca.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-cs.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-da.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-de.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-el.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-en-AU.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-en-GB.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-en-NZ.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-eo.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-es.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-et.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-eu.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-fa.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-fi.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-fo.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-fr-CH.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-fr.js +25 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-gl.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-he.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-hr.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-hu.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-hy.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-id.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-is.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-it.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ja.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ko.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-kz.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-lt.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-lv.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ml.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ms.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-nl.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-no.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-pl.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-pt-BR.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-pt.js +22 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-rm.js +21 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ro.js +26 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ru.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sk.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sl.js +24 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sq.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sr-SR.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sr.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-sv.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-ta.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-th.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-tj.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-tr.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-uk.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-vi.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-zh-CN.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-zh-HK.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/i18n/jquery.ui.datepicker-zh-TW.js +23 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.blind.js +49 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.bounce.js +78 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.clip.js +54 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.core.js +746 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.drop.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.explode.js +79 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.fade.js +32 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.fold.js +56 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.highlight.js +49 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.pulsate.js +51 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.scale.js +178 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.shake.js +57 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.slide.js +50 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.effects.transfer.js +45 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.accordion.js +611 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.autocomplete.js +612 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.button.js +416 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.core.js +312 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.datepicker.js +1814 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.dialog.js +879 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.draggable.js +823 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.droppable.js +296 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.mouse.js +160 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.position.js +252 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.progressbar.js +109 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.resizable.js +842 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.selectable.js +266 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.slider.js +666 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.sortable.js +1077 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.tabs.js +758 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.4/jquery.ui.widget.js +262 -0
- data/vendor/assets/javascripts/jquery-ui.js +55 -0
- data/vendor/assets/javascripts/jquery.autosize.js +242 -0
- data/vendor/assets/javascripts/jquery.pjax.js +817 -0
- data/vendor/assets/javascripts/jquery.tablesorter.js +1032 -0
- data/vendor/assets/javascripts/jquery.timeago.js +214 -0
- data/vendor/assets/javascripts/md5.js +202 -0
- data/vendor/assets/javascripts/mousetrap.js +953 -0
- data/vendor/assets/stylesheets/.gitkeep +0 -0
- data/vendor/assets/stylesheets/.keep +0 -0
- data/vendor/assets/stylesheets/alertify-bootstrap-3.css +2 -0
- data/vendor/assets/stylesheets/alertify-bootstrap.css +2 -0
- data/vendor/assets/stylesheets/alertify.css +2 -0
- data/vendor/assets/stylesheets/bootstrap-responsive.css +800 -0
- data/vendor/assets/stylesheets/bootstrap.css +6163 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.accordion.css +38 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.autocomplete.css +16 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.button.css +114 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.core.css +93 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.datepicker.css +178 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.dialog.css +69 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.menu.css +77 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.progressbar.css +28 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.resizable.css +78 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.selectable.css +15 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.slider.css +73 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.spinner.css +65 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.tabs.css +52 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.theme.css +406 -0
- data/vendor/assets/stylesheets/jquery-ui-1.10.1/jquery.ui.tooltip.css +19 -0
- data/vendor/assets/stylesheets/jquery-ui.css +28 -0
- data/vendor/images/fa-bank.svg +9 -0
- data/vendor/images/fa-bell.svg +9 -0
- data/vendor/images/fa-bomb.svg +9 -0
- data/vendor/images/fa-bug.svg +9 -0
- data/vendor/images/fa-bullhorn.svg +6 -0
- data/vendor/images/fa-burndown.svg +15 -0
- data/vendor/images/fa-calendar-o.svg +9 -0
- data/vendor/images/fa-comment.svg +9 -0
- data/vendor/images/fa-comments.svg +9 -0
- data/vendor/images/fa-database.svg +9 -0
- data/vendor/images/fa-fire-extinguisher.svg +9 -0
- data/vendor/images/fa-gear.svg +6 -0
- data/vendor/images/fa-lightbulb-o.svg +9 -0
- data/vendor/images/fa-paper-plane.svg +9 -0
- data/vendor/images/fa-road.svg +9 -0
- data/vendor/images/fa-user.svg +9 -0
- metadata +1611 -0
@@ -0,0 +1,214 @@
|
|
1
|
+
/**
|
2
|
+
* Timeago is a jQuery plugin that makes it easy to support automatically
|
3
|
+
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
4
|
+
*
|
5
|
+
* @name timeago
|
6
|
+
* @version 1.4.1
|
7
|
+
* @requires jQuery v1.2.3+
|
8
|
+
* @author Ryan McGeary
|
9
|
+
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
|
10
|
+
*
|
11
|
+
* For usage and examples, visit:
|
12
|
+
* http://timeago.yarp.com/
|
13
|
+
*
|
14
|
+
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
|
15
|
+
*/
|
16
|
+
|
17
|
+
(function (factory) {
|
18
|
+
if (typeof define === 'function' && define.amd) {
|
19
|
+
// AMD. Register as an anonymous module.
|
20
|
+
define(['jquery'], factory);
|
21
|
+
} else {
|
22
|
+
// Browser globals
|
23
|
+
factory(jQuery);
|
24
|
+
}
|
25
|
+
}(function ($) {
|
26
|
+
$.timeago = function(timestamp) {
|
27
|
+
if (timestamp instanceof Date) {
|
28
|
+
return inWords(timestamp);
|
29
|
+
} else if (typeof timestamp === "string") {
|
30
|
+
return inWords($.timeago.parse(timestamp));
|
31
|
+
} else if (typeof timestamp === "number") {
|
32
|
+
return inWords(new Date(timestamp));
|
33
|
+
} else {
|
34
|
+
return inWords($.timeago.datetime(timestamp));
|
35
|
+
}
|
36
|
+
};
|
37
|
+
var $t = $.timeago;
|
38
|
+
|
39
|
+
$.extend($.timeago, {
|
40
|
+
settings: {
|
41
|
+
refreshMillis: 60000,
|
42
|
+
allowPast: true,
|
43
|
+
allowFuture: false,
|
44
|
+
localeTitle: false,
|
45
|
+
cutoff: 0,
|
46
|
+
strings: {
|
47
|
+
prefixAgo: null,
|
48
|
+
prefixFromNow: null,
|
49
|
+
suffixAgo: "ago",
|
50
|
+
suffixFromNow: "from now",
|
51
|
+
inPast: 'any moment now',
|
52
|
+
seconds: "less than a minute",
|
53
|
+
minute: "about a minute",
|
54
|
+
minutes: "%d minutes",
|
55
|
+
hour: "about an hour",
|
56
|
+
hours: "about %d hours",
|
57
|
+
day: "a day",
|
58
|
+
days: "%d days",
|
59
|
+
month: "about a month",
|
60
|
+
months: "%d months",
|
61
|
+
year: "about a year",
|
62
|
+
years: "%d years",
|
63
|
+
wordSeparator: " ",
|
64
|
+
numbers: []
|
65
|
+
}
|
66
|
+
},
|
67
|
+
|
68
|
+
inWords: function(distanceMillis) {
|
69
|
+
if(!this.settings.allowPast && ! this.settings.allowFuture) {
|
70
|
+
throw 'timeago allowPast and allowFuture settings can not both be set to false.';
|
71
|
+
}
|
72
|
+
|
73
|
+
var $l = this.settings.strings;
|
74
|
+
var prefix = $l.prefixAgo;
|
75
|
+
var suffix = $l.suffixAgo;
|
76
|
+
if (this.settings.allowFuture) {
|
77
|
+
if (distanceMillis < 0) {
|
78
|
+
prefix = $l.prefixFromNow;
|
79
|
+
suffix = $l.suffixFromNow;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
if(!this.settings.allowPast && distanceMillis >= 0) {
|
84
|
+
return this.settings.strings.inPast;
|
85
|
+
}
|
86
|
+
|
87
|
+
var seconds = Math.abs(distanceMillis) / 1000;
|
88
|
+
var minutes = seconds / 60;
|
89
|
+
var hours = minutes / 60;
|
90
|
+
var days = hours / 24;
|
91
|
+
var years = days / 365;
|
92
|
+
|
93
|
+
function substitute(stringOrFunction, number) {
|
94
|
+
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
|
95
|
+
var value = ($l.numbers && $l.numbers[number]) || number;
|
96
|
+
return string.replace(/%d/i, value);
|
97
|
+
}
|
98
|
+
|
99
|
+
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
|
100
|
+
seconds < 90 && substitute($l.minute, 1) ||
|
101
|
+
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
|
102
|
+
minutes < 90 && substitute($l.hour, 1) ||
|
103
|
+
hours < 24 && substitute($l.hours, Math.round(hours)) ||
|
104
|
+
hours < 42 && substitute($l.day, 1) ||
|
105
|
+
days < 30 && substitute($l.days, Math.round(days)) ||
|
106
|
+
days < 45 && substitute($l.month, 1) ||
|
107
|
+
days < 365 && substitute($l.months, Math.round(days / 30)) ||
|
108
|
+
years < 1.5 && substitute($l.year, 1) ||
|
109
|
+
substitute($l.years, Math.round(years));
|
110
|
+
|
111
|
+
var separator = $l.wordSeparator || "";
|
112
|
+
if ($l.wordSeparator === undefined) { separator = " "; }
|
113
|
+
return $.trim([prefix, words, suffix].join(separator));
|
114
|
+
},
|
115
|
+
|
116
|
+
parse: function(iso8601) {
|
117
|
+
var s = $.trim(iso8601);
|
118
|
+
s = s.replace(/\.\d+/,""); // remove milliseconds
|
119
|
+
s = s.replace(/-/,"/").replace(/-/,"/");
|
120
|
+
s = s.replace(/T/," ").replace(/Z/," UTC");
|
121
|
+
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
|
122
|
+
s = s.replace(/([\+\-]\d\d)$/," $100"); // +09 -> +0900
|
123
|
+
return new Date(s);
|
124
|
+
},
|
125
|
+
datetime: function(elem) {
|
126
|
+
var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");
|
127
|
+
return $t.parse(iso8601);
|
128
|
+
},
|
129
|
+
isTime: function(elem) {
|
130
|
+
// jQuery's `is()` doesn't play well with HTML5 in IE
|
131
|
+
return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");
|
132
|
+
}
|
133
|
+
});
|
134
|
+
|
135
|
+
// functions that can be called via $(el).timeago('action')
|
136
|
+
// init is default when no action is given
|
137
|
+
// functions are called with context of a single element
|
138
|
+
var functions = {
|
139
|
+
init: function(){
|
140
|
+
var refresh_el = $.proxy(refresh, this);
|
141
|
+
refresh_el();
|
142
|
+
var $s = $t.settings;
|
143
|
+
if ($s.refreshMillis > 0) {
|
144
|
+
this._timeagoInterval = setInterval(refresh_el, $s.refreshMillis);
|
145
|
+
}
|
146
|
+
},
|
147
|
+
update: function(time){
|
148
|
+
var parsedTime = $t.parse(time);
|
149
|
+
$(this).data('timeago', { datetime: parsedTime });
|
150
|
+
if($t.settings.localeTitle) $(this).attr("title", parsedTime.toLocaleString());
|
151
|
+
refresh.apply(this);
|
152
|
+
},
|
153
|
+
updateFromDOM: function(){
|
154
|
+
$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });
|
155
|
+
refresh.apply(this);
|
156
|
+
},
|
157
|
+
dispose: function () {
|
158
|
+
if (this._timeagoInterval) {
|
159
|
+
window.clearInterval(this._timeagoInterval);
|
160
|
+
this._timeagoInterval = null;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
};
|
164
|
+
|
165
|
+
$.fn.timeago = function(action, options) {
|
166
|
+
var fn = action ? functions[action] : functions.init;
|
167
|
+
if(!fn){
|
168
|
+
throw new Error("Unknown function name '"+ action +"' for timeago");
|
169
|
+
}
|
170
|
+
// each over objects here and call the requested function
|
171
|
+
this.each(function(){
|
172
|
+
fn.call(this, options);
|
173
|
+
});
|
174
|
+
return this;
|
175
|
+
};
|
176
|
+
|
177
|
+
function refresh() {
|
178
|
+
var data = prepareData(this);
|
179
|
+
var $s = $t.settings;
|
180
|
+
|
181
|
+
if (!isNaN(data.datetime)) {
|
182
|
+
if ( $s.cutoff == 0 || Math.abs(distance(data.datetime)) < $s.cutoff) {
|
183
|
+
$(this).text(inWords(data.datetime));
|
184
|
+
}
|
185
|
+
}
|
186
|
+
return this;
|
187
|
+
}
|
188
|
+
|
189
|
+
function prepareData(element) {
|
190
|
+
element = $(element);
|
191
|
+
if (!element.data("timeago")) {
|
192
|
+
element.data("timeago", { datetime: $t.datetime(element) });
|
193
|
+
var text = $.trim(element.text());
|
194
|
+
if ($t.settings.localeTitle) {
|
195
|
+
element.attr("title", element.data('timeago').datetime.toLocaleString());
|
196
|
+
} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {
|
197
|
+
element.attr("title", text);
|
198
|
+
}
|
199
|
+
}
|
200
|
+
return element.data("timeago");
|
201
|
+
}
|
202
|
+
|
203
|
+
function inWords(date) {
|
204
|
+
return $t.inWords(distance(date));
|
205
|
+
}
|
206
|
+
|
207
|
+
function distance(date) {
|
208
|
+
return (new Date().getTime() - date.getTime());
|
209
|
+
}
|
210
|
+
|
211
|
+
// fix for IE6 suckage
|
212
|
+
document.createElement("abbr");
|
213
|
+
document.createElement("time");
|
214
|
+
}));
|
@@ -0,0 +1,202 @@
|
|
1
|
+
// Chris Coyier's MD5 Library
|
2
|
+
// http://css-tricks.com/snippets/javascript/javascript-md5/
|
3
|
+
var MD5 = function (string) {
|
4
|
+
|
5
|
+
function RotateLeft(lValue, iShiftBits) {
|
6
|
+
return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
|
7
|
+
}
|
8
|
+
|
9
|
+
function AddUnsigned(lX,lY) {
|
10
|
+
var lX4,lY4,lX8,lY8,lResult;
|
11
|
+
lX8 = (lX & 0x80000000);
|
12
|
+
lY8 = (lY & 0x80000000);
|
13
|
+
lX4 = (lX & 0x40000000);
|
14
|
+
lY4 = (lY & 0x40000000);
|
15
|
+
lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
|
16
|
+
if (lX4 & lY4) {
|
17
|
+
return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
|
18
|
+
}
|
19
|
+
if (lX4 | lY4) {
|
20
|
+
if (lResult & 0x40000000) {
|
21
|
+
return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
|
22
|
+
} else {
|
23
|
+
return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
|
24
|
+
}
|
25
|
+
} else {
|
26
|
+
return (lResult ^ lX8 ^ lY8);
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
function F(x,y,z) { return (x & y) | ((~x) & z); }
|
31
|
+
function G(x,y,z) { return (x & z) | (y & (~z)); }
|
32
|
+
function H(x,y,z) { return (x ^ y ^ z); }
|
33
|
+
function I(x,y,z) { return (y ^ (x | (~z))); }
|
34
|
+
|
35
|
+
function FF(a,b,c,d,x,s,ac) {
|
36
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
|
37
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
38
|
+
};
|
39
|
+
|
40
|
+
function GG(a,b,c,d,x,s,ac) {
|
41
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
|
42
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
43
|
+
};
|
44
|
+
|
45
|
+
function HH(a,b,c,d,x,s,ac) {
|
46
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
|
47
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
48
|
+
};
|
49
|
+
|
50
|
+
function II(a,b,c,d,x,s,ac) {
|
51
|
+
a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
|
52
|
+
return AddUnsigned(RotateLeft(a, s), b);
|
53
|
+
};
|
54
|
+
|
55
|
+
function ConvertToWordArray(string) {
|
56
|
+
var lWordCount;
|
57
|
+
var lMessageLength = string.length;
|
58
|
+
var lNumberOfWords_temp1=lMessageLength + 8;
|
59
|
+
var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
|
60
|
+
var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
|
61
|
+
var lWordArray=Array(lNumberOfWords-1);
|
62
|
+
var lBytePosition = 0;
|
63
|
+
var lByteCount = 0;
|
64
|
+
while ( lByteCount < lMessageLength ) {
|
65
|
+
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
66
|
+
lBytePosition = (lByteCount % 4)*8;
|
67
|
+
lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
|
68
|
+
lByteCount++;
|
69
|
+
}
|
70
|
+
lWordCount = (lByteCount-(lByteCount % 4))/4;
|
71
|
+
lBytePosition = (lByteCount % 4)*8;
|
72
|
+
lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
|
73
|
+
lWordArray[lNumberOfWords-2] = lMessageLength<<3;
|
74
|
+
lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
|
75
|
+
return lWordArray;
|
76
|
+
};
|
77
|
+
|
78
|
+
function WordToHex(lValue) {
|
79
|
+
var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
|
80
|
+
for (lCount = 0;lCount<=3;lCount++) {
|
81
|
+
lByte = (lValue>>>(lCount*8)) & 255;
|
82
|
+
WordToHexValue_temp = "0" + lByte.toString(16);
|
83
|
+
WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
|
84
|
+
}
|
85
|
+
return WordToHexValue;
|
86
|
+
};
|
87
|
+
|
88
|
+
function Utf8Encode(string) {
|
89
|
+
string = string.replace(/\r\n/g,"\n");
|
90
|
+
var utftext = "";
|
91
|
+
|
92
|
+
for (var n = 0; n < string.length; n++) {
|
93
|
+
|
94
|
+
var c = string.charCodeAt(n);
|
95
|
+
|
96
|
+
if (c < 128) {
|
97
|
+
utftext += String.fromCharCode(c);
|
98
|
+
}
|
99
|
+
else if((c > 127) && (c < 2048)) {
|
100
|
+
utftext += String.fromCharCode((c >> 6) | 192);
|
101
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
utftext += String.fromCharCode((c >> 12) | 224);
|
105
|
+
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
|
106
|
+
utftext += String.fromCharCode((c & 63) | 128);
|
107
|
+
}
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
return utftext;
|
112
|
+
};
|
113
|
+
|
114
|
+
var x=Array();
|
115
|
+
var k,AA,BB,CC,DD,a,b,c,d;
|
116
|
+
var S11=7, S12=12, S13=17, S14=22;
|
117
|
+
var S21=5, S22=9 , S23=14, S24=20;
|
118
|
+
var S31=4, S32=11, S33=16, S34=23;
|
119
|
+
var S41=6, S42=10, S43=15, S44=21;
|
120
|
+
|
121
|
+
string = Utf8Encode(string);
|
122
|
+
|
123
|
+
x = ConvertToWordArray(string);
|
124
|
+
|
125
|
+
a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
|
126
|
+
|
127
|
+
for (k=0;k<x.length;k+=16) {
|
128
|
+
AA=a; BB=b; CC=c; DD=d;
|
129
|
+
a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
|
130
|
+
d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
|
131
|
+
c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
|
132
|
+
b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
|
133
|
+
a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
|
134
|
+
d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
|
135
|
+
c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
|
136
|
+
b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
|
137
|
+
a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
|
138
|
+
d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
|
139
|
+
c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
|
140
|
+
b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
|
141
|
+
a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
|
142
|
+
d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
|
143
|
+
c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
|
144
|
+
b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
|
145
|
+
a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
|
146
|
+
d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
|
147
|
+
c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
|
148
|
+
b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
|
149
|
+
a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
|
150
|
+
d=GG(d,a,b,c,x[k+10],S22,0x2441453);
|
151
|
+
c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
|
152
|
+
b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
|
153
|
+
a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
|
154
|
+
d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
|
155
|
+
c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
|
156
|
+
b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
|
157
|
+
a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
|
158
|
+
d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
|
159
|
+
c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
|
160
|
+
b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
|
161
|
+
a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
|
162
|
+
d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
|
163
|
+
c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
|
164
|
+
b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
|
165
|
+
a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
|
166
|
+
d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
|
167
|
+
c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
|
168
|
+
b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
|
169
|
+
a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
|
170
|
+
d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
|
171
|
+
c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
|
172
|
+
b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
|
173
|
+
a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
|
174
|
+
d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
|
175
|
+
c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
|
176
|
+
b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
|
177
|
+
a=II(a,b,c,d,x[k+0], S41,0xF4292244);
|
178
|
+
d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
|
179
|
+
c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
|
180
|
+
b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
|
181
|
+
a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
|
182
|
+
d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
|
183
|
+
c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
|
184
|
+
b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
|
185
|
+
a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
|
186
|
+
d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
|
187
|
+
c=II(c,d,a,b,x[k+6], S43,0xA3014314);
|
188
|
+
b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
|
189
|
+
a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
|
190
|
+
d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
|
191
|
+
c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
|
192
|
+
b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
|
193
|
+
a=AddUnsigned(a,AA);
|
194
|
+
b=AddUnsigned(b,BB);
|
195
|
+
c=AddUnsigned(c,CC);
|
196
|
+
d=AddUnsigned(d,DD);
|
197
|
+
}
|
198
|
+
|
199
|
+
var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
|
200
|
+
|
201
|
+
return temp.toLowerCase();
|
202
|
+
};
|
@@ -0,0 +1,953 @@
|
|
1
|
+
/*global define:false */
|
2
|
+
/**
|
3
|
+
* Copyright 2013 Craig Campbell
|
4
|
+
*
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
* you may not use this file except in compliance with the License.
|
7
|
+
* You may obtain a copy of the License at
|
8
|
+
*
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
*
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
* See the License for the specific language governing permissions and
|
15
|
+
* limitations under the License.
|
16
|
+
*
|
17
|
+
* Mousetrap is a simple keyboard shortcut library for Javascript with
|
18
|
+
* no external dependencies
|
19
|
+
*
|
20
|
+
* @version 1.4.6
|
21
|
+
* @url craig.is/killing/mice
|
22
|
+
*/
|
23
|
+
(function(window, document, undefined) {
|
24
|
+
|
25
|
+
/**
|
26
|
+
* mapping of special keycodes to their corresponding keys
|
27
|
+
*
|
28
|
+
* everything in this dictionary cannot use keypress events
|
29
|
+
* so it has to be here to map to the correct keycodes for
|
30
|
+
* keyup/keydown events
|
31
|
+
*
|
32
|
+
* @type {Object}
|
33
|
+
*/
|
34
|
+
var _MAP = {
|
35
|
+
8: 'backspace',
|
36
|
+
9: 'tab',
|
37
|
+
13: 'enter',
|
38
|
+
16: 'shift',
|
39
|
+
17: 'ctrl',
|
40
|
+
18: 'alt',
|
41
|
+
20: 'capslock',
|
42
|
+
27: 'esc',
|
43
|
+
32: 'space',
|
44
|
+
33: 'pageup',
|
45
|
+
34: 'pagedown',
|
46
|
+
35: 'end',
|
47
|
+
36: 'home',
|
48
|
+
37: 'left',
|
49
|
+
38: 'up',
|
50
|
+
39: 'right',
|
51
|
+
40: 'down',
|
52
|
+
45: 'ins',
|
53
|
+
46: 'del',
|
54
|
+
91: 'meta',
|
55
|
+
93: 'meta',
|
56
|
+
224: 'meta'
|
57
|
+
},
|
58
|
+
|
59
|
+
/**
|
60
|
+
* mapping for special characters so they can support
|
61
|
+
*
|
62
|
+
* this dictionary is only used incase you want to bind a
|
63
|
+
* keyup or keydown event to one of these keys
|
64
|
+
*
|
65
|
+
* @type {Object}
|
66
|
+
*/
|
67
|
+
_KEYCODE_MAP = {
|
68
|
+
106: '*',
|
69
|
+
107: '+',
|
70
|
+
109: '-',
|
71
|
+
110: '.',
|
72
|
+
111 : '/',
|
73
|
+
186: ';',
|
74
|
+
187: '=',
|
75
|
+
188: ',',
|
76
|
+
189: '-',
|
77
|
+
190: '.',
|
78
|
+
191: '/',
|
79
|
+
192: '`',
|
80
|
+
219: '[',
|
81
|
+
220: '\\',
|
82
|
+
221: ']',
|
83
|
+
222: '\''
|
84
|
+
},
|
85
|
+
|
86
|
+
/**
|
87
|
+
* this is a mapping of keys that require shift on a US keypad
|
88
|
+
* back to the non shift equivelents
|
89
|
+
*
|
90
|
+
* this is so you can use keyup events with these keys
|
91
|
+
*
|
92
|
+
* note that this will only work reliably on US keyboards
|
93
|
+
*
|
94
|
+
* @type {Object}
|
95
|
+
*/
|
96
|
+
_SHIFT_MAP = {
|
97
|
+
'~': '`',
|
98
|
+
'!': '1',
|
99
|
+
'@': '2',
|
100
|
+
'#': '3',
|
101
|
+
'$': '4',
|
102
|
+
'%': '5',
|
103
|
+
'^': '6',
|
104
|
+
'&': '7',
|
105
|
+
'*': '8',
|
106
|
+
'(': '9',
|
107
|
+
')': '0',
|
108
|
+
'_': '-',
|
109
|
+
'+': '=',
|
110
|
+
':': ';',
|
111
|
+
'\"': '\'',
|
112
|
+
'<': ',',
|
113
|
+
'>': '.',
|
114
|
+
'?': '/',
|
115
|
+
'|': '\\'
|
116
|
+
},
|
117
|
+
|
118
|
+
/**
|
119
|
+
* this is a list of special strings you can use to map
|
120
|
+
* to modifier keys when you specify your keyboard shortcuts
|
121
|
+
*
|
122
|
+
* @type {Object}
|
123
|
+
*/
|
124
|
+
_SPECIAL_ALIASES = {
|
125
|
+
'option': 'alt',
|
126
|
+
'command': 'meta',
|
127
|
+
'return': 'enter',
|
128
|
+
'escape': 'esc',
|
129
|
+
'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
|
130
|
+
},
|
131
|
+
|
132
|
+
/**
|
133
|
+
* variable to store the flipped version of _MAP from above
|
134
|
+
* needed to check if we should use keypress or not when no action
|
135
|
+
* is specified
|
136
|
+
*
|
137
|
+
* @type {Object|undefined}
|
138
|
+
*/
|
139
|
+
_REVERSE_MAP,
|
140
|
+
|
141
|
+
/**
|
142
|
+
* a list of all the callbacks setup via Mousetrap.bind()
|
143
|
+
*
|
144
|
+
* @type {Object}
|
145
|
+
*/
|
146
|
+
_callbacks = {},
|
147
|
+
|
148
|
+
/**
|
149
|
+
* direct map of string combinations to callbacks used for trigger()
|
150
|
+
*
|
151
|
+
* @type {Object}
|
152
|
+
*/
|
153
|
+
_directMap = {},
|
154
|
+
|
155
|
+
/**
|
156
|
+
* keeps track of what level each sequence is at since multiple
|
157
|
+
* sequences can start out with the same sequence
|
158
|
+
*
|
159
|
+
* @type {Object}
|
160
|
+
*/
|
161
|
+
_sequenceLevels = {},
|
162
|
+
|
163
|
+
/**
|
164
|
+
* variable to store the setTimeout call
|
165
|
+
*
|
166
|
+
* @type {null|number}
|
167
|
+
*/
|
168
|
+
_resetTimer,
|
169
|
+
|
170
|
+
/**
|
171
|
+
* temporary state where we will ignore the next keyup
|
172
|
+
*
|
173
|
+
* @type {boolean|string}
|
174
|
+
*/
|
175
|
+
_ignoreNextKeyup = false,
|
176
|
+
|
177
|
+
/**
|
178
|
+
* temporary state where we will ignore the next keypress
|
179
|
+
*
|
180
|
+
* @type {boolean}
|
181
|
+
*/
|
182
|
+
_ignoreNextKeypress = false,
|
183
|
+
|
184
|
+
/**
|
185
|
+
* are we currently inside of a sequence?
|
186
|
+
* type of action ("keyup" or "keydown" or "keypress") or false
|
187
|
+
*
|
188
|
+
* @type {boolean|string}
|
189
|
+
*/
|
190
|
+
_nextExpectedAction = false;
|
191
|
+
|
192
|
+
/**
|
193
|
+
* loop through the f keys, f1 to f19 and add them to the map
|
194
|
+
* programatically
|
195
|
+
*/
|
196
|
+
for (var i = 1; i < 20; ++i) {
|
197
|
+
_MAP[111 + i] = 'f' + i;
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* loop through to map numbers on the numeric keypad
|
202
|
+
*/
|
203
|
+
for (i = 0; i <= 9; ++i) {
|
204
|
+
_MAP[i + 96] = i;
|
205
|
+
}
|
206
|
+
|
207
|
+
/**
|
208
|
+
* cross browser add event method
|
209
|
+
*
|
210
|
+
* @param {Element|HTMLDocument} object
|
211
|
+
* @param {string} type
|
212
|
+
* @param {Function} callback
|
213
|
+
* @returns void
|
214
|
+
*/
|
215
|
+
function _addEvent(object, type, callback) {
|
216
|
+
if (object.addEventListener) {
|
217
|
+
object.addEventListener(type, callback, false);
|
218
|
+
return;
|
219
|
+
}
|
220
|
+
|
221
|
+
object.attachEvent('on' + type, callback);
|
222
|
+
}
|
223
|
+
|
224
|
+
/**
|
225
|
+
* takes the event and returns the key character
|
226
|
+
*
|
227
|
+
* @param {Event} e
|
228
|
+
* @return {string}
|
229
|
+
*/
|
230
|
+
function _characterFromEvent(e) {
|
231
|
+
|
232
|
+
// for keypress events we should return the character as is
|
233
|
+
if (e.type == 'keypress') {
|
234
|
+
var character = String.fromCharCode(e.which);
|
235
|
+
|
236
|
+
// if the shift key is not pressed then it is safe to assume
|
237
|
+
// that we want the character to be lowercase. this means if
|
238
|
+
// you accidentally have caps lock on then your key bindings
|
239
|
+
// will continue to work
|
240
|
+
//
|
241
|
+
// the only side effect that might not be desired is if you
|
242
|
+
// bind something like 'A' cause you want to trigger an
|
243
|
+
// event when capital A is pressed caps lock will no longer
|
244
|
+
// trigger the event. shift+a will though.
|
245
|
+
if (!e.shiftKey) {
|
246
|
+
character = character.toLowerCase();
|
247
|
+
}
|
248
|
+
|
249
|
+
return character;
|
250
|
+
}
|
251
|
+
|
252
|
+
// for non keypress events the special maps are needed
|
253
|
+
if (_MAP[e.which]) {
|
254
|
+
return _MAP[e.which];
|
255
|
+
}
|
256
|
+
|
257
|
+
if (_KEYCODE_MAP[e.which]) {
|
258
|
+
return _KEYCODE_MAP[e.which];
|
259
|
+
}
|
260
|
+
|
261
|
+
// if it is not in the special map
|
262
|
+
|
263
|
+
// with keydown and keyup events the character seems to always
|
264
|
+
// come in as an uppercase character whether you are pressing shift
|
265
|
+
// or not. we should make sure it is always lowercase for comparisons
|
266
|
+
return String.fromCharCode(e.which).toLowerCase();
|
267
|
+
}
|
268
|
+
|
269
|
+
/**
|
270
|
+
* checks if two arrays are equal
|
271
|
+
*
|
272
|
+
* @param {Array} modifiers1
|
273
|
+
* @param {Array} modifiers2
|
274
|
+
* @returns {boolean}
|
275
|
+
*/
|
276
|
+
function _modifiersMatch(modifiers1, modifiers2) {
|
277
|
+
return modifiers1.sort().join(',') === modifiers2.sort().join(',');
|
278
|
+
}
|
279
|
+
|
280
|
+
/**
|
281
|
+
* resets all sequence counters except for the ones passed in
|
282
|
+
*
|
283
|
+
* @param {Object} doNotReset
|
284
|
+
* @returns void
|
285
|
+
*/
|
286
|
+
function _resetSequences(doNotReset) {
|
287
|
+
doNotReset = doNotReset || {};
|
288
|
+
|
289
|
+
var activeSequences = false,
|
290
|
+
key;
|
291
|
+
|
292
|
+
for (key in _sequenceLevels) {
|
293
|
+
if (doNotReset[key]) {
|
294
|
+
activeSequences = true;
|
295
|
+
continue;
|
296
|
+
}
|
297
|
+
_sequenceLevels[key] = 0;
|
298
|
+
}
|
299
|
+
|
300
|
+
if (!activeSequences) {
|
301
|
+
_nextExpectedAction = false;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
|
305
|
+
/**
|
306
|
+
* finds all callbacks that match based on the keycode, modifiers,
|
307
|
+
* and action
|
308
|
+
*
|
309
|
+
* @param {string} character
|
310
|
+
* @param {Array} modifiers
|
311
|
+
* @param {Event|Object} e
|
312
|
+
* @param {string=} sequenceName - name of the sequence we are looking for
|
313
|
+
* @param {string=} combination
|
314
|
+
* @param {number=} level
|
315
|
+
* @returns {Array}
|
316
|
+
*/
|
317
|
+
function _getMatches(character, modifiers, e, sequenceName, combination, level) {
|
318
|
+
var i,
|
319
|
+
callback,
|
320
|
+
matches = [],
|
321
|
+
action = e.type;
|
322
|
+
|
323
|
+
// if there are no events related to this keycode
|
324
|
+
if (!_callbacks[character]) {
|
325
|
+
return [];
|
326
|
+
}
|
327
|
+
|
328
|
+
// if a modifier key is coming up on its own we should allow it
|
329
|
+
if (action == 'keyup' && _isModifier(character)) {
|
330
|
+
modifiers = [character];
|
331
|
+
}
|
332
|
+
|
333
|
+
// loop through all callbacks for the key that was pressed
|
334
|
+
// and see if any of them match
|
335
|
+
for (i = 0; i < _callbacks[character].length; ++i) {
|
336
|
+
callback = _callbacks[character][i];
|
337
|
+
|
338
|
+
// if a sequence name is not specified, but this is a sequence at
|
339
|
+
// the wrong level then move onto the next match
|
340
|
+
if (!sequenceName && callback.seq && _sequenceLevels[callback.seq] != callback.level) {
|
341
|
+
continue;
|
342
|
+
}
|
343
|
+
|
344
|
+
// if the action we are looking for doesn't match the action we got
|
345
|
+
// then we should keep going
|
346
|
+
if (action != callback.action) {
|
347
|
+
continue;
|
348
|
+
}
|
349
|
+
|
350
|
+
// if this is a keypress event and the meta key and control key
|
351
|
+
// are not pressed that means that we need to only look at the
|
352
|
+
// character, otherwise check the modifiers as well
|
353
|
+
//
|
354
|
+
// chrome will not fire a keypress if meta or control is down
|
355
|
+
// safari will fire a keypress if meta or meta+shift is down
|
356
|
+
// firefox will fire a keypress if meta or control is down
|
357
|
+
if ((action == 'keypress' && !e.metaKey && !e.ctrlKey) || _modifiersMatch(modifiers, callback.modifiers)) {
|
358
|
+
|
359
|
+
// when you bind a combination or sequence a second time it
|
360
|
+
// should overwrite the first one. if a sequenceName or
|
361
|
+
// combination is specified in this call it does just that
|
362
|
+
//
|
363
|
+
// @todo make deleting its own method?
|
364
|
+
var deleteCombo = !sequenceName && callback.combo == combination;
|
365
|
+
var deleteSequence = sequenceName && callback.seq == sequenceName && callback.level == level;
|
366
|
+
if (deleteCombo || deleteSequence) {
|
367
|
+
_callbacks[character].splice(i, 1);
|
368
|
+
}
|
369
|
+
|
370
|
+
matches.push(callback);
|
371
|
+
}
|
372
|
+
}
|
373
|
+
|
374
|
+
return matches;
|
375
|
+
}
|
376
|
+
|
377
|
+
/**
|
378
|
+
* takes a key event and figures out what the modifiers are
|
379
|
+
*
|
380
|
+
* @param {Event} e
|
381
|
+
* @returns {Array}
|
382
|
+
*/
|
383
|
+
function _eventModifiers(e) {
|
384
|
+
var modifiers = [];
|
385
|
+
|
386
|
+
if (e.shiftKey) {
|
387
|
+
modifiers.push('shift');
|
388
|
+
}
|
389
|
+
|
390
|
+
if (e.altKey) {
|
391
|
+
modifiers.push('alt');
|
392
|
+
}
|
393
|
+
|
394
|
+
if (e.ctrlKey) {
|
395
|
+
modifiers.push('ctrl');
|
396
|
+
}
|
397
|
+
|
398
|
+
if (e.metaKey) {
|
399
|
+
modifiers.push('meta');
|
400
|
+
}
|
401
|
+
|
402
|
+
return modifiers;
|
403
|
+
}
|
404
|
+
|
405
|
+
/**
|
406
|
+
* prevents default for this event
|
407
|
+
*
|
408
|
+
* @param {Event} e
|
409
|
+
* @returns void
|
410
|
+
*/
|
411
|
+
function _preventDefault(e) {
|
412
|
+
if (e.preventDefault) {
|
413
|
+
e.preventDefault();
|
414
|
+
return;
|
415
|
+
}
|
416
|
+
|
417
|
+
e.returnValue = false;
|
418
|
+
}
|
419
|
+
|
420
|
+
/**
|
421
|
+
* stops propogation for this event
|
422
|
+
*
|
423
|
+
* @param {Event} e
|
424
|
+
* @returns void
|
425
|
+
*/
|
426
|
+
function _stopPropagation(e) {
|
427
|
+
if (e.stopPropagation) {
|
428
|
+
e.stopPropagation();
|
429
|
+
return;
|
430
|
+
}
|
431
|
+
|
432
|
+
e.cancelBubble = true;
|
433
|
+
}
|
434
|
+
|
435
|
+
/**
|
436
|
+
* actually calls the callback function
|
437
|
+
*
|
438
|
+
* if your callback function returns false this will use the jquery
|
439
|
+
* convention - prevent default and stop propogation on the event
|
440
|
+
*
|
441
|
+
* @param {Function} callback
|
442
|
+
* @param {Event} e
|
443
|
+
* @returns void
|
444
|
+
*/
|
445
|
+
function _fireCallback(callback, e, combo, sequence) {
|
446
|
+
|
447
|
+
// if this event should not happen stop here
|
448
|
+
if (Mousetrap.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
|
449
|
+
return;
|
450
|
+
}
|
451
|
+
|
452
|
+
if (callback(e, combo) === false) {
|
453
|
+
_preventDefault(e);
|
454
|
+
_stopPropagation(e);
|
455
|
+
}
|
456
|
+
}
|
457
|
+
|
458
|
+
/**
|
459
|
+
* handles a character key event
|
460
|
+
*
|
461
|
+
* @param {string} character
|
462
|
+
* @param {Array} modifiers
|
463
|
+
* @param {Event} e
|
464
|
+
* @returns void
|
465
|
+
*/
|
466
|
+
function _handleKey(character, modifiers, e) {
|
467
|
+
var callbacks = _getMatches(character, modifiers, e),
|
468
|
+
i,
|
469
|
+
doNotReset = {},
|
470
|
+
maxLevel = 0,
|
471
|
+
processedSequenceCallback = false;
|
472
|
+
|
473
|
+
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
|
474
|
+
for (i = 0; i < callbacks.length; ++i) {
|
475
|
+
if (callbacks[i].seq) {
|
476
|
+
maxLevel = Math.max(maxLevel, callbacks[i].level);
|
477
|
+
}
|
478
|
+
}
|
479
|
+
|
480
|
+
// loop through matching callbacks for this key event
|
481
|
+
for (i = 0; i < callbacks.length; ++i) {
|
482
|
+
|
483
|
+
// fire for all sequence callbacks
|
484
|
+
// this is because if for example you have multiple sequences
|
485
|
+
// bound such as "g i" and "g t" they both need to fire the
|
486
|
+
// callback for matching g cause otherwise you can only ever
|
487
|
+
// match the first one
|
488
|
+
if (callbacks[i].seq) {
|
489
|
+
|
490
|
+
// only fire callbacks for the maxLevel to prevent
|
491
|
+
// subsequences from also firing
|
492
|
+
//
|
493
|
+
// for example 'a option b' should not cause 'option b' to fire
|
494
|
+
// even though 'option b' is part of the other sequence
|
495
|
+
//
|
496
|
+
// any sequences that do not match here will be discarded
|
497
|
+
// below by the _resetSequences call
|
498
|
+
if (callbacks[i].level != maxLevel) {
|
499
|
+
continue;
|
500
|
+
}
|
501
|
+
|
502
|
+
processedSequenceCallback = true;
|
503
|
+
|
504
|
+
// keep a list of which sequences were matches for later
|
505
|
+
doNotReset[callbacks[i].seq] = 1;
|
506
|
+
_fireCallback(callbacks[i].callback, e, callbacks[i].combo, callbacks[i].seq);
|
507
|
+
continue;
|
508
|
+
}
|
509
|
+
|
510
|
+
// if there were no sequence matches but we are still here
|
511
|
+
// that means this is a regular match so we should fire that
|
512
|
+
if (!processedSequenceCallback) {
|
513
|
+
_fireCallback(callbacks[i].callback, e, callbacks[i].combo);
|
514
|
+
}
|
515
|
+
}
|
516
|
+
|
517
|
+
// if the key you pressed matches the type of sequence without
|
518
|
+
// being a modifier (ie "keyup" or "keypress") then we should
|
519
|
+
// reset all sequences that were not matched by this event
|
520
|
+
//
|
521
|
+
// this is so, for example, if you have the sequence "h a t" and you
|
522
|
+
// type "h e a r t" it does not match. in this case the "e" will
|
523
|
+
// cause the sequence to reset
|
524
|
+
//
|
525
|
+
// modifier keys are ignored because you can have a sequence
|
526
|
+
// that contains modifiers such as "enter ctrl+space" and in most
|
527
|
+
// cases the modifier key will be pressed before the next key
|
528
|
+
//
|
529
|
+
// also if you have a sequence such as "ctrl+b a" then pressing the
|
530
|
+
// "b" key will trigger a "keypress" and a "keydown"
|
531
|
+
//
|
532
|
+
// the "keydown" is expected when there is a modifier, but the
|
533
|
+
// "keypress" ends up matching the _nextExpectedAction since it occurs
|
534
|
+
// after and that causes the sequence to reset
|
535
|
+
//
|
536
|
+
// we ignore keypresses in a sequence that directly follow a keydown
|
537
|
+
// for the same character
|
538
|
+
var ignoreThisKeypress = e.type == 'keypress' && _ignoreNextKeypress;
|
539
|
+
if (e.type == _nextExpectedAction && !_isModifier(character) && !ignoreThisKeypress) {
|
540
|
+
_resetSequences(doNotReset);
|
541
|
+
}
|
542
|
+
|
543
|
+
_ignoreNextKeypress = processedSequenceCallback && e.type == 'keydown';
|
544
|
+
}
|
545
|
+
|
546
|
+
/**
|
547
|
+
* handles a keydown event
|
548
|
+
*
|
549
|
+
* @param {Event} e
|
550
|
+
* @returns void
|
551
|
+
*/
|
552
|
+
function _handleKeyEvent(e) {
|
553
|
+
|
554
|
+
// normalize e.which for key events
|
555
|
+
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
|
556
|
+
if (typeof e.which !== 'number') {
|
557
|
+
e.which = e.keyCode;
|
558
|
+
}
|
559
|
+
|
560
|
+
var character = _characterFromEvent(e);
|
561
|
+
|
562
|
+
// no character found then stop
|
563
|
+
if (!character) {
|
564
|
+
return;
|
565
|
+
}
|
566
|
+
|
567
|
+
// need to use === for the character check because the character can be 0
|
568
|
+
if (e.type == 'keyup' && _ignoreNextKeyup === character) {
|
569
|
+
_ignoreNextKeyup = false;
|
570
|
+
return;
|
571
|
+
}
|
572
|
+
|
573
|
+
Mousetrap.handleKey(character, _eventModifiers(e), e);
|
574
|
+
}
|
575
|
+
|
576
|
+
/**
|
577
|
+
* determines if the keycode specified is a modifier key or not
|
578
|
+
*
|
579
|
+
* @param {string} key
|
580
|
+
* @returns {boolean}
|
581
|
+
*/
|
582
|
+
function _isModifier(key) {
|
583
|
+
return key == 'shift' || key == 'ctrl' || key == 'alt' || key == 'meta';
|
584
|
+
}
|
585
|
+
|
586
|
+
/**
|
587
|
+
* called to set a 1 second timeout on the specified sequence
|
588
|
+
*
|
589
|
+
* this is so after each key press in the sequence you have 1 second
|
590
|
+
* to press the next key before you have to start over
|
591
|
+
*
|
592
|
+
* @returns void
|
593
|
+
*/
|
594
|
+
function _resetSequenceTimer() {
|
595
|
+
clearTimeout(_resetTimer);
|
596
|
+
_resetTimer = setTimeout(_resetSequences, 1000);
|
597
|
+
}
|
598
|
+
|
599
|
+
/**
|
600
|
+
* reverses the map lookup so that we can look for specific keys
|
601
|
+
* to see what can and can't use keypress
|
602
|
+
*
|
603
|
+
* @return {Object}
|
604
|
+
*/
|
605
|
+
function _getReverseMap() {
|
606
|
+
if (!_REVERSE_MAP) {
|
607
|
+
_REVERSE_MAP = {};
|
608
|
+
for (var key in _MAP) {
|
609
|
+
|
610
|
+
// pull out the numeric keypad from here cause keypress should
|
611
|
+
// be able to detect the keys from the character
|
612
|
+
if (key > 95 && key < 112) {
|
613
|
+
continue;
|
614
|
+
}
|
615
|
+
|
616
|
+
if (_MAP.hasOwnProperty(key)) {
|
617
|
+
_REVERSE_MAP[_MAP[key]] = key;
|
618
|
+
}
|
619
|
+
}
|
620
|
+
}
|
621
|
+
return _REVERSE_MAP;
|
622
|
+
}
|
623
|
+
|
624
|
+
/**
|
625
|
+
* picks the best action based on the key combination
|
626
|
+
*
|
627
|
+
* @param {string} key - character for key
|
628
|
+
* @param {Array} modifiers
|
629
|
+
* @param {string=} action passed in
|
630
|
+
*/
|
631
|
+
function _pickBestAction(key, modifiers, action) {
|
632
|
+
|
633
|
+
// if no action was picked in we should try to pick the one
|
634
|
+
// that we think would work best for this key
|
635
|
+
if (!action) {
|
636
|
+
action = _getReverseMap()[key] ? 'keydown' : 'keypress';
|
637
|
+
}
|
638
|
+
|
639
|
+
// modifier keys don't work as expected with keypress,
|
640
|
+
// switch to keydown
|
641
|
+
if (action == 'keypress' && modifiers.length) {
|
642
|
+
action = 'keydown';
|
643
|
+
}
|
644
|
+
|
645
|
+
return action;
|
646
|
+
}
|
647
|
+
|
648
|
+
/**
|
649
|
+
* binds a key sequence to an event
|
650
|
+
*
|
651
|
+
* @param {string} combo - combo specified in bind call
|
652
|
+
* @param {Array} keys
|
653
|
+
* @param {Function} callback
|
654
|
+
* @param {string=} action
|
655
|
+
* @returns void
|
656
|
+
*/
|
657
|
+
function _bindSequence(combo, keys, callback, action) {
|
658
|
+
|
659
|
+
// start off by adding a sequence level record for this combination
|
660
|
+
// and setting the level to 0
|
661
|
+
_sequenceLevels[combo] = 0;
|
662
|
+
|
663
|
+
/**
|
664
|
+
* callback to increase the sequence level for this sequence and reset
|
665
|
+
* all other sequences that were active
|
666
|
+
*
|
667
|
+
* @param {string} nextAction
|
668
|
+
* @returns {Function}
|
669
|
+
*/
|
670
|
+
function _increaseSequence(nextAction) {
|
671
|
+
return function() {
|
672
|
+
_nextExpectedAction = nextAction;
|
673
|
+
++_sequenceLevels[combo];
|
674
|
+
_resetSequenceTimer();
|
675
|
+
};
|
676
|
+
}
|
677
|
+
|
678
|
+
/**
|
679
|
+
* wraps the specified callback inside of another function in order
|
680
|
+
* to reset all sequence counters as soon as this sequence is done
|
681
|
+
*
|
682
|
+
* @param {Event} e
|
683
|
+
* @returns void
|
684
|
+
*/
|
685
|
+
function _callbackAndReset(e) {
|
686
|
+
_fireCallback(callback, e, combo);
|
687
|
+
|
688
|
+
// we should ignore the next key up if the action is key down
|
689
|
+
// or keypress. this is so if you finish a sequence and
|
690
|
+
// release the key the final key will not trigger a keyup
|
691
|
+
if (action !== 'keyup') {
|
692
|
+
_ignoreNextKeyup = _characterFromEvent(e);
|
693
|
+
}
|
694
|
+
|
695
|
+
// weird race condition if a sequence ends with the key
|
696
|
+
// another sequence begins with
|
697
|
+
setTimeout(_resetSequences, 10);
|
698
|
+
}
|
699
|
+
|
700
|
+
// loop through keys one at a time and bind the appropriate callback
|
701
|
+
// function. for any key leading up to the final one it should
|
702
|
+
// increase the sequence. after the final, it should reset all sequences
|
703
|
+
//
|
704
|
+
// if an action is specified in the original bind call then that will
|
705
|
+
// be used throughout. otherwise we will pass the action that the
|
706
|
+
// next key in the sequence should match. this allows a sequence
|
707
|
+
// to mix and match keypress and keydown events depending on which
|
708
|
+
// ones are better suited to the key provided
|
709
|
+
for (var i = 0; i < keys.length; ++i) {
|
710
|
+
var isFinal = i + 1 === keys.length;
|
711
|
+
var wrappedCallback = isFinal ? _callbackAndReset : _increaseSequence(action || _getKeyInfo(keys[i + 1]).action);
|
712
|
+
_bindSingle(keys[i], wrappedCallback, action, combo, i);
|
713
|
+
}
|
714
|
+
}
|
715
|
+
|
716
|
+
/**
|
717
|
+
* Converts from a string key combination to an array
|
718
|
+
*
|
719
|
+
* @param {string} combination like "command+shift+l"
|
720
|
+
* @return {Array}
|
721
|
+
*/
|
722
|
+
function _keysFromString(combination) {
|
723
|
+
if (combination === '+') {
|
724
|
+
return ['+'];
|
725
|
+
}
|
726
|
+
|
727
|
+
return combination.split('+');
|
728
|
+
}
|
729
|
+
|
730
|
+
/**
|
731
|
+
* Gets info for a specific key combination
|
732
|
+
*
|
733
|
+
* @param {string} combination key combination ("command+s" or "a" or "*")
|
734
|
+
* @param {string=} action
|
735
|
+
* @returns {Object}
|
736
|
+
*/
|
737
|
+
function _getKeyInfo(combination, action) {
|
738
|
+
var keys,
|
739
|
+
key,
|
740
|
+
i,
|
741
|
+
modifiers = [];
|
742
|
+
|
743
|
+
// take the keys from this pattern and figure out what the actual
|
744
|
+
// pattern is all about
|
745
|
+
keys = _keysFromString(combination);
|
746
|
+
|
747
|
+
for (i = 0; i < keys.length; ++i) {
|
748
|
+
key = keys[i];
|
749
|
+
|
750
|
+
// normalize key names
|
751
|
+
if (_SPECIAL_ALIASES[key]) {
|
752
|
+
key = _SPECIAL_ALIASES[key];
|
753
|
+
}
|
754
|
+
|
755
|
+
// if this is not a keypress event then we should
|
756
|
+
// be smart about using shift keys
|
757
|
+
// this will only work for US keyboards however
|
758
|
+
if (action && action != 'keypress' && _SHIFT_MAP[key]) {
|
759
|
+
key = _SHIFT_MAP[key];
|
760
|
+
modifiers.push('shift');
|
761
|
+
}
|
762
|
+
|
763
|
+
// if this key is a modifier then add it to the list of modifiers
|
764
|
+
if (_isModifier(key)) {
|
765
|
+
modifiers.push(key);
|
766
|
+
}
|
767
|
+
}
|
768
|
+
|
769
|
+
// depending on what the key combination is
|
770
|
+
// we will try to pick the best event for it
|
771
|
+
action = _pickBestAction(key, modifiers, action);
|
772
|
+
|
773
|
+
return {
|
774
|
+
key: key,
|
775
|
+
modifiers: modifiers,
|
776
|
+
action: action
|
777
|
+
};
|
778
|
+
}
|
779
|
+
|
780
|
+
/**
|
781
|
+
* binds a single keyboard combination
|
782
|
+
*
|
783
|
+
* @param {string} combination
|
784
|
+
* @param {Function} callback
|
785
|
+
* @param {string=} action
|
786
|
+
* @param {string=} sequenceName - name of sequence if part of sequence
|
787
|
+
* @param {number=} level - what part of the sequence the command is
|
788
|
+
* @returns void
|
789
|
+
*/
|
790
|
+
function _bindSingle(combination, callback, action, sequenceName, level) {
|
791
|
+
|
792
|
+
// store a direct mapped reference for use with Mousetrap.trigger
|
793
|
+
_directMap[combination + ':' + action] = callback;
|
794
|
+
|
795
|
+
// make sure multiple spaces in a row become a single space
|
796
|
+
combination = combination.replace(/\s+/g, ' ');
|
797
|
+
|
798
|
+
var sequence = combination.split(' '),
|
799
|
+
info;
|
800
|
+
|
801
|
+
// if this pattern is a sequence of keys then run through this method
|
802
|
+
// to reprocess each pattern one key at a time
|
803
|
+
if (sequence.length > 1) {
|
804
|
+
_bindSequence(combination, sequence, callback, action);
|
805
|
+
return;
|
806
|
+
}
|
807
|
+
|
808
|
+
info = _getKeyInfo(combination, action);
|
809
|
+
|
810
|
+
// make sure to initialize array if this is the first time
|
811
|
+
// a callback is added for this key
|
812
|
+
_callbacks[info.key] = _callbacks[info.key] || [];
|
813
|
+
|
814
|
+
// remove an existing match if there is one
|
815
|
+
_getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level);
|
816
|
+
|
817
|
+
// add this call back to the array
|
818
|
+
// if it is a sequence put it at the beginning
|
819
|
+
// if not put it at the end
|
820
|
+
//
|
821
|
+
// this is important because the way these are processed expects
|
822
|
+
// the sequence ones to come first
|
823
|
+
_callbacks[info.key][sequenceName ? 'unshift' : 'push']({
|
824
|
+
callback: callback,
|
825
|
+
modifiers: info.modifiers,
|
826
|
+
action: info.action,
|
827
|
+
seq: sequenceName,
|
828
|
+
level: level,
|
829
|
+
combo: combination
|
830
|
+
});
|
831
|
+
}
|
832
|
+
|
833
|
+
/**
|
834
|
+
* binds multiple combinations to the same callback
|
835
|
+
*
|
836
|
+
* @param {Array} combinations
|
837
|
+
* @param {Function} callback
|
838
|
+
* @param {string|undefined} action
|
839
|
+
* @returns void
|
840
|
+
*/
|
841
|
+
function _bindMultiple(combinations, callback, action) {
|
842
|
+
for (var i = 0; i < combinations.length; ++i) {
|
843
|
+
_bindSingle(combinations[i], callback, action);
|
844
|
+
}
|
845
|
+
}
|
846
|
+
|
847
|
+
// start!
|
848
|
+
_addEvent(document, 'keypress', _handleKeyEvent);
|
849
|
+
_addEvent(document, 'keydown', _handleKeyEvent);
|
850
|
+
_addEvent(document, 'keyup', _handleKeyEvent);
|
851
|
+
|
852
|
+
var Mousetrap = {
|
853
|
+
|
854
|
+
/**
|
855
|
+
* binds an event to mousetrap
|
856
|
+
*
|
857
|
+
* can be a single key, a combination of keys separated with +,
|
858
|
+
* an array of keys, or a sequence of keys separated by spaces
|
859
|
+
*
|
860
|
+
* be sure to list the modifier keys first to make sure that the
|
861
|
+
* correct key ends up getting bound (the last key in the pattern)
|
862
|
+
*
|
863
|
+
* @param {string|Array} keys
|
864
|
+
* @param {Function} callback
|
865
|
+
* @param {string=} action - 'keypress', 'keydown', or 'keyup'
|
866
|
+
* @returns void
|
867
|
+
*/
|
868
|
+
bind: function(keys, callback, action) {
|
869
|
+
keys = keys instanceof Array ? keys : [keys];
|
870
|
+
_bindMultiple(keys, callback, action);
|
871
|
+
return this;
|
872
|
+
},
|
873
|
+
|
874
|
+
/**
|
875
|
+
* unbinds an event to mousetrap
|
876
|
+
*
|
877
|
+
* the unbinding sets the callback function of the specified key combo
|
878
|
+
* to an empty function and deletes the corresponding key in the
|
879
|
+
* _directMap dict.
|
880
|
+
*
|
881
|
+
* TODO: actually remove this from the _callbacks dictionary instead
|
882
|
+
* of binding an empty function
|
883
|
+
*
|
884
|
+
* the keycombo+action has to be exactly the same as
|
885
|
+
* it was defined in the bind method
|
886
|
+
*
|
887
|
+
* @param {string|Array} keys
|
888
|
+
* @param {string} action
|
889
|
+
* @returns void
|
890
|
+
*/
|
891
|
+
unbind: function(keys, action) {
|
892
|
+
return Mousetrap.bind(keys, function() {}, action);
|
893
|
+
},
|
894
|
+
|
895
|
+
/**
|
896
|
+
* triggers an event that has already been bound
|
897
|
+
*
|
898
|
+
* @param {string} keys
|
899
|
+
* @param {string=} action
|
900
|
+
* @returns void
|
901
|
+
*/
|
902
|
+
trigger: function(keys, action) {
|
903
|
+
if (_directMap[keys + ':' + action]) {
|
904
|
+
_directMap[keys + ':' + action]({}, keys);
|
905
|
+
}
|
906
|
+
return this;
|
907
|
+
},
|
908
|
+
|
909
|
+
/**
|
910
|
+
* resets the library back to its initial state. this is useful
|
911
|
+
* if you want to clear out the current keyboard shortcuts and bind
|
912
|
+
* new ones - for example if you switch to another page
|
913
|
+
*
|
914
|
+
* @returns void
|
915
|
+
*/
|
916
|
+
reset: function() {
|
917
|
+
_callbacks = {};
|
918
|
+
_directMap = {};
|
919
|
+
return this;
|
920
|
+
},
|
921
|
+
|
922
|
+
/**
|
923
|
+
* should we stop this event before firing off callbacks
|
924
|
+
*
|
925
|
+
* @param {Event} e
|
926
|
+
* @param {Element} element
|
927
|
+
* @return {boolean}
|
928
|
+
*/
|
929
|
+
stopCallback: function(e, element) {
|
930
|
+
|
931
|
+
// if the element has the class "mousetrap" then no need to stop
|
932
|
+
if ((' ' + element.className + ' ').indexOf(' mousetrap ') > -1) {
|
933
|
+
return false;
|
934
|
+
}
|
935
|
+
|
936
|
+
// stop for input, select, and textarea
|
937
|
+
return element.tagName == 'INPUT' || element.tagName == 'SELECT' || element.tagName == 'TEXTAREA' || element.isContentEditable;
|
938
|
+
},
|
939
|
+
|
940
|
+
/**
|
941
|
+
* exposes _handleKey publicly so it can be overwritten by extensions
|
942
|
+
*/
|
943
|
+
handleKey: _handleKey
|
944
|
+
};
|
945
|
+
|
946
|
+
// expose mousetrap to the global object
|
947
|
+
window.Mousetrap = Mousetrap;
|
948
|
+
|
949
|
+
// expose mousetrap as an AMD module
|
950
|
+
if (typeof define === 'function' && define.amd) {
|
951
|
+
define(Mousetrap);
|
952
|
+
}
|
953
|
+
}) (window, document);
|