From 5d7889f1c933a1902629b4874e5d0658f6540563 Mon Sep 17 00:00:00 2001 From: Manuel Cillero Date: Thu, 21 Mar 2019 17:52:05 +0100 Subject: [PATCH] Actualizado plugin Redmine Questions 1.0.0 light --- README.md | 2 +- plugins/redmine_questions/Gemfile | 2 +- .../questions_answers_controller.rb | 107 +++++ .../questions_comments_controller.rb | 78 ++++ .../app/controllers/questions_controller.rb | 216 ++++++--- .../questions_sections_controller.rb | 106 +++++ .../questions_statuses_controller.rb | 82 ++++ .../app/helpers/questions_helper.rb | 54 ++- .../redmine_questions/app/models/question.rb | 290 ++++++++++++ .../app/models/questions_answer.rb | 126 ++++++ .../app/models/questions_section.rb | 92 ++++ .../app/models/questions_settings.rb | 47 ++ .../app/models/questions_status.rb | 38 ++ .../auto_completes/_questions_tags.json.erb | 6 + .../app/views/boards/index.html.erb | 1 - .../app/views/boards/show.html.erb | 64 --- .../mailer/question_answer_added.html.erb | 5 + .../mailer/question_answer_added.text.erb | 6 + .../mailer/question_comment_added.html.erb | 5 + .../mailer/question_comment_added.text.erb | 6 + .../mailer/question_question_added.html.erb | 5 + .../mailer/question_question_added.text.erb | 6 + .../app/views/messages/_form.html.erb | 39 -- .../app/views/messages/edit.html.erb | 18 - .../app/views/messages/show.html.erb | 144 ------ .../projects/_questions_settings.html.erb | 38 ++ .../app/views/questions/_form.html.erb | 43 ++ .../app/views/questions/_form_tags.html.erb | 23 - .../app/views/questions/_forums.html.erb | 68 --- .../views/questions/_latest_topics.html.erb | 18 +- .../app/views/questions/_notice.html.erb | 3 - .../views/questions/_popular_topics.html.erb | 18 + .../app/views/questions/_question.html.erb | 65 +++ .../views/questions/_question_item.html.erb | 23 + .../views/questions/_question_list.html.erb | 47 ++ .../app/views/questions/_tag_cloud.html.erb | 35 -- .../questions/_top_sticky_topics.html.erb | 20 +- .../app/views/questions/_topic_list.html.erb | 10 +- .../views/questions/_voted_topics.html.erb | 16 - .../autocomplete_for_subject.html.erb | 1 + .../questions/autocomplete_for_topic.html.erb | 1 - .../app/views/questions/edit.html.erb | 15 + .../app/views/questions/index.html.erb | 35 ++ .../app/views/questions/new.html.erb | 9 +- .../app/views/questions/show.html.erb | 6 + .../app/views/questions/topics.html.erb | 31 -- .../app/views/questions/update_form.js.erb | 1 + .../views/questions_answers/_actions.html.erb | 5 + .../questions_answers/_answer_item.html.erb | 23 + .../views/questions_answers/_form.html.erb | 10 + .../app/views/questions_answers/edit.html.erb | 12 + .../questions_comments/_comment.html.erb | 27 ++ .../questions_comments/_comment_form.html.erb | 7 + .../questions_comments/_comment_list.html.erb | 12 + .../_comments_container.html.erb | 7 + .../views/questions_comments/create.js.erb | 3 + .../views/questions_comments/edit.html.erb | 12 + .../views/questions_sections/_form.html.erb | 7 + .../questions_sections/_new_modal.html.erb | 8 + .../views/questions_sections/_tiles.html.erb | 29 ++ .../views/questions_sections/create.js.erb | 8 + .../views/questions_sections/edit.html.erb | 11 + .../views/questions_sections/index.html.erb | 29 ++ .../app/views/questions_sections/new.html.erb | 11 + .../app/views/questions_sections/new.js.erb | 2 + .../views/questions_statuses/_form.html.erb | 14 + .../views/questions_statuses/edit.html.erb | 6 + .../views/questions_statuses/index.api.rsb | 10 + .../app/views/questions_statuses/new.html.erb | 6 + .../app/views/settings/_questions.html.erb | 3 - .../assets/images/answered.svg | 8 + .../assets/images/answered_check.svg | 7 + .../assets/images/book_open.png | Bin 0 -> 622 bytes .../assets/images/downvote.svg | 15 + .../assets/images/downvote_arrow.svg | 3 + .../assets/images/upvote.graffle | Bin 0 -> 1794 bytes .../assets/images/upvote.svg | 15 + .../assets/images/upvote_arrow.svg | 3 + .../assets/images/voting.svg | 26 ++ .../javascripts/jquery.simplecolorpicker.js | 235 ++++++++++ .../{questions.js => redmine_questions.js} | 0 .../assets/javascripts/tag-it.js | 392 ----------------- .../stylesheets/jquery.simplecolorpicker.css | 88 ++++ .../assets/stylesheets/jquery.tagit.css | 54 --- .../assets/stylesheets/questions.css | 239 ---------- .../assets/stylesheets/redmine_questions.css | 402 +++++++++++++++++ .../redmine_questions/config/locales/en.yml | 76 +++- .../redmine_questions/config/locales/es.yml | 2 +- .../redmine_questions/config/locales/ru.yml | 75 +++- .../redmine_questions/config/locales/zh.yml | 5 +- plugins/redmine_questions/config/routes.rb | 57 ++- .../migrate/001_acts_as_votable_migration.rb | 31 +- .../db/migrate/002_add_viewing_migration.rb | 25 +- .../db/migrate/003_add_tagging_migration.rb | 21 +- .../db/migrate/004_create_questions.rb | 39 ++ .../migrate/005_create_questions_sections.rb | 31 ++ .../migrate/006_create_questions_answers.rb | 35 ++ .../migrate/007_create_questions_statuses.rb | 32 ++ plugins/redmine_questions/doc/CHANGELOG | 14 +- plugins/redmine_questions/doc/COPYING | 2 +- plugins/redmine_questions/doc/LICENSE | 18 +- plugins/redmine_questions/init.rb | 82 ++-- .../lib/acts_as_attachable_questions/init.rb | 28 ++ .../lib/acts_as_attachable_questions.rb | 108 +++++ .../lib/acts_as_votable_vote_patch.rb | 16 - .../lib/redmine_questions.rb | 33 +- .../hooks/views_layouts_hook.rb | 23 +- .../auto_completes_controller_patch.rb | 48 ++ .../patches/boards_controller_patch.rb | 21 - .../patches/comment_patch.rb | 51 +++ .../application_controller_patch.rb | 37 ++ .../redmine_questions/patches/mailer_patch.rb | 87 ++++ .../patches/message_patch.rb | 44 -- .../patches/messages_controller_patch.rb | 29 -- .../patches/notifiable_patch.rb | 49 +++ .../patches/project_patch.rb | 36 ++ .../patches/projects_helper_patch.rb | 56 +++ .../redmine_questions/patches/user_patch.rb | 19 + .../lib/tasks/migrate_from_boards.rake | 59 +++ .../test/fixtures/comments-3.4.6.yml | 17 + .../test/fixtures/comments.yml | 16 + .../test/fixtures/questions.yml | 26 ++ .../test/fixtures/questions_answers.yml | 12 + .../test/fixtures/questions_sections.yml | 25 ++ .../test/fixtures/taggings.yml | 19 + .../redmine_questions/test/fixtures/tags.yml | 6 + .../redmine_crm/images/vcard.png | Bin 0 -> 533 bytes .../javascripts/Chart.bundle.min.js | 16 + .../redmine_crm/javascripts/select2.js | 3 + .../javascripts/select2_helpers.js | 39 ++ .../redmine_crm/stylesheets/select2.css | 413 ++++++++++++++++++ .../questions_answers_controller_test.rb | 149 +++++++ .../questions_comments_controller_test.rb | 107 +++++ .../functional/questions_controller_test.rb | 236 +++++++++- .../questions_sections_controller_test.rb | 156 +++++++ .../test/integration/common_views_test.rb | 66 +++ plugins/redmine_questions/test/test_helper.rb | 115 +++++ .../test/unit/question_test.rb | 166 +++++++ .../test/unit/questions_section_test.rb | 42 ++ .../redmine_questions/test/unit/user_test.rb | 34 ++ 140 files changed, 5342 insertions(+), 1430 deletions(-) create mode 100644 plugins/redmine_questions/app/controllers/questions_answers_controller.rb create mode 100644 plugins/redmine_questions/app/controllers/questions_comments_controller.rb create mode 100644 plugins/redmine_questions/app/controllers/questions_sections_controller.rb create mode 100644 plugins/redmine_questions/app/controllers/questions_statuses_controller.rb create mode 100644 plugins/redmine_questions/app/models/question.rb create mode 100644 plugins/redmine_questions/app/models/questions_answer.rb create mode 100644 plugins/redmine_questions/app/models/questions_section.rb create mode 100644 plugins/redmine_questions/app/models/questions_settings.rb create mode 100644 plugins/redmine_questions/app/models/questions_status.rb create mode 100644 plugins/redmine_questions/app/views/auto_completes/_questions_tags.json.erb delete mode 100644 plugins/redmine_questions/app/views/boards/index.html.erb delete mode 100644 plugins/redmine_questions/app/views/boards/show.html.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_answer_added.html.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_answer_added.text.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_comment_added.html.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_comment_added.text.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_question_added.html.erb create mode 100644 plugins/redmine_questions/app/views/mailer/question_question_added.text.erb delete mode 100644 plugins/redmine_questions/app/views/messages/_form.html.erb delete mode 100644 plugins/redmine_questions/app/views/messages/edit.html.erb delete mode 100644 plugins/redmine_questions/app/views/messages/show.html.erb create mode 100644 plugins/redmine_questions/app/views/projects/_questions_settings.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/_form.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/_form_tags.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/_forums.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/_notice.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/_popular_topics.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/_question.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/_question_item.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/_question_list.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/_tag_cloud.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/_voted_topics.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/autocomplete_for_subject.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/autocomplete_for_topic.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/edit.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/index.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/show.html.erb delete mode 100644 plugins/redmine_questions/app/views/questions/topics.html.erb create mode 100644 plugins/redmine_questions/app/views/questions/update_form.js.erb create mode 100644 plugins/redmine_questions/app/views/questions_answers/_actions.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_answers/_answer_item.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_answers/_form.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_answers/edit.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/_comment.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/_comment_form.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/_comment_list.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/_comments_container.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/create.js.erb create mode 100644 plugins/redmine_questions/app/views/questions_comments/edit.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/_form.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/_new_modal.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/_tiles.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/create.js.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/edit.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/index.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/new.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_sections/new.js.erb create mode 100644 plugins/redmine_questions/app/views/questions_statuses/_form.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_statuses/edit.html.erb create mode 100644 plugins/redmine_questions/app/views/questions_statuses/index.api.rsb create mode 100644 plugins/redmine_questions/app/views/questions_statuses/new.html.erb delete mode 100644 plugins/redmine_questions/app/views/settings/_questions.html.erb create mode 100644 plugins/redmine_questions/assets/images/answered.svg create mode 100644 plugins/redmine_questions/assets/images/answered_check.svg create mode 100644 plugins/redmine_questions/assets/images/book_open.png create mode 100644 plugins/redmine_questions/assets/images/downvote.svg create mode 100644 plugins/redmine_questions/assets/images/downvote_arrow.svg create mode 100644 plugins/redmine_questions/assets/images/upvote.graffle create mode 100644 plugins/redmine_questions/assets/images/upvote.svg create mode 100644 plugins/redmine_questions/assets/images/upvote_arrow.svg create mode 100644 plugins/redmine_questions/assets/images/voting.svg create mode 100644 plugins/redmine_questions/assets/javascripts/jquery.simplecolorpicker.js rename plugins/redmine_questions/assets/javascripts/{questions.js => redmine_questions.js} (100%) delete mode 100755 plugins/redmine_questions/assets/javascripts/tag-it.js create mode 100644 plugins/redmine_questions/assets/stylesheets/jquery.simplecolorpicker.css delete mode 100755 plugins/redmine_questions/assets/stylesheets/jquery.tagit.css delete mode 100644 plugins/redmine_questions/assets/stylesheets/questions.css create mode 100644 plugins/redmine_questions/assets/stylesheets/redmine_questions.css create mode 100644 plugins/redmine_questions/db/migrate/004_create_questions.rb create mode 100644 plugins/redmine_questions/db/migrate/005_create_questions_sections.rb create mode 100644 plugins/redmine_questions/db/migrate/006_create_questions_answers.rb create mode 100644 plugins/redmine_questions/db/migrate/007_create_questions_statuses.rb mode change 100644 => 100755 plugins/redmine_questions/doc/CHANGELOG create mode 100755 plugins/redmine_questions/lib/acts_as_attachable_questions/init.rb create mode 100755 plugins/redmine_questions/lib/acts_as_attachable_questions/lib/acts_as_attachable_questions.rb delete mode 100644 plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/auto_completes_controller_patch.rb delete mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/boards_controller_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/comment_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/compatibility/application_controller_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/mailer_patch.rb delete mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/message_patch.rb delete mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/messages_controller_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/notifiable_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/project_patch.rb create mode 100644 plugins/redmine_questions/lib/redmine_questions/patches/projects_helper_patch.rb create mode 100644 plugins/redmine_questions/lib/tasks/migrate_from_boards.rake create mode 100644 plugins/redmine_questions/test/fixtures/comments-3.4.6.yml create mode 100644 plugins/redmine_questions/test/fixtures/comments.yml create mode 100644 plugins/redmine_questions/test/fixtures/questions.yml create mode 100644 plugins/redmine_questions/test/fixtures/questions_answers.yml create mode 100644 plugins/redmine_questions/test/fixtures/questions_sections.yml create mode 100644 plugins/redmine_questions/test/fixtures/taggings.yml create mode 100644 plugins/redmine_questions/test/fixtures/tags.yml create mode 100644 plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/images/vcard.png create mode 100644 plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/Chart.bundle.min.js create mode 100644 plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/select2.js create mode 100644 plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/select2_helpers.js create mode 100644 plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/stylesheets/select2.css create mode 100644 plugins/redmine_questions/test/functional/questions_answers_controller_test.rb create mode 100644 plugins/redmine_questions/test/functional/questions_comments_controller_test.rb create mode 100644 plugins/redmine_questions/test/functional/questions_sections_controller_test.rb create mode 100644 plugins/redmine_questions/test/integration/common_views_test.rb create mode 100644 plugins/redmine_questions/test/unit/question_test.rb create mode 100644 plugins/redmine_questions/test/unit/questions_section_test.rb create mode 100644 plugins/redmine_questions/test/unit/user_test.rb diff --git a/README.md b/README.md index e38b668..07e5519 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,7 @@ redmine_private_wiki ### Redmine Q&A plugin - * questions 0.0.7 + * questions 1.0.0 * https://www.redmine.org/plugins/redmine_questions * http://www.redminecrm.com/projects/questions diff --git a/plugins/redmine_questions/Gemfile b/plugins/redmine_questions/Gemfile index 156042f..58237bb 100644 --- a/plugins/redmine_questions/Gemfile +++ b/plugins/redmine_questions/Gemfile @@ -1 +1 @@ -gem "redmine_crm" \ No newline at end of file +gem "redmine_crm" diff --git a/plugins/redmine_questions/app/controllers/questions_answers_controller.rb b/plugins/redmine_questions/app/controllers/questions_answers_controller.rb new file mode 100644 index 0000000..7ebf11d --- /dev/null +++ b/plugins/redmine_questions/app/controllers/questions_answers_controller.rb @@ -0,0 +1,107 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsAnswersController < ApplicationController + unloadable + + before_action :find_question, :only => [:new, :create] + before_action :find_answer, :only => [:update, :destroy, :edit, :show] + + helper :questions + helper :watchers + helper :attachments + + include QuestionsHelper + + def new + @answer = QuestionsAnswer.new(:question => @question_item) + end + + def edit + end + + def update + @answer.safe_attributes = params[:answer] + @answer.save_attachments(params[:attachments]) + if @answer.save + flash[:notice] = l(:label_answer_successful_update) + respond_to do |format| + format.html { redirect_to_question } + end + else + respond_to do |format| + format.html { render :edit} + end + end + end + + def create + @answer = QuestionsAnswer.new + @answer.author = User.current + @answer.question = @question_item + @answer.safe_attributes = params[:answer] + @answer.save_attachments(params[:attachments]) + if @answer.save + flash[:notice] = l(:label_answer_successful_added) + render_attachment_warning_if_needed(@answer) + end + redirect_to_question + end + + def destroy + if @answer.destroy + flash[:notice] = l(:notice_successful_delete) + respond_to do |format| + format.html { redirect_to_question } + format.api { render_api_ok } + end + else + flash[:error] = l(:notice_unsuccessful_save) + end + end + + def preview + if params[:id].present? && answer = Question.find_by_id(params[:id]) + @previewed = answer + end + @text = (params[:answer] ? params[:answer][:content] : nil) + render :partial => 'common/preview' + end + + private + + def redirect_to_question + redirect_to question_path(@answer.question, :anchor => "question_item_#{@answer.id}") + end + + def find_answer + @answer = QuestionsAnswer.find(params[:id]) + @question_item = @answer.question + @project = @question_item.project + rescue ActiveRecord::RecordNotFound + render_404 + end + + def find_question + @question_item = Question.visible.find(params[:question_id]) unless params[:question_id].blank? + @project = @question_item.project + rescue ActiveRecord::RecordNotFound + render_404 + end +end diff --git a/plugins/redmine_questions/app/controllers/questions_comments_controller.rb b/plugins/redmine_questions/app/controllers/questions_comments_controller.rb new file mode 100644 index 0000000..7c4512e --- /dev/null +++ b/plugins/redmine_questions/app/controllers/questions_comments_controller.rb @@ -0,0 +1,78 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsCommentsController < ApplicationController + before_action :find_comment_source + + helper :questions + + def create + raise Unauthorized unless @comment_source.commentable? + + @comment = Comment.new + @comment.safe_attributes = params[:comment] + @comment.author = User.current + if @comment_source.comments << @comment + @comment_source.touch + flash[:notice] = l(:label_comment_added) unless request.xhr? + end + + respond_to do |format| + format.html { redirect_to_question } + format.js + end + end + + def edit + @comment = @comment_source.comments.find(params[:id]) + end + + def update + @comment = @comment_source.comments.find(params[:id]) + @comment.safe_attributes = params[:comment] + if @comment.save + flash[:notice] = l(:notice_successful_update) + redirect_to_question + else + render :action => 'edit' + end + end + + def destroy + @comment_source.comments.find(params[:id]).destroy + redirect_to_question + end + + private + + def find_comment_source + comment_source_type = params[:source_type] + comment_source_id = params[:source_id] + + klass = Object.const_get(comment_source_type.camelcase) + @comment_source = klass.find(comment_source_id) + rescue ActiveRecord::RecordNotFound + render_404 + end + + def redirect_to_question + question = @comment_source.is_a?(QuestionsAnswer) ? @comment_source.question : @comment_source + redirect_to question_path(question, :anchor => @comment.blank? ? "#{@comment_source.class.name.underscore}_#{@comment_source.id}" : "comment_#{@comment.id}") + end +end diff --git a/plugins/redmine_questions/app/controllers/questions_controller.rb b/plugins/redmine_questions/app/controllers/questions_controller.rb index ab08eef..224844c 100644 --- a/plugins/redmine_questions/app/controllers/questions_controller.rb +++ b/plugins/redmine_questions/app/controllers/questions_controller.rb @@ -1,76 +1,146 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + class QuestionsController < ApplicationController unloadable - before_filter :find_optional_project, :only => [:autocomplete_for_topic, :topics] - before_filter :find_optional_board, :only => [:autocomplete_for_topic, :topics] - before_filter :find_topic, :authorize, :only => :vote - before_filter :find_topics, :only => [:topics, :autocomplete_for_topic] + before_action :find_question, :only => [:edit, :show, :update, :destroy] + before_action :find_optional_project, :only => [:index, :update_form, :new, :create, :autocomplete_for_subject] + before_action :find_section, :only => [:new, :create, :update, :edit] + before_action :find_questions, :only => [:autocomplete_for_subject, :index] #:autocomplete_for_subject helper :questions - if Redmine::VERSION.to_s > '2.1' - helper :boards - end + helper :watchers + helper :attachments + include QuestionsHelper def index - @boards = Board.visible.includes(:last_message => :author).includes(:messages).order(:project_id) - # show the board if there is only one - if @boards.size == 1 - @board = @boards.first - redirect_to project_board_url(@board, :project_id => @board.project) + @question_item = Question.new + end + + def new + @question_item = Question.new + @question_item.section ||= @section + end + + def show + @answers = @question_item.answers.by_accepted.by_votes.by_date + if @answers + @limit = Setting.issues_export_limit.to_i + @answer_count = @answers.count + @answer_pages = Paginator.new @answer_count, @limit, (params[:page] || 1) + @offset ||= @answer_pages.offset + end + @answer = QuestionsAnswer.new + @answer.question = @question_item + @question_item.view request.remote_addr, User.current + end + + def update + @question_item.safe_attributes = params[:question] + @question_item.save_attachments(params[:attachments]) + if @question_item.save + flash[:notice] = l(:label_question_successful_update) + respond_to do |format| + format.html {redirect_to :action => :show, :id => @question_item} + end else - render "boards/index" + respond_to do |format| + format.html { render :edit} + end end end - def topics + def update_form + @question_item = Question.new + @question_item.safe_attributes = params[:question] end - def vote - User.current.voted_for?(@topic) ? @topic.dislike(User.current.becomes(Principal)) : @topic.like(User.current.becomes(Principal)) + def create + @question_item = Question.new + @question_item.section = @section + @question_item.safe_attributes = params[:question] + @question_item.author = User.current + @question_item.save_attachments(params[:attachments]) + respond_to do |format| - format.html { redirect_to_referer_or {render :text => (watching ? 'Vote added.' : 'Vote removed.'), :layout => true}} + if @question_item.save + format.html { redirect_to :action => :show, :id => @question_item} + else + format.html { render :action => 'new' } + end end end - def autocomplete_for_topic + def autocomplete_for_subject render :layout => false end - def convert_issue - issue = Issue.visible.find(params[:issue_id]) - board = Board.visible.find(params[:board_id]) - message = Message.new - message.author = issue.author - message.created_on = issue.created_on - message.board = board - message.subject = issue.subject - message.content = issue.description.blank? ? issue.subject : issue.description - message.watchers = issue.watchers - message.add_watcher(issue.author) - message.attachments = issue.attachments - issue.journals.select{|j| !j.notes.blank?}.each do |journal| - reply = Message.new - reply.author = journal.user - reply.created_on = journal.created_on - reply.subject = "Re: #{message.subject}" - reply.content = journal.notes - reply.board = board - message.children << reply - end - if message.save - issue.destroy if params[:destroy] - redirect_to board_message_path(board, message) - else - redirect_back_or_default({:controller => 'issues', :action => 'show', :id => issue}) - end + # def convert_issue_to_question + # issue = Issue.visible.find(params[:issue_id]) + # question = Question.from_issue(issue) + # if question.save + # issue.destroy if params[:destroy] + # redirect_to _question_path(question) + # else + # redirect_back_or_default({:controller => 'issues', :action => 'show', :id => issue}) + # end + # end + # def convert_to_issue + # issue = @question_item.to_issue + # if issue.save + # redirect_to issue_path(issue) + # else + # redirect_back_or_default question_path(@question_item) + # end + # end + + def destroy + back_id = @question_item.section + if @question_item.destroy + flash[:notice] = l(:notice_successful_delete) + else + flash[:error] = l(:notice_unsuccessful_save) + end + respond_to do |format| + format.html { redirect_back_or_default questions_path(:section_id => back_id) } + format.api { render_api_ok } + end end -private + def preview + if params[:id].present? && query = Question.find_by_id(params[:question_id]) + @previewed = query + end + @text = (params[:question] ? params[:question][:content] : nil) + render :partial => 'common/preview' + end + private - def find_topics + def find_questions seach = params[:q] || params[:topic_search] + @section = QuestionsSection.find(params[:section_id]) if params[:section_id] + + scope = Question.visible + scope = scope.where(:section_id => @section) if @section columns = ["subject", "content"] tokens = seach.to_s.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect{|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}.uniq.select {|w| w.length > 1 } @@ -79,39 +149,49 @@ private sql = (['(' + token_clauses.join(' OR ') + ')'] * tokens.size).join(' AND ') find_options = [sql, * (tokens.collect {|w| "%#{w.downcase}%"} * token_clauses.size).sort] - scope = Message.joins(:board).where({}) - scope = scope.where("#{Message.table_name}.parent_id IS NULL") - scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project - scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board + scope = scope.in_project(@project) scope = scope.where(find_options) unless tokens.blank? - scope = scope.visible.includes(:board).order("#{Message.table_name}.updated_on DESC") + @sort_order = params[:sort_order] + case @sort_order + when 'popular' + scope = scope.by_views.by_update + when 'newest' + scope = scope.by_date + when 'active' + scope = scope.by_update + when 'unanswered' + scope = scope.questions.where(:answers_count => 0) + else + scope = scope.by_votes.by_views.by_update + end - @topic_count = scope.count @limit = per_page_option - @topic_pages = Paginator.new(self, @topic_count, @limit, params[:page]) - @offset = @topic_pages.current.offset + @offset = params[:page].to_i*@limit scope = scope.limit(@limit).offset(@offset) scope = scope.tagged_with(params[:tag]) unless params[:tag].blank? - @topics = scope + + @topic_count = scope.count + @topic_pages = Paginator.new @topic_count, @limit, params[:page] + + @question_items = scope end - def find_topic - @topic = Message.visible.find(params[:id]) unless params[:id].blank? - @board = @topic.board - @project = @board.project + def find_section + @section = QuestionsSection.find_by_id(params[:section_id] || (params[:question] && params[:question][:section_id])) + @section ||= @project.questions_sections.first rescue ActiveRecord::RecordNotFound render_404 end - def find_optional_board - @board = Board.visible.find(params[:board_id]) unless params[:board_id].blank? - @project = @board.project if @board - allowed = User.current.allowed_to?({:controller => params[:controller], :action => params[:action]}, @project, :global => true) - allowed ? true : deny_access + def find_question + if Redmine::VERSION.to_s =~ /^2.6/ + @question_item = Question.visible.find(params[:id], readonly: false) + else + @question_item = Question.visible.find(params[:id]) + end + return deny_access unless @question_item.visible? + @project = @question_item.project rescue ActiveRecord::RecordNotFound render_404 end - - - end diff --git a/plugins/redmine_questions/app/controllers/questions_sections_controller.rb b/plugins/redmine_questions/app/controllers/questions_sections_controller.rb new file mode 100644 index 0000000..b33376d --- /dev/null +++ b/plugins/redmine_questions/app/controllers/questions_sections_controller.rb @@ -0,0 +1,106 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsSectionsController < ApplicationController + menu_item :questions + + before_action :find_section, :only => [:edit, :update, :destroy] + before_action :find_optional_project, :only => [:index, :new, :create] + + helper :questions + + def new + @section = @project.questions_sections.build + + respond_to do |format| + format.html + format.js + end + end + + def create + @section = @project.nil? ? QuestionsSection.new : @project.questions_sections.build + @section.safe_attributes = params[:questions_section] + if @section.save + respond_to do |format| + format.html do + flash[:notice] = l(:notice_successful_create) + redirect_to_settings_in_projects + end + format.js + end + else + respond_to do |format| + format.html { render :action => 'new' } + format.js + end + end + end + + def edit + end + + def update + @section.safe_attributes = params[:questions_section] + if @section.save + respond_to do |format| + format.html do + flash[:notice] = l(:notice_successful_update) + redirect_to_settings_in_projects + end + format.js { head 200 } + end + else + respond_to do |format| + format.html { render :action => 'edit' } + format.js { head 422 } + end + end + end + + def destroy + @section.destroy + respond_to do |format| + format.html { redirect_to_settings_in_projects } + end + end + + def index + ApplicationController.menu_item :questions + @question_item = Question.new + @sections = QuestionsSection.visible.order(:project_id).sorted.for_project(@project) + redirect_to project_questions_path(:section_id => @sections.last, :project_id => @sections.last.project) if @sections.size == 1 + + @sections = @sections.with_questions_count + end + +private + + def find_section + @section = QuestionsSection.find(params[:id]) + @project = @section.project + rescue ActiveRecord::RecordNotFound + render_404 + end + + def redirect_to_settings_in_projects + redirect_back_or_default( @project ? settings_project_path(@project, :tab => 'questions') : plugin_settings_path(:id => "redmine_questions")) + end + +end diff --git a/plugins/redmine_questions/app/controllers/questions_statuses_controller.rb b/plugins/redmine_questions/app/controllers/questions_statuses_controller.rb new file mode 100644 index 0000000..35db2e2 --- /dev/null +++ b/plugins/redmine_questions/app/controllers/questions_statuses_controller.rb @@ -0,0 +1,82 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsStatusesController < ApplicationController + unloadable + layout 'admin' + + before_action :require_admin, :except => :index + before_action :require_admin_or_api_request, :only => :index + + accept_api_auth :index + + def index + respond_to do |format| + format.api { + @questions_statuses = QuestionsStatus.sorted + } + end + end + + def new + @questions_status = QuestionsStatus.new + end + + def create + @questions_status = QuestionsStatus.new(params[:questions_status]) + if request.post? && @questions_status.save + flash[:notice] = l(:notice_successful_create) + redirect_to :action => "plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses' + else + render :action => 'new' + end + end + + def edit + @questions_status = QuestionsStatus.find(params[:id]) + end + + def update + @questions_status = QuestionsStatus.find(params[:id]) + if @questions_status.update_attributes(params[:questions_status]) + respond_to do |format| + format.html { + flash[:notice] = l(:notice_successful_update) + redirect_to :action => 'plugin', :id => 'redmine_questions', :controller => 'settings', :tab => 'questions_statuses' + } + format.js { head 200 } + end + else + respond_to do |format| + format.html { render :action => 'edit' } + format.js { head 422 } + end + end + end + + def destroy + QuestionsStatus.find(params[:id]).destroy + redirect_to :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses' + rescue + flash[:error] = l(:error_products_unable_delete_questions_status) + redirect_to :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses' + end + + +end diff --git a/plugins/redmine_questions/app/helpers/questions_helper.rb b/plugins/redmine_questions/app/helpers/questions_helper.rb index ac0c279..a9e353c 100644 --- a/plugins/redmine_questions/app/helpers/questions_helper.rb +++ b/plugins/redmine_questions/app/helpers/questions_helper.rb @@ -1,15 +1,51 @@ +# encoding: utf-8 +# +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + module QuestionsHelper - def vote_tag(object, user, options={}) - content_tag("span", vote_link(object, user)) + def question_status_tag(status) + return '' unless status + content_tag(:span, status.name, :class => 'question-status-tag tag-label-color', :style => "background-color: #{status.color}") end - def vote_link(object, user) - return '' unless user && user.logged? && user.respond_to?('voted_for?') - voted = user.voted_for?(object) - url = {:controller => 'questions', :action => 'vote', :id => object} - link_to((voted ? l(:button_questions_unvote) : l(:button_questions_vote)), url, - :class => (voted ? 'icon icon-vote' : 'icon icon-unvote')) + def allow_voting?(votable, user = User.current) + (votable.author == user && QuestionsSettings.vote_own? || votable.author != user) && + user.allowed_to?(:vote_questions, votable.project) + end - end + def question_breadcrumb(item) + links = [] + links << link_to(l(:label_questions), { :controller => 'questions_sections', :action => 'index', :project_id => nil}) + links << link_to(item.project.name, { :controller => 'questions_sections', :action => 'index', :project_id => item.project }) if item && item.project + links << link_to(item.section.name, { :controller => 'questions', :action => 'index', :project_id => item.project, :section_id => item.section }) if item && item.is_a?(Question) && item.section.present? + breadcrumb links + end + + def global_modificator + return {:global => true} if !@project + {} + end + + def path_to_sections + return project_questions_sections_path if @project + questions_sections_path + end end diff --git a/plugins/redmine_questions/app/models/question.rb b/plugins/redmine_questions/app/models/question.rb new file mode 100644 index 0000000..99efbcd --- /dev/null +++ b/plugins/redmine_questions/app/models/question.rb @@ -0,0 +1,290 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class Question < ActiveRecord::Base + unloadable + + include Redmine::SafeAttributes + extend ApplicationHelper + + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + belongs_to :section, :class_name => 'QuestionsSection', :foreign_key => 'section_id' + belongs_to :status, :class_name => 'QuestionsStatus', :foreign_key => 'status_id' + + delegate :section_type, :to => :section, :allow_nil => true + + has_many :answers, :class_name => 'QuestionsAnswer', :dependent => :destroy + + if ActiveRecord::VERSION::MAJOR >= 4 + has_many :comments, lambda { order('created_on') }, :as => :commented, :dependent => :delete_all + else + has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on" + end + rcrm_acts_as_viewed + + acts_as_attachable_questions + acts_as_watchable + + acts_as_event :datetime => :created_on, + :url => Proc.new {|o| {:controller => 'questions', :action => 'show', :id => o }}, + :type => Proc.new {|o| 'icon ' + (o.is_solution? ? 'icon-solution': 'icon-question')}, + :description => :content, + :title => Proc.new {|o| o.subject } + + + if ActiveRecord::VERSION::MAJOR >= 4 + acts_as_activity_provider :type => 'questions', + :permission => :view_questions, + :author_key => :author_id, + :timestamp => "#{table_name}.created_on", + :scope => joins({:section => :project}, :author) + acts_as_searchable :columns => ["#{table_name}.subject", + "#{table_name}.content", + "#{QuestionsAnswer.table_name}.content"], + :scope => joins({:section => :project}, :answers), + :project_key => "#{QuestionsSection.table_name}.project_id" + else + acts_as_activity_provider :type => 'questions', + :permission => :view_questions, + :author_key => :author_id, + :timestamp => "#{table_name}.created_on", + :find_options => { :include => [{:section => :project}, :author] } + acts_as_searchable :columns => ["#{table_name}.subject", + "#{table_name}.content", + "#{QuestionsAnswer.table_name}.content"], + :include => [{:section => :project}, :answers], + :project_key => "#{QuestionsSection.table_name}.project_id" + end + + scope :solutions, lambda { joins(:section).where(:questions_sections => {:section_type => QuestionsSection::SECTION_TYPE_SOLUTIONS}) } + scope :questions, lambda { joins(:section).where(:questions_sections => {:section_type => QuestionsSection::SECTION_TYPE_QUESTIONS}) } + scope :by_votes, lambda { order("#{Question.table_name}.cached_weighted_score DESC") } + scope :by_date, lambda { order("#{Question.table_name}.created_on DESC") } + scope :by_update, lambda { order("#{Question.table_name}.updated_on DESC") } + scope :by_views, lambda { order("#{Question.table_name}.views DESC") } + scope :positive, lambda { where("#{Question.table_name}.cached_weighted_score > 0") } + scope :featured, lambda {|*args| where(:featured => true) } + scope :in_section, lambda { |section| + where(:section_id => section) if section.present? + } + scope :in_project, lambda { |project| + joins(:section => :project).where("#{QuestionsSection.table_name}.project_id = ?", project) if project.present? + } + scope :visible, lambda { |*args| + joins(:section => :project) + .where(Project.allowed_to_condition(args.shift || User.current, :view_questions, *args)) + } + + validates_presence_of :author, :content, :subject, :section + + after_create :add_author_as_watcher + after_create :send_notification + + safe_attributes 'author', + 'subject', + 'content', + 'tag_list', + 'section_id', + 'status_id' + + safe_attributes 'status_id', + :if => lambda {|question, user| question.is_idea?} + + def self.visible_condition(user) + user.reload if user + global_questions_allowed = user.allowed_to?(:view_questions, nil) + projects_allowed_to_view_questions = Project.where(Project.allowed_to_condition(user, :view_questions)).pluck(:id) + allowed_to_view_condition = global_questions_allowed ? "(#{table_name}.project_id IS NULL)" : '(0=1)' + allowed_to_view_condition += projects_allowed_to_view_questions.empty? ? ' OR (0=1) ' : " OR (#{table_name}.project_id IN (#{projects_allowed_to_view_questions.join(',')}))" + + user.admin? ? '(1=1)' : allowed_to_view_condition + end + + def self.related(question, limit) + tokens = question.subject.strip.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}). + collect {|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '').gsub(%r{('|"|`)}, '')}.select{|m| m.size > 3} || "" + + related_questions = where(tokens.map{ |t| "LOWER(subject) LIKE LOWER('%#{t}%')" }.join(' OR ')) + related_questions = related_questions.in_project(question.project) + related_questions = related_questions.where("#{Question.table_name}.id != ?", question.id) + related_questions.limit(limit).to_a.compact + end + + def commentable?(user = User.current) + return false if locked? + user.allowed_to?(:comment_question, project) + end + + def visible?(user=User.current) + user.allowed_to?(:view_questions, project) + end + + def to_param + "#{id}-#{ActiveSupport::Inflector.transliterate(subject || " ").parameterize}" + end + + def section_name + section.try(:name) + end + + def project + section.project + end + + def allow_voting? + false + end + + def allow_liking? + section.allow_liking? + end + + def allow_answering? + !locked? && section.allow_answering? + end + + def last_reply + answers.order('created_on DESC').last + end + + def last_comment + Comment.where(:commented_type => self.class.name, :commented_id => [id] + answer_ids).order('created_on DESC').last + end + + def replies_count + answers.count + end + + def editable_by?(user) + (author == user && user.allowed_to?(:edit_own_questions, project)) || + user.allowed_to?(:edit_questions, project) + end + + def destroyable_by?(user) + user.allowed_to?(:delete_questions, project) + end + + def votable_by?(user) + user.allowed_to?(:vote_questions, project) + end + + def convertable_by?(user) + return false if project.blank? + user.allowed_to?(:convert_questions, project) + end + + def answered? + answers.where(:accepted => true).any? + end + + def is_question? + section && section.is_questions? + end + + def is_solution? + section && section.is_solutions? + end + + def is_idea? + section && section.is_ideas? + end + + # def to_issue + # issue = Issue.new + # issue.author = self.author + # issue.created_on = self.created_on + # issue.subject = self.subject + # issue.description = self.content + # issue.watchers = self.watchers + # issue.attachments = self.attachments + # issue.project = self.project + # issue.tracker = self.project.trackers.first + # issue.status = IssueStatus.first + # self.answers.each do |ans| + # journal = Journal.new(:notes => ans.content, :user => ans.author) + # issue.journals << journal + # end + # issue + # end + + # def self.from_issue(issue) + # question = Question.new + # question.author = issue.author + # question.created_on = issue.created_on + # question.subject = issue.subject + # question.content = issue.description.blank? ? issue.subject : issue.description + # question.watchers = issue.watchers + # question.attachments = issue.attachments + # question.project = issue.project + # question.section = issue.project.questions_sections.first + # issue.journals.select{|j| j.notes.present?}.each do |journal| + # reply = Question.new + # reply.author = journal.user + # reply.created_on = journal.created_on + # reply.content = journal.notes + # reply.project = issue.project + # reply.question = question + # question.answers << reply + # end + # question + # end + + def notified_users + project.notified_users.select { |user| visible?(user) }.collect(&:mail) + end + + def self.to_text(input) + textile_glyphs = { + '’' => "'", + '‘' => "'", + '<' => '<', + '>' => '>', + '”' => "'", + '“' => '"', + '…' => '...', + '\1—' => '--', + ' → ' => '->', + '¶' => ' ', + ' – ' => '-', + '×' => '-', + '™' => '(TM)', + '®' => '(R)', + '©' => '(C)', + '&' => '&' + }.freeze + + html_regexp = /<(?:[^>"']+|"(?:\\.|[^\\"]+)*"|'(?:\\.|[^\\']+)*')*>/xm + + input.dup.gsub(html_regexp, '').tap do |h| + textile_glyphs.each do |entity, char| + h.gsub!(entity, char) + end + end + end + + private + + def add_author_as_watcher + Watcher.create(:watchable => self, :user => author) + end + + def send_notification + Mailer.question_question_added(self).deliver if Setting.notified_events.include?('question_added') + end +end diff --git a/plugins/redmine_questions/app/models/questions_answer.rb b/plugins/redmine_questions/app/models/questions_answer.rb new file mode 100644 index 0000000..b1e9f0f --- /dev/null +++ b/plugins/redmine_questions/app/models/questions_answer.rb @@ -0,0 +1,126 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsAnswer < ActiveRecord::Base + unloadable + + include Redmine::SafeAttributes + extend ApplicationHelper + + belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' + belongs_to :question, :counter_cache => 'answers_count', :touch => true + + attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4 + + acts_as_attachable_questions + + acts_as_event :datetime => :created_on, + :url => Proc.new {|o| {:controller => 'questions', :action => 'show', :id => o.question, :anchor => "questions_answer_#{o.id}" }}, + :group => :question, + :type => Proc.new {|o| 'icon icon-reply'}, + :description => :content, + :title => Proc.new {|o| o.question.subject } + + if ActiveRecord::VERSION::MAJOR >= 4 + acts_as_activity_provider :type => 'questions', + :permission => :view_questions, + :author_key => :author_id, + :timestamp => "#{table_name}.created_on", + :scope => joins({ :question => { :section => :project } }, :author) + else + acts_as_activity_provider :type => 'questions', + :permission => :view_questions, + :author_key => :author_id, + :timestamp => "#{table_name}.created_on", + :find_options => { :joins => [{ :question => { :section => :project } }, :author] } + end + + scope :visible, lambda {|*args| where(Question.visible_condition(args.shift || User.current)) } + scope :by_votes, lambda { order("#{table_name}.cached_weighted_score DESC") } + scope :by_accepted, lambda { order("#{table_name}.accepted DESC") } + scope :by_date, lambda { order("#{table_name}.created_on DESC") } + scope :featured, lambda {|*args| where(:featured => true) } + + validates_presence_of :question, :author, :content + validate :cannot_answer_to_locked_question, :on => :create + + after_create :add_author_as_watcher + after_create :send_notification + + safe_attributes 'author', + 'content' + + def commentable?(user = User.current) + return false if question.locked? + user.allowed_to?(:comment_question, project) + end + + def cannot_answer_to_locked_question + # Can not reply to a locked topic + errors.add :base, 'Question is locked' if question && question.locked? + end + + def section_name + question.try(:section).try(:name) + end + + def project + question.project if question + end + + def allow_voting? + question && question.section && question.section.allow_voting? + end + + def last_comment + Comment.where(:commented_type => self.class.name, :commented_id => [id] + answer_ids).order('created_on DESC').last + end + + def replies_count + answers.count + end + + def editable_by?(user) + user.allowed_to?(:edit_questions, project) + end + + def destroyable_by?(user) + user.allowed_to?(:delete_answers, project) + end + + def votable_by?(user) + user.allowed_to?(:vote_questions, project) + end + + private + def check_accepted + question.answers.update_all(:accepted => false) if question && + accepted? && + accepted_changed? + end + # + + def add_author_as_watcher + Watcher.create(:watchable => question, :user => author) + end + + def send_notification + Mailer.question_answer_added(self).deliver if Setting.notified_events.include?('question_answer_added') + end +end diff --git a/plugins/redmine_questions/app/models/questions_section.rb b/plugins/redmine_questions/app/models/questions_section.rb new file mode 100644 index 0000000..1263bbf --- /dev/null +++ b/plugins/redmine_questions/app/models/questions_section.rb @@ -0,0 +1,92 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsSection < ActiveRecord::Base + unloadable + include Redmine::SafeAttributes + + belongs_to :project + has_many :questions, :foreign_key => "section_id", :dependent => :destroy + + attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4 + safe_attributes 'name', 'project', 'position', 'description', 'section_type' + + scope :with_questions_count, lambda { select("#{QuestionsSection.table_name}.*, count(#{QuestionsSection.table_name}.id) as questions_count").joins(:questions).order("project_id ASC").group("#{QuestionsSection.table_name}.id, #{QuestionsSection.table_name}.name, #{QuestionsSection.table_name}.project_id, #{QuestionsSection.table_name}.section_type") } + scope :for_project, lambda { |project| where(:project_id => project) unless project.blank? } + scope :visible, lambda {|*args| + joins(:project). + where(Project.allowed_to_condition(args.shift || User.current, :view_questions, *args)) + } + scope :sorted, lambda { order(:position) } + + rcrm_acts_as_list :scope => 'project_id = #{project_id}' + acts_as_watchable + + SECTION_TYPE_QUESTIONS = 'questions' + + validates_presence_of :section_type, :project_id, :name + validates_uniqueness_of :name, :scope => :project_id + + def initialize(attributes=nil, *args) + super + if new_record? + # set default values for new records only + self.section_type ||= SECTION_TYPE_QUESTIONS + end + end + + def to_param + "#{id}-#{ActiveSupport::Inflector.transliterate(name).parameterize}" + end + + def is_questions? + true + end + + def is_solutions? + false + end + + def is_ideas? + false + end + + def allow_voting? + false + end + + def allow_liking? + false + end + + def allow_answering? + is_questions? + end + + def self.types_list + end + + def l_type + I18n.t("label_questions_section_type_#{section_type}") if section_type + end + + def to_s + name + end +end diff --git a/plugins/redmine_questions/app/models/questions_settings.rb b/plugins/redmine_questions/app/models/questions_settings.rb new file mode 100644 index 0000000..bd81f48 --- /dev/null +++ b/plugins/redmine_questions/app/models/questions_settings.rb @@ -0,0 +1,47 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsSettings + unloadable + + IDEA_COLORS = { + :green => 'green', + :blue => 'blue', + :turquoise => 'turquoise', + :light_green => 'lightgreen', + :yellow => 'yellow', + :orange => 'orange', + :red => 'red', + :purple => 'purple', + :gray => 'gray' + } + + class << self + + def vote_own? + false + end + + def show_popular? + false + end + + + end +end diff --git a/plugins/redmine_questions/app/models/questions_status.rb b/plugins/redmine_questions/app/models/questions_status.rb new file mode 100644 index 0000000..1014152 --- /dev/null +++ b/plugins/redmine_questions/app/models/questions_status.rb @@ -0,0 +1,38 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class QuestionsStatus < ActiveRecord::Base + unloadable + include Redmine::SafeAttributes + + belongs_to :question + + attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4 + safe_attributes 'name', 'is_closed', 'position', 'color' + + validates :name, :presence => true, :uniqueness => true + + scope :sorted, lambda { order(:position) } + + rcrm_acts_as_list + + def to_s + name + end +end diff --git a/plugins/redmine_questions/app/views/auto_completes/_questions_tags.json.erb b/plugins/redmine_questions/app/views/auto_completes/_questions_tags.json.erb new file mode 100644 index 0000000..987c6f5 --- /dev/null +++ b/plugins/redmine_questions/app/views/auto_completes/_questions_tags.json.erb @@ -0,0 +1,6 @@ +<%= raw @questions_tags.map { |question_tag| { + 'id' => @names_only ? question_tag.name : question_tag.id, + 'text' => question_tag.name + } + }.to_json +%> diff --git a/plugins/redmine_questions/app/views/boards/index.html.erb b/plugins/redmine_questions/app/views/boards/index.html.erb deleted file mode 100644 index 83b036e..0000000 --- a/plugins/redmine_questions/app/views/boards/index.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "questions/forums" %> \ No newline at end of file diff --git a/plugins/redmine_questions/app/views/boards/show.html.erb b/plugins/redmine_questions/app/views/boards/show.html.erb deleted file mode 100644 index 63b5c80..0000000 --- a/plugins/redmine_questions/app/views/boards/show.html.erb +++ /dev/null @@ -1,64 +0,0 @@ -<%= board_breadcrumb(@board) %> - -
-
-<%= link_to_if_authorized l(:label_message_new), - {:controller => 'messages', :action => 'new', :board_id => @board}, - :class => 'icon icon-add', - :onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' %> -<%= content_tag('span', watcher_link(@board, User.current), :id => 'watcher') %> -
- - - -

<%=h @board.name %>

-

<%=h @board.description %>

- -
- <%= form_tag({:controller => "questions", :action => "topics" }, :method => :get, :id => "query_form") do %> - <%= hidden_field_tag('project_id', @project.to_param) if @project %> - <%= hidden_field_tag('board_id', @board.to_param) if @board %> - <% no_filters = true %> - - <%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %> - <%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %> - - - <% end %> - -
- -
- -
-<%= render :partial => "questions/topic_list" %> -
- -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> -<% end %> - - -<% content_for :sidebar do %> - <%= render :partial => "questions/notice" %> - <%= render :partial => "questions/tag_cloud" %> - <%= render :partial => "questions/voted_topics" %> -<% end %> - -<% html_title @board.name %> - -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %> - <%= javascript_include_tag :questions, :plugin => 'redmine_questions' %> -<% end %> diff --git a/plugins/redmine_questions/app/views/mailer/question_answer_added.html.erb b/plugins/redmine_questions/app/views/mailer/question_answer_added.html.erb new file mode 100644 index 0000000..83c13ed --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_answer_added.html.erb @@ -0,0 +1,5 @@ +

<%= @question.section_name %>: <%= link_to(@question.subject, @question_url) %>

+ +

<%= l(:text_user_wrote, :value => h(@answer.author)) %>

+ +<%= textilizable @answer, :content, :only_path => false %> diff --git a/plugins/redmine_questions/app/views/mailer/question_answer_added.text.erb b/plugins/redmine_questions/app/views/mailer/question_answer_added.text.erb new file mode 100644 index 0000000..b240505 --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_answer_added.text.erb @@ -0,0 +1,6 @@ +<%= @question.section_name %>: <%= @question.subject %> +<%= @question_url %> + +<%= l(:text_user_wrote, :value => @answer.author) %> + +<%= @answer.content %> diff --git a/plugins/redmine_questions/app/views/mailer/question_comment_added.html.erb b/plugins/redmine_questions/app/views/mailer/question_comment_added.html.erb new file mode 100644 index 0000000..c16b307 --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_comment_added.html.erb @@ -0,0 +1,5 @@ +

<%= @question.section_name %>: <%= link_to(@question.subject, @question_url) %>

+ +

<%= l(:text_user_wrote, :value => h(@comment.author)) %>

+ +<%= textilizable @comment, :comments, :only_path => false %> diff --git a/plugins/redmine_questions/app/views/mailer/question_comment_added.text.erb b/plugins/redmine_questions/app/views/mailer/question_comment_added.text.erb new file mode 100644 index 0000000..75ceae1 --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_comment_added.text.erb @@ -0,0 +1,6 @@ +<%= @question.section_name %>: <%= @question.subject %> +<%= @question_url %> + +<%= l(:text_user_wrote, :value => @comment.author) %> + +<%= @comment.comments %> diff --git a/plugins/redmine_questions/app/views/mailer/question_question_added.html.erb b/plugins/redmine_questions/app/views/mailer/question_question_added.html.erb new file mode 100644 index 0000000..16a7a24 --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_question_added.html.erb @@ -0,0 +1,5 @@ +

<%= @question.section_name %>: <%= link_to(@question.subject, @question_url) %>

+ +

<%= l(:text_user_wrote, :value => h(@question.author)) %>

+ +<%= textilizable @question, :content, :only_path => false %> diff --git a/plugins/redmine_questions/app/views/mailer/question_question_added.text.erb b/plugins/redmine_questions/app/views/mailer/question_question_added.text.erb new file mode 100644 index 0000000..3e2c35a --- /dev/null +++ b/plugins/redmine_questions/app/views/mailer/question_question_added.text.erb @@ -0,0 +1,6 @@ +<%= @question.section_name %>: <%= @question.subject %> +<%= @question_url %> + +<%= l(:text_user_wrote, :value => @question.author) %> + +<%= @question.content %> diff --git a/plugins/redmine_questions/app/views/messages/_form.html.erb b/plugins/redmine_questions/app/views/messages/_form.html.erb deleted file mode 100644 index 3db5127..0000000 --- a/plugins/redmine_questions/app/views/messages/_form.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%= error_messages_for 'message' %> -<% replying ||= false %> - -
- -

>
- <%= f.text_field :subject, :style => "width: 80%;", :id => "message_subject" %> -<% unless replying %> - - <% if @message.safe_attribute? 'sticky' %> - <%= f.check_box :sticky %> <%= label_tag 'message_sticky', l(:label_board_sticky) %> - <% end %> - <% if @message.safe_attribute? 'locked' %> - <%= f.check_box :locked %> <%= label_tag 'message_locked', l(:label_board_locked) %> - <% end %> -<% end %> -

- -<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %> -


- <%= f.select :board_id, boards_options_for_select(@message.project.boards) %>

-<% end %> - -

-<%= label_tag "message_content", l(:description_message_content), :class => "hidden-for-sighted" %> -<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content' %>

-<%= wikitoolbar_for 'message_content' %> - - -<% if !replying && @message.safe_attribute?('tag_list') %> -

-
- <%= render :partial => 'questions/form_tags' %> -

-<% end %> - -

<%= l(:label_attachment_plural) %>
-<%= render :partial => 'attachments/form', :locals => {:container => @message} %>

-
diff --git a/plugins/redmine_questions/app/views/messages/edit.html.erb b/plugins/redmine_questions/app/views/messages/edit.html.erb deleted file mode 100644 index df45e02..0000000 --- a/plugins/redmine_questions/app/views/messages/edit.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<%= board_breadcrumb(@message) %> - -

<%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %>

- -<%= form_for @message, { - :as => :message, - :url => {:action => 'edit'}, - :html => {:multipart => true, - :id => 'message-form', - :method => :post} - } do |f| %> - <%= render :partial => 'form', - :locals => {:f => f, :replying => !@message.parent.nil?} %> - <%= submit_tag l(:button_save) %> - <%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board, :id => @message}, 'message-form') %> -<% end %> -
- diff --git a/plugins/redmine_questions/app/views/messages/show.html.erb b/plugins/redmine_questions/app/views/messages/show.html.erb deleted file mode 100644 index 2c1dea6..0000000 --- a/plugins/redmine_questions/app/views/messages/show.html.erb +++ /dev/null @@ -1,144 +0,0 @@ -<%= board_breadcrumb(@message) %> - -
- <%= content_tag('span', watcher_link(@topic, User.current), :id => 'watcher') %> - <% voted = User.current.voted_for?(@topic) %> - <%= link_to( - voted ? l(:button_questions_unvote) : l(:button_questions_vote), - {:controller => 'questions', :action => 'vote', :id => @topic}, - :class => 'icon ' + (voted ? 'icon-vote' : 'icon-unvote') - ) if User.current.allowed_to?(:vote_messages, @project) %> - - <%= link_to( - l(:button_quote), - {:action => 'quote', :id => @topic}, - :remote => true, - :method => 'get', - :class => 'icon icon-comment', - :remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - l(:button_edit), - {:action => 'edit', :id => @topic}, - :class => 'icon icon-edit' - ) if @message.editable_by?(User.current) %> - <%= link_to( - l(:button_delete), - {:action => 'destroy', :id => @topic}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :class => 'icon icon-del' - ) if @message.destroyable_by?(User.current) %> -
- -
-

<%=h @topic.subject %>

- <%= avatar(@topic.author, :size => "32") %> -

<%= link_to_user @topic.author %>
- <%= l(:label_questions_added_time, :value => time_tag(@topic.created_on)).html_safe %> -

-
- <%= textilizable(@topic, :content) %> -
- <%= link_to_attachments @topic, :author => false %> - -
-
- -<% unless @replies.empty? %> -

<%= l(:label_reply_plural) %> (<%= @reply_count %>)

-<% @replies.each do |message| %> -
"> -
- <% liked = User.current.voted_for?(message) %> - <%= link_to( - message.count_votes_up > 0 ? "(#{message.count_votes_up})" : "", - {:controller => 'questions', :action => 'vote', :id => message}, - :class => 'vote icon ' + (liked ? 'icon-vote' : 'icon-unvote') - ) if true || User.current.allowed_to?(:vote_messages, @project) %> - <%= link_to( - image_tag('comment.png'), - {:action => 'quote', :id => message}, - :remote => true, - :method => 'get', - :title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %> - <%= link_to( - image_tag('edit.png'), - {:action => 'edit', :id => message}, - :title => l(:button_edit) - ) if message.editable_by?(User.current) %> - <%= link_to( - image_tag('delete.png'), - {:action => 'destroy', :id => message}, - :method => :post, - :data => {:confirm => l(:text_are_you_sure)}, - :title => l(:button_delete) - ) if message.destroyable_by?(User.current) %> -
- <% if Setting.gravatar_enabled? %> -
- <%= message_avatar = avatar(message.author, :size => "32") %> -
- <% end %> -
-

<%= authoring message.created_on, message.author %>

-
<%= textilizable message, :content, :attachments => message.attachments %>
- <%= link_to_attachments message, :author => false %> -
-
-<% end %> -

<%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %>

-<% end %> - -<% if !@topic.locked? && authorize_for('messages', 'reply') %> -

<%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %>

- -<% end %> - - -<% content_for :sidebar do %> -

<%= l(:label_questions_message) %>

-
    -
  • - <%= l(:label_questions_votes, :count => @topic.count_votes_up - @topic.count_votes_down ) %> -
  • -
  • - <%= l(:label_questions_views, :count => @topic.view_count ) %> -
  • - <% unless @topic.tags.blank? %> -
  • - <%= - @topic.tags.collect do |tag| - link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name} - end.join(', ').html_safe - %> -
  • - <% end %> -
- -

<%= l(:label_questions_related_messages) %>

- - - -<% end %> - -<% html_title @topic.subject %> diff --git a/plugins/redmine_questions/app/views/projects/_questions_settings.html.erb b/plugins/redmine_questions/app/views/projects/_questions_settings.html.erb new file mode 100644 index 0000000..9e38735 --- /dev/null +++ b/plugins/redmine_questions/app/views/projects/_questions_settings.html.erb @@ -0,0 +1,38 @@ +

<%= l(:label_questions_sections_plural) %>

+ + + + + + + + + + + <% QuestionsSection.for_project(@project).sorted.each do |section| %> + + + + + + <% end %> + +
<%= l(:field_name) %><%=l(:field_type)%>
+ <%= h(section.name) %> + + <%= section.l_type %> + + <% if User.current.allowed_to?(:manage_sections, @project) %> + <%= reorder_handle(section, :url => project_questions_section_path(@project, section), :param => 'questions_section') if respond_to?(:reorder_handle) %> + <%= link_to l(:button_edit), {:controller => 'questions_sections', :action => 'edit', :project_id => @project, :id => section}, :class => 'icon icon-edit' %> + <%= delete_link :controller => 'questions_sections', :action => 'destroy', :project_id => @project, :id => section %> + <% end %> +
+ +<% if User.current.allowed_to?(:manage_sections, @project) %> + <%= link_to image_tag('add.png', :style => 'vertical-align: middle;')+l(:label_questions_section_new), :controller => 'questions_sections', :action => 'new', :project_id => @project %> +<% end %> + +<%= javascript_tag do %> + $(function() { $("table.questions_sections tbody").positionedItems(); }); +<% end if respond_to?(:reorder_handle) %> diff --git a/plugins/redmine_questions/app/views/questions/_form.html.erb b/plugins/redmine_questions/app/views/questions/_form.html.erb new file mode 100644 index 0000000..2f22e64 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/_form.html.erb @@ -0,0 +1,43 @@ +<%= error_messages_for @question_item %> +<%= fields_for :question, @question_item do |f| %> +
+ +


+ <%= f.text_field :subject, :id => "question_subject", :size => 120%> +

+


+ <%= f.select :section_id, options_from_collection_for_select(QuestionsSection.where(:project_id => @project),:id, :name, f.object.section_id), :style => "width: 80%;", :required => true %> + <%= javascript_tag do %> + $('#question_section_id').change(function() { + $.ajax({ + url: '<%= escape_javascript update_form_questions_path(:id => @question_item, :format => 'js', :project_id => @project) %>', + type: 'put', + data: $('#question_form').serialize() + }); + }); + <% end %> + <%= link_to(image_tag('add.png', :style => 'vertical-align: middle;'), + (@project ? new_project_questions_section_url(:project_id => @project) : new_questions_section_url ), + :remote => true, + :method => 'get', + :title => l(:label_questions_section_new), + :class => "add_section", + :tabindex => 200) if User.current.allowed_to?(:manage_sections, @project) %> +

+ <% if @question_item.is_idea? %> +


+ <%= f.select :status_id, options_from_collection_for_select(QuestionsStatus.sorted,:id, :name, @question_item.status_id ), :include_blank => true %> +

+ <% end %> +

+ <%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'question_content', :label => l(:label_questions_message) %> +

+ <%= wikitoolbar_for 'question_content' %> + + +

+ <%= l(:label_attachment_plural) %>
+ <%= render :partial => 'attachments/form', :locals => {:container => @question_item} %> +

+
+<% end %> diff --git a/plugins/redmine_questions/app/views/questions/_form_tags.html.erb b/plugins/redmine_questions/app/views/questions/_form_tags.html.erb deleted file mode 100644 index 75dce7e..0000000 --- a/plugins/redmine_questions/app/views/questions/_form_tags.html.erb +++ /dev/null @@ -1,23 +0,0 @@ - - - - <%= text_field_tag 'message[tag_list]', "#{@message.tags.map(&:name).join(',').html_safe}", :size => 10, :class => 'hol', :id => "allowSpacesTags" %> - - - -<% content_for :header_tags do %> - <%= javascript_include_tag :"tag-it", :plugin => 'redmine_questions' %> - <%= stylesheet_link_tag :"jquery.tagit.css", :plugin => 'redmine_questions' %> -<% end %> diff --git a/plugins/redmine_questions/app/views/questions/_forums.html.erb b/plugins/redmine_questions/app/views/questions/_forums.html.erb deleted file mode 100644 index bafd855..0000000 --- a/plugins/redmine_questions/app/views/questions/_forums.html.erb +++ /dev/null @@ -1,68 +0,0 @@ -

<%= l(:label_questions) %>

- -
- <%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %> - <%= hidden_field_tag('project_id', @project.to_param) if @project %> - <%= text_field_tag(:topic_search, params[:topic_search] , :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %> - <%= javascript_tag "observeSearchfield('topic_search', 'forum_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %> - - <% end %> - -
- -
- <% previous_group = false %> - <% boards = @project ? @boards : @boards.select{|b| b.topics_count > 0} %> - <% if @project %> -
    - <% end %> - <% boards.each do |board| %> - <% cache(Message.last.updated_on.to_s + board.id.to_s) do %> - <% if @project.blank? && (group = board.project) != previous_group %> - <% reset_cycle %> -
-
-

<%= group.blank? ? 'None' : group.name %><%= link_to " \xc2\xbb", project_boards_path(:project_id => group) %>

-
-
    - <% previous_group = group %> - <% end %> - -
  • -

    - <%= link_to h(board.name), {:controller => "boards", :action => 'show', :id => board, :project_id => board.project_id}, :class => "board" %> - <%= "(#{board.topics.count})" %> -

    -
    - <% board.topics.sort_by{|m| [m.sticky, m.updated_on] }.reverse.first(5).each do |topic| %> -
    - - <%= link_to h(topic.subject), { :controller => 'messages', :action => 'show', :board_id => board, :id => topic } %> -
    - - <% last_update = [topic.last_reply ? topic.last_reply.updated_on : topic.created_on, topic.updated_on].max %> - <% last_author = (topic.last_reply && topic.last_reply.updated_on) ? topic.last_reply.author : topic.author %> - - <%= authoring last_update, last_author, :label => :label_updated_time_by %>
    - -
    -
    - <% end %> -
    -
  • - <% end %> - <% end %> -
-
- - <% content_for :sidebar do %> - <%= render :partial => "questions/notice" %> - <%= render :partial => "questions/tag_cloud" %> - <%= render :partial => "questions/latest_topics" %> - <%= render :partial => "questions/voted_topics" %> - <% end %> - -<% content_for :header_tags do %> - <%= javascript_include_tag :questions, :plugin => 'redmine_questions' %> -<% end %> - diff --git a/plugins/redmine_questions/app/views/questions/_latest_topics.html.erb b/plugins/redmine_questions/app/views/questions/_latest_topics.html.erb index d36d26c..ea9514e 100644 --- a/plugins/redmine_questions/app/views/questions/_latest_topics.html.erb +++ b/plugins/redmine_questions/app/views/questions/_latest_topics.html.erb @@ -1,14 +1,8 @@ -<% - scope = Message.where({}) - scope = scope.where("#{Message.table_name}.parent_id IS NULL") - scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project - @latest_topics = scope.visible.includes(:board).order("#{Message.table_name}.created_on DESC").limit(5) -%>

<%= l(:label_questions_latest_messages) %>

\ No newline at end of file + <% Question.visible.by_date.in_project(@project).limit(5).each do |question| %> + + <% end %> + diff --git a/plugins/redmine_questions/app/views/questions/_notice.html.erb b/plugins/redmine_questions/app/views/questions/_notice.html.erb deleted file mode 100644 index b4aaf27..0000000 --- a/plugins/redmine_questions/app/views/questions/_notice.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -<% unless Setting.plugin_redmine_questions[:sidebar_message].blank? %> -
<%= textilizable(Setting.plugin_redmine_questions[:sidebar_message]) %>
-<% end %> \ No newline at end of file diff --git a/plugins/redmine_questions/app/views/questions/_popular_topics.html.erb b/plugins/redmine_questions/app/views/questions/_popular_topics.html.erb new file mode 100644 index 0000000..b39b576 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/_popular_topics.html.erb @@ -0,0 +1,18 @@ +<% + @popular_topics = Question. + visible. + in_project(@project). + in_section(@section). + positive. + by_views. + by_votes. + limit(5) +%> +

<%= l(:label_questions_most_popular) %>

+ diff --git a/plugins/redmine_questions/app/views/questions/_question.html.erb b/plugins/redmine_questions/app/views/questions/_question.html.erb new file mode 100644 index 0000000..bd55d58 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/_question.html.erb @@ -0,0 +1,65 @@ +
+ <%= content_tag('span', watcher_link(@question_item, User.current), :id => 'watcher') %> + <%= link_to(l(:button_edit), edit_question_path(@question_item), :class => 'icon icon-edit' ) if @question_item.editable_by?(User.current) + %> + <%= link_to(l(:button_delete), question_path(@question_item), :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') if @question_item.destroyable_by?(User.current) + %> +
+ +

<%=h @question_item.subject %>

+<%= render :partial => 'question_item', :object => @question_item %> + +<% if @question_item.section.allow_answering? %> +
+ <% if @answers.any? %> +

<%= l(:label_questions_answer_plural) %> (<%= @answer_count %>)

+ <% @answers.each do |answer| %> + <%= render :partial => 'questions_answers/answer_item', :locals => { :question_item => answer } %> + <% end %> + <%= pagination_links_full @answer_pages, @answer_count %> + <% end %> + + <% if @question_item.allow_answering? && User.current.allowed_to?(:add_answers, @project) %> +

<%= l(:label_questions_your_answer) %>

+
+ <%= form_for @answer, :as => :answer, :url => question_answers_path(@question_item), :html => {:multipart => true, :id => 'answer-form'} do |f| %> + <%= render :partial => 'questions_answers/form', :locals => {:f => f, :replying => true} %> + <%= submit_tag l(:button_submit) %> + <% end %> +
+
+ <% end %> +
+<% end %> + +<% content_for :sidebar do %> +

<%= l(:label_questions_message) %>

+
    +
  • + <%= l(:label_questions_views, :count => @question_item.views ) %> +
  • +
+ + <% if @question_item.convertable_by?(User.current) && User.current.allowed_to?(:add_issues, @project) %> +

<%= l(:label_questions_actions) %>

+
    +
  • + <%= link_to( + l(:button_questions_to_issue), + convert_to_issue_project_question_path(@project, @question_item) + ) + %> +
  • +
+ <% end %> + +

<%= l(:label_questions_related_questions) %>

+ + +<% end %> diff --git a/plugins/redmine_questions/app/views/questions/_question_item.html.erb b/plugins/redmine_questions/app/views/questions/_question_item.html.erb new file mode 100644 index 0000000..738298b --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/_question_item.html.erb @@ -0,0 +1,23 @@ +
div-table" id="question_<%= question_item.id %>"> + + <% if question_item.allow_voting? && User.current.allowed_to?(:vote_questions, @project) %> +
+ <%= render :partial => 'questions_votes/question_item_vote', :locals => {:question_item => question_item} %> +
+ <% end %> + +
+ <%= avatar(question_item.author, :size => "32") %> +

+ <%= link_to_user question_item.author %>
+ <%= l(:label_questions_added_time, :value => time_tag(question_item.created_on)).html_safe %> +

+
+ <%= textilizable(question_item, :content) %> +
+ + <%= link_to_attachments question_item, :author => false %> + + <%= render :partial => 'questions_comments/comments_container', :locals => { :question_item => question_item } %> +
+
diff --git a/plugins/redmine_questions/app/views/questions/_question_list.html.erb b/plugins/redmine_questions/app/views/questions/_question_list.html.erb new file mode 100644 index 0000000..122c1f2 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/_question_list.html.erb @@ -0,0 +1,47 @@ +<% if @question_items && @question_items.any? %> + <% unless params[:tag].blank? %> +
+

<%= l(:label_questions_tagged_by, :count => @question_items.size, :tag => params[:tag]) %>

+
+ <% end %> + +
+
"> + <% @question_items.each do |question| %> +
+ <% if @section && @section.allow_voting? %> +
+ <%= question.weighted_score %> + + <% if question.answered? %> +
+ <% end %> +
+ <% end %> +
+

+ <%= link_to h(question.subject), { :controller => 'questions', :action => 'show', :project_id => question.project, :id => question } %> + <%= question_status_tag(question.status) %> +

+

<%= truncate(Question.to_text(textilizable(question.content)), :length => 100) %>

+
    + <% if question.allow_answering? %> +
  • <%= l(:label_questions_answers, :count => question.answers_count) %>
  • + <% end %> +
  • <%= l(:label_questions_views, :count => question.views ) %>
  • +
+
+
+ <% end %> +
+
+ <% if @topic_pages %> + <% params[:controller] = 'questions' + params[:action] = 'topics' + %> +

<%= pagination_links_full @topic_pages, @topic_count %>

+ <% end %> +<% else %> +

+

<%= l(:label_no_data) %>

+<% end %> diff --git a/plugins/redmine_questions/app/views/questions/_tag_cloud.html.erb b/plugins/redmine_questions/app/views/questions/_tag_cloud.html.erb deleted file mode 100644 index 5ab1697..0000000 --- a/plugins/redmine_questions/app/views/questions/_tag_cloud.html.erb +++ /dev/null @@ -1,35 +0,0 @@ -<% - limit = 30 - - scope = RedmineCrm::Tag.where({}) - scope = scope.where("#{Project.table_name}.id = ?", @project) if @project - scope = scope.where(Project.allowed_to_condition(User.current, :view_messages)) - - - join = [] - join << "JOIN #{RedmineCrm::Tagging.table_name} ON #{RedmineCrm::Tagging.table_name}.tag_id = #{RedmineCrm::Tag.table_name}.id " - join << "JOIN #{Message.table_name} ON #{Message.table_name}.id = #{RedmineCrm::Tagging.table_name}.taggable_id AND #{RedmineCrm::Tagging.table_name}.taggable_type = '#{Message.name}' " - join << "JOIN #{Board.table_name} ON #{Board.table_name}.id = #{Message.table_name}.board_id" - join << "JOIN #{Project.table_name} ON #{Project.table_name}.id = #{Board.table_name}.project_id" - - group_fields = "" - group_fields << ", #{RedmineCrm::Tag.table_name}.created_at" if RedmineCrm::Tag.respond_to?(:created_at) - group_fields << ", #{RedmineCrm::Tag.table_name}.updated_at" if RedmineCrm::Tag.respond_to?(:updated_at) - - scope = scope.joins(join.join(' ')) - scope = scope.select("#{RedmineCrm::Tag.table_name}.*, COUNT(DISTINCT #{RedmineCrm::Tagging.table_name}.taggable_id) AS count") - scope = scope.group("#{RedmineCrm::Tag.table_name}.id, #{RedmineCrm::Tag.table_name}.name #{group_fields} HAVING COUNT(*) > 0") - scope = scope.order("#{RedmineCrm::Tag.table_name}.name") - scope = scope.limit(limit) if limit - @available_tags = scope - %> - -

<%= l(:label_questions_tags) %>

-
    - <% @available_tags.each do |tag| %> -
  • - <%= link_to tag, {:controller => "questions", :action => "topics", :project_id => @project, :tag => tag.name} %> - <%= tag.count %> -
  • - <% end if @available_tags %> -
\ No newline at end of file diff --git a/plugins/redmine_questions/app/views/questions/_top_sticky_topics.html.erb b/plugins/redmine_questions/app/views/questions/_top_sticky_topics.html.erb index 6ced3e8..c222aa9 100644 --- a/plugins/redmine_questions/app/views/questions/_top_sticky_topics.html.erb +++ b/plugins/redmine_questions/app/views/questions/_top_sticky_topics.html.erb @@ -1,16 +1,16 @@ <% - scope = Message.scoped({}) - scope = scope.where("#{Message.table_name}.parent_id IS NULL") - scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project - scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board - scope = scope.where(:sticky => true) - @sticky_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(10) + # scope = Message.scoped({}) + # scope = scope.where("#{Message.table_name}.parent_id IS NULL") + # scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project + # scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board + # scope = scope.where(:featured => true) + # @featured_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(10) %>

<%= l(:label_questions_most_voted) %>

\ No newline at end of file + <% end unless @featured_topics.blank? %> + diff --git a/plugins/redmine_questions/app/views/questions/_topic_list.html.erb b/plugins/redmine_questions/app/views/questions/_topic_list.html.erb index 9f002ef..dee1bc4 100644 --- a/plugins/redmine_questions/app/views/questions/_topic_list.html.erb +++ b/plugins/redmine_questions/app/views/questions/_topic_list.html.erb @@ -1,8 +1,8 @@ <% if @topics && @topics.any? %> <% unless params[:tag].blank? %> -
-

<%= l(:label_questions_tagged_by, :count => @topics.size, :tag => params[:tag]) %>

-
+
+

<%= l(:label_questions_tagged_by, :count => @topics.size, :tag => params[:tag]) %>

+
<% end %>
<% @topics.each do |topic| %> @@ -26,5 +26,5 @@

<%= pagination_links_full @topic_pages, @topic_count %>

<% end %> <% else %> -

<%= l(:label_no_data) %>

-<% end %> \ No newline at end of file +

<%= l(:label_no_data) %>

+<% end %> diff --git a/plugins/redmine_questions/app/views/questions/_voted_topics.html.erb b/plugins/redmine_questions/app/views/questions/_voted_topics.html.erb deleted file mode 100644 index 70fde5c..0000000 --- a/plugins/redmine_questions/app/views/questions/_voted_topics.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -<% - scope = Message.where({}) - scope = scope.where("#{Message.table_name}.parent_id IS NULL") - scope = scope.where(["#{Board.table_name}.project_id = ?", @project.id]) if @project - scope = scope.where(["#{Message.table_name}.board_id = ?", @board.id]) if @board - scope = scope.where("#{Message.table_name}.cached_votes_up > 0") - @most_voted_topics = scope.visible.includes(:board).order("#{Message.table_name}.cached_votes_up DESC").limit(5) -%> -

<%= l(:label_questions_most_voted) %>

- \ No newline at end of file diff --git a/plugins/redmine_questions/app/views/questions/autocomplete_for_subject.html.erb b/plugins/redmine_questions/app/views/questions/autocomplete_for_subject.html.erb new file mode 100644 index 0000000..38bdf4f --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/autocomplete_for_subject.html.erb @@ -0,0 +1 @@ +<%= render :partial => "questions/question_list" %> diff --git a/plugins/redmine_questions/app/views/questions/autocomplete_for_topic.html.erb b/plugins/redmine_questions/app/views/questions/autocomplete_for_topic.html.erb deleted file mode 100644 index 2ccb2ad..0000000 --- a/plugins/redmine_questions/app/views/questions/autocomplete_for_topic.html.erb +++ /dev/null @@ -1 +0,0 @@ -<%= render :partial => "questions/topic_list" %> \ No newline at end of file diff --git a/plugins/redmine_questions/app/views/questions/edit.html.erb b/plugins/redmine_questions/app/views/questions/edit.html.erb new file mode 100644 index 0000000..055f9a7 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/edit.html.erb @@ -0,0 +1,15 @@ + +

<%= avatar(@question_item.author, :size => "24") %><%=h @question_item.subject %>

+ +<%= form_for @question_item, { :url => question_path(@question_item), :html => {:multipart => true, + :id => 'question_form', :method => :put}} do |f| %> + <%= back_url_hidden_field_tag %> +
+ <%= render :partial => 'form', :locals => {:f => f} %> +
+ <%= submit_tag l(:button_save) %> + <%= preview_link({:controller => 'questions', :action => 'preview', :question_id => @question_item}, 'question_form') %> + +<% end %> +
+ diff --git a/plugins/redmine_questions/app/views/questions/index.html.erb b/plugins/redmine_questions/app/views/questions/index.html.erb new file mode 100644 index 0000000..a364d69 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/index.html.erb @@ -0,0 +1,35 @@ +<% html_title l(:label_questions) %> +
+
+ <%= link_to(l(:label_questions_new), + {:controller => 'questions', :action => 'new', :section_id => @section}, + :class => 'icon icon-add') if User.current.allowed_to?(:add_questions, @project) %> + <%= link_to(l(:label_questions_section_edit), + {:controller => 'questions_sections', :action => 'edit', :id => @section}, + :class => 'icon icon-edit') if @section && User.current.allowed_to?(:manage_sections, @project) %> +
+ + <%= question_breadcrumb @section %> +

+ <%= @section ? @section.name : l(:label_questions)%> +

+ <% if @section && !@section.description.blank? %> + <%= @section.description %> + <% end %> +
+ <%= form_tag({:controller => "questions", :action => "index"}, :method => :get, :id => "query_form") do %> + <%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %> + <%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_subject_questions_path(:project_id => @project, :section_id => @section)) }')" %> + <% end %> +
+
+ +
+ <%= render :partial => "questions/question_list" %> +
+ +<% content_for :sidebar do %> + <%= render :partial => "questions/latest_topics" %> + <%= render :partial => "questions/popular_topics" %> +<% end %> + diff --git a/plugins/redmine_questions/app/views/questions/new.html.erb b/plugins/redmine_questions/app/views/questions/new.html.erb index dbe56c5..48eae58 100644 --- a/plugins/redmine_questions/app/views/questions/new.html.erb +++ b/plugins/redmine_questions/app/views/questions/new.html.erb @@ -1,9 +1,12 @@

<%= l(:label_message_new) %>

-<%= form_for @message, :url => {:controller => "messages", :action => 'new'}, :html => {:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'messages/form', :locals => {:f => f} %> +<%= form_for @question_item, { :url => questions_path, :html => {:multipart => true, + :id => 'question_form'}} do |f| %> +
+ <%= render :partial => 'form', :locals => {:f => f} %> +
<%= submit_tag l(:button_create) %> - <%# preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %> + <% preview_link({:controller => 'questions', :action => 'preview', :id => @question_item}, 'question_form') %> <% end %>
diff --git a/plugins/redmine_questions/app/views/questions/show.html.erb b/plugins/redmine_questions/app/views/questions/show.html.erb new file mode 100644 index 0000000..3d6b3fb --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/show.html.erb @@ -0,0 +1,6 @@ +<%= question_breadcrumb @question_item %> + + +<%= render :partial => 'question' if QA_VERSION_TYPE.match(/Light/) %> + +<% html_title @question_item.subject %> diff --git a/plugins/redmine_questions/app/views/questions/topics.html.erb b/plugins/redmine_questions/app/views/questions/topics.html.erb deleted file mode 100644 index 81e0c30..0000000 --- a/plugins/redmine_questions/app/views/questions/topics.html.erb +++ /dev/null @@ -1,31 +0,0 @@ - -<% if @board %> - <%= board_breadcrumb(@board) %> -
-

<%=h @board.name %>

-

<%=h @board.description %>

-<% else %> -

<%= l(:label_questions) %>

-<% end %> - -
- <%= form_tag({:controller => "questions", :action => "topics"}, :method => :get, :id => "query_form") do %> - <%= hidden_field_tag('project_id', @project.to_param) if @project %> - <%= hidden_field_tag('board_id', @board.to_param) if @board %> - <%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %> - <%= javascript_tag "observeSearchfield('topic_search', 'topics_list', '#{ escape_javascript(autocomplete_for_topic_questions_path(:project_id => @project, :board_id => @board)) }')" %> - - <% end %> - -
-<% if @board %> -
-<% end %> - -
- <%= render :partial => "questions/topic_list" %> -
- -<% content_for :sidebar do %> - <%= render :partial => "questions/latest_topics" %> -<% end %> \ No newline at end of file diff --git a/plugins/redmine_questions/app/views/questions/update_form.js.erb b/plugins/redmine_questions/app/views/questions/update_form.js.erb new file mode 100644 index 0000000..e490932 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions/update_form.js.erb @@ -0,0 +1 @@ +$('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>'); diff --git a/plugins/redmine_questions/app/views/questions_answers/_actions.html.erb b/plugins/redmine_questions/app/views/questions_answers/_actions.html.erb new file mode 100644 index 0000000..bb3d84a --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_answers/_actions.html.erb @@ -0,0 +1,5 @@ +
+ <%= link_to(l(:button_edit), edit_questions_answer_path(question_item), :class => 'icon icon-edit') if question_item.editable_by?(User.current) %> + <%= link_to(l(:button_delete), questions_answer_path(question_item), :method => :delete, :data => {:confirm => l(:text_are_you_sure)}, :class => 'icon icon-del') if question_item.destroyable_by?(User.current) + %> +
diff --git a/plugins/redmine_questions/app/views/questions_answers/_answer_item.html.erb b/plugins/redmine_questions/app/views/questions_answers/_answer_item.html.erb new file mode 100644 index 0000000..01a39ca --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_answers/_answer_item.html.erb @@ -0,0 +1,23 @@ +
+ + <% if question_item.allow_voting? && User.current.allowed_to?(:vote_questions, @project) %> +
+ <%= render :partial => 'questions_votes/question_item_vote', :locals => {:question_item => question_item } %> +
+ <% end %> + +
+ <%= render :partial => "questions_answers/actions", :locals => { :question_item => question_item } %> + <%= avatar(question_item.author, :size => "32") %> +

+ <%= link_to_user question_item.author %>
+ <%= l(:label_questions_added_time, :value => time_tag(question_item.created_on)).html_safe %> +

+
+ <%= textilizable(question_item, :content) %> +
+ + <%= link_to_attachments question_item, :author => false %> + +
+
diff --git a/plugins/redmine_questions/app/views/questions_answers/_form.html.erb b/plugins/redmine_questions/app/views/questions_answers/_form.html.erb new file mode 100644 index 0000000..f12bbb4 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_answers/_form.html.erb @@ -0,0 +1,10 @@ +<%= error_messages_for @answer %> +
+ <%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'answer_content', :no_label => true %> + <%= wikitoolbar_for 'answer_content' %> + +

+ <%= l(:label_attachment_plural) %>
+ <%= render :partial => 'attachments/form', :locals => {:container => @answer} %> +

+
diff --git a/plugins/redmine_questions/app/views/questions_answers/edit.html.erb b/plugins/redmine_questions/app/views/questions_answers/edit.html.erb new file mode 100644 index 0000000..ea448b8 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_answers/edit.html.erb @@ -0,0 +1,12 @@ + +

<%= avatar(@answer.author, :size => "24") %><%=h @answer.question.subject %>

+ +<%= form_for @answer, :as => :answer, :url => questions_answer_path(@answer), :html => {:multipart => true, :id => 'answer-form', :method => :put} do |f| %> + <%= back_url_hidden_field_tag %> + <%= render :partial => 'form', :locals => {:f => f} %> + <%= submit_tag l(:button_save) %> + <%= preview_link(preview_questions_answers_path(@answer), 'answer-form') %> + +<% end %> +
+ diff --git a/plugins/redmine_questions/app/views/questions_comments/_comment.html.erb b/plugins/redmine_questions/app/views/questions_comments/_comment.html.erb new file mode 100644 index 0000000..2f4d008 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/_comment.html.erb @@ -0,0 +1,27 @@ +
+
+ <%= link_to( + "", + {:controller => 'questions_comments', :action => 'edit', :source_id => comment.commented, :source_type => comment.commented.class.name.underscore, :id => comment.id}, + :class => 'icon icon-edit', + :method => :get + ) if (User.current.allowed_to?(:edit_question_comments, comment.commented.project) || (comment.author == User.current && User.current.allowed_to?(:edit_own_question_comments, comment.commented.project))) + %> + <%= link_to( + "", + {:controller => 'questions_comments', :action => 'destroy', :source_id => comment.commented, :id => comment, :source_type => comment.commented.class.name.underscore}, :class => 'icon icon-del', + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :title => l(:button_delete) + ) if (User.current.allowed_to?(:edit_question_comments, comment.commented.project) || (comment.author == User.current && User.current.allowed_to?(:edit_own_question_comments, comment.commented.project))) + %> +
+
+ <%= link_to_user comment.author %> + <%= time_tag(comment.created_on) %> +
+
+ <%= textilizable(comment.comments) %> +
+
+ diff --git a/plugins/redmine_questions/app/views/questions_comments/_comment_form.html.erb b/plugins/redmine_questions/app/views/questions_comments/_comment_form.html.erb new file mode 100644 index 0000000..07fe9f8 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/_comment_form.html.erb @@ -0,0 +1,7 @@ + <% if question_item.commentable? %> + <%= form_tag({:controller => 'questions_comments', :action => 'create', :id => question_item, :source_id => question_item, :source_type => question_item.class.name.underscore}, :class => "add-comment-form", :remote => true) do %> + <%= text_area 'comment', @comment.respond_to?(:content) ? 'content' : 'comments', :cols => 80, :rows => 5, :id => "comments_for_#{question_item.class.name.underscore}_#{question_item.id}" %> + <%= submit_tag l(:button_add), :class => "button-small" %> + <%= link_to l(:button_cancel), {}, :onclick => "$('#add_#{question_item.class.name.underscore}_comments_#{question_item.id}').hide(); return false;" %> + <% end %> + <% end %> diff --git a/plugins/redmine_questions/app/views/questions_comments/_comment_list.html.erb b/plugins/redmine_questions/app/views/questions_comments/_comment_list.html.erb new file mode 100644 index 0000000..8442b49 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/_comment_list.html.erb @@ -0,0 +1,12 @@ +<% if question_item.comments.any? %> +
+ <% question_item.comments.each do |comment| %> + <% next if comment.new_record? %> + <%= render :partial => "questions_comments/comment", :locals => {:comment => comment, :comment_source => question_item} %> + <% end %> +
+<% end %> + + diff --git a/plugins/redmine_questions/app/views/questions_comments/_comments_container.html.erb b/plugins/redmine_questions/app/views/questions_comments/_comments_container.html.erb new file mode 100644 index 0000000..2aa539b --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/_comments_container.html.erb @@ -0,0 +1,7 @@ +<% if question_item.commentable? %> + <%= link_to l(:label_questions_comment), "#", :onclick => "$('#add_comments_#{question_item.id}').toggle(); showAndScrollTo('add_#{question_item.class.name.underscore}_comments_#{question_item.id}', 'comments_for_#{question_item.class.name.underscore}_#{question_item.id}'); return false;", :class => 'icon icon-comment add-comment-link' %> +<% end %> + +
+ <%= render :partial => 'questions_comments/comment_list', :locals => {:question_item => question_item} %> +
diff --git a/plugins/redmine_questions/app/views/questions_comments/create.js.erb b/plugins/redmine_questions/app/views/questions_comments/create.js.erb new file mode 100644 index 0000000..4577486 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/create.js.erb @@ -0,0 +1,3 @@ +$("#<%= @comment_source.class.name.underscore %>_<%= @comment_source.id %> .comments_container").html('<%= escape_javascript(render :partial => "questions_comments/comment_list", :locals => {:question_item => @comment_source}) %>'); +$(".comment#comment_<%= @comment.id %>").effect('highlight', {}, 1000); +$("textarea#comments_for_<%= @comment_source.class.name.underscore %>_<%= @comment_source.id %>").val(""); diff --git a/plugins/redmine_questions/app/views/questions_comments/edit.html.erb b/plugins/redmine_questions/app/views/questions_comments/edit.html.erb new file mode 100644 index 0000000..08ae907 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_comments/edit.html.erb @@ -0,0 +1,12 @@ + +

<%= avatar(@comment.author, :size => "24") %>

+<%= form_tag({:controller => 'questions_comments', :action => 'update', :source_id => @comment_source, :source_type => @comment_source.class.name.underscore, :id => @comment, :method => :put}) do %> + +
+ <%= text_area 'comment', 'comments', :cols => 80, :rows => 5%> +
+ +

<%= submit_tag l(:button_update) %>

+ +<% end %> +
diff --git a/plugins/redmine_questions/app/views/questions_sections/_form.html.erb b/plugins/redmine_questions/app/views/questions_sections/_form.html.erb new file mode 100644 index 0000000..c4a3efc --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/_form.html.erb @@ -0,0 +1,7 @@ +<%= error_messages_for @section %> +

+ <%= f.text_field :name, :required => true %> +

+

+ <%= f.text_area :description, :rows => 5 %> +

diff --git a/plugins/redmine_questions/app/views/questions_sections/_new_modal.html.erb b/plugins/redmine_questions/app/views/questions_sections/_new_modal.html.erb new file mode 100644 index 0000000..ab78154 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/_new_modal.html.erb @@ -0,0 +1,8 @@ +

<%=l(:label_questions_section_new) %>

+ +<%= labelled_form_for((@project ? [@project, @section] : @section), :remote => true, :html => {:class => 'tabular'}) do |f|%> + <%= render :partial => 'form', :locals => { :f => f} %> +

+ <%= f.submit l(:button_create) %> +

+<% end %> diff --git a/plugins/redmine_questions/app/views/questions_sections/_tiles.html.erb b/plugins/redmine_questions/app/views/questions_sections/_tiles.html.erb new file mode 100644 index 0000000..44420f3 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/_tiles.html.erb @@ -0,0 +1,29 @@ +<% previous_group = false %> +
+<% @sections.each do |section| %> + <% if @project.blank? && (group = section.project) != previous_group %> + <% reset_cycle %> +
+ <% if group %> +
+

+ <%= group.name %> + <%= link_to " \xc2\xbb", project_questions_sections_path(:project_id => group.identifier) %> +

+
+ <% end %> +
+ <% previous_group = group %> + <% end %> + + 'index', :section_id => section, :project_id => section.project}) %>" id="section_<%= section.id %>" class="section-tile"> +

+ <%= section.name %> + <%= "(#{section.questions_count})" %> +

+
+ <%= section.description %> +
+
+<% end %> + diff --git a/plugins/redmine_questions/app/views/questions_sections/create.js.erb b/plugins/redmine_questions/app/views/questions_sections/create.js.erb new file mode 100644 index 0000000..bd08650 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/create.js.erb @@ -0,0 +1,8 @@ +hideModal(); +<% select = content_tag('select', content_tag('option') + options_from_collection_for_select(QuestionsSection.where(:project_id => @project), :id, :name, @section.id.to_s), :id => 'question_section_id', :name => 'question[section_id]') %> +$('#question_section_id').replaceWith('<%= escape_javascript(select) %>'); +$.ajax({ + url: '<%= escape_javascript update_form_questions_path(:id => @question_item, :format => 'js', :project_id => @project) %>', + type: 'put', + data: $('#question_form').serialize() + }); diff --git a/plugins/redmine_questions/app/views/questions_sections/edit.html.erb b/plugins/redmine_questions/app/views/questions_sections/edit.html.erb new file mode 100644 index 0000000..6fd731d --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/edit.html.erb @@ -0,0 +1,11 @@ +

<%=l(:label_questions_section)%>

+ +<%= labelled_form_for (@project ? [@project, @section] : @section), :method => "PUT", :html => {:class => 'tabular'} do |f|%> +
+ <%= back_url_hidden_field_tag %> + <%= render :partial => 'form', :locals => { :f => f} %> +
+

+ <%= f.submit l(:button_save) %> +

+<% end %> diff --git a/plugins/redmine_questions/app/views/questions_sections/index.html.erb b/plugins/redmine_questions/app/views/questions_sections/index.html.erb new file mode 100644 index 0000000..d8aec00 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/index.html.erb @@ -0,0 +1,29 @@ +<% html_title l(:label_questions) %> +
+ <%= link_to(l(:label_questions_new), + {:controller => 'questions', :action => 'new', :section_id => @section}, + :class => 'icon icon-add') if User.current.allowed_to?(:add_questions, @project) %> +
+ + +

<%= l(:label_questions) %>

+
+ <%= form_tag({:controller => "questions", :action => "index"}, :method => :get, :id => "query_form") do %> + <%= text_field_tag(:topic_search, params[:topic_search], :autocomplete => "off", :class => "questions-search", :placeholder => l(:label_questions_search) ) %> + <%= javascript_tag "observeSearchfield('topic_search', 'forum_list', '#{ escape_javascript(autocomplete_for_subject_questions_path(:project_id => @project, :section_id => @section)) }')" %> + <% end %> +
+ +
+ <%= render :partial => 'tiles' %> +
+ +<% content_for :sidebar do %> + <%= render :partial => "questions/latest_topics" %> + <%= render :partial => "questions/popular_topics" %> +<% end %> + +<% content_for :header_tags do %> + <%= javascript_include_tag :questions, :plugin => 'redmine_questions' %> +<% end %> + diff --git a/plugins/redmine_questions/app/views/questions_sections/new.html.erb b/plugins/redmine_questions/app/views/questions_sections/new.html.erb new file mode 100644 index 0000000..ed39e24 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/new.html.erb @@ -0,0 +1,11 @@ +

<%=l(:label_questions_section_new)%>

+ +<%= labelled_form_for((@project ? [@project, @section] : @section), :html => {:class => 'tabular'}) do |f|%> +
+ <%= back_url_hidden_field_tag %> + <%= render :partial => 'form', :locals => { :f => f} %> +
+

+ <%= f.submit l(:button_create) %> +

+<% end %> diff --git a/plugins/redmine_questions/app/views/questions_sections/new.js.erb b/plugins/redmine_questions/app/views/questions_sections/new.js.erb new file mode 100644 index 0000000..8ae93d1 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_sections/new.js.erb @@ -0,0 +1,2 @@ +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'new_modal') %>'); +showModal('ajax-modal', '600px'); diff --git a/plugins/redmine_questions/app/views/questions_statuses/_form.html.erb b/plugins/redmine_questions/app/views/questions_statuses/_form.html.erb new file mode 100644 index 0000000..5a569f0 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_statuses/_form.html.erb @@ -0,0 +1,14 @@ +<%= error_messages_for 'questions_status' %> + +
+

<%= f.text_field :name, :required => true %>

+

<%= f.select :color, options_for_select(QuestionsSettings::IDEA_COLORS, @questions_status.color), {:label => l(:field_color)} %>

+

<%= f.check_box :is_closed, :label => :label_questions_status_closed %>

+ +
+ +<%= javascript_tag "$('#questions_status_color').simplecolorpicker({picker: true});"%> +<% content_for :header_tags do %> + <%= javascript_include_tag 'jquery.simplecolorpicker.js', :plugin => "redmine_questions" %> + <%= stylesheet_link_tag 'jquery.simplecolorpicker.css', :plugin => 'redmine_questions' %> +<% end %> diff --git a/plugins/redmine_questions/app/views/questions_statuses/edit.html.erb b/plugins/redmine_questions/app/views/questions_statuses/edit.html.erb new file mode 100644 index 0000000..1bd37d0 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_statuses/edit.html.erb @@ -0,0 +1,6 @@ +

<%= link_to l(:label_questions_status_plural), :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses' %> » <%=h @questions_status %>

+ +<%= labelled_form_for @questions_status do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <%= submit_tag l(:button_save) %> +<% end %> diff --git a/plugins/redmine_questions/app/views/questions_statuses/index.api.rsb b/plugins/redmine_questions/app/views/questions_statuses/index.api.rsb new file mode 100644 index 0000000..289f8cf --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_statuses/index.api.rsb @@ -0,0 +1,10 @@ +api.array :questions_statuses do + @questions_statuses.each do |status| + api.questions_status do + api.id status.id + api.name status.name + api.color status.color + api.is_closed status.is_closed + end + end +end diff --git a/plugins/redmine_questions/app/views/questions_statuses/new.html.erb b/plugins/redmine_questions/app/views/questions_statuses/new.html.erb new file mode 100644 index 0000000..bddd7c9 --- /dev/null +++ b/plugins/redmine_questions/app/views/questions_statuses/new.html.erb @@ -0,0 +1,6 @@ +

<%= link_to l(:label_questions_status_plural), :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses' %> » <%=l(:label_questions_status_new)%>

+ +<%= labelled_form_for @questions_status do |f| %> + <%= render :partial => 'form', :locals => {:f => f} %> + <%= submit_tag l(:button_create) %> +<% end %> diff --git a/plugins/redmine_questions/app/views/settings/_questions.html.erb b/plugins/redmine_questions/app/views/settings/_questions.html.erb deleted file mode 100644 index 33bf3df..0000000 --- a/plugins/redmine_questions/app/views/settings/_questions.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -

-<%= text_area_tag 'settings[sidebar_message]', @settings[:sidebar_message], :class => 'wiki-edit', :rows => 5 %> -

\ No newline at end of file diff --git a/plugins/redmine_questions/assets/images/answered.svg b/plugins/redmine_questions/assets/images/answered.svg new file mode 100644 index 0000000..f5a00d4 --- /dev/null +++ b/plugins/redmine_questions/assets/images/answered.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/plugins/redmine_questions/assets/images/answered_check.svg b/plugins/redmine_questions/assets/images/answered_check.svg new file mode 100644 index 0000000..9c0e2fd --- /dev/null +++ b/plugins/redmine_questions/assets/images/answered_check.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/redmine_questions/assets/images/book_open.png b/plugins/redmine_questions/assets/images/book_open.png new file mode 100644 index 0000000000000000000000000000000000000000..7d863f949741ff83fd8373a77c0d95a3d95e441f GIT binary patch literal 622 zcmV-!0+IcRP)YeaZ-G+53gSTz{SPWVdFiPaPX+$~@n)fi9>qgJ zh4fN-QcEhq^wI<|vImjml9)pF*W2zl+qWbTPaSyKyqWKt`DS)j3xa?yVgf%ewhl|m zA$_0x^Rx4E@d&=>uRoSN*Cm&aL#`7&zr0;L(pKMn1G#$ZszFkMC^?B8f`0w&-UD$u zd-(?iK6#!;xZ`>J^A9DGiTfguewDOKwDEKoL}`ZE_M}0=xvsgf$usmJeV$oo28d0#yu!pdgpag$giC zhlKP!CMX3wsPMGgZ5n>Xg+hV--ENofAcH61#0B7Hvl-7Il}g2A6;lfG`FxbX8A>p$ z0P;GW4il9Mr9jO9)xB^Rgy%*CSTdQ6D;kDDnM{U{5Q21FA4#ZM71$_Dba8z<-Y_Na zS@|v#c0PZNDux9AoXD-ZoWP~q)7QrC`G + + + + + + + + + + + + + + diff --git a/plugins/redmine_questions/assets/images/downvote_arrow.svg b/plugins/redmine_questions/assets/images/downvote_arrow.svg new file mode 100644 index 0000000..8ac1909 --- /dev/null +++ b/plugins/redmine_questions/assets/images/downvote_arrow.svg @@ -0,0 +1,3 @@ + + + Produced by OmniGraffle 6.5.3 2016-07-07 08:57:24 +0000Canvas 1Layer 1 diff --git a/plugins/redmine_questions/assets/images/upvote.graffle b/plugins/redmine_questions/assets/images/upvote.graffle new file mode 100644 index 0000000000000000000000000000000000000000..05ecdbf2268d5be64069ae8f8bc814da6fcce54d GIT binary patch literal 1794 zcmV+d2mSaTiwFP!000030Nq(xQ{y-gerA4!m)9kU@5EGKD%U`UBY^}Mc-a!RNVF)H zM^*?&@!wanllYJWW{#@eby0wGf~bh?}iu$S7a( zKDV$+W`X1L8Op&|BEf>Fp2}HOWTifySqV6c_>yGkbSUZYgy}o9w73dBI zp)5Ee7$q8WBK>ZHU%6CIdpCxS*b{~ca%FEk$fqRt$!Kag9`91HNX$wMI~}CW;qF|! zVRe_>#QqE64I#4<;m`s80|*BcO;8dDD@R6tOn=8jVuYTdgkSnwk|20K^II5Ae90nB zwkSf60^sr~)_4j5-ZyyMMK>!be-MG(1xzwVS2eq$*7={JHg-*I*RYj8Renjp!O zozI}p@_b$UP?wyzjN(wFlmdQd!!pOC6p=Kwsv6?bHPhDBx~AIk5zI=b#SnkkT4RgaLC&0m^^)yPt@h>HmsryzhuY>cH2zhD%|QrEqaj7?ED z#a$yq-WYiTCO%|oYt}y7%Fsf~E+jKn$qgpiZ zr1Wve12&yKlHoP8k~q&JV#sZJc*#2Py$wg#ob{E^Fp-@6uq6Ef$s`5l?xQq21s++v z<%xWv-IQqy=FX+?Uo&_5RtR2}itf}tP?pfi&RA7rYU-M0s*!icL9>8@ z8_3Z?)crS6!ZGT)WhUWim8L`)N%{kl|659=ikwUtc|eiZ_wPt?aVSP}Ma0sPTH>~4 z(*K)K0nY|Qj#EI6NwuoU0eM@1lTnjWDEba6<)h3(q;;=YW)>8zQ?dw!kW>z5vrV?b zJeVU7hR4LchhDyp$$Zol`VxicR<4$EYNE}32qrKrQ7iUm9N6L6jzKEH4GDe(VK64y znl0OTM6Fc#Zp9=PE`OVRnJ&gp!K@&gMQW6S=o#`yR$!2r;x$j`xfWtzj|$jqM4I~my) zk1)v?Uljhw9DNM^37bj^;^I|Rb*G`~hAy_NjKWC%0|v4M2~a6~mTcU_`%UbT$+oOv zKY$N8dqz{3DtzO>U$f$bc<63$9mO#@xjA6S%U}n{WNrw13tgsS!;T8)LXtA^ErasncK$w zv-Z)VH<^;_y;5fXL?9_|D>z4!>2D>%m;}FL`s_XyxoO}-kwZ7sU*`~b10O%VpIpz$ zqU?zxhn6}{jP}4WV)8x^pLu2qwpd~YD2vPx=W}tH8=uLSsB$A=Q3wIwg&&l?@X_}< zOuFhfR(}z~p3e|{%k7tC3+^lA^FDI(p4ORD$~_TzQf@y~x&7!p2EgZx{wsEIs-8`1 zkma!{&CqLoq@gz&JBnsn;#fmhZG%7XVy)oNUvxTY%eR`0&S5Pxem=+P^pgYdPjn03 z8@@tbx|Up59%{krIqgOm+#W)~?_52oTlxBNS)`o9NhYnYJyFq|9i`F`j;Nc}y4A27 zPTjCI!%}VTBTKKE{K3&|$8mJ6ZWlQz{j + + + + + + + + + + + + + + diff --git a/plugins/redmine_questions/assets/images/upvote_arrow.svg b/plugins/redmine_questions/assets/images/upvote_arrow.svg new file mode 100644 index 0000000..2d65861 --- /dev/null +++ b/plugins/redmine_questions/assets/images/upvote_arrow.svg @@ -0,0 +1,3 @@ + + + Produced by OmniGraffle 6.5.3 2016-07-07 08:55:07 +0000Canvas 1Layer 1 diff --git a/plugins/redmine_questions/assets/images/voting.svg b/plugins/redmine_questions/assets/images/voting.svg new file mode 100644 index 0000000..973ee64 --- /dev/null +++ b/plugins/redmine_questions/assets/images/voting.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/redmine_questions/assets/javascripts/jquery.simplecolorpicker.js b/plugins/redmine_questions/assets/javascripts/jquery.simplecolorpicker.js new file mode 100644 index 0000000..9cfc456 --- /dev/null +++ b/plugins/redmine_questions/assets/javascripts/jquery.simplecolorpicker.js @@ -0,0 +1,235 @@ +/* + * Very simple jQuery Color Picker + * https://github.com/tkrotoff/jquery-simplecolorpicker + * + * Copyright (C) 2012-2013 Tanguy Krotoff + * + * Licensed under the MIT license + */ + +(function($) { + 'use strict'; + + /** + * Constructor. + */ + var SimpleColorPicker = function(select, options) { + this.init('simplecolorpicker', select, options); + }; + + /** + * SimpleColorPicker class. + */ + SimpleColorPicker.prototype = { + constructor: SimpleColorPicker, + + init: function(type, select, options) { + var self = this; + + self.type = type; + + self.$select = $(select); + self.$select.hide(); + + self.options = $.extend({}, $.fn.simplecolorpicker.defaults, options); + + self.$colorList = null; + + if (self.options.picker === true) { + var selectText = self.$select.find('> option:selected').text(); + self.$icon = $('' + + '').insertAfter(self.$select); + self.$icon.on('click.' + self.type, $.proxy(self.showPicker, self)); + + self.$picker = $('').appendTo(document.body); + self.$colorList = self.$picker; + + // Hide picker when clicking outside + $(document).on('mousedown.' + self.type, $.proxy(self.hidePicker, self)); + self.$picker.on('mousedown.' + self.type, $.proxy(self.mousedown, self)); + } else { + self.$inline = $('').insertAfter(self.$select); + self.$colorList = self.$inline; + } + + // Build the list of colors + // + self.$select.find('> option').each(function() { + var $option = $(this); + var color = $option.val(); + + var isSelected = $option.is(':selected'); + var isDisabled = $option.is(':disabled'); + + var selected = ''; + if (isSelected === true) { + selected = ' data-selected'; + } + + var disabled = ''; + if (isDisabled === true) { + disabled = ' data-disabled'; + } + + var title = ''; + if (isDisabled === false) { + title = ' title="' + $option.text() + '"'; + } + + var role = ''; + if (isDisabled === false) { + role = ' role="button" tabindex="0"'; + } + + var $colorSpan = $('' + + ''); + + self.$colorList.append($colorSpan); + $colorSpan.on('click.' + self.type, $.proxy(self.colorSpanClicked, self)); + + var $next = $option.next(); + if ($next.is('optgroup') === true) { + // Vertical break, like hr + self.$colorList.append(''); + } + }); + }, + + /** + * Changes the selected color. + * + * @param color the hexadecimal color to select, ex: '#fbd75b' + */ + selectColor: function(color) { + var self = this; + + var $colorSpan = self.$colorList.find('> span.color').filter(function() { + return $(this).data('color').toLowerCase() === color.toLowerCase(); + }); + + if ($colorSpan.length > 0) { + self.selectColorSpan($colorSpan); + } else { + console.error("The given color '" + color + "' could not be found"); + } + }, + + showPicker: function() { + var pos = this.$icon.offset(); + this.$picker.css({ + // Remove some pixels to align the picker icon with the icons inside the dropdown + left: pos.left - 1, + top: pos.top - 4//+ this.$icon.outerHeight() + }); + + this.$picker.show(this.options.pickerDelay); + }, + + hidePicker: function() { + this.$picker.hide(this.options.pickerDelay); + }, + + /** + * Selects the given span inside $colorList. + * + * The given span becomes the selected one. + * It also changes the HTML select value, this will emit the 'change' event. + */ + selectColorSpan: function($colorSpan) { + var color = $colorSpan.data('color'); + var title = $colorSpan.prop('title'); + + // Mark this span as the selected one + $colorSpan.siblings().removeAttr('data-selected'); + $colorSpan.attr('data-selected', ''); + + if (this.options.picker === true) { + this.$icon.css('background-color', color); + this.$icon.prop('title', title); + this.hidePicker(); + } + + // Change HTML select value + this.$select.val(color); + }, + + /** + * The user clicked on a color inside $colorList. + */ + colorSpanClicked: function(e) { + // When a color is clicked, make it the new selected one (unless disabled) + if ($(e.target).is('[data-disabled]') === false) { + this.selectColorSpan($(e.target)); + this.$select.trigger('change'); + } + }, + + /** + * Prevents the mousedown event from "eating" the click event. + */ + mousedown: function(e) { + e.stopPropagation(); + e.preventDefault(); + }, + + destroy: function() { + if (this.options.picker === true) { + this.$icon.off('.' + this.type); + this.$icon.remove(); + $(document).off('.' + this.type); + } + + this.$colorList.off('.' + this.type); + this.$colorList.remove(); + + this.$select.removeData(this.type); + this.$select.show(); + } + }; + + /** + * Plugin definition. + * How to use: $('#id').simplecolorpicker() + */ + $.fn.simplecolorpicker = function(option) { + var args = $.makeArray(arguments); + args.shift(); + + // For HTML element passed to the plugin + return this.each(function() { + var $this = $(this), + data = $this.data('simplecolorpicker'), + options = typeof option === 'object' && option; + if (data === undefined) { + $this.data('simplecolorpicker', (data = new SimpleColorPicker(this, options))); + } + if (typeof option === 'string') { + data[option].apply(data, args); + } + }); + }; + + /** + * Default options. + */ + $.fn.simplecolorpicker.defaults = { + // No theme by default + theme: '', + + // Show the picker or make it inline + picker: false, + + // Animation delay in milliseconds + pickerDelay: 0 + }; + +})(jQuery); diff --git a/plugins/redmine_questions/assets/javascripts/questions.js b/plugins/redmine_questions/assets/javascripts/redmine_questions.js similarity index 100% rename from plugins/redmine_questions/assets/javascripts/questions.js rename to plugins/redmine_questions/assets/javascripts/redmine_questions.js diff --git a/plugins/redmine_questions/assets/javascripts/tag-it.js b/plugins/redmine_questions/assets/javascripts/tag-it.js deleted file mode 100755 index 1280eca..0000000 --- a/plugins/redmine_questions/assets/javascripts/tag-it.js +++ /dev/null @@ -1,392 +0,0 @@ -/* -* jQuery UI Tag-it! -* -* @version v2.0 (06/2011) -* -* Copyright 2011, Levy Carneiro Jr. -* Released under the MIT license. -* http://aehlke.github.com/tag-it/LICENSE -* -* Homepage: -* http://aehlke.github.com/tag-it/ -* -* Authors: -* Levy Carneiro Jr. -* Martin Rehfeld -* Tobias Schmidt -* Skylar Challand -* Alex Ehlke -* -* Maintainer: -* Alex Ehlke - Twitter: @aehlke -* -* Dependencies: -* jQuery v1.4+ -* jQuery UI v1.8+ -*/ -(function($) { - - $.widget('ui.tagit', { - options: { - itemName : 'item', - fieldName : 'tags', - availableTags : [], - tagSource : null, - removeConfirmation: false, - caseSensitive : true, - placeholderText : null, - - // When enabled, quotes are not neccesary - // for inputting multi-word tags. - allowSpaces: false, - - // Whether to animate tag removals or not. - animate: true, - - // The below options are for using a single field instead of several - // for our form values. - // - // When enabled, will use a single hidden field for the form, - // rather than one per tag. It will delimit tags in the field - // with singleFieldDelimiter. - // - // The easiest way to use singleField is to just instantiate tag-it - // on an INPUT element, in which case singleField is automatically - // set to true, and singleFieldNode is set to that element. This - // way, you don't need to fiddle with these options. - singleField: false, - - singleFieldDelimiter: ',', - - // Set this to an input DOM node to use an existing form field. - // Any text in it will be erased on init. But it will be - // populated with the text of tags as they are created, - // delimited by singleFieldDelimiter. - // - // If this is not set, we create an input node for it, - // with the name given in settings.fieldName, - // ignoring settings.itemName. - singleFieldNode: null, - - // Optionally set a tabindex attribute on the input that gets - // created for tag-it. - tabIndex: null, - - - // Event callbacks. - onTagAdded : null, - onTagRemoved: null, - onTagClicked: null - }, - - - _create: function() { - // for handling static scoping inside callbacks - var that = this; - - // There are 2 kinds of DOM nodes this widget can be instantiated on: - // 1. UL, OL, or some element containing either of these. - // 2. INPUT, in which case 'singleField' is overridden to true, - // a UL is created and the INPUT is hidden. - if (this.element.is('input')) { - this.tagList = $('
    ').insertAfter(this.element); - this.options.singleField = true; - this.options.singleFieldNode = this.element; - this.element.css('display', 'none'); - } else { - this.tagList = this.element.find('ul, ol').andSelf().last(); - } - - this._tagInput = $('').addClass('ui-widget-content'); - if (this.options.tabIndex) { - this._tagInput.attr('tabindex', this.options.tabIndex); - } - if (this.options.placeholderText) { - this._tagInput.attr('placeholder', this.options.placeholderText); - } - - this.options.tagSource = this.options.tagSource || function(search, showChoices) { - var filter = search.term.toLowerCase(); - var choices = $.grep(this.options.availableTags, function(element) { - // Only match autocomplete options that begin with the search term. - // (Case insensitive.) - return (element.toLowerCase().indexOf(filter) === 0); - }); - showChoices(this._subtractArray(choices, this.assignedTags())); - }; - - // Bind tagSource callback functions to this context. - if ($.isFunction(this.options.tagSource)) { - this.options.tagSource = $.proxy(this.options.tagSource, this); - } - - this.tagList - .addClass('tagit') - .addClass('ui-widget ui-widget-content ui-corner-all') - // Create the input field. - .append($('
  • ').append(this._tagInput)) - .click(function(e) { - var target = $(e.target); - if (target.hasClass('tagit-label')) { - that._trigger('onTagClicked', e, target.closest('.tagit-choice')); - } else { - // Sets the focus() to the input field, if the user - // clicks anywhere inside the UL. This is needed - // because the input field needs to be of a small size. - that._tagInput.focus(); - } - }); - - // Add existing tags from the list, if any. - this.tagList.children('li').each(function() { - if (!$(this).hasClass('tagit-new')) { - that.createTag($(this).html(), $(this).attr('class')); - $(this).remove(); - } - }); - - // Single field support. - if (this.options.singleField) { - if (this.options.singleFieldNode) { - // Add existing tags from the input field. - var node = $(this.options.singleFieldNode); - var tags = node.val().split(this.options.singleFieldDelimiter); - node.val(''); - $.each(tags, function(index, tag) { - that.createTag(tag); - }); - } else { - // Create our single field input after our list. - this.options.singleFieldNode = this.tagList.after(''); - } - } - - // Events. - this._tagInput - .keydown(function(event) { - // Backspace is not detected within a keypress, so it must use keydown. - if (event.which == $.ui.keyCode.BACKSPACE && that._tagInput.val() === '') { - var tag = that._lastTag(); - if (!that.options.removeConfirmation || tag.hasClass('remove')) { - // When backspace is pressed, the last tag is deleted. - that.removeTag(tag); - } else if (that.options.removeConfirmation) { - tag.addClass('remove ui-state-highlight'); - } - } else if (that.options.removeConfirmation) { - that._lastTag().removeClass('remove ui-state-highlight'); - } - - // Comma/Space/Enter are all valid delimiters for new tags, - // except when there is an open quote or if setting allowSpaces = true. - // Tab will also create a tag, unless the tag input is empty, in which case it isn't caught. - if ( - // event.which == $.ui.keyCode.COMMA || - event.which == $.ui.keyCode.ENTER || - ( - event.which == $.ui.keyCode.TAB && - that._tagInput.val() !== '' - ) || - ( - event.which == $.ui.keyCode.SPACE && - that.options.allowSpaces !== true && - ( - $.trim(that._tagInput.val()).replace( /^s*/, '' ).charAt(0) != '"' || - ( - $.trim(that._tagInput.val()).charAt(0) == '"' && - $.trim(that._tagInput.val()).charAt($.trim(that._tagInput.val()).length - 1) == '"' && - $.trim(that._tagInput.val()).length - 1 !== 0 - ) - ) - ) - ) { - event.preventDefault(); - that.createTag(that._cleanedInput()); - - // The autocomplete doesn't close automatically when TAB is pressed. - // So let's ensure that it closes. - that._tagInput.autocomplete('close'); - } - }).blur(function(e){ - // Create a tag when the element loses focus (unless it's empty). - that.createTag(that._cleanedInput()); - }); - - - // Autocomplete. - if (this.options.availableTags || this.options.tagSource) { - this._tagInput.autocomplete({ - source: this.options.tagSource, - select: function(event, ui) { - // Delete the last tag if we autocomplete something despite the input being empty - // This happens because the input's blur event causes the tag to be created when - // the user clicks an autocomplete item. - // The only artifact of this is that while the user holds down the mouse button - // on the selected autocomplete item, a tag is shown with the pre-autocompleted text, - // and is changed to the autocompleted text upon mouseup. - if (that._tagInput.val() === '') { - that.removeTag(that._lastTag(), false); - } - that.createTag(ui.item.value); - // Preventing the tag input to be updated with the chosen value. - return false; - } - }); - } - }, - - _cleanedInput: function() { - // Returns the contents of the tag input, cleaned and ready to be passed to createTag - return $.trim(this._tagInput.val().replace(/^"(.*)"$/, '$1')); - }, - - _lastTag: function() { - return this.tagList.children('.tagit-choice:last'); - }, - - assignedTags: function() { - // Returns an array of tag string values - var that = this; - var tags = []; - if (this.options.singleField) { - tags = $(this.options.singleFieldNode).val().split(this.options.singleFieldDelimiter); - if (tags[0] === '') { - tags = []; - } - } else { - this.tagList.children('.tagit-choice').each(function() { - tags.push(that.tagLabel(this)); - }); - } - return tags; - }, - - _updateSingleTagsField: function(tags) { - // Takes a list of tag string values, updates this.options.singleFieldNode.val to the tags delimited by this.options.singleFieldDelimiter - $(this.options.singleFieldNode).val(tags.join(this.options.singleFieldDelimiter)); - }, - - _subtractArray: function(a1, a2) { - var result = []; - for (var i = 0; i < a1.length; i++) { - if ($.inArray(a1[i], a2) == -1) { - result.push(a1[i]); - } - } - return result; - }, - - tagLabel: function(tag) { - // Returns the tag's string label. - if (this.options.singleField) { - return $(tag).children('.tagit-label').text(); - } else { - return $(tag).children('input').val(); - } - }, - - _isNew: function(value) { - var that = this; - var isNew = true; - this.tagList.children('.tagit-choice').each(function(i) { - if (that._formatStr(value) == that._formatStr(that.tagLabel(this))) { - isNew = false; - return false; - } - }); - return isNew; - }, - - _formatStr: function(str) { - if (this.options.caseSensitive) { - return str; - } - return $.trim(str.toLowerCase()); - }, - - createTag: function(value, additionalClass) { - var that = this; - // Automatically trims the value of leading and trailing whitespace. - value = $.trim(value); - - if (!this._isNew(value) || value === '') { - return false; - } - - var label = $(this.options.onTagClicked ? '' : '').text(value); - - // Create tag. - var tag = $('
  • ') - .addClass('tagit-choice ui-widget-content ui-state-default ui-corner-all') - .addClass(additionalClass) - .append(label); - - // Button for removing the tag. - var removeTagIcon = $('') - .addClass('ui-icon ui-icon-close'); - var removeTag = $('\xd7') // \xd7 is an X - .addClass('tagit-close') - .append(removeTagIcon) - .click(function(e) { - // Removes a tag when the little 'x' is clicked. - that.removeTag(tag); - }); - tag.append(removeTag); - - // Unless options.singleField is set, each tag has a hidden input field inline. - if (this.options.singleField) { - var tags = this.assignedTags(); - tags.push(value); - this._updateSingleTagsField(tags); - } else { - var escapedValue = label.html(); - tag.append(''); - } - - this._trigger('onTagAdded', null, tag); - - // Cleaning the input. - this._tagInput.val(''); - - // insert tag - this._tagInput.parent().before(tag); - }, - - removeTag: function(tag, animate) { - animate = animate || this.options.animate; - - tag = $(tag); - - this._trigger('onTagRemoved', null, tag); - - if (this.options.singleField) { - var tags = this.assignedTags(); - var removedTagLabel = this.tagLabel(tag); - tags = $.grep(tags, function(el){ - return el != removedTagLabel; - }); - this._updateSingleTagsField(tags); - } - // Animate the removal. - if (animate) { - tag.fadeOut('fast').hide('blind', {direction: 'horizontal'}, 'fast', function(){ - tag.remove(); - }).dequeue(); - } else { - tag.remove(); - } - }, - - removeAll: function() { - // Removes all tags. - var that = this; - this.tagList.children('.tagit-choice').each(function(index, tag) { - that.removeTag(tag, false); - }); - } - - }); - -})(jQuery); - - diff --git a/plugins/redmine_questions/assets/stylesheets/jquery.simplecolorpicker.css b/plugins/redmine_questions/assets/stylesheets/jquery.simplecolorpicker.css new file mode 100644 index 0000000..234017d --- /dev/null +++ b/plugins/redmine_questions/assets/stylesheets/jquery.simplecolorpicker.css @@ -0,0 +1,88 @@ +/* + * Very simple jQuery Color Picker + * https://github.com/tkrotoff/jquery-simplecolorpicker + * + * Copyright (C) 2012-2013 Tanguy Krotoff + * + * Licensed under the MIT license + */ + +/** + * Inspired by Bootstrap Twitter. + * See https://github.com/twbs/bootstrap/blob/master/less/navbar.less + * See https://github.com/twbs/bootstrap/blob/master/less/dropdowns.less + */ + +.simplecolorpicker.picker { + position: absolute; + top: 100%; + left: 0; + z-index: 1051; /* Above Bootstrap modal (@zindex-modal = 1050) */ + display: none; + float: left; + + min-width: 160px; + max-width: 283px; /* @popover-max-width = 276px + 7 */ + + padding: 5px 0 0 5px; + margin: 2px 0 0; + list-style: none; + background-color: #fff; /* @dropdown-bg */ + + border: 1px solid #ccc; +} + +.simplecolorpicker.inline { + display: inline-block; +} + +.simplecolorpicker span { + margin: 0 5px 5px 0; +} + +.simplecolorpicker.button, +.simplecolorpicker span.color { + display: inline-block; + outline: none; + cursor: pointer; + border: 1px solid transparent; +} + +.simplecolorpicker.button { + border: 1px solid #DDD; +} + +.simplecolorpicker.button:after, +.simplecolorpicker span.color:after { + content: '\00a0\00a0\00a0\00a0'; /* Spaces */ +} + +.simplecolorpicker span.color[data-disabled]:hover { + cursor: not-allowed; + border: 1px solid transparent; +} + +.simplecolorpicker span.color:hover, +.simplecolorpicker span.color[data-selected], +.simplecolorpicker span.color[data-selected]:hover { + border: 1px solid #222; /* @gray-dark */ +} +.simplecolorpicker span.color[data-selected]:after { + color: #fff; +} + +/* Vertical separator, replaces optgroup. */ +.simplecolorpicker span.vr { + border-left: 1px solid #222; /* @gray-dark */ +} + +.simplecolorpicker span.color[data-selected]:after { + /*font-family: 'FontAwesome';*/ + -webkit-font-smoothing: antialiased; + + content: '\2714'; /* Ok/check mark */ + + margin-right: 2px; + margin-left: 2px; +} + diff --git a/plugins/redmine_questions/assets/stylesheets/jquery.tagit.css b/plugins/redmine_questions/assets/stylesheets/jquery.tagit.css deleted file mode 100755 index 36dc882..0000000 --- a/plugins/redmine_questions/assets/stylesheets/jquery.tagit.css +++ /dev/null @@ -1,54 +0,0 @@ -ul.tagit { - padding: 1px 5px; - overflow: auto; - margin-left: inherit; /* usually we don't want the regular ul margins. */ - margin-right: inherit; -} -ul.tagit li { - display: block; - float: left; - margin: 2px 5px 2px 0; -} -ul.tagit li.tagit-choice { - padding: .2em 18px .2em .5em; - position: relative; - line-height: inherit; -} -ul.tagit li.tagit-new { - padding: .25em 4px .25em 0; -} - -ul.tagit li.tagit-choice a.tagit-label { - cursor: pointer; - text-decoration: none; -} -ul.tagit li.tagit-choice .tagit-close { - cursor: pointer; - position: absolute; - right: .1em; - top: 50%; - margin-top: -8px; -} - -/* used for some custom themes that don't need image icons */ -ul.tagit li.tagit-choice .tagit-close .text-icon { - display: none; -} - -ul.tagit li.tagit-choice input { - display: block; - float: left; - margin: 2px 5px 2px 0; -} -ul.tagit input[type="text"] { - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - box-sizing: border-box; - - border: none; - margin: 0; - padding: 0; - width: inherit; - background-color: inherit; - outline: none; -} diff --git a/plugins/redmine_questions/assets/stylesheets/questions.css b/plugins/redmine_questions/assets/stylesheets/questions.css deleted file mode 100644 index 667aec3..0000000 --- a/plugins/redmine_questions/assets/stylesheets/questions.css +++ /dev/null @@ -1,239 +0,0 @@ -#forum_list div.list-item { - margin-bottom: 10px; -} - -#forum_list div.list-item .last-author { - font-size: 80%; - color: gray; -} - -#forum_list div.list-item .last-author a { - color: gray; -} - -#forum_list > ul > li { - float: left; - width: 44%; - padding: 0; - margin: 15px 3% 0 0; -} - -#forum_list div.project-forums { - border-bottom: 1px solid #CCC; - padding-top: 20px; - clear: left; -} - -#forum_list > ul { - list-style: none; - padding: 0px; - margin-top: 0px; -} - -#forum_list > ul > li.even { - margin-right: 0; - width: 46%; -} - -#forum_list > ul > li.odd { - clear: left; -} - -#forum_list > ul > li.odd, #forum_list > ul > li.even { - background-color: inherit; -} - -.topic { - padding: 10px 0 20px; -} - -div.topic p { - margin: 5px 0; -} - -div.topic h3.subject { - margin: 0px; -} - -div.topic ul.meta { - margin: 0px; - padding: 0px; -} - -div.topic ul.meta li { - display: block; - float: left; - font-size: 11px; - color: #999; - margin-right: 8px; - list-style: none; -} - -#topics_list div.title-bar h4 { - padding: 15px 0; - border-bottom: 1px dotted #bbb; -} - -input.questions-search { - background: url(/images/magnifier.png) no-repeat 6px 50%; - border: 1px solid #D7D7D7; - background-color: white; - padding-left: 30px; - border-radius: 3px; - height: 1.5em; - width: 94%; - font-size: 16px; -} - -input.questions-search.ajax-loading { - background-image: url(/images/loading.gif); -} - -div.message.reply { - margin-bottom: 20px; -} - -div.message.reply div.avatar { - position: absolute; -} - -div.message.reply div.reply-details.use-avatar { - padding-left: 50px; -} - -div.message.reply .author{ - margin-bottom: 5px; -} - -div.message.reply .wiki > p:first-child { - margin-top: 0px; -} - -div.message.reply .contextual .icon.vote { - position: relative; - bottom: 5px; -} - -div.message.details img.gravatar { - float: left; - margin-right: 5px; -} - -div.message.details p.author { - margin-top: 15px; -} - -div.message.details .wiki { - margin-top: 15px; - padding-top: 10px; - border-top: 1px dotted #BBB; -} - -/* Question meta */ - -#sidebar ul.question-meta, #sidebar ul.related-topics { - list-style: none; - padding: 0px; -} - -#sidebar ul.question-meta li { - margin-bottom: 10px; - padding-left: 20px; - padding-top: 2px; - padding-bottom: 3px; -} - -#sidebar ul.related-topics li { - margin-bottom: 5px; -} - -/* Tags cloud */ - -#sidebar ul.questions-tags { - list-style: none; - padding: 0px; -} - -#sidebar ul.questions-tags li { - margin-bottom: 5px; -} - -#sidebar ul.questions-tags span.count { - color: gray; -} - - - -/**********************************************************************/ -/* TAGS -/**********************************************************************/ -.message-tags-edit ul.tagit li.tagit-choice:hover, ul.tagit li.tagit-choice.remove { - background-color: #E5E5E5; - text-decoration: none; - color: black; -} - -.message-tags-edit ul.tagit { - border: 1px solid #D7D7D7; - -moz-border-radius: 0px; - -webkit-border-radius: 0px; - -khtml-border-radius: 0px; - border-radius: 0px; - background: white; - padding: 0px; - margin-top: 0px; -} - -.message-tags-edit ul.tagit li.tagit-choice { - font-weight: normal; - -moz-border-radius: 0px; - -webkit-border-radius: 0px; - border-radius: 0px; - font-size: 11px; - color: inherit; - padding-top: 0px; - padding-bottom: 0px; - background-color: #F7F7F7; - margin: 1px; -} - -.message-tags-edit ul.tagit li.tagit-choice { - font-weight: normal; - font-size: 11px; - color: inherit; -} - -.message-tags-edit ul.tagit li.tagit-choice a.tagit-close { - text-decoration: none; -} - -.message-tags-edit ul.tagit li.tagit-choice .tagit-close .text-icon { - display: inline; - line-height: 16px; -} - -.message-tags-edit ul.tagit li.tagit-choice .ui-icon { - display: none; -} - -.message-tags-edit ul.tagit li.tagit-new { - padding: 0px; -} - -.message-tags-edit ul.tagit li.tagit-new input { - font-size: 11px; - background: white; - margin-bottom: 2px; - margin-left: 2px; - width: 200px; -} - -/**********************************************************************/ -/* ICONS -/**********************************************************************/ - -.icon-vote { background-image: url(../images/thumb_up.png); } -.icon-unvote { background-image: url(../images/unvote.png); } -.icon-view { background-image: url(../images/eye.png); } -.icon-calendar { background-image: url(/images/calendar.png); } -.icon-tag { background-image: url(../images/tag_blue.png); } \ No newline at end of file diff --git a/plugins/redmine_questions/assets/stylesheets/redmine_questions.css b/plugins/redmine_questions/assets/stylesheets/redmine_questions.css new file mode 100644 index 0000000..7843900 --- /dev/null +++ b/plugins/redmine_questions/assets/stylesheets/redmine_questions.css @@ -0,0 +1,402 @@ +/**********************************************************************/ +/* SECTION list +/**********************************************************************/ + +.section-list {margin-top: 10px} +.section-list .section-tile { + text-align: center; + display: inline-block; + width: 29%; + border: 1px solid #e0e0e0; + margin: 0 .8% 20px; + padding: 1.5em 1em; + cursor: pointer; + -webkit-transition: background .15s; + -moz-transition: background .15s; + -o-transition: background .15s; + transition: background .15s; + vertical-align: top; +} + +.section-list .section-tile:hover { + text-decoration: none; + background: #f8f8f8 +} +.section-list .section-tile .description { + color: #999; +} +/**********************************************************************/ +/* QUESTION index +/**********************************************************************/ + +.questions h2.section-title { + margin-bottom: 0px; +} + +.questions .filters { + margin-top: 10px; +} + +.questions-filters { + float: right; +} + +.questions-filters > ul > li { + list-style-type: none; + float: left; + margin-left: 5px; +} + +.questions-filters > ul > li:not(:last-child):after { + content: " |" +} + +.questions-filters > ul > li a.selected { + color: #888; +} + +#forum_list div.list-item { + margin-bottom: 10px; +} + +#forum_list div.list-item .last-author { + font-size: 80%; + color: gray; +} + +#forum_list div.list-item .last-author a { + color: gray; +} + +#forum_list > ul > li { + float: left; + width: 44%; + padding: 0; + margin: 15px 3% 0 0; +} + +#forum_list div.project-forums { + border-bottom: 1px solid #CCC; + padding-top: 20px; + clear: left; +} + +#forum_list > ul { + list-style: none; + padding: 0px; + margin-top: 0px; +} + +#forum_list > ul > li.even { + margin-right: 0; + width: 46%; +} + +#forum_list > ul > li.odd { + clear: left; +} + +#forum_list > ul > li.odd, #forum_list > ul > li.even { + background-color: inherit; +} + +.topic { + padding: 20px 0 20px; +} + +.comment_container .topic{ + padding: 5px 0 5px; +} + +div.topic p { + margin: 5px 0; +} + +div.topic h3.subject { + margin: 0px; +} + +div.topic ul.meta { + margin: 0px; + padding: 0px; +} + +div.topic ul.meta li { + display: block; + float: left; + font-size: 11px; + color: #999; + margin-right: 8px; + list-style: none; +} + +div.topic ul.meta li a { + color: #999; +} + +#topics_container.votable .topic-vote {float: left; width: 60px; text-align: center;} +#topics_container.votable .topic-content {padding-left: 60px;} +#topics_container.votable .topic-vote .vote-score {display: block; font-size: 24px;} +#topics_container.votable .topic-vote .vote-score {display: block; font-size: 24px;} +#topics_container.votable .topic-vote label {color: #999; line-height: 1; font-size: 12px; margin-bottom: 3px; display: block;} +#topics_container.votable .topic-vote .status-answered { + height: 30px; + width: 35px; + background-position: -35px -75px; + margin-left: auto; + margin-right: auto; +} + +#topics_list div.title-bar h4 { + padding: 15px 0; + border-bottom: 1px dotted #bbb; +} + +input.questions-search { + background: url(/images/magnifier.png) no-repeat 6px 50%; + border: 1px solid #D7D7D7; + background-color: white; + padding-left: 30px !important; + border-radius: 3px; + height: 1.5em; + width: 94%; + font-size: 16px; +} + +input.questions-search.ajax-loading { + background-image: url(/images/loading.gif); +} + + + +/**********************************************************************/ +/* QUESTION show +/**********************************************************************/ + +h1.question-title { + font-weight: normal; +} + +div.question.answer { + margin-bottom: 20px; + padding-top: 10px; + border-top: 1px solid #ddd; +} + +.question a[disabled] { + color: #aaa; + pointer-events: none; +} + +div.question img.gravatar { + float: left; + margin-right: 5px; +} + +div.question p.author { + margin-top: 0px; +} + +.question-status-tag { + font-family: Verdana, sans-serif; + background-color: #759FCF; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 3px; + padding: 2px 4px; + font-size: 10px; + display: inline-block; + vertical-align: middle; + color: white; + font-weight: normal; +} + +/* Question vote*/ + +div.question {display: table; width: 100%;} +div.question.votable .vote {display: table-cell; padding: 0px 12px;} +div.question.votable .question-container {display: table-cell;vertical-align: top;} +div.question.votable .question-container .contextual {margin-top: 0px;} + +.question .vote a.disabled {pointer-events: none;opacity: 0.5} +.question .vote {font-size: 24px; width: 35px;} + +.question .vote .vote-up, +.question .vote .vote-down, +.question .vote .vote-count, +.question .vote .accepted { + display: block; + margin: 0 auto; + width: 35px; + height: 35px; + margin-bottom: 2px; + text-align: center; + text-decoration: none; + cursor: pointer; +} + +.question .vote .vote-up, +.question .vote .vote-down, +.question .vote .accepted, +#topics_container.votable .topic-vote .status-answered { + background-image: url(../images/voting.svg); + background-size: initial; + background-repeat: no-repeat; + overflow: hidden; +} + +.question .vote .accepted {cursor: default; background-position: 0px -69px;} +.question .vote .vote-up {background-position: -70px 0px;} +.question .vote .vote-down {background-position: -35px 0px;} +.question .vote .vote-count {height: 32px;} +/*.question .vote .vote-up:hover {background-position: -70px -35px;} +.question .vote .vote-down:hover {background-position: -35px -35px;} +*/ +.question div.attachments { + margin-bottom: 12px; +} + +/* Question meta */ + +#sidebar ul.question-meta, #sidebar ul.related-topics { + list-style: none; + padding: 0px; +} + +#sidebar ul.question-meta li { + margin-bottom: 10px; + padding-left: 20px; + padding-top: 2px; + padding-bottom: 3px; +} + +#sidebar ul.related-topics li { + margin-bottom: 5px; +} + +/* Tags cloud */ + +#sidebar ul.questions-tags { + list-style: none; + padding: 0px; +} + +#sidebar ul.questions-tags li { + margin-bottom: 5px; +} + +#sidebar ul.questions-tags span.count { + color: gray; +} + +/**********************************************************************/ +/* SOLUTION show +/**********************************************************************/ +.question.solution > h2 { + margin-bottom: 0px; + padding-bottom: 10px; + border-bottom: 1px solid #ddd; +} + +.question.solution .liking { + padding: 10px 0px; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd; + margin: 10px 0px +} + +.question.solution .liking > a { + padding: 0 5px; +} + + +.question.solution .liking .author { + float: right; +} + + + + +/**********************************************************************/ +/* COMMENTS +/**********************************************************************/ + +.comments_container { + background-color: #f5f5f5; + font-size: 0.9em; + margin: 10px 0px 0px 10px; +} + +.question-comments .comment .contextual { + display: none; +} + +.question-comments .comment:hover .contextual { + display: inline-block; + opacity: 0.4; +} + +.question-comments .comment .contextual:hover { + opacity: 1; +} + + +.question-comments .comment { + padding: 10px; + border-bottom: 1px dashed #ccc; +} + +.question-comments .comment:last-child { + border-bottom: 0px; +} + +.question-comments .comment .author { + margin-bottom: 3px; +} + +.question-comments .comment .wiki-content { + color: #707070; + display: inline-block; +} +.comments_container .comment .wiki-content p { + margin-bottom: 0px; +} + +.question-comments .comment .wiki-content p:first-child { + margin-top: 0px; +} + +.add-comment-link { + font-size: 0.9em; + display: block; +} + +.add_comments {padding: 10px 10px 10px;} +.add_comments:not(:first-child) {border-top: 1px dashed #ccc;} + +.add_comments textarea { + width: 98%; +} + +/* Answers*/ + +#answers { + padding-top: 10px; +} + +.accepted_answer{ + float: right; +} + + +/**********************************************************************/ +/* ICONS +/**********************************************************************/ + +.icon-vote { background-image: url(../images/thumb_up.png); } +.icon-unvote { background-image: url(../images/unvote.png); } +.icon-downvote { background-image: url(../images/thumb_down.png); } +.icon-view { background-image: url(../images/eye.png); } +.icon-calendar { background-image: url(/images/calendar.png); } +.icon-tag { background-image: url(../images/tag_blue.png); } +.icon-question { background-image: url(../../../images/help.png); } +.icon-solution { background-image: url(../images/book_open.png); } diff --git a/plugins/redmine_questions/config/locales/en.yml b/plugins/redmine_questions/config/locales/en.yml index 660c65a..1c06d6c 100644 --- a/plugins/redmine_questions/config/locales/en.yml +++ b/plugins/redmine_questions/config/locales/en.yml @@ -6,13 +6,13 @@ en: label_questions_new: New question label_questions_message: Message label_questions_added_time: "Added %{value} ago" - label_questions_related_messages: Related messages + label_questions_related_questions: Related questions label_questions_latest_messages: Latest messages label_questions_views: '%{count} views' label_questions_votes: '%{count} votes' label_questions_answers: '%{count} answers' label_questions_tags: Tags - label_questions_tagged_by: '%{count} topic(s) tagged by %{tag}' + label_questions_tagged_by: '%{count} item(s) tagged by %{tag}' label_questions_sidebar_message: Sidebar message label_questions_notice: Notice label_questions_most_voted: Most voted @@ -24,9 +24,31 @@ en: field_questions_tags: Tags - permission_view_questions: View Help & Support - permission_edit_messages_tags: Edit tags - permission_edit_vote_messages: Vote messages + label_questions_add_comment: Add comment + label_question_comment_successful_added: Comment successful added + label_question_successful_update: Question successful updated + label_answer_successful_update: Answer successful updated + label_answer_successful_added: Answer successful added + lebel_questions_new_comment: New comment + + button_questions_to_issue: Convert to issue + button_questions_issue_to_question: Convert to question + label_questions_actions: Actions + label_questions_accept: Accept + + label_questions_section_type_questions: Questions + label_questions_section_type_solutions: Solutions + label_questions_section_type_ideas: Ideas + + label_questions_section: Section + label_questions_sections_plural: Sections + label_questions_section_new: New section + label_questions_section_type: Section type + label_questions_topic: Topic + label_questions_featured: Featured + label_questions_locked: Locked + + project_module_questions: Questions i18n: transliterate: @@ -105,4 +127,46 @@ en: "Ь": "" "Э": "E" "Ю": "YU" - "Я": "YA" \ No newline at end of file + "Я": "YA" + label_questions_comment: Comment + label_questions_your_answer: Your answer + label_questions_answer_plural: Answers + label_questions_x_votes: + one: "vote" + other: "votes" + label_questions_wasthishelpful: Was this helpful? + + label_question_plural: Questions + label_questions_related_solutions: Related solutions + label_questions_section_edit: Edit section + label_soluition_plural: Solutions + label_questions_add_tag: '+ add tag' + label_questions_vote_added: Vote added + label_questions_vote_removed: Vote removed + label_questions_vote_own: Vote own questions + label_questions_show_popular: Show popular articles in section + label_questions_most_popular: Most popular + label_questions_status_plural: Idea statuses + label_questions_status_closed: Closed + label_questions_status_new: New status + label_questions_newest: Newest + label_questions_active: Active + label_questions_voted: Voted + label_questions_unanswered: Unanswered + + permission_view_questions: View questions + permission_create_tags: Create new tags + permission_edit_vote_messages: Vote questions + permission_add_answers: Add answers + permission_delete_answers: Delete answers + permission_edit_question_comments: Edit comments + permission_edit_own_question_comments: Edit own comments + permission_comment_question: Add comments + permission_add_questions: Add questions + permission_edit_questions: Edit questions + permission_edit_own_questions: Edit own questions + permission_delete_questions: Delete questions + permission_vote_questions: Vote questions + permission_accept_answers: Accept answers + permission_manage_sections: Manage sections + permission_create_tags: Create new tags \ No newline at end of file diff --git a/plugins/redmine_questions/config/locales/es.yml b/plugins/redmine_questions/config/locales/es.yml index 9531ee3..b052764 100644 --- a/plugins/redmine_questions/config/locales/es.yml +++ b/plugins/redmine_questions/config/locales/es.yml @@ -4,7 +4,7 @@ es: label_questions_new: Nueva pregunta label_questions_message: Mensaje label_questions_added_time: "Agregado hace %{value}" - label_questions_related_messages: Mensajes relacionados + label_questions_related_questions: Mensajes relacionados label_questions_latest_messages: Últimos mensajes label_questions_views: '%{count} vistas' label_questions_votes: '%{count} votos' diff --git a/plugins/redmine_questions/config/locales/ru.yml b/plugins/redmine_questions/config/locales/ru.yml index e5da458..a8c198d 100644 --- a/plugins/redmine_questions/config/locales/ru.yml +++ b/plugins/redmine_questions/config/locales/ru.yml @@ -1,11 +1,13 @@ # Russian strings go here for Rails i18n +# encoding: utf-8 +# English strings go here for Rails i18n ru: - label_questions: 'Поддержка' + label_questions: 'Вопросы/Ответы' label_questions_search: 'Поиск вопросов и ответов ...' label_questions_new: Новая тема label_questions_message: Сообщение label_questions_added_time: "Добавлена %{value} назад" - label_questions_related_messages: Связанные темы + label_questions_related_questions: Связанные вопросы label_questions_latest_messages: Последние сообщения label_questions_views: '%{count} просмотров' label_questions_votes: '%{count} голосов' @@ -23,6 +25,73 @@ ru: field_questions_tags: Тэги + + label_questions_add_comment: Комментировать + label_question_comment_successful_added: Комментарий добавлен + label_question_successful_update: Вопрос обновлен + label_answer_successful_update: Ответ обновлен + label_answer_successful_added: Ответ добавлен + lebel_questions_new_comment: Новый комментарий + + button_questions_to_issue: Конв. в задачу + button_questions_issue_to_question: Конв. в вопрос + label_questions_actions: Действия + label_questions_accept: Принять + + label_questions_section_type_questions: Вопросы + label_questions_section_type_solutions: Решения + label_questions_section_type_ideas: Идеи + + label_questions_section: Раздел + label_questions_sections_plural: Разделы + label_questions_section_new: Новый раздел + label_questions_section_type: Тип раздела + label_questions_featured: Выделено + label_questions_locked: Заблокировано + + project_module_questions: Вопросы/Ответы + + label_questions_comment: Комментарий + label_questions_your_answer: Ваш ответ + label_questions_answer_plural: Оветы + label_questions_x_votes: + one: "голос" + few: "голоса" + many: "голосов" + other: "голоса" + label_questions_wasthishelpful: Полезно ли Вам было? + + label_question_plural: Вопросы + label_questions_related_solutions: Связанные решения + label_questions_section_edit: Редактировать раздел + label_soluition_plural: Решения + label_questions_add_tag: '+ добавить тэг' + label_questions_vote_added: Голос добавлен + label_questions_vote_removed: Голос удален + label_questions_vote_own: Голосовать за свои вопросы + label_questions_show_popular: Показыть популярные вопросы на списке секций + label_questions_most_popular: Популярные + label_questions_status_plural: Статусы идеи + label_questions_status_closed: Закрыто + label_questions_status_new: Новый статус + label_questions_newest: Новейшие + label_questions_active: Активные + label_questions_voted: Голоса + label_questions_unanswered: Неотвеченные + permission_view_questions: Просматривать вопросы ответы - permission_edit_messages_tags: Редактирвоать тэги + permission_create_tags: Создавать тэги permission_edit_vote_messages: Голосовать + permission_add_answers: Добавить ответы + permission_delete_answers: Удалить ответы + permission_edit_question_comments: Редактировать комментарии + permission_edit_own_question_comments: Редактировать свои комментарии + permission_comment_question: Добавить комментарии + permission_add_questions: Добавить вопросы + permission_edit_questions: Редактировать вопросы + permission_edit_own_questions: Редактировать свои вопросы + permission_delete_questions: Удалить вопросы + permission_vote_questions: Голосовать за вопросы + permission_accept_answers: Принимать ответы + permission_manage_sections: Управлять секциями + permission_create_tags: Создавать новые тэги \ No newline at end of file diff --git a/plugins/redmine_questions/config/locales/zh.yml b/plugins/redmine_questions/config/locales/zh.yml index 090f103..d0e517f 100644 --- a/plugins/redmine_questions/config/locales/zh.yml +++ b/plugins/redmine_questions/config/locales/zh.yml @@ -2,11 +2,10 @@ # Simplified Chinese strings go here for Rails i18n # Author: Salivaxiu@163.com # Based on file: en.yml - zh: label_questions: '帮助与支持' label_questions_search: '搜索特定的问题或回答或帖子...' - label_questions_new: 新问题 + label_questions_new: 新问答 label_questions_message: 消息 label_questions_added_time: "在 %{value} 之前增加" label_questions_related_messages: 相关的消息 @@ -16,7 +15,7 @@ zh: label_questions_answers: '回答 %{count} 次' label_questions_tags: 标签 label_questions_tagged_by: '%{count} 个主题包含标签 %{tag}' - label_questions_notice_message: 通知消息 + label_questions_sidebar_message: 侧边栏信息 label_questions_notice: 通知 label_questions_most_voted: 大多数投票 diff --git a/plugins/redmine_questions/config/routes.rb b/plugins/redmine_questions/config/routes.rb index 60e6c79..9135b49 100644 --- a/plugins/redmine_questions/config/routes.rb +++ b/plugins/redmine_questions/config/routes.rb @@ -1,14 +1,65 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + # Plugin's routes # See: http://guides.rubyonrails.org/routing.html +# match '/news/:id/comments', :to => 'comments#create', :via => :post +# match '/news/:id/comments/:comment_id', :to => 'comments#destroy', :via => :delete resources :questions do collection do - get :autocomplete_for_topic + put :preview + put :update_form + # match :preview, :to => 'questions#preview', :via => [:get, :put, :post] + get :autocomplete_for_subject get :topics + get :index_public end member do - get :vote + get :from_issue + # post :new_comment + end + resources :questions_answers, :as => :answers +end + +resources :questions_answers, :except => [:show, :index] do + collection do + put :preview end end -match "issues/:issue_id/move_to_forum/:board_id" => "questions#convert_issue", :via => [:get, :post] +match "questions_votes", :to => 'questions_votes#create', :via => [:get, :post], :as => 'questions_votes' + +resources :questions_comments do + member do + post :update + end +end + +resources :questions_sections +resources :questions_statuses, :except => :show + +resources :projects do + resources :questions_sections + resources :questions +end + +match "projects/:project_id/questions/questions_sections/:section_id" => "questions#index", :via => [:get] +match "questions/questions_sections/:section_id" => "questions#index", :via => [:get] +match 'auto_completes/questions_tags' => 'auto_completes#questions_tags', :via => :get, :as => 'auto_complete_questions_tags' diff --git a/plugins/redmine_questions/db/migrate/001_acts_as_votable_migration.rb b/plugins/redmine_questions/db/migrate/001_acts_as_votable_migration.rb index 326fe3a..7f4787d 100644 --- a/plugins/redmine_questions/db/migrate/001_acts_as_votable_migration.rb +++ b/plugins/redmine_questions/db/migrate/001_acts_as_votable_migration.rb @@ -1,18 +1,27 @@ -class ActsAsVotableMigration < ActiveRecord::Migration +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class ActsAsVotableMigration < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] def self.up ActiveRecord::Base.create_votable_table - add_column :messages, :cached_votes_total, :integer, :default => 0 - add_column :messages, :cached_votes_up, :integer, :default => 0 - add_column :messages, :cached_votes_down, :integer, :default => 0 - add_index :messages, :cached_votes_total - add_index :messages, :cached_votes_up - add_index :messages, :cached_votes_down end def self.down - ActiveRecord::Base.drop_votable_table - remove_column :messages, :cached_votes_total - remove_column :messages, :cached_votes_up - remove_column :messages, :cached_votes_down end end diff --git a/plugins/redmine_questions/db/migrate/002_add_viewing_migration.rb b/plugins/redmine_questions/db/migrate/002_add_viewing_migration.rb index 386d522..63f04c0 100644 --- a/plugins/redmine_questions/db/migrate/002_add_viewing_migration.rb +++ b/plugins/redmine_questions/db/migrate/002_add_viewing_migration.rb @@ -1,10 +1,29 @@ -class AddViewingMigration < ActiveRecord::Migration +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . +class AddViewingMigration < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] def self.up - ActiveRecord::Base.create_viewings_table + unless table_exists?(:viewings) + ActiveRecord::Base.create_viewings_table + end end def self.down - ActiveRecord::Base.drop_viewings_table end end diff --git a/plugins/redmine_questions/db/migrate/003_add_tagging_migration.rb b/plugins/redmine_questions/db/migrate/003_add_tagging_migration.rb index 2b1c55d..a54614e 100644 --- a/plugins/redmine_questions/db/migrate/003_add_tagging_migration.rb +++ b/plugins/redmine_questions/db/migrate/003_add_tagging_migration.rb @@ -1,4 +1,23 @@ -class AddTaggingMigration < ActiveRecord::Migration +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class AddTaggingMigration < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] def up ActiveRecord::Base.create_taggable_table end diff --git a/plugins/redmine_questions/db/migrate/004_create_questions.rb b/plugins/redmine_questions/db/migrate/004_create_questions.rb new file mode 100644 index 0000000..8165cf0 --- /dev/null +++ b/plugins/redmine_questions/db/migrate/004_create_questions.rb @@ -0,0 +1,39 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class CreateQuestions < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] + def change + create_table :questions do |t| + t.string :subject + t.text :content + t.references :section, :index => true + t.references :status, :index => true + t.references :author, :index => true + t.boolean :featured, :default => false + t.boolean :locked, :default => false + t.integer :cached_weighted_score, :default => 0 + t.integer :comments_count, :default => 0 + t.integer :answers_count, :default => 0 + t.integer :views, :default => 0 + t.integer :total_views, :default => 0 + t.datetime :created_on + t.datetime :updated_on + end + end +end diff --git a/plugins/redmine_questions/db/migrate/005_create_questions_sections.rb b/plugins/redmine_questions/db/migrate/005_create_questions_sections.rb new file mode 100644 index 0000000..f53d117 --- /dev/null +++ b/plugins/redmine_questions/db/migrate/005_create_questions_sections.rb @@ -0,0 +1,31 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class CreateQuestionsSections < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] + def change + create_table :questions_sections do |t| + t.string :name + t.text :description + t.references :project, :index => true + t.string :section_type + t.integer :position + end + add_index :questions_sections, :position + end +end diff --git a/plugins/redmine_questions/db/migrate/006_create_questions_answers.rb b/plugins/redmine_questions/db/migrate/006_create_questions_answers.rb new file mode 100644 index 0000000..2c984b2 --- /dev/null +++ b/plugins/redmine_questions/db/migrate/006_create_questions_answers.rb @@ -0,0 +1,35 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class CreateQuestionsAnswers < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] + def change + create_table :questions_answers do |t| + t.text :content + t.references :author, :index => true + t.references :question, :index => true + t.boolean :accepted, :default => false + t.integer :cached_weighted_score, :default => 0 + t.integer :comments_count, :default => 0 + t.datetime :created_on + t.datetime :updated_on + end + + add_index :questions_answers, :accepted + end +end diff --git a/plugins/redmine_questions/db/migrate/007_create_questions_statuses.rb b/plugins/redmine_questions/db/migrate/007_create_questions_statuses.rb new file mode 100644 index 0000000..9fb72d0 --- /dev/null +++ b/plugins/redmine_questions/db/migrate/007_create_questions_statuses.rb @@ -0,0 +1,32 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +class CreateQuestionsStatuses < Rails.version < '5.1' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2] + def change + create_table :questions_statuses do |t| + t.string :name + t.boolean :is_closed, :default => false + t.string :color + t.integer :position + end + + add_index :questions_statuses, :is_closed + add_index :questions_statuses, :position + end +end diff --git a/plugins/redmine_questions/doc/CHANGELOG b/plugins/redmine_questions/doc/CHANGELOG old mode 100644 new mode 100755 index dee05fc..aee16f7 --- a/plugins/redmine_questions/doc/CHANGELOG +++ b/plugins/redmine_questions/doc/CHANGELOG @@ -1,13 +1,19 @@ == Redmine Q&A plugin changelog Redmine Q&A plugin -Copyright (C) 2011-2016 Kirill Bezrukov -http://www.redminecrm.com/ +Copyright (C) 2011-2018 RedmineUP +https://www.redmineup.com/ -== 2016-01-18 v0.0.7 +== 2018-08-31 v1.0.0 +* Separate models for questions, answers and comments +* Voting for questions and answers +* Comments for questions and asnwers +* Section types: Question, Idea, Solution +* Different main page styles +* Answered question status +* Idea statutes * Chinese translation (zhoutt) -* Redmine 3+ support == 2014-02-04 v0.0.6 diff --git a/plugins/redmine_questions/doc/COPYING b/plugins/redmine_questions/doc/COPYING index 82fa1da..63e41a4 100644 --- a/plugins/redmine_questions/doc/COPYING +++ b/plugins/redmine_questions/doc/COPYING @@ -336,4 +336,4 @@ This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +Public License instead of this License. \ No newline at end of file diff --git a/plugins/redmine_questions/doc/LICENSE b/plugins/redmine_questions/doc/LICENSE index 9457f59..e2e50b5 100644 --- a/plugins/redmine_questions/doc/LICENSE +++ b/plugins/redmine_questions/doc/LICENSE @@ -1,26 +1,26 @@ LICENSING -RedmineCRM Licencing +RedmineUP Licencing -This End User License Agreement is a binding legal agreement between you and RedmineCRM. Purchase, installation or use of RedmineCRM Extensions provided on redminecrm.com signifies that you have read, understood, and agreed to be bound by the terms outlined below. +This End User License Agreement is a binding legal agreement between you and RedmineUP. Purchase, installation or use of RedmineUP Extensions provided on redmineup.com signifies that you have read, understood, and agreed to be bound by the terms outlined below. -RedmineCRM GPL Licencing +RedmineUP GPL Licencing -All Redmine Extensions produced by RedmineCRM are released under the GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html). Specifically, the Ruby code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript are NOT GPL, and are released under the RedmineCRM Proprietary Use License v1.0 (See below) unless specifically authorized by RedmineCRM. Elements of the extensions released under this proprietary license may not be redistributed or repackaged for use other than those allowed by the Terms of Service. +All Redmine Extensions produced by RedmineUP are released under the GNU General Public License, version 2 (http://www.gnu.org/licenses/gpl-2.0.html). Specifically, the Ruby code portions are distributed under the GPL license. If not otherwise stated, all images, manuals, cascading style sheets, and included JavaScript are NOT GPL, and are released under the RedmineUP Proprietary Use License v1.0 (See below) unless specifically authorized by RedmineUP. Elements of the extensions released under this proprietary license may not be redistributed or repackaged for use other than those allowed by the Terms of Service. -RedmineCRM Proprietary Use License (v1.0) +RedmineUP Proprietary Use License (v1.0) -The RedmineCRM Proprietary Use License covers any images, cascading stylesheets, manuals and JavaScript files in any extensions produced and/or distributed by redminecrm.com. These files are copyrighted by redminecrm.com (RedmineCRM) and cannot be redistributed in any form without prior consent from redminecrm.com (RedmineCRM) +The RedmineUP Proprietary Use License covers any images, cascading stylesheets, manuals and JavaScript files in any extensions produced and/or distributed by redmineup.com. These files are copyrighted by redmineup.com (RedmineUP) and cannot be redistributed in any form without prior consent from redmineup.com (RedmineUP) Usage Terms You are allowed to use the Extensions on one or many "production" domains, depending on the type of your license You are allowed to make any changes to the code, however modified code will not be supported by us. -Modification Of Extensions Produced By RedmineCRM. +Modification Of Extensions Produced By RedmineUP. -You are authorized to make any modification(s) to RedmineCRM extension Ruby code. However, if you change any Ruby code and it breaks functionality, support may not be available to you. +You are authorized to make any modification(s) to RedmineUP extension Ruby code. However, if you change any Ruby code and it breaks functionality, support may not be available to you. -In accordance with the RedmineCRM Proprietary Use License v1.0, you may not release any proprietary files (modified or otherwise) under the GPL license. The terms of this license and the GPL v2 prohibit the removal of the copyright information from any file. +In accordance with the RedmineUP Proprietary Use License v1.0, you may not release any proprietary files (modified or otherwise) under the GPL license. The terms of this license and the GPL v2 prohibit the removal of the copyright information from any file. Please contact us if you have any requirements that are not covered by these terms. \ No newline at end of file diff --git a/plugins/redmine_questions/init.rb b/plugins/redmine_questions/init.rb index f3e086d..0e373b3 100644 --- a/plugins/redmine_questions/init.rb +++ b/plugins/redmine_questions/init.rb @@ -1,38 +1,68 @@ -requires_redmine_crm(:version_or_higher => '0.0.17') +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +requires_redmine_crm version_or_higher: '0.0.38' + require 'redmine_questions' +QA_VERSION_NUMBER = '1.0.0' +QA_VERSION_TYPE = "Light version" Redmine::Plugin.register :redmine_questions do - name 'Redmine Q&A plugin' - author 'RedmineCRM' + name "Redmine Q&A plugin (#{QA_VERSION_TYPE})" + author 'RedmineUP' description 'This is a Q&A plugin for Redmine' - version '0.0.7' - url 'http://www.redminecrm.com/projects/questions' - author_url 'mailto:support@redminecrm.com' + version QA_VERSION_NUMBER + url 'https://www.redmineup.com/pages/plugins/questions' + author_url 'mailto:support@redmineup.com' - requires_redmine :version_or_higher => '2.1.2' - - settings :default => { - :sidebar_message => '*Can\'t find the answer you\'re looking for?* Email us at ...' - }, :partial => 'settings/questions' - - permission :view_questions, { - :questions => [:index, :autocomplete_for_topic, :topics] - } + requires_redmine :version_or_higher => '2.6' delete_menu_item(:top_menu, :help) - menu :top_menu, :questions, {:controller => 'questions', :action => 'index'}, - :last => true, - :caption => :label_questions, - :if => Proc.new {User.current.allowed_to?({:controller => 'questions', :action => 'index'}, nil, {:global => true})} + menu :top_menu, :questions, {controller: 'questions_sections', action: 'index', project_id: nil}, + caption: :label_questions, + if: Proc.new {User.current.allowed_to?({controller: 'questions_sections', action: 'index'}, nil, {global: true})} - Redmine::AccessControl.map do |map| - map.project_module :boards do |map| - map.permission :view_questions, {:questions => [:autocomplete_for_topic, :topics]} - map.permission :vote_messages, {:questions => [:vote]} - map.permission :convert_issues, {:questions => [:convert_issue]} - map.permission :edit_messages_tags, {} - end + menu :project_menu, :questions, {controller: 'questions_sections', action: 'index'}, + param: :project_id + + project_module :questions do + permission :add_questions, { questions: [:create, :new, :preview, :update_form] } + permission :edit_questions, { questions: [:edit, :update, :preview, :update_form], questions_answers: [:edit, :update, :preview] }, require: :loggedin + permission :edit_own_questions, {questions: [:edit, :update, :preview, :update_form]}, require: :loggedin + permission :add_answers, { questions_answers: [:create, :show, :new, :edit, :update, :preview] } + permission :view_questions, { questions: [:index, :show, :autocomplete_for_subject], questions_sections: [:index] }, read: true + permission :delete_questions, { questions: [:destroy] }, require: :loggedin + permission :delete_answers, { questions_answers: [:destroy] }, require: :loggedin + permission :vote_questions, { questions_votes: [:create] } + permission :accept_answers, { questions_answers: [:update] }, require: :loggedin + permission :comment_question, { questions_comments: [:create] } + permission :edit_question_comments, { questions_comments: [:update, :destroy, :edit] }, require: :loggedin + permission :edit_own_question_comments, { questions_comments: [:update, :destroy, :edit] }, require: :loggedin + permission :manage_sections, { projects: :settings, questions_sections: [:create, :new, :edit, :update] }, require: :loggedin + permission :create_tags, {} end + + activity_provider :questions, default: false, class_name: ['Question', 'QuestionsAnswer'] + + Redmine::Search.map do |search| + search.register :questions + end end diff --git a/plugins/redmine_questions/lib/acts_as_attachable_questions/init.rb b/plugins/redmine_questions/lib/acts_as_attachable_questions/init.rb new file mode 100755 index 0000000..92731f3 --- /dev/null +++ b/plugins/redmine_questions/lib/acts_as_attachable_questions/init.rb @@ -0,0 +1,28 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +# $LOAD_PATH.unshift(File.dirname(__FILE__)) +# require "lib/acts_as_viewable" +# $LOAD_PATH.shift + +require File.dirname(__FILE__) + '/lib/acts_as_attachable_questions' + +unless ActiveRecord::Base.included_modules.include?(Redmine::Acts::AttachableQuestions) + ActiveRecord::Base.send(:include, Redmine::Acts::AttachableQuestions) +end diff --git a/plugins/redmine_questions/lib/acts_as_attachable_questions/lib/acts_as_attachable_questions.rb b/plugins/redmine_questions/lib/acts_as_attachable_questions/lib/acts_as_attachable_questions.rb new file mode 100755 index 0000000..61edb90 --- /dev/null +++ b/plugins/redmine_questions/lib/acts_as_attachable_questions/lib/acts_as_attachable_questions.rb @@ -0,0 +1,108 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module Redmine + module Acts + module AttachableQuestions + def self.included(base) + base.extend ClassMethods + end + + module ClassMethods + def acts_as_attachable_questions(options = {}) + if ActiveRecord::VERSION::MAJOR >= 4 + has_many :attachments, lambda { order("#{Attachment.table_name}.created_on") }, options.merge(:as => :container, + :dependent => :destroy) + else + has_many :attachments, options.merge(:as => :container, + :order => "#{Attachment.table_name}.created_on", + :dependent => :destroy) + end + + send :include, Redmine::Acts::AttachableQuestions::InstanceMethods + before_save :attach_saved_attachments + end + end + + module InstanceMethods + def self.included(base) + base.extend ClassMethods + end + + def attachments_visible?(user = User.current) + respond_to?(:visible?) ? visible?(user) : true + end + + def attachments_editable?(user = User.current) + (respond_to?(:visible?) ? visible?(user) : true) && + (user.allowed_to?(:manage_sections, project, :global => true) || + user.allowed_to?(:add_questions, project, :global => true)) + end + + def attachments_deletable?(user = User.current) + (respond_to?(:visible?) ? visible?(user) : true) && + (user.allowed_to?(:delete_questions, project, :global => true) || + user.allowed_to?(:add_questions, project, :global => true)) + end + + def saved_attachments + @saved_attachments ||= [] + end + + def unsaved_attachments + @unsaved_attachments ||= [] + end + + def save_attachments(attachments, author = User.current) + attachments = attachments.values if attachments.is_a?(Hash) + if attachments.is_a?(Array) + attachments.each do |attachment| + a = nil + if file = attachment['file'] + next unless file.size > 0 + a = Attachment.create(:file => file, :author => author) + elsif token = attachment['token'] + a = Attachment.find_by_token(token) + next unless a + a.filename = attachment['filename'] unless attachment['filename'].blank? + a.content_type = attachment['content_type'] + end + next unless a + a.description = attachment['description'].to_s.strip + if a.new_record? + unsaved_attachments << a + else + saved_attachments << a + end + end + end + { :files => saved_attachments, :unsaved => unsaved_attachments } + end + + def attach_saved_attachments + saved_attachments.each do |attachment| + attachments << attachment + end + end + module ClassMethods + end + end + end + end +end diff --git a/plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb b/plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb deleted file mode 100644 index a6db3c5..0000000 --- a/plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb +++ /dev/null @@ -1,16 +0,0 @@ -module RedmineQuestions - module Patches - module ActsAsVotableVotePatch - def self.included(base) # :nodoc: - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - attr_accessible :votable, :voter, :vote_scope - end - end - end - end -end - -unless RedmineCrm::ActsAsVotable::Vote.included_modules.include?(RedmineQuestions::Patches::ActsAsVotableVotePatch) - RedmineCrm::ActsAsVotable::Vote.send(:include, RedmineQuestions::Patches::ActsAsVotableVotePatch) -end \ No newline at end of file diff --git a/plugins/redmine_questions/lib/redmine_questions.rb b/plugins/redmine_questions/lib/redmine_questions.rb index e58ca81..f74816b 100644 --- a/plugins/redmine_questions/lib/redmine_questions.rb +++ b/plugins/redmine_questions/lib/redmine_questions.rb @@ -1,7 +1,32 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + require_dependency 'redmine_questions/hooks/views_layouts_hook' -# require_dependency 'redmine_questions/patches/boards_controller_patch' -require_dependency 'redmine_questions/patches/message_patch' require_dependency 'redmine_questions/patches/user_patch' -require_dependency 'redmine_questions/patches/messages_controller_patch' -require_dependency 'acts_as_votable_vote_patch' if ActiveRecord::VERSION::MAJOR >= 4 +require_dependency 'redmine_questions/patches/project_patch' +require_dependency 'redmine_questions/patches/notifiable_patch' +require_dependency 'redmine_questions/patches/mailer_patch' +require_dependency 'redmine_questions/patches/projects_helper_patch' +require_dependency 'redmine_questions/patches/auto_completes_controller_patch' +require_dependency 'redmine_questions/patches/comment_patch' + +require_dependency 'acts_as_attachable_questions/init' + +require 'redmine_questions/patches/compatibility/application_controller_patch' if Rails::VERSION::MAJOR < 4 diff --git a/plugins/redmine_questions/lib/redmine_questions/hooks/views_layouts_hook.rb b/plugins/redmine_questions/lib/redmine_questions/hooks/views_layouts_hook.rb index 94e1933..2405ae1 100644 --- a/plugins/redmine_questions/lib/redmine_questions/hooks/views_layouts_hook.rb +++ b/plugins/redmine_questions/lib/redmine_questions/hooks/views_layouts_hook.rb @@ -1,9 +1,28 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + module RedmineQuestions module Hooks class ViewsLayoutsHook < Redmine::Hook::ViewListener def view_layouts_base_html_head(context={}) - return stylesheet_link_tag(:questions, :plugin => 'redmine_questions') + return stylesheet_link_tag(:redmine_questions, :plugin => 'redmine_questions') end end end -end \ No newline at end of file +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/auto_completes_controller_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/auto_completes_controller_patch.rb new file mode 100644 index 0000000..7449d84 --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/auto_completes_controller_patch.rb @@ -0,0 +1,48 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +require_dependency 'auto_completes_controller' + +module RedmineQuestions + module Patches + module AutoCompletesControllerPatch + def self.included(base) + base.send(:include, InstanceMethods) + + base.class_eval do + end + end + + module InstanceMethods + def questions_tags + @names_only = params[:names] + @questions_tags = [] + q = (params[:q] || params[:term]).to_s.strip + scope = Question.tags_cloud(:name_like => q, :limit => params[:limit] || 10) + @questions_tags = scope.to_a.sort! { |x, y| x.name <=> y.name } + render :layout => false, :partial => 'questions_tags' + end + end + end + end +end + +unless AutoCompletesController.included_modules.include?(RedmineQuestions::Patches::AutoCompletesControllerPatch) + AutoCompletesController.send(:include, RedmineQuestions::Patches::AutoCompletesControllerPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/boards_controller_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/boards_controller_patch.rb deleted file mode 100644 index a64da13..0000000 --- a/plugins/redmine_questions/lib/redmine_questions/patches/boards_controller_patch.rb +++ /dev/null @@ -1,21 +0,0 @@ -require_dependency 'boards_controller' -require_dependency 'board' - -module RedmineQuestions - module Patches - - module BoardsControllerPatch - def self.included(base) # :nodoc: - base.class_eval do - helper :questions - end - end - - end - - end -end - -unless MessagesController.included_modules.include?(RedmineQuestions::Patches::BoardsControllerPatch) - MessagesController.send(:include, RedmineQuestions::Patches::BoardsControllerPatch) -end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/comment_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/comment_patch.rb new file mode 100644 index 0000000..94146b7 --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/comment_patch.rb @@ -0,0 +1,51 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module RedmineQuestions + module Patches + module CommentPatch + def self.included(base) # :nodoc: + base.send(:include, InstanceMethods) + base.class_eval do + unloadable + if method_defined?(:send_notification) + alias_method :send_notification_without_questions, :send_notification + alias_method :send_notification, :send_notification_with_questions + end + end + end + + module InstanceMethods + def send_notification_with_questions + if [Question, QuestionsAnswer].include?(commented.class) + if Setting.notified_events.include?('question_comment_added') + Mailer.send('question_comment_added', self).deliver + end + else + send_notification_without_questions + end + end + end + end + end +end + +unless Comment.included_modules.include?(RedmineQuestions::Patches::CommentPatch) + Comment.send(:include, RedmineQuestions::Patches::CommentPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/compatibility/application_controller_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/compatibility/application_controller_patch.rb new file mode 100644 index 0000000..723eb8c --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/compatibility/application_controller_patch.rb @@ -0,0 +1,37 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module RedmineQuestions + module Patches + module ApplicationControllerPatch + def self.included(base) # :nodoc: + base.class_eval do + unloadable # Send unloadable so it will not be unloaded in development + class << self + alias_method :before_action, :before_filter + end + end + end + end + end +end + +unless ApplicationController.included_modules.include?(RedmineQuestions::Patches::ApplicationControllerPatch) + ApplicationController.send(:include, RedmineQuestions::Patches::ApplicationControllerPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/mailer_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/mailer_patch.rb new file mode 100644 index 0000000..b0022af --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/mailer_patch.rb @@ -0,0 +1,87 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module RedmineQuestions + module Patches + module MailerPatch + module InstanceMethods + def question_comment_added(comment) + question = comment.commented.is_a?(Question) ? comment.commented : comment.commented.question + @question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id) + project_identifier = question.project.try(:identifier) + redmine_headers 'Project' => project_identifier, 'Question-Id' => question.id + message_id comment + @author = comment.author + @comment = comment + @question = question + project_prefix = [project_identifier, question.section_name, "q&a#{question.id}"].compact.join(' - ') + recipients = question.watcher_recipients + mail :to => recipients, + :subject => "[#{project_prefix}] RE: #{question.subject}" + end + + def question_question_added(question) + @question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id) + project_identifier = question.project.try(:identifier) + redmine_headers 'Project' => project_identifier, 'Question-Id' => question.id + message_id question + @author = question.author + @question = question + recipients = question.notified_users + cc = question.section.notified_watchers - recipients + project_prefix = [project_identifier, question.section_name, "q&a#{question.id}"].compact.join(' - ') + mail :to => recipients, + :cc => cc, + :subject => "[#{project_prefix}] #{question.subject}" + end + + def question_answer_added(answer) + question = answer.question + @question_url = url_for(:controller => 'questions', :action => 'show', :id => question.id) + project_identifier = question.project.try(:identifier) + redmine_headers 'Project' => project_identifier, 'Question-Id' => question.id + message_id question + recipients = question.notified_users + watchers = (question.notified_watchers + question.section.notified_watchers).uniq + watchers = watchers.map(&:mail) if watchers.first.respond_to?(:mail) + cc = watchers - recipients + + @author = answer.author + @answer = answer + @question = question + project_prefix = [project_identifier, question.section_name, "q&a#{question.id}"].compact.join(' - ') + mail :to => recipients, + :cc => cc, + :subject => "[#{project_prefix}] - answ##{answer.id} - RE: #{question.subject}" + end + end + + def self.included(receiver) + receiver.send :include, InstanceMethods + receiver.class_eval do + unloadable + end + end + end + end +end + +unless Mailer.included_modules.include?(RedmineQuestions::Patches::MailerPatch) + Mailer.send(:include, RedmineQuestions::Patches::MailerPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/message_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/message_patch.rb deleted file mode 100644 index fbe9b45..0000000 --- a/plugins/redmine_questions/lib/redmine_questions/patches/message_patch.rb +++ /dev/null @@ -1,44 +0,0 @@ -module RedmineQuestions - module Patches - module MessagePatch - def self.included(base) # :nodoc: - base.send(:include, InstanceMethods) - - base.class_eval do - unloadable # Send unloadable so it will not be unloaded in development - rcrm_acts_as_taggable - rcrm_acts_as_votable - rcrm_acts_as_viewed - - safe_attributes 'tag_list', - :if => lambda {|message, user| - user.allowed_to?(:edit_messages_tags, message.project) - } - end - - end - - module InstanceMethods - - def to_param - "#{id}-#{ActiveSupport::Inflector.transliterate(subject).parameterize}" - end - - def like(user) - liked_by(user) - end - - def dislike(user) - unvote(:voter => user) - end - - end - - end - end -end - -unless Message.included_modules.include?(RedmineQuestions::Patches::MessagePatch) - Message.send(:include, RedmineQuestions::Patches::MessagePatch) -end - diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/messages_controller_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/messages_controller_patch.rb deleted file mode 100644 index f4707d4..0000000 --- a/plugins/redmine_questions/lib/redmine_questions/patches/messages_controller_patch.rb +++ /dev/null @@ -1,29 +0,0 @@ -module RedmineQuestions - module Patches - - module MessagesControllerPatch - - module InstanceMethods - - def view_message - @message.view(request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip || request.remote_addr, User.current.logged? ? User.current : nil) unless @message.author == User.current - end - - end - - def self.included(base) # :nodoc: - base.send(:include, InstanceMethods) - - base.class_eval do - after_filter :view_message, :only => :show - end - end - - end - - end -end - -unless MessagesController.included_modules.include?(RedmineQuestions::Patches::MessagesControllerPatch) - MessagesController.send(:include, RedmineQuestions::Patches::MessagesControllerPatch) -end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/notifiable_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/notifiable_patch.rb new file mode 100644 index 0000000..578d435 --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/notifiable_patch.rb @@ -0,0 +1,49 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module RedmineQuestions + module Patches + module NotifiablePatch + def self.included(base) + base.extend(ClassMethods) + base.class_eval do + unloadable + class << self + alias_method :all_without_questions, :all + alias_method :all, :all_with_questions + end + end + end + + module ClassMethods + def all_with_questions + notifications = all_without_questions + notifications << Redmine::Notifiable.new('question_added') + notifications << Redmine::Notifiable.new('question_answer_added') + notifications << Redmine::Notifiable.new('question_comment_added') + notifications + end + end + end + end +end + +unless Redmine::Notifiable.included_modules.include?(RedmineQuestions::Patches::NotifiablePatch) + Redmine::Notifiable.send(:include, RedmineQuestions::Patches::NotifiablePatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/project_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/project_patch.rb new file mode 100644 index 0000000..cb9ef94 --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/project_patch.rb @@ -0,0 +1,36 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +module RedmineQuestions + module Patches + module ProjectPatch + def self.included(base) # :nodoc: + base.class_eval do + unloadable # Send unloadable so it will not be unloaded in development + has_many :questions_sections, :dependent => :delete_all + has_many :questions, :through => :questions_sections + end + end + end + end +end + +unless Project.included_modules.include?(RedmineQuestions::Patches::ProjectPatch) + Project.send(:include, RedmineQuestions::Patches::ProjectPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/projects_helper_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/projects_helper_patch.rb new file mode 100644 index 0000000..96ba21a --- /dev/null +++ b/plugins/redmine_questions/lib/redmine_questions/patches/projects_helper_patch.rb @@ -0,0 +1,56 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + +require_dependency 'queries_helper' + +module RedmineQuestions + module Patches + module ProjectsHelperPatch + def self.included(base) + base.send(:include, InstanceMethods) + + base.class_eval do + unloadable + alias_method :project_settings_tabs_without_questions, :project_settings_tabs + alias_method :project_settings_tabs, :project_settings_tabs_with_questions + end + end + + module InstanceMethods + # include ContactsHelper + + def project_settings_tabs_with_questions + tabs = project_settings_tabs_without_questions + + tabs.push({ :name => 'questions', + :action => :manage_sections, + :partial => 'projects/questions_settings', + :label => :label_questions }) if User.current.allowed_to?(:manage_sections, @project) + tabs + + end + end + + end + end +end + +unless ProjectsHelper.included_modules.include?(RedmineQuestions::Patches::ProjectsHelperPatch) + ProjectsHelper.send(:include, RedmineQuestions::Patches::ProjectsHelperPatch) +end diff --git a/plugins/redmine_questions/lib/redmine_questions/patches/user_patch.rb b/plugins/redmine_questions/lib/redmine_questions/patches/user_patch.rb index 8cf223e..e2467ad 100644 --- a/plugins/redmine_questions/lib/redmine_questions/patches/user_patch.rb +++ b/plugins/redmine_questions/lib/redmine_questions/patches/user_patch.rb @@ -1,3 +1,22 @@ +# This file is a part of Redmine Q&A (redmine_questions) plugin, +# Q&A plugin for Redmine +# +# Copyright (C) 2011-2018 RedmineUP +# http://www.redmineup.com/ +# +# redmine_questions is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# redmine_questions is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with redmine_questions. If not, see . + module RedmineQuestions module Patches module UserPatch diff --git a/plugins/redmine_questions/lib/tasks/migrate_from_boards.rake b/plugins/redmine_questions/lib/tasks/migrate_from_boards.rake new file mode 100644 index 0000000..c13175b --- /dev/null +++ b/plugins/redmine_questions/lib/tasks/migrate_from_boards.rake @@ -0,0 +1,59 @@ +namespace :redmine do + namespace :questions do + desc <<-END_DESC +Migrate forum board to questions section + + rake redmine:questions:migrate_board_to_section RAILS_ENV="production" board_id="source forum board id" question_section_id="destination question section id" project_id="section project id (nil for global section)" + +END_DESC + + task :migrate_board_to_section => :environment do + board_id = ENV['board_id'] + question_section_id = ENV['question_section_id'] + question_section_name = ENV['question_section_name'] + project_id = ENV['project_id'] + + if board_id.blank? && project_id.blank? + puts 'RedmineQuestions: Params board_id or project_id should be present' + exit + end + + project = Project.where(:identifier => project_id).first + project.enable_module!(:questions) if project + boards = [Board.where(:id => board_id).first].compact + boards = project.boards if project && boards.blank? + boards.each do |board| + section = QuestionsSection.for_project(project).where(:id => question_section_id).first + section ||= QuestionsSection.for_project(project).find_or_create_by(:name => question_section_name) if question_section_name + section ||= QuestionsSection.for_project(project).find_or_create_by(:name => board.name) + if section.nil? || board.nil? + puts 'RedmineQuestions: Destination section does not found' unless section + puts 'RedmineQuestions: Source board does not found' unless board + exit + end + + board.topics.reverse.each do |topic| + if section.questions.where(:subject => topic.subject).first.present? + puts "Questions with subject #{topic.subject} already exists." + next + end + + question_attrs = topic.attributes.slice('subject', 'content', 'author_id', 'locked').merge('project_id' => project.try(:id)) + migrated_question = section.questions.create(question_attrs) + migrated_question.attachments = topic.attachments.map { |attachment| attachment.copy } + + topic.children.each do |reply| + if section.section_type == 'questions' + answer_attrs = reply.slice('subject', 'content', 'author_id', 'locked').merge('project_id' => project.try(:id)) + migrated_answer = migrated_question.answers.create(answer_attrs) + migrated_answer.attachments = reply.attachments.map { |attachment| attachment.copy } + else + comment_attrs = { 'author_id' => reply.author_id, 'comments' => reply.content } + migrated_question.comments.create(comment_attrs) + end + end + end + end #each + end + end +end diff --git a/plugins/redmine_questions/test/fixtures/comments-3.4.6.yml b/plugins/redmine_questions/test/fixtures/comments-3.4.6.yml new file mode 100644 index 0000000..8046621 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/comments-3.4.6.yml @@ -0,0 +1,17 @@ +_fixture: + model_class: Comment +comment_001: + content: text for cooment 001 + commented_type: Question + commented_id: 1 + author_id: 1 +comment_002: + content: text for cooment 002 + commented_type: Question + commented_id: 2 + author_id: 1 +comment_003: + content: text for cooment 003 (comment for answer!) + commented_type: Question + commented_id: 5 + author_id: 1 diff --git a/plugins/redmine_questions/test/fixtures/comments.yml b/plugins/redmine_questions/test/fixtures/comments.yml new file mode 100644 index 0000000..094815d --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/comments.yml @@ -0,0 +1,16 @@ +comment_001: + comments: text for cooment 001 + commented_type: Question + commented_id: 1 + author_id: 1 +comment_002: + comments: text for cooment 002 + commented_type: Question + commented_id: 2 + author_id: 1 +comment_003: + comments: text for cooment 003 (comment for answer!) + commented_type: Question + commented_id: 5 + author_id: 1 + diff --git a/plugins/redmine_questions/test/fixtures/questions.yml b/plugins/redmine_questions/test/fixtures/questions.yml new file mode 100644 index 0000000..5d81934 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/questions.yml @@ -0,0 +1,26 @@ +question_001: + id: 1 + subject: Hard question + content: Text for hard question + author_id: 1 + section_id: 1 +question_002: + id: 2 + subject: Another hard question + content: Text for Another hard question + author_id: 2 + section_id: 1 + featured: true +question_003: + id: 3 + subject: Simple question + content: Text for simple question + author_id: 1 + section_id: 2 +question_004: + id: 4 + subject: Another hard question + content: Text for simple hard question + author_id: 2 + section_id: 2 + locked: true \ No newline at end of file diff --git a/plugins/redmine_questions/test/fixtures/questions_answers.yml b/plugins/redmine_questions/test/fixtures/questions_answers.yml new file mode 100644 index 0000000..1b9ff76 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/questions_answers.yml @@ -0,0 +1,12 @@ +answer_001: + id: 1 + content: This is answer for question_001 + question_id: 1 + author_id: 2 + accepted: true +answer_002: + id: 2 + content: This is answer for question_002 + question_id: 2 + author_id: 1 + accepted: false \ No newline at end of file diff --git a/plugins/redmine_questions/test/fixtures/questions_sections.yml b/plugins/redmine_questions/test/fixtures/questions_sections.yml new file mode 100644 index 0000000..8028ea1 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/questions_sections.yml @@ -0,0 +1,25 @@ +section_001: + id: 1 + name: FAQ + section_type: questions + project_id: 1 +section_002: + id: 2 + name: Ideas + section_type: ideas + project_id: 2 +section_003: + id: 3 + name: Global FAQ + section_type: questions + project_id: 1 +section_004: + id: 4 + name: Off topic + section_type: questions + project_id: 1 +section_005: + id: 5 + name: Ideas in project 1 + section_type: ideas + project_id: 1 diff --git a/plugins/redmine_questions/test/fixtures/taggings.yml b/plugins/redmine_questions/test/fixtures/taggings.yml new file mode 100644 index 0000000..f3cffd7 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/taggings.yml @@ -0,0 +1,19 @@ +tagging_001: + tag_id: 1 + taggable_id: 1 + taggable_type: Question + +tagging_002: + tag_id: 1 + taggable_id: 2 + taggable_type: Question + +tagging_003: + tag_id: 2 + taggable_id: 3 + taggable_type: Question + +tagging_004: + tag_id: 2 + taggable_id: 4 + taggable_type: Question diff --git a/plugins/redmine_questions/test/fixtures/tags.yml b/plugins/redmine_questions/test/fixtures/tags.yml new file mode 100644 index 0000000..c92d758 --- /dev/null +++ b/plugins/redmine_questions/test/fixtures/tags.yml @@ -0,0 +1,6 @@ +tag_hard: + id: 1 + name: hard +tag_simple: + id: 2 + name: simple \ No newline at end of file diff --git a/plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/images/vcard.png b/plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/images/vcard.png new file mode 100644 index 0000000000000000000000000000000000000000..c02f315d20749098a50e79bd9525eed3cda7be6b GIT binary patch literal 533 zcmV+w0_y#VP)~%#^24dF_nR2<@_W67)1?cUEu^twUb)isDIFhhds}=iK3R>bPJ|0e?$zQO{gfSb6 zAmw}l&+|y1)FDbOh~LB|8AsbZWx#U1r$+A&&@Nx#xl}^&O@y|4t-qIL8GGyFgudOB zMUBefj6^S-TgKXw9~(9fXO}l9u&h~_&1U!^@!0B?~s|2G5wL<6_)Q&2rqn4Ysi zYDkz=-^k9mUKoqT&@0!tb`xM{bJg4sMG?(rlN1C@+IG7gZnyh)fD-9^wOWPO>qRga zgu~$&m^wiaP%IV^2m}y`M05a#41+*G!W1YTk2ASkP8&9ThNn^~CX>l%T{(BmzyFOt XHe4|Dt4X literal 0 HcmV?d00001 diff --git a/plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/Chart.bundle.min.js b/plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/Chart.bundle.min.js new file mode 100644 index 0000000..a7c0cf9 --- /dev/null +++ b/plugins/redmine_questions/test/functional/public/plugin_assets/redmine_crm/javascripts/Chart.bundle.min.js @@ -0,0 +1,16 @@ +/*! + * Chart.js + * http://chartjs.org/ + * Version: 2.6.0 + * + * Copyright 2017 Nick Downie + * Released under the MIT license + * https://github.com/chartjs/Chart.js/blob/master/LICENSE.md + */ +!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Chart=t()}}(function(){var t;return function t(e,n,i){function a(o,s){if(!n[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(r)return r(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var d=n[o]={exports:{}};e[o][0].call(d.exports,function(t){var n=e[o][1][t];return a(n?n:t)},d,d.exports,t,e,n,i)}return n[o].exports}for(var r="function"==typeof require&&require,o=0;on?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},dark:function(){var t=this.values.rgb,e=(299*t[0]+587*t[1]+114*t[2])/1e3;return e<128},light:function(){return!this.dark()},negate:function(){for(var t=[],e=0;e<3;e++)t[e]=255-this.values.rgb[e];return this.setValues("rgb",t),this},lighten:function(t){var e=this.values.hsl;return e[2]+=e[2]*t,this.setValues("hsl",e),this},darken:function(t){var e=this.values.hsl;return e[2]-=e[2]*t,this.setValues("hsl",e),this},saturate:function(t){var e=this.values.hsl;return e[1]+=e[1]*t,this.setValues("hsl",e),this},desaturate:function(t){var e=this.values.hsl;return e[1]-=e[1]*t,this.setValues("hsl",e),this},whiten:function(t){var e=this.values.hwb;return e[1]+=e[1]*t,this.setValues("hwb",e),this},blacken:function(t){var e=this.values.hwb;return e[2]+=e[2]*t,this.setValues("hwb",e),this},greyscale:function(){var t=this.values.rgb,e=.3*t[0]+.59*t[1]+.11*t[2];return this.setValues("rgb",[e,e,e]),this},clearer:function(t){var e=this.values.alpha;return this.setValues("alpha",e-e*t),this},opaquer:function(t){var e=this.values.alpha;return this.setValues("alpha",e+e*t),this},rotate:function(t){var e=this.values.hsl,n=(e[0]+t)%360;return e[0]=n<0?360+n:n,this.setValues("hsl",e),this},mix:function(t,e){var n=this,i=t,a=void 0===e?.5:e,r=2*a-1,o=n.alpha()-i.alpha(),s=((r*o===-1?r:(r+o)/(1+r*o))+1)/2,l=1-s;return this.rgb(s*n.red()+l*i.red(),s*n.green()+l*i.green(),s*n.blue()+l*i.blue()).alpha(n.alpha()*a+i.alpha()*(1-a))},toJSON:function(){return this.rgb()},clone:function(){var t,e,n=new r,i=this.values,a=n.values;for(var o in i)i.hasOwnProperty(o)&&(t=i[o],e={}.toString.call(t),"[object Array]"===e?a[o]=t.slice(0):"[object Number]"===e?a[o]=t:console.error("unexpected color value:",t));return n}},r.prototype.spaces={rgb:["red","green","blue"],hsl:["hue","saturation","lightness"],hsv:["hue","saturation","value"],hwb:["hue","whiteness","blackness"],cmyk:["cyan","magenta","yellow","black"]},r.prototype.maxes={rgb:[255,255,255],hsl:[360,100,100],hsv:[360,100,100],hwb:[360,100,100],cmyk:[100,100,100,100]},r.prototype.getValues=function(t){for(var e=this.values,n={},i=0;i.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92,i=i>.04045?Math.pow((i+.055)/1.055,2.4):i/12.92;var a=.4124*e+.3576*n+.1805*i,r=.2126*e+.7152*n+.0722*i,o=.0193*e+.1192*n+.9505*i;return[100*a,100*r,100*o]}function d(t){var e,n,i,a=u(t),r=a[0],o=a[1],s=a[2];return r/=95.047,o/=100,s/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,s=s>.008856?Math.pow(s,1/3):7.787*s+16/116,e=116*o-16,n=500*(r-o),i=200*(o-s),[e,n,i]}function c(t){return Y(d(t))}function h(t){var e,n,i,a,r,o=t[0]/360,s=t[1]/100,l=t[2]/100;if(0==s)return r=255*l,[r,r,r];n=l<.5?l*(1+s):l+s-l*s,e=2*l-n,a=[0,0,0];for(var u=0;u<3;u++)i=o+1/3*-(u-1),i<0&&i++,i>1&&i--,r=6*i<1?e+6*(n-e)*i:2*i<1?n:3*i<2?e+(n-e)*(2/3-i)*6:e,a[u]=255*r;return a}function f(t){var e,n,i=t[0],a=t[1]/100,r=t[2]/100;return 0===r?[0,0,0]:(r*=2,a*=r<=1?r:2-r,n=(r+a)/2,e=2*a/(r+a),[i,100*e,100*n])}function p(t){return o(h(t))}function m(t){return s(h(t))}function v(t){return l(h(t))}function y(t){var e=t[0]/60,n=t[1]/100,i=t[2]/100,a=Math.floor(e)%6,r=e-Math.floor(e),o=255*i*(1-n),s=255*i*(1-n*r),l=255*i*(1-n*(1-r)),i=255*i;switch(a){case 0:return[i,l,o];case 1:return[s,i,o];case 2:return[o,i,l];case 3:return[o,s,i];case 4:return[l,o,i];case 5:return[i,o,s]}}function x(t){var e,n,i=t[0],a=t[1]/100,r=t[2]/100;return n=(2-a)*r,e=a*r,e/=n<=1?n:2-n,e=e||0,n/=2,[i,100*e,100*n]}function _(t){return o(y(t))}function k(t){return s(y(t))}function w(t){return l(y(t))}function M(t){var e,n,i,a,o=t[0]/360,s=t[1]/100,l=t[2]/100,u=s+l;switch(u>1&&(s/=u,l/=u),e=Math.floor(6*o),n=1-l,i=6*o-e,0!=(1&e)&&(i=1-i),a=s+i*(n-s),e){default:case 6:case 0:r=n,g=a,b=s;break;case 1:r=a,g=n,b=s;break;case 2:r=s,g=n,b=a;break;case 3:r=s,g=a,b=n;break;case 4:r=a,g=s,b=n;break;case 5:r=n,g=s,b=a}return[255*r,255*g,255*b]}function S(t){return i(M(t))}function D(t){return a(M(t))}function C(t){return s(M(t))}function P(t){return l(M(t))}function T(t){var e,n,i,a=t[0]/100,r=t[1]/100,o=t[2]/100,s=t[3]/100;return e=1-Math.min(1,a*(1-s)+s),n=1-Math.min(1,r*(1-s)+s),i=1-Math.min(1,o*(1-s)+s),[255*e,255*n,255*i]}function I(t){return i(T(t))}function A(t){return a(T(t))}function F(t){return o(T(t))}function O(t){return l(T(t))}function R(t){var e,n,i,a=t[0]/100,r=t[1]/100,o=t[2]/100;return e=3.2406*a+r*-1.5372+o*-.4986,n=a*-.9689+1.8758*r+.0415*o,i=.0557*a+r*-.204+1.057*o,e=e>.0031308?1.055*Math.pow(e,1/2.4)-.055:e*=12.92,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:n*=12.92,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*=12.92,e=Math.min(Math.max(0,e),1),n=Math.min(Math.max(0,n),1),i=Math.min(Math.max(0,i),1),[255*e,255*n,255*i]}function L(t){var e,n,i,a=t[0],r=t[1],o=t[2];return a/=95.047,r/=100,o/=108.883,a=a>.008856?Math.pow(a,1/3):7.787*a+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,e=116*r-16,n=500*(a-r),i=200*(r-o),[e,n,i]}function V(t){return Y(L(t))}function W(t){var e,n,i,a,r=t[0],o=t[1],s=t[2];return r<=8?(n=100*r/903.3,a=7.787*(n/100)+16/116):(n=100*Math.pow((r+16)/116,3),a=Math.pow(n/100,1/3)),e=e/95.047<=.008856?e=95.047*(o/500+a-16/116)/7.787:95.047*Math.pow(o/500+a,3),i=i/108.883<=.008859?i=108.883*(a-s/200-16/116)/7.787:108.883*Math.pow(a-s/200,3),[e,n,i]}function Y(t){var e,n,i,a=t[0],r=t[1],o=t[2];return e=Math.atan2(o,r),n=360*e/2/Math.PI,n<0&&(n+=360),i=Math.sqrt(r*r+o*o),[a,i,n]}function z(t){return R(W(t))}function N(t){var e,n,i,a=t[0],r=t[1],o=t[2];return i=o/360*2*Math.PI,e=r*Math.cos(i),n=r*Math.sin(i),[a,e,n]}function B(t){return W(N(t))}function E(t){return z(N(t))}function H(t){return J[t]}function j(t){return i(H(t))}function U(t){return a(H(t))}function G(t){return o(H(t))}function q(t){return s(H(t))}function Z(t){return d(H(t))}function X(t){return u(H(t))}e.exports={rgb2hsl:i,rgb2hsv:a,rgb2hwb:o,rgb2cmyk:s,rgb2keyword:l,rgb2xyz:u,rgb2lab:d,rgb2lch:c,hsl2rgb:h,hsl2hsv:f,hsl2hwb:p,hsl2cmyk:m,hsl2keyword:v,hsv2rgb:y,hsv2hsl:x,hsv2hwb:_,hsv2cmyk:k,hsv2keyword:w,hwb2rgb:M,hwb2hsl:S,hwb2hsv:D,hwb2cmyk:C,hwb2keyword:P,cmyk2rgb:T,cmyk2hsl:I,cmyk2hsv:A,cmyk2hwb:F,cmyk2keyword:O,keyword2rgb:H,keyword2hsl:j,keyword2hsv:U,keyword2hwb:G,keyword2cmyk:q,keyword2lab:Z,keyword2xyz:X,xyz2rgb:R,xyz2lab:L,xyz2lch:V,lab2xyz:W,lab2rgb:z,lab2lch:Y,lch2lab:N,lch2xyz:B,lch2rgb:E};var J={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},K={};for(var Q in J)K[JSON.stringify(J[Q])]=Q},{}],4:[function(t,e,n){var i=t(3),a=function(){return new u};for(var r in i){a[r+"Raw"]=function(t){return function(e){return"number"==typeof e&&(e=Array.prototype.slice.call(arguments)),i[t](e)}}(r);var o=/(\w+)2(\w+)/.exec(r),s=o[1],l=o[2];a[s]=a[s]||{},a[s][l]=a[r]=function(t){return function(e){"number"==typeof e&&(e=Array.prototype.slice.call(arguments));var n=i[t](e);if("string"==typeof n||void 0===n)return n;for(var a=0;a0)for(n=0;n0?"future":"past"];return C(n)?n(e):n.replace(/%s/i,e)}function W(t,e){var n=t.toLowerCase();Vi[n]=Vi[n+"s"]=Vi[e]=t}function Y(t){return"string"==typeof t?Vi[t]||Vi[t.toLowerCase()]:void 0}function z(t){var e,n,i={};for(n in t)c(t,n)&&(e=Y(n),e&&(i[e]=t[n]));return i}function N(t,e){Wi[t]=e}function B(t){var e=[];for(var n in t)e.push({unit:n,priority:Wi[n]});return e.sort(function(t,e){return t.priority-e.priority}),e}function E(e,n){return function(i){return null!=i?(j(this,e,i),t.updateOffset(this,n),this):H(this,e)}}function H(t,e){return t.isValid()?t._d["get"+(t._isUTC?"UTC":"")+e]():NaN}function j(t,e,n){t.isValid()&&t._d["set"+(t._isUTC?"UTC":"")+e](n)}function U(t){return t=Y(t),C(this[t])?this[t]():this}function G(t,e){if("object"==typeof t){t=z(t);for(var n=B(t),i=0;i=0;return(r?n?"+":"":"-")+Math.pow(10,Math.max(0,a)).toString().substr(1)+i}function Z(t,e,n,i){var a=i;"string"==typeof i&&(a=function(){return this[i]()}),t&&(Bi[t]=a),e&&(Bi[e[0]]=function(){return q(a.apply(this,arguments),e[1],e[2])}),n&&(Bi[n]=function(){return this.localeData().ordinal(a.apply(this,arguments),t)})}function X(t){return t.match(/\[[\s\S]/)?t.replace(/^\[|\]$/g,""):t.replace(/\\/g,"")}function J(t){var e,n,i=t.match(Yi);for(e=0,n=i.length;e=0&&zi.test(t);)t=t.replace(zi,n),zi.lastIndex=0,i-=1;return t}function $(t,e,n){ra[t]=C(e)?e:function(t,i){return t&&n?n:e}}function tt(t,e){return c(ra,t)?ra[t](e._strict,e._locale):new RegExp(et(t))}function et(t){return nt(t.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(t,e,n,i,a){return e||n||i||a}))}function nt(t){return t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function it(t,e){var n,i=e;for("string"==typeof t&&(t=[t]),l(e)&&(i=function(t,n){n[e]=k(t)}),n=0;n=0&&isFinite(s.getFullYear())&&s.setFullYear(t),s}function _t(t){var e=new Date(Date.UTC.apply(null,arguments));return t<100&&t>=0&&isFinite(e.getUTCFullYear())&&e.setUTCFullYear(t),e}function kt(t,e,n){var i=7+e-n,a=(7+_t(t,0,i).getUTCDay()-e)%7;return-a+i-1}function wt(t,e,n,i,a){var r,o,s=(7+n-i)%7,l=kt(t,i,a),u=1+7*(e-1)+s+l;return u<=0?(r=t-1,o=vt(r)+u):u>vt(t)?(r=t+1,o=u-vt(t)):(r=t,o=u),{year:r,dayOfYear:o}}function Mt(t,e,n){var i,a,r=kt(t.year(),e,n),o=Math.floor((t.dayOfYear()-r-1)/7)+1;return o<1?(a=t.year()-1,i=o+St(a,e,n)):o>St(t.year(),e,n)?(i=o-St(t.year(),e,n),a=t.year()+1):(a=t.year(),i=o),{week:i,year:a}}function St(t,e,n){var i=kt(t,e,n),a=kt(t+1,e,n);return(vt(t)-i+a)/7}function Dt(t){return Mt(t,this._week.dow,this._week.doy).week}function Ct(){return this._week.dow}function Pt(){return this._week.doy}function Tt(t){var e=this.localeData().week(this);return null==t?e:this.add(7*(t-e),"d")}function It(t){var e=Mt(this,1,4).week;return null==t?e:this.add(7*(t-e),"d")}function At(t,e){return"string"!=typeof t?t:isNaN(t)?(t=e.weekdaysParse(t),"number"==typeof t?t:null):parseInt(t,10)}function Ft(t,e){return"string"==typeof t?e.weekdaysParse(t)%7||7:isNaN(t)?null:t}function Ot(t,e){return t?a(this._weekdays)?this._weekdays[t.day()]:this._weekdays[this._weekdays.isFormat.test(e)?"format":"standalone"][t.day()]:a(this._weekdays)?this._weekdays:this._weekdays.standalone}function Rt(t){return t?this._weekdaysShort[t.day()]:this._weekdaysShort}function Lt(t){return t?this._weekdaysMin[t.day()]:this._weekdaysMin}function Vt(t,e,n){var i,a,r,o=t.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],i=0;i<7;++i)r=f([2e3,1]).day(i),this._minWeekdaysParse[i]=this.weekdaysMin(r,"").toLocaleLowerCase(),this._shortWeekdaysParse[i]=this.weekdaysShort(r,"").toLocaleLowerCase(),this._weekdaysParse[i]=this.weekdays(r,"").toLocaleLowerCase();return n?"dddd"===e?(a=ma.call(this._weekdaysParse,o),a!==-1?a:null):"ddd"===e?(a=ma.call(this._shortWeekdaysParse,o),a!==-1?a:null):(a=ma.call(this._minWeekdaysParse,o),a!==-1?a:null):"dddd"===e?(a=ma.call(this._weekdaysParse,o),a!==-1?a:(a=ma.call(this._shortWeekdaysParse,o),a!==-1?a:(a=ma.call(this._minWeekdaysParse,o),a!==-1?a:null))):"ddd"===e?(a=ma.call(this._shortWeekdaysParse,o),a!==-1?a:(a=ma.call(this._weekdaysParse,o),a!==-1?a:(a=ma.call(this._minWeekdaysParse,o),a!==-1?a:null))):(a=ma.call(this._minWeekdaysParse,o),a!==-1?a:(a=ma.call(this._weekdaysParse,o),a!==-1?a:(a=ma.call(this._shortWeekdaysParse,o),a!==-1?a:null)))}function Wt(t,e,n){var i,a,r;if(this._weekdaysParseExact)return Vt.call(this,t,e,n);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),i=0;i<7;i++){if(a=f([2e3,1]).day(i),n&&!this._fullWeekdaysParse[i]&&(this._fullWeekdaysParse[i]=new RegExp("^"+this.weekdays(a,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[i]=new RegExp("^"+this.weekdaysShort(a,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[i]=new RegExp("^"+this.weekdaysMin(a,"").replace(".",".?")+"$","i")),this._weekdaysParse[i]||(r="^"+this.weekdays(a,"")+"|^"+this.weekdaysShort(a,"")+"|^"+this.weekdaysMin(a,""),this._weekdaysParse[i]=new RegExp(r.replace(".",""),"i")),n&&"dddd"===e&&this._fullWeekdaysParse[i].test(t))return i;if(n&&"ddd"===e&&this._shortWeekdaysParse[i].test(t))return i;if(n&&"dd"===e&&this._minWeekdaysParse[i].test(t))return i;if(!n&&this._weekdaysParse[i].test(t))return i}}function Yt(t){if(!this.isValid())return null!=t?this:NaN;var e=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=t?(t=At(t,this.localeData()),this.add(t-e,"d")):e}function zt(t){if(!this.isValid())return null!=t?this:NaN;var e=(this.day()+7-this.localeData()._week.dow)%7;return null==t?e:this.add(t-e,"d")}function Nt(t){if(!this.isValid())return null!=t?this:NaN;if(null!=t){var e=Ft(t,this.localeData());return this.day(this.day()%7?e:e-7)}return this.day()||7}function Bt(t){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")||jt.call(this),t?this._weekdaysStrictRegex:this._weekdaysRegex):(c(this,"_weekdaysRegex")||(this._weekdaysRegex=Ca),this._weekdaysStrictRegex&&t?this._weekdaysStrictRegex:this._weekdaysRegex)}function Et(t){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")||jt.call(this),t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(c(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=Pa),this._weekdaysShortStrictRegex&&t?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Ht(t){return this._weekdaysParseExact?(c(this,"_weekdaysRegex")||jt.call(this),t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(c(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=Ta),this._weekdaysMinStrictRegex&&t?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function jt(){function t(t,e){return e.length-t.length}var e,n,i,a,r,o=[],s=[],l=[],u=[];for(e=0;e<7;e++)n=f([2e3,1]).day(e),i=this.weekdaysMin(n,""),a=this.weekdaysShort(n,""),r=this.weekdays(n,""),o.push(i),s.push(a),l.push(r),u.push(i),u.push(a),u.push(r);for(o.sort(t),s.sort(t),l.sort(t),u.sort(t),e=0;e<7;e++)s[e]=nt(s[e]),l[e]=nt(l[e]),u[e]=nt(u[e]);this._weekdaysRegex=new RegExp("^("+u.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+l.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+s.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+o.join("|")+")","i")}function Ut(){return this.hours()%12||12}function Gt(){return this.hours()||24}function qt(t,e){Z(t,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),e)})}function Zt(t,e){return e._meridiemParse}function Xt(t){return"p"===(t+"").toLowerCase().charAt(0)}function Jt(t,e,n){return t>11?n?"pm":"PM":n?"am":"AM"}function Kt(t){return t?t.toLowerCase().replace("_","-"):t}function Qt(t){for(var e,n,i,a,r=0;r0;){if(i=$t(a.slice(0,e).join("-")))return i;if(n&&n.length>=e&&w(a,n,!0)>=e-1)break;e--}r++}return null}function $t(t){var i=null;if(!Ra[t]&&"undefined"!=typeof n&&n&&n.exports)try{i=Ia._abbr,e("./locale/"+t),te(i)}catch(t){}return Ra[t]}function te(t,e){var n;return t&&(n=s(e)?ie(t):ee(t,e),n&&(Ia=n)),Ia._abbr}function ee(t,e){if(null!==e){var n=Oa;if(e.abbr=t,null!=Ra[t])D("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),n=Ra[t]._config;else if(null!=e.parentLocale){if(null==Ra[e.parentLocale])return La[e.parentLocale]||(La[e.parentLocale]=[]),La[e.parentLocale].push({name:t,config:e}),null;n=Ra[e.parentLocale]._config}return Ra[t]=new I(T(n,e)),La[t]&&La[t].forEach(function(t){ee(t.name,t.config)}),te(t),Ra[t]}return delete Ra[t],null}function ne(t,e){if(null!=e){var n,i=Oa;null!=Ra[t]&&(i=Ra[t]._config),e=T(i,e),n=new I(e),n.parentLocale=Ra[t],Ra[t]=n,te(t)}else null!=Ra[t]&&(null!=Ra[t].parentLocale?Ra[t]=Ra[t].parentLocale:null!=Ra[t]&&delete Ra[t]);return Ra[t]}function ie(t){var e;if(t&&t._locale&&t._locale._abbr&&(t=t._locale._abbr),!t)return Ia;if(!a(t)){if(e=$t(t))return e;t=[t]}return Qt(t)}function ae(){return Ti(Ra)}function re(t){var e,n=t._a;return n&&p(t).overflow===-2&&(e=n[la]<0||n[la]>11?la:n[ua]<1||n[ua]>ot(n[sa],n[la])?ua:n[da]<0||n[da]>24||24===n[da]&&(0!==n[ca]||0!==n[ha]||0!==n[fa])?da:n[ca]<0||n[ca]>59?ca:n[ha]<0||n[ha]>59?ha:n[fa]<0||n[fa]>999?fa:-1,p(t)._overflowDayOfYear&&(eua)&&(e=ua),p(t)._overflowWeeks&&e===-1&&(e=ga),p(t)._overflowWeekday&&e===-1&&(e=pa),p(t).overflow=e),t}function oe(t){var e,n,i,a,r,o,s=t._i,l=Va.exec(s)||Wa.exec(s);if(l){for(p(t).iso=!0,e=0,n=za.length;e10?"YYYY ":"YY "),r="HH:mm"+(n[4]?":ss":""),n[1]){var c=new Date(n[2]),h=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"][c.getDay()];if(n[1].substr(0,3)!==h)return p(t).weekdayMismatch=!0,void(t._isValid=!1)}switch(n[5].length){case 2:0===l?s=" +0000":(l=d.indexOf(n[5][1].toUpperCase())-12,s=(l<0?" -":" +")+(""+l).replace(/^-?/,"0").match(/..$/)[0]+"00");break;case 4:s=u[n[5]];break;default:s=u[" GMT"]}n[5]=s,t._i=n.splice(1).join(""),o=" ZZ",t._f=i+a+r+o,fe(t),p(t).rfc2822=!0}else t._isValid=!1}function le(e){var n=Ba.exec(e._i);return null!==n?void(e._d=new Date(+n[1])):(oe(e),void(e._isValid===!1&&(delete e._isValid,se(e),e._isValid===!1&&(delete e._isValid,t.createFromInputFallback(e)))))}function ue(t,e,n){return null!=t?t:null!=e?e:n}function de(e){var n=new Date(t.now());return e._useUTC?[n.getUTCFullYear(),n.getUTCMonth(),n.getUTCDate()]:[n.getFullYear(),n.getMonth(),n.getDate()]}function ce(t){var e,n,i,a,r=[];if(!t._d){for(i=de(t),t._w&&null==t._a[ua]&&null==t._a[la]&&he(t),null!=t._dayOfYear&&(a=ue(t._a[sa],i[sa]),(t._dayOfYear>vt(a)||0===t._dayOfYear)&&(p(t)._overflowDayOfYear=!0),n=_t(a,0,t._dayOfYear),t._a[la]=n.getUTCMonth(),t._a[ua]=n.getUTCDate()),e=0;e<3&&null==t._a[e];++e)t._a[e]=r[e]=i[e];for(;e<7;e++)t._a[e]=r[e]=null==t._a[e]?2===e?1:0:t._a[e];24===t._a[da]&&0===t._a[ca]&&0===t._a[ha]&&0===t._a[fa]&&(t._nextDay=!0,t._a[da]=0),t._d=(t._useUTC?_t:xt).apply(null,r),null!=t._tzm&&t._d.setUTCMinutes(t._d.getUTCMinutes()-t._tzm),t._nextDay&&(t._a[da]=24)}}function he(t){var e,n,i,a,r,o,s,l;if(e=t._w,null!=e.GG||null!=e.W||null!=e.E)r=1,o=4,n=ue(e.GG,t._a[sa],Mt(_e(),1,4).year),i=ue(e.W,1),a=ue(e.E,1),(a<1||a>7)&&(l=!0);else{r=t._locale._week.dow,o=t._locale._week.doy;var u=Mt(_e(),r,o);n=ue(e.gg,t._a[sa],u.year),i=ue(e.w,u.week),null!=e.d?(a=e.d,(a<0||a>6)&&(l=!0)):null!=e.e?(a=e.e+r,(e.e<0||e.e>6)&&(l=!0)):a=r}i<1||i>St(n,r,o)?p(t)._overflowWeeks=!0:null!=l?p(t)._overflowWeekday=!0:(s=wt(n,i,a,r,o),t._a[sa]=s.year,t._dayOfYear=s.dayOfYear)}function fe(e){if(e._f===t.ISO_8601)return void oe(e);if(e._f===t.RFC_2822)return void se(e);e._a=[],p(e).empty=!0;var n,i,a,r,o,s=""+e._i,l=s.length,u=0;for(a=Q(e._f,e._locale).match(Yi)||[],n=0;n0&&p(e).unusedInput.push(o),s=s.slice(s.indexOf(i)+i.length),u+=i.length),Bi[r]?(i?p(e).empty=!1:p(e).unusedTokens.push(r),rt(r,i,e)):e._strict&&!i&&p(e).unusedTokens.push(r);p(e).charsLeftOver=l-u,s.length>0&&p(e).unusedInput.push(s),e._a[da]<=12&&p(e).bigHour===!0&&e._a[da]>0&&(p(e).bigHour=void 0),p(e).parsedDateParts=e._a.slice(0),p(e).meridiem=e._meridiem,e._a[da]=ge(e._locale,e._a[da],e._meridiem),ce(e),re(e)}function ge(t,e,n){var i;return null==n?e:null!=t.meridiemHour?t.meridiemHour(e,n):null!=t.isPM?(i=t.isPM(n),i&&e<12&&(e+=12),i||12!==e||(e=0),e):e}function pe(t){var e,n,i,a,r;if(0===t._f.length)return p(t).invalidFormat=!0,void(t._d=new Date(NaN));for(a=0;athis.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Ee(){if(!s(this._isDSTShifted))return this._isDSTShifted;var t={};if(y(t,this),t=ye(t),t._a){var e=t._isUTC?f(t._a):_e(t._a);this._isDSTShifted=this.isValid()&&w(t._a,e.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function He(){return!!this.isValid()&&!this._isUTC}function je(){return!!this.isValid()&&this._isUTC}function Ue(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Ge(t,e){var n,i,a,r=t,o=null;return Te(t)?r={ms:t._milliseconds,d:t._days,M:t._months}:l(t)?(r={},e?r[e]=t:r.milliseconds=t):(o=Za.exec(t))?(n="-"===o[1]?-1:1,r={y:0,d:k(o[ua])*n,h:k(o[da])*n,m:k(o[ca])*n,s:k(o[ha])*n,ms:k(Ie(1e3*o[fa]))*n}):(o=Xa.exec(t))?(n="-"===o[1]?-1:1,r={y:qe(o[2],n),M:qe(o[3],n),w:qe(o[4],n),d:qe(o[5],n),h:qe(o[6],n),m:qe(o[7],n),s:qe(o[8],n)}):null==r?r={}:"object"==typeof r&&("from"in r||"to"in r)&&(a=Xe(_e(r.from),_e(r.to)),r={},r.ms=a.milliseconds,r.M=a.months),i=new Pe(r),Te(t)&&c(t,"_locale")&&(i._locale=t._locale),i}function qe(t,e){var n=t&&parseFloat(t.replace(",","."));return(isNaN(n)?0:n)*e}function Ze(t,e){var n={milliseconds:0,months:0};return n.months=e.month()-t.month()+12*(e.year()-t.year()),t.clone().add(n.months,"M").isAfter(e)&&--n.months,n.milliseconds=+e-+t.clone().add(n.months,"M"),n}function Xe(t,e){var n;return t.isValid()&&e.isValid()?(e=Oe(e,t),t.isBefore(e)?n=Ze(t,e):(n=Ze(e,t),n.milliseconds=-n.milliseconds,n.months=-n.months),n):{milliseconds:0,months:0}}function Je(t,e){return function(n,i){var a,r;return null===i||isNaN(+i)||(D(e,"moment()."+e+"(period, number) is deprecated. Please use moment()."+e+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),r=n,n=i,i=r),n="string"==typeof n?+n:n,a=Ge(n,i),Ke(this,a,t),this}}function Ke(e,n,i,a){var r=n._milliseconds,o=Ie(n._days),s=Ie(n._months);e.isValid()&&(a=null==a||a,r&&e._d.setTime(e._d.valueOf()+r*i),o&&j(e,"Date",H(e,"Date")+o*i),s&&ct(e,H(e,"Month")+s*i),a&&t.updateOffset(e,o||s))}function Qe(t,e){var n=t.diff(e,"days",!0);return n<-6?"sameElse":n<-1?"lastWeek":n<0?"lastDay":n<1?"sameDay":n<2?"nextDay":n<7?"nextWeek":"sameElse"}function $e(e,n){var i=e||_e(),a=Oe(i,this).startOf("day"),r=t.calendarFormat(this,a)||"sameElse",o=n&&(C(n[r])?n[r].call(this,i):n[r]);return this.format(o||this.localeData().calendar(r,this,_e(i)))}function tn(){return new b(this)}function en(t,e){var n=x(t)?t:_e(t);return!(!this.isValid()||!n.isValid())&&(e=Y(s(e)?"millisecond":e),"millisecond"===e?this.valueOf()>n.valueOf():n.valueOf()9999?K(t,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):C(Date.prototype.toISOString)?this.toDate().toISOString():K(t,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}function hn(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var t="moment",e="";this.isLocal()||(t=0===this.utcOffset()?"moment.utc":"moment.parseZone",e="Z");var n="["+t+'("]',i=0<=this.year()&&this.year()<=9999?"YYYY":"YYYYYY",a="-MM-DD[T]HH:mm:ss.SSS",r=e+'[")]';return this.format(n+i+a+r)}function fn(e){e||(e=this.isUtc()?t.defaultFormatUtc:t.defaultFormat);var n=K(this,e);return this.localeData().postformat(n)}function gn(t,e){return this.isValid()&&(x(t)&&t.isValid()||_e(t).isValid())?Ge({to:this,from:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function pn(t){return this.from(_e(),t)}function mn(t,e){return this.isValid()&&(x(t)&&t.isValid()||_e(t).isValid())?Ge({from:this,to:t}).locale(this.locale()).humanize(!e):this.localeData().invalidDate()}function vn(t){return this.to(_e(),t)}function yn(t){var e;return void 0===t?this._locale._abbr:(e=ie(t),null!=e&&(this._locale=e),this)}function bn(){return this._locale}function xn(t){switch(t=Y(t)){case"year":this.month(0);case"quarter":case"month":this.date(1);case"week":case"isoWeek":case"day":case"date":this.hours(0);case"hour":this.minutes(0);case"minute":this.seconds(0);case"second":this.milliseconds(0)}return"week"===t&&this.weekday(0),"isoWeek"===t&&this.isoWeekday(1),"quarter"===t&&this.month(3*Math.floor(this.month()/3)),this}function _n(t){return t=Y(t),void 0===t||"millisecond"===t?this:("date"===t&&(t="day"),this.startOf(t).add(1,"isoWeek"===t?"week":t).subtract(1,"ms"))}function kn(){return this._d.valueOf()-6e4*(this._offset||0)}function wn(){return Math.floor(this.valueOf()/1e3)}function Mn(){return new Date(this.valueOf())}function Sn(){var t=this;return[t.year(),t.month(),t.date(),t.hour(),t.minute(),t.second(),t.millisecond()]}function Dn(){var t=this;return{years:t.year(),months:t.month(),date:t.date(),hours:t.hours(),minutes:t.minutes(),seconds:t.seconds(),milliseconds:t.milliseconds()}}function Cn(){return this.isValid()?this.toISOString():null}function Pn(){return m(this)}function Tn(){return h({},p(this))}function In(){return p(this).overflow}function An(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function Fn(t,e){Z(0,[t,t.length],0,e)}function On(t){return Wn.call(this,t,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Rn(t){return Wn.call(this,t,this.isoWeek(),this.isoWeekday(),1,4)}function Ln(){return St(this.year(),1,4)}function Vn(){var t=this.localeData()._week;return St(this.year(),t.dow,t.doy)}function Wn(t,e,n,i,a){var r;return null==t?Mt(this,i,a).year:(r=St(t,i,a),e>r&&(e=r),Yn.call(this,t,e,n,i,a))}function Yn(t,e,n,i,a){var r=wt(t,e,n,i,a),o=_t(r.year,0,r.dayOfYear);return this.year(o.getUTCFullYear()),this.month(o.getUTCMonth()),this.date(o.getUTCDate()),this}function zn(t){return null==t?Math.ceil((this.month()+1)/3):this.month(3*(t-1)+this.month()%3)}function Nn(t){var e=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==t?e:this.add(t-e,"d")}function Bn(t,e){e[fa]=k(1e3*("0."+t))}function En(){return this._isUTC?"UTC":""}function Hn(){return this._isUTC?"Coordinated Universal Time":""}function jn(t){return _e(1e3*t)}function Un(){return _e.apply(null,arguments).parseZone()}function Gn(t){return t}function qn(t,e,n,i){var a=ie(),r=f().set(i,e);return a[n](r,t)}function Zn(t,e,n){if(l(t)&&(e=t,t=void 0),t=t||"",null!=e)return qn(t,e,n,"month");var i,a=[];for(i=0;i<12;i++)a[i]=qn(t,i,n,"month");return a}function Xn(t,e,n,i){"boolean"==typeof t?(l(e)&&(n=e,e=void 0),e=e||""):(e=t,n=e,t=!1,l(e)&&(n=e,e=void 0),e=e||"");var a=ie(),r=t?a._week.dow:0;if(null!=n)return qn(e,(n+r)%7,i,"day");var o,s=[];for(o=0;o<7;o++)s[o]=qn(e,(o+r)%7,i,"day");return s}function Jn(t,e){return Zn(t,e,"months")}function Kn(t,e){return Zn(t,e,"monthsShort")}function Qn(t,e,n){return Xn(t,e,n,"weekdays")}function $n(t,e,n){return Xn(t,e,n,"weekdaysShort")}function ti(t,e,n){return Xn(t,e,n,"weekdaysMin")}function ei(){var t=this._data;return this._milliseconds=or(this._milliseconds),this._days=or(this._days),this._months=or(this._months),t.milliseconds=or(t.milliseconds),t.seconds=or(t.seconds),t.minutes=or(t.minutes),t.hours=or(t.hours),t.months=or(t.months),t.years=or(t.years),this}function ni(t,e,n,i){var a=Ge(e,n);return t._milliseconds+=i*a._milliseconds,t._days+=i*a._days,t._months+=i*a._months,t._bubble()}function ii(t,e){return ni(this,t,e,1)}function ai(t,e){return ni(this,t,e,-1)}function ri(t){return t<0?Math.floor(t):Math.ceil(t)}function oi(){var t,e,n,i,a,r=this._milliseconds,o=this._days,s=this._months,l=this._data;return r>=0&&o>=0&&s>=0||r<=0&&o<=0&&s<=0||(r+=864e5*ri(li(s)+o),o=0,s=0),l.milliseconds=r%1e3,t=_(r/1e3),l.seconds=t%60,e=_(t/60),l.minutes=e%60,n=_(e/60),l.hours=n%24,o+=_(n/24),a=_(si(o)),s+=a,o-=ri(li(a)),i=_(s/12),s%=12,l.days=o,l.months=s,l.years=i,this}function si(t){return 4800*t/146097}function li(t){return 146097*t/4800}function ui(t){if(!this.isValid())return NaN;var e,n,i=this._milliseconds;if(t=Y(t),"month"===t||"year"===t)return e=this._days+i/864e5,n=this._months+si(e),"month"===t?n:n/12;switch(e=this._days+Math.round(li(this._months)),t){case"week":return e/7+i/6048e5;case"day":return e+i/864e5;case"hour":return 24*e+i/36e5;case"minute":return 1440*e+i/6e4;case"second":return 86400*e+i/1e3;case"millisecond":return Math.floor(864e5*e)+i;default:throw new Error("Unknown unit "+t)}}function di(){return this.isValid()?this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*k(this._months/12):NaN}function ci(t){return function(){return this.as(t)}}function hi(t){return t=Y(t),this.isValid()?this[t+"s"]():NaN}function fi(t){return function(){return this.isValid()?this._data[t]:NaN}}function gi(){return _(this.days()/7)}function pi(t,e,n,i,a){return a.relativeTime(e||1,!!n,t,i)}function mi(t,e,n){var i=Ge(t).abs(),a=kr(i.as("s")),r=kr(i.as("m")),o=kr(i.as("h")),s=kr(i.as("d")),l=kr(i.as("M")),u=kr(i.as("y")),d=a<=wr.ss&&["s",a]||a0,d[4]=n,pi.apply(null,d)}function vi(t){return void 0===t?kr:"function"==typeof t&&(kr=t,!0)}function yi(t,e){return void 0!==wr[t]&&(void 0===e?wr[t]:(wr[t]=e,"s"===t&&(wr.ss=e-1),!0))}function bi(t){if(!this.isValid())return this.localeData().invalidDate();var e=this.localeData(),n=mi(this,!t,e);return t&&(n=e.pastFuture(+this,n)),e.postformat(n)}function xi(){if(!this.isValid())return this.localeData().invalidDate();var t,e,n,i=Mr(this._milliseconds)/1e3,a=Mr(this._days),r=Mr(this._months);t=_(i/60),e=_(t/60),i%=60,t%=60,n=_(r/12),r%=12;var o=n,s=r,l=a,u=e,d=t,c=i,h=this.asSeconds();return h?(h<0?"-":"")+"P"+(o?o+"Y":"")+(s?s+"M":"")+(l?l+"D":"")+(u||d||c?"T":"")+(u?u+"H":"")+(d?d+"M":"")+(c?c+"S":""):"P0D"}var _i,ki;ki=Array.prototype.some?Array.prototype.some:function(t){for(var e=Object(this),n=e.length>>>0,i=0;i68?1900:2e3)};var ka=E("FullYear",!0);Z("w",["ww",2],"wo","week"),Z("W",["WW",2],"Wo","isoWeek"),W("week","w"),W("isoWeek","W"),N("week",5),N("isoWeek",5),$("w",qi),$("ww",qi,Hi),$("W",qi),$("WW",qi,Hi),at(["w","ww","W","WW"],function(t,e,n,i){e[i.substr(0,1)]=k(t)});var wa={dow:0,doy:6};Z("d",0,"do","day"),Z("dd",0,0,function(t){return this.localeData().weekdaysMin(this,t)}),Z("ddd",0,0,function(t){return this.localeData().weekdaysShort(this,t)}),Z("dddd",0,0,function(t){return this.localeData().weekdays(this,t)}),Z("e",0,0,"weekday"),Z("E",0,0,"isoWeekday"),W("day","d"),W("weekday","e"),W("isoWeekday","E"),N("day",11),N("weekday",11),N("isoWeekday",11),$("d",qi),$("e",qi),$("E",qi),$("dd",function(t,e){return e.weekdaysMinRegex(t)}),$("ddd",function(t,e){return e.weekdaysShortRegex(t)}),$("dddd",function(t,e){return e.weekdaysRegex(t)}),at(["dd","ddd","dddd"],function(t,e,n,i){var a=n._locale.weekdaysParse(t,i,n._strict);null!=a?e.d=a:p(n).invalidWeekday=t; +}),at(["d","e","E"],function(t,e,n,i){e[i]=k(t)});var Ma="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),Sa="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),Da="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),Ca=aa,Pa=aa,Ta=aa;Z("H",["HH",2],0,"hour"),Z("h",["hh",2],0,Ut),Z("k",["kk",2],0,Gt),Z("hmm",0,0,function(){return""+Ut.apply(this)+q(this.minutes(),2)}),Z("hmmss",0,0,function(){return""+Ut.apply(this)+q(this.minutes(),2)+q(this.seconds(),2)}),Z("Hmm",0,0,function(){return""+this.hours()+q(this.minutes(),2)}),Z("Hmmss",0,0,function(){return""+this.hours()+q(this.minutes(),2)+q(this.seconds(),2)}),qt("a",!0),qt("A",!1),W("hour","h"),N("hour",13),$("a",Zt),$("A",Zt),$("H",qi),$("h",qi),$("k",qi),$("HH",qi,Hi),$("hh",qi,Hi),$("kk",qi,Hi),$("hmm",Zi),$("hmmss",Xi),$("Hmm",Zi),$("Hmmss",Xi),it(["H","HH"],da),it(["k","kk"],function(t,e,n){var i=k(t);e[da]=24===i?0:i}),it(["a","A"],function(t,e,n){n._isPm=n._locale.isPM(t),n._meridiem=t}),it(["h","hh"],function(t,e,n){e[da]=k(t),p(n).bigHour=!0}),it("hmm",function(t,e,n){var i=t.length-2;e[da]=k(t.substr(0,i)),e[ca]=k(t.substr(i)),p(n).bigHour=!0}),it("hmmss",function(t,e,n){var i=t.length-4,a=t.length-2;e[da]=k(t.substr(0,i)),e[ca]=k(t.substr(i,2)),e[ha]=k(t.substr(a)),p(n).bigHour=!0}),it("Hmm",function(t,e,n){var i=t.length-2;e[da]=k(t.substr(0,i)),e[ca]=k(t.substr(i))}),it("Hmmss",function(t,e,n){var i=t.length-4,a=t.length-2;e[da]=k(t.substr(0,i)),e[ca]=k(t.substr(i,2)),e[ha]=k(t.substr(a))});var Ia,Aa=/[ap]\.?m?\.?/i,Fa=E("Hours",!0),Oa={calendar:Ii,longDateFormat:Ai,invalidDate:Fi,ordinal:Oi,dayOfMonthOrdinalParse:Ri,relativeTime:Li,months:ya,monthsShort:ba,week:wa,weekdays:Ma,weekdaysMin:Da,weekdaysShort:Sa,meridiemParse:Aa},Ra={},La={},Va=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Wa=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ya=/Z|[+-]\d\d(?::?\d\d)?/,za=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],Na=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ba=/^\/?Date\((\-?\d+)/i,Ea=/^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Za-ik-z]|[+-]\d{4}))$/;t.createFromInputFallback=S("value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(t){t._d=new Date(t._i+(t._useUTC?" UTC":""))}),t.ISO_8601=function(){},t.RFC_2822=function(){};var Ha=S("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var t=_e.apply(null,arguments);return this.isValid()&&t.isValid()?tthis?this:t:v()}),Ua=function(){return Date.now?Date.now():+new Date},Ga=["year","quarter","month","week","day","hour","minute","second","millisecond"];Ae("Z",":"),Ae("ZZ",""),$("Z",na),$("ZZ",na),it(["Z","ZZ"],function(t,e,n){n._useUTC=!0,n._tzm=Fe(na,t)});var qa=/([\+\-]|\d\d)/gi;t.updateOffset=function(){};var Za=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,Xa=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Ge.fn=Pe.prototype,Ge.invalid=Ce;var Ja=Je(1,"add"),Ka=Je(-1,"subtract");t.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",t.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Qa=S("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(t){return void 0===t?this.localeData():this.locale(t)});Z(0,["gg",2],0,function(){return this.weekYear()%100}),Z(0,["GG",2],0,function(){return this.isoWeekYear()%100}),Fn("gggg","weekYear"),Fn("ggggg","weekYear"),Fn("GGGG","isoWeekYear"),Fn("GGGGG","isoWeekYear"),W("weekYear","gg"),W("isoWeekYear","GG"),N("weekYear",1),N("isoWeekYear",1),$("G",ta),$("g",ta),$("GG",qi,Hi),$("gg",qi,Hi),$("GGGG",Ki,Ui),$("gggg",Ki,Ui),$("GGGGG",Qi,Gi),$("ggggg",Qi,Gi),at(["gggg","ggggg","GGGG","GGGGG"],function(t,e,n,i){e[i.substr(0,2)]=k(t)}),at(["gg","GG"],function(e,n,i,a){n[a]=t.parseTwoDigitYear(e)}),Z("Q",0,"Qo","quarter"),W("quarter","Q"),N("quarter",7),$("Q",Ei),it("Q",function(t,e){e[la]=3*(k(t)-1)}),Z("D",["DD",2],"Do","date"),W("date","D"),N("date",9),$("D",qi),$("DD",qi,Hi),$("Do",function(t,e){return t?e._dayOfMonthOrdinalParse||e._ordinalParse:e._dayOfMonthOrdinalParseLenient}),it(["D","DD"],ua),it("Do",function(t,e){e[ua]=k(t.match(qi)[0],10)});var $a=E("Date",!0);Z("DDD",["DDDD",3],"DDDo","dayOfYear"),W("dayOfYear","DDD"),N("dayOfYear",4),$("DDD",Ji),$("DDDD",ji),it(["DDD","DDDD"],function(t,e,n){n._dayOfYear=k(t)}),Z("m",["mm",2],0,"minute"),W("minute","m"),N("minute",14),$("m",qi),$("mm",qi,Hi),it(["m","mm"],ca);var tr=E("Minutes",!1);Z("s",["ss",2],0,"second"),W("second","s"),N("second",15),$("s",qi),$("ss",qi,Hi),it(["s","ss"],ha);var er=E("Seconds",!1);Z("S",0,0,function(){return~~(this.millisecond()/100)}),Z(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),Z(0,["SSS",3],0,"millisecond"),Z(0,["SSSS",4],0,function(){return 10*this.millisecond()}),Z(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),Z(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),Z(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),Z(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),Z(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),W("millisecond","ms"),N("millisecond",16),$("S",Ji,Ei),$("SS",Ji,Hi),$("SSS",Ji,ji);var nr;for(nr="SSSS";nr.length<=9;nr+="S")$(nr,$i);for(nr="S";nr.length<=9;nr+="S")it(nr,Bn);var ir=E("Milliseconds",!1);Z("z",0,0,"zoneAbbr"),Z("zz",0,0,"zoneName");var ar=b.prototype;ar.add=Ja,ar.calendar=$e,ar.clone=tn,ar.diff=ln,ar.endOf=_n,ar.format=fn,ar.from=gn,ar.fromNow=pn,ar.to=mn,ar.toNow=vn,ar.get=U,ar.invalidAt=In,ar.isAfter=en,ar.isBefore=nn,ar.isBetween=an,ar.isSame=rn,ar.isSameOrAfter=on,ar.isSameOrBefore=sn,ar.isValid=Pn,ar.lang=Qa,ar.locale=yn,ar.localeData=bn,ar.max=ja,ar.min=Ha,ar.parsingFlags=Tn,ar.set=G,ar.startOf=xn,ar.subtract=Ka,ar.toArray=Sn,ar.toObject=Dn,ar.toDate=Mn,ar.toISOString=cn,ar.inspect=hn,ar.toJSON=Cn,ar.toString=dn,ar.unix=wn,ar.valueOf=kn,ar.creationData=An,ar.year=ka,ar.isLeapYear=bt,ar.weekYear=On,ar.isoWeekYear=Rn,ar.quarter=ar.quarters=zn,ar.month=ht,ar.daysInMonth=ft,ar.week=ar.weeks=Tt,ar.isoWeek=ar.isoWeeks=It,ar.weeksInYear=Vn,ar.isoWeeksInYear=Ln,ar.date=$a,ar.day=ar.days=Yt,ar.weekday=zt,ar.isoWeekday=Nt,ar.dayOfYear=Nn,ar.hour=ar.hours=Fa,ar.minute=ar.minutes=tr,ar.second=ar.seconds=er,ar.millisecond=ar.milliseconds=ir,ar.utcOffset=Le,ar.utc=We,ar.local=Ye,ar.parseZone=ze,ar.hasAlignedHourOffset=Ne,ar.isDST=Be,ar.isLocal=He,ar.isUtcOffset=je,ar.isUtc=Ue,ar.isUTC=Ue,ar.zoneAbbr=En,ar.zoneName=Hn,ar.dates=S("dates accessor is deprecated. Use date instead.",$a),ar.months=S("months accessor is deprecated. Use month instead",ht),ar.years=S("years accessor is deprecated. Use year instead",ka),ar.zone=S("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Ve),ar.isDSTShifted=S("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Ee);var rr=I.prototype;rr.calendar=A,rr.longDateFormat=F,rr.invalidDate=O,rr.ordinal=R,rr.preparse=Gn,rr.postformat=Gn,rr.relativeTime=L,rr.pastFuture=V,rr.set=P,rr.months=st,rr.monthsShort=lt,rr.monthsParse=dt,rr.monthsRegex=pt,rr.monthsShortRegex=gt,rr.week=Dt,rr.firstDayOfYear=Pt,rr.firstDayOfWeek=Ct,rr.weekdays=Ot,rr.weekdaysMin=Lt,rr.weekdaysShort=Rt,rr.weekdaysParse=Wt,rr.weekdaysRegex=Bt,rr.weekdaysShortRegex=Et,rr.weekdaysMinRegex=Ht,rr.isPM=Xt,rr.meridiem=Jt,te("en",{dayOfMonthOrdinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(t){var e=t%10,n=1===k(t%100/10)?"th":1===e?"st":2===e?"nd":3===e?"rd":"th";return t+n}}),t.lang=S("moment.lang is deprecated. Use moment.locale instead.",te),t.langData=S("moment.langData is deprecated. Use moment.localeData instead.",ie);var or=Math.abs,sr=ci("ms"),lr=ci("s"),ur=ci("m"),dr=ci("h"),cr=ci("d"),hr=ci("w"),fr=ci("M"),gr=ci("y"),pr=fi("milliseconds"),mr=fi("seconds"),vr=fi("minutes"),yr=fi("hours"),br=fi("days"),xr=fi("months"),_r=fi("years"),kr=Math.round,wr={ss:44,s:45,m:45,h:22,d:26,M:11},Mr=Math.abs,Sr=Pe.prototype;return Sr.isValid=De,Sr.abs=ei,Sr.add=ii,Sr.subtract=ai,Sr.as=ui,Sr.asMilliseconds=sr,Sr.asSeconds=lr,Sr.asMinutes=ur,Sr.asHours=dr,Sr.asDays=cr,Sr.asWeeks=hr,Sr.asMonths=fr,Sr.asYears=gr,Sr.valueOf=di,Sr._bubble=oi,Sr.get=hi,Sr.milliseconds=pr,Sr.seconds=mr,Sr.minutes=vr,Sr.hours=yr,Sr.days=br,Sr.weeks=gi,Sr.months=xr,Sr.years=_r,Sr.humanize=bi,Sr.toISOString=xi,Sr.toString=xi,Sr.toJSON=xi,Sr.locale=yn,Sr.localeData=bn,Sr.toIsoString=S("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",xi),Sr.lang=Qa,Z("X",0,0,"unix"),Z("x",0,0,"valueOf"),$("x",ta),$("X",ia),it("X",function(t,e,n){n._d=new Date(1e3*parseFloat(t,10))}),it("x",function(t,e,n){n._d=new Date(k(t))}),t.version="2.18.1",i(_e),t.fn=ar,t.min=we,t.max=Me,t.now=Ua,t.utc=f,t.unix=jn,t.months=Jn,t.isDate=u,t.locale=te,t.invalid=v,t.duration=Ge,t.isMoment=x,t.weekdays=Qn,t.parseZone=Un,t.localeData=ie,t.isDuration=Te,t.monthsShort=Kn,t.weekdaysMin=ti,t.defineLocale=ee,t.updateLocale=ne,t.locales=ae,t.weekdaysShort=$n,t.normalizeUnits=Y,t.relativeTimeRounding=vi,t.relativeTimeThreshold=yi,t.calendarFormat=Qe,t.prototype=ar,t})},{}],7:[function(t,e,n){var i=t(28)();t(26)(i),t(40)(i),t(22)(i),t(25)(i),t(30)(i),t(21)(i),t(23)(i),t(24)(i),t(29)(i),t(32)(i),t(33)(i),t(31)(i),t(27)(i),t(34)(i),t(35)(i),t(36)(i),t(37)(i),t(38)(i),t(46)(i),t(44)(i),t(45)(i),t(47)(i),t(48)(i),t(49)(i),t(15)(i),t(16)(i),t(17)(i),t(18)(i),t(19)(i),t(20)(i),t(8)(i),t(9)(i),t(10)(i),t(11)(i),t(12)(i),t(13)(i),t(14)(i);var a=[];a.push(t(41)(i),t(42)(i),t(43)(i)),i.plugins.register(a),e.exports=i,"undefined"!=typeof window&&(window.Chart=i)},{10:10,11:11,12:12,13:13,14:14,15:15,16:16,17:17,18:18,19:19,20:20,21:21,22:22,23:23,24:24,25:25,26:26,27:27,28:28,29:29,30:30,31:31,32:32,33:33,34:34,35:35,36:36,37:37,38:38,40:40,41:41,42:42,43:43,44:44,45:45,46:46,47:47,48:48,49:49,8:8,9:9}],8:[function(t,e,n){"use strict";e.exports=function(t){t.Bar=function(e,n){return n.type="bar",new t(e,n)}}},{}],9:[function(t,e,n){"use strict";e.exports=function(t){t.Bubble=function(e,n){return n.type="bubble",new t(e,n)}}},{}],10:[function(t,e,n){"use strict";e.exports=function(t){t.Doughnut=function(e,n){return n.type="doughnut",new t(e,n)}}},{}],11:[function(t,e,n){"use strict";e.exports=function(t){t.Line=function(e,n){return n.type="line",new t(e,n)}}},{}],12:[function(t,e,n){"use strict";e.exports=function(t){t.PolarArea=function(e,n){return n.type="polarArea",new t(e,n)}}},{}],13:[function(t,e,n){"use strict";e.exports=function(t){t.Radar=function(e,n){return n.type="radar",new t(e,n)}}},{}],14:[function(t,e,n){"use strict";e.exports=function(t){var e={hover:{mode:"single"},scales:{xAxes:[{type:"linear",position:"bottom",id:"x-axis-1"}],yAxes:[{type:"linear",position:"left",id:"y-axis-1"}]},tooltips:{callbacks:{title:function(){return""},label:function(t){return"("+t.xLabel+", "+t.yLabel+")"}}}};t.defaults.scatter=e,t.controllers.scatter=t.controllers.line,t.Scatter=function(e,n){return n.type="scatter",new t(e,n)}}},{}],15:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.bar={hover:{mode:"label"},scales:{xAxes:[{type:"category",categoryPercentage:.8,barPercentage:.9,gridLines:{offsetGridLines:!0}}],yAxes:[{type:"linear"}]}},t.controllers.bar=t.DatasetController.extend({dataElementType:t.elements.Rectangle,initialize:function(){var e,n=this;t.DatasetController.prototype.initialize.apply(n,arguments),e=n.getMeta(),e.stack=n.getDataset().stack,e.bar=!0},update:function(t){var e,n,i=this,a=i.getMeta().data;for(i._ruler=i.getRuler(),e=0,n=a.length;e=0&&a>0)&&(m+=a));return r=c.getPixelForValue(m),o=c.getPixelForValue(m+f),s=(o-r)/2,{size:s,base:r,head:o,center:o+s/2}},calculateBarIndexPixels:function(t,e,n){var i=this,a=n.scale,r=i.chart.isCombo,o=i.getStackIndex(t),s=a.getPixelForValue(null,e,t,r),l=n.barSize;return s-=r?n.tickSize/2:0,s+=n.fullBarSize*o,s+=n.categorySpacing/2,s+=n.barSpacing/2,{size:l,base:s,head:s+l,center:s+l/2}},draw:function(){var t,n=this,i=n.chart,a=n.getMeta().data,r=n.getDataset(),o=a.length,s=0;for(e.canvas.clipArea(i.ctx,i.chartArea);s0&&(t[0].yLabel?n=t[0].yLabel:e.labels.length>0&&t[0].index');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var r=0;r'),a[r]&&e.push(a[r]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(t){var n=t.data;return n.labels.length&&n.datasets.length?n.labels.map(function(i,a){var r=t.getDatasetMeta(0),o=n.datasets[0],s=r.data[a],l=s&&s.custom||{},u=e.getValueAtIndexOrDefault,d=t.options.elements.arc,c=l.backgroundColor?l.backgroundColor:u(o.backgroundColor,a,d.backgroundColor),h=l.borderColor?l.borderColor:u(o.borderColor,a,d.borderColor),f=l.borderWidth?l.borderWidth:u(o.borderWidth,a,d.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(o.data[a])||r.data[a].hidden,index:a}}):[]}},onClick:function(t,e){var n,i,a,r=e.index,o=this.chart;for(n=0,i=(o.data.datasets||[]).length;n=Math.PI?-1:g<-Math.PI?1:0);var p=g+f,m={x:Math.cos(g),y:Math.sin(g)},v={x:Math.cos(p),y:Math.sin(p)},y=g<=0&&0<=p||g<=2*Math.PI&&2*Math.PI<=p,b=g<=.5*Math.PI&&.5*Math.PI<=p||g<=2.5*Math.PI&&2.5*Math.PI<=p,x=g<=-Math.PI&&-Math.PI<=p||g<=Math.PI&&Math.PI<=p,_=g<=.5*-Math.PI&&.5*-Math.PI<=p||g<=1.5*Math.PI&&1.5*Math.PI<=p,k=h/100,w={x:x?-1:Math.min(m.x*(m.x<0?1:k),v.x*(v.x<0?1:k)),y:_?-1:Math.min(m.y*(m.y<0?1:k),v.y*(v.y<0?1:k))},M={x:y?1:Math.max(m.x*(m.x>0?1:k),v.x*(v.x>0?1:k)),y:b?1:Math.max(m.y*(m.y>0?1:k),v.y*(v.y>0?1:k))},S={width:.5*(M.x-w.x),height:.5*(M.y-w.y)};u=Math.min(s/S.width,l/S.height),d={x:(M.x+w.x)*-.5,y:(M.y+w.y)*-.5}}i.borderWidth=n.getMaxBorderWidth(c.data),i.outerRadius=Math.max((u-i.borderWidth)/2,0),i.innerRadius=Math.max(h?i.outerRadius/100*h:0,0),i.radiusLength=(i.outerRadius-i.innerRadius)/i.getVisibleDatasetCount(),i.offsetX=d.x*i.outerRadius,i.offsetY=d.y*i.outerRadius,c.total=n.calculateTotal(),n.outerRadius=i.outerRadius-i.radiusLength*n.getRingIndex(n.index),n.innerRadius=Math.max(n.outerRadius-i.radiusLength,0),e.each(c.data,function(e,i){n.updateElement(e,i,t)})},updateElement:function(t,n,i){var a=this,r=a.chart,o=r.chartArea,s=r.options,l=s.animation,u=(o.left+o.right)/2,d=(o.top+o.bottom)/2,c=s.rotation,h=s.rotation,f=a.getDataset(),g=i&&l.animateRotate?0:t.hidden?0:a.calculateCircumference(f.data[n])*(s.circumference/(2*Math.PI)),p=i&&l.animateScale?0:a.innerRadius,m=i&&l.animateScale?0:a.outerRadius,v=e.getValueAtIndexOrDefault;e.extend(t,{_datasetIndex:a.index,_index:n,_model:{x:u+r.offsetX,y:d+r.offsetY,startAngle:c,endAngle:h,circumference:g,outerRadius:m,innerRadius:p,label:v(f.label,n,r.data.labels[n])}});var y=t._model;this.removeHoverStyle(t),i&&l.animateRotate||(0===n?y.startAngle=s.rotation:y.startAngle=a.getMeta().data[n-1]._model.endAngle,y.endAngle=y.startAngle+y.circumference),t.pivot()},removeHoverStyle:function(e){t.DatasetController.prototype.removeHoverStyle.call(this,e,this.chart.options.elements.arc)},calculateTotal:function(){var t,n=this.getDataset(),i=this.getMeta(),a=0;return e.each(i.data,function(e,i){t=n.data[i],isNaN(t)||e.hidden||(a+=Math.abs(t))}),a},calculateCircumference:function(t){var e=this.getMeta().total;return e>0&&!isNaN(t)?2*Math.PI*(t/e):0},getMaxBorderWidth:function(t){for(var e,n,i=0,a=this.index,r=t.length,o=0;oi?e:i,i=n>i?n:i;return i}})}},{}],18:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){return n.getValueOrDefault(t.showLine,e.showLines)}var n=t.helpers;t.defaults.line={showLines:!0,spanGaps:!1,hover:{mode:"label"},scales:{xAxes:[{type:"category",id:"x-axis-0"}],yAxes:[{type:"linear",id:"y-axis-0"}]}},t.controllers.line=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,update:function(t){var i,a,r,o=this,s=o.getMeta(),l=s.dataset,u=s.data||[],d=o.chart.options,c=d.elements.line,h=o.getScaleForId(s.yAxisID),f=o.getDataset(),g=e(f,d);for(g&&(r=l.custom||{},void 0!==f.tension&&void 0===f.lineTension&&(f.lineTension=f.tension),l._scale=h,l._datasetIndex=o.index,l._children=u,l._model={spanGaps:f.spanGaps?f.spanGaps:d.spanGaps,tension:r.tension?r.tension:n.getValueOrDefault(f.lineTension,c.tension),backgroundColor:r.backgroundColor?r.backgroundColor:f.backgroundColor||c.backgroundColor,borderWidth:r.borderWidth?r.borderWidth:f.borderWidth||c.borderWidth,borderColor:r.borderColor?r.borderColor:f.borderColor||c.borderColor,borderCapStyle:r.borderCapStyle?r.borderCapStyle:f.borderCapStyle||c.borderCapStyle,borderDash:r.borderDash?r.borderDash:f.borderDash||c.borderDash,borderDashOffset:r.borderDashOffset?r.borderDashOffset:f.borderDashOffset||c.borderDashOffset,borderJoinStyle:r.borderJoinStyle?r.borderJoinStyle:f.borderJoinStyle||c.borderJoinStyle,fill:r.fill?r.fill:void 0!==f.fill?f.fill:c.fill,steppedLine:r.steppedLine?r.steppedLine:n.getValueOrDefault(f.steppedLine,c.stepped),cubicInterpolationMode:r.cubicInterpolationMode?r.cubicInterpolationMode:n.getValueOrDefault(f.cubicInterpolationMode,c.cubicInterpolationMode)},l.pivot()),i=0,a=u.length;i');var n=t.data,i=n.datasets,a=n.labels;if(i.length)for(var r=0;r'),a[r]&&e.push(a[r]),e.push("");return e.push(""),e.join("")},legend:{labels:{generateLabels:function(t){var n=t.data;return n.labels.length&&n.datasets.length?n.labels.map(function(i,a){var r=t.getDatasetMeta(0),o=n.datasets[0],s=r.data[a],l=s.custom||{},u=e.getValueAtIndexOrDefault,d=t.options.elements.arc,c=l.backgroundColor?l.backgroundColor:u(o.backgroundColor,a,d.backgroundColor),h=l.borderColor?l.borderColor:u(o.borderColor,a,d.borderColor),f=l.borderWidth?l.borderWidth:u(o.borderWidth,a,d.borderWidth);return{text:i,fillStyle:c,strokeStyle:h,lineWidth:f,hidden:isNaN(o.data[a])||r.data[a].hidden,index:a}}):[]}},onClick:function(t,e){var n,i,a,r=e.index,o=this.chart;for(n=0,i=(o.data.datasets||[]).length;n0&&!isNaN(t)?2*Math.PI/e:0}})}},{}],20:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.radar={aspectRatio:1,scale:{type:"radialLinear"},elements:{line:{tension:0}}},t.controllers.radar=t.DatasetController.extend({datasetElementType:t.elements.Line,dataElementType:t.elements.Point,linkScales:e.noop,update:function(t){var n=this,i=n.getMeta(),a=i.dataset,r=i.data,o=a.custom||{},s=n.getDataset(),l=n.chart.options.elements.line,u=n.chart.scale;void 0!==s.tension&&void 0===s.lineTension&&(s.lineTension=s.tension),e.extend(i.dataset,{_datasetIndex:n.index,_scale:u,_children:r,_loop:!0,_model:{tension:o.tension?o.tension:e.getValueOrDefault(s.lineTension,l.tension),backgroundColor:o.backgroundColor?o.backgroundColor:s.backgroundColor||l.backgroundColor,borderWidth:o.borderWidth?o.borderWidth:s.borderWidth||l.borderWidth,borderColor:o.borderColor?o.borderColor:s.borderColor||l.borderColor,fill:o.fill?o.fill:void 0!==s.fill?s.fill:l.fill,borderCapStyle:o.borderCapStyle?o.borderCapStyle:s.borderCapStyle||l.borderCapStyle,borderDash:o.borderDash?o.borderDash:s.borderDash||l.borderDash,borderDashOffset:o.borderDashOffset?o.borderDashOffset:s.borderDashOffset||l.borderDashOffset,borderJoinStyle:o.borderJoinStyle?o.borderJoinStyle:s.borderJoinStyle||l.borderJoinStyle}}),i.dataset.pivot(),e.each(r,function(e,i){n.updateElement(e,i,t)},n),n.updateBezierControlPoints()},updateElement:function(t,n,i){var a=this,r=t.custom||{},o=a.getDataset(),s=a.chart.scale,l=a.chart.options.elements.point,u=s.getPointPositionForValue(n,o.data[n]);void 0!==o.radius&&void 0===o.pointRadius&&(o.pointRadius=o.radius),void 0!==o.hitRadius&&void 0===o.pointHitRadius&&(o.pointHitRadius=o.hitRadius),e.extend(t,{_datasetIndex:a.index,_index:n,_scale:s,_model:{x:i?s.xCenter:u.x,y:i?s.yCenter:u.y,tension:r.tension?r.tension:e.getValueOrDefault(o.lineTension,a.chart.options.elements.line.tension),radius:r.radius?r.radius:e.getValueAtIndexOrDefault(o.pointRadius,n,l.radius),backgroundColor:r.backgroundColor?r.backgroundColor:e.getValueAtIndexOrDefault(o.pointBackgroundColor,n,l.backgroundColor),borderColor:r.borderColor?r.borderColor:e.getValueAtIndexOrDefault(o.pointBorderColor,n,l.borderColor),borderWidth:r.borderWidth?r.borderWidth:e.getValueAtIndexOrDefault(o.pointBorderWidth,n,l.borderWidth),pointStyle:r.pointStyle?r.pointStyle:e.getValueAtIndexOrDefault(o.pointStyle,n,l.pointStyle),hitRadius:r.hitRadius?r.hitRadius:e.getValueAtIndexOrDefault(o.pointHitRadius,n,l.hitRadius)}}),t._model.skip=r.skip?r.skip:isNaN(t._model.x)||isNaN(t._model.y)},updateBezierControlPoints:function(){var t=this.chart.chartArea,n=this.getMeta();e.each(n.data,function(i,a){var r=i._model,o=e.splineCurve(e.previousItem(n.data,a,!0)._model,r,e.nextItem(n.data,a,!0)._model,r.tension);r.controlPointPreviousX=Math.max(Math.min(o.previous.x,t.right),t.left),r.controlPointPreviousY=Math.max(Math.min(o.previous.y,t.bottom),t.top),r.controlPointNextX=Math.max(Math.min(o.next.x,t.right),t.left),r.controlPointNextY=Math.max(Math.min(o.next.y,t.bottom),t.top),i.pivot()})},setHoverStyle:function(t){var n=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},a=t._index,r=t._model;r.radius=i.hoverRadius?i.hoverRadius:e.getValueAtIndexOrDefault(n.pointHoverRadius,a,this.chart.options.elements.point.hoverRadius),r.backgroundColor=i.hoverBackgroundColor?i.hoverBackgroundColor:e.getValueAtIndexOrDefault(n.pointHoverBackgroundColor,a,e.getHoverColor(r.backgroundColor)),r.borderColor=i.hoverBorderColor?i.hoverBorderColor:e.getValueAtIndexOrDefault(n.pointHoverBorderColor,a,e.getHoverColor(r.borderColor)),r.borderWidth=i.hoverBorderWidth?i.hoverBorderWidth:e.getValueAtIndexOrDefault(n.pointHoverBorderWidth,a,r.borderWidth)},removeHoverStyle:function(t){var n=this.chart.data.datasets[t._datasetIndex],i=t.custom||{},a=t._index,r=t._model,o=this.chart.options.elements.point;r.radius=i.radius?i.radius:e.getValueAtIndexOrDefault(n.pointRadius,a,o.radius),r.backgroundColor=i.backgroundColor?i.backgroundColor:e.getValueAtIndexOrDefault(n.pointBackgroundColor,a,o.backgroundColor),r.borderColor=i.borderColor?i.borderColor:e.getValueAtIndexOrDefault(n.pointBorderColor,a,o.borderColor),r.borderWidth=i.borderWidth?i.borderWidth:e.getValueAtIndexOrDefault(n.pointBorderWidth,a,o.borderWidth)}})}},{}],21:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers;t.defaults.global.animation={duration:1e3,easing:"easeOutQuart",onProgress:e.noop,onComplete:e.noop},t.Animation=t.Element.extend({chart:null,currentStep:0,numSteps:60,easing:"",render:null,onAnimationProgress:null,onAnimationComplete:null}),t.animationService={frameDuration:17,animations:[],dropFrames:0,request:null,addAnimation:function(t,e,n,i){var a,r,o=this.animations;for(e.chart=t,i||(t.animating=!0),a=0,r=o.length;a1&&(n=Math.floor(t.dropFrames),t.dropFrames=t.dropFrames%1),t.advance(1+n);var i=Date.now();t.dropFrames+=(i-e)/t.frameDuration,t.animations.length>0&&t.requestAnimationFrame()},advance:function(t){for(var n,i,a=this.animations,r=0;r=n.numSteps?(e.callback(n.onAnimationComplete,[n],i),i.animating=!1,a.splice(r,1)):++r}},Object.defineProperty(t.Animation.prototype,"animationObject",{get:function(){return this}}),Object.defineProperty(t.Animation.prototype,"chartInstance",{get:function(){return this.chart},set:function(t){this.chart=t}})}},{}],22:[function(t,e,n){"use strict";e.exports=function(t){var e=t.canvasHelpers={};e.drawPoint=function(e,n,i,a,r){var o,s,l,u,d,c;if("object"==typeof n&&(o=n.toString(),"[object HTMLImageElement]"===o||"[object HTMLCanvasElement]"===o))return void e.drawImage(n,a-n.width/2,r-n.height/2,n.width,n.height);if(!(isNaN(i)||i<=0)){switch(n){default:e.beginPath(),e.arc(a,r,i,0,2*Math.PI),e.closePath(),e.fill();break;case"triangle":e.beginPath(),s=3*i/Math.sqrt(3),d=s*Math.sqrt(3)/2,e.moveTo(a-s/2,r+d/3),e.lineTo(a+s/2,r+d/3),e.lineTo(a,r-2*d/3),e.closePath(),e.fill();break;case"rect":c=1/Math.SQRT2*i,e.beginPath(),e.fillRect(a-c,r-c,2*c,2*c),e.strokeRect(a-c,r-c,2*c,2*c);break;case"rectRounded":var h=i/Math.SQRT2,f=a-h,g=r-h,p=Math.SQRT2*i;t.helpers.drawRoundedRectangle(e,f,g,p,p,i/2),e.fill();break;case"rectRot":c=1/Math.SQRT2*i,e.beginPath(),e.moveTo(a-c,r),e.lineTo(a,r+c),e.lineTo(a+c,r),e.lineTo(a,r-c),e.closePath(),e.fill();break;case"cross":e.beginPath(),e.moveTo(a,r+i),e.lineTo(a,r-i),e.moveTo(a-i,r),e.lineTo(a+i,r),e.closePath();break;case"crossRot":e.beginPath(),l=Math.cos(Math.PI/4)*i,u=Math.sin(Math.PI/4)*i,e.moveTo(a-l,r-u),e.lineTo(a+l,r+u),e.moveTo(a-l,r+u),e.lineTo(a+l,r-u),e.closePath();break;case"star":e.beginPath(),e.moveTo(a,r+i),e.lineTo(a,r-i),e.moveTo(a-i,r),e.lineTo(a+i,r),l=Math.cos(Math.PI/4)*i,u=Math.sin(Math.PI/4)*i,e.moveTo(a-l,r-u),e.lineTo(a+l,r+u),e.moveTo(a-l,r+u),e.lineTo(a+l,r-u),e.closePath();break;case"line":e.beginPath(),e.moveTo(a-i,r),e.lineTo(a+i,r),e.closePath();break;case"dash":e.beginPath(),e.moveTo(a,r),e.lineTo(a+i,r),e.closePath()}e.stroke()}},e.clipArea=function(t,e){t.save(),t.beginPath(),t.rect(e.left,e.top,e.right-e.left,e.bottom-e.top),t.clip()},e.unclipArea=function(t){t.restore()},e.lineTo=function(t,e,n,i){return n.steppedLine?("after"===n.steppedLine?t.lineTo(e.x,n.y):t.lineTo(n.x,e.y),void t.lineTo(n.x,n.y)):n.tension?void t.bezierCurveTo(i?e.controlPointPreviousX:e.controlPointNextX,i?e.controlPointPreviousY:e.controlPointNextY,i?n.controlPointNextX:n.controlPointPreviousX,i?n.controlPointNextY:n.controlPointPreviousY,n.x,n.y):void t.lineTo(n.x,n.y)},t.helpers.canvas=e}},{}],23:[function(t,e,n){"use strict";e.exports=function(t){function e(e){e=e||{};var n=e.data=e.data||{};return n.datasets=n.datasets||[],n.labels=n.labels||[],e.options=a.configMerge(t.defaults.global,t.defaults[e.type],e.options||{}),e}function n(t){var e=t.options;e.scale?t.scale.options=e.scale:e.scales&&e.scales.xAxes.concat(e.scales.yAxes).forEach(function(e){t.scales[e.id].options=e}),t.tooltip._options=e.tooltips}function i(t){return"top"===t||"bottom"===t}var a=t.helpers,r=t.plugins,o=t.platform;t.types={},t.instances={},t.controllers={},a.extend(t.prototype,{construct:function(n,i){var r=this;i=e(i);var s=o.acquireContext(n,i),l=s&&s.canvas,u=l&&l.height,d=l&&l.width;return r.id=a.uid(),r.ctx=s,r.canvas=l,r.config=i,r.width=d,r.height=u,r.aspectRatio=u?d/u:null,r.options=i.options,r._bufferedRender=!1,r.chart=r,r.controller=r,t.instances[r.id]=r,Object.defineProperty(r,"data",{get:function(){return r.config.data},set:function(t){r.config.data=t}}),s&&l?(r.initialize(),void r.update()):void console.error("Failed to create chart: can't acquire context from the given item")},initialize:function(){var t=this;return r.notify(t,"beforeInit"),a.retinaScale(t),t.bindEvents(),t.options.responsive&&t.resize(!0),t.ensureScalesHaveIDs(),t.buildScales(),t.initToolTip(),r.notify(t,"afterInit"),t},clear:function(){return a.clear(this),this},stop:function(){return t.animationService.cancelAnimation(this),this},resize:function(t){var e=this,n=e.options,i=e.canvas,o=n.maintainAspectRatio&&e.aspectRatio||null,s=Math.floor(a.getMaximumWidth(i)),l=Math.floor(o?s/o:a.getMaximumHeight(i));if((e.width!==s||e.height!==l)&&(i.width=e.width=s,i.height=e.height=l,i.style.width=s+"px",i.style.height=l+"px",a.retinaScale(e),!t)){var u={width:s,height:l};r.notify(e,"resize",[u]),e.options.onResize&&e.options.onResize(e,u),e.stop(),e.update(e.options.responsiveAnimationDuration)}},ensureScalesHaveIDs:function(){var t=this.options,e=t.scales||{},n=t.scale;a.each(e.xAxes,function(t,e){t.id=t.id||"x-axis-"+e}),a.each(e.yAxes,function(t,e){t.id=t.id||"y-axis-"+e}),n&&(n.id=n.id||"scale")},buildScales:function(){var e=this,n=e.options,r=e.scales={},o=[];n.scales&&(o=o.concat((n.scales.xAxes||[]).map(function(t){return{options:t,dtype:"category",dposition:"bottom"}}),(n.scales.yAxes||[]).map(function(t){return{options:t,dtype:"linear",dposition:"left"}}))),n.scale&&o.push({options:n.scale,dtype:"radialLinear",isDefault:!0,dposition:"chartArea"}),a.each(o,function(n){var o=n.options,s=a.getValueOrDefault(o.type,n.dtype),l=t.scaleService.getScaleConstructor(s);if(l){i(o.position)!==i(n.dposition)&&(o.position=n.dposition);var u=new l({id:o.id,options:o,ctx:e.ctx,chart:e});r[u.id]=u,n.isDefault&&(e.scale=u)}}),t.scaleService.addScalesToLayout(this)},buildOrUpdateControllers:function(){var e=this,n=[],i=[];if(a.each(e.data.datasets,function(a,r){var o=e.getDatasetMeta(r);if(o.type||(o.type=a.type||e.config.type),n.push(o.type),o.controller)o.controller.updateIndex(r);else{var s=t.controllers[o.type];if(void 0===s)throw new Error('"'+o.type+'" is not a chart type.');o.controller=new s(e,r),i.push(o.controller)}},e),n.length>1)for(var r=1;r=0;--n)e.isDatasetVisible(n)&&e.drawDataset(n,t);r.notify(e,"afterDatasetsDraw",[t])}},drawDataset:function(t,e){var n=this,i=n.getDatasetMeta(t),a={meta:i,index:t,easingValue:e};r.notify(n,"beforeDatasetDraw",[a])!==!1&&(i.controller.draw(e),r.notify(n,"afterDatasetDraw",[a]))},getElementAtEvent:function(e){return t.Interaction.modes.single(this,e)},getElementsAtEvent:function(e){return t.Interaction.modes.label(this,e,{intersect:!0})},getElementsAtXAxis:function(e){return t.Interaction.modes["x-axis"](this,e,{intersect:!0})},getElementsAtEventForMode:function(e,n,i){var a=t.Interaction.modes[n];return"function"==typeof a?a(this,e,i):[]},getDatasetAtEvent:function(e){return t.Interaction.modes.dataset(this,e,{intersect:!0})},getDatasetMeta:function(t){var e=this,n=e.data.datasets[t];n._meta||(n._meta={});var i=n._meta[e.id];return i||(i=n._meta[e.id]={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null}),i},getVisibleDatasetCount:function(){for(var t=0,e=0,n=this.data.datasets.length;e0||(a.forEach(function(e){delete t[e]}),delete t._chartjs)}}var i=t.helpers,a=["push","pop","shift","splice","unshift"];t.DatasetController=function(t,e){this.initialize(t,e)},i.extend(t.DatasetController.prototype,{datasetElementType:null,dataElementType:null,initialize:function(t,e){var n=this;n.chart=t,n.index=e,n.linkScales(),n.addElements()},updateIndex:function(t){this.index=t},linkScales:function(){var t=this,e=t.getMeta(),n=t.getDataset();null===e.xAxisID&&(e.xAxisID=n.xAxisID||t.chart.options.scales.xAxes[0].id),null===e.yAxisID&&(e.yAxisID=n.yAxisID||t.chart.options.scales.yAxes[0].id)},getDataset:function(){return this.chart.data.datasets[this.index]},getMeta:function(){return this.chart.getDatasetMeta(this.index)},getScaleForId:function(t){return this.chart.scales[t]},reset:function(){this.update(!0)},destroy:function(){this._data&&n(this._data,this)},createMetaDataset:function(){var t=this,e=t.datasetElementType;return e&&new e({_chart:t.chart,_datasetIndex:t.index})},createMetaData:function(t){var e=this,n=e.dataElementType;return n&&new n({_chart:e.chart,_datasetIndex:e.index,_index:t})},addElements:function(){var t,e,n=this,i=n.getMeta(),a=n.getDataset().data||[],r=i.data;for(t=0,e=a.length;ti&&t.insertElements(i,a-i)},insertElements:function(t,e){for(var n=0;n=0;a--)e.call(n,t[a],a);else for(a=0;a=i[n].length||!i[n][a].type?i[n].push(r.configMerge(s,e)):e.type&&e.type!==i[n][a].type?i[n][a]=r.configMerge(i[n][a],s,e):i[n][a]=r.configMerge(i[n][a],e)}):(i[n]=[],r.each(e,function(e){var a=r.getValueOrDefault(e.type,"xAxes"===n?"category":"linear");i[n].push(r.configMerge(t.scaleService.getScaleDefaults(a),e))})):i.hasOwnProperty(n)&&"object"==typeof i[n]&&null!==i[n]&&"object"==typeof e?i[n]=r.configMerge(i[n],e):i[n]=e}),i},r.getValueAtIndexOrDefault=function(t,e,n){return void 0===t||null===t?n:r.isArray(t)?e=0;i--){var a=t[i];if(e(a))return a}},r.inherits=function(t){var e=this,n=t&&t.hasOwnProperty("constructor")?t.constructor:function(){return e.apply(this,arguments)},i=function(){this.constructor=n};return i.prototype=e.prototype,n.prototype=new i,n.extend=r.inherits,t&&r.extend(n.prototype,t),n.__super__=e.prototype,n},r.noop=function(){},r.uid=function(){var t=0;return function(){return t++}}(),r.isNumber=function(t){return!isNaN(parseFloat(t))&&isFinite(t)},r.almostEquals=function(t,e,n){return Math.abs(t-e)t},r.max=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.max(t,e)},Number.NEGATIVE_INFINITY)},r.min=function(t){return t.reduce(function(t,e){return isNaN(e)?t:Math.min(t,e)},Number.POSITIVE_INFINITY)},r.sign=Math.sign?function(t){return Math.sign(t)}:function(t){return t=+t,0===t||isNaN(t)?t:t>0?1:-1},r.log10=Math.log10?function(t){return Math.log10(t)}:function(t){return Math.log(t)/Math.LN10},r.toRadians=function(t){return t*(Math.PI/180)},r.toDegrees=function(t){return t*(180/Math.PI)},r.getAngleFromPoint=function(t,e){var n=e.x-t.x,i=e.y-t.y,a=Math.sqrt(n*n+i*i),r=Math.atan2(i,n);return r<-.5*Math.PI&&(r+=2*Math.PI),{angle:r,distance:a}},r.distanceBetweenPoints=function(t,e){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))},r.aliasPixel=function(t){return t%2===0?0:.5},r.splineCurve=function(t,e,n,i){var a=t.skip?e:t,r=e,o=n.skip?e:n,s=Math.sqrt(Math.pow(r.x-a.x,2)+Math.pow(r.y-a.y,2)),l=Math.sqrt(Math.pow(o.x-r.x,2)+Math.pow(o.y-r.y,2)),u=s/(s+l),d=l/(s+l);u=isNaN(u)?0:u,d=isNaN(d)?0:d;var c=i*u,h=i*d;return{previous:{x:r.x-c*(o.x-a.x),y:r.y-c*(o.y-a.y)},next:{x:r.x+h*(o.x-a.x),y:r.y+h*(o.y-a.y)}}},r.EPSILON=Number.EPSILON||1e-14,r.splineCurveMonotone=function(t){var e,n,i,a,o=(t||[]).map(function(t){return{model:t._model,deltaK:0,mK:0}}),s=o.length;for(e=0;e0?o[e-1]:null,a=e0?o[e-1]:null,a=e=t.length-1?t[0]:t[e+1]:e>=t.length-1?t[t.length-1]:t[e+1]},r.previousItem=function(t,e,n){return n?e<=0?t[t.length-1]:t[e-1]:e<=0?t[0]:t[e-1]},r.niceNum=function(t,e){var n,i=Math.floor(r.log10(t)),a=t/Math.pow(10,i);return n=e?a<1.5?1:a<3?2:a<7?5:10:a<=1?1:a<=2?2:a<=5?5:10,n*Math.pow(10,i)};var o=r.easingEffects={linear:function(t){return t},easeInQuad:function(t){return t*t},easeOutQuad:function(t){return-1*t*(t-2)},easeInOutQuad:function(t){return(t/=.5)<1?.5*t*t:-.5*(--t*(t-2)-1)},easeInCubic:function(t){return t*t*t},easeOutCubic:function(t){return 1*((t=t/1-1)*t*t+1)},easeInOutCubic:function(t){return(t/=.5)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},easeInQuart:function(t){return t*t*t*t},easeOutQuart:function(t){return-1*((t=t/1-1)*t*t*t-1)},easeInOutQuart:function(t){return(t/=.5)<1?.5*t*t*t*t:-.5*((t-=2)*t*t*t-2)},easeInQuint:function(t){return 1*(t/=1)*t*t*t*t},easeOutQuint:function(t){return 1*((t=t/1-1)*t*t*t*t+1)},easeInOutQuint:function(t){return(t/=.5)<1?.5*t*t*t*t*t:.5*((t-=2)*t*t*t*t+2)},easeInSine:function(t){return-1*Math.cos(t/1*(Math.PI/2))+1},easeOutSine:function(t){return 1*Math.sin(t/1*(Math.PI/2))},easeInOutSine:function(t){return-.5*(Math.cos(Math.PI*t/1)-1)},easeInExpo:function(t){return 0===t?1:1*Math.pow(2,10*(t/1-1))},easeOutExpo:function(t){return 1===t?1:1*(-Math.pow(2,-10*t/1)+1)},easeInOutExpo:function(t){return 0===t?0:1===t?1:(t/=.5)<1?.5*Math.pow(2,10*(t-1)):.5*(-Math.pow(2,-10*--t)+2)},easeInCirc:function(t){return t>=1?t:-1*(Math.sqrt(1-(t/=1)*t)-1)},easeOutCirc:function(t){return 1*Math.sqrt(1-(t=t/1-1)*t)},easeInOutCirc:function(t){return(t/=.5)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},easeInElastic:function(t){var e=1.70158,n=0,i=1;return 0===t?0:1===(t/=1)?1:(n||(n=.3),i0?(n=l[0].clientX,i=l[0].clientY):(n=a.clientX,i=a.clientY);var u=parseFloat(r.getStyle(o,"padding-left")),d=parseFloat(r.getStyle(o,"padding-top")),c=parseFloat(r.getStyle(o,"padding-right")),h=parseFloat(r.getStyle(o,"padding-bottom")),f=s.right-s.left-u-c,g=s.bottom-s.top-d-h;return n=Math.round((n-s.left-u)/f*o.width/e.currentDevicePixelRatio),i=Math.round((i-s.top-d)/g*o.height/e.currentDevicePixelRatio),{x:n,y:i}},r.addEvent=function(t,e,n){t.addEventListener?t.addEventListener(e,n):t.attachEvent?t.attachEvent("on"+e,n):t["on"+e]=n},r.removeEvent=function(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent?t.detachEvent("on"+e,n):t["on"+e]=r.noop},r.getConstraintWidth=function(t){return a(t,"max-width","clientWidth")},r.getConstraintHeight=function(t){return a(t,"max-height","clientHeight")},r.getMaximumWidth=function(t){var e=t.parentNode,n=parseInt(r.getStyle(e,"padding-left"),10),i=parseInt(r.getStyle(e,"padding-right"),10),a=e.clientWidth-n-i,o=r.getConstraintWidth(t);return isNaN(o)?a:Math.min(a,o)},r.getMaximumHeight=function(t){var e=t.parentNode,n=parseInt(r.getStyle(e,"padding-top"),10),i=parseInt(r.getStyle(e,"padding-bottom"),10),a=e.clientHeight-n-i,o=r.getConstraintHeight(t);return isNaN(o)?a:Math.min(a,o)},r.getStyle=function(t,e){return t.currentStyle?t.currentStyle[e]:document.defaultView.getComputedStyle(t,null).getPropertyValue(e)},r.retinaScale=function(t){var e=t.currentDevicePixelRatio=window.devicePixelRatio||1;if(1!==e){var n=t.canvas,i=t.height,a=t.width;n.height=i*e,n.width=a*e,t.ctx.scale(e,e),n.style.height=i+"px",n.style.width=a+"px"}},r.clear=function(t){t.ctx.clearRect(0,0,t.width,t.height)},r.fontString=function(t,e,n){return e+" "+t+"px "+n},r.longestText=function(t,e,n,i){i=i||{};var a=i.data=i.data||{},o=i.garbageCollect=i.garbageCollect||[];i.font!==e&&(a=i.data={},o=i.garbageCollect=[],i.font=e),t.font=e;var s=0;r.each(n,function(e){void 0!==e&&null!==e&&r.isArray(e)!==!0?s=r.measureText(t,a,o,s,e):r.isArray(e)&&r.each(e,function(e){void 0===e||null===e||r.isArray(e)||(s=r.measureText(t,a,o,s,e))})});var l=o.length/2;if(l>n.length){for(var u=0;ui&&(i=r),i},r.numberOfLabelLines=function(t){var e=1;return r.each(t,function(t){r.isArray(t)&&t.length>e&&(e=t.length)}),e},r.drawRoundedRectangle=function(t,e,n,i,a,r){t.beginPath(),t.moveTo(e+r,n),t.lineTo(e+i-r,n),t.quadraticCurveTo(e+i,n,e+i,n+r),t.lineTo(e+i,n+a-r),t.quadraticCurveTo(e+i,n+a,e+i-r,n+a),t.lineTo(e+r,n+a),t.quadraticCurveTo(e,n+a,e,n+a-r),t.lineTo(e,n+r),t.quadraticCurveTo(e,n,e+r,n),t.closePath()},r.color=i?function(e){return e instanceof CanvasGradient&&(e=t.defaults.global.defaultColor),i(e)}:function(t){return console.error("Color.js not found!"),t},r.isArray=Array.isArray?function(t){return Array.isArray(t)}:function(t){return"[object Array]"===Object.prototype.toString.call(t)},r.arrayEquals=function(t,e){var n,i,a,o;if(!t||!e||t.length!==e.length)return!1;for(n=0,i=t.length;n0&&(s=t.getDatasetMeta(s[0]._datasetIndex).data),s},"x-axis":function(t,e){return r(t,e,!0)},point:function(t,n){var a=e(n,t);return i(t,a)},nearest:function(t,n,i){var r=e(n,t),o=a(t,r,i.intersect);return o.length>1&&o.sort(function(t,e){var n=t.getArea(),i=e.getArea(),a=n-i;return 0===a&&(a=t._datasetIndex-e._datasetIndex),a}),o.slice(0,1)},x:function(t,i,a){var r=e(i,t),o=[],s=!1;return n(t,function(t){t.inXRange(r.x)&&o.push(t),t.inRange(r.x,r.y)&&(s=!0)}),a.intersect&&!s&&(o=[]),o},y:function(t,i,a){var r=e(i,t),o=[],s=!1;return n(t,function(t){t.inYRange(r.y)&&o.push(t),t.inRange(r.x,r.y)&&(s=!0)}),a.intersect&&!s&&(o=[]),o}}}}},{}],28:[function(t,e,n){"use strict";e.exports=function(){var t=function(t,e){return this.construct(t,e),this};return t.defaults={global:{responsive:!0,responsiveAnimationDuration:0,maintainAspectRatio:!0,events:["mousemove","mouseout","click","touchstart","touchmove"],hover:{onHover:null,mode:"nearest",intersect:!0,animationDuration:400},onClick:null,defaultColor:"rgba(0,0,0,0.1)",defaultFontColor:"#666",defaultFontFamily:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",defaultFontSize:12,defaultFontStyle:"normal",showLines:!0,elements:{},legendCallback:function(t){var e=[];e.push('
      ');for(var n=0;n'),t.data.datasets[n].label&&e.push(t.data.datasets[n].label),e.push("");return e.push("
    "),e.join("")}}},t.Chart=t,t}},{}],29:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){return i.where(t,function(t){return t.position===e})}function n(t,e){t.forEach(function(t,e){return t._tmpIndex_=e,t}),t.sort(function(t,n){var i=e?n:t,a=e?t:n;return i.weight===a.weight?i._tmpIndex_-a._tmpIndex_:i.weight-a.weight}),t.forEach(function(t){delete t._tmpIndex_})}var i=t.helpers;t.layoutService={defaults:{},addBox:function(t,e){t.boxes||(t.boxes=[]),e.fullWidth=e.fullWidth||!1,e.position=e.position||"top",e.weight=e.weight||0,t.boxes.push(e)},removeBox:function(t,e){var n=t.boxes?t.boxes.indexOf(e):-1;n!==-1&&t.boxes.splice(n,1)},configure:function(t,e,n){for(var i,a=["fullWidth","position","weight"],r=a.length,o=0;oc&&ot.maxHeight){o--;break}o++,d=s*u}t.labelRotation=o},afterCalculateTickRotation:function(){i.callback(this.options.afterCalculateTickRotation,[this])},beforeFit:function(){i.callback(this.options.beforeFit,[this])},fit:function(){var t=this,a=t.minSize={width:0,height:0},r=t.options,o=r.ticks,s=r.scaleLabel,l=r.gridLines,u=r.display,d=t.isHorizontal(),c=n(o),h=1.5*n(s).size,f=r.gridLines.tickMarkLength;if(d?a.width=t.isFullWidth()?t.maxWidth-t.margins.left-t.margins.right:t.maxWidth:a.width=u&&l.drawTicks?f:0,d?a.height=u&&l.drawTicks?f:0:a.height=t.maxHeight,s.display&&u&&(d?a.height+=h:a.width+=h),o.display&&u){var g=i.longestText(t.ctx,c.font,t.ticks,t.longestTextCache),p=i.numberOfLabelLines(t.ticks),m=.5*c.size;if(d){t.longestLabelWidth=g;var v=i.toRadians(t.labelRotation),y=Math.cos(v),b=Math.sin(v),x=b*g+c.size*p+m*p;a.height=Math.min(t.maxHeight,a.height+x),t.ctx.font=c.font;var _=t.ticks[0],k=e(t.ctx,_,c.font),w=t.ticks[t.ticks.length-1],M=e(t.ctx,w,c.font);0!==t.labelRotation?(t.paddingLeft="bottom"===r.position?y*k+3:y*m+3,t.paddingRight="bottom"===r.position?y*m+3:y*M+3):(t.paddingLeft=k/2+3,t.paddingRight=M/2+3)}else o.mirror?g=0:g+=t.options.ticks.padding,a.width=Math.min(t.maxWidth,a.width+g),t.paddingTop=c.size/2,t.paddingBottom=c.size/2}t.handleMargins(),t.width=a.width,t.height=a.height},handleMargins:function(){var t=this;t.margins&&(t.paddingLeft=Math.max(t.paddingLeft-t.margins.left,0),t.paddingTop=Math.max(t.paddingTop-t.margins.top,0),t.paddingRight=Math.max(t.paddingRight-t.margins.right,0),t.paddingBottom=Math.max(t.paddingBottom-t.margins.bottom,0))},afterFit:function(){i.callback(this.options.afterFit,[this])},isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},isFullWidth:function(){return this.options.fullWidth},getRightValue:function(t){return null===t||"undefined"==typeof t?NaN:"number"!=typeof t||isFinite(t)?"object"==typeof t?t instanceof Date||t.isValid?t:this.getRightValue(this.isHorizontal()?t.x:t.y):t:NaN},getLabelForIndex:i.noop,getPixelForValue:i.noop,getValueForPixel:i.noop,getPixelForTick:function(t,e){var n=this;if(n.isHorizontal()){var i=n.width-(n.paddingLeft+n.paddingRight),a=i/Math.max(n.ticks.length-(n.options.gridLines.offsetGridLines?0:1),1),r=a*t+n.paddingLeft;e&&(r+=a/2);var o=n.left+Math.round(r);return o+=n.isFullWidth()?n.margins.left:0}var s=n.height-(n.paddingTop+n.paddingBottom);return n.top+t*(s/(n.ticks.length-1))},getPixelForDecimal:function(t){var e=this;if(e.isHorizontal()){var n=e.width-(e.paddingLeft+e.paddingRight),i=n*t+e.paddingLeft,a=e.left+Math.round(i);return a+=e.isFullWidth()?e.margins.left:0}return e.top+t*e.height},getBasePixel:function(){return this.getPixelForValue(this.getBaseValue())},getBaseValue:function(){var t=this,e=t.min,n=t.max;return t.beginAtZero?0:e<0&&n<0?n:e>0&&n>0?e:0},draw:function(e){var a=this,r=a.options;if(r.display){var o,s,l=a.ctx,u=t.defaults.global,d=r.ticks,c=r.gridLines,h=r.scaleLabel,f=0!==a.labelRotation,g=d.autoSkip,p=a.isHorizontal();d.maxTicksLimit&&(s=d.maxTicksLimit);var m=i.getValueOrDefault(d.fontColor,u.defaultFontColor),v=n(d),y=c.drawTicks?c.tickMarkLength:0,b=i.getValueOrDefault(h.fontColor,u.defaultFontColor),x=n(h),_=i.toRadians(a.labelRotation),k=Math.cos(_),w=a.longestLabelWidth*k;l.fillStyle=m;var M=[];if(p){if(o=!1,(w+d.autoSkipPadding)*a.ticks.length>a.width-(a.paddingLeft+a.paddingRight)&&(o=1+Math.floor((w+d.autoSkipPadding)*a.ticks.length/(a.width-(a.paddingLeft+a.paddingRight)))),s&&a.ticks.length>s)for(;!o||a.ticks.length/(o||1)>s;)o||(o=1),o+=1;g||(o=!1)}var S="right"===r.position?a.left:a.right-y,D="right"===r.position?a.left+y:a.right,C="bottom"===r.position?a.top:a.bottom-y,P="bottom"===r.position?a.top+y:a.bottom;if(i.each(a.ticks,function(t,n){if(void 0!==t&&null!==t){var s=a.ticks.length===n+1,l=o>1&&n%o>0||n%o===0&&n+o>=a.ticks.length;if((!l||s)&&void 0!==t&&null!==t){var h,g,m,v;n===("undefined"!=typeof a.zeroLineIndex?a.zeroLineIndex:0)?(h=c.zeroLineWidth,g=c.zeroLineColor,m=c.zeroLineBorderDash,v=c.zeroLineBorderDashOffset):(h=i.getValueAtIndexOrDefault(c.lineWidth,n),g=i.getValueAtIndexOrDefault(c.color,n),m=i.getValueOrDefault(c.borderDash,u.borderDash),v=i.getValueOrDefault(c.borderDashOffset,u.borderDashOffset));var b,x,k,w,T,I,A,F,O,R,L="middle",V="middle";if(p){"bottom"===r.position?(V=f?"middle":"top",L=f?"right":"center",R=a.top+y):(V=f?"middle":"bottom",L=f?"left":"center",R=a.bottom-y);var W=a.getPixelForTick(n)+i.aliasPixel(h);O=a.getPixelForTick(n,c.offsetGridLines)+d.labelOffset,b=k=T=A=W,x=C,w=P,I=e.top,F=e.bottom}else{var Y,z="left"===r.position,N=d.padding;d.mirror?(L=z?"left":"right",Y=N):(L=z?"right":"left",Y=y+N),O=z?a.right-Y:a.left+Y;var B=a.getPixelForTick(n);B+=i.aliasPixel(h),R=a.getPixelForTick(n,c.offsetGridLines),b=S,k=D,T=e.left,A=e.right,x=w=I=F=B}M.push({tx1:b,ty1:x,tx2:k,ty2:w,x1:T,y1:I,x2:A,y2:F,labelX:O,labelY:R,glWidth:h,glColor:g,glBorderDash:m,glBorderDashOffset:v,rotation:-1*_,label:t,textBaseline:V,textAlign:L})}}}),i.each(M,function(t){if(c.display&&(l.save(),l.lineWidth=t.glWidth,l.strokeStyle=t.glColor,l.setLineDash&&(l.setLineDash(t.glBorderDash),l.lineDashOffset=t.glBorderDashOffset),l.beginPath(),c.drawTicks&&(l.moveTo(t.tx1,t.ty1),l.lineTo(t.tx2,t.ty2)),c.drawOnChartArea&&(l.moveTo(t.x1,t.y1),l.lineTo(t.x2,t.y2)),l.stroke(),l.restore()),d.display){l.save(),l.translate(t.labelX,t.labelY),l.rotate(t.rotation),l.font=v.font,l.textBaseline=t.textBaseline,l.textAlign=t.textAlign;var e=t.label;if(i.isArray(e))for(var n=0,a=0;n0)i=t.stepSize;else{var r=e.niceNum(n.max-n.min,!1);i=e.niceNum(r/(t.maxTicks-1),!0)}var o=Math.floor(n.min/i)*i,s=Math.ceil(n.max/i)*i;t.min&&t.max&&t.stepSize&&e.almostWhole((t.max-t.min)/t.stepSize,i/1e3)&&(o=t.min,s=t.max);var l=(s-o)/i;l=e.almostEquals(l,Math.round(l),i/1e3)?Math.round(l):Math.ceil(l),a.push(void 0!==t.min?t.min:o);for(var u=1;u3?i[2]-i[1]:i[1]-i[0];Math.abs(a)>1&&t!==Math.floor(t)&&(a=t-Math.floor(t));var r=e.log10(Math.abs(a)),o="";if(0!==t){var s=-1*Math.floor(r);s=Math.max(Math.min(s,20),0),o=t.toFixed(s)}else o="0";return o},logarithmic:function(t,n,i){var a=t/Math.pow(10,Math.floor(e.log10(t)));return 0===t?"0":1===a||2===a||5===a||0===n||n===i.length-1?t.toExponential():""}}}}},{}],34:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){var n=l.color(t);return n.alpha(e*n.alpha()).rgbaString()}function n(t,e){return e&&(l.isArray(e)?Array.prototype.push.apply(t,e):t.push(e)),t}function i(t){var e=t._xScale,n=t._yScale||t._scale,i=t._index,a=t._datasetIndex;return{xLabel:e?e.getLabelForIndex(i,a):"",yLabel:n?n.getLabelForIndex(i,a):"",index:i,datasetIndex:a,x:t._model.x,y:t._model.y}}function a(e){var n=t.defaults.global,i=l.getValueOrDefault;return{xPadding:e.xPadding,yPadding:e.yPadding,xAlign:e.xAlign,yAlign:e.yAlign,bodyFontColor:e.bodyFontColor,_bodyFontFamily:i(e.bodyFontFamily,n.defaultFontFamily),_bodyFontStyle:i(e.bodyFontStyle,n.defaultFontStyle),_bodyAlign:e.bodyAlign,bodyFontSize:i(e.bodyFontSize,n.defaultFontSize),bodySpacing:e.bodySpacing,titleFontColor:e.titleFontColor,_titleFontFamily:i(e.titleFontFamily,n.defaultFontFamily),_titleFontStyle:i(e.titleFontStyle,n.defaultFontStyle),titleFontSize:i(e.titleFontSize,n.defaultFontSize),_titleAlign:e.titleAlign,titleSpacing:e.titleSpacing,titleMarginBottom:e.titleMarginBottom,footerFontColor:e.footerFontColor,_footerFontFamily:i(e.footerFontFamily,n.defaultFontFamily),_footerFontStyle:i(e.footerFontStyle,n.defaultFontStyle),footerFontSize:i(e.footerFontSize,n.defaultFontSize),_footerAlign:e.footerAlign,footerSpacing:e.footerSpacing,footerMarginTop:e.footerMarginTop,caretSize:e.caretSize,cornerRadius:e.cornerRadius,backgroundColor:e.backgroundColor,opacity:0,legendColorBackground:e.multiKeyBackground,displayColors:e.displayColors,borderColor:e.borderColor,borderWidth:e.borderWidth}}function r(t,e){var n=t._chart.ctx,i=2*e.yPadding,a=0,r=e.body,o=r.reduce(function(t,e){return t+e.before.length+e.lines.length+e.after.length},0);o+=e.beforeBody.length+e.afterBody.length;var s=e.title.length,u=e.footer.length,d=e.titleFontSize,c=e.bodyFontSize,h=e.footerFontSize;i+=s*d,i+=s?(s-1)*e.titleSpacing:0,i+=s?e.titleMarginBottom:0,i+=o*c,i+=o?(o-1)*e.bodySpacing:0,i+=u?e.footerMarginTop:0,i+=u*h,i+=u?(u-1)*e.footerSpacing:0;var f=0,g=function(t){a=Math.max(a,n.measureText(t).width+f)};return n.font=l.fontString(d,e._titleFontStyle,e._titleFontFamily),l.each(e.title,g),n.font=l.fontString(c,e._bodyFontStyle,e._bodyFontFamily),l.each(e.beforeBody.concat(e.afterBody),g),f=e.displayColors?c+2:0,l.each(r,function(t){l.each(t.before,g),l.each(t.lines,g),l.each(t.after,g)}),f=0,n.font=l.fontString(h,e._footerFontStyle,e._footerFontFamily),l.each(e.footer,g),a+=2*e.xPadding,{width:a,height:i}}function o(t,e){var n=t._model,i=t._chart,a=t._chart.chartArea,r="center",o="center";n.yi.height-e.height&&(o="bottom");var s,l,u,d,c,h=(a.left+a.right)/2,f=(a.top+a.bottom)/2;"center"===o?(s=function(t){return t<=h},l=function(t){return t>h}):(s=function(t){return t<=e.width/2},l=function(t){return t>=i.width-e.width/2}),u=function(t){return t+e.width>i.width},d=function(t){return t-e.width<0},c=function(t){return t<=f?"top":"bottom"},s(n.x)?(r="left",u(n.x)&&(r="center",o=c(n.y))):l(n.x)&&(r="right",d(n.x)&&(r="center",o=c(n.y)));var g=t._options;return{xAlign:g.xAlign?g.xAlign:r,yAlign:g.yAlign?g.yAlign:o}}function s(t,e,n){var i=t.x,a=t.y,r=t.caretSize,o=t.caretPadding,s=t.cornerRadius,l=n.xAlign,u=n.yAlign,d=r+o,c=s+o;return"right"===l?i-=e.width:"center"===l&&(i-=e.width/2),"top"===u?a+=d:a-="bottom"===u?e.height+d:e.height/2,"center"===u?"left"===l?i+=d:"right"===l&&(i-=d):"left"===l?i-=c:"right"===l&&(i+=c),{x:i,y:a}}var l=t.helpers;t.defaults.global.tooltips={enabled:!0,custom:null,mode:"nearest",position:"average",intersect:!0,backgroundColor:"rgba(0,0,0,0.8)",titleFontStyle:"bold",titleSpacing:2,titleMarginBottom:6,titleFontColor:"#fff",titleAlign:"left",bodySpacing:2,bodyFontColor:"#fff",bodyAlign:"left",footerFontStyle:"bold",footerSpacing:2,footerMarginTop:6,footerFontColor:"#fff",footerAlign:"left",yPadding:6,xPadding:6,caretPadding:2,caretSize:5,cornerRadius:6,multiKeyBackground:"#fff",displayColors:!0,borderColor:"rgba(0,0,0,0)",borderWidth:0,callbacks:{beforeTitle:l.noop,title:function(t,e){var n="",i=e.labels,a=i?i.length:0;if(t.length>0){var r=t[0];r.xLabel?n=r.xLabel:a>0&&r.index0&&i.stroke()},draw:function(){var t=this._chart.ctx,e=this._view;if(0!==e.opacity){var n={width:e.width,height:e.height},i={x:e.x,y:e.y},a=Math.abs(e.opacity<.001)?0:e.opacity,r=e.title.length||e.beforeBody.length||e.body.length||e.afterBody.length||e.footer.length;this._options.enabled&&r&&(this.drawBackground(i,e,t,n,a),i.x+=e.xPadding,i.y+=e.yPadding,this.drawTitle(i,e,t,a),this.drawBody(i,e,t,a),this.drawFooter(i,e,t,a))}},handleEvent:function(t){var e=this,n=e._options,i=!1;if(e._lastActive=e._lastActive||[],"mouseout"===t.type?e._active=[]:e._active=e._chart.getElementsAtEventForMode(t,n.mode,n),i=!l.arrayEquals(e._active,e._lastActive),!i)return!1;if(e._lastActive=e._active,n.enabled||n.custom){e._eventPosition={x:t.x,y:t.y};var a=e._model;e.update(!0),e.pivot(),i|=a.x!==e._model.x||a.y!==e._model.y}return i}}),t.Tooltip.positioners={average:function(t){if(!t.length)return!1;var e,n,i=0,a=0,r=0;for(e=0,n=t.length;el;)r-=2*Math.PI;for(;r=s&&r<=l,d=o>=i.innerRadius&&o<=i.outerRadius;return u&&d}return!1},getCenterPoint:function(){var t=this._view,e=(t.startAngle+t.endAngle)/2,n=(t.innerRadius+t.outerRadius)/2;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},getArea:function(){var t=this._view;return Math.PI*((t.endAngle-t.startAngle)/(2*Math.PI))*(Math.pow(t.outerRadius,2)-Math.pow(t.innerRadius,2))},tooltipPosition:function(){var t=this._view,e=t.startAngle+(t.endAngle-t.startAngle)/2,n=(t.outerRadius-t.innerRadius)/2+t.innerRadius;return{x:t.x+Math.cos(e)*n,y:t.y+Math.sin(e)*n}},draw:function(){var t=this._chart.ctx,e=this._view,n=e.startAngle,i=e.endAngle;t.beginPath(),t.arc(e.x,e.y,e.outerRadius,n,i),t.arc(e.x,e.y,e.innerRadius,i,n,!0),t.closePath(),t.strokeStyle=e.borderColor,t.lineWidth=e.borderWidth,t.fillStyle=e.backgroundColor,t.fill(),t.lineJoin="bevel",e.borderWidth&&t.stroke()}})}},{}],36:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers,n=t.defaults.global;t.defaults.global.elements.line={tension:.4,backgroundColor:n.defaultColor,borderWidth:3,borderColor:n.defaultColor,borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",capBezierPoints:!0,fill:!0},t.elements.Line=t.Element.extend({draw:function(){var t,i,a,r,o=this,s=o._view,l=o._chart.ctx,u=s.spanGaps,d=o._children.slice(),c=n.elements.line,h=-1;for(o._loop&&d.length&&d.push(d[0]),l.save(),l.lineCap=s.borderCapStyle||c.borderCapStyle,l.setLineDash&&l.setLineDash(s.borderDash||c.borderDash),l.lineDashOffset=s.borderDashOffset||c.borderDashOffset,l.lineJoin=s.borderJoinStyle||c.borderJoinStyle,l.lineWidth=s.borderWidth||c.borderWidth,l.strokeStyle=s.borderColor||n.defaultColor,l.beginPath(),h=-1,t=0;te?1:-1,o=1,s=u.borderSkipped||"left"):(e=u.x-u.width/2,n=u.x+u.width/2,i=u.y,a=u.base,r=1,o=a>i?1:-1,s=u.borderSkipped||"bottom"),d){var c=Math.min(Math.abs(e-n),Math.abs(i-a));d=d>c?c:d;var h=d/2,f=e+("left"!==s?h*r:0),g=n+("right"!==s?-h*r:0),p=i+("top"!==s?h*o:0),m=a+("bottom"!==s?-h*o:0);f!==g&&(i=p,a=m),p!==m&&(e=f,n=g)}l.beginPath(),l.fillStyle=u.backgroundColor,l.strokeStyle=u.borderColor,l.lineWidth=d;var v=[[e,a],[e,i],[n,i],[n,a]],y=["bottom","left","top","right"],b=y.indexOf(s,0);b===-1&&(b=0);var x=t(0);l.moveTo(x[0],x[1]);for(var _=1;_<4;_++)x=t(_),l.lineTo(x[0],x[1]);l.fill(),d&&l.stroke()},height:function(){var t=this._view;return t.base-t.y},inRange:function(t,e){var i=!1;if(this._view){var a=n(this);i=t>=a.left&&t<=a.right&&e>=a.top&&e<=a.bottom}return i},inLabelRange:function(t,i){var a=this;if(!a._view)return!1;var r=!1,o=n(a);return r=e(a)?t>=o.left&&t<=o.right:i>=o.top&&i<=o.bottom},inXRange:function(t){var e=n(this);return t>=e.left&&t<=e.right},inYRange:function(t){var e=n(this);return t>=e.top&&t<=e.bottom},getCenterPoint:function(){var t,n,i=this._view;return e(this)?(t=i.x,n=(i.y+i.base)/2):(t=(i.x+i.base)/2,n=i.y),{x:t,y:n}},getArea:function(){var t=this._view;return t.width*Math.abs(t.y-t.base)},tooltipPosition:function(){var t=this._view;return{x:t.x,y:t.y}}})}},{}],39:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e){var n=l.getStyle(t,e),i=n&&n.match(/^(\d+)(\.\d+)?px$/);return i?Number(i[1]):void 0}function n(t,n){var i=t.style,a=t.getAttribute("height"),r=t.getAttribute("width");if(t._chartjs={initial:{height:a,width:r,style:{display:i.display,height:i.height,width:i.width}}},i.display=i.display||"block",null===r||""===r){var o=e(t,"width");void 0!==o&&(t.width=o)}if(null===a||""===a)if(""===t.style.height)t.height=t.width/(n.options.aspectRatio||2);else{var s=e(t,"height");void 0!==o&&(t.height=s)}return t}function i(t,e,n,i,a){return{type:t,chart:e,native:a||null,x:void 0!==n?n:null,y:void 0!==i?i:null}}function a(t,e){var n=u[t.type]||t.type,a=l.getRelativePosition(t,e);return i(n,e,a.x,a.y,t)}function r(t){var e=document.createElement("iframe");return e.className="chartjs-hidden-iframe",e.style.cssText="display:block;overflow:hidden;border:0;margin:0;top:0;left:0;bottom:0;right:0;height:100%;width:100%;position:absolute;pointer-events:none;z-index:-1;",e.tabIndex=-1,l.addEvent(e,"load",function(){l.addEvent(e.contentWindow||e,"resize",t),t()}),e}function o(t,e,n){var a=t._chartjs={ticking:!1},o=function(){a.ticking||(a.ticking=!0,l.requestAnimFrame.call(window,function(){if(a.resizer)return a.ticking=!1,e(i("resize",n))}))};a.resizer=r(o),t.insertBefore(a.resizer,t.firstChild)}function s(t){if(t&&t._chartjs){var e=t._chartjs.resizer;e&&(e.parentNode.removeChild(e),t._chartjs.resizer=null),delete t._chartjs}}var l=t.helpers,u={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};return{acquireContext:function(t,e){"string"==typeof t?t=document.getElementById(t):t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas);var i=t&&t.getContext&&t.getContext("2d");return i&&i.canvas===t?(n(t,e),i):null},releaseContext:function(t){var e=t.canvas;if(e._chartjs){var n=e._chartjs.initial;["height","width"].forEach(function(t){var i=n[t];void 0===i||null===i?e.removeAttribute(t):e.setAttribute(t,i)}),l.each(n.style||{},function(t,n){e.style[n]=t}),e.width=e.width,delete e._chartjs}},addEventListener:function(t,e,n){var i=t.canvas;if("resize"===e)return void o(i.parentNode,n,t);var r=n._chartjs||(n._chartjs={}),s=r.proxies||(r.proxies={}),u=s[t.id+"_"+e]=function(e){n(a(e,t))};l.addEvent(i,e,u)},removeEventListener:function(t,e,n){var i=t.canvas;if("resize"===e)return void s(i.parentNode,n);var a=n._chartjs||{},r=a.proxies||{},o=r[t.id+"_"+e];o&&l.removeEvent(i,e,o)}}}},{}],40:[function(t,e,n){"use strict";var i=t(39);e.exports=function(t){t.platform={acquireContext:function(){},releaseContext:function(){},addEventListener:function(){},removeEventListener:function(){}},t.helpers.extend(t.platform,i(t))}},{39:39}],41:[function(t,e,n){"use strict";e.exports=function(t){function e(t,e,n){var i,a=t._model||{},r=a.fill;if(void 0===r&&(r=!!a.backgroundColor),r===!1||null===r)return!1;if(r===!0)return"origin";if(i=parseFloat(r,10),isFinite(i)&&Math.floor(i)===i)return"-"!==r[0]&&"+"!==r[0]||(i=e+i),!(i===e||i<0||i>=n)&&i;switch(r){case"bottom":return"start";case"top":return"end";case"zero":return"origin";case"origin":case"start":case"end":return r;default:return!1}}function n(t){var e,n=t.el._model||{},i=t.el._scale||{},a=t.fill,r=null;if(isFinite(a))return null;if("start"===a?r=void 0===n.scaleBottom?i.bottom:n.scaleBottom:"end"===a?r=void 0===n.scaleTop?i.top:n.scaleTop:void 0!==n.scaleZero?r=n.scaleZero:i.getBasePosition?r=i.getBasePosition():i.getBasePixel&&(r=i.getBasePixel()),void 0!==r&&null!==r){if(void 0!==r.x&&void 0!==r.y)return r;if("number"==typeof r&&isFinite(r))return e=i.isHorizontal(),{x:e?r:null,y:e?null:r}}return null}function i(t,e,n){var i,a=t[e],r=a.fill,o=[e];if(!n)return r;for(;r!==!1&&o.indexOf(r)===-1;){if(!isFinite(r))return r;if(i=t[r],!i)return!1;if(i.visible)return r;o.push(r),r=i.fill}return!1}function a(t){var e=t.fill,n="dataset";return e===!1?null:(isFinite(e)||(n="boundary"),d[n](t))}function r(t){return t&&!t.skip}function o(t,e,n,i,a){var r;if(i&&a){for(t.moveTo(e[0].x,e[0].y),r=1;r0;--r)u.canvas.lineTo(t,n[r],n[r-1],!0)}}function s(t,e,n,i,a,s){var l,u,d,c,h,f,g,p=e.length,m=i.spanGaps,v=[],y=[],b=0,x=0;for(t.beginPath(),l=0,u=p+!!s;l=n.width&&(y+=d+r.padding,v[v.length]=n.left),g[i]={left:0,top:0,width:o,height:d},v[v.length-1]+=o+r.padding}),p.height+=y}else{var b=r.padding,x=n.columnWidths=[],_=r.padding,k=0,w=0,M=d+b;i.each(n.legendItems,function(t,n){var i=e(r,d),a=i+d/2+s.measureText(t.text).width;w+M>p.height&&(_+=k+r.padding,x.push(k),k=0,w=0),k=Math.max(k,a),w+=M,g[n]={left:0,top:0,width:a,height:d}}),_+=k,x.push(k),p.width+=_}n.width=p.width,n.height=p.height},afterFit:r,isHorizontal:function(){return"top"===this.options.position||"bottom"===this.options.position},draw:function(){var n=this,a=n.options,r=a.labels,o=t.defaults.global,s=o.elements.line,l=n.width,u=n.lineWidths;if(a.display){var d,c=n.ctx,h=i.getValueOrDefault,f=h(r.fontColor,o.defaultFontColor),g=h(r.fontSize,o.defaultFontSize),p=h(r.fontStyle,o.defaultFontStyle),m=h(r.fontFamily,o.defaultFontFamily),v=i.fontString(g,p,m);c.textAlign="left",c.textBaseline="top",c.lineWidth=.5,c.strokeStyle=f,c.fillStyle=f,c.font=v;var y=e(r,g),b=n.legendHitBoxes,x=function(e,n,i){if(!(isNaN(y)||y<=0)){c.save(),c.fillStyle=h(i.fillStyle,o.defaultColor),c.lineCap=h(i.lineCap,s.borderCapStyle),c.lineDashOffset=h(i.lineDashOffset,s.borderDashOffset),c.lineJoin=h(i.lineJoin,s.borderJoinStyle),c.lineWidth=h(i.lineWidth,s.borderWidth),c.strokeStyle=h(i.strokeStyle,o.defaultColor);var r=0===h(i.lineWidth,s.borderWidth);if(c.setLineDash&&c.setLineDash(h(i.lineDash,s.borderDash)),a.labels&&a.labels.usePointStyle){var l=g*Math.SQRT2/2,u=l/Math.SQRT2,d=e+u,f=n+u;t.canvasHelpers.drawPoint(c,i.pointStyle,l,d,f)}else r||c.strokeRect(e,n,y,g),c.fillRect(e,n,y,g);c.restore()}},_=function(t,e,n,i){c.fillText(n.text,y+g/2+t,e),n.hidden&&(c.beginPath(),c.lineWidth=2,c.moveTo(y+g/2+t,e+g/2),c.lineTo(y+g/2+t+i,e+g/2),c.stroke())},k=n.isHorizontal();d=k?{x:n.left+(l-u[0])/2,y:n.top+r.padding,line:0}:{x:n.left+r.padding,y:n.top+r.padding,line:0};var w=g+r.padding;i.each(n.legendItems,function(t,e){var i=c.measureText(t.text).width,a=y+g/2+i,o=d.x,s=d.y;k?o+a>=l&&(s=d.y+=w,d.line++,o=d.x=n.left+(l-u[d.line])/2):s+w>n.bottom&&(o=d.x=o+n.columnWidths[d.line]+r.padding,s=d.y=n.top+r.padding,d.line++),x(o,s,t),b[e].left=o,b[e].top=s,_(o,s,t,i),k?d.x+=a+r.padding:d.y+=w})}},handleEvent:function(t){var e=this,n=e.options,i="mouseup"===t.type?"click":t.type,a=!1;if("mousemove"===i){if(!n.onHover)return}else{if("click"!==i)return;if(!n.onClick)return}var r=t.x,o=t.y;if(r>=e.left&&r<=e.right&&o>=e.top&&o<=e.bottom)for(var s=e.legendHitBoxes,l=0;l=u.left&&r<=u.left+u.width&&o>=u.top&&o<=u.top+u.height){if("click"===i){n.onClick.call(e,t.native,e.legendItems[l]),a=!0;break}if("mousemove"===i){n.onHover.call(e,t.native,e.legendItems[l]),a=!0;break}}}return a}}),{id:"legend",beforeInit:function(t){var e=t.options.legend;e&&n(t,e)},beforeUpdate:function(e){var r=e.options.legend,o=e.legend;r?(r=i.configMerge(t.defaults.global.legend,r),o?(a.configure(e,o,r),o.options=r):n(e,r)):o&&(a.removeBox(e,o),delete e.legend)},afterEvent:function(t,e){var n=t.legend;n&&n.handleEvent(e)}}}},{}],43:[function(t,e,n){"use strict";e.exports=function(t){function e(e,n){var a=new t.Title({ctx:e.ctx,options:n,chart:e});i.configure(e,a,n),i.addBox(e,a),e.titleBlock=a}var n=t.helpers,i=t.layoutService,a=n.noop;return t.defaults.global.title={display:!1,position:"top",fullWidth:!0,weight:2e3,fontStyle:"bold",padding:10,text:""},t.Title=t.Element.extend({initialize:function(t){var e=this;n.extend(e,t),e.legendHitBoxes=[]},beforeUpdate:a,update:function(t,e,n){var i=this;return i.beforeUpdate(),i.maxWidth=t,i.maxHeight=e,i.margins=n,i.beforeSetDimensions(),i.setDimensions(),i.afterSetDimensions(),i.beforeBuildLabels(),i.buildLabels(),i.afterBuildLabels(),i.beforeFit(),i.fit(),i.afterFit(),i.afterUpdate(),i.minSize},afterUpdate:a,beforeSetDimensions:a,setDimensions:function(){var t=this;t.isHorizontal()?(t.width=t.maxWidth,t.left=0,t.right=t.width):(t.height=t.maxHeight,t.top=0,t.bottom=t.height),t.paddingLeft=0,t.paddingTop=0,t.paddingRight=0,t.paddingBottom=0,t.minSize={width:0,height:0}},afterSetDimensions:a,beforeBuildLabels:a,buildLabels:a,afterBuildLabels:a,beforeFit:a,fit:function(){var e=this,i=n.getValueOrDefault,a=e.options,r=t.defaults.global,o=a.display,s=i(a.fontSize,r.defaultFontSize),l=e.minSize;e.isHorizontal()?(l.width=e.maxWidth,l.height=o?s+2*a.padding:0):(l.width=o?s+2*a.padding:0,l.height=e.maxHeight),e.width=l.width,e.height=l.height},afterFit:a,isHorizontal:function(){var t=this.options.position;return"top"===t||"bottom"===t},draw:function(){var e=this,i=e.ctx,a=n.getValueOrDefault,r=e.options,o=t.defaults.global;if(r.display){var s,l,u,d=a(r.fontSize,o.defaultFontSize),c=a(r.fontStyle,o.defaultFontStyle),h=a(r.fontFamily,o.defaultFontFamily),f=n.fontString(d,c,h),g=0,p=e.top,m=e.left,v=e.bottom,y=e.right;i.fillStyle=a(r.fontColor,o.defaultFontColor),i.font=f,e.isHorizontal()?(s=m+(y-m)/2,l=p+(v-p)/2,u=y-m):(s="left"===r.position?m+d/2:y-d/2,l=p+(v-p)/2,u=v-p,g=Math.PI*("left"===r.position?-.5:.5)),i.save(),i.translate(s,l),i.rotate(g),i.textAlign="center",i.textBaseline="middle",i.fillText(r.text,0,0,u),i.restore()}}}),{id:"title",beforeInit:function(t){var n=t.options.title;n&&e(t,n)},beforeUpdate:function(a){var r=a.options.title,o=a.titleBlock;r?(r=n.configMerge(t.defaults.global.title,r),o?(i.configure(a,o,r),o.options=r):e(a,r)):o&&(t.layoutService.removeBox(a,o),delete a.titleBlock)}}}},{}],44:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers,n={position:"bottom"},i=t.Scale.extend({getLabels:function(){var t=this.chart.data;return(this.isHorizontal()?t.xLabels:t.yLabels)||t.labels},determineDataLimits:function(){var t=this,n=t.getLabels();t.minIndex=0,t.maxIndex=n.length-1;var i;void 0!==t.options.ticks.min&&(i=e.indexOf(n,t.options.ticks.min),t.minIndex=i!==-1?i:t.minIndex),void 0!==t.options.ticks.max&&(i=e.indexOf(n,t.options.ticks.max),t.maxIndex=i!==-1?i:t.maxIndex),t.min=n[t.minIndex],t.max=n[t.maxIndex]},buildTicks:function(){var t=this,e=t.getLabels();t.ticks=0===t.minIndex&&t.maxIndex===e.length-1?e:e.slice(t.minIndex,t.maxIndex+1)},getLabelForIndex:function(t,e){var n=this,i=n.chart.data,a=n.isHorizontal();return i.yLabels&&!a?n.getRightValue(i.datasets[e].data[t]):n.ticks[t-n.minIndex]},getPixelForValue:function(t,e,n,i){var a,r=this,o=Math.max(r.maxIndex+1-r.minIndex-(r.options.gridLines.offsetGridLines?0:1),1);if(void 0!==t&&null!==t&&(a=r.isHorizontal()?t.x:t.y),void 0!==a||void 0!==t&&isNaN(e)){var s=r.getLabels();t=a||t;var l=s.indexOf(t);e=l!==-1?l:e}if(r.isHorizontal()){var u=r.width/o,d=u*(e-r.minIndex);return(r.options.gridLines.offsetGridLines&&i||r.maxIndex===r.minIndex&&i)&&(d+=u/2),r.left+Math.round(d)}var c=r.height/o,h=c*(e-r.minIndex);return r.options.gridLines.offsetGridLines&&i&&(h+=c/2),r.top+Math.round(h)},getPixelForTick:function(t,e){return this.getPixelForValue(this.ticks[t],t+this.minIndex,null,e)},getValueForPixel:function(t){var e,n=this,i=Math.max(n.ticks.length-(n.options.gridLines.offsetGridLines?0:1),1),a=n.isHorizontal(),r=(a?n.width:n.height)/i;return t-=a?n.left:n.top,n.options.gridLines.offsetGridLines&&(t-=r/2),e=t<=0?0:Math.round(t/r)},getBasePixel:function(){return this.bottom}});t.scaleService.registerScaleType("category",i,n)}},{}],45:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers,n={position:"left",ticks:{callback:t.Ticks.formatters.linear}},i=t.LinearScaleBase.extend({determineDataLimits:function(){function t(t){return s?t.xAxisID===n.id:t.yAxisID===n.id}var n=this,i=n.options,a=n.chart,r=a.data,o=r.datasets,s=n.isHorizontal(),l=0,u=1;n.min=null,n.max=null;var d=i.stacked;if(void 0===d&&e.each(o,function(e,n){if(!d){var i=a.getDatasetMeta(n);a.isDatasetVisible(n)&&t(i)&&void 0!==i.stack&&(d=!0)}}),i.stacked||d){var c={};e.each(o,function(r,o){var s=a.getDatasetMeta(o),l=[s.type,void 0===i.stacked&&void 0===s.stack?o:"",s.stack].join(".");void 0===c[l]&&(c[l]={positiveValues:[],negativeValues:[]});var u=c[l].positiveValues,d=c[l].negativeValues;a.isDatasetVisible(o)&&t(s)&&e.each(r.data,function(t,e){var a=+n.getRightValue(t);isNaN(a)||s.data[e].hidden||(u[e]=u[e]||0,d[e]=d[e]||0,i.relativePoints?u[e]=100:a<0?d[e]+=a:u[e]+=a)})}),e.each(c,function(t){var i=t.positiveValues.concat(t.negativeValues),a=e.min(i),r=e.max(i);n.min=null===n.min?a:Math.min(n.min,a),n.max=null===n.max?r:Math.max(n.max,r)})}else e.each(o,function(i,r){var o=a.getDatasetMeta(r);a.isDatasetVisible(r)&&t(o)&&e.each(i.data,function(t,e){var i=+n.getRightValue(t);isNaN(i)||o.data[e].hidden||(null===n.min?n.min=i:in.max&&(n.max=i))})});n.min=isFinite(n.min)?n.min:l,n.max=isFinite(n.max)?n.max:u,this.handleTickRangeOptions()},getTickLimit:function(){var n,i=this,a=i.options.ticks;if(i.isHorizontal())n=Math.min(a.maxTicksLimit?a.maxTicksLimit:11,Math.ceil(i.width/50));else{var r=e.getValueOrDefault(a.fontSize,t.defaults.global.defaultFontSize);n=Math.min(a.maxTicksLimit?a.maxTicksLimit:11,Math.ceil(i.height/(2*r)))}return n},handleDirectionalChanges:function(){this.isHorizontal()||this.ticks.reverse()},getLabelForIndex:function(t,e){return+this.getRightValue(this.chart.data.datasets[e].data[t])},getPixelForValue:function(t){var e,n=this,i=n.start,a=+n.getRightValue(t),r=n.end-i;return n.isHorizontal()?(e=n.left+n.width/r*(a-i),Math.round(e)):(e=n.bottom-n.height/r*(a-i),Math.round(e))},getValueForPixel:function(t){var e=this,n=e.isHorizontal(),i=n?e.width:e.height,a=(n?t-e.left:e.bottom-t)/i;return e.start+(e.end-e.start)*a},getPixelForTick:function(t){return this.getPixelForValue(this.ticksAsNumbers[t])}});t.scaleService.registerScaleType("linear",i,n)}},{}],46:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers,n=e.noop;t.LinearScaleBase=t.Scale.extend({handleTickRangeOptions:function(){var t=this,n=t.options,i=n.ticks;if(i.beginAtZero){var a=e.sign(t.min),r=e.sign(t.max);a<0&&r<0?t.max=0:a>0&&r>0&&(t.min=0)}void 0!==i.min?t.min=i.min:void 0!==i.suggestedMin&&(null===t.min?t.min=i.suggestedMin:t.min=Math.min(t.min,i.suggestedMin)),void 0!==i.max?t.max=i.max:void 0!==i.suggestedMax&&(null===t.max?t.max=i.suggestedMax:t.max=Math.max(t.max,i.suggestedMax)),t.min===t.max&&(t.max++,i.beginAtZero||t.min--)},getTickLimit:n,handleDirectionalChanges:n,buildTicks:function(){var n=this,i=n.options,a=i.ticks,r=n.getTickLimit();r=Math.max(2,r);var o={maxTicks:r,min:a.min,max:a.max,stepSize:e.getValueOrDefault(a.fixedStepSize,a.stepSize)},s=n.ticks=t.Ticks.generators.linear(o,n);n.handleDirectionalChanges(),n.max=e.max(s),n.min=e.min(s),a.reverse?(s.reverse(),n.start=n.max,n.end=n.min):(n.start=n.min,n.end=n.max)},convertTicksToLabels:function(){var e=this;e.ticksAsNumbers=e.ticks.slice(),e.zeroLineIndex=e.ticks.indexOf(0),t.Scale.prototype.convertTicksToLabels.call(e)}})}},{}],47:[function(t,e,n){"use strict";e.exports=function(t){var e=t.helpers,n={position:"left",ticks:{callback:t.Ticks.formatters.logarithmic}},i=t.Scale.extend({determineDataLimits:function(){function t(t){return u?t.xAxisID===n.id:t.yAxisID===n.id}var n=this,i=n.options,a=i.ticks,r=n.chart,o=r.data,s=o.datasets,l=e.getValueOrDefault,u=n.isHorizontal();n.min=null,n.max=null,n.minNotZero=null;var d=i.stacked;if(void 0===d&&e.each(s,function(e,n){if(!d){var i=r.getDatasetMeta(n);r.isDatasetVisible(n)&&t(i)&&void 0!==i.stack&&(d=!0)}}),i.stacked||d){var c={};e.each(s,function(a,o){var s=r.getDatasetMeta(o),l=[s.type,void 0===i.stacked&&void 0===s.stack?o:"",s.stack].join(".");r.isDatasetVisible(o)&&t(s)&&(void 0===c[l]&&(c[l]=[]),e.each(a.data,function(t,e){var a=c[l],r=+n.getRightValue(t);isNaN(r)||s.data[e].hidden||(a[e]=a[e]||0,i.relativePoints?a[e]=100:a[e]+=r)}))}),e.each(c,function(t){var i=e.min(t),a=e.max(t);n.min=null===n.min?i:Math.min(n.min,i),n.max=null===n.max?a:Math.max(n.max,a)})}else e.each(s,function(i,a){var o=r.getDatasetMeta(a);r.isDatasetVisible(a)&&t(o)&&e.each(i.data,function(t,e){var i=+n.getRightValue(t);isNaN(i)||o.data[e].hidden||(null===n.min?n.min=i:in.max&&(n.max=i),0!==i&&(null===n.minNotZero||ia?{start:e-n-5,end:e}:{start:e,end:e+n+5}}function r(t){var r,o,s,l=n(t),u=Math.min(t.height/2,t.width/2),d={r:t.width,l:0,t:t.height,b:0},c={};t.ctx.font=l.font,t._pointLabelSizes=[];var h=e(t);for(r=0;rd.r&&(d.r=m.end,c.r=g),v.startd.b&&(d.b=v.end,c.b=g)}t.setReductions(u,d,c)}function o(t){var e=Math.min(t.height/2,t.width/2);t.drawingArea=Math.round(e),t.setCenterPoint(0,0,0,0)}function s(t){return 0===t||180===t?"center":t<180?"left":"right"}function l(t,e,n,i){if(f.isArray(e))for(var a=n.y,r=1.5*i,o=0;o270||t<90)&&(n.y-=e.h)}function d(t){var i=t.ctx,a=f.getValueOrDefault,r=t.options,o=r.angleLines,d=r.pointLabels;i.lineWidth=o.lineWidth,i.strokeStyle=o.color;var c=t.getDistanceFromCenterForValue(r.reverse?t.min:t.max),h=n(t);i.textBaseline="top";for(var p=e(t)-1;p>=0;p--){if(o.display){var m=t.getPointPosition(p,c);i.beginPath(),i.moveTo(t.xCenter,t.yCenter),i.lineTo(m.x,m.y),i.stroke(),i.closePath()}if(d.display){var v=t.getPointPosition(p,c+5),y=a(d.fontColor,g.defaultFontColor);i.font=h.font,i.fillStyle=y;var b=t.getIndexAngle(p),x=f.toDegrees(b);i.textAlign=s(x),u(x,t._pointLabelSizes[p],v),l(i,t.pointLabels[p]||"",v,h.size)}}}function c(t,n,i,a){var r=t.ctx;if(r.strokeStyle=f.getValueAtIndexOrDefault(n.color,a-1),r.lineWidth=f.getValueAtIndexOrDefault(n.lineWidth,a-1),t.options.gridLines.circular)r.beginPath(),r.arc(t.xCenter,t.yCenter,i,0,2*Math.PI), +r.closePath(),r.stroke();else{var o=e(t);if(0===o)return;r.beginPath();var s=t.getPointPosition(0,i);r.moveTo(s.x,s.y);for(var l=1;l0&&n>0?e:0)},draw:function(){var t=this,e=t.options,n=e.gridLines,i=e.ticks,a=f.getValueOrDefault;if(e.display){var r=t.ctx,o=a(i.fontSize,g.defaultFontSize),s=a(i.fontStyle,g.defaultFontStyle),l=a(i.fontFamily,g.defaultFontFamily),u=f.fontString(o,s,l);f.each(t.ticks,function(s,l){if(l>0||e.reverse){var d=t.getDistanceFromCenterForValue(t.ticksAsNumbers[l]),h=t.yCenter-d;if(n.display&&0!==l&&c(t,n,d,l),i.display){var f=a(i.fontColor,g.defaultFontColor);if(r.font=u,i.showLabelBackdrop){var p=r.measureText(s).width;r.fillStyle=i.backdropColor,r.fillRect(t.xCenter-p/2-i.backdropPaddingX,h-o/2-i.backdropPaddingY,p+2*i.backdropPaddingX,o+2*i.backdropPaddingY)}r.textAlign="center",r.textBaseline="middle",r.fillStyle=f,r.fillText(s,t.xCenter,h)}}}),(e.angleLines.display||e.pointLabels.display)&&d(t)}}});t.scaleService.registerScaleType("radialLinear",m,p)}},{}],49:[function(t,e,n){"use strict";var i=t(6);i="function"==typeof i?i:window.moment,e.exports=function(t){function e(t,e){var n=t.options.time;if("string"==typeof n.parser)return i(e,n.parser);if("function"==typeof n.parser)return n.parser(e);if("function"==typeof e.getMonth||"number"==typeof e)return i(e);if(e.isValid&&e.isValid())return e;var a=n.format;return"string"!=typeof a&&a.call?(console.warn("options.time.format is deprecated and replaced by options.time.parser."),a(e)):i(e,a)}function n(t,e,n,i){for(var a,r=Object.keys(s),o=r.length,l=r.indexOf(t);li;c++)l=a.steps[c],o=Math.ceil(u/(r*l));else for(;o>i&&i>0;)++l,o=Math.ceil(u/(r*l));return l}function r(t,e,n){var a=[];if(t.maxTicks){var r=t.stepSize;a.push(void 0!==t.min?t.min:n.min);for(var o=i(n.min);o.add(r,t.unit).valueOf()0&&a.add(1,"week"),a=a.valueOf()):(n=i(e.min).startOf(t.unit).valueOf(),a=i(e.max).startOf(t.unit),e.max-a>0&&a.add(1,t.unit),a=a.valueOf()),r(t,e,{min:n,max:a})};var u=t.Scale.extend({initialize:function(){if(!i)throw new Error("Chart.js - Moment.js could not be found! You must include it before Chart.js to use the time scale. Download at https://momentjs.com");t.Scale.prototype.initialize.call(this)},determineDataLimits:function(){var t,n=this,i=n.options.time,a=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER,s=n.chart.data,l={labels:[],datasets:[]};o.each(s.labels,function(o,s){var u=e(n,o);u.isValid()&&(i.round&&u.startOf(i.round),t=u.valueOf(),a=Math.min(t,a),r=Math.max(t,r),l.labels[s]=t)}),o.each(s.datasets,function(s,u){var d=[];"object"==typeof s.data[0]&&null!==s.data[0]&&n.chart.isDatasetVisible(u)?o.each(s.data,function(o,s){var l=e(n,n.getRightValue(o));l.isValid()&&(i.round&&l.startOf(i.round),t=l.valueOf(),a=Math.min(t,a),r=Math.max(t,r),d[s]=t)}):d=l.labels.slice(),l.datasets[u]=d}),n.dataMin=a,n.dataMax=r,n._parsedData=l},buildTicks:function(){var i,r,s=this,l=s.options.time,u=s.dataMin,d=s.dataMax;if(l.min){var c=e(s,l.min);l.round&&c.round(l.round),i=c.valueOf()}l.max&&(r=e(s,l.max).valueOf());var h=s.getLabelCapacity(i||u),f=l.unit||n(l.minUnit,i||u,r||d,h);s.displayFormat=l.displayFormats[f];var g=l.stepSize||a(i||u,r||d,f,h);s.ticks=t.Ticks.generators.time({maxTicks:h,min:i,max:r,stepSize:g,unit:f,isoWeekday:l.isoWeekday},{min:u,max:d}),s.max=o.max(s.ticks),s.min=o.min(s.ticks)},getLabelForIndex:function(t,n){var i=this,a=i.chart.data.labels&&t0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){var d=v.call(arguments,0);return"string"!=typeof d[0]&&1===d.length&&d.push(null),n.apply(b,d.concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;hc;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('
      ');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('
    • '),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),d[0].className+=" select2-results__message",this.$results.append(d)},c.prototype.hideMessages=function(){this.$results.find(".select2-results__message").remove()},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c0?b.first().trigger("mouseenter"):a.first().trigger("mouseenter"),this.ensureHighlightVisible()},c.prototype.setClasses=function(){var b=this;this.data.current(function(c){var d=a.map(c,function(a){return a.id.toString()}),e=b.$results.find(".select2-results__option[aria-selected]");e.each(function(){var b=a(this),c=a.data(this,"data"),e=""+c.id;null!=c.element&&c.element.selected||null==c.element&&a.inArray(e,d)>-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")})})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";a(h);this.template(b,h);for(var i=[],j=0;j",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b,c){var d=this,e=b.id+"-results";this.$results.attr("id",e),b.on("results:all",function(a){d.clear(),d.append(a.data),b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("results:append",function(a){d.append(a.data),b.isOpen()&&d.setClasses()}),b.on("query",function(a){d.hideMessages(),d.showLoading(a)}),b.on("select",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("unselect",function(){b.isOpen()&&(d.setClasses(),d.highlightFirstItem())}),b.on("open",function(){d.$results.attr("aria-expanded","true"),d.$results.attr("aria-hidden","false"),d.setClasses(),d.ensureHighlightVisible()}),b.on("close",function(){d.$results.attr("aria-expanded","false"),d.$results.attr("aria-hidden","true"),d.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=d.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=d.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?d.trigger("close",{}):d.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a);if(0!==c){var e=c-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top,h=f.offset().top,i=d.$results.scrollTop()+(h-g);0===e?d.$results.scrollTop(0):0>h-g&&d.$results.scrollTop(i)}}),b.on("results:next",function(){var a=d.getHighlightedResults(),b=d.$results.find("[aria-selected]"),c=b.index(a),e=c+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=d.$results.offset().top+d.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=d.$results.scrollTop()+h-g;0===e?d.$results.scrollTop(0):h>g&&d.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){d.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=d.$results.scrollTop(),c=d.$results.get(0).scrollHeight-b+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&c<=d.$results.height();e?(d.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(d.$results.scrollTop(d.$results.get(0).scrollHeight-d.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var c=a(this),e=c.data("data");return"true"===c.attr("aria-selected")?void(d.options.get("multiple")?d.trigger("unselect",{originalEvent:b,data:e}):d.trigger("close",{})):void d.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(b){var c=a(this).data("data");d.getHighlightedResults().removeClass("select2-results__option--highlighted"),d.trigger("results:focus",{data:c,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b,c);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a,b){var d=this,e=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){d.trigger("focus",a)}),this.$selection.on("blur",function(a){d._handleBlur(a)}),this.$selection.on("keydown",function(a){d.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){d.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){d.update(a.data)}),a.on("open",function(){d.$selection.attr("aria-expanded","true"),d.$selection.attr("aria-owns",e),d._attachCloseHandler(a)}),a.on("close",function(){d.$selection.attr("aria-expanded","false"),d.$selection.removeAttr("aria-activedescendant"),d.$selection.removeAttr("aria-owns"),d.$selection.focus(),d._detachCloseHandler(a)}),a.on("enable",function(){d.$selection.attr("tabindex",d._tabindex)}),a.on("disable",function(){d.$selection.attr("tabindex","-1")})},d.prototype._handleBlur=function(b){var c=this;window.setTimeout(function(){document.activeElement==c.$selection[0]||a.contains(c.$selection[0],document.activeElement)||c.trigger("blur",b)},1)},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(a){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c,d){function e(){e.__super__.constructor.apply(this,arguments)}return c.Extend(e,b),e.prototype.render=function(){var a=e.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html(''),a},e.prototype.bind=function(a,b){var c=this;e.__super__.bind.apply(this,arguments);var d=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",d),this.$selection.attr("aria-labelledby",d),this.$selection.on("mousedown",function(a){1===a.which&&c.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(a){}),this.$selection.on("blur",function(a){}),a.on("focus",function(b){a.isOpen()||c.$selection.focus()}),a.on("selection:update",function(a){c.update(a.data)})},e.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},e.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},e.prototype.selectionContainer=function(){return a("")},e.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.$selection.find(".select2-selection__rendered"),d=this.display(b,c);c.empty().append(d),c.prop("title",b.title||b.text)},e}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(a,b){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('
        '),a},d.prototype.bind=function(b,c){var e=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){e.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(b){if(!e.options.get("disabled")){var c=a(this),d=c.parent(),f=d.data("data");e.trigger("unselect",{originalEvent:b,data:f})}})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a,b){var c=this.options.get("templateSelection"),d=this.options.get("escapeMarkup");return d(c(a,b))},d.prototype.selectionContainer=function(){var b=a('
      • ×
      • ');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},b}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e0||0===c.length)){var d=a('×');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return this._transferTabIndex(),d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.trigger("focus")}),b.on("close",function(){e.$search.val(""),e.$search.removeAttr("aria-activedescendant"),e.$search.trigger("focus")}),b.on("enable",function(){e.$search.prop("disabled",!1),e._transferTabIndex()}),b.on("disable",function(){e.$search.prop("disabled",!0)}),b.on("focus",function(a){e.$search.trigger("focus")}),b.on("results:focus",function(a){e.$search.attr("aria-activedescendant",a.id)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e._handleBlur(a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}});var f=document.documentMode,g=f&&11>=f;this.$selection.on("input.searchcheck",".select2-search--inline",function(a){return g?void e.$selection.off("input.search input.searchcheck"):void e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input.search",".select2-search--inline",function(a){if(g&&"input"===a.type)return void e.$selection.off("input.search input.searchcheck");var b=a.which;b!=c.SHIFT&&b!=c.CTRL&&b!=c.ALT&&b!=c.TAB&&e.handleSearch(a)})},d.prototype._transferTabIndex=function(a){this.$search.attr("tabindex",this.$selection.attr("tabindex")),this.$selection.attr("tabindex","-1")},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){var c=this.$search[0]==document.activeElement;this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch(),c&&this.$search.focus()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.$search.val(b.text),this.handleSearch()},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(a,c){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(a){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(a,b){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(a,b){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change"); +if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f=0){var k=f.filter(d(j)),l=this.item(k),m=c.extend(!0,{},j,l),n=this.option(m);k.replaceWith(n)}else{var o=this.option(j);if(j.children){var p=this.convertToOptions(j.children);b.appendMany(o,p)}h.push(o)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(a,b){this.ajaxOptions=this._applyDefaults(b.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),d.__super__.constructor.call(this,a,b)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return c.extend({},a,{q:a.term})},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){d.status&&"0"===d.status||e.trigger("results:message",{message:"errorLoading"})});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url.call(this.$element,a)),"function"==typeof f.data&&(f.data=f.data.call(this.$element,a)),this.ajaxOptions.delay&&null!=a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");void 0!==f&&(this.createTag=f);var g=d.get("insertTag");if(void 0!==g&&(this.insertTag=g),b.call(this,c,d),a.isArray(e))for(var h=0;h0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.bind=function(){},c.prototype.position=function(a,b){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a,b){function c(){}return c.prototype.render=function(b){var c=b.call(this),d=a('');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},c.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(b){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("focus",function(){c.isOpen()&&e.$search.focus()}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},c.prototype.handleSearch=function(a){if(!this._keyUpPrevented){var b=this.$search.val();this.trigger("query",{term:b})}this._keyUpPrevented=!1},c.prototype.showSearch=function(a,b){return!0},c}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('
      • '),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(b,c,d){this.$dropdownParent=d.get("dropdownParent")||a(document.body),b.call(this,c,d)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.destroy=function(a){a.call(this),this.$dropdownContainer.remove()},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a(""),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(a){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c,d){var e=this,f="scroll.select2."+d.id,g="resize.select2."+d.id,h="orientationchange.select2."+d.id,i=this.$container.parents().filter(b.hasScroll);i.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),i.on(f,function(b){var c=a(this).data("select2-scroll-position");a(this).scrollTop(c.y)}),a(window).on(f+" "+g+" "+h,function(a){e._positionDropdown(),e._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c,d){var e="scroll.select2."+d.id,f="resize.select2."+d.id,g="orientationchange.select2."+d.id,h=this.$container.parents().filter(b.hasScroll);h.off(e),a(window).off(e+" "+f+" "+g)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=this.$container.offset();f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.topf.bottom+h.height,l={left:f.left,top:g.bottom},m=this.$dropdownParent;"static"===m.css("position")&&(m=m.offsetParent());var n=m.offset();l.top-=n.top,l.left-=n.left,c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-n.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.position="relative",a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(a){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.multiple?l.selectionAdapter=e:l.selectionAdapter=d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(a.prop("dir")?this.options.dir=a.prop("dir"):a.closest("[dir]").prop("dir")?this.options.dir=a.closest("[dir]").prop("dir"):this.options.dir="ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b=b.replace(/(:|\.|\[|\]|,)/g,""),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this.$element.on("focus.select2",function(a){b.trigger("focus",a)}),this._syncA=c.bind(this._syncAttributes,this),this._syncS=c.bind(this._syncSubtree,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._syncA);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._syncA),a.each(c,b._syncS)}),this._observer.observe(this.$element[0],{attributes:!0,childList:!0,subtree:!1})):this.$element[0].addEventListener&&(this.$element[0].addEventListener("DOMAttrModified",b._syncA,!1),this.$element[0].addEventListener("DOMNodeInserted",b._syncS,!1),this.$element[0].addEventListener("DOMNodeRemoved",b._syncS,!1))},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle","focus"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("focus",function(a){b.focus(a)}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open",{}),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ESC||c===d.TAB||c===d.UP&&b.altKey?(a.close(),b.preventDefault()):c===d.ENTER?(a.trigger("results:select",{}),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle",{}),b.preventDefault()):c===d.UP?(a.trigger("results:previous",{}),b.preventDefault()):c===d.DOWN&&(a.trigger("results:next",{}),b.preventDefault()):(c===d.ENTER||c===d.SPACE||c===d.DOWN&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable",{})):this.trigger("enable",{})},e.prototype._syncSubtree=function(a,b){var c=!1,d=this;if(!a||!a.target||"OPTION"===a.target.nodeName||"OPTGROUP"===a.target.nodeName){if(b)if(b.addedNodes&&b.addedNodes.length>0)for(var e=0;e0&&(c=!0);else c=!0;c&&this.dataAdapter.current(function(a){d.trigger("selection:update",{data:a})})}},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(void 0===b&&(b={}),a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||this.trigger("query",{})},e.prototype.close=function(){this.isOpen()&&this.trigger("close",{})},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.hasFocus=function(){return this.$container.hasClass("select2-container--focus")},e.prototype.focus=function(a){this.hasFocus()||(this.$container.addClass("select2-container--focus"),this.trigger("focus",{}))},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._syncA),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&(this.$element[0].removeEventListener("DOMAttrModified",this._syncA,!1),this.$element[0].removeEventListener("DOMNodeInserted",this._syncS,!1),this.$element[0].removeEventListener("DOMNodeRemoved",this._syncS,!1)),this._syncA=null,this._syncS=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null; +},e.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("select2/compat/utils",["jquery"],function(a){function b(b,c,d){var e,f,g=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0===this.indexOf("select2-")&&g.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&(f=d(this),null!=f&&g.push(f))})),b.attr("class",g.join(" "))}return{syncCssClasses:b}}),b.define("select2/compat/containerCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("containerCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptContainerCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("containerCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/dropdownCss",["jquery","./utils"],function(a,b){function c(a){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("dropdownCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptDropdownCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all:","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("dropdownCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/initSelection",["jquery"],function(a){function b(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=c.get("initSelection"),this._isInitialized=!1,a.call(this,b,c)}return b.prototype.current=function(b,c){var d=this;return this._isInitialized?void b.call(this,c):void this.initSelection.call(null,this.$element,function(b){d._isInitialized=!0,a.isArray(b)||(b=[b]),c(b)})},b}),b.define("select2/compat/inputData",["jquery"],function(a){function b(a,b,c){this._currentData=[],this._valueSeparator=c.get("valueSeparator")||",","hidden"===b.prop("type")&&c.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `