think_feel_do_engine 3.10.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +54 -0
- data/Rakefile +49 -0
- data/app/assets/images/changing_actions.gif +0 -0
- data/app/assets/images/evaluating_thoughts.gif +0 -0
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/images/think_feel_do_engine/athletic_man.png +0 -0
- data/app/assets/images/think_feel_do_engine/favicon.ico +0 -0
- data/app/assets/images/think_feel_do_engine/head_with_gears.jpg +0 -0
- data/app/assets/images/think_feel_do_engine/professional_woman.png +0 -0
- data/app/assets/images/think_feel_do_engine/woman_with_wrench.png +0 -0
- data/app/assets/javascripts/think_feel_do_engine.js +32 -0
- data/app/assets/javascripts/think_feel_do_engine/activities/activity_tracker.js +386 -0
- data/app/assets/javascripts/think_feel_do_engine/activities/dailyBreakdown.js +407 -0
- data/app/assets/javascripts/think_feel_do_engine/activities/forms.js +81 -0
- data/app/assets/javascripts/think_feel_do_engine/activities/your_activities.js +28 -0
- data/app/assets/javascripts/think_feel_do_engine/assessments.js +14 -0
- data/app/assets/javascripts/think_feel_do_engine/coach/messages/new.js +13 -0
- data/app/assets/javascripts/think_feel_do_engine/coach/patient_dashboards/index.js +16 -0
- data/app/assets/javascripts/think_feel_do_engine/dateWrapper.js +7 -0
- data/app/assets/javascripts/think_feel_do_engine/devise/passwords/edit.js.erb +24 -0
- data/app/assets/javascripts/think_feel_do_engine/event_capture/init.js +68 -0
- data/app/assets/javascripts/think_feel_do_engine/feel/emotion_mood_viz.js +31 -0
- data/app/assets/javascripts/think_feel_do_engine/feel/emotions.js +450 -0
- data/app/assets/javascripts/think_feel_do_engine/feel/timeago.js +214 -0
- data/app/assets/javascripts/think_feel_do_engine/forms/multi_page.js.erb +22 -0
- data/app/assets/javascripts/think_feel_do_engine/forms/multi_page_thought.js.erb +41 -0
- data/app/assets/javascripts/think_feel_do_engine/forms/suggested_prompt.js +22 -0
- data/app/assets/javascripts/think_feel_do_engine/markdown_editor.js +13 -0
- data/app/assets/javascripts/think_feel_do_engine/media_access_events.js +35 -0
- data/app/assets/javascripts/think_feel_do_engine/messages.js +8 -0
- data/app/assets/javascripts/think_feel_do_engine/participants.js +12 -0
- data/app/assets/javascripts/think_feel_do_engine/responsive-table.js +75 -0
- data/app/assets/javascripts/think_feel_do_engine/scrollindicator.js +92 -0
- data/app/assets/javascripts/think_feel_do_engine/shared/detect_timeout.js +42 -0
- data/app/assets/javascripts/think_feel_do_engine/slideshows.js +14 -0
- data/app/assets/javascripts/think_feel_do_engine/stepped_care.js +53 -0
- data/app/assets/javascripts/think_feel_do_engine/task_status.js +19 -0
- data/app/assets/javascripts/think_feel_do_engine/thought_patterns/index.js.erb +17 -0
- data/app/assets/javascripts/think_feel_do_engine/thoughts/edit_bulk.js +12 -0
- data/app/assets/javascripts/think_feel_do_engine/thoughts/scThoughtTrackerMenuViz.js +346 -0
- data/app/assets/javascripts/think_feel_do_engine/thoughts/thought_viz.js +53 -0
- data/app/assets/javascripts/think_feel_do_engine/users.js +10 -0
- data/app/assets/javascripts/think_feel_do_engine/validate_social_sharing.js +60 -0
- data/app/assets/stylesheets/think_feel_do_engine.css +12 -0
- data/app/assets/stylesheets/think_feel_do_engine/activities.css.scss +15 -0
- data/app/assets/stylesheets/think_feel_do_engine/base.css.scss +691 -0
- data/app/assets/stylesheets/think_feel_do_engine/dataTables-overrides.css.scss +27 -0
- data/app/assets/stylesheets/think_feel_do_engine/mobile.css.scss +3 -0
- data/app/assets/stylesheets/think_feel_do_engine/print.css.scss +1 -0
- data/app/controllers/think_feel_do_engine/application_controller.rb +77 -0
- data/app/controllers/think_feel_do_engine/bit_maker/content_modules_controller.rb +115 -0
- data/app/controllers/think_feel_do_engine/bit_maker/content_providers_controller.rb +117 -0
- data/app/controllers/think_feel_do_engine/bit_maker/slides_controller.rb +168 -0
- data/app/controllers/think_feel_do_engine/bit_maker/slideshow_anchors_controller.rb +61 -0
- data/app/controllers/think_feel_do_engine/bit_maker/slideshows_controller.rb +93 -0
- data/app/controllers/think_feel_do_engine/coach/group_dashboard_controller.rb +18 -0
- data/app/controllers/think_feel_do_engine/coach/memberships_controller.rb +38 -0
- data/app/controllers/think_feel_do_engine/coach/messages_controller.rb +91 -0
- data/app/controllers/think_feel_do_engine/coach/participant_activities_visualizations_controller.rb +24 -0
- data/app/controllers/think_feel_do_engine/coach/participant_thoughts_visualizations_controller.rb +15 -0
- data/app/controllers/think_feel_do_engine/coach/patient_dashboards_controller.rb +70 -0
- data/app/controllers/think_feel_do_engine/coach/phq_assessments_controller.rb +94 -0
- data/app/controllers/think_feel_do_engine/coach/received_messages_controller.rb +45 -0
- data/app/controllers/think_feel_do_engine/coach/sent_messages_controller.rb +26 -0
- data/app/controllers/think_feel_do_engine/coach/site_messages_controller.rb +49 -0
- data/app/controllers/think_feel_do_engine/coach_dashboard_controller.rb +11 -0
- data/app/controllers/think_feel_do_engine/concerns/browser_detective.rb +26 -0
- data/app/controllers/think_feel_do_engine/concerns/navigator_enabled.rb +17 -0
- data/app/controllers/think_feel_do_engine/keep_alive_controller.rb +27 -0
- data/app/controllers/think_feel_do_engine/lesson_slides_controller.rb +98 -0
- data/app/controllers/think_feel_do_engine/lessons_controller.rb +128 -0
- data/app/controllers/think_feel_do_engine/manage/groups_controller.rb +29 -0
- data/app/controllers/think_feel_do_engine/manage/tasks_controller.rb +68 -0
- data/app/controllers/think_feel_do_engine/memberships_controller.rb +55 -0
- data/app/controllers/think_feel_do_engine/navigator_controller.rb +109 -0
- data/app/controllers/think_feel_do_engine/participant_data_controller.rb +83 -0
- data/app/controllers/think_feel_do_engine/participants/activities_controller.rb +62 -0
- data/app/controllers/think_feel_do_engine/participants/assessments_controller.rb +84 -0
- data/app/controllers/think_feel_do_engine/participants/lessons_controller.rb +28 -0
- data/app/controllers/think_feel_do_engine/participants/media_access_events_controller.rb +42 -0
- data/app/controllers/think_feel_do_engine/participants/passwords_controller.rb +33 -0
- data/app/controllers/think_feel_do_engine/participants/public_slides_controller.rb +11 -0
- data/app/controllers/think_feel_do_engine/participants/sessions_controller.rb +16 -0
- data/app/controllers/think_feel_do_engine/participants/task_status_controller.rb +29 -0
- data/app/controllers/think_feel_do_engine/participants/thoughts_controller.rb +28 -0
- data/app/controllers/think_feel_do_engine/password_entropy_bits_controller.rb +12 -0
- data/app/controllers/think_feel_do_engine/privacy_policies_controller.rb +15 -0
- data/app/controllers/think_feel_do_engine/quick_sign_ins_controller.rb +18 -0
- data/app/controllers/think_feel_do_engine/users/passwords_controller.rb +16 -0
- data/app/controllers/think_feel_do_engine/users/registrations_controller.rb +16 -0
- data/app/controllers/think_feel_do_engine/users/sessions_controller.rb +36 -0
- data/app/helpers/think_feel_do_engine/activities_helper.rb +53 -0
- data/app/helpers/think_feel_do_engine/application_helper.rb +24 -0
- data/app/helpers/think_feel_do_engine/brand_helper.rb +36 -0
- data/app/helpers/think_feel_do_engine/coach/activity_color_code_helper.rb +52 -0
- data/app/helpers/think_feel_do_engine/coach/dashboard_and_phq_table_helper.rb +93 -0
- data/app/helpers/think_feel_do_engine/coach/group_dashboard_helper.rb +156 -0
- data/app/helpers/think_feel_do_engine/coach/messages_helper.rb +35 -0
- data/app/helpers/think_feel_do_engine/coach/moods_and_phq_viz_helper.rb +23 -0
- data/app/helpers/think_feel_do_engine/coach/patient_dashboard_helper.rb +58 -0
- data/app/helpers/think_feel_do_engine/emotions_helper.rb +15 -0
- data/app/helpers/think_feel_do_engine/phq_assessment_helper.rb +14 -0
- data/app/helpers/think_feel_do_engine/presenters_helper.rb +8 -0
- data/app/helpers/think_feel_do_engine/slides_helper.rb +43 -0
- data/app/helpers/think_feel_do_engine/tasks_helper.rb +110 -0
- data/app/mailers/think_feel_do_engine/lesson_notification_mailer.rb +15 -0
- data/app/mailers/think_feel_do_engine/message_notifications.rb +21 -0
- data/app/mailers/think_feel_do_engine/site_message_mailer.rb +11 -0
- data/app/models/ability.rb +91 -0
- data/app/models/activity.rb +362 -0
- data/app/models/activity_type.rb +8 -0
- data/app/models/arm.rb +47 -0
- data/app/models/arm_validator.rb +11 -0
- data/app/models/available_content_module.rb +95 -0
- data/app/models/awake_period.rb +40 -0
- data/app/models/bit_core/slide_observer.rb +9 -0
- data/app/models/coach_assignment.rb +9 -0
- data/app/models/content_modules.rb +27 -0
- data/app/models/content_modules/lesson_module.rb +88 -0
- data/app/models/content_provider_decorator.rb +115 -0
- data/app/models/content_provider_policy.rb +6 -0
- data/app/models/content_providers/accomplished_activity_index_provider.rb +21 -0
- data/app/models/content_providers/activity_index_provider.rb +25 -0
- data/app/models/content_providers/augmented_thoughts_table_provider.rb +18 -0
- data/app/models/content_providers/awake_period_form.rb +67 -0
- data/app/models/content_providers/create_activity.rb +42 -0
- data/app/models/content_providers/edit_past_feel_provider.rb +8 -0
- data/app/models/content_providers/evaluate_thoughts_provider.rb +15 -0
- data/app/models/content_providers/fun_activity_checklist.rb +43 -0
- data/app/models/content_providers/harmful_thoughts_edit_form_provider.rb +31 -0
- data/app/models/content_providers/helpful_thoughts_index_provider.rb +31 -0
- data/app/models/content_providers/important_activity_checklist.rb +44 -0
- data/app/models/content_providers/index_past_feel_provider.rb +24 -0
- data/app/models/content_providers/input_new_activity_form.rb +28 -0
- data/app/models/content_providers/learn_lessons_index_provider.rb +55 -0
- data/app/models/content_providers/messages_index_provider.rb +64 -0
- data/app/models/content_providers/module_index_provider.rb +41 -0
- data/app/models/content_providers/new_complete_thought_form_provider.rb +26 -0
- data/app/models/content_providers/new_current_emotion_provider.rb +30 -0
- data/app/models/content_providers/new_current_feel_provider.rb +26 -0
- data/app/models/content_providers/new_harmful_thought_form_provider.rb +27 -0
- data/app/models/content_providers/new_message_form_provider.rb +61 -0
- data/app/models/content_providers/new_past_feel_provider.rb +26 -0
- data/app/models/content_providers/new_thought_form_provider.rb +26 -0
- data/app/models/content_providers/new_thoughts_form_provider.rb +26 -0
- data/app/models/content_providers/past_activity_form.rb +55 -0
- data/app/models/content_providers/past_activity_review_form.rb +36 -0
- data/app/models/content_providers/past_due_activities_viz.rb +40 -0
- data/app/models/content_providers/pleasurable_activity_index_provider.rb +20 -0
- data/app/models/content_providers/previous_planned_activities_provider.rb +35 -0
- data/app/models/content_providers/random_slide_provider.rb +14 -0
- data/app/models/content_providers/show_message_provider.rb +78 -0
- data/app/models/content_providers/thought_patterns_index_provider.rb +21 -0
- data/app/models/content_providers/thoughts_distortion_viz_provider.rb +22 -0
- data/app/models/content_providers/thoughts_table_provider.rb +17 -0
- data/app/models/content_providers/unhelpful_thoughts_list_provider.rb +67 -0
- data/app/models/content_providers/unhelpful_thoughts_reflection_provider.rb +26 -0
- data/app/models/content_providers/unplanned_activity_form.rb +35 -0
- data/app/models/content_providers/your_activities_provider.rb +94 -0
- data/app/models/delivered_message.rb +59 -0
- data/app/models/emotion.rb +30 -0
- data/app/models/emotional_rating.rb +45 -0
- data/app/models/engagement.rb +7 -0
- data/app/models/group.rb +144 -0
- data/app/models/media_access_event.rb +24 -0
- data/app/models/membership.rb +199 -0
- data/app/models/message.rb +58 -0
- data/app/models/message_sms_notification.rb +45 -0
- data/app/models/mood.rb +31 -0
- data/app/models/participant.rb +355 -0
- data/app/models/participant_login_event.rb +6 -0
- data/app/models/participant_token.rb +32 -0
- data/app/models/phq_assessment.rb +55 -0
- data/app/models/phq_stepping.rb +325 -0
- data/app/models/phq_stepping_assessment.rb +96 -0
- data/app/models/planned_activity.rb +5 -0
- data/app/models/roles/clinician.rb +4 -0
- data/app/models/roles/content_author.rb +4 -0
- data/app/models/roles/researcher.rb +4 -0
- data/app/models/site_message.rb +6 -0
- data/app/models/slideshow_anchor.rb +16 -0
- data/app/models/task.rb +102 -0
- data/app/models/task_status.rb +94 -0
- data/app/models/think_feel_do_engine/addressable.rb +28 -0
- data/app/models/think_feel_do_engine/concerns/validate_password.rb +65 -0
- data/app/models/think_feel_do_engine/password_validator.rb +55 -0
- data/app/models/think_feel_do_engine/reports/emotional_rating.rb +23 -0
- data/app/models/think_feel_do_engine/reports/event.rb +26 -0
- data/app/models/think_feel_do_engine/reports/lesson_module.rb +47 -0
- data/app/models/think_feel_do_engine/reports/lesson_slide_view.rb +94 -0
- data/app/models/think_feel_do_engine/reports/lesson_viewing.rb +64 -0
- data/app/models/think_feel_do_engine/reports/login.rb +22 -0
- data/app/models/think_feel_do_engine/reports/messaging.rb +109 -0
- data/app/models/think_feel_do_engine/reports/module_page_view.rb +57 -0
- data/app/models/think_feel_do_engine/reports/module_session.rb +130 -0
- data/app/models/think_feel_do_engine/reports/patient_activity.rb +22 -0
- data/app/models/think_feel_do_engine/reports/patient_thought.rb +22 -0
- data/app/models/think_feel_do_engine/reports/phq_assessment.rb +32 -0
- data/app/models/think_feel_do_engine/reports/reporter.rb +45 -0
- data/app/models/think_feel_do_engine/reports/site_session.rb +63 -0
- data/app/models/think_feel_do_engine/reports/task_completion.rb +30 -0
- data/app/models/think_feel_do_engine/reports/tool_access.rb +51 -0
- data/app/models/think_feel_do_engine/reports/tool_module.rb +29 -0
- data/app/models/think_feel_do_engine/reports/user_agent.rb +33 -0
- data/app/models/think_feel_do_engine/reports/video_session.rb +65 -0
- data/app/models/think_feel_do_engine/reports/wai_assessment.rb +35 -0
- data/app/models/thought.rb +80 -0
- data/app/models/thought_pattern.rb +6 -0
- data/app/models/tool_nav_item.rb +65 -0
- data/app/models/tools/home.rb +5 -0
- data/app/models/tools/learn.rb +5 -0
- data/app/models/tools/messages.rb +5 -0
- data/app/models/tools/think.rb +5 -0
- data/app/models/unplanned_activities.rb +47 -0
- data/app/models/user.rb +55 -0
- data/app/models/user_role.rb +18 -0
- data/app/models/values/accomplishment.rb +23 -0
- data/app/models/values/emotional_rating.rb +23 -0
- data/app/models/values/mood.rb +22 -0
- data/app/models/values/pleasure.rb +23 -0
- data/app/models/wai_assessment.rb +30 -0
- data/app/presenters/think_feel_do_engine/harmful_thought_viz_presenter.rb +30 -0
- data/app/presenters/think_feel_do_engine/lesson_event/completion_data_presenter.rb +41 -0
- data/app/presenters/think_feel_do_engine/media_access_event_presenter.rb +54 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/devise/passwords/edit.html.erb +35 -0
- data/app/views/devise/passwords/new.html.erb +17 -0
- data/app/views/devise/sessions/new.html.erb +50 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/layouts/phq_assessment_mailer.html.erb +87 -0
- data/app/views/slides/show.html.erb +2 -0
- data/app/views/think_feel_do_engine/activities/_activity.html.erb +18 -0
- data/app/views/think_feel_do_engine/activities/_activity_coach_view.html.erb +6 -0
- data/app/views/think_feel_do_engine/activities/_activity_coach_view_future.html.erb +13 -0
- data/app/views/think_feel_do_engine/activities/_activity_coach_view_past.html.erb +21 -0
- data/app/views/think_feel_do_engine/activities/_activity_form_fields.html.erb +21 -0
- data/app/views/think_feel_do_engine/activities/_build_activity.html.erb +107 -0
- data/app/views/think_feel_do_engine/activities/_daily_summary.html.erb +121 -0
- data/app/views/think_feel_do_engine/activities/_intensity_selector.html.erb +25 -0
- data/app/views/think_feel_do_engine/activities/_mutable_activity.html.erb +14 -0
- data/app/views/think_feel_do_engine/activities/_past_due_activities_index_viz.html.erb +25 -0
- data/app/views/think_feel_do_engine/activities/_past_due_rows.erb +7 -0
- data/app/views/think_feel_do_engine/activities/_past_due_table.erb +39 -0
- data/app/views/think_feel_do_engine/activities/_previously_planned.html.erb +9 -0
- data/app/views/think_feel_do_engine/activities/accomplished_index.html.erb +84 -0
- data/app/views/think_feel_do_engine/activities/create_activity.html.erb +5 -0
- data/app/views/think_feel_do_engine/activities/fun_activity_checklist.html.erb +5 -0
- data/app/views/think_feel_do_engine/activities/important_activity_checklist.html.erb +5 -0
- data/app/views/think_feel_do_engine/activities/index.html.erb +81 -0
- data/app/views/think_feel_do_engine/activities/input_new_activity_form.html.erb +64 -0
- data/app/views/think_feel_do_engine/activities/past_activity_form.html.erb +75 -0
- data/app/views/think_feel_do_engine/activities/past_activity_review.html.erb +104 -0
- data/app/views/think_feel_do_engine/activities/pleasurable_index.html.erb +84 -0
- data/app/views/think_feel_do_engine/activities/previously_planned_fullpage.html.erb +12 -0
- data/app/views/think_feel_do_engine/activities/unplanned_activity_form.html.erb +21 -0
- data/app/views/think_feel_do_engine/activities/visualization.html.erb +120 -0
- data/app/views/think_feel_do_engine/assigned_tasks/show.html.erb +1 -0
- data/app/views/think_feel_do_engine/awake_periods/incomplete.html.erb +13 -0
- data/app/views/think_feel_do_engine/awake_periods/new.html.erb +34 -0
- data/app/views/think_feel_do_engine/bit_maker/content_modules/_form.html.erb +24 -0
- data/app/views/think_feel_do_engine/bit_maker/content_modules/edit.html.erb +9 -0
- data/app/views/think_feel_do_engine/bit_maker/content_modules/index.html.erb +38 -0
- data/app/views/think_feel_do_engine/bit_maker/content_modules/new.html.erb +9 -0
- data/app/views/think_feel_do_engine/bit_maker/content_modules/show.html.erb +27 -0
- data/app/views/think_feel_do_engine/bit_maker/content_providers/_form.html.erb +48 -0
- data/app/views/think_feel_do_engine/bit_maker/content_providers/edit.html.erb +12 -0
- data/app/views/think_feel_do_engine/bit_maker/content_providers/index.html.erb +36 -0
- data/app/views/think_feel_do_engine/bit_maker/content_providers/new.html.erb +12 -0
- data/app/views/think_feel_do_engine/bit_maker/content_providers/show.html.erb +42 -0
- data/app/views/think_feel_do_engine/bit_maker/slides/_fields.html.erb +212 -0
- data/app/views/think_feel_do_engine/bit_maker/slides/_slide.html.erb +23 -0
- data/app/views/think_feel_do_engine/bit_maker/slides/edit.html.erb +9 -0
- data/app/views/think_feel_do_engine/bit_maker/slides/index.html.erb +6 -0
- data/app/views/think_feel_do_engine/bit_maker/slides/new.html.erb +6 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshow_anchors/create.js.erb +2 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshow_anchors/destroy.js.erb +2 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/_fields.html +4 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/_slide_panel.html.erb +12 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/_toc_panel.html.erb +5 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/edit.html.erb +7 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/index.html.erb +42 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/new.html.erb +6 -0
- data/app/views/think_feel_do_engine/bit_maker/slideshows/show.html.erb +31 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_activities_future.html.erb +69 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_activities_past.html.erb +75 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_comments.html.erb +63 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_goals.html.erb +71 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_learning_lesson_row.html.erb +5 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_lesson_completion_breakdown.html.erb +33 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_lessons.html.erb +21 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_likes.html.erb +63 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_logins.html.erb +24 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_on_my_mind_statements.html.erb +66 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_summary.html.erb +30 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_summary_social.html.erb +24 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/_thoughts.html.erb +67 -0
- data/app/views/think_feel_do_engine/coach/group_dashboard/index.html.erb +50 -0
- data/app/views/think_feel_do_engine/coach/messages/index.html.erb +50 -0
- data/app/views/think_feel_do_engine/coach/messages/new.html.erb +32 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_active_patient.html.erb +104 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_details.html.erb +54 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_header.html.erb +5 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_inactive_patient.html.erb +34 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_mood_emotion_viz.html.erb +6 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_not_stepped_table.html.erb +36 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_phq_summary.html.erb +61 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_stepped_table.html.erb +35 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_table_of_contents.html.erb +20 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_test_summary.html.erb +39 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/_vizs.html.erb +73 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/index.html.erb +20 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/show.html.erb +23 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_audio_access_table.html.erb +49 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_feelings_table.html.erb +48 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_future_activities_table.html.erb +66 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_lessons_table.html.erb +56 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_logins_table.html.erb +47 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_messages_table.html.erb +46 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_mood_table.html.erb +46 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_past_activities_table.html.erb +70 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_patient_info.html.erb +39 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_patient_login_stats.html.erb +51 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_phq9_data.html.erb +47 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_summary_totals.html.erb +49 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_tasks_table.html.erb +47 -0
- data/app/views/think_feel_do_engine/coach/patient_dashboards/tables/_thoughts_table.html.erb +49 -0
- data/app/views/think_feel_do_engine/coach/phq_assessments/_form.html.erb +42 -0
- data/app/views/think_feel_do_engine/coach/phq_assessments/edit.html.erb +3 -0
- data/app/views/think_feel_do_engine/coach/phq_assessments/index.html.erb +43 -0
- data/app/views/think_feel_do_engine/coach/phq_assessments/new.html.erb +3 -0
- data/app/views/think_feel_do_engine/coach/received_messages/_received_message.html.erb +5 -0
- data/app/views/think_feel_do_engine/coach/site_messages/_form.html.erb +38 -0
- data/app/views/think_feel_do_engine/coach/site_messages/index.html.erb +30 -0
- data/app/views/think_feel_do_engine/coach/site_messages/new.html.erb +3 -0
- data/app/views/think_feel_do_engine/coach/site_messages/show.html.erb +16 -0
- data/app/views/think_feel_do_engine/emotions/_emotion_coach_view.html.erb +8 -0
- data/app/views/think_feel_do_engine/emotions/_form.html.erb +28 -0
- data/app/views/think_feel_do_engine/emotions/index.html.erb +75 -0
- data/app/views/think_feel_do_engine/emotions/new_current.html.erb +30 -0
- data/app/views/think_feel_do_engine/learn/_completion_data.html.erb +28 -0
- data/app/views/think_feel_do_engine/learn/lessons_index.html.erb +72 -0
- data/app/views/think_feel_do_engine/lesson_notification_mailer/lesson_notification_email.html.erb +82 -0
- data/app/views/think_feel_do_engine/lesson_notification_mailer/lesson_notification_email.text.erb +10 -0
- data/app/views/think_feel_do_engine/lesson_slides/_audio.html.erb +1 -0
- data/app/views/think_feel_do_engine/lesson_slides/_video.html.erb +4 -0
- data/app/views/think_feel_do_engine/lesson_slides/edit.html.erb +7 -0
- data/app/views/think_feel_do_engine/lesson_slides/new.html.erb +6 -0
- data/app/views/think_feel_do_engine/lesson_slides/show.html.erb +21 -0
- data/app/views/think_feel_do_engine/lessons/_form.html.erb +8 -0
- data/app/views/think_feel_do_engine/lessons/_lesson.html.erb +6 -0
- data/app/views/think_feel_do_engine/lessons/all_content.html.erb +12 -0
- data/app/views/think_feel_do_engine/lessons/edit.html.erb +8 -0
- data/app/views/think_feel_do_engine/lessons/index.html.erb +36 -0
- data/app/views/think_feel_do_engine/lessons/new.html.erb +8 -0
- data/app/views/think_feel_do_engine/lessons/show.html.erb +30 -0
- data/app/views/think_feel_do_engine/login_events/_login_event.html.erb +6 -0
- data/app/views/think_feel_do_engine/manage/groups/_assigned_task_cell.html.erb +16 -0
- data/app/views/think_feel_do_engine/manage/groups/edit_tasks.html.erb +83 -0
- data/app/views/think_feel_do_engine/manage/groups/index.html.erb +19 -0
- data/app/views/think_feel_do_engine/manage/tasks/index.html.erb +24 -0
- data/app/views/think_feel_do_engine/media_access_events/_access_data.html.erb +24 -0
- data/app/views/think_feel_do_engine/memberships/update.js.erb +4 -0
- data/app/views/think_feel_do_engine/message_notifications/new_for_coach.html.erb +93 -0
- data/app/views/think_feel_do_engine/message_notifications/new_for_coach.text.erb +3 -0
- data/app/views/think_feel_do_engine/message_notifications/new_for_participant.html.erb +93 -0
- data/app/views/think_feel_do_engine/message_notifications/new_for_participant.text.erb +3 -0
- data/app/views/think_feel_do_engine/messages/_message.html.erb +7 -0
- data/app/views/think_feel_do_engine/messages/_message_info.html.erb +9 -0
- data/app/views/think_feel_do_engine/messages/index.html.erb +54 -0
- data/app/views/think_feel_do_engine/messages/new.html.erb +34 -0
- data/app/views/think_feel_do_engine/messages/not_found.html.erb +3 -0
- data/app/views/think_feel_do_engine/messages/show.html.erb +27 -0
- data/app/views/think_feel_do_engine/moods/_mood.html.erb +7 -0
- data/app/views/think_feel_do_engine/moods/new_current.html.erb +18 -0
- data/app/views/think_feel_do_engine/moods/new_past_mood.html.erb +28 -0
- data/app/views/think_feel_do_engine/navigator/_before_content.html.erb +5 -0
- data/app/views/think_feel_do_engine/navigator/show_content.html.erb +14 -0
- data/app/views/think_feel_do_engine/participant_data/create.js.erb +1 -0
- data/app/views/think_feel_do_engine/participant_data/update.js.erb +1 -0
- data/app/views/think_feel_do_engine/participants/activities/create.js.erb +5 -0
- data/app/views/think_feel_do_engine/participants/assessments/new_phq_assessment.html.erb +77 -0
- data/app/views/think_feel_do_engine/participants/assessments/new_wai_assessment.html.erb +51 -0
- data/app/views/think_feel_do_engine/participants/assessments/success.html +1 -0
- data/app/views/think_feel_do_engine/participants/content_modules/index.html.erb +36 -0
- data/app/views/think_feel_do_engine/participants/lessons/_printable.html.erb +15 -0
- data/app/views/think_feel_do_engine/participants/lessons/show.html.erb +1 -0
- data/app/views/think_feel_do_engine/participants/messages/_inbox_header.html.erb +1 -0
- data/app/views/think_feel_do_engine/participants/public_slides/show.html.erb +8 -0
- data/app/views/think_feel_do_engine/participants/received_messages/_received_message.html.erb +1 -0
- data/app/views/think_feel_do_engine/participants/thoughts/create.js.erb +24 -0
- data/app/views/think_feel_do_engine/phq_assessments/_phq_assessment.html.erb +15 -0
- data/app/views/think_feel_do_engine/privacy_policies/show.html.erb +17 -0
- data/app/views/think_feel_do_engine/shared/_alerts.html.erb +17 -0
- data/app/views/think_feel_do_engine/shared/_authentication.html.erb +5 -0
- data/app/views/think_feel_do_engine/shared/_email_head.html.erb +771 -0
- data/app/views/think_feel_do_engine/shared/_footer.html.erb +21 -0
- data/app/views/think_feel_do_engine/shared/_head.html.erb +14 -0
- data/app/views/think_feel_do_engine/shared/_home.html.erb +4 -0
- data/app/views/think_feel_do_engine/shared/_jplayer.html.erb +48 -0
- data/app/views/think_feel_do_engine/shared/_rating_selector.html.erb +16 -0
- data/app/views/think_feel_do_engine/shared/participant/_hamburger_nav_items.html.erb +19 -0
- data/app/views/think_feel_do_engine/shared/participant/_nav_items.html.erb +49 -0
- data/app/views/think_feel_do_engine/shared/participant/_navbar.html.erb +38 -0
- data/app/views/think_feel_do_engine/shared/user/_navbar.html.erb +25 -0
- data/app/views/think_feel_do_engine/site_message_mailer/general.html.erb +8 -0
- data/app/views/think_feel_do_engine/site_message_mailer/general.text.erb +3 -0
- data/app/views/think_feel_do_engine/slides/_audio.html.erb +4 -0
- data/app/views/think_feel_do_engine/slides/_slide.html.erb +18 -0
- data/app/views/think_feel_do_engine/slides/_table_of_contents.html.erb +24 -0
- data/app/views/think_feel_do_engine/slides/_video.html.erb +34 -0
- data/app/views/think_feel_do_engine/slides/homepage.html.erb +29 -0
- data/app/views/think_feel_do_engine/slides/show.html.erb +11 -0
- data/app/views/think_feel_do_engine/slides/sort.js.erb +1 -0
- data/app/views/think_feel_do_engine/slides/sort_with_reload.js.erb +1 -0
- data/app/views/think_feel_do_engine/task_statuses/_task_status.html.erb +8 -0
- data/app/views/think_feel_do_engine/thought_patterns/evaluating.html.erb +2 -0
- data/app/views/think_feel_do_engine/thought_patterns/index.html.erb +8 -0
- data/app/views/think_feel_do_engine/thoughts/_form.html.erb +11 -0
- data/app/views/think_feel_do_engine/thoughts/_harmful_thought.html.erb +4 -0
- data/app/views/think_feel_do_engine/thoughts/_mutable_thought.html.erb +23 -0
- data/app/views/think_feel_do_engine/thoughts/_thought.html.erb +10 -0
- data/app/views/think_feel_do_engine/thoughts/_thought_effects.html.erb +1 -0
- data/app/views/think_feel_do_engine/thoughts/_thought_patterns.html.erb +7 -0
- data/app/views/think_feel_do_engine/thoughts/distortion_viz.html.erb +28 -0
- data/app/views/think_feel_do_engine/thoughts/edit_bulk.html.erb +43 -0
- data/app/views/think_feel_do_engine/thoughts/index.html.erb +24 -0
- data/app/views/think_feel_do_engine/thoughts/new.html.erb +5 -0
- data/app/views/think_feel_do_engine/thoughts/new_bulk.html.erb +36 -0
- data/app/views/think_feel_do_engine/thoughts/new_complete.html.erb +28 -0
- data/app/views/think_feel_do_engine/thoughts/new_harmful.html.erb +14 -0
- data/app/views/think_feel_do_engine/thoughts/thoughts_table.html.erb +60 -0
- data/app/views/think_feel_do_engine/thoughts/unhelpful_thoughts_form.html.erb +103 -0
- data/config/brakeman.ignore +206 -0
- data/config/brakeman.yml +5 -0
- data/config/initializers/datetime_formats.rb +32 -0
- data/config/initializers/devise.rb +272 -0
- data/config/initializers/event_capture.rb +43 -0
- data/config/initializers/think_feel_do_engine.rb +4 -0
- data/config/locales/devise.en.yml +60 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/rails_admin.en.yml +5 -0
- data/config/routes.rb +107 -0
- data/db/migrate/20140221174027_devise_create_users.rb +41 -0
- data/db/migrate/20140221182135_devise_create_participants.rb +28 -0
- data/db/migrate/20140221184614_create_groups.rb +29 -0
- data/db/migrate/20140221190256_create_memberships.rb +39 -0
- data/db/migrate/20140221201915_create_user_roles.rb +23 -0
- data/db/migrate/20140221204356_create_activity_types.rb +27 -0
- data/db/migrate/20140221211420_create_activities.rb +46 -0
- data/db/migrate/20140221214020_create_awake_periods.rb +29 -0
- data/db/migrate/20140223151355_create_slideshows.rb +12 -0
- data/db/migrate/20140223151505_create_slides.rb +33 -0
- data/db/migrate/20140224024338_create_content_modules.rb +12 -0
- data/db/migrate/20140224031252_create_content_providers.rb +34 -0
- data/db/migrate/20140224194936_require_titles_on_slides.rb +8 -0
- data/db/migrate/20140226174312_add_is_title_visible_to_slides.rb +8 -0
- data/db/migrate/20140226234059_drop_time_requirement_on_activities.rb +9 -0
- data/db/migrate/20140228042747_add_type_to_slides.rb +9 -0
- data/db/migrate/20140304020641_create_participant_statuses.rb +16 -0
- data/db/migrate/20140305134049_create_thoughts.rb +40 -0
- data/db/migrate/20140305204811_drop_extracted_bit_player_tables.rb +9 -0
- data/db/migrate/20140305220121_create_bit_player_content_modules.bit_player.rb +12 -0
- data/db/migrate/20140305220122_create_bit_player_content_providers.bit_player.rb +34 -0
- data/db/migrate/20140305233152_create_bit_player_participant_statuses.bit_player.rb +16 -0
- data/db/migrate/20140305235536_create_bit_player_slideshows.bit_player.rb +10 -0
- data/db/migrate/20140306000610_create_bit_player_slides.bit_player.rb +47 -0
- data/db/migrate/20140306161346_create_messages.rb +13 -0
- data/db/migrate/20140306161532_create_delivered_messages.rb +29 -0
- data/db/migrate/20140306175954_create_coach_assignments.rb +12 -0
- data/db/migrate/20140311172344_create_mood.rb +9 -0
- data/db/migrate/20140311182036_create_emotions.rb +10 -0
- data/db/migrate/20140311194313_add_column_activation_level_and_intensity_to_emotion.rb +9 -0
- data/db/migrate/20140313025147_create_thought_patterns.rb +10 -0
- data/db/migrate/20140313192408_add_pattern_id_to_thoughts.rb +22 -0
- data/db/migrate/20140313205806_add_name_to_emotions.rb +6 -0
- data/db/migrate/20140314203044_change_column_name_activation_level_to_valence.rb +8 -0
- data/db/migrate/20140318163703_create_group_slideshow_joins.rb +12 -0
- data/db/migrate/20140320183600_add_start_date_to_memberships.rb +5 -0
- data/db/migrate/20140326144359_create_phq_assessments.rb +39 -0
- data/db/migrate/20140326205140_create_participant_tokens.rb +32 -0
- data/db/migrate/20140331165739_add_end_date_to_memberships.rb +5 -0
- data/db/migrate/20140402151311_create_tasks.rb +11 -0
- data/db/migrate/20140402170153_add_creator_id_to_tasks.rb +5 -0
- data/db/migrate/20140407134214_create_task_statuses.rb +11 -0
- data/db/migrate/20140407150122_add_release_day_to_task_remove_is_completed_at_from_task.rb +6 -0
- data/db/migrate/20140407202026_create_bit_player_tools.bit_player.rb +14 -0
- data/db/migrate/20140407202027_change_module_context_to_tool.bit_player.rb +31 -0
- data/db/migrate/20140411184738_add_recurring_to_tasks.rb +5 -0
- data/db/migrate/20140411195557_add_question_and_explanation_to_thought_pattern.rb +6 -0
- data/db/migrate/20140411195804_add_challenging_thought_and_as_if_to_thought.rb +6 -0
- data/db/migrate/20140415165729_add_start_day_to_task_statuses.rb +5 -0
- data/db/migrate/20140418190852_remove_fk_groups_users_constraint.rb +21 -0
- data/db/migrate/20140421192355_change_start_date_on_membership_from_date_time_to_date.rb +9 -0
- data/db/migrate/20140501170217_add_is_admin_to_users.rb +5 -0
- data/db/migrate/20140501190812_add_participant_login_event.rb +9 -0
- data/db/migrate/20140502222145_add_is_admin_to_all_current_users.rb +15 -0
- data/db/migrate/20140505145843_add_study_id_to_participants.rb +5 -0
- data/db/migrate/20140523154605_delete_group_slideshow_join.rb +16 -0
- data/db/migrate/20140609181801_create_engagements.rb +10 -0
- data/db/migrate/20140620171824_create_bit_core_tools.bit_core.rb +29 -0
- data/db/migrate/20140620171825_create_bit_core_content_modules.bit_core.rb +41 -0
- data/db/migrate/20140620171826_create_bit_core_content_providers.bit_core.rb +43 -0
- data/db/migrate/20140620171827_create_bit_core_slideshows.bit_core.rb +10 -0
- data/db/migrate/20140620171828_create_bit_core_slides.bit_core.rb +44 -0
- data/db/migrate/20140620181933_add_options_to_slides.bit_core.rb +6 -0
- data/db/migrate/20140621023345_convert_slides_slideshows_to_bit_core.bit_player.rb +39 -0
- data/db/migrate/20140621024853_update_tasks_with_bit_core.rb +7 -0
- data/db/migrate/20140621024854_add_config_fields_to_providers.bit_core.rb +10 -0
- data/db/migrate/20140621031203_convert_tools_modules_presenters_to_bit_core.bit_player.rb +53 -0
- data/db/migrate/20140623182430_remove_valence_from_emotions.rb +5 -0
- data/db/migrate/20140624163655_rename_column_participant_id_on_emotions_to_creator_id.rb +5 -0
- data/db/migrate/20140624165438_create_emotional_ratings.rb +10 -0
- data/db/migrate/20140624165626_remove_rating_from_emotion_remove_intensity_from_emotion.rb +6 -0
- data/db/migrate/20140625133411_add_type_to_content_modules.bit_core.rb +6 -0
- data/db/migrate/20140625140629_convert_lesson_modules.rb +12 -0
- data/db/migrate/20140625140630_add_recommendations_to_thought_patterns.rb +5 -0
- data/db/migrate/20140702192100_create_content_provider_policies.rb +10 -0
- data/db/migrate/20140703203931_add_termination_day_to_tasks.rb +5 -0
- data/db/migrate/20140710122908_create_slideshow_anchors.rb +10 -0
- data/db/migrate/20140715170155_add_inactive_log_out_to_participant_login_event.rb +5 -0
- data/db/migrate/20140721190945_normalize_emotions.rb +18 -0
- data/db/migrate/20140722163946_add_thought_patterns.rb +83 -0
- data/db/migrate/20140722172101_add_missing_fk_constraints.rb +187 -0
- data/db/migrate/20140722195542_add_emotion_ids_to_orphaned_emotional_ratings.rb +12 -0
- data/db/migrate/20140725164219_add_is_monitored_to_activity.rb +5 -0
- data/db/migrate/20140725185012_add_participant_onload_log_out_to_login_event.rb +5 -0
- data/db/migrate/20140729151610_add_signed_out_at_to_participant_login_events.rb +5 -0
- data/db/migrate/20140729171907_remove_participant_on_load_log_out_from_login_event.rb +5 -0
- data/db/migrate/20140730202349_update_thought_patterns.rb +94 -0
- data/db/migrate/20140815190945_add_phq_edit_columns.rb +13 -0
- data/db/migrate/20140818202120_add_has_didactic_content_to_tasks.rb +5 -0
- data/db/migrate/20140821184357_add_is_scheduled_to_activities.rb +5 -0
- data/db/migrate/20140902204337_create_event_capture_events.event_capture.rb +14 -0
- data/db/migrate/20140903134021_add_participant_id_to_events.rb +23 -0
- data/db/migrate/20141027181511_add_phone_number_to_participant.rb +5 -0
- data/db/migrate/20141027181539_add_contact_status_to_participant.rb +5 -0
- data/db/migrate/20141110190545_create_site_messages.rb +29 -0
- data/db/migrate/20141121152018_create_arms.rb +8 -0
- data/db/migrate/20141121201238_add_arm_id_to_groups.rb +5 -0
- data/db/migrate/20141125194600_add_null_false_to_arms.rb +6 -0
- data/db/migrate/20141125202627_add_null_false_to_columns_and_associate_arm_group_join_arm_ids_to_groups.rb +5 -0
- data/db/migrate/20141201154255_add_arm_id_to_bit_core_tools.rb +9 -0
- data/db/migrate/20141201165610_change_column_bit_core_tools_arm_id_to_null.rb +5 -0
- data/db/migrate/20141202133320_remove_position_unique_constraint_from_tool.rb +21 -0
- data/db/migrate/20141202173321_add_arm_id_to_bit_core_slideshows.rb +5 -0
- data/db/migrate/20141202173458_change_column_bit_core_slideshows_to_null_false.rb +38 -0
- data/db/migrate/20141211140747_add_is_admin_.textClipping +0 -0
- data/db/migrate/20141211140747_add_is_admin_to_participants.rb +5 -0
- data/db/migrate/20141214203919_add_has_woz_to_arm.rb +5 -0
- data/db/migrate/20141222222717_change_default_contact_preference.rb +5 -0
- data/db/migrate/20150107183443_add_is_positive_to_emotion.rb +6 -0
- data/db/migrate/20150107192208_remove_is_positive_from_emotion.rb +5 -0
- data/db/migrate/20150107192402_add_is_positive_to_emotional_rating.rb +5 -0
- data/db/migrate/20150127204928_add_is_complete_to_membership.rb +5 -0
- data/db/migrate/20150127204950_add_is_stepped_to_membership.rb +5 -0
- data/db/migrate/20150128151059_change_is_stepped_membership_to_not_allow_null.rb +5 -0
- data/db/migrate/20150128151231_change_is_complete_membership_to_not_allow_null.rb +5 -0
- data/db/migrate/20150128151515_data_migration_add_values_for_is_stepped_and_is_complete.rb +11 -0
- data/db/migrate/20150128192928_destroy_invalid_task_statuses.rb +14 -0
- data/db/migrate/20150129160122_add_description_to_tools.rb +5 -0
- data/db/migrate/20150130160818_add_type_to_tools.bit_core.rb +6 -0
- data/db/migrate/20150130161629_convert_messages_tool_type.rb +7 -0
- data/db/migrate/20150130173324_convert_home_tool_type.rb +7 -0
- data/db/migrate/20150130185412_convert_learn_tool_type.rb +7 -0
- data/db/migrate/20150131200718_add_is_viz_to_content_modules.bit_core.rb +6 -0
- data/db/migrate/20150131201021_add_is_viz_flag_to_modules.rb +9 -0
- data/db/migrate/20150202203359_update_tool_type_columns.rb +23 -0
- data/db/migrate/20150202215540_fix_module_viz_columns.rb +9 -0
- data/db/migrate/20150202232642_prevent_null_membership_dates.rb +6 -0
- data/db/migrate/20150206221439_create_wai_assessments.rb +52 -0
- data/db/migrate/20150209195004_create_think_feel_do_engine_media_access_events.rb +12 -0
- data/db/migrate/20150209212556_add_stepped_on_column_to_memberships.rb +10 -0
- data/db/migrate/20150209213422_remove_is_stepped_column_from_memberships.rb +5 -0
- data/db/migrate/20150210142824_destroy_invalid_messages.rb +5 -0
- data/db/migrate/20150210153608_add_slide_reference_to_media_access_events.rb +8 -0
- data/db/migrate/20150210161100_add_missing_constraints.rb +43 -0
- data/db/migrate/20150210163220_add_fk_constraints_to_media_access_events.rb +21 -0
- data/db/migrate/20150210164226_add_slide_fk_contstraint_to_media_access_events.rb +21 -0
- data/db/migrate/20150210165021_add_tool_constraint.bit_core.rb +26 -0
- data/db/migrate/20150218184531_add_has_table_of_contents_to_slideshows.rb +9 -0
- data/db/migrate/20150225221700_add_is_reviewed_to_activities.rb +5 -0
- data/db/migrate/20150226210641_remove_is_monitored_from_activities.rb +5 -0
- data/db/migrate/20150227221640_remove_is_complete_from_activities.rb +5 -0
- data/db/migrate/20150302155709_remove_is_scheduled_from_activities.rb +5 -0
- data/db/migrate/20150307182155_create_available_content_modules_view.rb +46 -0
- data/db/migrate/20150310171015_update_available_content_modules_view.rb +48 -0
- data/db/migrate/20150410174157_add_can_message_after_membership_complete_to_arms.rb +5 -0
- data/db/migrate/20150410175659_populate_arm_message_flag.rb +7 -0
- data/db/migrate/20150810204045_nullify_empty_thoughts_columns.rb +15 -0
- data/db/migrate/20150903210028_add_relase_day_not_null_constraint_to_trask.rb +5 -0
- data/db/migrate/20151104152804_update_think_tool_type_to_tools_think.rb +9 -0
- data/lib/tasks/lesson_notifications.rake +66 -0
- data/lib/tasks/seed.rake +30 -0
- data/lib/tasks/think_feel_do_engine_tasks.rake +4 -0
- data/lib/think_feel_do_engine.rb +16 -0
- data/lib/think_feel_do_engine/engine.rb +16 -0
- data/lib/think_feel_do_engine/version.rb +4 -0
- data/vendor/assets/images/jplayer.blue.monday.jpg +0 -0
- data/vendor/assets/images/jplayer.blue.monday.seeking.gif +0 -0
- data/vendor/assets/images/jplayer.blue.monday.video.play.png +0 -0
- data/vendor/assets/javascripts/bootstrap-markdown.js +1347 -0
- data/vendor/assets/javascripts/bootstrap-timepicker.js +1097 -0
- data/vendor/assets/javascripts/d3.min.js +5 -0
- data/vendor/assets/javascripts/froogaloop.min.js +4 -0
- data/vendor/assets/javascripts/jplayer.2.9.2.min.js +1 -0
- data/vendor/assets/javascripts/moment.min.js +6 -0
- data/vendor/assets/javascripts/snap.js +568 -0
- data/vendor/assets/stylesheets/bootstrap-timepicker.min.css +10 -0
- data/vendor/assets/stylesheets/jplayer.blue.monday.css.scss +630 -0
- data/vendor/assets/stylesheets/snap.css.scss +80 -0
- metadata +949 -0
data/lib/tasks/seed.rake
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "active_record/fixtures"
|
2
|
+
|
3
|
+
module ActiveRecord
|
4
|
+
module ConnectionAdapters
|
5
|
+
class PostgreSQLAdapter < AbstractAdapter
|
6
|
+
# PostgreSQL only disables referential integrity when connection
|
7
|
+
# user is root and that is not the case.
|
8
|
+
def disable_referential_integrity
|
9
|
+
yield
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :seed do
|
16
|
+
desc "seed the database with fixtures from spec/fixtures"
|
17
|
+
task with_think_feel_do_engine_fixtures: :environment do
|
18
|
+
path = File.join(File.dirname(__FILE__), "..", "..", "spec", "fixtures")
|
19
|
+
ActiveRecord::FixtureSet.create_fixtures path, [
|
20
|
+
:arms, :participants, :"bit_core/slideshows", :"bit_core/slides",
|
21
|
+
:"bit_core/tools", :"bit_core/content_modules",
|
22
|
+
:"bit_core/content_providers", :content_provider_policies, :users, :user_roles, :activity_types,
|
23
|
+
:activities, :coach_assignments, :groups, :memberships, :messages,
|
24
|
+
:delivered_messages, :thought_patterns, :thoughts,
|
25
|
+
:tasks, :task_status, :moods, :phq_assessments, :emotions,
|
26
|
+
:emotional_ratings, :media_access_events, :awake_periods, :slideshow_anchors,
|
27
|
+
:"event_capture/events", :participant_login_events
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Devise must be required first to override views.
|
2
|
+
require "devise"
|
3
|
+
require "think_feel_do_engine/engine"
|
4
|
+
require "font-awesome-rails"
|
5
|
+
require "jquery-rails"
|
6
|
+
require "jquery-ui-rails"
|
7
|
+
require "bootstrap-sass"
|
8
|
+
require "underscore-rails"
|
9
|
+
require "turbolinks"
|
10
|
+
require "bit_core"
|
11
|
+
require "bit_player"
|
12
|
+
require "redcarpet"
|
13
|
+
|
14
|
+
# Top level namespace.
|
15
|
+
module ThinkFeelDoEngine
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module ThinkFeelDoEngine
|
2
|
+
# The mountable application engine.
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
isolate_namespace ThinkFeelDoEngine
|
5
|
+
|
6
|
+
config.to_prepare do
|
7
|
+
Devise::SessionsController.layout "think_feel_do_engine"
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer "think_feel_do_engine.action_controller" do
|
11
|
+
ActiveSupport.on_load :action_controller do
|
12
|
+
helper ThinkFeelDoEngine::TasksHelper
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,1347 @@
|
|
1
|
+
/* ===================================================
|
2
|
+
* bootstrap-markdown.js v2.8.0
|
3
|
+
* http://github.com/toopay/bootstrap-markdown
|
4
|
+
* ===================================================
|
5
|
+
* Copyright 2013-2014 Taufan Aditya
|
6
|
+
*
|
7
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
* you may not use this file except in compliance with the License.
|
9
|
+
* You may obtain a copy of the License at
|
10
|
+
*
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
*
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
* See the License for the specific language governing permissions and
|
17
|
+
* limitations under the License.
|
18
|
+
* ========================================================== */
|
19
|
+
|
20
|
+
!function ($) {
|
21
|
+
|
22
|
+
"use strict"; // jshint ;_;
|
23
|
+
|
24
|
+
/* MARKDOWN CLASS DEFINITION
|
25
|
+
* ========================== */
|
26
|
+
|
27
|
+
var Markdown = function (element, options) {
|
28
|
+
// @TODO : remove this BC on next major release
|
29
|
+
// @see : https://github.com/toopay/bootstrap-markdown/issues/109
|
30
|
+
var opts = ['autofocus', 'savable', 'hideable', 'width',
|
31
|
+
'height', 'resize', 'iconlibrary', 'language',
|
32
|
+
'footer', 'fullscreen', 'hiddenButtons', 'disabledButtons'];
|
33
|
+
$.each(opts,function(_, opt){
|
34
|
+
if (typeof $(element).data(opt) !== 'undefined') {
|
35
|
+
options = typeof options == 'object' ? options : {}
|
36
|
+
options[opt] = $(element).data(opt)
|
37
|
+
}
|
38
|
+
});
|
39
|
+
// End BC
|
40
|
+
|
41
|
+
// Class Properties
|
42
|
+
this.$ns = 'bootstrap-markdown';
|
43
|
+
this.$element = $(element);
|
44
|
+
this.$editable = {el:null, type:null,attrKeys:[], attrValues:[], content:null};
|
45
|
+
this.$options = $.extend(true, {}, $.fn.markdown.defaults, options, this.$element.data('options'));
|
46
|
+
this.$oldContent = null;
|
47
|
+
this.$isPreview = false;
|
48
|
+
this.$isFullscreen = false;
|
49
|
+
this.$editor = null;
|
50
|
+
this.$textarea = null;
|
51
|
+
this.$handler = [];
|
52
|
+
this.$callback = [];
|
53
|
+
this.$nextTab = [];
|
54
|
+
|
55
|
+
this.showEditor();
|
56
|
+
};
|
57
|
+
|
58
|
+
Markdown.prototype = {
|
59
|
+
|
60
|
+
constructor: Markdown
|
61
|
+
|
62
|
+
, __alterButtons: function(name,alter) {
|
63
|
+
var handler = this.$handler, isAll = (name == 'all'),that = this;
|
64
|
+
|
65
|
+
$.each(handler,function(k,v) {
|
66
|
+
var halt = true;
|
67
|
+
if (isAll) {
|
68
|
+
halt = false;
|
69
|
+
} else {
|
70
|
+
halt = v.indexOf(name) < 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
if (halt === false) {
|
74
|
+
alter(that.$editor.find('button[data-handler="'+v+'"]'));
|
75
|
+
}
|
76
|
+
});
|
77
|
+
}
|
78
|
+
|
79
|
+
, __buildButtons: function(buttonsArray, container) {
|
80
|
+
var i,
|
81
|
+
ns = this.$ns,
|
82
|
+
handler = this.$handler,
|
83
|
+
callback = this.$callback;
|
84
|
+
|
85
|
+
for (i=0;i<buttonsArray.length;i++) {
|
86
|
+
// Build each group container
|
87
|
+
var y, btnGroups = buttonsArray[i];
|
88
|
+
for (y=0;y<btnGroups.length;y++) {
|
89
|
+
// Build each button group
|
90
|
+
var z,
|
91
|
+
buttons = btnGroups[y].data,
|
92
|
+
btnGroupContainer = $('<div/>', {
|
93
|
+
'class': 'btn-group'
|
94
|
+
});
|
95
|
+
|
96
|
+
for (z=0;z<buttons.length;z++) {
|
97
|
+
var button = buttons[z],
|
98
|
+
buttonContainer, buttonIconContainer,
|
99
|
+
buttonHandler = ns+'-'+button.name,
|
100
|
+
buttonIcon = this.__getIcon(button.icon),
|
101
|
+
btnText = button.btnText ? button.btnText : '',
|
102
|
+
btnClass = button.btnClass ? button.btnClass : 'btn',
|
103
|
+
tabIndex = button.tabIndex ? button.tabIndex : '-1',
|
104
|
+
hotkey = typeof button.hotkey !== 'undefined' ? button.hotkey : '',
|
105
|
+
hotkeyCaption = typeof jQuery.hotkeys !== 'undefined' && hotkey !== '' ? ' ('+hotkey+')' : '';
|
106
|
+
|
107
|
+
// Construct the button object
|
108
|
+
buttonContainer = $('<button></button>');
|
109
|
+
buttonContainer.text(' ' + this.__localize(btnText)).addClass('btn-default btn-sm').addClass(btnClass);
|
110
|
+
if(btnClass.match(/btn\-(primary|success|info|warning|danger|link)/)){
|
111
|
+
buttonContainer.removeClass('btn-default');
|
112
|
+
}
|
113
|
+
buttonContainer.attr({
|
114
|
+
'type': 'button',
|
115
|
+
'title': this.__localize(button.title) + hotkeyCaption,
|
116
|
+
'tabindex': tabIndex,
|
117
|
+
'data-provider': ns,
|
118
|
+
'data-handler': buttonHandler,
|
119
|
+
'data-hotkey': hotkey
|
120
|
+
});
|
121
|
+
if (button.toggle === true){
|
122
|
+
buttonContainer.attr('data-toggle', 'button');
|
123
|
+
}
|
124
|
+
buttonIconContainer = $('<span/>');
|
125
|
+
buttonIconContainer.addClass(buttonIcon);
|
126
|
+
buttonIconContainer.prependTo(buttonContainer);
|
127
|
+
|
128
|
+
// Attach the button object
|
129
|
+
btnGroupContainer.append(buttonContainer);
|
130
|
+
|
131
|
+
// Register handler and callback
|
132
|
+
handler.push(buttonHandler);
|
133
|
+
callback.push(button.callback);
|
134
|
+
}
|
135
|
+
|
136
|
+
// Attach the button group into container dom
|
137
|
+
container.append(btnGroupContainer);
|
138
|
+
}
|
139
|
+
}
|
140
|
+
|
141
|
+
return container;
|
142
|
+
}
|
143
|
+
, __setListener: function() {
|
144
|
+
// Set size and resizable Properties
|
145
|
+
var hasRows = typeof this.$textarea.attr('rows') !== 'undefined',
|
146
|
+
maxRows = this.$textarea.val().split("\n").length > 5 ? this.$textarea.val().split("\n").length : '5',
|
147
|
+
rowsVal = hasRows ? this.$textarea.attr('rows') : maxRows;
|
148
|
+
|
149
|
+
this.$textarea.attr('rows',rowsVal);
|
150
|
+
if (this.$options.resize) {
|
151
|
+
this.$textarea.css('resize',this.$options.resize);
|
152
|
+
}
|
153
|
+
|
154
|
+
this.$textarea
|
155
|
+
.on('focus', $.proxy(this.focus, this))
|
156
|
+
.on('keypress', $.proxy(this.keypress, this))
|
157
|
+
.on('keyup', $.proxy(this.keyup, this))
|
158
|
+
.on('change', $.proxy(this.change, this));
|
159
|
+
|
160
|
+
if (this.eventSupported('keydown')) {
|
161
|
+
this.$textarea.on('keydown', $.proxy(this.keydown, this));
|
162
|
+
}
|
163
|
+
|
164
|
+
// Re-attach markdown data
|
165
|
+
this.$textarea.data('markdown',this);
|
166
|
+
}
|
167
|
+
|
168
|
+
, __handle: function(e) {
|
169
|
+
var target = $(e.currentTarget),
|
170
|
+
handler = this.$handler,
|
171
|
+
callback = this.$callback,
|
172
|
+
handlerName = target.attr('data-handler'),
|
173
|
+
callbackIndex = handler.indexOf(handlerName),
|
174
|
+
callbackHandler = callback[callbackIndex];
|
175
|
+
|
176
|
+
// Trigger the focusin
|
177
|
+
$(e.currentTarget).focus();
|
178
|
+
|
179
|
+
callbackHandler(this);
|
180
|
+
|
181
|
+
// Trigger onChange for each button handle
|
182
|
+
this.change(this);
|
183
|
+
|
184
|
+
// Unless it was the save handler,
|
185
|
+
// focusin the textarea
|
186
|
+
if (handlerName.indexOf('cmdSave') < 0) {
|
187
|
+
this.$textarea.focus();
|
188
|
+
}
|
189
|
+
|
190
|
+
e.preventDefault();
|
191
|
+
}
|
192
|
+
|
193
|
+
, __localize: function(string) {
|
194
|
+
var messages = $.fn.markdown.messages,
|
195
|
+
language = this.$options.language;
|
196
|
+
if (
|
197
|
+
typeof messages !== 'undefined' &&
|
198
|
+
typeof messages[language] !== 'undefined' &&
|
199
|
+
typeof messages[language][string] !== 'undefined'
|
200
|
+
) {
|
201
|
+
return messages[language][string];
|
202
|
+
}
|
203
|
+
return string;
|
204
|
+
}
|
205
|
+
|
206
|
+
, __getIcon: function(src) {
|
207
|
+
return typeof src == 'object' ? src[this.$options.iconlibrary] : src;
|
208
|
+
}
|
209
|
+
|
210
|
+
, setFullscreen: function(mode) {
|
211
|
+
var $editor = this.$editor,
|
212
|
+
$textarea = this.$textarea;
|
213
|
+
|
214
|
+
if (mode === true) {
|
215
|
+
$editor.addClass('md-fullscreen-mode');
|
216
|
+
$('body').addClass('md-nooverflow');
|
217
|
+
this.$options.onFullscreen(this);
|
218
|
+
} else {
|
219
|
+
$editor.removeClass('md-fullscreen-mode');
|
220
|
+
$('body').removeClass('md-nooverflow');
|
221
|
+
}
|
222
|
+
|
223
|
+
this.$isFullscreen = mode;
|
224
|
+
$textarea.focus();
|
225
|
+
}
|
226
|
+
|
227
|
+
, showEditor: function() {
|
228
|
+
var instance = this,
|
229
|
+
textarea,
|
230
|
+
ns = this.$ns,
|
231
|
+
container = this.$element,
|
232
|
+
originalHeigth = container.css('height'),
|
233
|
+
originalWidth = container.css('width'),
|
234
|
+
editable = this.$editable,
|
235
|
+
handler = this.$handler,
|
236
|
+
callback = this.$callback,
|
237
|
+
options = this.$options,
|
238
|
+
editor = $( '<div/>', {
|
239
|
+
'class': 'md-editor',
|
240
|
+
click: function() {
|
241
|
+
instance.focus();
|
242
|
+
}
|
243
|
+
});
|
244
|
+
|
245
|
+
// Prepare the editor
|
246
|
+
if (this.$editor === null) {
|
247
|
+
// Create the panel
|
248
|
+
var editorHeader = $('<div/>', {
|
249
|
+
'class': 'md-header btn-toolbar'
|
250
|
+
});
|
251
|
+
|
252
|
+
// Merge the main & additional button groups together
|
253
|
+
var allBtnGroups = [];
|
254
|
+
if (options.buttons.length > 0) allBtnGroups = allBtnGroups.concat(options.buttons[0]);
|
255
|
+
if (options.additionalButtons.length > 0) allBtnGroups = allBtnGroups.concat(options.additionalButtons[0]);
|
256
|
+
|
257
|
+
// Reduce and/or reorder the button groups
|
258
|
+
if (options.reorderButtonGroups.length > 0) {
|
259
|
+
allBtnGroups = allBtnGroups
|
260
|
+
.filter(function(btnGroup) {
|
261
|
+
return options.reorderButtonGroups.indexOf(btnGroup.name) > -1;
|
262
|
+
})
|
263
|
+
.sort(function(a, b) {
|
264
|
+
if (options.reorderButtonGroups.indexOf(a.name) < options.reorderButtonGroups.indexOf(b.name)) return -1;
|
265
|
+
if (options.reorderButtonGroups.indexOf(a.name) > options.reorderButtonGroups.indexOf(b.name)) return 1;
|
266
|
+
return 0;
|
267
|
+
});
|
268
|
+
}
|
269
|
+
|
270
|
+
// Build the buttons
|
271
|
+
if (allBtnGroups.length > 0) {
|
272
|
+
editorHeader = this.__buildButtons([allBtnGroups], editorHeader);
|
273
|
+
}
|
274
|
+
|
275
|
+
if (options.fullscreen.enable) {
|
276
|
+
editorHeader.append('<div class="md-controls"><a class="md-control md-control-fullscreen" href="#"><span class="'+this.__getIcon(options.fullscreen.icons.fullscreenOn)+'"></span></a></div>').on('click', '.md-control-fullscreen', function(e) {
|
277
|
+
e.preventDefault();
|
278
|
+
instance.setFullscreen(true);
|
279
|
+
});
|
280
|
+
}
|
281
|
+
|
282
|
+
editor.append(editorHeader);
|
283
|
+
|
284
|
+
// Wrap the textarea
|
285
|
+
if (container.is('textarea')) {
|
286
|
+
container.before(editor);
|
287
|
+
textarea = container;
|
288
|
+
textarea.addClass('md-input');
|
289
|
+
editor.append(textarea);
|
290
|
+
} else {
|
291
|
+
var rawContent = (typeof toMarkdown == 'function') ? toMarkdown(container.html()) : container.html(),
|
292
|
+
currentContent = $.trim(rawContent);
|
293
|
+
|
294
|
+
// This is some arbitrary content that could be edited
|
295
|
+
textarea = $('<textarea/>', {
|
296
|
+
'class': 'md-input',
|
297
|
+
'val' : currentContent
|
298
|
+
});
|
299
|
+
|
300
|
+
editor.append(textarea);
|
301
|
+
|
302
|
+
// Save the editable
|
303
|
+
editable.el = container;
|
304
|
+
editable.type = container.prop('tagName').toLowerCase();
|
305
|
+
editable.content = container.html();
|
306
|
+
|
307
|
+
$(container[0].attributes).each(function(){
|
308
|
+
editable.attrKeys.push(this.nodeName);
|
309
|
+
editable.attrValues.push(this.nodeValue);
|
310
|
+
});
|
311
|
+
|
312
|
+
// Set editor to blocked the original container
|
313
|
+
container.replaceWith(editor);
|
314
|
+
}
|
315
|
+
|
316
|
+
var editorFooter = $('<div/>', {
|
317
|
+
'class': 'md-footer'
|
318
|
+
}),
|
319
|
+
createFooter = false,
|
320
|
+
footer = '';
|
321
|
+
// Create the footer if savable
|
322
|
+
if (options.savable) {
|
323
|
+
createFooter = true;
|
324
|
+
var saveHandler = 'cmdSave';
|
325
|
+
|
326
|
+
// Register handler and callback
|
327
|
+
handler.push(saveHandler);
|
328
|
+
callback.push(options.onSave);
|
329
|
+
|
330
|
+
editorFooter.append('<button class="btn btn-success" data-provider="'
|
331
|
+
+ ns
|
332
|
+
+ '" data-handler="'
|
333
|
+
+ saveHandler
|
334
|
+
+ '"><i class="icon icon-white icon-ok"></i> '
|
335
|
+
+ this.__localize('Save')
|
336
|
+
+ '</button>');
|
337
|
+
|
338
|
+
|
339
|
+
}
|
340
|
+
|
341
|
+
footer = typeof options.footer === 'function' ? options.footer(this) : options.footer;
|
342
|
+
|
343
|
+
if ($.trim(footer) !== '') {
|
344
|
+
createFooter = true;
|
345
|
+
editorFooter.append(footer);
|
346
|
+
}
|
347
|
+
|
348
|
+
if (createFooter) editor.append(editorFooter);
|
349
|
+
|
350
|
+
// Set width
|
351
|
+
if (options.width && options.width !== 'inherit') {
|
352
|
+
if (jQuery.isNumeric(options.width)) {
|
353
|
+
editor.css('display', 'table');
|
354
|
+
textarea.css('width', options.width + 'px');
|
355
|
+
} else {
|
356
|
+
editor.addClass(options.width);
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
// Set height
|
361
|
+
if (options.height && options.height !== 'inherit') {
|
362
|
+
if (jQuery.isNumeric(options.height)) {
|
363
|
+
var height = options.height;
|
364
|
+
if (editorHeader) height = Math.max(0, height - editorHeader.outerHeight());
|
365
|
+
if (editorFooter) height = Math.max(0, height - editorFooter.outerHeight());
|
366
|
+
textarea.css('height', height + 'px');
|
367
|
+
} else {
|
368
|
+
editor.addClass(options.height);
|
369
|
+
}
|
370
|
+
}
|
371
|
+
|
372
|
+
// Reference
|
373
|
+
this.$editor = editor;
|
374
|
+
this.$textarea = textarea;
|
375
|
+
this.$editable = editable;
|
376
|
+
this.$oldContent = this.getContent();
|
377
|
+
|
378
|
+
this.__setListener();
|
379
|
+
|
380
|
+
// Set editor attributes, data short-hand API and listener
|
381
|
+
this.$editor.attr('id',(new Date()).getTime());
|
382
|
+
this.$editor.on('click', '[data-provider="bootstrap-markdown"]', $.proxy(this.__handle, this));
|
383
|
+
|
384
|
+
if (this.$element.is(':disabled') || this.$element.is('[readonly]')) {
|
385
|
+
this.$editor.addClass('md-editor-disabled');
|
386
|
+
this.disableButtons('all');
|
387
|
+
}
|
388
|
+
|
389
|
+
if (this.eventSupported('keydown') && typeof jQuery.hotkeys === 'object') {
|
390
|
+
editorHeader.find('[data-provider="bootstrap-markdown"]').each(function() {
|
391
|
+
var $button = $(this),
|
392
|
+
hotkey = $button.attr('data-hotkey');
|
393
|
+
if (hotkey.toLowerCase() !== '') {
|
394
|
+
textarea.bind('keydown', hotkey, function() {
|
395
|
+
$button.trigger('click');
|
396
|
+
return false;
|
397
|
+
});
|
398
|
+
}
|
399
|
+
});
|
400
|
+
}
|
401
|
+
|
402
|
+
if (options.initialstate === 'preview') {
|
403
|
+
this.showPreview();
|
404
|
+
} else if (options.initialstate === 'fullscreen' && options.fullscreen.enable) {
|
405
|
+
this.setFullscreen(true);
|
406
|
+
}
|
407
|
+
|
408
|
+
} else {
|
409
|
+
this.$editor.show();
|
410
|
+
}
|
411
|
+
|
412
|
+
if (options.autofocus) {
|
413
|
+
this.$textarea.focus();
|
414
|
+
this.$editor.addClass('active');
|
415
|
+
}
|
416
|
+
|
417
|
+
if (options.fullscreen.enable && options.fullscreen !== false) {
|
418
|
+
this.$editor.append('\
|
419
|
+
<div class="md-fullscreen-controls">\
|
420
|
+
<a href="#" class="exit-fullscreen" title="Exit fullscreen"><span class="'+this.__getIcon(options.fullscreen.icons.fullscreenOff)+'"></span></a>\
|
421
|
+
</div>');
|
422
|
+
|
423
|
+
this.$editor.on('click', '.exit-fullscreen', function(e) {
|
424
|
+
e.preventDefault();
|
425
|
+
instance.setFullscreen(false);
|
426
|
+
});
|
427
|
+
}
|
428
|
+
|
429
|
+
// hide hidden buttons from options
|
430
|
+
this.hideButtons(options.hiddenButtons);
|
431
|
+
|
432
|
+
// disable disabled buttons from options
|
433
|
+
this.disableButtons(options.disabledButtons);
|
434
|
+
|
435
|
+
// Trigger the onShow hook
|
436
|
+
options.onShow(this);
|
437
|
+
|
438
|
+
return this;
|
439
|
+
}
|
440
|
+
|
441
|
+
, parseContent: function(val) {
|
442
|
+
var content;
|
443
|
+
|
444
|
+
// parse with supported markdown parser
|
445
|
+
var val = val || this.$textarea.val();
|
446
|
+
|
447
|
+
if (typeof markdown == 'object') {
|
448
|
+
content = markdown.toHTML(val);
|
449
|
+
} else if (typeof marked == 'function') {
|
450
|
+
content = marked(val);
|
451
|
+
} else {
|
452
|
+
content = val;
|
453
|
+
}
|
454
|
+
|
455
|
+
return content;
|
456
|
+
}
|
457
|
+
|
458
|
+
, showPreview: function() {
|
459
|
+
var options = this.$options,
|
460
|
+
container = this.$textarea,
|
461
|
+
afterContainer = container.next(),
|
462
|
+
replacementContainer = $('<div/>',{'class':'md-preview','data-provider':'markdown-preview'}),
|
463
|
+
content,
|
464
|
+
callbackContent;
|
465
|
+
|
466
|
+
// Give flag that tell the editor enter preview mode
|
467
|
+
this.$isPreview = true;
|
468
|
+
// Disable all buttons
|
469
|
+
this.disableButtons('all').enableButtons('cmdPreview');
|
470
|
+
|
471
|
+
// Try to get the content from callback
|
472
|
+
callbackContent = options.onPreview(this);
|
473
|
+
// Set the content based from the callback content if string otherwise parse value from textarea
|
474
|
+
content = typeof callbackContent == 'string' ? callbackContent : this.parseContent();
|
475
|
+
|
476
|
+
// Build preview element
|
477
|
+
replacementContainer.html(content);
|
478
|
+
|
479
|
+
if (afterContainer && afterContainer.attr('class') == 'md-footer') {
|
480
|
+
// If there is footer element, insert the preview container before it
|
481
|
+
replacementContainer.insertBefore(afterContainer);
|
482
|
+
} else {
|
483
|
+
// Otherwise, just append it after textarea
|
484
|
+
container.parent().append(replacementContainer);
|
485
|
+
}
|
486
|
+
|
487
|
+
// Set the preview element dimensions
|
488
|
+
replacementContainer.css({
|
489
|
+
width: container.outerWidth() + 'px',
|
490
|
+
height: container.outerHeight() + 'px'
|
491
|
+
});
|
492
|
+
|
493
|
+
if (this.$options.resize) {
|
494
|
+
replacementContainer.css('resize',this.$options.resize);
|
495
|
+
}
|
496
|
+
|
497
|
+
// Hide the last-active textarea
|
498
|
+
container.hide();
|
499
|
+
|
500
|
+
// Attach the editor instances
|
501
|
+
replacementContainer.data('markdown',this);
|
502
|
+
|
503
|
+
if (this.$element.is(':disabled') || this.$element.is('[readonly]')) {
|
504
|
+
this.$editor.addClass('md-editor-disabled');
|
505
|
+
this.disableButtons('all');
|
506
|
+
}
|
507
|
+
|
508
|
+
return this;
|
509
|
+
}
|
510
|
+
|
511
|
+
, hidePreview: function() {
|
512
|
+
// Give flag that tell the editor quit preview mode
|
513
|
+
this.$isPreview = false;
|
514
|
+
|
515
|
+
// Obtain the preview container
|
516
|
+
var container = this.$editor.find('div[data-provider="markdown-preview"]');
|
517
|
+
|
518
|
+
// Remove the preview container
|
519
|
+
container.remove();
|
520
|
+
|
521
|
+
// Enable all buttons
|
522
|
+
this.enableButtons('all');
|
523
|
+
// Disable configured disabled buttons
|
524
|
+
this.disableButtons(this.$options.disabledButtons);
|
525
|
+
|
526
|
+
// Back to the editor
|
527
|
+
this.$textarea.show();
|
528
|
+
this.__setListener();
|
529
|
+
|
530
|
+
return this;
|
531
|
+
}
|
532
|
+
|
533
|
+
, isDirty: function() {
|
534
|
+
return this.$oldContent != this.getContent();
|
535
|
+
}
|
536
|
+
|
537
|
+
, getContent: function() {
|
538
|
+
return this.$textarea.val();
|
539
|
+
}
|
540
|
+
|
541
|
+
, setContent: function(content) {
|
542
|
+
this.$textarea.val(content);
|
543
|
+
|
544
|
+
return this;
|
545
|
+
}
|
546
|
+
|
547
|
+
, findSelection: function(chunk) {
|
548
|
+
var content = this.getContent(), startChunkPosition;
|
549
|
+
|
550
|
+
if (startChunkPosition = content.indexOf(chunk), startChunkPosition >= 0 && chunk.length > 0) {
|
551
|
+
var oldSelection = this.getSelection(), selection;
|
552
|
+
|
553
|
+
this.setSelection(startChunkPosition,startChunkPosition+chunk.length);
|
554
|
+
selection = this.getSelection();
|
555
|
+
|
556
|
+
this.setSelection(oldSelection.start,oldSelection.end);
|
557
|
+
|
558
|
+
return selection;
|
559
|
+
} else {
|
560
|
+
return null;
|
561
|
+
}
|
562
|
+
}
|
563
|
+
|
564
|
+
, getSelection: function() {
|
565
|
+
|
566
|
+
var e = this.$textarea[0];
|
567
|
+
|
568
|
+
return (
|
569
|
+
|
570
|
+
('selectionStart' in e && function() {
|
571
|
+
var l = e.selectionEnd - e.selectionStart;
|
572
|
+
return { start: e.selectionStart, end: e.selectionEnd, length: l, text: e.value.substr(e.selectionStart, l) };
|
573
|
+
}) ||
|
574
|
+
|
575
|
+
/* browser not supported */
|
576
|
+
function() {
|
577
|
+
return null;
|
578
|
+
}
|
579
|
+
|
580
|
+
)();
|
581
|
+
|
582
|
+
}
|
583
|
+
|
584
|
+
, setSelection: function(start,end) {
|
585
|
+
|
586
|
+
var e = this.$textarea[0];
|
587
|
+
|
588
|
+
return (
|
589
|
+
|
590
|
+
('selectionStart' in e && function() {
|
591
|
+
e.selectionStart = start;
|
592
|
+
e.selectionEnd = end;
|
593
|
+
return;
|
594
|
+
}) ||
|
595
|
+
|
596
|
+
/* browser not supported */
|
597
|
+
function() {
|
598
|
+
return null;
|
599
|
+
}
|
600
|
+
|
601
|
+
)();
|
602
|
+
|
603
|
+
}
|
604
|
+
|
605
|
+
, replaceSelection: function(text) {
|
606
|
+
|
607
|
+
var e = this.$textarea[0];
|
608
|
+
|
609
|
+
return (
|
610
|
+
|
611
|
+
('selectionStart' in e && function() {
|
612
|
+
e.value = e.value.substr(0, e.selectionStart) + text + e.value.substr(e.selectionEnd, e.value.length);
|
613
|
+
// Set cursor to the last replacement end
|
614
|
+
e.selectionStart = e.value.length;
|
615
|
+
return this;
|
616
|
+
}) ||
|
617
|
+
|
618
|
+
/* browser not supported */
|
619
|
+
function() {
|
620
|
+
e.value += text;
|
621
|
+
return jQuery(e);
|
622
|
+
}
|
623
|
+
|
624
|
+
)();
|
625
|
+
}
|
626
|
+
|
627
|
+
, getNextTab: function() {
|
628
|
+
// Shift the nextTab
|
629
|
+
if (this.$nextTab.length === 0) {
|
630
|
+
return null;
|
631
|
+
} else {
|
632
|
+
var nextTab, tab = this.$nextTab.shift();
|
633
|
+
|
634
|
+
if (typeof tab == 'function') {
|
635
|
+
nextTab = tab();
|
636
|
+
} else if (typeof tab == 'object' && tab.length > 0) {
|
637
|
+
nextTab = tab;
|
638
|
+
}
|
639
|
+
|
640
|
+
return nextTab;
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
, setNextTab: function(start,end) {
|
645
|
+
// Push new selection into nextTab collections
|
646
|
+
if (typeof start == 'string') {
|
647
|
+
var that = this;
|
648
|
+
this.$nextTab.push(function(){
|
649
|
+
return that.findSelection(start);
|
650
|
+
});
|
651
|
+
} else if (typeof start == 'number' && typeof end == 'number') {
|
652
|
+
var oldSelection = this.getSelection();
|
653
|
+
|
654
|
+
this.setSelection(start,end);
|
655
|
+
this.$nextTab.push(this.getSelection());
|
656
|
+
|
657
|
+
this.setSelection(oldSelection.start,oldSelection.end);
|
658
|
+
}
|
659
|
+
|
660
|
+
return;
|
661
|
+
}
|
662
|
+
|
663
|
+
, __parseButtonNameParam: function(nameParam) {
|
664
|
+
var buttons = [];
|
665
|
+
|
666
|
+
if (typeof nameParam == 'string') {
|
667
|
+
buttons = nameParam.split(',')
|
668
|
+
} else {
|
669
|
+
buttons = nameParam;
|
670
|
+
}
|
671
|
+
|
672
|
+
return buttons;
|
673
|
+
}
|
674
|
+
|
675
|
+
, enableButtons: function(name) {
|
676
|
+
var buttons = this.__parseButtonNameParam(name),
|
677
|
+
that = this;
|
678
|
+
|
679
|
+
$.each(buttons, function(i, v) {
|
680
|
+
that.__alterButtons(buttons[i], function (el) {
|
681
|
+
el.removeAttr('disabled');
|
682
|
+
});
|
683
|
+
});
|
684
|
+
|
685
|
+
return this;
|
686
|
+
}
|
687
|
+
|
688
|
+
, disableButtons: function(name) {
|
689
|
+
var buttons = this.__parseButtonNameParam(name),
|
690
|
+
that = this;
|
691
|
+
|
692
|
+
$.each(buttons, function(i, v) {
|
693
|
+
that.__alterButtons(buttons[i], function (el) {
|
694
|
+
el.attr('disabled','disabled');
|
695
|
+
});
|
696
|
+
});
|
697
|
+
|
698
|
+
return this;
|
699
|
+
}
|
700
|
+
|
701
|
+
, hideButtons: function(name) {
|
702
|
+
var buttons = this.__parseButtonNameParam(name),
|
703
|
+
that = this;
|
704
|
+
|
705
|
+
$.each(buttons, function(i, v) {
|
706
|
+
that.__alterButtons(buttons[i], function (el) {
|
707
|
+
el.addClass('hidden');
|
708
|
+
});
|
709
|
+
});
|
710
|
+
|
711
|
+
return this;
|
712
|
+
}
|
713
|
+
|
714
|
+
, showButtons: function(name) {
|
715
|
+
var buttons = this.__parseButtonNameParam(name),
|
716
|
+
that = this;
|
717
|
+
|
718
|
+
$.each(buttons, function(i, v) {
|
719
|
+
that.__alterButtons(buttons[i], function (el) {
|
720
|
+
el.removeClass('hidden');
|
721
|
+
});
|
722
|
+
});
|
723
|
+
|
724
|
+
return this;
|
725
|
+
}
|
726
|
+
|
727
|
+
, eventSupported: function(eventName) {
|
728
|
+
var isSupported = eventName in this.$element;
|
729
|
+
if (!isSupported) {
|
730
|
+
this.$element.setAttribute(eventName, 'return;');
|
731
|
+
isSupported = typeof this.$element[eventName] === 'function';
|
732
|
+
}
|
733
|
+
return isSupported;
|
734
|
+
}
|
735
|
+
|
736
|
+
, keyup: function (e) {
|
737
|
+
var blocked = false;
|
738
|
+
switch(e.keyCode) {
|
739
|
+
case 40: // down arrow
|
740
|
+
case 38: // up arrow
|
741
|
+
case 16: // shift
|
742
|
+
case 17: // ctrl
|
743
|
+
case 18: // alt
|
744
|
+
break;
|
745
|
+
|
746
|
+
case 9: // tab
|
747
|
+
var nextTab;
|
748
|
+
if (nextTab = this.getNextTab(),nextTab !== null) {
|
749
|
+
// Get the nextTab if exists
|
750
|
+
var that = this;
|
751
|
+
setTimeout(function(){
|
752
|
+
that.setSelection(nextTab.start,nextTab.end);
|
753
|
+
},500);
|
754
|
+
|
755
|
+
blocked = true;
|
756
|
+
} else {
|
757
|
+
// The next tab memory contains nothing...
|
758
|
+
// check the cursor position to determine tab action
|
759
|
+
var cursor = this.getSelection();
|
760
|
+
|
761
|
+
if (cursor.start == cursor.end && cursor.end == this.getContent().length) {
|
762
|
+
// The cursor already reach the end of the content
|
763
|
+
blocked = false;
|
764
|
+
} else {
|
765
|
+
// Put the cursor to the end
|
766
|
+
this.setSelection(this.getContent().length,this.getContent().length);
|
767
|
+
|
768
|
+
blocked = true;
|
769
|
+
}
|
770
|
+
}
|
771
|
+
|
772
|
+
break;
|
773
|
+
|
774
|
+
case 13: // enter
|
775
|
+
blocked = false;
|
776
|
+
break;
|
777
|
+
case 27: // escape
|
778
|
+
if (this.$isFullscreen) this.setFullscreen(false);
|
779
|
+
blocked = false;
|
780
|
+
break;
|
781
|
+
|
782
|
+
default:
|
783
|
+
blocked = false;
|
784
|
+
}
|
785
|
+
|
786
|
+
if (blocked) {
|
787
|
+
e.stopPropagation();
|
788
|
+
e.preventDefault();
|
789
|
+
}
|
790
|
+
|
791
|
+
this.$options.onChange(this);
|
792
|
+
}
|
793
|
+
|
794
|
+
, change: function(e) {
|
795
|
+
this.$options.onChange(this);
|
796
|
+
return this;
|
797
|
+
}
|
798
|
+
|
799
|
+
, focus: function (e) {
|
800
|
+
var options = this.$options,
|
801
|
+
isHideable = options.hideable,
|
802
|
+
editor = this.$editor;
|
803
|
+
|
804
|
+
editor.addClass('active');
|
805
|
+
|
806
|
+
// Blur other markdown(s)
|
807
|
+
$(document).find('.md-editor').each(function(){
|
808
|
+
if ($(this).attr('id') !== editor.attr('id')) {
|
809
|
+
var attachedMarkdown;
|
810
|
+
|
811
|
+
if (attachedMarkdown = $(this).find('textarea').data('markdown'),
|
812
|
+
attachedMarkdown === null) {
|
813
|
+
attachedMarkdown = $(this).find('div[data-provider="markdown-preview"]').data('markdown');
|
814
|
+
}
|
815
|
+
|
816
|
+
if (attachedMarkdown) {
|
817
|
+
attachedMarkdown.blur();
|
818
|
+
}
|
819
|
+
}
|
820
|
+
});
|
821
|
+
|
822
|
+
// Trigger the onFocus hook
|
823
|
+
options.onFocus(this);
|
824
|
+
|
825
|
+
return this;
|
826
|
+
}
|
827
|
+
|
828
|
+
, blur: function (e) {
|
829
|
+
var options = this.$options,
|
830
|
+
isHideable = options.hideable,
|
831
|
+
editor = this.$editor,
|
832
|
+
editable = this.$editable;
|
833
|
+
|
834
|
+
if (editor.hasClass('active') || this.$element.parent().length === 0) {
|
835
|
+
editor.removeClass('active');
|
836
|
+
|
837
|
+
if (isHideable) {
|
838
|
+
// Check for editable elements
|
839
|
+
if (editable.el !== null) {
|
840
|
+
// Build the original element
|
841
|
+
var oldElement = $('<'+editable.type+'/>'),
|
842
|
+
content = this.getContent(),
|
843
|
+
currentContent = (typeof markdown == 'object') ? markdown.toHTML(content) : content;
|
844
|
+
|
845
|
+
$(editable.attrKeys).each(function(k,v) {
|
846
|
+
oldElement.attr(editable.attrKeys[k],editable.attrValues[k]);
|
847
|
+
});
|
848
|
+
|
849
|
+
// Get the editor content
|
850
|
+
oldElement.html(currentContent);
|
851
|
+
|
852
|
+
editor.replaceWith(oldElement);
|
853
|
+
} else {
|
854
|
+
editor.hide();
|
855
|
+
}
|
856
|
+
}
|
857
|
+
|
858
|
+
// Trigger the onBlur hook
|
859
|
+
options.onBlur(this);
|
860
|
+
}
|
861
|
+
|
862
|
+
return this;
|
863
|
+
}
|
864
|
+
|
865
|
+
};
|
866
|
+
|
867
|
+
/* MARKDOWN PLUGIN DEFINITION
|
868
|
+
* ========================== */
|
869
|
+
|
870
|
+
var old = $.fn.markdown;
|
871
|
+
|
872
|
+
$.fn.markdown = function (option) {
|
873
|
+
return this.each(function () {
|
874
|
+
var $this = $(this)
|
875
|
+
, data = $this.data('markdown')
|
876
|
+
, options = typeof option == 'object' && option;
|
877
|
+
if (!data) $this.data('markdown', (data = new Markdown(this, options)))
|
878
|
+
})
|
879
|
+
};
|
880
|
+
|
881
|
+
$.fn.markdown.messages = {};
|
882
|
+
|
883
|
+
$.fn.markdown.defaults = {
|
884
|
+
/* Editor Properties */
|
885
|
+
autofocus: false,
|
886
|
+
hideable: false,
|
887
|
+
savable:false,
|
888
|
+
width: 'inherit',
|
889
|
+
height: 'inherit',
|
890
|
+
resize: 'none',
|
891
|
+
iconlibrary: 'glyph',
|
892
|
+
language: 'en',
|
893
|
+
initialstate: 'editor',
|
894
|
+
|
895
|
+
/* Buttons Properties */
|
896
|
+
buttons: [
|
897
|
+
[{
|
898
|
+
name: 'groupFont',
|
899
|
+
data: [{
|
900
|
+
name: 'cmdBold',
|
901
|
+
hotkey: 'Ctrl+B',
|
902
|
+
title: 'Bold',
|
903
|
+
icon: { glyph: 'glyphicon glyphicon-bold', fa: 'fa fa-bold', 'fa-3': 'icon-bold' },
|
904
|
+
callback: function(e){
|
905
|
+
// Give/remove ** surround the selection
|
906
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
907
|
+
|
908
|
+
if (selected.length === 0) {
|
909
|
+
// Give extra word
|
910
|
+
chunk = e.__localize('strong text');
|
911
|
+
} else {
|
912
|
+
chunk = selected.text;
|
913
|
+
}
|
914
|
+
|
915
|
+
// transform selection and set the cursor into chunked text
|
916
|
+
if (content.substr(selected.start-2,2) === '**'
|
917
|
+
&& content.substr(selected.end,2) === '**' ) {
|
918
|
+
e.setSelection(selected.start-2,selected.end+2);
|
919
|
+
e.replaceSelection(chunk);
|
920
|
+
cursor = selected.start-2;
|
921
|
+
} else {
|
922
|
+
e.replaceSelection('**'+chunk+'**');
|
923
|
+
cursor = selected.start+2;
|
924
|
+
}
|
925
|
+
|
926
|
+
// Set the cursor
|
927
|
+
e.setSelection(cursor,cursor+chunk.length);
|
928
|
+
}
|
929
|
+
},{
|
930
|
+
name: 'cmdItalic',
|
931
|
+
title: 'Italic',
|
932
|
+
hotkey: 'Ctrl+I',
|
933
|
+
icon: { glyph: 'glyphicon glyphicon-italic', fa: 'fa fa-italic', 'fa-3': 'icon-italic' },
|
934
|
+
callback: function(e){
|
935
|
+
// Give/remove * surround the selection
|
936
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
937
|
+
|
938
|
+
if (selected.length === 0) {
|
939
|
+
// Give extra word
|
940
|
+
chunk = e.__localize('emphasized text');
|
941
|
+
} else {
|
942
|
+
chunk = selected.text;
|
943
|
+
}
|
944
|
+
|
945
|
+
// transform selection and set the cursor into chunked text
|
946
|
+
if (content.substr(selected.start-1,1) === '_'
|
947
|
+
&& content.substr(selected.end,1) === '_' ) {
|
948
|
+
e.setSelection(selected.start-1,selected.end+1);
|
949
|
+
e.replaceSelection(chunk);
|
950
|
+
cursor = selected.start-1;
|
951
|
+
} else {
|
952
|
+
e.replaceSelection('_'+chunk+'_');
|
953
|
+
cursor = selected.start+1;
|
954
|
+
}
|
955
|
+
|
956
|
+
// Set the cursor
|
957
|
+
e.setSelection(cursor,cursor+chunk.length);
|
958
|
+
}
|
959
|
+
},{
|
960
|
+
name: 'cmdHeading',
|
961
|
+
title: 'Heading',
|
962
|
+
hotkey: 'Ctrl+H',
|
963
|
+
icon: { glyph: 'glyphicon glyphicon-header', fa: 'fa fa-header', 'fa-3': 'icon-font' },
|
964
|
+
callback: function(e){
|
965
|
+
// Append/remove ### surround the selection
|
966
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent(), pointer, prevChar;
|
967
|
+
|
968
|
+
if (selected.length === 0) {
|
969
|
+
// Give extra word
|
970
|
+
chunk = e.__localize('heading text');
|
971
|
+
} else {
|
972
|
+
chunk = selected.text + '\n';
|
973
|
+
}
|
974
|
+
|
975
|
+
// transform selection and set the cursor into chunked text
|
976
|
+
if ((pointer = 4, content.substr(selected.start-pointer,pointer) === '### ')
|
977
|
+
|| (pointer = 3, content.substr(selected.start-pointer,pointer) === '###')) {
|
978
|
+
e.setSelection(selected.start-pointer,selected.end);
|
979
|
+
e.replaceSelection(chunk);
|
980
|
+
cursor = selected.start-pointer;
|
981
|
+
} else if (selected.start > 0 && (prevChar = content.substr(selected.start-1,1), !!prevChar && prevChar != '\n')) {
|
982
|
+
e.replaceSelection('\n\n### '+chunk);
|
983
|
+
cursor = selected.start+6;
|
984
|
+
} else {
|
985
|
+
// Empty string before element
|
986
|
+
e.replaceSelection('### '+chunk);
|
987
|
+
cursor = selected.start+4;
|
988
|
+
}
|
989
|
+
|
990
|
+
// Set the cursor
|
991
|
+
e.setSelection(cursor,cursor+chunk.length);
|
992
|
+
}
|
993
|
+
}]
|
994
|
+
},{
|
995
|
+
name: 'groupLink',
|
996
|
+
data: [{
|
997
|
+
name: 'cmdUrl',
|
998
|
+
title: 'URL/Link',
|
999
|
+
hotkey: 'Ctrl+L',
|
1000
|
+
icon: { glyph: 'glyphicon glyphicon-link', fa: 'fa fa-link', 'fa-3': 'icon-link' },
|
1001
|
+
callback: function(e){
|
1002
|
+
// Give [] surround the selection and prepend the link
|
1003
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent(), link;
|
1004
|
+
|
1005
|
+
if (selected.length === 0) {
|
1006
|
+
// Give extra word
|
1007
|
+
chunk = e.__localize('enter link description here');
|
1008
|
+
} else {
|
1009
|
+
chunk = selected.text;
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
link = prompt(e.__localize('Insert Hyperlink'),'http://');
|
1013
|
+
|
1014
|
+
if (link !== null && link !== '' && link !== 'http://' && link.substr(0,4) === 'http') {
|
1015
|
+
var sanitizedLink = $('<div>'+link+'</div>').text();
|
1016
|
+
|
1017
|
+
// transform selection and set the cursor into chunked text
|
1018
|
+
e.replaceSelection('['+chunk+']('+sanitizedLink+')');
|
1019
|
+
cursor = selected.start+1;
|
1020
|
+
|
1021
|
+
// Set the cursor
|
1022
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
},{
|
1026
|
+
name: 'cmdImage',
|
1027
|
+
title: 'Image',
|
1028
|
+
hotkey: 'Ctrl+G',
|
1029
|
+
icon: { glyph: 'glyphicon glyphicon-picture', fa: 'fa fa-picture-o', 'fa-3': 'icon-picture' },
|
1030
|
+
callback: function(e){
|
1031
|
+
// Give ![] surround the selection and prepend the image link
|
1032
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent(), link;
|
1033
|
+
|
1034
|
+
if (selected.length === 0) {
|
1035
|
+
// Give extra word
|
1036
|
+
chunk = e.__localize('enter image description here');
|
1037
|
+
} else {
|
1038
|
+
chunk = selected.text;
|
1039
|
+
}
|
1040
|
+
|
1041
|
+
link = prompt(e.__localize('Insert Image Hyperlink'),'http://');
|
1042
|
+
|
1043
|
+
if (link !== null && link !== '' && link !== 'http://' && link.substr(0,4) === 'http') {
|
1044
|
+
var sanitizedLink = $('<div>'+link+'</div>').text();
|
1045
|
+
|
1046
|
+
// transform selection and set the cursor into chunked text
|
1047
|
+
e.replaceSelection('!['+chunk+']('+sanitizedLink+' "'+e.__localize('enter image title here')+'")');
|
1048
|
+
cursor = selected.start+2;
|
1049
|
+
|
1050
|
+
// Set the next tab
|
1051
|
+
e.setNextTab(e.__localize('enter image title here'));
|
1052
|
+
|
1053
|
+
// Set the cursor
|
1054
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1055
|
+
}
|
1056
|
+
}
|
1057
|
+
}]
|
1058
|
+
},{
|
1059
|
+
name: 'groupMisc',
|
1060
|
+
data: [{
|
1061
|
+
name: 'cmdList',
|
1062
|
+
hotkey: 'Ctrl+U',
|
1063
|
+
title: 'Unordered List',
|
1064
|
+
icon: { glyph: 'glyphicon glyphicon-list', fa: 'fa fa-list', 'fa-3': 'icon-list-ul' },
|
1065
|
+
callback: function(e){
|
1066
|
+
// Prepend/Give - surround the selection
|
1067
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
1068
|
+
|
1069
|
+
// transform selection and set the cursor into chunked text
|
1070
|
+
if (selected.length === 0) {
|
1071
|
+
// Give extra word
|
1072
|
+
chunk = e.__localize('list text here');
|
1073
|
+
|
1074
|
+
e.replaceSelection('- '+chunk);
|
1075
|
+
// Set the cursor
|
1076
|
+
cursor = selected.start+2;
|
1077
|
+
} else {
|
1078
|
+
if (selected.text.indexOf('\n') < 0) {
|
1079
|
+
chunk = selected.text;
|
1080
|
+
|
1081
|
+
e.replaceSelection('- '+chunk);
|
1082
|
+
|
1083
|
+
// Set the cursor
|
1084
|
+
cursor = selected.start+2;
|
1085
|
+
} else {
|
1086
|
+
var list = [];
|
1087
|
+
|
1088
|
+
list = selected.text.split('\n');
|
1089
|
+
chunk = list[0];
|
1090
|
+
|
1091
|
+
$.each(list,function(k,v) {
|
1092
|
+
list[k] = '- '+v;
|
1093
|
+
});
|
1094
|
+
|
1095
|
+
e.replaceSelection('\n\n'+list.join('\n'));
|
1096
|
+
|
1097
|
+
// Set the cursor
|
1098
|
+
cursor = selected.start+4;
|
1099
|
+
}
|
1100
|
+
}
|
1101
|
+
|
1102
|
+
// Set the cursor
|
1103
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1104
|
+
}
|
1105
|
+
},
|
1106
|
+
{
|
1107
|
+
name: 'cmdListO',
|
1108
|
+
hotkey: 'Ctrl+O',
|
1109
|
+
title: 'Ordered List',
|
1110
|
+
icon: { glyph: 'glyphicon glyphicon-th-list', fa: 'fa fa-list-ol', 'fa-3': 'icon-list-ol' },
|
1111
|
+
callback: function(e) {
|
1112
|
+
|
1113
|
+
// Prepend/Give - surround the selection
|
1114
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
1115
|
+
|
1116
|
+
// transform selection and set the cursor into chunked text
|
1117
|
+
if (selected.length === 0) {
|
1118
|
+
// Give extra word
|
1119
|
+
chunk = e.__localize('list text here');
|
1120
|
+
e.replaceSelection('1. '+chunk);
|
1121
|
+
// Set the cursor
|
1122
|
+
cursor = selected.start+3;
|
1123
|
+
} else {
|
1124
|
+
if (selected.text.indexOf('\n') < 0) {
|
1125
|
+
chunk = selected.text;
|
1126
|
+
|
1127
|
+
e.replaceSelection('1. '+chunk);
|
1128
|
+
|
1129
|
+
// Set the cursor
|
1130
|
+
cursor = selected.start+3;
|
1131
|
+
} else {
|
1132
|
+
var list = [];
|
1133
|
+
|
1134
|
+
list = selected.text.split('\n');
|
1135
|
+
chunk = list[0];
|
1136
|
+
|
1137
|
+
$.each(list,function(k,v) {
|
1138
|
+
list[k] = '1. '+v;
|
1139
|
+
});
|
1140
|
+
|
1141
|
+
e.replaceSelection('\n\n'+list.join('\n'));
|
1142
|
+
|
1143
|
+
// Set the cursor
|
1144
|
+
cursor = selected.start+5;
|
1145
|
+
}
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
// Set the cursor
|
1149
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1150
|
+
}
|
1151
|
+
},
|
1152
|
+
{
|
1153
|
+
name: 'cmdCode',
|
1154
|
+
hotkey: 'Ctrl+K',
|
1155
|
+
title: 'Code',
|
1156
|
+
icon: { glyph: 'glyphicon glyphicon-asterisk', fa: 'fa fa-code', 'fa-3': 'icon-code' },
|
1157
|
+
callback: function(e) {
|
1158
|
+
// Give/remove ** surround the selection
|
1159
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
1160
|
+
|
1161
|
+
if (selected.length === 0) {
|
1162
|
+
// Give extra word
|
1163
|
+
chunk = e.__localize('code text here');
|
1164
|
+
} else {
|
1165
|
+
chunk = selected.text;
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
// transform selection and set the cursor into chunked text
|
1169
|
+
if (content.substr(selected.start-4,4) === '```\n'
|
1170
|
+
&& content.substr(selected.end,4) === '\n```') {
|
1171
|
+
e.setSelection(selected.start-4, selected.end+4);
|
1172
|
+
e.replaceSelection(chunk);
|
1173
|
+
cursor = selected.start-4;
|
1174
|
+
} else if (content.substr(selected.start-1,1) === '`'
|
1175
|
+
&& content.substr(selected.end,1) === '`') {
|
1176
|
+
e.setSelection(selected.start-1,selected.end+1);
|
1177
|
+
e.replaceSelection(chunk);
|
1178
|
+
cursor = selected.start-1;
|
1179
|
+
} else if (content.indexOf('\n') > -1) {
|
1180
|
+
e.replaceSelection('```\n'+chunk+'\n```');
|
1181
|
+
cursor = selected.start+4;
|
1182
|
+
} else {
|
1183
|
+
e.replaceSelection('`'+chunk+'`');
|
1184
|
+
cursor = selected.start+1;
|
1185
|
+
}
|
1186
|
+
|
1187
|
+
// Set the cursor
|
1188
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1189
|
+
}
|
1190
|
+
},
|
1191
|
+
{
|
1192
|
+
name: 'cmdQuote',
|
1193
|
+
hotkey: 'Ctrl+Q',
|
1194
|
+
title: 'Quote',
|
1195
|
+
icon: { glyph: 'glyphicon glyphicon-comment', fa: 'fa fa-quote-left', 'fa-3': 'icon-quote-left' },
|
1196
|
+
callback: function(e) {
|
1197
|
+
// Prepend/Give - surround the selection
|
1198
|
+
var chunk, cursor, selected = e.getSelection(), content = e.getContent();
|
1199
|
+
|
1200
|
+
// transform selection and set the cursor into chunked text
|
1201
|
+
if (selected.length === 0) {
|
1202
|
+
// Give extra word
|
1203
|
+
chunk = e.__localize('quote here');
|
1204
|
+
|
1205
|
+
e.replaceSelection('> '+chunk);
|
1206
|
+
|
1207
|
+
// Set the cursor
|
1208
|
+
cursor = selected.start+2;
|
1209
|
+
} else {
|
1210
|
+
if (selected.text.indexOf('\n') < 0) {
|
1211
|
+
chunk = selected.text;
|
1212
|
+
|
1213
|
+
e.replaceSelection('> '+chunk);
|
1214
|
+
|
1215
|
+
// Set the cursor
|
1216
|
+
cursor = selected.start+2;
|
1217
|
+
} else {
|
1218
|
+
var list = [];
|
1219
|
+
|
1220
|
+
list = selected.text.split('\n');
|
1221
|
+
chunk = list[0];
|
1222
|
+
|
1223
|
+
$.each(list,function(k,v) {
|
1224
|
+
list[k] = '> '+v;
|
1225
|
+
});
|
1226
|
+
|
1227
|
+
e.replaceSelection('\n\n'+list.join('\n'));
|
1228
|
+
|
1229
|
+
// Set the cursor
|
1230
|
+
cursor = selected.start+4;
|
1231
|
+
}
|
1232
|
+
}
|
1233
|
+
|
1234
|
+
// Set the cursor
|
1235
|
+
e.setSelection(cursor,cursor+chunk.length);
|
1236
|
+
}
|
1237
|
+
}]
|
1238
|
+
},{
|
1239
|
+
name: 'groupUtil',
|
1240
|
+
data: [{
|
1241
|
+
name: 'cmdPreview',
|
1242
|
+
toggle: true,
|
1243
|
+
hotkey: 'Ctrl+P',
|
1244
|
+
title: 'Preview',
|
1245
|
+
btnText: 'Preview',
|
1246
|
+
btnClass: 'btn btn-primary btn-sm',
|
1247
|
+
icon: { glyph: 'glyphicon glyphicon-search', fa: 'fa fa-search', 'fa-3': 'icon-search' },
|
1248
|
+
callback: function(e){
|
1249
|
+
// Check the preview mode and toggle based on this flag
|
1250
|
+
var isPreview = e.$isPreview,content;
|
1251
|
+
|
1252
|
+
if (isPreview === false) {
|
1253
|
+
// Give flag that tell the editor enter preview mode
|
1254
|
+
e.showPreview();
|
1255
|
+
} else {
|
1256
|
+
e.hidePreview();
|
1257
|
+
}
|
1258
|
+
}
|
1259
|
+
}]
|
1260
|
+
}]
|
1261
|
+
],
|
1262
|
+
additionalButtons:[], // Place to hook more buttons by code
|
1263
|
+
reorderButtonGroups:[],
|
1264
|
+
hiddenButtons:[], // Default hidden buttons
|
1265
|
+
disabledButtons:[], // Default disabled buttons
|
1266
|
+
footer: '',
|
1267
|
+
fullscreen: {
|
1268
|
+
enable: true,
|
1269
|
+
icons: {
|
1270
|
+
fullscreenOn: {
|
1271
|
+
fa: 'fa fa-expand',
|
1272
|
+
glyph: 'glyphicon glyphicon-fullscreen',
|
1273
|
+
'fa-3': 'icon-resize-full'
|
1274
|
+
},
|
1275
|
+
fullscreenOff: {
|
1276
|
+
fa: 'fa fa-compress',
|
1277
|
+
glyph: 'glyphicon glyphicon-fullscreen',
|
1278
|
+
'fa-3': 'icon-resize-small'
|
1279
|
+
}
|
1280
|
+
}
|
1281
|
+
},
|
1282
|
+
|
1283
|
+
/* Events hook */
|
1284
|
+
onShow: function (e) {},
|
1285
|
+
onPreview: function (e) {},
|
1286
|
+
onSave: function (e) {},
|
1287
|
+
onBlur: function (e) {},
|
1288
|
+
onFocus: function (e) {},
|
1289
|
+
onChange: function(e) {},
|
1290
|
+
onFullscreen: function(e) {}
|
1291
|
+
};
|
1292
|
+
|
1293
|
+
$.fn.markdown.Constructor = Markdown;
|
1294
|
+
|
1295
|
+
|
1296
|
+
/* MARKDOWN NO CONFLICT
|
1297
|
+
* ==================== */
|
1298
|
+
|
1299
|
+
$.fn.markdown.noConflict = function () {
|
1300
|
+
$.fn.markdown = old;
|
1301
|
+
return this;
|
1302
|
+
};
|
1303
|
+
|
1304
|
+
/* MARKDOWN GLOBAL FUNCTION & DATA-API
|
1305
|
+
* ==================================== */
|
1306
|
+
var initMarkdown = function(el) {
|
1307
|
+
var $this = el;
|
1308
|
+
|
1309
|
+
if ($this.data('markdown')) {
|
1310
|
+
$this.data('markdown').showEditor();
|
1311
|
+
return;
|
1312
|
+
}
|
1313
|
+
|
1314
|
+
$this.markdown()
|
1315
|
+
};
|
1316
|
+
|
1317
|
+
var blurNonFocused = function(e) {
|
1318
|
+
var $activeElement = $(document.activeElement);
|
1319
|
+
|
1320
|
+
// Blur event
|
1321
|
+
$(document).find('.md-editor').each(function(){
|
1322
|
+
var $this = $(this),
|
1323
|
+
focused = $activeElement.closest('.md-editor')[0] === this,
|
1324
|
+
attachedMarkdown = $this.find('textarea').data('markdown') ||
|
1325
|
+
$this.find('div[data-provider="markdown-preview"]').data('markdown');
|
1326
|
+
|
1327
|
+
if (attachedMarkdown && !focused) {
|
1328
|
+
attachedMarkdown.blur();
|
1329
|
+
}
|
1330
|
+
})
|
1331
|
+
};
|
1332
|
+
|
1333
|
+
$(document)
|
1334
|
+
.on('click.markdown.data-api', '[data-provide="markdown-editable"]', function (e) {
|
1335
|
+
initMarkdown($(this));
|
1336
|
+
e.preventDefault();
|
1337
|
+
})
|
1338
|
+
.on('click focusin', function (e) {
|
1339
|
+
blurNonFocused(e);
|
1340
|
+
})
|
1341
|
+
.ready(function(){
|
1342
|
+
$('textarea[data-provide="markdown"]').each(function(){
|
1343
|
+
initMarkdown($(this));
|
1344
|
+
})
|
1345
|
+
});
|
1346
|
+
|
1347
|
+
}(window.jQuery);
|