diff --git a/app/assets/javascripts/admins/competition_settings/index.js b/app/assets/javascripts/admins/competition_settings/index.js index c9df31bb9..1b0dc65b0 100644 --- a/app/assets/javascripts/admins/competition_settings/index.js +++ b/app/assets/javascripts/admins/competition_settings/index.js @@ -600,6 +600,67 @@ $(document).on('turbolinks:load', function(){ $(".stage-update-form .section-start-time").datetimepicker(timeOptions); $(".stage-update-form .section-end-time").datetimepicker(timeOptions); }); + + // 奖项设置 + var $prizeContainer = $('#competition-prize-card'); + var competitionId = $prizeContainer.data('id'); + $(document).on('prize.save.success', function(){ + $.ajax({ + method: 'GET', + url: '/admins/competitions/' + competitionId + '/competition_prizes', + dataType: 'script' + }) + }); + + $('.modal.admin-upload-file-modal').on('upload:success', function(e, data){ + var $imageElement; + if(data.suffix === '_member'){ + $imageElement = $('.prize-member-image-' + data.source_id); + } else if(data.suffix === '_team'){ + $imageElement = $('.prize-team-image-' + data.source_id); + } else { + $imageElement = $('.prize-teacher-image-' + data.source_id); + } + $imageElement.attr('src', data.url); + $imageElement.show(); + $imageElement.next().html('重新上传'); + }) + + // 生成获奖记录 + $prizeContainer.on('click', '.generate-prize-user-action', function(){ + var $link = $(this); + + var generateRequest = function(){ + return $.ajax({ + method: 'POST', + url: '/admins/competitions/' + competitionId + '/competition_prize_users', + dataType: 'json', + success: function(data){ + if(data && data.status === 0){ + show_success_flash(); + $link.remove(); + } else { + showErrorNotify(data.message); + } + }, + error: function(res){ + var data = res.responseJSON; + showErrorNotify(data.message); + } + }) + } + + customConfirm({ + content: '确认生成吗?', + ok: function () { + customLoading({ + ajax: generateRequest + }) + } + }) + }); + } else { + $(document).unbind('prize.save.success'); } }); diff --git a/app/assets/javascripts/admins/modals/admin-save-competition-prize-modal.js b/app/assets/javascripts/admins/modals/admin-save-competition-prize-modal.js new file mode 100644 index 000000000..9d874dc08 --- /dev/null +++ b/app/assets/javascripts/admins/modals/admin-save-competition-prize-modal.js @@ -0,0 +1,46 @@ +$(document).on('turbolinks:load', function() { + $('.admin-modal-container').on('show.bs.modal', '.admin-save-competition-prize-modal', function(event){ + var $modal = $('.modal.admin-save-competition-prize-modal'); + var $form = $modal.find('form.admin-save-competition-prize-form'); + + $form.validate({ + errorElement: 'span', + errorClass: 'danger text-danger', + rules: { + 'competition_prize[name]': { + required: true, + maxlength: 10 + }, + 'competition_prize[num]': { + required: true, + digits: true, + min: 1 + } + } + }); + + $modal.on('click', '.submit-btn', function(){ + $form.find('.error').html(''); + var url = $form.attr('action'); + var formMethod = $form.data('form-method') + + if ($form.valid()) { + $.ajax({ + method: formMethod, + dataType: 'json', + url: url, + data: $form.serialize(), + success: function(data){ + if(data && data.status === 0) { + show_success_flash(); + $(document).trigger('prize.save.success'); + $modal.modal('hide'); + } else { + $modal.find('.error').html(data.message) + } + } + }); + } + }); + }) +}); \ No newline at end of file diff --git a/app/assets/javascripts/common.js b/app/assets/javascripts/common.js index e77b42b53..4589f52c2 100644 --- a/app/assets/javascripts/common.js +++ b/app/assets/javascripts/common.js @@ -66,10 +66,32 @@ function customConfirm(opts){ return $.confirm($.extend({}, defaultOpts, opts)) } -function show_success_flash(message) { +function customLoading(opts) { + var loading; + var defaultOpts = { + content: opts.ajax, + contentLoaded: function(){ + setTimeout(function(){ + loading.close() + }, 200); + } + } + loading = $.confirm($.extend({}, defaultOpts, opts)); + return loading; +} + +function show_success_flash(message){ $.notify({ message: message || '操作成功' },{ type: 'success' }); } + +function showErrorNotify(message){ + $.notify({ + message: message || '操作失败' + },{ + type: 'danger' + }); +} diff --git a/app/controllers/admins/competition_prize_users_controller.rb b/app/controllers/admins/competition_prize_users_controller.rb new file mode 100644 index 000000000..50d11e211 --- /dev/null +++ b/app/controllers/admins/competition_prize_users_controller.rb @@ -0,0 +1,41 @@ +class Admins::CompetitionPrizeUsersController < Admins::BaseController + def index + @competition = current_competition + + prize_users = Admins::CompetitionPrizeUserQuery.call(params.merge(competition_id: current_competition.id)) + include_class = [:competition_team, :competition_prize, :approver, + user: [:process_real_name_apply, :process_professional_apply, user_extension: :school]] + @prize_users = paginate(prize_users.preload(include_class)) + end + + def create + Admins::CreateCompetitionPrizeUsersService.call(current_competition) + render_ok + rescue ApplicationService::Error => ex + render_error(ex.message) + end + + def approve + Admins::ApproveCompetitionPrizeUserService.call(current_prize_user, current_user) + @prize_user = current_prize_user + rescue ApplicationService::Error => ex + render_js_error(ex.message, type: :notify) + end + + def unapprove + Admins::UnapproveCompetitionPrizeUserService.call(current_prize_user, current_user) + @prize_user = current_prize_user + rescue ApplicationService::Error => ex + render_js_error(ex.message, type: :notify) + end + + private + + def current_prize_user + @_current_prize_user ||= current_competition.competition_prize_users.find(params[:id]) + end + + def current_competition + @_current_competition ||= Competition.find(params[:competition_id]) + end +end \ No newline at end of file diff --git a/app/controllers/admins/competition_prizes_controller.rb b/app/controllers/admins/competition_prizes_controller.rb new file mode 100644 index 000000000..cde48f96e --- /dev/null +++ b/app/controllers/admins/competition_prizes_controller.rb @@ -0,0 +1,43 @@ +class Admins::CompetitionPrizesController < Admins::BaseController + def index + @competition = current_competition + end + + def new + @prize = current_competition.competition_prizes.new + end + + def create + @prize = current_competition.competition_prizes.create!(save_params) + render_ok + end + + def edit + @prize = current_competition_prize + end + + def update + current_competition_prize.update!(save_params) + render_ok + end + + def destroy + current_competition_prize.destroy! + + render_delete_success + end + + private + + def current_competition_prize + @_current_competition_prize ||= current_competition.competition_prizes.find(params[:id]) + end + + def current_competition + @_current_competition ||= Competition.find(params[:competition_id]) + end + + def save_params + params.require(:competition_prize).permit(:name, :category, :num) + end +end \ No newline at end of file diff --git a/app/controllers/competitions/certificates_controller.rb b/app/controllers/competitions/certificates_controller.rb new file mode 100644 index 000000000..ab52920cd --- /dev/null +++ b/app/controllers/competitions/certificates_controller.rb @@ -0,0 +1,23 @@ +class Competitions::CertificatesController < Competitions::BaseController + def personal + prize_user = CompetitionPrizeUser.find_by!(user: current_user, id: params[:id]) + return render_not_found unless prize_user.certificate_exist? + + team = prize_user.competition_team + prize = prize_user.competition_prize + filename = "#{current_competition.name}-#{prize.name}-#{team.name}-#{prize_user.user.real_name}.pdf" + + send_file prize_user.certificate_path, filename: filename + end + + def team + team = CompetitionTeam.find(id: params[:id]) + return render_forbidden unless team.team_members.exists?(user_id: current_user.id) + return render_not_found unless team.certificate_exist? + + prize = team.competition_prize_users.first.competition_prize + filename = "#{current_competition.name}-#{prize.name}-#{team.name}.pdf" + + send_file team.certificate_path, filename: filename + end +end \ No newline at end of file diff --git a/app/controllers/competitions/competition_modules_controller.rb b/app/controllers/competitions/competition_modules_controller.rb index c4692af70..8c66368fb 100644 --- a/app/controllers/competitions/competition_modules_controller.rb +++ b/app/controllers/competitions/competition_modules_controller.rb @@ -5,6 +5,11 @@ class Competitions::CompetitionModulesController < Competitions::BaseController def index @modules = current_competition.unhidden_competition_modules.order(position: :asc) + + # 未登录、未获奖用户,不展示获奖证书栏目 + if !current_user.logged? || !current_competition.competition_prize_users.exists?(user: current_user) + @modules = @modules.select { |mod| mod.name != '获奖证书' } + end end def show diff --git a/app/controllers/competitions/prize_leader_accounts_controller.rb b/app/controllers/competitions/prize_leader_accounts_controller.rb new file mode 100644 index 000000000..0c01e2738 --- /dev/null +++ b/app/controllers/competitions/prize_leader_accounts_controller.rb @@ -0,0 +1,25 @@ +class Competitions::PrizeLeaderAccountsController < Competitions::BaseController + before_action :require_prize_team_leader! + + def update + Competitions::SavePrizeTeamAccountService.call(current_competition, current_user, update_params) + render_ok + rescue ApplicationService::Error => ex + render_error(ex.message) + end + + private + + def require_prize_team_leader! + prize_user = current_competition.competition_prize_users.joins(:competition_prize) + .where(competition_prizes: { category: :bonus }) + .find_by(leader: true, user_id: current_user.id) + return if prize_user.present? + + render_forbidden + end + + def update_params + params.permit(:bank, :second_bank, :card_no) + end +end \ No newline at end of file diff --git a/app/controllers/competitions/prizes_controller.rb b/app/controllers/competitions/prizes_controller.rb new file mode 100644 index 000000000..aab1df9a1 --- /dev/null +++ b/app/controllers/competitions/prizes_controller.rb @@ -0,0 +1,26 @@ +class Competitions::PrizesController < Competitions::BaseController + before_action :require_prize_user! + + def show + self_prizes = current_competition.competition_prize_users.where(user_id: current_user.id).includes(:competition_team) + + @leader = self_prizes.any?(&:leader?) # 是否为队长 + @bank_account = self_prizes.find(&:leader?).extra if @leader + + @self_prizes = self_prizes.select(&:certificate_exist?) # 个人证书quit + @team_prizes = self_prizes.map(&:competition_team).uniq.select(&:certificate_exists?) # 团队证书 + + prize_users = current_competition.competition_prize_users.where(competition_team_id: self_prizes.map(&:competition_team_id)) + .includes(:competition_team, user: [:user_extension, :process_real_name_apply, :process_professional_apply]) + + @prize_user_map = prize_users.group_by(&:competition_team) + end + + private + + def require_prize_user! + return if current_competition.competition_prize_users.exists?(user: current_user) + + render_forbidden + end +end \ No newline at end of file diff --git a/app/forms/competitions/save_prize_team_account_form.rb b/app/forms/competitions/save_prize_team_account_form.rb new file mode 100644 index 000000000..b048c8368 --- /dev/null +++ b/app/forms/competitions/save_prize_team_account_form.rb @@ -0,0 +1,9 @@ +class Competitions::SavePrizeTeamAccountForm + include ActiveModel::Model + + attr_accessor :bank, :second_bank, :card_no + + validates :bank, presence: true + validates :second_bank, presence: true + validates :card_no, presence: true +end diff --git a/app/helpers/admins/competition_prize_users_helper.rb b/app/helpers/admins/competition_prize_users_helper.rb new file mode 100644 index 000000000..0fa338341 --- /dev/null +++ b/app/helpers/admins/competition_prize_users_helper.rb @@ -0,0 +1,10 @@ +module Admins::CompetitionPrizeUsersHelper + def display_auth_state(flag, other = false, success: nil, normal: nil, error: nil) + success ||= ''.html_safe + normal ||= '--' + error ||= ''.html_safe + + return success if flag + other ? normal : error + end +end \ No newline at end of file diff --git a/app/models/competition.rb b/app/models/competition.rb index 9eac28616..8613e974a 100644 --- a/app/models/competition.rb +++ b/app/models/competition.rb @@ -29,6 +29,9 @@ class Competition < ApplicationRecord has_many :competition_managers, dependent: :destroy has_many :managers, through: :competition_managers, source: :user + has_many :competition_prizes, dependent: :destroy + has_many :competition_prize_users, dependent: :destroy + after_create :create_competition_modules def mode_type @@ -131,7 +134,7 @@ class Competition < ApplicationRecord end def all_module_types - %w[home enroll inform chart resource] + %w[home enroll inform chart resource certificate] end def max_stage_end_time @@ -146,6 +149,10 @@ class Competition < ApplicationRecord user && competition_managers.exists?(user_id: user.id) end + def finished? + end_time.blank? || end_time < Time.now + end + private def get_module_name type @@ -155,6 +162,7 @@ class Competition < ApplicationRecord when 'inform' then '通知公告' when 'chart' then '排行榜' when 'resource' then '资料下载' + when 'certificate' then '获奖证书' else '' end end diff --git a/app/models/competition_prize.rb b/app/models/competition_prize.rb new file mode 100644 index 000000000..8acbc6713 --- /dev/null +++ b/app/models/competition_prize.rb @@ -0,0 +1,21 @@ +class CompetitionPrize < ApplicationRecord + extend Enumerize + + belongs_to :competition + + has_many :competition_prize_users, dependent: :destroy + + enumerize :category, in: %i[bonus unset] + + def self.member_suffix + '_member' + end + + def self.teacher_suffix + '_teacher' + end + + def self.team_suffix + '_team' + end +end \ No newline at end of file diff --git a/app/models/competition_prize_user.rb b/app/models/competition_prize_user.rb new file mode 100644 index 000000000..fe5877e4d --- /dev/null +++ b/app/models/competition_prize_user.rb @@ -0,0 +1,48 @@ +class CompetitionPrizeUser < ApplicationRecord + include AASM + + belongs_to :competition + belongs_to :competition_team + belongs_to :competition_prize + belongs_to :user + belongs_to :approver, class_name: 'User', optional: true # 审批人 + + serialize :extra, JSON + + aasm(:status) do + state :pending, initial: true + state :approved + + event :approve do + transitions from: [:pending], to: :approved, guard: :user_certified? + end + + event :unapprove do + transitions from: [:approved], to: :pending + end + end + + delegate :bank, :second_bank, :card_no, to: :extra, allow_nil: true + + def user_certified? + user.certification? && user.professional_certification? + end + + def certificate_exist? + Util::FileManage.exists?(self) + end + + def certificate_url + Util::FileManage.source_disk_file_url(self) + end + + def certificate_path + Util::FileManage.source_disk_filename(self) + end + + def role_text + return '队长' if leader? + + user.is_teacher? ? '教师' : '队员' + end +end \ No newline at end of file diff --git a/app/models/competition_team.rb b/app/models/competition_team.rb index a05ceb032..ecfdd218a 100644 --- a/app/models/competition_team.rb +++ b/app/models/competition_team.rb @@ -11,6 +11,8 @@ class CompetitionTeam < ApplicationRecord has_many :members, -> { without_teachers }, class_name: 'TeamMember' has_many :teachers, -> { only_teachers }, class_name: 'TeamMember' + has_many :competition_prize_users, dependent: :destroy + def group_team_type? team_type.zero? end @@ -48,4 +50,24 @@ class CompetitionTeam < ApplicationRecord def members_name members.map{|member| member.user.real_name}.join(",") end + + def all_prize_approved? + !competition_prize_users.exists?(status: :pending) + end + + def certificate_exists? + Util::FileManage.exists?(self, self.class.certificate_suffix) + end + + def certificate_url + Util::FileManage.source_disk_file_url(self, self.class.certificate_suffix) + end + + def certificate_path + Util::FileManage.source_disk_filename(self, self.class.certificate_suffix) + end + + def self.certificate_suffix + '_CERT' + end end \ No newline at end of file diff --git a/app/models/user.rb b/app/models/user.rb index 4d13727db..85b9ef551 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -503,6 +503,10 @@ class User < ApplicationRecord phone.present? end + def email_binded? + mail.present? + end + def self.current=(user) Thread.current[:current_user] = user end diff --git a/app/queries/admins/competition_prize_user_query.rb b/app/queries/admins/competition_prize_user_query.rb new file mode 100644 index 000000000..c6cdfb562 --- /dev/null +++ b/app/queries/admins/competition_prize_user_query.rb @@ -0,0 +1,77 @@ +class Admins::CompetitionPrizeUserQuery < ApplicationQuery + include CustomSortable + + attr_reader :params + + sort_columns :rank, default_by: :rank, default_direction: :asc + + def initialize(params) + @params = params + end + + def call + records = CompetitionPrizeUser.all + + # 竞赛过滤 + records = records.where(competition_id: params[:competition_id]) if params[:competition_id].present? + + # 关键字检索 + keyword = params[:keyword].to_s.strip + if keyword.present? + like_sql = 'competition_teams.name LIKE :keyword OR schools.name LIKE :keyword' + records = records.left_joins(:competition_team, user: { user_extension: :school }) + .where(like_sql, keyword: "%#{keyword}%") + end + + # 奖项过滤 + records = records.where(competition_prize_id: params[:prize_id]) if params[:prize_id].present? + + # 审批状态过滤 + records = records.where(status: params[:status]) if params[:status].present? + + # 职业过滤 + if params[:identity].present? + records = records.left_joins(user: :user_extension).where(user_extensions: { identity: params[:identity] }) + end + + # 实名认证过滤 + records = real_name_auth_filter(records) if params[:real_name_auth].present? + + # 职业认证过滤 + records = professional_auth_filter(records) if params[:professional_auth].present? + + custom_sort(records, params[:sort_by], params[:sort_direction]) + end + + private + + def real_name_auth_filter(records) + records = records.left_joins(:user) + sql = ApplyUserAuthentication.real_name_auth.processing.where('apply_user_authentications.user_id = users.id').to_sql + + case params[:real_name_auth] + when 'authed' then + records.where(users: { authentication: true }) + when 'not_authed' then + records.where(users: { authentication: false }).where("NOT EXISTS (#{sql})") + when 'authing' then + records.where(users: { authentication: false }).where("EXISTS (#{sql})") + else records + end + end + + def professional_auth_filter(records) + records = records.left_joins(:user) + sql = ApplyUserAuthentication.professional_auth.processing.where('apply_user_authentications.user_id = users.id').to_sql + + case params[:professional_auth] + when 'authed' then + records.where(users: { professional_certification: true }) + when 'not_authed' then + records.where(users: { professional_certification: false }).where("NOT EXISTS (#{sql})") + when 'authing' then + records.where(users: { professional_certification: false }).where("EXISTS (#{sql})") + else records + end + end +end \ No newline at end of file diff --git a/app/services/admins/approve_competition_prize_user_service.rb b/app/services/admins/approve_competition_prize_user_service.rb new file mode 100644 index 000000000..cd1c2101b --- /dev/null +++ b/app/services/admins/approve_competition_prize_user_service.rb @@ -0,0 +1,26 @@ +class Admins::ApproveCompetitionPrizeUserService < ApplicationService + attr_reader :prize_user, :approver + + def initialize(prize_user, approver) + @prize_user = prize_user + @approver = approver + end + + def call + raise Error, '请勿重复审批' if prize_user.approved? + raise Error, '该用户未认证完成' unless prize_user.user_certified? + + ActiveRecord::Base.transaction do + prize_user.approve + prize_user.approver = approver + prize_user.approved_at = Time.now + prize_user.save! + + if prize_user.competition_team.all_prize_approved? + # TODO: 生成团队证书 + end + + # TODO: 生成个人证书 + end + end +end \ No newline at end of file diff --git a/app/services/admins/create_competition_prize_users_service.rb b/app/services/admins/create_competition_prize_users_service.rb new file mode 100644 index 000000000..0cacaa2f1 --- /dev/null +++ b/app/services/admins/create_competition_prize_users_service.rb @@ -0,0 +1,70 @@ +class Admins::CreateCompetitionPrizeUsersService < ApplicationService + attr_reader :competition + + def initialize(competition) + @competition = competition + end + + def call + raise Error, '竞赛还未结束' unless competition.finished? + raise Error, '请勿重复生成' if competition.competition_prize_users.exists? + raise Error, '请先设置奖项' if prizes.blank? + raise Error, '无获奖队伍' if prize_teams.blank? + + ActiveRecord::Base.transaction do + columns = %i[competition_id competition_team_id competition_prize_id user_id + status rank leader created_at updated_at] + + CompetitionPrizeUser.bulk_insert(*columns) do |worker| + prize_teams.each_with_index do |team, index| + rank = index + 1 + prize = team_prize(rank) # 根据排名获取当前队伍奖项 + + team.team_members.each do |member| + attr = { + competition_id: competition.id, + competition_team_id: team.id, + competition_prize_id: prize.id, + user_id: member.user_id, + leader: member.creator?, + status: :pending, + rank: rank + } + + worker.add(attr) + end + end + end + end + end + + private + + def prizes + @_prizes ||= competition.competition_prizes.order(id: :asc).to_a + end + + def team_prize(rank) + current = 0 + prizes.each do |prize| + return prize if rank > current && rank <= current + prize.num + + current += prize.num + end + end + + def prize_teams + @_prize_teams ||= begin + prize_num_total = prizes.sum(&:num) + + # 只有一个阶段,则成绩为该阶段成绩,否则为stage ID为0的总成绩 + stage_id = competition.competition_stages.count == 1 ? competition.competition_stages.first.id : 0 + + competition.competition_teams.joins(:competition_scores) + .where(competition_scores: { competition_stage_id: stage_id }) + .order("competition_scores.score desc, competition_scores.cost_time desc") + .includes(:team_members) + .limit(prize_num_total) + end + end +end \ No newline at end of file diff --git a/app/services/admins/unapprove_competition_prize_user_service.rb b/app/services/admins/unapprove_competition_prize_user_service.rb new file mode 100644 index 000000000..0bfcd20c1 --- /dev/null +++ b/app/services/admins/unapprove_competition_prize_user_service.rb @@ -0,0 +1,27 @@ +class Admins::UnapproveCompetitionPrizeUserService < ApplicationService + attr_reader :prize_user, :approver + + def initialize(prize_user, approver) + @prize_user = prize_user + @approver = approver + end + + def call + raise Error, '状态有误' if prize_user.pending? + + ActiveRecord::Base.transaction do + prize_user.unapprove + prize_user.approver = approver + prize_user.approved_at = nil + prize_user.save! + + # 删除团队证书 + team_certificate_path = Util::FileManage.source_disk_filename(prize_user.competition_team, CompetitionTeam.certificate_suffix) + File.delete(team_certificate_path) if File.exist?(team_certificate_path) + + # 删除个人证书 + user_certificate_path = Util::FileManage.source_disk_filename(prize_user) + File.delete(user_certificate_path) if File.exist?(user_certificate_path) + end + end +end \ No newline at end of file diff --git a/app/services/competitions/save_prize_team_account_service.rb b/app/services/competitions/save_prize_team_account_service.rb new file mode 100644 index 000000000..60d10cf54 --- /dev/null +++ b/app/services/competitions/save_prize_team_account_service.rb @@ -0,0 +1,19 @@ +class Competitions::SavePrizeTeamAccountService < ApplicationService + attr_reader :competition, :user, :params + + def initialize(competition, user, params) + @competition = competition + @user = user + @params = params + end + + def call + Competitions::SavePrizeTeamAccountForm.new(params).validate! + + prize_leaders = competition.competition_prize_users.where(competition.competition_prize_users) + + raise Error, '审批通过后不能修改' if prize_leaders.exists?(status: :approved) + + prize_leaders.update_all(extra: params) + end +end \ No newline at end of file diff --git a/app/views/admins/competition_prize_users/approve.js.erb b/app/views/admins/competition_prize_users/approve.js.erb new file mode 100644 index 000000000..d8e8f3a66 --- /dev/null +++ b/app/views/admins/competition_prize_users/approve.js.erb @@ -0,0 +1 @@ +$('.competition-prize-user-list-container .competition-prize-user-item-<%= @prize_user.id %>').html("<%= j( render partial: 'admins/competition_prize_users/shared/tr', locals: { prize_user: @prize_user } ) %>"); \ No newline at end of file diff --git a/app/views/admins/competition_prize_users/index.html.erb b/app/views/admins/competition_prize_users/index.html.erb new file mode 100644 index 000000000..dbb86d066 --- /dev/null +++ b/app/views/admins/competition_prize_users/index.html.erb @@ -0,0 +1,58 @@ +<% + define_admin_breadcrumbs do + add_admin_breadcrumb('竞赛列表', admins_competitions_path) + add_admin_breadcrumb(@competition.name) + end +%> + +
奖项 | +排名 | +战队名称 | +真实姓名 | +职业 | +学号 | +单位 | +实名 | +职业 | +手机 | +队长 | +审批时间 | +审批人 | +操作 | +
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
序号 | +奖项名称 | +数量 | +奖励类型 | +队员个人证书模板 | +团队证书模板 | +指导老师证书模板 | +操作 | + + + <%= render 'admins/competition_settings/shared/competition_prizes', competition: @competition %> + +
---|
d)},a.validator.format("Please select no more than {0} files.")),a.validator.addMethod("maxsize",function(b,c,d){if(this.optional(c))return!0;if("file"===a(c).attr("type")&&c.files&&c.files.length)for(var e=0;ed)return!1;return!0},a.validator.format("File size must not exceed {0} bytes each.")),a.validator.addMethod("maxsizetotal",function(b,c,d){if(this.optional(c))return!0;if("file"===a(c).attr("type")&&c.files&&c.files.length)for(var e=0,f=0;f d)return!1;return!0},a.validator.format("Total size of all files must not exceed {0} bytes.")),a.validator.addMethod("mobileNL",function(a,b){return this.optional(b)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(a)},"Please specify a valid mobile number"),a.validator.addMethod("mobileRU",function(a,b){var c=a.replace(/\(|\)|\s+|-/g,"");return this.optional(b)||c.length>9&&/^((\+7|7|8)+([0-9]){10})$/.test(c)},"Please specify a valid mobile number"),a.validator.addMethod("mobileUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/)},"Please specify a valid mobile number"),a.validator.addMethod("netmask",function(a,b){return this.optional(b)||/^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/i.test(a)},"Please enter a valid netmask."),a.validator.addMethod("nieES",function(a,b){"use strict";if(this.optional(b))return!0;var c,d=new RegExp(/^[MXYZ]{1}[0-9]{7,8}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/gi),e="TRWAGMYFPDXBNJZSQVHLCKET",f=a.substr(a.length-1).toUpperCase();return a=a.toString().toUpperCase(),!(a.length>10||a.length<9||!d.test(a))&&(a=a.replace(/^[X]/,"0").replace(/^[Y]/,"1").replace(/^[Z]/,"2"),c=9===a.length?a.substr(0,8):a.substr(0,9),e.charAt(parseInt(c,10)%23)===f)},"Please specify a valid NIE number."),a.validator.addMethod("nifES",function(a,b){"use strict";return!!this.optional(b)||(a=a.toUpperCase(),!!a.match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")&&(/^[0-9]{8}[A-Z]{1}$/.test(a)?"TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.substring(8,0)%23)===a.charAt(8):!!/^[KLM]{1}/.test(a)&&a[8]==="TRWAGMYFPDXBNJZSQVHLCKE".charAt(a.substring(8,1)%23)))},"Please specify a valid NIF number."),a.validator.addMethod("nipPL",function(a){"use strict";if(a=a.replace(/[^0-9]/g,""),10!==a.length)return!1;for(var b=[6,5,7,2,3,4,5,6,7],c=0,d=0;d<9;d++)c+=b[d]*a[d];var e=c%11,f=10===e?0:e;return f===parseInt(a[9],10)},"Please specify a valid NIP number."),a.validator.addMethod("nisBR",function(a){var b,c,d,e,f,g=0;if(a=a.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,""),11!==a.length)return!1;for(c=parseInt(a.substring(10,11),10),b=parseInt(a.substring(0,10),10),e=2;e<12;e++)f=e,10===e&&(f=2),11===e&&(f=3),g+=b%10*f,b=parseInt(b/10,10);return d=g%11,d=d>1?11-d:0,c===d},"Please specify a valid NIS/PIS number"),a.validator.addMethod("notEqualTo",function(b,c,d){return this.optional(c)||!a.validator.methods.equalTo.call(this,b,c,d)},"Please enter a different value, values must not be the same."),a.validator.addMethod("nowhitespace",function(a,b){return this.optional(b)||/^\S+$/i.test(a)},"No white space please"),a.validator.addMethod("pattern",function(a,b,c){return!!this.optional(b)||("string"==typeof c&&(c=new RegExp("^(?:"+c+")$")),c.test(a))},"Invalid format."),a.validator.addMethod("phoneNL",function(a,b){return this.optional(b)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(a)},"Please specify a valid phone number."),a.validator.addMethod("phonePL",function(a,b){a=a.replace(/\s+/g,"");var c=/^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/;return this.optional(b)||c.test(a)},"Please specify a valid phone number"),a.validator.addMethod("phonesUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/)},"Please specify a valid uk phone number"),a.validator.addMethod("phoneUK",function(a,b){return a=a.replace(/\(|\)|\s+|-/g,""),this.optional(b)||a.length>9&&a.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/)},"Please specify a valid phone number"),a.validator.addMethod("phoneUS",function(a,b){return a=a.replace(/\s+/g,""),this.optional(b)||a.length>9&&a.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/)},"Please specify a valid phone number"),a.validator.addMethod("postalcodeBR",function(a,b){return this.optional(b)||/^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(a)},"Informe um CEP válido."),a.validator.addMethod("postalCodeCA",function(a,b){return this.optional(b)||/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] *\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeIT",function(a,b){return this.optional(b)||/^\d{5}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postalcodeNL",function(a,b){return this.optional(b)||/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(a)},"Please specify a valid postal code"),a.validator.addMethod("postcodeUK",function(a,b){return this.optional(b)||/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(a)},"Please specify a valid UK postcode"),a.validator.addMethod("require_from_group",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_req_grp")?f.data("valid_req_grp"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length>=d[0];return f.data("valid_req_grp",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),h},a.validator.format("Please fill at least {0} of these fields.")),a.validator.addMethod("skip_or_fill_minimum",function(b,c,d){var e=a(d[1],c.form),f=e.eq(0),g=f.data("valid_skip")?f.data("valid_skip"):a.extend({},this),h=e.filter(function(){return g.elementValue(this)}).length,i=0===h||h>=d[0];return f.data("valid_skip",g),a(c).data("being_validated")||(e.data("being_validated",!0),e.each(function(){g.element(this)}),e.data("being_validated",!1)),i},a.validator.format("Please either skip these fields or fill at least {0} of them.")),a.validator.addMethod("stateUS",function(a,b,c){var d,e="undefined"==typeof c,f=!e&&"undefined"!=typeof c.caseSensitive&&c.caseSensitive,g=!e&&"undefined"!=typeof c.includeTerritories&&c.includeTerritories,h=!e&&"undefined"!=typeof c.includeMilitary&&c.includeMilitary;return d=g||h?g&&h?"^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":g?"^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":"^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$":"^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$",d=f?new RegExp(d):new RegExp(d,"i"),this.optional(b)||d.test(a)},"Please specify a valid state"),a.validator.addMethod("strippedminlength",function(b,c,d){return a(b).text().length>=d},a.validator.format("Please enter at least {0} characters")),a.validator.addMethod("time",function(a,b){return this.optional(b)||/^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(a)},"Please enter a valid time, between 00:00 and 23:59"),a.validator.addMethod("time12h",function(a,b){return this.optional(b)||/^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(a)},"Please enter a valid time in 12-hour am/pm format"),a.validator.addMethod("url2",function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)},a.validator.messages.url),a.validator.addMethod("vinUS",function(a){if(17!==a.length)return!1;var b,c,d,e,f,g,h=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"],i=[1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9],j=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],k=0;for(b=0;b<17;b++){if(e=j[b],d=a.slice(b,b+1),8===b&&(g=d),isNaN(d)){for(c=0;c '); - } + } } }, styleURL: function() { @@ -19109,7 +19109,7 @@ return Popper; offsetAmt = (parseInt(offsetAmt)+parseInt(this.settings.spacing)) + this.$ele.outerHeight(); this.reposition(offsetAmt); } - + if ($.isFunction(self.settings.onShow)) { self.settings.onShow.call(this.$ele); } @@ -19133,7 +19133,7 @@ return Popper; bind: function() { var self = this; - this.$ele.find('[data-notify="dismiss"]').on('click', function() { + this.$ele.find('[data-notify="dismiss"]').on('click', function() { self.close(); }) @@ -19167,8 +19167,8 @@ return Popper; hasAnimation = false; this.$ele.data('closing', 'true').addClass(this.settings.animate.exit); - self.reposition(posX); - + self.reposition(posX); + if ($.isFunction(self.settings.onClose)) { self.settings.onClose.call(this.$ele); } @@ -21148,7 +21148,7 @@ S2.define('select2/selection/allowClear',[ return; } - var removeAll = this.options.get('translations').get('removeAllItems'); + var removeAll = this.options.get('translations').get('removeAllItems'); var $remove = $( '' + @@ -29428,7 +29428,7 @@ S2.define('jquery.select2',[ '' + '', contTemplate: ' ', - footTemplate: '' + + footTemplate: '' + ' ' + ' ' + '' @@ -29898,13 +29898,35 @@ function customConfirm(opts){ return $.confirm($.extend({}, defaultOpts, opts)) } -function show_success_flash(message) { +function customLoading(opts) { + var loading; + var defaultOpts = { + content: opts.ajax, + contentLoaded: function(){ + setTimeout(function(){ + loading.close() + }, 200); + } + } + loading = $.confirm($.extend({}, defaultOpts, opts)); + return loading; +} + +function show_success_flash(message){ $.notify({ message: message || '操作成功' },{ type: 'success' }); } + +function showErrorNotify(message){ + $.notify({ + message: message || '操作失败' + },{ + type: 'danger' + }); +} ; (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : @@ -38504,7 +38526,7 @@ ZImage.prototype = { // Draw rect text if (style.text != null) { // Only restore transform when needs draw text. - this.restoreTransform(ctx); + this.restoreTransform(ctx); this.drawRectText(ctx, this.getBoundingRect()); } }, @@ -44048,7 +44070,7 @@ Path.prototype = { // Draw rect text if (style.text != null) { // Only restore transform when needs draw text. - this.restoreTransform(ctx); + this.restoreTransform(ctx); this.drawRectText(ctx, this.getBoundingRect()); } }, @@ -75940,7 +75962,7 @@ SeriesModel.extend({ return tree.data; }, - + /** * Make the configuration 'orient' backward compatibly, with 'horizontal = LR', 'vertical = TB'. * @returns {string} orient @@ -76805,7 +76827,7 @@ function commonLayout(seriesModel, api) { var width = 0; var height = 0; var separation$$1 = null; - + if (layout === 'radial') { width = 2 * Math.PI; height = Math.min(layoutInfo.height, layoutInfo.width) / 2; @@ -76862,7 +76884,7 @@ function commonLayout(seriesModel, api) { }); } else { - var orient = seriesModel.getOrient(); + var orient = seriesModel.getOrient(); if (orient === 'RL' || orient === 'LR') { ky = height / (right.getLayout().x + delta + tx); kx = width / ((bottom.depth - 1) || 1); @@ -76886,7 +76908,7 @@ function commonLayout(seriesModel, api) { }); } } - } + } } /* @@ -87518,7 +87540,7 @@ extendChartView({ var width = layoutInfo.width; // view height var height = layoutInfo.height; - + var nodeData = seriesModel.getData(); var edgeData = seriesModel.getData('edge'); @@ -87643,12 +87665,12 @@ extendChartView({ localY: this.shape.y / height }); }; - + el.draggable = true; el.cursor = 'move'; }); } - + if (!this._data && seriesModel.get('animation')) { group.setClipPath(createGridClipShape$2(group.getBoundingRect(), seriesModel, function () { group.removeClipPath(); @@ -87932,7 +87954,7 @@ function computeNodeValues(nodes) { /** * Compute the x-position for each node. - * + * * Here we use Kahn algorithm to detect cycle when we traverse * the node to computer the initial x position. * @@ -87962,7 +87984,7 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width) { zeroIndegrees.push(nodes[i]); } } - + while (zeroIndegrees.length) { each$1(zeroIndegrees, function (node) { node.setLayout({x: x}, true); @@ -87977,18 +87999,18 @@ function computeNodeBreadths(nodes, edges, nodeWidth, width) { } }); }); - + ++x; zeroIndegrees = nextNode; nextNode = []; } - + for (var i = 0; i < remainEdges.length; i++) { if (__DEV__) { if (remainEdges[i] === 1) { throw new Error('Sankey is a DAG, the original data has cycle!'); } - } + } } moveSinksRight(nodes, x); @@ -88296,7 +88318,7 @@ var sankeyVisual = function (ecModel, payload) { maxValue = nodeValue; } }); - + each$1(nodes, function (node) { var mapping = new VisualMapping({ type: 'color', @@ -88304,7 +88326,7 @@ var sankeyVisual = function (ecModel, payload) { dataExtent: [minValue, maxValue], visual: seriesModel.get('color') }); - + var mapValueToColor = mapping.mapValueToVisual(node.getLayout().value); node.setVisual('color', mapValueToColor); // If set itemStyle.normal.color @@ -97332,10 +97354,10 @@ var sunburstLayout = function (seriesType, ecModel, api, payload) { ? unitRadian : (value * unitRadian); if (angle < minAngle) { angle = minAngle; - + } else { - + } endAngle = startAngle + dir * angle; @@ -130129,8 +130151,8 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); /* * Editor.md * - * @file editormd.js - * @version v1.5.0 + * @file editormd.js + * @version v1.5.0 * @description Open source online markdown editor. * @license MIT License * @author Pandao @@ -130141,10 +130163,10 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); ;(function(factory) { "use strict"; - + // CommonJS/Node.js if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { + { module.exports = factory; } else if (typeof define === "function") // AMD/CMD/Sea.js @@ -130152,60 +130174,60 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); if (define.amd) // for Require.js { /* Require.js define replace */ - } - else + } + else { define(["jquery"], factory); // for Sea.js } - } + } else - { + { window.editormd = factory(); } - -}(function() { + +}(function() { /* Require.js assignment replace */ - + "use strict"; - + var $ = (typeof (jQuery) !== "undefined") ? jQuery : Zepto; if (typeof ($) === "undefined") { return ; } - + /** * editormd - * + * * @param {String} id 编辑器的ID * @param {Object} options 配置选项 Key/Value * @returns {Object} editormd 返回editormd对象 */ - + var editormd = function (id, options) { return new editormd.fn.init(id, options); }; - + editormd.title = editormd.$name = "Editor.md"; editormd.version = "1.5.0"; editormd.homePage = "https://pandao.github.io/editor.md/"; editormd.classPrefix = "editormd-"; - + editormd.toolbarModes = { full : [ - "undo", "redo", "|", - "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", - "h1", "h2", "h3", "h4", "h5", "h6", "|", + "undo", "redo", "|", + "bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h4", "h5", "h6", "|", "list-ul", "list-ol", "hr", "|", "link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime", "emoji", "html-entities", "pagebreak", "|", "goto-line", "watch", "preview", "fullscreen", "clear", "search", "|", "help", "info" ], simple : [ - "undo", "redo", "|", - "bold", "del", "italic", "quote", "uppercase", "lowercase", "|", - "h1", "h2", "h3", "h4", "h5", "h6", "|", + "undo", "redo", "|", + "bold", "del", "italic", "quote", "uppercase", "lowercase", "|", + "h1", "h2", "h3", "h4", "h5", "h6", "|", "list-ul", "list-ol", "hr", "|", "watch", "preview", "fullscreen", "|", "help", "info" @@ -130216,7 +130238,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "help", "info" ] }; - + editormd.defaults = { mode : "gfm", //gfm or markdown name : "", // Form element name @@ -130261,7 +130283,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); fontSize : "13px", saveHTMLToTextarea : false, disabledKeyMaps : [], - + onload : function() {}, onresize : function() {}, onchange : function() {}, @@ -130273,20 +130295,20 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); onfullscreenExit : function() {}, onscroll : function() {}, onpreviewscroll : function() {}, - + imageUpload : false, imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"], imageUploadURL : "", crossDomainUpload : false, uploadCallbackURL : "", - + toc : true, // Table of contents tocm : false, // Using [TOCM], auto create ToC dropdown menu tocTitle : "", // for ToC dropdown menu btn tocDropdown : false, tocContainer : "", tocStartLevel : 1, // Said from H1 to create ToC - htmlDecode : false, // Open the HTML tag identification + htmlDecode : false, // Open the HTML tag identification pageBreak : true, // Enable parse page break [========] atLink : true, // for @link emailLink : true, // for email address auto link @@ -130298,7 +130320,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); flowChart : false, // flowChart.js only support IE9+ sequenceDiagram : false, // sequenceDiagram.js only support IE9+ previewCodeHighlight : true, - + toolbar : true, // show/hide toolbar toolbarAutoFixed : true, // on window scroll auto fixed position toolbarIcons : "full", @@ -130314,7 +130336,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); toolbarCustomIcons : { // using html tag create toolbar icon, unused default tag. lowercase : "a", "ucwords" : "Aa" - }, + }, toolbarIconsClass : { undo : "fa-undo", redo : "fa-repeat", @@ -130352,9 +130374,9 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); clear : "fa-eraser", help : "fa-question-circle", info : "fa-info-circle" - }, + }, toolbarIconTexts : {}, - + lang : { name : "zh-cn", description : "开源在线Markdown编辑器
Open source online Markdown editor.", @@ -130432,11 +130454,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); formatNotAllowed : "错误:只允许上传图片文件,允许上传的图片文件格式有:" }, preformattedText : { - title : "添加预格式文本或代码块", + title : "添加预格式文本或代码块", emptyAlert : "错误:请填写预格式文本或代码的内容。" }, codeBlock : { - title : "添加代码块", + title : "添加代码块", selectLabel : "代码语言:", selectDefaultText : "请选择代码语言", otherLanguage : "其他语言", @@ -130452,18 +130474,18 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } } }; - + editormd.classNames = { tex : editormd.classPrefix + "tex" }; editormd.dialogZindex = 99999; - + editormd.$katex = null; editormd.$marked = null; editormd.$CodeMirror = null; editormd.$prettyPrint = null; - + var timer, flowchartTimer; editormd.prototype = editormd.fn = { @@ -130473,76 +130495,76 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); preview : false, fullscreen : false }, - + /** * 构造函数/实例初始化 * Constructor / instance initialization - * + * * @param {String} id 编辑器的ID * @param {Object} [options={}] 配置选项 Key/Value * @returns {editormd} 返回editormd的实例对象 */ - + init : function (id, options) { - + options = options || {}; - + if (typeof id === "object") { options = id; } - + var _this = this; - var classPrefix = this.classPrefix = editormd.classPrefix; + var classPrefix = this.classPrefix = editormd.classPrefix; var settings = this.settings = $.extend(true, editormd.defaults, options); - + id = (typeof id === "object") ? settings.id : id; - + var editor = this.editor = $("#" + id); - + this.id = id; this.lang = settings.lang; - + var classNames = this.classNames = { textarea : { html : classPrefix + "html-textarea", markdown : classPrefix + "markdown-textarea" } }; - - settings.pluginPath = (settings.pluginPath === "") ? settings.path + "../plugins/" : settings.pluginPath; - + + settings.pluginPath = (settings.pluginPath === "") ? settings.path + "../plugins/" : settings.pluginPath; + this.state.watching = (settings.watch) ? true : false; - + if ( !editor.hasClass("editormd") ) { editor.addClass("editormd"); } - + editor.css({ width : (typeof settings.width === "number") ? settings.width + "px" : settings.width, height : (typeof settings.height === "number") ? settings.height + "px" : settings.height }); - + if (settings.autoHeight) { editor.css("height", "auto"); } - + var markdownTextarea = this.markdownTextarea = editor.children("textarea"); - + if (markdownTextarea.length < 1) { editor.append(""); markdownTextarea = this.markdownTextarea = editor.children("textarea"); } - + markdownTextarea.addClass(classNames.textarea.markdown).attr("placeholder", settings.placeholder); - + if (typeof markdownTextarea.attr("name") === "undefined" || markdownTextarea.attr("name") === "") { markdownTextarea.attr("name", (settings.name !== "") ? settings.name : id + "-markdown-doc"); } - + var appendElements = [ (!settings.readOnly) ? "" : "", ( (settings.saveHTMLToTextarea) ? "" : "" ), @@ -130550,114 +130572,114 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "", "" ].join("\n"); - + editor.append(appendElements).addClass(classPrefix + "vertical"); - - if (settings.theme !== "") + + if (settings.theme !== "") { editor.addClass(classPrefix + "theme-" + settings.theme); } - - this.mask = editor.children("." + classPrefix + "mask"); + + this.mask = editor.children("." + classPrefix + "mask"); this.containerMask = editor.children("." + classPrefix + "container-mask"); - + if (settings.markdown !== "") { markdownTextarea.val(settings.markdown); } - + if (settings.appendMarkdown !== "") { markdownTextarea.val(markdownTextarea.val() + settings.appendMarkdown); } - - this.htmlTextarea = editor.children("." + classNames.textarea.html); + + this.htmlTextarea = editor.children("." + classNames.textarea.html); this.preview = editor.children("." + classPrefix + "preview"); this.previewContainer = this.preview.children("." + classPrefix + "preview-container"); - - if (settings.previewTheme !== "") + + if (settings.previewTheme !== "") { this.preview.addClass(classPrefix + "preview-theme-" + settings.previewTheme); } - + if (typeof define === "function" && define.amd) { - if (typeof katex !== "undefined") + if (typeof katex !== "undefined") { editormd.$katex = katex; } - - if (settings.searchReplace && !settings.readOnly) + + if (settings.searchReplace && !settings.readOnly) { editormd.loadCSS(settings.path + "codemirror/addon/dialog/dialog"); editormd.loadCSS(settings.path + "codemirror/addon/search/matchesonscrollbar"); } } - + if ((typeof define === "function" && define.amd) || !settings.autoLoadModules) { if (typeof CodeMirror !== "undefined") { editormd.$CodeMirror = CodeMirror; } - + if (typeof marked !== "undefined") { editormd.$marked = marked; } - + this.setCodeMirror().setToolbar().loadedDisplay(); - } - else + } + else { this.loadQueues(); } return this; }, - + /** * 所需组件加载队列 * Required components loading queue - * + * * @returns {editormd} 返回editormd的实例对象 */ - + loadQueues : function() { var _this = this; var settings = this.settings; var loadPath = settings.path; - + var loadFlowChartOrSequenceDiagram = function() { - - if (editormd.isIE8) + + if (editormd.isIE8) { _this.loadedDisplay(); - + return ; } - if (settings.flowChart || settings.sequenceDiagram) + if (settings.flowChart || settings.sequenceDiagram) { editormd.loadScript(loadPath + "raphael.min", function() { - editormd.loadScript(loadPath + "underscore.min", function() { + editormd.loadScript(loadPath + "underscore.min", function() { - if (!settings.flowChart && settings.sequenceDiagram) + if (!settings.flowChart && settings.sequenceDiagram) { editormd.loadScript(loadPath + "sequence-diagram.min", function() { _this.loadedDisplay(); }); } - else if (settings.flowChart && !settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "flowchart.min", function() { + else if (settings.flowChart && !settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { editormd.loadScript(loadPath + "jquery.flowchart.min", function() { _this.loadedDisplay(); }); }); } - else if (settings.flowChart && settings.sequenceDiagram) - { - editormd.loadScript(loadPath + "flowchart.min", function() { + else if (settings.flowChart && settings.sequenceDiagram) + { + editormd.loadScript(loadPath + "flowchart.min", function() { editormd.loadScript(loadPath + "jquery.flowchart.min", function() { editormd.loadScript(loadPath + "sequence-diagram.min", function() { _this.loadedDisplay(); @@ -130668,157 +130690,157 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }); }); - } + } else { _this.loadedDisplay(); } - }; + }; editormd.loadCSS(loadPath + "codemirror/codemirror.min"); - + if (settings.searchReplace && !settings.readOnly) { editormd.loadCSS(loadPath + "codemirror/addon/dialog/dialog"); editormd.loadCSS(loadPath + "codemirror/addon/search/matchesonscrollbar"); } - + if (settings.codeFold) { - editormd.loadCSS(loadPath + "codemirror/addon/fold/foldgutter"); + editormd.loadCSS(loadPath + "codemirror/addon/fold/foldgutter"); } - + editormd.loadScript(loadPath + "codemirror/codemirror.min", function() { editormd.$CodeMirror = CodeMirror; - + editormd.loadScript(loadPath + "codemirror/modes.min", function() { - + editormd.loadScript(loadPath + "codemirror/addons.min", function() { - + _this.setCodeMirror(); - - if (settings.mode !== "gfm" && settings.mode !== "markdown") + + if (settings.mode !== "gfm" && settings.mode !== "markdown") { _this.loadedDisplay(); - + return false; } - + _this.setToolbar(); editormd.loadScript(loadPath + "marked.min", function() { editormd.$marked = marked; - - if (settings.previewCodeHighlight) + + if (settings.previewCodeHighlight) { editormd.loadScript(loadPath + "prettify.min", function() { loadFlowChartOrSequenceDiagram(); }); - } + } else - { + { loadFlowChartOrSequenceDiagram(); } }); - + }); - + }); - + }); return this; }, - + /** * 设置 Editor.md 的整体主题,主要是工具栏 * Setting Editor.md theme - * + * * @returns {editormd} 返回editormd的实例对象 */ - + setTheme : function(theme) { var editor = this.editor; var oldTheme = this.settings.theme; var themePrefix = this.classPrefix + "theme-"; - + editor.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); - + this.settings.theme = theme; - + return this; }, - + /** * 设置 CodeMirror(编辑区)的主题 * Setting CodeMirror (Editor area) theme - * + * * @returns {editormd} 返回editormd的实例对象 */ - - setEditorTheme : function(theme) { - var settings = this.settings; - settings.editorTheme = theme; - + + setEditorTheme : function(theme) { + var settings = this.settings; + settings.editorTheme = theme; + if (theme !== "default") { editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); } - + this.cm.setOption("theme", theme); - + return this; }, - + /** * setEditorTheme() 的别名 * setEditorTheme() alias - * + * * @returns {editormd} 返回editormd的实例对象 */ - - setCodeMirrorTheme : function (theme) { + + setCodeMirrorTheme : function (theme) { this.setEditorTheme(theme); - + return this; }, - + /** * 设置 Editor.md 的主题 * Setting Editor.md theme - * + * * @returns {editormd} 返回editormd的实例对象 */ - - setPreviewTheme : function(theme) { + + setPreviewTheme : function(theme) { var preview = this.preview; var oldTheme = this.settings.previewTheme; var themePrefix = this.classPrefix + "preview-theme-"; - + preview.removeClass(themePrefix + oldTheme).addClass(themePrefix + theme); - + this.settings.previewTheme = theme; - + return this; }, - + /** * 配置和初始化CodeMirror组件 * CodeMirror initialization - * + * * @returns {editormd} 返回editormd的实例对象 */ - - setCodeMirror : function() { + + setCodeMirror : function() { var settings = this.settings; var editor = this.editor; - + if (settings.editorTheme !== "default") { editormd.loadCSS(settings.path + "codemirror/theme/" + settings.editorTheme); } - + var codeMirrorConfig = { mode : settings.mode, theme : settings.editorTheme, @@ -130831,8 +130853,8 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); lineNumbers : settings.lineNumbers, lineWrapping : settings.lineWrapping, extraKeys : { - "Ctrl-Q": function(cm) { - cm.foldCode(cm.getCursor()); + "Ctrl-Q": function(cm) { + cm.foldCode(cm.getCursor()); } }, foldGutter : settings.codeFold, @@ -130845,10 +130867,10 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); showTrailingSpace : settings.showTrailingSpace, highlightSelectionMatches : ( (!settings.matchWordHighlight) ? false : { showToken: (settings.matchWordHighlight === "onselected") ? false : /\w/ } ) }; - + this.codeEditor = this.cm = editormd.$CodeMirror.fromTextArea(this.markdownTextarea[0], codeMirrorConfig); this.codeMirror = this.cmElement = editor.children(".CodeMirror"); - + if (settings.value !== "") { this.cm.setValue(settings.value); @@ -130858,13 +130880,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); fontSize : settings.fontSize, width : (!settings.watch) ? "100%" : "50%" }); - + if (settings.autoHeight) { this.codeMirror.css("height", "auto"); this.cm.setOption("viewportMargin", Infinity); } - + if (!settings.lineNumbers) { this.codeMirror.find(".CodeMirror-gutters").css("border-right", "none"); @@ -130872,149 +130894,149 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 获取CodeMirror的配置选项 * Get CodeMirror setting options - * + * * @returns {Mixed} return CodeMirror setting option value */ - - getCodeMirrorOption : function(key) { + + getCodeMirrorOption : function(key) { return this.cm.getOption(key); }, - + /** * 配置和重配置CodeMirror的选项 * CodeMirror setting options / resettings - * + * * @returns {editormd} 返回editormd的实例对象 */ - + setCodeMirrorOption : function(key, value) { - + this.cm.setOption(key, value); - + return this; }, - + /** * 添加 CodeMirror 键盘快捷键 * Add CodeMirror keyboard shortcuts key map - * + * * @returns {editormd} 返回editormd的实例对象 */ - + addKeyMap : function(map, bottom) { this.cm.addKeyMap(map, bottom); - + return this; }, - + /** * 移除 CodeMirror 键盘快捷键 * Remove CodeMirror keyboard shortcuts key map - * + * * @returns {editormd} 返回editormd的实例对象 */ - + removeKeyMap : function(map) { this.cm.removeKeyMap(map); - + return this; }, - + /** * 跳转到指定的行 * Goto CodeMirror line - * + * * @param {String|Intiger} line line number or "first"|"last" * @returns {editormd} 返回editormd的实例对象 */ - + gotoLine : function (line) { - + var settings = this.settings; - + if (!settings.gotoLine) { return this; } - + var cm = this.cm; var editor = this.editor; var count = cm.lineCount(); var preview = this.preview; - + if (typeof line === "string") { if(line === "last") { line = count; } - + if (line === "first") { line = 1; } } - - if (typeof line !== "number") - { + + if (typeof line !== "number") + { alert("Error: The line number must be an integer."); return this; } - + line = parseInt(line) - 1; - + if (line > count) { alert("Error: The line number range 1-" + count); - + return this; } - + cm.setCursor( {line : line, ch : 0} ); - + var scrollInfo = cm.getScrollInfo(); - var clientHeight = scrollInfo.clientHeight; + var clientHeight = scrollInfo.clientHeight; var coords = cm.charCoords({line : line, ch : 0}, "local"); - + cm.scrollTo(null, (coords.top + coords.bottom - clientHeight) / 2); - + if (settings.watch) - { + { var cmScroll = this.codeMirror.find(".CodeMirror-scroll")[0]; - var height = $(cmScroll).height(); - var scrollTop = cmScroll.scrollTop; + var height = $(cmScroll).height(); + var scrollTop = cmScroll.scrollTop; var percent = (scrollTop / cmScroll.scrollHeight); if (scrollTop === 0) { preview.scrollTop(0); - } + } else if (scrollTop + height >= cmScroll.scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } + { + preview.scrollTop(preview[0].scrollHeight); + } else - { + { preview.scrollTop(preview[0].scrollHeight * percent); } } cm.focus(); - + return this; }, - + /** * 扩展当前实例对象,可同时设置多个或者只设置一个 * Extend editormd instance object, can mutil setting. - * + * * @returns {editormd} this(editormd instance object.) */ - + extend : function() { if (typeof arguments[1] !== "undefined") { @@ -131025,7 +131047,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); this[arguments[0]] = arguments[1]; } - + if (typeof arguments[0] === "object" && typeof arguments[0].length === "undefined") { $.extend(true, this, arguments[0]); @@ -131033,168 +131055,168 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 设置或扩展当前实例对象,单个设置 * Extend editormd instance object, one by one - * + * * @param {String|Object} key option key * @param {String|Object} value option value * @returns {editormd} this(editormd instance object.) */ - + set : function (key, value) { - + if (typeof value !== "undefined" && typeof value === "function") { value = $.proxy(value, this); } - + this[key] = value; return this; }, - + /** * 重新配置 * Resetting editor options - * + * * @param {String|Object} key option key * @param {String|Object} value option value * @returns {editormd} this(editormd instance object.) */ - + config : function(key, value) { var settings = this.settings; - + if (typeof key === "object") { settings = $.extend(true, settings, key); } - + if (typeof key === "string") { settings[key] = value; } - + this.settings = settings; this.recreate(); - + return this; }, - + /** * 注册事件处理方法 * Bind editor event handle - * + * * @param {String} eventType event type * @param {Function} callback 回调函数 * @returns {editormd} this(editormd instance object.) */ - + on : function(eventType, callback) { var settings = this.settings; - - if (typeof settings["on" + eventType] !== "undefined") - { - settings["on" + eventType] = $.proxy(callback, this); + + if (typeof settings["on" + eventType] !== "undefined") + { + settings["on" + eventType] = $.proxy(callback, this); } return this; }, - + /** * 解除事件处理方法 * Unbind editor event handle - * + * * @param {String} eventType event type * @returns {editormd} this(editormd instance object.) */ - + off : function(eventType) { var settings = this.settings; - - if (typeof settings["on" + eventType] !== "undefined") + + if (typeof settings["on" + eventType] !== "undefined") { settings["on" + eventType] = function(){}; } - + return this; }, - + /** * 显示工具栏 * Display toolbar - * + * * @param {Function} [callback=function(){}] 回调函数 * @returns {editormd} 返回editormd的实例对象 */ - + showToolbar : function(callback) { var settings = this.settings; - + if(settings.readOnly) { return this; } - + if (settings.toolbar && (this.toolbar.length < 1 || this.toolbar.find("." + this.classPrefix + "menu").html() === "") ) { this.setToolbar(); } - - settings.toolbar = true; - + + settings.toolbar = true; + this.toolbar.show(); this.resize(); - + $.proxy(callback || function(){}, this)(); return this; }, - + /** * 隐藏工具栏 * Hide toolbar - * + * * @param {Function} [callback=function(){}] 回调函数 * @returns {editormd} this(editormd instance object.) */ - - hideToolbar : function(callback) { + + hideToolbar : function(callback) { var settings = this.settings; - - settings.toolbar = false; + + settings.toolbar = false; this.toolbar.hide(); this.resize(); - + $.proxy(callback || function(){}, this)(); return this; }, - + /** * 页面滚动时工具栏的固定定位 * Set toolbar in window scroll auto fixed position - * + * * @returns {editormd} 返回editormd的实例对象 */ - + setToolbarAutoFixed : function(fixed) { - + var state = this.state; var editor = this.editor; var toolbar = this.toolbar; var settings = this.settings; - + if (typeof fixed !== "undefined") { settings.toolbarAutoFixed = fixed; } - + var autoFixedHandle = function(){ var $window = $(window); var top = $window.scrollTop(); - + if (!settings.toolbarAutoFixed) { return false; @@ -131217,7 +131239,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }); } }; - + if (!state.fullscreen && !state.preview && settings.toolbar && settings.toolbarAutoFixed) { $(window).bind("scroll", autoFixedHandle); @@ -131225,58 +131247,58 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 配置和初始化工具栏 * Set toolbar and Initialization - * + * * @returns {editormd} 返回editormd的实例对象 */ - + setToolbar : function() { - var settings = this.settings; - + var settings = this.settings; + if(settings.readOnly) { return this; } - + var editor = this.editor; var preview = this.preview; var classPrefix = this.classPrefix; - + var toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); - + if (settings.toolbar && toolbar.length < 1) - { + { var toolbarHTML = ""; - + editor.append(toolbarHTML); toolbar = this.toolbar = editor.children("." + classPrefix + "toolbar"); } - - if (!settings.toolbar) + + if (!settings.toolbar) { toolbar.hide(); - + return this; } - + toolbar.show(); - - var icons = (typeof settings.toolbarIcons === "function") ? settings.toolbarIcons() + + var icons = (typeof settings.toolbarIcons === "function") ? settings.toolbarIcons() : ((typeof settings.toolbarIcons === "string") ? editormd.toolbarModes[settings.toolbarIcons] : settings.toolbarIcons); - + var toolbarMenu = toolbar.find("." + this.classPrefix + "menu"), menu = ""; var pullRight = false; - + for (var i = 0, len = icons.length; i < len; i++) { var name = icons[i]; - if (name === "||") - { + if (name === "||") + { pullRight = true; - } + } else if (name === "|") { menu += "| "; @@ -131285,26 +131307,26 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { var isHeader = (/h(\d)/.test(name)); var index = name; - + if (name === "watch" && !settings.watch) { index = "unwatch"; } - + var title = settings.lang.toolbar[index]; var iconTexts = settings.toolbarIconTexts[index]; var iconClass = settings.toolbarIconsClass[index]; - + title = (typeof title === "undefined") ? "" : title; iconTexts = (typeof iconTexts === "undefined") ? "" : iconTexts; iconClass = (typeof iconClass === "undefined") ? "" : iconClass; var menuItem = pullRight ? "" : " "; - + if (typeof settings.toolbarCustomIcons[name] !== "undefined" && typeof settings.toolbarCustomIcons[name] !== "function") { menuItem += settings.toolbarCustomIcons[name]; } - else + else { menuItem += ""; menuItem += ""+((isHeader) ? name.toUpperCase() : ( (iconClass === "") ? iconTexts : "") ) + ""; @@ -131318,64 +131340,64 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } toolbarMenu.html(menu); - + toolbarMenu.find("[title=\"Lowercase\"]").attr("title", settings.lang.toolbar.lowercase); toolbarMenu.find("[title=\"ucwords\"]").attr("title", settings.lang.toolbar.ucwords); - + this.setToolbarHandler(); this.setToolbarAutoFixed(); return this; }, - + /** * 工具栏图标事件处理对象序列 * Get toolbar icons event handlers - * + * * @param {Object} cm CodeMirror的实例对象 * @param {String} name 要获取的事件处理器名称 * @returns {Object} 返回处理对象序列 */ - + dialogLockScreen : function() { $.proxy(editormd.dialogLockScreen, this)(); - + return this; }, dialogShowMask : function(dialog) { $.proxy(editormd.dialogShowMask, this)(dialog); - + return this; }, - - getToolbarHandles : function(name) { + + getToolbarHandles : function(name) { var toolbarHandlers = this.toolbarHandlers = editormd.toolbarHandlers; - + return (name && typeof toolbarIconHandlers[name] !== "undefined") ? toolbarHandlers[name] : toolbarHandlers; }, - + /** * 工具栏图标事件处理器 * Bind toolbar icons event handle - * + * * @returns {editormd} 返回editormd的实例对象 */ - + setToolbarHandler : function() { var _this = this; var settings = this.settings; - + if (!settings.toolbar || settings.readOnly) { return this; } - + var toolbar = this.toolbar; var cm = this.cm; - var classPrefix = this.classPrefix; - var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); - var toolbarIconHandlers = this.getToolbarHandles(); - + var classPrefix = this.classPrefix; + var toolbarIcons = this.toolbarIcons = toolbar.find("." + classPrefix + "menu > li > a"); + var toolbarIconHandlers = this.getToolbarHandles(); + toolbarIcons.bind(editormd.mouseOrTouch("click", "touchend"), function(event) { var icon = $(this).children(".fa"); @@ -131386,23 +131408,23 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); if (name === "") { return ; } - + _this.activeIcon = icon; - if (typeof toolbarIconHandlers[name] !== "undefined") + if (typeof toolbarIconHandlers[name] !== "undefined") { $.proxy(toolbarIconHandlers[name], _this)(cm); } - else + else { - if (typeof settings.toolbarHandlers[name] !== "undefined") + if (typeof settings.toolbarHandlers[name] !== "undefined") { $.proxy(settings.toolbarHandlers[name], _this)(cm, icon, cursor, selection); } } - - if (name !== "link" && name !== "reference-link" && name !== "image" && name !== "code-block" && - name !== "preformatted-text" && name !== "watch" && name !== "preview" && name !== "search" && name !== "fullscreen" && name !== "info") + + if (name !== "link" && name !== "reference-link" && name !== "image" && name !== "code-block" && + name !== "preformatted-text" && name !== "watch" && name !== "preview" && name !== "search" && name !== "fullscreen" && name !== "info") { cm.focus(); } @@ -131413,31 +131435,31 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 动态创建对话框 * Creating custom dialogs - * + * * @param {Object} options 配置项键值对 Key/Value * @returns {dialog} 返回创建的dialog的jQuery实例对象 */ - - createDialog : function(options) { + + createDialog : function(options) { return $.proxy(editormd.createDialog, this)(options); }, - + /** * 创建关于Editor.md的对话框 * Create about Editor.md dialog - * + * * @returns {editormd} 返回editormd的实例对象 */ - + createInfoDialog : function() { var _this = this; var editor = this.editor; - var classPrefix = this.classPrefix; - + var classPrefix = this.classPrefix; + var infoDialogHTML = [ " ", "", @@ -131451,30 +131473,30 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); ].join("\n"); editor.append(infoDialogHTML); - + var infoDialog = this.infoDialog = editor.children("." + classPrefix + "dialog-info"); infoDialog.find("." + classPrefix + "dialog-close").bind(editormd.mouseOrTouch("click", "touchend"), function() { _this.hideInfoDialog(); }); - + infoDialog.css("border", (editormd.isIE8) ? "1px solid #ddd" : "").css("z-index", editormd.dialogZindex).show(); - + this.infoDialogPosition(); return this; }, - + /** * 关于Editor.md对话居中定位 * Editor.md dialog position handle - * + * * @returns {editormd} 返回editormd的实例对象 */ - + infoDialogPosition : function() { var infoDialog = this.infoDialog; - + var _infoDialogPosition = function() { infoDialog.css({ top : ($(window).height() - infoDialog.height()) / 2 + "px", @@ -131485,33 +131507,33 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); _infoDialogPosition(); $(window).resize(_infoDialogPosition); - + return this; }, - + /** * 显示关于Editor.md * Display about Editor.md dialog - * + * * @returns {editormd} 返回editormd的实例对象 */ - + showInfoDialog : function() { $("html,body").css("overflow-x", "hidden"); - + var _this = this; var editor = this.editor; - var settings = this.settings; + var settings = this.settings; var infoDialog = this.infoDialog = editor.children("." + this.classPrefix + "dialog-info"); - + if (infoDialog.length < 1) { this.createInfoDialog(); } - + this.lockScreen(true); - + this.mask.css({ opacity : settings.dialogMaskOpacity, backgroundColor : settings.dialogMaskBgColor @@ -131523,15 +131545,15 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 隐藏关于Editor.md * Hide about Editor.md dialog - * + * * @returns {editormd} 返回editormd的实例对象 */ - - hideInfoDialog : function() { + + hideInfoDialog : function() { $("html,body").css("overflow-x", ""); this.infoDialog.hide(); this.mask.hide(); @@ -131539,116 +131561,116 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 锁屏 * lock screen - * + * * @param {Boolean} lock Boolean 布尔值,是否锁屏 * @returns {editormd} 返回editormd的实例对象 */ - + lockScreen : function(lock) { editormd.lockScreen(lock); this.resize(); return this; }, - + /** * 编辑器界面重建,用于动态语言包或模块加载等 * Recreate editor - * + * * @returns {editormd} 返回editormd的实例对象 */ - + recreate : function() { var _this = this; var editor = this.editor; var settings = this.settings; - + this.codeMirror.remove(); - + this.setCodeMirror(); - if (!settings.readOnly) + if (!settings.readOnly) { if (editor.find(".editormd-dialog").length > 0) { editor.find(".editormd-dialog").remove(); } - - if (settings.toolbar) - { - this.getToolbarHandles(); + + if (settings.toolbar) + { + this.getToolbarHandles(); this.setToolbar(); } } - + this.loadedDisplay(true); return this; }, - + /** * 高亮预览HTML的pre代码部分 * highlight of preview codes - * + * * @returns {editormd} 返回editormd的实例对象 */ - - previewCodeHighlight : function() { + + previewCodeHighlight : function() { var settings = this.settings; var previewContainer = this.previewContainer; - - if (settings.previewCodeHighlight) + + if (settings.previewCodeHighlight) { previewContainer.find("pre").addClass("prettyprint linenums"); - + if (typeof prettyPrint !== "undefined") - { + { prettyPrint(); } } return this; }, - + /** * 解析TeX(KaTeX)科学公式 * TeX(KaTeX) Renderer - * + * * @returns {editormd} 返回editormd的实例对象 */ - + katexRender : function() { - + if (timer === null) { return this; } - + this.previewContainer.find("." + editormd.classNames.tex).each(function(){ var tex = $(this); editormd.$katex.render(tex.text(), tex[0]); - + tex.find(".katex").css("font-size", "1.6em"); - }); + }); return this; }, - + /** * 解析和渲染流程图及时序图 * FlowChart and SequenceDiagram Renderer - * + * * @returns {editormd} 返回editormd的实例对象 */ - + flowChartAndSequenceDiagramRender : function() { var $this = this; var settings = this.settings; var previewContainer = this.previewContainer; - + if (editormd.isIE8) { return this; } @@ -131657,20 +131679,20 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); if (flowchartTimer === null) { return this; } - - previewContainer.find(".flowchart").flowChart(); + + previewContainer.find(".flowchart").flowChart(); } if (settings.sequenceDiagram) { previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"}); } - + var preview = $this.preview; var codeMirror = $this.codeMirror; var codeView = codeMirror.find(".CodeMirror-scroll"); var height = codeView.height(); - var scrollTop = codeView.scrollTop(); + var scrollTop = codeView.scrollTop(); var percent = (scrollTop / codeView[0].scrollHeight); var tocHeight = 0; @@ -131678,43 +131700,43 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); tocHeight += $(this).height(); }); - var tocMenuHeight = preview.find(".editormd-toc-menu").height(); + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; - if (scrollTop === 0) + if (scrollTop === 0) { preview.scrollTop(0); - } + } else if (scrollTop + height >= codeView[0].scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } + { + preview.scrollTop(preview[0].scrollHeight); + } else - { + { preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); } return this; }, - + /** * 注册键盘快捷键处理 * Register CodeMirror keyMaps (keyboard shortcuts). - * + * * @param {Object} keyMap KeyMap key/value {"(Ctrl/Shift/Alt)-Key" : function(){}} * @returns {editormd} return this */ - + registerKeyMaps : function(keyMap) { - + var _this = this; var cm = this.cm; var settings = this.settings; var toolbarHandlers = editormd.toolbarHandlers; var disabledKeyMaps = settings.disabledKeyMaps; - + keyMap = keyMap || null; - + if (keyMap) { for (var i in keyMap) @@ -131734,7 +131756,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { var _keyMap = editormd.keyMaps[k]; var handle = (typeof _keyMap === "string") ? $.proxy(toolbarHandlers[_keyMap], _this) : $.proxy(_keyMap, _this); - + if ($.inArray(k, ["F9", "F10", "F11"]) < 0 && $.inArray(k, disabledKeyMaps) < 0) { var _map = {}; @@ -131743,15 +131765,15 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.addKeyMap(_map); } } - + $(window).keydown(function(event) { - + var keymaps = { "120" : "F9", "121" : "F10", "122" : "F11" }; - + if ( $.inArray(keymaps[event.keyCode], disabledKeyMaps) < 0 ) { switch (event.keyCode) @@ -131760,17 +131782,17 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); $.proxy(toolbarHandlers["watch"], _this)(); return false; break; - + case 121: $.proxy(toolbarHandlers["preview"], _this)(); return false; break; - + case 122: - $.proxy(toolbarHandlers["fullscreen"], _this)(); + $.proxy(toolbarHandlers["fullscreen"], _this)(); return false; break; - + default: break; } @@ -131780,53 +131802,53 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 绑定同步滚动 - * + * * @returns {editormd} return this */ - + bindScrollEvent : function() { - + var _this = this; var preview = this.preview; var settings = this.settings; var codeMirror = this.codeMirror; var mouseOrTouch = editormd.mouseOrTouch; - + if (!settings.syncScrolling) { return this; } - - var cmBindScroll = function() { + + var cmBindScroll = function() { codeMirror.find(".CodeMirror-scroll").bind(mouseOrTouch("scroll", "touchmove"), function(event) { var height = $(this).height(); - var scrollTop = $(this).scrollTop(); + var scrollTop = $(this).scrollTop(); var percent = (scrollTop / $(this)[0].scrollHeight); - + var tocHeight = 0; - + preview.find(".markdown-toc-list").each(function(){ tocHeight += $(this).height(); }); - + var tocMenuHeight = preview.find(".editormd-toc-menu").height(); tocMenuHeight = (!tocMenuHeight) ? 0 : tocMenuHeight; - if (scrollTop === 0) + if (scrollTop === 0) { preview.scrollTop(0); - } + } else if (scrollTop + height >= $(this)[0].scrollHeight - 16) - { - preview.scrollTop(preview[0].scrollHeight); - } + { + preview.scrollTop(preview[0].scrollHeight); + } else { preview.scrollTop((preview[0].scrollHeight + tocHeight + tocMenuHeight) * percent); } - + $.proxy(settings.onscroll, _this)(event); }); }; @@ -131836,26 +131858,26 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }; var previewBindScroll = function() { - + preview.bind(mouseOrTouch("scroll", "touchmove"), function(event) { var height = $(this).height(); - var scrollTop = $(this).scrollTop(); + var scrollTop = $(this).scrollTop(); var percent = (scrollTop / $(this)[0].scrollHeight); var codeView = codeMirror.find(".CodeMirror-scroll"); - if(scrollTop === 0) + if(scrollTop === 0) { codeView.scrollTop(0); } else if (scrollTop + height >= $(this)[0].scrollHeight) { - codeView.scrollTop(codeView[0].scrollHeight); + codeView.scrollTop(codeView[0].scrollHeight); } - else + else { codeView.scrollTop(codeView[0].scrollHeight * percent); } - + $.proxy(settings.onpreviewscroll, _this)(event); }); @@ -131863,7 +131885,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var previewUnbindScroll = function() { preview.unbind(mouseOrTouch("scroll", "touchmove")); - }; + }; codeMirror.bind({ mouseover : cmBindScroll, @@ -131871,11 +131893,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); touchstart : cmBindScroll, touchend : cmUnbindScroll }); - + if (settings.syncScrolling === "single") { return this; } - + preview.bind({ mouseover : previewBindScroll, mouseout : previewUnbindScroll, @@ -131885,24 +131907,24 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + bindChangeEvent : function() { - + var _this = this; var cm = this.cm; var settings = this.settings; - + if (!settings.syncScrolling) { return this; } - + cm.on("change", function(_cm, changeObj) { - + if (settings.watch) { _this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); } - + timer = setTimeout(function() { clearTimeout(timer); _this.save(); @@ -131912,210 +131934,210 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 加载队列完成之后的显示处理 * Display handle of the module queues loaded after. - * + * * @param {Boolean} recreate 是否为重建编辑器 * @returns {editormd} 返回editormd的实例对象 */ - + loadedDisplay : function(recreate) { - + recreate = recreate || false; - + var _this = this; var editor = this.editor; var preview = this.preview; var settings = this.settings; - + this.containerMask.hide(); - + this.save(); - + if (settings.watch) { preview.show(); } - + editor.data("oldWidth", editor.width()).data("oldHeight", editor.height()); // 为了兼容Zepto - + this.resize(); this.registerKeyMaps(); - + $(window).resize(function(){ _this.resize(); }); - + this.bindScrollEvent().bindChangeEvent(); - + if (!recreate) { $.proxy(settings.onload, this)(); } - + this.state.loaded = true; return this; }, - + /** * 设置编辑器的宽度 * Set editor width - * + * * @param {Number|String} width 编辑器宽度值 * @returns {editormd} 返回editormd的实例对象 */ - + width : function(width) { - - this.editor.css("width", (typeof width === "number") ? width + "px" : width); + + this.editor.css("width", (typeof width === "number") ? width + "px" : width); this.resize(); - + return this; }, - + /** * 设置编辑器的高度 * Set editor height - * + * * @param {Number|String} height 编辑器高度值 * @returns {editormd} 返回editormd的实例对象 */ - + height : function(height) { - - this.editor.css("height", (typeof height === "number") ? height + "px" : height); + + this.editor.css("height", (typeof height === "number") ? height + "px" : height); this.resize(); - + return this; }, - + /** * 调整编辑器的尺寸和布局 * Resize editor layout - * + * * @param {Number|String} [width=null] 编辑器宽度值 * @param {Number|String} [height=null] 编辑器高度值 * @returns {editormd} 返回editormd的实例对象 */ - + resize : function(width, height) { - + width = width || null; height = height || null; - + var state = this.state; var editor = this.editor; var preview = this.preview; var toolbar = this.toolbar; var settings = this.settings; var codeMirror = this.codeMirror; - + if (width) { editor.css("width", (typeof width === "number") ? width + "px" : width); } - + if (settings.autoHeight && !state.fullscreen && !state.preview) { editor.css("height", "auto"); codeMirror.css("height", "auto"); - } - else + } + else { - if (height) + if (height) { editor.css("height", (typeof height === "number") ? height + "px" : height); } - + if (state.fullscreen) { editor.height($(window).height()); } - if (settings.toolbar && !settings.readOnly) + if (settings.toolbar && !settings.readOnly) { codeMirror.css("margin-top", toolbar.height() + 1).height(editor.height() - toolbar.height()); - } + } else { codeMirror.css("margin-top", 0).height(editor.height()); } } - - if(settings.watch) + + if(settings.watch) { codeMirror.width(editor.width() / 2); preview.width((!state.preview) ? editor.width() / 2 : editor.width()); - + this.previewContainer.css("padding", settings.autoHeight ? "20px 20px 50px 40px" : "20px"); - - if (settings.toolbar && !settings.readOnly) + + if (settings.toolbar && !settings.readOnly) { preview.css("top", toolbar.height() + 1); - } - else + } + else { preview.css("top", 0); } - + if (settings.autoHeight && !state.fullscreen && !state.preview) { preview.height(""); } else - { + { var previewHeight = (settings.toolbar && !settings.readOnly) ? editor.height() - toolbar.height() : editor.height(); - + preview.height(previewHeight); } - } - else + } + else { codeMirror.width(editor.width()); preview.hide(); } - - if (state.loaded) + + if (state.loaded) { $.proxy(settings.onresize, this)(); } return this; }, - + /** * 解析和保存Markdown代码 * Parse & Saving Markdown source code - * + * * @returns {editormd} 返回editormd的实例对象 */ - + save : function() { - + if (timer === null) { return this; } - + var _this = this; var state = this.state; var settings = this.settings; - var cm = this.cm; + var cm = this.cm; var cmValue = cm.getValue(); var previewContainer = this.previewContainer; - if (settings.mode !== "gfm" && settings.mode !== "markdown") + if (settings.mode !== "gfm" && settings.mode !== "markdown") { this.markdownTextarea.val(cmValue); - + return this; } - + var marked = editormd.$marked; - var markdownToC = this.markdownToC = []; - var rendererOptions = this.markedRendererOptions = { + var markdownToC = this.markdownToC = []; + var rendererOptions = this.markedRendererOptions = { toc : settings.toc, tocm : settings.tocm, tocStartLevel : settings.tocStartLevel, @@ -132129,7 +132151,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); sequenceDiagram : settings.sequenceDiagram, previewCodeHighlight : settings.previewCodeHighlight, }; - + var markedOptions = this.markedOptions = { renderer : editormd.markedRenderer(markdownToC, rendererOptions), gfm : true, @@ -132140,74 +132162,74 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); smartLists : true, smartypants : true }; - + marked.setOptions(markedOptions); - + var newMarkdownDoc = editormd.$marked(cmValue, markedOptions); - + //console.info("cmValue", cmValue, newMarkdownDoc); - + newMarkdownDoc = editormd.filterHTMLTags(newMarkdownDoc, settings.htmlDecode); - + //console.error("cmValue", cmValue, newMarkdownDoc); - + this.markdownTextarea.text(cmValue); - + cm.save(); - - if (settings.saveHTMLToTextarea) + + if (settings.saveHTMLToTextarea) { this.htmlTextarea.text(newMarkdownDoc); } - + if(settings.watch || (!settings.watch && state.preview)) { previewContainer.html(newMarkdownDoc); this.previewCodeHighlight(); - - if (settings.toc) + + if (settings.toc) { var tocContainer = (settings.tocContainer === "") ? previewContainer : $(settings.tocContainer); var tocMenu = tocContainer.find("." + this.classPrefix + "toc-menu"); - + tocContainer.attr("previewContainer", (settings.tocContainer === "") ? "true" : "false"); - + if (settings.tocContainer !== "" && tocMenu.length > 0) { tocMenu.remove(); } - + editormd.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); - + if (settings.tocDropdown || tocContainer.find("." + this.classPrefix + "toc-menu").length > 0) { editormd.tocDropdownMenu(tocContainer, (settings.tocTitle !== "") ? settings.tocTitle : this.lang.tocTitle); } - + if (settings.tocContainer !== "") { previewContainer.find(".markdown-toc").css("border", "none"); } } - + if (settings.tex) { - if (!editormd.kaTeXLoaded && settings.autoLoadModules) + if (!editormd.kaTeXLoaded && settings.autoLoadModules) { editormd.loadKaTeX(function() { editormd.$katex = katex; editormd.kaTeXLoaded = true; _this.katexRender(); }); - } - else + } + else { editormd.$katex = katex; this.katexRender(); } - } - + } + if (settings.flowChart || settings.sequenceDiagram) { flowchartTimer = setTimeout(function(){ @@ -132217,7 +132239,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }, 10); } - if (state.loaded) + if (state.loaded) { $.proxy(settings.onchange, this)(); } @@ -132225,215 +132247,215 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return this; }, - + /** * 聚焦光标位置 * Focusing the cursor position - * + * * @returns {editormd} 返回editormd的实例对象 */ - + focus : function() { this.cm.focus(); return this; }, - + /** * 设置光标的位置 * Set cursor position - * + * * @param {Object} cursor 要设置的光标位置键值对象,例:{line:1, ch:0} * @returns {editormd} 返回editormd的实例对象 */ - + setCursor : function(cursor) { this.cm.setCursor(cursor); return this; }, - + /** * 获取当前光标的位置 * Get the current position of the cursor - * + * * @returns {Cursor} 返回一个光标Cursor对象 */ - + getCursor : function() { return this.cm.getCursor(); }, - + /** * 设置光标选中的范围 * Set cursor selected ranges - * + * * @param {Object} from 开始位置的光标键值对象,例:{line:1, ch:0} * @param {Object} to 结束位置的光标键值对象,例:{line:1, ch:0} * @returns {editormd} 返回editormd的实例对象 */ - + setSelection : function(from, to) { - + this.cm.setSelection(from, to); - + return this; }, - + /** * 获取光标选中的文本 * Get the texts from cursor selected - * + * * @returns {String} 返回选中文本的字符串形式 */ - + getSelection : function() { return this.cm.getSelection(); }, - + /** * 设置光标选中的文本范围 * Set the cursor selection ranges - * + * * @param {Array} ranges cursor selection ranges array * @returns {Array} return this */ - + setSelections : function(ranges) { this.cm.setSelections(ranges); - + return this; }, - + /** * 获取光标选中的文本范围 * Get the cursor selection ranges - * + * * @returns {Array} return selection ranges array */ - + getSelections : function() { return this.cm.getSelections(); }, - + /** * 替换当前光标选中的文本或在当前光标处插入新字符 * Replace the text at the current cursor selected or insert a new character at the current cursor position - * + * * @param {String} value 要插入的字符值 * @returns {editormd} 返回editormd的实例对象 */ - + replaceSelection : function(value) { this.cm.replaceSelection(value); return this; }, - + /** * 在当前光标处插入新字符 * Insert a new character at the current cursor position * * 同replaceSelection()方法 * With the replaceSelection() method - * + * * @param {String} value 要插入的字符值 * @returns {editormd} 返回editormd的实例对象 */ - + insertValue : function(value) { this.replaceSelection(value); return this; }, - + /** * 追加markdown * append Markdown to editor - * + * * @param {String} md 要追加的markdown源文档 * @returns {editormd} 返回editormd的实例对象 */ - + appendMarkdown : function(md) { var settings = this.settings; var cm = this.cm; - + cm.setValue(cm.getValue() + md); - + return this; }, - + /** * 设置和传入编辑器的markdown源文档 * Set Markdown source document - * + * * @param {String} md 要传入的markdown源文档 * @returns {editormd} 返回editormd的实例对象 */ - + setMarkdown : function(md) { this.cm.setValue(md || this.settings.markdown); - + return this; }, - + /** * 获取编辑器的markdown源文档 * Set Editor.md markdown/CodeMirror value - * + * * @returns {editormd} 返回editormd的实例对象 */ - + getMarkdown : function() { return this.cm.getValue(); }, - + /** * 获取编辑器的源文档 * Get CodeMirror value - * + * * @returns {editormd} 返回editormd的实例对象 */ - + getValue : function() { return this.cm.getValue(); }, - + /** * 设置编辑器的源文档 * Set CodeMirror value - * + * * @param {String} value set code/value/string/text * @returns {editormd} 返回editormd的实例对象 */ - + setValue : function(value) { this.cm.setValue(value); - + return this; }, - + /** * 清空编辑器 * Empty CodeMirror editor container - * + * * @returns {editormd} 返回editormd的实例对象 */ - + clear : function() { this.cm.setValue(""); - + return this; }, - + /** * 获取解析后存放在Textarea的HTML源码 * Get parsed html code from Textarea - * + * * @returns {String} 返回HTML源码 */ - + getHTML : function() { if (!this.settings.saveHTMLToTextarea) { @@ -132441,28 +132463,28 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return false; } - + return this.htmlTextarea.val(); }, - + /** * getHTML()的别名 * getHTML (alias) - * + * * @returns {String} Return html code 返回HTML源码 */ - + getTextareaSavedHTML : function() { return this.getHTML(); }, - + /** * 获取预览窗口的HTML源码 * Get html from preview container - * + * * @returns {editormd} 返回editormd的实例对象 */ - + getPreviewedHTML : function() { if (!this.settings.watch) { @@ -132470,137 +132492,137 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return false; } - + return this.previewContainer.html(); }, - + /** * 开启实时预览 * Enable real-time watching - * + * * @returns {editormd} 返回editormd的实例对象 */ - - watch : function(callback) { + + watch : function(callback) { var settings = this.settings; - + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) { return this; } - + this.state.watching = settings.watch = true; this.preview.show(); - + if (this.toolbar) { var watchIcon = settings.toolbarIconsClass.watch; var unWatchIcon = settings.toolbarIconsClass.unwatch; - + var icon = this.toolbar.find(".fa[name=watch]"); icon.parent().attr("title", settings.lang.toolbar.watch); icon.removeClass(unWatchIcon).addClass(watchIcon); } - - this.codeMirror.css("border-right", "1px solid #ddd").width(this.editor.width() / 2); - + + this.codeMirror.css("border-right", "1px solid #ddd").width(this.editor.width() / 2); + timer = 0; - + this.save().resize(); - + if (!settings.onwatch) { settings.onwatch = callback || function() {}; } - + $.proxy(settings.onwatch, this)(); - + return this; }, - + /** * 关闭实时预览 * Disable real-time watching - * + * * @returns {editormd} 返回editormd的实例对象 */ - + unwatch : function(callback) { var settings = this.settings; this.state.watching = settings.watch = false; this.preview.hide(); - - if (this.toolbar) + + if (this.toolbar) { var watchIcon = settings.toolbarIconsClass.watch; var unWatchIcon = settings.toolbarIconsClass.unwatch; - + var icon = this.toolbar.find(".fa[name=watch]"); icon.parent().attr("title", settings.lang.toolbar.unwatch); icon.removeClass(watchIcon).addClass(unWatchIcon); } - + this.codeMirror.css("border-right", "none").width(this.editor.width()); - + this.resize(); - + if (!settings.onunwatch) { settings.onunwatch = callback || function() {}; } - + $.proxy(settings.onunwatch, this)(); - + return this; }, - + /** * 显示编辑器 * Show editor - * + * * @param {Function} [callback=function()] 回调函数 * @returns {editormd} 返回editormd的实例对象 */ - + show : function(callback) { callback = callback || function() {}; - + var _this = this; this.editor.show(0, function() { $.proxy(callback, _this)(); }); - + return this; }, - + /** * 隐藏编辑器 * Hide editor - * + * * @param {Function} [callback=function()] 回调函数 * @returns {editormd} 返回editormd的实例对象 */ - + hide : function(callback) { callback = callback || function() {}; - + var _this = this; this.editor.hide(0, function() { $.proxy(callback, _this)(); }); - + return this; }, - + /** * 隐藏编辑器部分,只预览HTML * Enter preview html state - * + * * @returns {editormd} 返回editormd的实例对象 */ - + previewing : function() { - + var _this = this; var editor = this.editor; var preview = this.preview; @@ -132608,18 +132630,18 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var settings = this.settings; var codeMirror = this.codeMirror; var previewContainer = this.previewContainer; - + if ($.inArray(settings.mode, ["gfm", "markdown"]) < 0) { return this; } - + if (settings.toolbar && toolbar) { toolbar.toggle(); toolbar.find(".fa[name=preview]").toggleClass("active"); } - + codeMirror.toggle(); - + var escHandle = function(event) { if (event.shiftKey && event.keyCode === 27) { _this.previewed(); @@ -132633,20 +132655,20 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); if (this.state.fullscreen) { preview.css("background", "#fff"); } - + editor.find("." + this.classPrefix + "preview-close-btn").show().bind(editormd.mouseOrTouch("click", "touchend"), function(){ _this.previewed(); }); - + if (!settings.watch) { this.save(); - } - else + } + else { previewContainer.css("padding", ""); } - + previewContainer.addClass(this.classPrefix + "preview-active"); preview.show().css({ @@ -132655,30 +132677,30 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); width : editor.width(), height : (settings.autoHeight && !this.state.fullscreen) ? "auto" : editor.height() }); - + if (this.state.loaded) { $.proxy(settings.onpreviewing, this)(); } $(window).bind("keyup", escHandle); - } - else + } + else { $(window).unbind("keyup", escHandle); this.previewed(); } }, - + /** * 显示编辑器部分,退出只预览HTML * Exit preview html state - * + * * @returns {editormd} 返回editormd的实例对象 */ - + previewed : function() { - + var editor = this.editor; var preview = this.preview; var toolbar = this.toolbar; @@ -132687,25 +132709,25 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var previewCloseBtn = editor.find("." + this.classPrefix + "preview-close-btn"); this.state.preview = false; - + this.codeMirror.show(); - + if (settings.toolbar) { toolbar.show(); } - + preview[(settings.watch) ? "show" : "hide"](); - + previewCloseBtn.hide().unbind(editormd.mouseOrTouch("click", "touchend")); - + previewContainer.removeClass(this.classPrefix + "preview-active"); - + if (settings.watch) { previewContainer.css("padding", "20px"); } - - preview.css({ + + preview.css({ background : null, position : "absolute", width : editor.width() / 2, @@ -132717,19 +132739,19 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { $.proxy(settings.onpreviewed, this)(); } - + return this; }, - + /** * 编辑器全屏显示 * Fullscreen show - * + * * @returns {editormd} 返回editormd的实例对象 */ - + fullscreen : function() { - + var _this = this; var state = this.state; var editor = this.editor; @@ -132737,13 +132759,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var toolbar = this.toolbar; var settings = this.settings; var fullscreenClass = this.classPrefix + "fullscreen"; - + if (toolbar) { - toolbar.find(".fa[name=fullscreen]").parent().toggleClass("active"); + toolbar.find(".fa[name=fullscreen]").parent().toggleClass("active"); } - + var escHandle = function(event) { - if (!event.shiftKey && event.keyCode === 27) + if (!event.shiftKey && event.keyCode === 27) { if (state.fullscreen) { @@ -132752,50 +132774,50 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } }; - if (!editor.hasClass(fullscreenClass)) + if (!editor.hasClass(fullscreenClass)) { state.fullscreen = true; $("html,body").css("overflow", "hidden"); - + editor.css({ width : $(window).width(), height : $(window).height() }).addClass(fullscreenClass); this.resize(); - + $.proxy(settings.onfullscreen, this)(); $(window).bind("keyup", escHandle); } else - { - $(window).unbind("keyup", escHandle); + { + $(window).unbind("keyup", escHandle); this.fullscreenExit(); } return this; }, - + /** * 编辑器退出全屏显示 * Exit fullscreen state - * + * * @returns {editormd} 返回editormd的实例对象 */ - + fullscreenExit : function() { - + var editor = this.editor; var settings = this.settings; var toolbar = this.toolbar; - var fullscreenClass = this.classPrefix + "fullscreen"; - + var fullscreenClass = this.classPrefix + "fullscreen"; + this.state.fullscreen = false; - + if (toolbar) { - toolbar.find(".fa[name=fullscreen]").parent().removeClass("active"); + toolbar.find(".fa[name=fullscreen]").parent().removeClass("active"); } $("html,body").css("overflow", ""); @@ -132806,43 +132828,43 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }).removeClass(fullscreenClass); this.resize(); - + $.proxy(settings.onfullscreenExit, this)(); return this; }, - + /** * 加载并执行插件 * Load and execute the plugin - * + * * @param {String} name plugin name / function name * @param {String} path plugin load path * @returns {editormd} 返回editormd的实例对象 */ - + executePlugin : function(name, path) { - + var _this = this; var cm = this.cm; var settings = this.settings; - + path = settings.pluginPath + path; - - if (typeof define === "function") - { + + if (typeof define === "function") + { if (typeof this[name] === "undefined") { alert("Error: " + name + " plugin is not found, you are not load this plugin."); - + return this; } - + this[name](cm); - + return this; } - + if ($.inArray(path, editormd.loadFiles.plugin) < 0) { editormd.loadPlugin(path, function() { @@ -132854,79 +132876,79 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { $.proxy(editormd.loadPlugins[name], this)(cm); } - + return this; }, - + /** * 搜索替换 * Search & replace - * + * * @param {String} command CodeMirror serach commands, "find, fintNext, fintPrev, clearSearch, replace, replaceAll" * @returns {editormd} return this */ - + search : function(command) { var settings = this.settings; - + if (!settings.searchReplace) { alert("Error: settings.searchReplace == false"); return this; } - + if (!settings.readOnly) { this.cm.execCommand(command || "find"); } - + return this; }, - - searchReplace : function() { + + searchReplace : function() { this.search("replace"); - + return this; }, - - searchReplaceAll : function() { + + searchReplaceAll : function() { this.search("replaceAll"); - + return this; } }; - - editormd.fn.init.prototype = editormd.fn; - + + editormd.fn.init.prototype = editormd.fn; + /** * 锁屏 * lock screen when dialog opening - * + * * @returns {void} */ editormd.dialogLockScreen = function() { var settings = this.settings || {dialogLockScreen : true}; - - if (settings.dialogLockScreen) - { + + if (settings.dialogLockScreen) + { $("html,body").css("overflow", "hidden"); this.resize(); } }; - + /** * 显示透明背景层 * Display mask layer when dialog opening - * + * * @param {Object} dialog dialog jQuery object * @returns {void} */ - + editormd.dialogShowMask = function(dialog) { var editor = this.editor; var settings = this.settings || {dialogShowMask : true}; - + dialog.css({ top : ($(window).height() - dialog.height()) / 2 + "px", left : ($(window).width() - dialog.width()) / 2 + "px" @@ -132941,11 +132963,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); undo : function() { this.cm.undo(); }, - + redo : function() { this.cm.redo(); }, - + bold : function() { var cm = this.cm; var cursor = cm.getCursor(); @@ -132957,7 +132979,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.setCursor(cursor.line, cursor.ch + 2); } }, - + del : function() { var cm = this.cm; var cursor = cm.getCursor(); @@ -133001,7 +133023,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); //cm.replaceSelection("> " + selection); //cm.setCursor(cursor.line, (selection === "") ? cursor.ch + 2 : cursor.ch + selection.length + 2); }, - + ucfirst : function() { var cm = this.cm; var selection = cm.getSelection(); @@ -133010,7 +133032,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.replaceSelection(editormd.firstUpperCase(selection)); cm.setSelections(selections); }, - + ucwords : function() { var cm = this.cm; var selection = cm.getSelection(); @@ -133019,7 +133041,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.replaceSelection(editormd.wordsFirstUpperCase(selection)); cm.setSelections(selections); }, - + uppercase : function() { var cm = this.cm; var selection = cm.getSelection(); @@ -133028,13 +133050,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.replaceSelection(selection.toUpperCase()); cm.setSelections(selections); }, - + lowercase : function() { var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); var selections = cm.listSelections(); - + cm.replaceSelection(selection.toLowerCase()); cm.setSelections(selections); }, @@ -133146,15 +133168,15 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var cursor = cm.getCursor(); var selection = cm.getSelection(); - if (selection === "") + if (selection === "") { cm.replaceSelection("- " + selection); - } - else + } + else { var selectionText = selection.split("\n"); - for (var i = 0, len = selectionText.length; i < len; i++) + for (var i = 0, len = selectionText.length; i < len; i++) { selectionText[i] = (selectionText[i] === "") ? "" : "- " + selectionText[i]; } @@ -133168,7 +133190,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var cursor = cm.getCursor(); var selection = cm.getSelection(); - if(selection === "") + if(selection === "") { cm.replaceSelection("1. " + selection); } @@ -133176,7 +133198,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { var selectionText = selection.split("\n"); - for (var i = 0, len = selectionText.length; i < len; i++) + for (var i = 0, len = selectionText.length; i < len; i++) { selectionText[i] = (selectionText[i] === "") ? "" : (i+1) + ". " + selectionText[i]; } @@ -133199,7 +133221,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); alert("settings.tex === false"); return this; } - + var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); @@ -133225,7 +133247,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); alert("settings.pageBreak === false"); return this; } - + var cm = this.cm; var selection = cm.getSelection(); @@ -133235,7 +133257,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); image : function() { this.executePlugin("imageDialog", "image-dialog/image-dialog"); }, - + code : function() { var cm = this.cm; var cursor = cm.getCursor(); @@ -133249,17 +133271,17 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }, "code-block" : function() { - this.executePlugin("codeBlockDialog", "code-block-dialog/code-block-dialog"); + this.executePlugin("codeBlockDialog", "code-block-dialog/code-block-dialog"); }, "preformatted-text" : function() { this.executePlugin("preformattedTextDialog", "preformatted-text-dialog/preformatted-text-dialog"); }, - + table : function() { - this.executePlugin("tableDialog", "table-dialog/table-dialog"); + this.executePlugin("tableDialog", "table-dialog/table-dialog"); }, - + datetime : function() { var cm = this.cm; var selection = cm.getSelection(); @@ -133269,20 +133291,20 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.replaceSelection(datefmt); }, - + emoji : function() { this.executePlugin("emojiDialog", "emoji-dialog/emoji-dialog"); }, - + "html-entities" : function() { this.executePlugin("htmlEntitiesDialog", "html-entities-dialog/html-entities-dialog"); }, - + "goto-line" : function() { this.executePlugin("gotoLineDialog", "goto-line-dialog/goto-line-dialog"); }, - watch : function() { + watch : function() { this[this.settings.watch ? "unwatch" : "watch"](); }, @@ -133297,7 +133319,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); clear : function() { this.clear(); }, - + search : function() { this.search(); }, @@ -133310,7 +133332,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); this.showInfoDialog(); } }; - + editormd.keyMaps = { "Ctrl-1" : "h1", "Ctrl-2" : "h2", @@ -133320,12 +133342,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "Ctrl-6" : "h6", "Ctrl-B" : "bold", // if this is string == editormd.toolbarHandlers.xxxx "Ctrl-D" : "datetime", - + "Ctrl-E" : function() { // emoji var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); - + if (!this.settings.emoji) { alert("Error: settings.emoji == false"); @@ -133342,12 +133364,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "Ctrl-H" : "hr", "Ctrl-I" : "italic", "Ctrl-K" : "code", - + "Ctrl-L" : function() { var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); - + var title = (selection === "") ? "" : " \""+selection+"\""; cm.replaceSelection("[" + selection + "]("+title+")"); @@ -133357,12 +133379,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } }, "Ctrl-U" : "list-ul", - + "Shift-Ctrl-A" : function() { var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); - + if (!this.settings.atLink) { alert("Error: settings.atLink == false"); @@ -133375,24 +133397,24 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.setCursor(cursor.line, cursor.ch + 1); } }, - + "Shift-Ctrl-C" : "code", "Shift-Ctrl-Q" : "quote", "Shift-Ctrl-S" : "del", "Shift-Ctrl-K" : "tex", // KaTeX - + "Shift-Alt-C" : function() { var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); - + cm.replaceSelection(["```", selection, "```"].join("\n")); if (selection === "") { cm.setCursor(cursor.line, cursor.ch + 3); - } + } }, - + "Shift-Ctrl-Alt-C" : "code-block", "Shift-Ctrl-H" : "html-entities", "Shift-Alt-H" : "help", @@ -133401,12 +133423,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "Shift-Alt-U" : "ucwords", "Shift-Ctrl-Alt-U" : "ucfirst", "Shift-Alt-L" : "lowercase", - + "Shift-Ctrl-I" : function() { var cm = this.cm; var cursor = cm.getCursor(); var selection = cm.getSelection(); - + var title = (selection === "") ? "" : " \""+selection+"\""; cm.replaceSelection("![" + selection + "]("+title+")"); @@ -133415,7 +133437,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); cm.setCursor(cursor.line, cursor.ch + 4); } }, - + "Shift-Ctrl-Alt-I" : "image", "Shift-Ctrl-L" : "link", "Shift-Ctrl-O" : "list-ol", @@ -133426,59 +133448,59 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); "F10" : "preview", "F11" : "fullscreen", }; - + /** * 清除字符串两边的空格 * Clear the space of strings both sides. - * + * * @param {String} str string - * @returns {String} trimed string + * @returns {String} trimed string */ - + var trim = function(str) { return (!String.prototype.trim) ? str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "") : str.trim(); }; - + editormd.trim = trim; - + /** * 所有单词首字母大写 * Words first to uppercase - * + * * @param {String} str string * @returns {String} string */ - + var ucwords = function (str) { - return str.toLowerCase().replace(/\b(\w)|\s(\w)/g, function($1) { + return str.toLowerCase().replace(/\b(\w)|\s(\w)/g, function($1) { return $1.toUpperCase(); }); }; - + editormd.ucwords = editormd.wordsFirstUpperCase = ucwords; - + /** * 字符串首字母大写 * Only string first char to uppercase - * + * * @param {String} str string * @returns {String} string */ - - var firstUpperCase = function(str) { + + var firstUpperCase = function(str) { return str.toLowerCase().replace(/\b(\w)/, function($1){ return $1.toUpperCase(); }); }; - + var ucfirst = firstUpperCase; - + editormd.firstUpperCase = editormd.ucfirst = firstUpperCase; - + editormd.urls = { atLinkBase : "https://github.com/" }; - + editormd.regexs = { atLink : /@(\w+)/g, email : /(\w+)@(\w+)\.(\w+)\.?(\w+)?/g, @@ -133497,7 +133519,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); ext : ".png" }; - // Twitter Emoji (Twemoji) graphics files url path + // Twitter Emoji (Twemoji) graphics files url path editormd.twemoji = { path : "http://twemoji.maxcdn.com/36x36/", ext : ".png" @@ -133506,7 +133528,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); /** * 自定义marked的解析器 * Custom Marked renderer rules - * + * * @param {Array} markdownToC 传入用于接收TOC的数组 * @returns {Renderer} markedRenderer 返回marked的Renderer自定义对象 */ @@ -133515,7 +133537,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var defaults = { toc : true, // Table of contents tocm : false, - tocStartLevel : 1, // Said from H1 to create ToC + tocStartLevel : 1, // Said from H1 to create ToC pageBreak : true, atLink : true, // for @link emailLink : true, // for mail address auto link @@ -133525,12 +133547,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); flowChart : false, // flowChart.js only support IE9+ sequenceDiagram : false, // sequenceDiagram.js only support IE9+ }; - - var settings = $.extend(defaults, options || {}); + + var settings = $.extend(defaults, options || {}); var marked = editormd.$marked; var markedRenderer = new marked.Renderer(); - markdownToC = markdownToC || []; - + markdownToC = markdownToC || []; + var regexs = editormd.regexs; var atLinkReg = regexs.atLink; var emojiReg = regexs.emoji; @@ -133542,11 +133564,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var pageBreakReg = regexs.pageBreak; markedRenderer.emoji = function(text) { - - text = text.replace(editormd.regexs.emojiDatetime, function($1) { + + text = text.replace(editormd.regexs.emojiDatetime, function($1) { return $1.replace(/:/g, ":"); }); - + var matchs = text.match(emojiReg); if (!matchs || !settings.emoji) { @@ -133554,7 +133576,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } for (var i = 0, len = matchs.length; i < len; i++) - { + { if (matchs[i] === ":+1:") { matchs[i] = ":\\+1:"; } @@ -133564,11 +133586,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var name = $1.replace(/:/g, ""); if (faMatchs) - { + { for (var fa = 0, len1 = faMatchs.length; fa < len1; fa++) { var faName = faMatchs[fa].replace(/:/g, ""); - + return ""; } } @@ -133577,15 +133599,15 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var emdlogoMathcs = $1.match(editormdLogoReg); var twemojiMatchs = $1.match(twemojiReg); - if (emdlogoMathcs) - { + if (emdlogoMathcs) + { for (var x = 0, len2 = emdlogoMathcs.length; x < len2; x++) { var logoName = emdlogoMathcs[x].replace(/:/g, ""); return ""; } } - else if (twemojiMatchs) + else if (twemojiMatchs) { for (var t = 0, len3 = twemojiMatchs.length; t < len3; t++) { @@ -133611,8 +133633,8 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); markedRenderer.atLink = function(text) { if (atLinkReg.test(text)) - { - if (settings.atLink) + { + if (settings.atLink) { text = text.replace(emailReg, function($1, $2, $3, $4) { return $1.replace(/@/g, "_#_@_#_"); @@ -133622,7 +133644,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return "" + $1 + ""; }).replace(/_#_@_#_/g, "@"); } - + if (settings.emailLink) { text = text.replace(emailLinkReg, function($1, $2, $3, $4, $5) { @@ -133635,7 +133657,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return text; }; - + markedRenderer.link = function (href, title, text) { if (this.options.sanitize) { @@ -133651,14 +133673,14 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } var out = "" + text.replace(/@/g, "@") + ""; } @@ -133670,14 +133692,14 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return out; }; - + markedRenderer.heading = function(text, level, raw) { - + var linkText = text; var hasLinkReg = /\s*\]*)\>(.*)\<\/a\>\s*/; var getLinkTextReg = /\s*\]+)\>([^\>]*)\<\/a\>\s*/g; - if (hasLinkReg.test(text)) + if (hasLinkReg.test(text)) { var tempText = []; text = text.split(/\]+)\>([^\>]*)\<\/a\>/); @@ -133689,23 +133711,23 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); text = tempText.join(" "); } - + text = trim(text); - + var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-"); var toc = { text : text, level : level, slug : escapedText }; - + var isChinese = /^[\u4e00-\u9fa5]+$/.test(text); var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-"); markdownToC.push(toc); - + var headingHTML = ""; - + headingHTML += ""; headingHTML += ""; headingHTML += (hasLinkReg) ? this.atLink(this.emoji(linkText)) : this.atLink(this.emoji(text)); @@ -133713,13 +133735,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return headingHTML; }; - + markedRenderer.pageBreak = function(text) { if (pageBreakReg.test(text) && settings.pageBreak) { text = "
"; } - + return text; }; @@ -133729,39 +133751,39 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var isTeXAddClass = (isTeXLine) ? " class=\"" + editormd.classNames.tex + "\"" : ""; var isToC = (settings.tocm) ? /^(\[TOC\]|\[TOCM\])$/.test(text) : /^\[TOC\]$/.test(text); var isToCMenu = /^\[TOCM\]$/.test(text); - - if (!isTeXLine && isTeXInline) + + if (!isTeXLine && isTeXInline) { text = text.replace(/(\$\$([^\$]*)\$\$)+/g, function($1, $2) { return "" + $2.replace(/\$/g, "") + ""; }); - } - else + } + else { text = (isTeXLine) ? text.replace(/\$/g, "") : text; } - + var tocHTML = "" + text + ""; - + return (isToC) ? ( (isToCMenu) ? "
" : tocHTML ) : ( (pageBreakReg.test(text)) ? this.pageBreak(text) : "" + this.atLink(this.emoji(text)) + "
\n" ); }; - markedRenderer.code = function (code, lang, escaped) { + markedRenderer.code = function (code, lang, escaped) { if (lang === "seq" || lang === "sequence") { return "" + code + ""; - } + } else if ( lang === "flow") { return "" + code + ""; - } + } else if ( lang === "math" || lang === "latex" || lang === "katex") { return "" + code + "
"; - } - else + } + else { return marked.Renderer.prototype.code.apply(this, arguments); @@ -133771,64 +133793,64 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); markedRenderer.tablecell = function(content, flags) { var type = (flags.header) ? "th" : "td"; var tag = (flags.align) ? "<" + type +" style=\"text-align:" + flags.align + "\">" : "<" + type + ">"; - + return tag + this.atLink(this.emoji(content)) + "" + type + ">\n"; }; markedRenderer.listitem = function(text) { - if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) + if (settings.taskList && /^\s*\[[x\s]\]\s*/.test(text)) { text = text.replace(/^\s*\[\s\]\s*/, " ") .replace(/^\s*\[x\]\s*/, " "); return "" + this.atLink(this.emoji(text)) + " "; } - else + else { return "" + this.atLink(this.emoji(text)) + " "; } }; - + return markedRenderer; }; - + /** * * 生成TOC(Table of Contents) * Creating ToC (Table of Contents) - * + * * @param {Array} toc 从marked获取的TOC数组列表 * @param {Element} container 插入TOC的容器元素 * @param {Integer} startLevel Hx 起始层级 * @returns {Object} tocContainer 返回ToC列表容器层的jQuery对象元素 */ - + editormd.markdownToCRenderer = function(toc, container, tocDropdown, startLevel) { - - var html = ""; + + var html = ""; var lastLevel = 0; var classPrefix = this.classPrefix; - + startLevel = startLevel || 1; - - for (var i = 0, len = toc.length; i < len; i++) + + for (var i = 0, len = toc.length; i < len; i++) { var text = toc[i].text; var level = toc[i].level; - + if (level < startLevel) { continue; } - - if (level > lastLevel) + + if (level > lastLevel) { html += ""; } - else if (level < lastLevel) + else if (level < lastLevel) { html += (new Array(lastLevel - level + 2)).join(""); - } - else + } + else { html += ""; } @@ -133836,44 +133858,44 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); html += "" + text + " "; lastLevel = level; } - + var tocContainer = container.find(".markdown-toc"); - + if ((tocContainer.length < 1 && container.attr("previewContainer") === "false")) { var tocHTML = ""; - + tocHTML = (tocDropdown) ? "
" + tocHTML + "" : tocHTML; - + container.html(tocHTML); - + tocContainer = container.find(".markdown-toc"); } - + if (tocDropdown) { tocContainer.wrap("
"); } - + tocContainer.html("").children(".markdown-toc-list").html(html.replace(/\r?\n?\
\<\/ul\>/g, "")); - + return tocContainer; }; - + /** * * 生成TOC下拉菜单 * Creating ToC dropdown menu - * + * * @param {Object} container 插入TOC的容器jQuery对象元素 * @param {String} tocTitle ToC title * @returns {Object} return toc-menu object */ - + editormd.tocDropdownMenu = function(container, tocTitle) { - + tocTitle = tocTitle || "Table of Contents"; - + var zindex = 400; var tocMenus = container.find("." + this.classPrefix + "toc-menu"); @@ -133882,13 +133904,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var toc = $this.children(".markdown-toc"); var icon = ""; var btn = "" + icon + tocTitle + ""; - var menu = toc.children("ul"); + var menu = toc.children("ul"); var list = menu.find("li"); - + toc.append(btn); - + list.first().before("
- "); - + $this.mouseover(function(){ menu.show(); @@ -133920,27 +133942,27 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }); }).mouseleave(function(){ menu.hide(); - }); - }); - + }); + }); + return tocMenus; }; - + /** * 简单地过滤指定的HTML标签 * Filter custom html tags - * + * * @param {String} html 要过滤HTML * @param {String} filters 要过滤的标签 * @returns {String} html 返回过滤的HTML */ - + editormd.filterHTMLTags = function(html, filters) { - + if (typeof html !== "string") { html = new String(html); } - + if (typeof filters !== "string") { return html; } @@ -133955,7 +133977,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); html = html.replace(new RegExp("\<\s*" + tag + "\s*([^\>]*)\>([^\>]*)\<\s*\/" + tag + "\s*\>", "igm"), ""); } - + //return html; if (typeof attrs !== "undefined") @@ -133966,7 +133988,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { html = html.replace(htmlTagRegex, function($1, $2, $3, $4, $5) { return "<" + $2 + ">" + $4 + "" + $5 + ">"; - }); + }); } else if (attrs === "on*") { @@ -133974,19 +133996,19 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var el = $("<" + $2 + ">" + $4 + "" + $5 + ">"); var _attrs = $($1)[0].attributes; var $attrs = {}; - + $.each(_attrs, function(i, e) { if (e.nodeName !== '"') $attrs[e.nodeName] = e.nodeValue; }); - - $.each($attrs, function(i) { + + $.each($attrs, function(i) { if (i.indexOf("on") === 0) { delete $attrs[i]; } }); - + el.attr($attrs); - + var text = (typeof el[1] !== "undefined") ? $(el[1]).text() : ""; return el[0].outerHTML + text; @@ -134007,19 +134029,19 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }); } } - + return html; }; - + /** * 将Markdown文档解析为HTML用于前台显示 * Parse Markdown to HTML for Font-end preview. - * + * * @param {String} id 用于显示HTML的对象ID * @param {Object} [options={}] 配置选项,可选 * @returns {Object} div 返回jQuery对象元素 */ - + editormd.markdownToHTML = function(id, options) { var defaults = { gfm : true, @@ -134043,23 +134065,23 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); sequenceDiagram : false, previewCodeHighlight : true }; - + editormd.$marked = marked; var div = $("#" + id); var settings = div.settings = $.extend(true, defaults, options || {}); var saveTo = div.find("textarea"); - + if (saveTo.length < 1) { div.append(""); saveTo = div.find("textarea"); - } - - var markdownDoc = (settings.markdown === "") ? saveTo.val() : settings.markdown; + } + + var markdownDoc = (settings.markdown === "") ? saveTo.val() : settings.markdown; var markdownToC = []; - var rendererOptions = { + var rendererOptions = { toc : settings.toc, tocm : settings.tocm, tocStartLevel : settings.tocStartLevel, @@ -134084,53 +134106,53 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); smartLists : true, smartypants : true }; - + markdownDoc = new String(markdownDoc); - + var markdownParsed = marked(markdownDoc, markedOptions); - + markdownParsed = editormd.filterHTMLTags(markdownParsed, settings.htmlDecode); - + if (settings.markdownSourceCode) { saveTo.text(markdownDoc); } else { saveTo.remove(); } - + div.addClass("markdown-body " + this.classPrefix + "html-preview").append(markdownParsed); - + var tocContainer = (settings.tocContainer !== "") ? $(settings.tocContainer) : div; - + if (settings.tocContainer !== "") { tocContainer.attr("previewContainer", false); } - - if (settings.toc) + + if (settings.toc) { div.tocContainer = this.markdownToCRenderer(markdownToC, tocContainer, settings.tocDropdown, settings.tocStartLevel); - + if (settings.tocDropdown || div.find("." + this.classPrefix + "toc-menu").length > 0) { this.tocDropdownMenu(div, settings.tocTitle); } - + if (settings.tocContainer !== "") { div.find(".editormd-toc-menu, .editormd-markdown-toc").remove(); } } - - if (settings.previewCodeHighlight) + + if (settings.previewCodeHighlight) { div.find("pre").addClass("prettyprint linenums"); prettyPrint(); } - - if (!editormd.isIE8) + + if (!editormd.isIE8) { if (settings.flowChart) { - div.find(".flowchart").flowChart(); + div.find(".flowchart").flowChart(); } if (settings.sequenceDiagram) { @@ -134142,12 +134164,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); { var katexHandle = function() { div.find("." + editormd.classNames.tex).each(function(){ - var tex = $(this); - katex.render(tex.html().replace(/</g, "<").replace(/>/g, ">"), tex[0]); + var tex = $(this); + katex.render(tex.html().replace(/</g, "<").replace(/>/g, ">"), tex[0]); tex.find(".katex").css("font-size", "1.6em"); }); }; - + if (settings.autoLoadKaTeX && !editormd.$katex && !editormd.kaTeXLoaded) { this.loadKaTeX(function() { @@ -134161,22 +134183,22 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); katexHandle(); } } - - div.getMarkdown = function() { + + div.getMarkdown = function() { return saveTo.val(); }; - + return div; }; - + // Editor.md themes, change toolbar themes etc. // added @1.5.0 editormd.themes = ["default", "dark"]; - + // Preview area themes // added @1.5.0 editormd.previewThemes = ["default", "dark"]; - + // CodeMirror / editor area themes // @1.5.0 rename -> editorThemes, old version -> themes editormd.editorThemes = [ @@ -134197,44 +134219,44 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); ]; editormd.loadPlugins = {}; - + editormd.loadFiles = { js : [], css : [], plugin : [] }; - + /** * 动态加载Editor.md插件,但不立即执行 * Load editor.md plugins - * + * * @param {String} fileName 插件文件路径 * @param {Function} [callback=function()] 加载成功后执行的回调函数 * @param {String} [into="head"] 嵌入页面的位置 */ - + editormd.loadPlugin = function(fileName, callback, into) { callback = callback || function() {}; - + this.loadScript(fileName, function() { editormd.loadFiles.plugin.push(fileName); callback(); }, into); }; - + /** * 动态加载CSS文件的方法 * Load css file method - * + * * @param {String} fileName CSS文件名 * @param {Function} [callback=function()] 加载成功后执行的回调函数 * @param {String} [into="head"] 嵌入页面的位置 */ - + editormd.loadCSS = function(fileName, callback, into) { - into = into || "head"; + into = into || "head"; callback = callback || function() {}; - + var css = document.createElement("link"); css.type = "text/css"; css.rel = "stylesheet"; @@ -134251,42 +134273,42 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); document.body.appendChild(css); } }; - + editormd.isIE = (navigator.appName == "Microsoft Internet Explorer"); editormd.isIE8 = (editormd.isIE && navigator.appVersion.match(/8./i) == "8."); /** * 动态加载JS文件的方法 * Load javascript file method - * + * * @param {String} fileName JS文件名 * @param {Function} [callback=function()] 加载成功后执行的回调函数 * @param {String} [into="head"] 嵌入页面的位置 */ editormd.loadScript = function(fileName, callback, into) { - + into = into || "head"; callback = callback || function() {}; - - var script = null; + + var script = null; script = document.createElement("script"); script.id = fileName.replace(/[\./]+/g, "-"); - script.type = "text/javascript"; + script.type = "text/javascript"; script.src = fileName + ".js"; - - if (editormd.isIE8) - { + + if (editormd.isIE8) + { script.onreadystatechange = function() { - if(script.readyState) + if(script.readyState) { - if (script.readyState === "loaded" || script.readyState === "complete") + if (script.readyState === "loaded" || script.readyState === "complete") { - script.onreadystatechange = null; + script.onreadystatechange = null; editormd.loadFiles.js.push(fileName); callback(); } - } + } }; } else @@ -134303,45 +134325,45 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); document.body.appendChild(script); } }; - + // 使用国外的CDN,加载速度有时会很慢,或者自定义URL // You can custom KaTeX load url. editormd.katexURL = { css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min", js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min" }; - + editormd.kaTeXLoaded = false; - + /** * 加载KaTeX文件 * load KaTeX files - * + * * @param {Function} [callback=function()] 加载成功后执行的回调函数 */ - + editormd.loadKaTeX = function (callback) { editormd.loadCSS(editormd.katexURL.css, function(){ editormd.loadScript(editormd.katexURL.js, callback || function(){}); }); }; - + /** * 锁屏 * lock screen - * + * * @param {Boolean} lock Boolean 布尔值,是否锁屏 * @returns {void} */ - + editormd.lockScreen = function(lock) { $("html,body").css("overflow", (lock) ? "hidden" : ""); }; - + /** * 动态创建对话框 * Creating custom dialogs - * + * * @param {Object} options 配置项键值对 Key/Value * @returns {dialog} 返回创建的dialog的jQuery实例对象 */ @@ -134366,7 +134388,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }; options = $.extend(true, defaults, options); - + var $this = this; var editor = this.editor; var classPrefix = editormd.classPrefix; @@ -134388,9 +134410,9 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); html += ""; } - html += "
" + tocTitle + " " + icon + "
" + options.content; + html += "" + options.content; - if (options.footer || typeof options.footer === "string") + if (options.footer || typeof options.footer === "string") { html += "" + ( (typeof options.footer === "boolean") ? "" : options.footer) + ""; } @@ -134407,7 +134429,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); dialog.lockScreen = function(lock) { if (options.lockScreen) - { + { $("html,body").css("overflow", (lock) ? "hidden" : ""); $this.resize(); } @@ -134432,7 +134454,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return dialog; }; - dialog.loading = function(show) { + dialog.loading = function(show) { var loading = dialog.find("." + classPrefix + "dialog-mask"); loading[(show) ? "show" : "hide"](); @@ -134479,7 +134501,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } if (options.title !== "" && options.drag) - { + { var posX, posY; var dialogHeader = dialog.children("." + classPrefix + "dialog-header"); @@ -134495,7 +134517,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); posX = e.clientX - parseInt(dialog[0].style.left); posY = e.clientY - parseInt(dialog[0].style.top); - document.onmousemove = moveAction; + document.onmousemove = moveAction; }); var userCanSelect = function (obj) { @@ -134503,7 +134525,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); }; var userUnselect = function (obj) { - obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE + obj.addClass(classPrefix + "user-unselect").on("selectstart", function(event) { // selectstart for IE return false; }); }; @@ -134516,7 +134538,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); if( nowLeft >= 0 ) { if( nowLeft + dialog.width() <= $(window).width()) { left = e.clientX - posX; - } else { + } else { left = $(window).width() - dialog.width(); document.onmousemove = null; } @@ -134543,18 +134565,18 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); dialog[0].style.top = top + "px"; }; - document.onmouseup = function() { + document.onmouseup = function() { userCanSelect($("body")); userCanSelect(dialog); - document.onselectstart = null; + document.onselectstart = null; document.onmousemove = null; }; dialogHeader.touchDraggable = function() { var offset = null; var start = function(e) { - var orig = e.originalEvent; + var orig = e.originalEvent; var pos = $(this).parent().position(); offset = { @@ -134583,20 +134605,20 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return dialog; }; - + /** * 鼠标和触摸事件的判断/选择方法 * MouseEvent or TouchEvent type switch - * + * * @param {String} [mouseEventType="click"] 供选择的鼠标事件 * @param {String} [touchEventType="touchend"] 供选择的触摸事件 * @returns {String} EventType 返回事件类型名称 */ - + editormd.mouseOrTouch = function(mouseEventType, touchEventType) { mouseEventType = mouseEventType || "click"; touchEventType = touchEventType || "touchend"; - + var eventType = mouseEventType; try { @@ -134606,23 +134628,23 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); return eventType; }; - + /** * 日期时间的格式化方法 * Datetime format method - * + * * @param {String} [format=""] 日期时间的格式,类似PHP的格式 * @returns {String} datefmt 返回格式化后的日期时间字符串 */ - - editormd.dateFormat = function(format) { + + editormd.dateFormat = function(format) { format = format || ""; var addZero = function(d) { return (d < 10) ? "0" + d : d; }; - var date = new Date(); + var date = new Date(); var year = date.getFullYear(); var year2 = year.toString().slice(2, 4); var month = addZero(date.getMonth() + 1); @@ -134631,14 +134653,14 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); var hour = addZero(date.getHours()); var min = addZero(date.getMinutes()); var second = addZero(date.getSeconds()); - var ms = addZero(date.getMilliseconds()); + var ms = addZero(date.getMilliseconds()); var datefmt = ""; var ymd = year2 + "-" + month + "-" + day; var fymd = year + "-" + month + "-" + day; var hms = hour + ":" + min + ":" + second; - switch (format) + switch (format) { case "UNIX Time" : datefmt = date.getTime(); @@ -134646,11 +134668,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); case "UTC" : datefmt = date.toUTCString(); - break; + break; case "yy" : datefmt = year2; - break; + break; case "year" : case "yyyy" : @@ -134660,7 +134682,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); case "month" : case "mm" : datefmt = month; - break; + break; case "cn-week-day" : case "cn-wd" : @@ -134707,7 +134729,7 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); break; case "yyyy-mm-dd h:i:s ms" : - case "full + ms" : + case "full + ms" : datefmt = fymd + " " + hms + " " + ms; break; @@ -134802,11 +134824,11 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); formatNotAllowed : "錯誤:只允許上傳圖片文件,允許上傳的圖片文件格式有:" }, preformattedText : { - title : "添加預格式文本或代碼塊", + title : "添加預格式文本或代碼塊", emptyAlert : "錯誤:請填寫預格式文本或代碼的內容。" }, codeBlock : { - title : "添加代碼塊", + title : "添加代碼塊", selectLabel : "代碼語言:", selectDefaultText : "請語言代碼語言", otherLanguage : "其他語言", @@ -134821,13 +134843,13 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); } } }; - + exports.defaults.lang = lang; }; - + // CommonJS/Node.js if (typeof require === "function" && typeof exports === "object" && typeof module === "object") - { + { module.exports = factory; } else if (typeof define === "function") // AMD/CMD/Sea.js @@ -134844,12 +134866,12 @@ CodeMirror.defineMIME('application/x-sh', 'shell'); factory(editormd); }); } - } + } else { factory(window.editormd); } - + })(); (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dragula = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o\n' + ' \n' + '\n' + - ' 第1阶段\n' + + ' 第1阶段\n' + '\n' + '\n' + - ' 有效时间:\n' + - '\n' + + '\n' + '有效时间:\n' + + '\n' + '\n' + ' \n' + '\n' + ' ~\n' + - '\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 总任务数:\n' + - '\n' + + '总任务数:\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 成绩来源:\n' + - '\n' + + '成绩来源:\n' + + '\n' + ' \n' + - '\n' + + '\n' + '\n' + - ' 任务1\n' + - '\n' + + ' 任务1\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务2\n' + - '\n' + + ' 任务2\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务3\n' + - '\n' + + ' 任务3\n' + + '\n' + @@ -136595,45 +136617,45 @@ $(document).on('turbolinks:load', function(){ var html='\n' + ' \n' + '\n' + '\n' + - ' 第'+showCount+'阶段\n' + + ' 第'+showCount+'阶段\n' + '\n' + '\n' + - ' 有效时间:\n' + - '\n' + + '\n' + '有效时间:\n' + + '\n' + '\n' + ' \n' + '\n' + ' ~\n' + - '\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 总任务数:\n' + - '\n' + + '总任务数:\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 成绩来源:\n' + - '\n' + + '成绩来源:\n' + + '\n' + ' \n' + - '\n' + + '\n'+ '\n' + - ' 任务1\n' + - '\n' + + ' 任务1\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务2\n' + - '\n' + + ' 任务2\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务3\n' + - '\n' + + ' 任务3\n' + + '\n' + @@ -136648,6 +136670,67 @@ $(document).on('turbolinks:load', function(){ $(".stage-update-form .section-start-time").datetimepicker(timeOptions); $(".stage-update-form .section-end-time").datetimepicker(timeOptions); }); + + // 奖项设置 + var $prizeContainer = $('#competition-prize-card'); + var competitionId = $prizeContainer.data('id'); + $(document).on('prize.save.success', function(){ + $.ajax({ + method: 'GET', + url: '/admins/competitions/' + competitionId + '/competition_prizes', + dataType: 'script' + }) + }); + + $('.modal.admin-upload-file-modal').on('upload:success', function(e, data){ + var $imageElement; + if(data.suffix === '_member'){ + $imageElement = $('.prize-member-image-' + data.source_id); + } else if(data.suffix === '_team'){ + $imageElement = $('.prize-team-image-' + data.source_id); + } else { + $imageElement = $('.prize-teacher-image-' + data.source_id); + } + $imageElement.attr('src', data.url); + $imageElement.show(); + $imageElement.next().html('重新上传'); + }) + + // 生成获奖记录 + $prizeContainer.on('click', '.generate-prize-user-action', function(){ + var $link = $(this); + + var generateRequest = function(){ + return $.ajax({ + method: 'POST', + url: '/admins/competitions/' + competitionId + '/competition_prize_users', + dataType: 'json', + success: function(data){ + if(data && data.status === 0){ + show_success_flash(); + $link.remove(); + } else { + showErrorNotify(data.message); + } + }, + error: function(res){ + var data = res.responseJSON; + showErrorNotify(data.message); + } + }) + } + + customConfirm({ + content: '确认生成吗?', + ok: function () { + customLoading({ + ajax: generateRequest + }) + } + }) + }); + } else { + $(document).unbind('prize.save.success'); } }); @@ -136681,8 +136764,8 @@ function change_total(item) { var html = ""; if(count > divCount){ for(var i=0;i < count-divCount ;i++){ - html+='\n' + ' \n' + '\n' + '任务'+(divCount+i+1)+'\n' + - '\n' + + html+='\n' + '任务'+(divCount+i+1)+'\n' + + ''; @@ -136736,45 +136819,45 @@ function addNewTab(competition_id) { '\n' + '\n' + '\n' + '\n' + '\n' + - ' 第1阶段\n' + + ' 第1阶段\n' + '\n' + '\n' + - ' 有效时间:\n' + - '\n' + + '\n' + '有效时间:\n' + + '\n' + '\n' + ' \n' + '\n' + ' ~\n' + - '\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 总任务数:\n' + - '\n' + + '总任务数:\n' + + '\n' + + '\n' + ' \n' + - '\n' + - ' 成绩来源:\n' + - '\n' + + '成绩来源:\n' + + '\n' + ' \n' + - '\n' + + '\n' + '\n' + - ' 任务1\n' + - '\n' + + ' 任务1\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务2\n' + - '\n' + + ' 任务2\n' + + '\n' + '\n' + ' \n' + '\n' + '\n' + - ' 任务3\n' + - '\n' + + ' 任务3\n' + + '\n' + @@ -137786,8 +137869,8 @@ $(document).on('turbolinks:load', function() { data: $form.serialize() }); } - }); - }) + }); + }) }); $(document).on('turbolinks:load', function () { $('.admin-modal-container').on('show.bs.modal', '.modal.admin-edit-subject-modal', function () { @@ -138085,6 +138168,52 @@ $(document).on('turbolinks:load', function() { }); } }); +$(document).on('turbolinks:load', function() { + $('.admin-modal-container').on('show.bs.modal', '.admin-save-competition-prize-modal', function(event){ + var $modal = $('.modal.admin-save-competition-prize-modal'); + var $form = $modal.find('form.admin-save-competition-prize-form'); + + $form.validate({ + errorElement: 'span', + errorClass: 'danger text-danger', + rules: { + 'competition_prize[name]': { + required: true, + maxlength: 10 + }, + 'competition_prize[num]': { + required: true, + digits: true, + min: 1 + } + } + }); + + $modal.on('click', '.submit-btn', function(){ + $form.find('.error').html(''); + var url = $form.attr('action'); + var formMethod = $form.data('form-method') + + if ($form.valid()) { + $.ajax({ + method: formMethod, + dataType: 'json', + url: url, + data: $form.serialize(), + success: function(data){ + if(data && data.status === 0) { + show_success_flash(); + $(document).trigger('prize.save.success'); + $modal.modal('hide'); + } else { + $modal.find('.error').html(data.message) + } + } + }); + } + }); + }) +}); $(document).on('turbolinks:load', function() { var $modal = $('.modal.admin-upload-file-modal'); if ($modal.length > 0) { diff --git a/public/assets/admin-5d791c4f4a14e1586cfa44776ae262b3c1494e1c0fb0e00c330f0cb9d30fd7ba.js.gz b/public/assets/admin-5d791c4f4a14e1586cfa44776ae262b3c1494e1c0fb0e00c330f0cb9d30fd7ba.js.gz new file mode 100644 index 000000000..5ea1b2817 Binary files /dev/null and b/public/assets/admin-5d791c4f4a14e1586cfa44776ae262b3c1494e1c0fb0e00c330f0cb9d30fd7ba.js.gz differ diff --git a/public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css b/public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css similarity index 99% rename from public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css rename to public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css index c21343820..2611b0b16 100644 --- a/public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css +++ b/public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css @@ -20922,9 +20922,9 @@ span.CodeMirror-selectedtext { } /*! prefixes.scss v0.1.0 | Author: Pandao | https://github.com/pandao/prefixes.scss | MIT license | Copyright (c) 2015 */ -/*! - * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome - * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) +/*! + * Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome + * License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License) */ @font-face { font-family: FontAwesome; @@ -25681,6 +25681,48 @@ input.form-control { border: none; } +/* line 91, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n-2) > span.col-4 { + -webkit-box-flex: 0; + flex: 0 0 81px; + max-width: 81px; +} + +/* line 95, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n-2) { + -webkit-box-flex: 0; + flex: 0 0 50%; + max-width: 50%; +} + +/* line 99, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n-1) { + -webkit-box-flex: 0; + flex: 0 0 25%; + max-width: 25%; +} + +/* line 103, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n) { + -webkit-box-flex: 0; + flex: 0 0 33.3%; + max-width: 33.3%; +} + +/* line 107, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n) > span.col-4 { + -webkit-box-flex: 0; + flex: 0 0 25%; + max-width: 25%; +} + +/* line 111, app/assets/stylesheets/admins/competition_settings.scss */ +.admins-competition-settings-index-page .large_panel .task_Input_div:nth-child(3n) > div.col-6 { + -webkit-box-flex: 0; + flex: 0 0 58.3%; + max-width: 58.3%; +} + /* line 4, app/assets/stylesheets/admins/cooperatives.scss */ .admins-cooperatives-index-page .coo-img-card .coo-img-item > .drag { cursor: move; @@ -26142,7 +26184,7 @@ input.form-control { /* line 27, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active .sidebar-header-logo > .logo-label { - display: none; + display: none; } /* line 33, app/assets/stylesheets/admins/sidebar.scss */ @@ -26214,25 +26256,25 @@ input.form-control { /* line 83, app/assets/stylesheets/admins/sidebar.scss */ #sidebar .sidebar-header-logo { - display: -webkit-box; - display: flex; - -webkit-box-pack: justify; - justify-content: space-between; - -webkit-box-align: center; - align-items: center; + display: -webkit-box; + display: flex; + -webkit-box-pack: justify; + justify-content: space-between; + -webkit-box-align: center; + align-items: center; } /* line 88, app/assets/stylesheets/admins/sidebar.scss */ #sidebar .sidebar-header-logo > img { - width: 40px; - height: auto; + width: 40px; + height: auto; } /* line 93, app/assets/stylesheets/admins/sidebar.scss */ #sidebar .sidebar-header-logo > .logo-label { - font-size: 18px; - color: darkgrey; - margin-left: 10px; + font-size: 18px; + color: darkgrey; + margin-left: 10px; } /* line 101, app/assets/stylesheets/admins/sidebar.scss */ @@ -26336,7 +26378,7 @@ input.form-control { } @media (max-width: 768px) { - /* line 182, app/assets/stylesheets/admins/sidebar.scss */ + /* line 182, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active { padding: 10px 5px; min-width: 40px; @@ -26346,47 +26388,39 @@ input.form-control { -webkit-transform: none; transform: none; } - - /* line 190, app/assets/stylesheets/admins/sidebar.scss */ + /* line 190, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active .sidebar-header { padding: 0px; } - - /* line 193, app/assets/stylesheets/admins/sidebar.scss */ + /* line 193, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active .sidebar-header .sidebar-header-logo { display: none; } - - /* line 197, app/assets/stylesheets/admins/sidebar.scss */ + /* line 197, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active .sidebar-header #sidebarCollapse { width: 30px; height: 20px; } - - /* line 203, app/assets/stylesheets/admins/sidebar.scss */ + /* line 203, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active ul li a { padding: 10px; font-size: 0.85em; } - - /* line 207, app/assets/stylesheets/admins/sidebar.scss */ + /* line 207, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active ul li a i { margin-right: 0; display: block; margin-bottom: 5px; } - - /* line 214, app/assets/stylesheets/admins/sidebar.scss */ + /* line 214, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active > ul > li > a > i { font-size: 1.8em; } - - /* line 218, app/assets/stylesheets/admins/sidebar.scss */ + /* line 218, app/assets/stylesheets/admins/sidebar.scss */ #sidebar.active ul ul a { padding: 10px !important; } - - /* line 227, app/assets/stylesheets/admins/sidebar.scss */ + /* line 227, app/assets/stylesheets/admins/sidebar.scss */ .dropdown-toggle::after { top: auto; bottom: 10px; diff --git a/public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css.gz b/public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css.gz similarity index 75% rename from public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css.gz rename to public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css.gz index 48f2a32cf..1e065c160 100644 Binary files a/public/assets/admin-6a76c25b6691b4f436608be28606d90c907ba8f033f5f47c6c20d7bf11251cb6.css.gz and b/public/assets/admin-70dc0e7136a8f54139e4167c00f3fde9ccc92b404b01b37ac6064913806e3f6e.css.gz differ diff --git a/public/assets/admin-e975e2039206e9ae2b6a072fee083cf39b8e04f2318f67bfbf1923fe208456b3.js.gz b/public/assets/admin-e975e2039206e9ae2b6a072fee083cf39b8e04f2318f67bfbf1923fe208456b3.js.gz deleted file mode 100644 index 73ad7510e..000000000 Binary files a/public/assets/admin-e975e2039206e9ae2b6a072fee083cf39b8e04f2318f67bfbf1923fe208456b3.js.gz and /dev/null differ diff --git a/public/assets/cooperative-f1ac8f14ad6ade8d1f79ca49ea9c79be77d49aae9d2705ca672e78444481700d.js b/public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js similarity index 99% rename from public/assets/cooperative-f1ac8f14ad6ade8d1f79ca49ea9c79be77d49aae9d2705ca672e78444481700d.js rename to public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js index 64eec3d6b..cf5015df2 100644 --- a/public/assets/cooperative-f1ac8f14ad6ade8d1f79ca49ea9c79be77d49aae9d2705ca672e78444481700d.js +++ b/public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js @@ -29891,13 +29891,35 @@ function customConfirm(opts){ return $.confirm($.extend({}, defaultOpts, opts)) } -function show_success_flash(){ +function customLoading(opts) { + var loading; + var defaultOpts = { + content: opts.ajax, + contentLoaded: function(){ + setTimeout(function(){ + loading.close() + }, 200); + } + } + loading = $.confirm($.extend({}, defaultOpts, opts)); + return loading; +} + +function show_success_flash(message){ $.notify({ - message: '操作成功' + message: message || '操作成功' },{ type: 'success' }); } + +function showErrorNotify(message){ + $.notify({ + message: message || '操作失败' + },{ + type: 'danger' + }); +} ; (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : diff --git a/public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js.gz b/public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js.gz new file mode 100644 index 000000000..5ee8073c2 Binary files /dev/null and b/public/assets/cooperative-4fe879591997da39d38e94f6f5eb3b688aa827fa42cb8fd73d21bc96ed880236.js.gz differ diff --git a/public/assets/cooperative-a309d245cd0b0b9c653db471c53ec090e49ba7ad885879ffa02a11b6efd79d74.js b/public/assets/cooperative-a309d245cd0b0b9c653db471c53ec090e49ba7ad885879ffa02a11b6efd79d74.js deleted file mode 100644 index 2e7bf74aa..000000000 --- a/public/assets/cooperative-a309d245cd0b0b9c653db471c53ec090e49ba7ad885879ffa02a11b6efd79d74.js +++ /dev/null @@ -1,141770 +0,0 @@ -/* -Unobtrusive JavaScript -https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts -Released under the MIT license - */ - - -(function () { - var context = this; - - (function () { - (function () { - this.Rails = { - linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote]:not([disabled]), a[data-disable-with], a[data-disable]', - buttonClickSelector: { - selector: 'button[data-remote]:not([form]), button[data-confirm]:not([form])', - exclude: 'form button' - }, - inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]', - formSubmitSelector: 'form', - formInputClickSelector: 'form input[type=submit], form input[type=image], form button[type=submit], form button:not([type]), input[type=submit][form], input[type=image][form], button[type=submit][form], button[form]:not([type])', - formDisableSelector: 'input[data-disable-with]:enabled, button[data-disable-with]:enabled, textarea[data-disable-with]:enabled, input[data-disable]:enabled, button[data-disable]:enabled, textarea[data-disable]:enabled', - formEnableSelector: 'input[data-disable-with]:disabled, button[data-disable-with]:disabled, textarea[data-disable-with]:disabled, input[data-disable]:disabled, button[data-disable]:disabled, textarea[data-disable]:disabled', - fileInputSelector: 'input[name][type=file]:not([disabled])', - linkDisableSelector: 'a[data-disable-with], a[data-disable]', - buttonDisableSelector: 'button[data-remote][data-disable-with], button[data-remote][data-disable]' - }; - - }).call(this); - }).call(context); - - var Rails = context.Rails; - - (function () { - (function () { - var cspNonce; - - cspNonce = Rails.cspNonce = function () { - var meta; - meta = document.querySelector('meta[name=csp-nonce]'); - return meta && meta.content; - }; - - }).call(this); - (function () { - var expando, m; - - m = Element.prototype.matches || Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector; - - Rails.matches = function (element, selector) { - if (selector.exclude != null) { - return m.call(element, selector.selector) && !m.call(element, selector.exclude); - } else { - return m.call(element, selector); - } - }; - - expando = '_ujsData'; - - Rails.getData = function (element, key) { - var ref; - return (ref = element[expando]) != null ? ref[key] : void 0; - }; - - Rails.setData = function (element, key, value) { - if (element[expando] == null) { - element[expando] = {}; - } - return element[expando][key] = value; - }; - - Rails.$ = function (selector) { - return Array.prototype.slice.call(document.querySelectorAll(selector)); - }; - - }).call(this); - (function () { - var $, csrfParam, csrfToken; - - $ = Rails.$; - - csrfToken = Rails.csrfToken = function () { - var meta; - meta = document.querySelector('meta[name=csrf-token]'); - return meta && meta.content; - }; - - csrfParam = Rails.csrfParam = function () { - var meta; - meta = document.querySelector('meta[name=csrf-param]'); - return meta && meta.content; - }; - - Rails.CSRFProtection = function (xhr) { - var token; - token = csrfToken(); - if (token != null) { - return xhr.setRequestHeader('X-CSRF-Token', token); - } - }; - - Rails.refreshCSRFTokens = function () { - var param, token; - token = csrfToken(); - param = csrfParam(); - if ((token != null) && (param != null)) { - return $('form input[name="' + param + '"]').forEach(function (input) { - return input.value = token; - }); - } - }; - - }).call(this); - (function () { - var CustomEvent, fire, matches, preventDefault; - - matches = Rails.matches; - - CustomEvent = window.CustomEvent; - - if (typeof CustomEvent !== 'function') { - CustomEvent = function (event, params) { - var evt; - evt = document.createEvent('CustomEvent'); - evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); - return evt; - }; - CustomEvent.prototype = window.Event.prototype; - preventDefault = CustomEvent.prototype.preventDefault; - CustomEvent.prototype.preventDefault = function () { - var result; - result = preventDefault.call(this); - if (this.cancelable && !this.defaultPrevented) { - Object.defineProperty(this, 'defaultPrevented', { - get: function () { - return true; - } - }); - } - return result; - }; - } - - fire = Rails.fire = function (obj, name, data) { - var event; - event = new CustomEvent(name, { - bubbles: true, - cancelable: true, - detail: data - }); - obj.dispatchEvent(event); - return !event.defaultPrevented; - }; - - Rails.stopEverything = function (e) { - fire(e.target, 'ujs:everythingStopped'); - e.preventDefault(); - e.stopPropagation(); - return e.stopImmediatePropagation(); - }; - - Rails.delegate = function (element, selector, eventType, handler) { - return element.addEventListener(eventType, function (e) { - var target; - target = e.target; - while (!(!(target instanceof Element) || matches(target, selector))) { - target = target.parentNode; - } - if (target instanceof Element && handler.call(target, e) === false) { - e.preventDefault(); - return e.stopPropagation(); - } - }); - }; - - }).call(this); - (function () { - var AcceptHeaders, CSRFProtection, createXHR, cspNonce, fire, prepareOptions, processResponse; - - cspNonce = Rails.cspNonce, CSRFProtection = Rails.CSRFProtection, fire = Rails.fire; - - AcceptHeaders = { - '*': '*/*', - text: 'text/plain', - html: 'text/html', - xml: 'application/xml, text/xml', - json: 'application/json, text/javascript', - script: 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript' - }; - - Rails.ajax = function (options) { - var xhr; - options = prepareOptions(options); - xhr = createXHR(options, function () { - var ref, response; - response = processResponse((ref = xhr.response) != null ? ref : xhr.responseText, xhr.getResponseHeader('Content-Type')); - if (Math.floor(xhr.status / 100) === 2) { - if (typeof options.success === "function") { - options.success(response, xhr.statusText, xhr); - } - } else { - if (typeof options.error === "function") { - options.error(response, xhr.statusText, xhr); - } - } - return typeof options.complete === "function" ? options.complete(xhr, xhr.statusText) : void 0; - }); - if ((options.beforeSend != null) && !options.beforeSend(xhr, options)) { - return false; - } - if (xhr.readyState === XMLHttpRequest.OPENED) { - return xhr.send(options.data); - } - }; - - prepareOptions = function (options) { - options.url = options.url || location.href; - options.type = options.type.toUpperCase(); - if (options.type === 'GET' && options.data) { - if (options.url.indexOf('?') < 0) { - options.url += '?' + options.data; - } else { - options.url += '&' + options.data; - } - } - if (AcceptHeaders[options.dataType] == null) { - options.dataType = '*'; - } - options.accept = AcceptHeaders[options.dataType]; - if (options.dataType !== '*') { - options.accept += ', */*; q=0.01'; - } - return options; - }; - - createXHR = function (options, done) { - var xhr; - xhr = new XMLHttpRequest(); - xhr.open(options.type, options.url, true); - xhr.setRequestHeader('Accept', options.accept); - if (typeof options.data === 'string') { - xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); - } - if (!options.crossDomain) { - xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); - } - CSRFProtection(xhr); - xhr.withCredentials = !!options.withCredentials; - xhr.onreadystatechange = function () { - if (xhr.readyState === XMLHttpRequest.DONE) { - return done(xhr); - } - }; - return xhr; - }; - - processResponse = function (response, type) { - var parser, script; - if (typeof response === 'string' && typeof type === 'string') { - if (type.match(/\bjson\b/)) { - try { - response = JSON.parse(response); - } catch (error) { - } - } else if (type.match(/\b(?:java|ecma)script\b/)) { - script = document.createElement('script'); - script.setAttribute('nonce', cspNonce()); - script.text = response; - document.head.appendChild(script).parentNode.removeChild(script); - } else if (type.match(/\b(xml|html|svg)\b/)) { - parser = new DOMParser(); - type = type.replace(/;.+/, ''); - try { - response = parser.parseFromString(response, type); - } catch (error) { - } - } - } - return response; - }; - - Rails.href = function (element) { - return element.href; - }; - - Rails.isCrossDomain = function (url) { - var e, originAnchor, urlAnchor; - originAnchor = document.createElement('a'); - originAnchor.href = location.href; - urlAnchor = document.createElement('a'); - try { - urlAnchor.href = url; - return !(((!urlAnchor.protocol || urlAnchor.protocol === ':') && !urlAnchor.host) || (originAnchor.protocol + '//' + originAnchor.host === urlAnchor.protocol + '//' + urlAnchor.host)); - } catch (error) { - e = error; - return true; - } - }; - - }).call(this); - (function () { - var matches, toArray; - - matches = Rails.matches; - - toArray = function (e) { - return Array.prototype.slice.call(e); - }; - - Rails.serializeElement = function (element, additionalParam) { - var inputs, params; - inputs = [element]; - if (matches(element, 'form')) { - inputs = toArray(element.elements); - } - params = []; - inputs.forEach(function (input) { - if (!input.name || input.disabled) { - return; - } - if (matches(input, 'select')) { - return toArray(input.options).forEach(function (option) { - if (option.selected) { - return params.push({ - name: input.name, - value: option.value - }); - } - }); - } else if (input.checked || ['radio', 'checkbox', 'submit'].indexOf(input.type) === -1) { - return params.push({ - name: input.name, - value: input.value - }); - } - }); - if (additionalParam) { - params.push(additionalParam); - } - return params.map(function (param) { - if (param.name != null) { - return (encodeURIComponent(param.name)) + "=" + (encodeURIComponent(param.value)); - } else { - return param; - } - }).join('&'); - }; - - Rails.formElements = function (form, selector) { - if (matches(form, 'form')) { - return toArray(form.elements).filter(function (el) { - return matches(el, selector); - }); - } else { - return toArray(form.querySelectorAll(selector)); - } - }; - - }).call(this); - (function () { - var allowAction, fire, stopEverything; - - fire = Rails.fire, stopEverything = Rails.stopEverything; - - Rails.handleConfirm = function (e) { - if (!allowAction(this)) { - return stopEverything(e); - } - }; - - allowAction = function (element) { - var answer, callback, message; - message = element.getAttribute('data-confirm'); - if (!message) { - return true; - } - answer = false; - if (fire(element, 'confirm')) { - try { - answer = confirm(message); - } catch (error) { - } - callback = fire(element, 'confirm:complete', [answer]); - } - return answer && callback; - }; - - }).call(this); - (function () { - var disableFormElement, disableFormElements, disableLinkElement, enableFormElement, enableFormElements, - enableLinkElement, formElements, getData, matches, setData, stopEverything; - - matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, stopEverything = Rails.stopEverything, formElements = Rails.formElements; - - Rails.handleDisabledElement = function (e) { - var element; - element = this; - if (element.disabled) { - return stopEverything(e); - } - }; - - Rails.enableElement = function (e) { - var element; - element = e instanceof Event ? e.target : e; - if (matches(element, Rails.linkDisableSelector)) { - return enableLinkElement(element); - } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formEnableSelector)) { - return enableFormElement(element); - } else if (matches(element, Rails.formSubmitSelector)) { - return enableFormElements(element); - } - }; - - Rails.disableElement = function (e) { - var element; - element = e instanceof Event ? e.target : e; - if (matches(element, Rails.linkDisableSelector)) { - return disableLinkElement(element); - } else if (matches(element, Rails.buttonDisableSelector) || matches(element, Rails.formDisableSelector)) { - return disableFormElement(element); - } else if (matches(element, Rails.formSubmitSelector)) { - return disableFormElements(element); - } - }; - - disableLinkElement = function (element) { - var replacement; - replacement = element.getAttribute('data-disable-with'); - if (replacement != null) { - setData(element, 'ujs:enable-with', element.innerHTML); - element.innerHTML = replacement; - } - element.addEventListener('click', stopEverything); - return setData(element, 'ujs:disabled', true); - }; - - enableLinkElement = function (element) { - var originalText; - originalText = getData(element, 'ujs:enable-with'); - if (originalText != null) { - element.innerHTML = originalText; - setData(element, 'ujs:enable-with', null); - } - element.removeEventListener('click', stopEverything); - return setData(element, 'ujs:disabled', null); - }; - - disableFormElements = function (form) { - return formElements(form, Rails.formDisableSelector).forEach(disableFormElement); - }; - - disableFormElement = function (element) { - var replacement; - replacement = element.getAttribute('data-disable-with'); - if (replacement != null) { - if (matches(element, 'button')) { - setData(element, 'ujs:enable-with', element.innerHTML); - element.innerHTML = replacement; - } else { - setData(element, 'ujs:enable-with', element.value); - element.value = replacement; - } - } - element.disabled = true; - return setData(element, 'ujs:disabled', true); - }; - - enableFormElements = function (form) { - return formElements(form, Rails.formEnableSelector).forEach(enableFormElement); - }; - - enableFormElement = function (element) { - var originalText; - originalText = getData(element, 'ujs:enable-with'); - if (originalText != null) { - if (matches(element, 'button')) { - element.innerHTML = originalText; - } else { - element.value = originalText; - } - setData(element, 'ujs:enable-with', null); - } - element.disabled = false; - return setData(element, 'ujs:disabled', null); - }; - - }).call(this); - (function () { - var stopEverything; - - stopEverything = Rails.stopEverything; - - Rails.handleMethod = function (e) { - var csrfParam, csrfToken, form, formContent, href, link, method; - link = this; - method = link.getAttribute('data-method'); - if (!method) { - return; - } - href = Rails.href(link); - csrfToken = Rails.csrfToken(); - csrfParam = Rails.csrfParam(); - form = document.createElement('form'); - formContent = ""; - if ((csrfParam != null) && (csrfToken != null) && !Rails.isCrossDomain(href)) { - formContent += ""; - } - formContent += ''; - form.method = 'post'; - form.action = href; - form.target = link.target; - form.innerHTML = formContent; - form.style.display = 'none'; - document.body.appendChild(form); - form.querySelector('[type="submit"]').click(); - return stopEverything(e); - }; - - }).call(this); - (function () { - var ajax, fire, getData, isCrossDomain, isRemote, matches, serializeElement, setData, stopEverything, - slice = [].slice; - - matches = Rails.matches, getData = Rails.getData, setData = Rails.setData, fire = Rails.fire, stopEverything = Rails.stopEverything, ajax = Rails.ajax, isCrossDomain = Rails.isCrossDomain, serializeElement = Rails.serializeElement; - - isRemote = function (element) { - var value; - value = element.getAttribute('data-remote'); - return (value != null) && value !== 'false'; - }; - - Rails.handleRemote = function (e) { - var button, data, dataType, element, method, url, withCredentials; - element = this; - if (!isRemote(element)) { - return true; - } - if (!fire(element, 'ajax:before')) { - fire(element, 'ajax:stopped'); - return false; - } - withCredentials = element.getAttribute('data-with-credentials'); - dataType = element.getAttribute('data-type') || 'script'; - if (matches(element, Rails.formSubmitSelector)) { - button = getData(element, 'ujs:submit-button'); - method = getData(element, 'ujs:submit-button-formmethod') || element.method; - url = getData(element, 'ujs:submit-button-formaction') || element.getAttribute('action') || location.href; - if (method.toUpperCase() === 'GET') { - url = url.replace(/\?.*$/, ''); - } - if (element.enctype === 'multipart/form-data') { - data = new FormData(element); - if (button != null) { - data.append(button.name, button.value); - } - } else { - data = serializeElement(element, button); - } - setData(element, 'ujs:submit-button', null); - setData(element, 'ujs:submit-button-formmethod', null); - setData(element, 'ujs:submit-button-formaction', null); - } else if (matches(element, Rails.buttonClickSelector) || matches(element, Rails.inputChangeSelector)) { - method = element.getAttribute('data-method'); - url = element.getAttribute('data-url'); - data = serializeElement(element, element.getAttribute('data-params')); - } else { - method = element.getAttribute('data-method'); - url = Rails.href(element); - data = element.getAttribute('data-params'); - } - ajax({ - type: method || 'GET', - url: url, - data: data, - dataType: dataType, - beforeSend: function (xhr, options) { - if (fire(element, 'ajax:beforeSend', [xhr, options])) { - return fire(element, 'ajax:send', [xhr]); - } else { - fire(element, 'ajax:stopped'); - return false; - } - }, - success: function () { - var args; - args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return fire(element, 'ajax:success', args); - }, - error: function () { - var args; - args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return fire(element, 'ajax:error', args); - }, - complete: function () { - var args; - args = 1 <= arguments.length ? slice.call(arguments, 0) : []; - return fire(element, 'ajax:complete', args); - }, - crossDomain: isCrossDomain(url), - withCredentials: (withCredentials != null) && withCredentials !== 'false' - }); - return stopEverything(e); - }; - - Rails.formSubmitButtonClick = function (e) { - var button, form; - button = this; - form = button.form; - if (!form) { - return; - } - if (button.name) { - setData(form, 'ujs:submit-button', { - name: button.name, - value: button.value - }); - } - setData(form, 'ujs:formnovalidate-button', button.formNoValidate); - setData(form, 'ujs:submit-button-formaction', button.getAttribute('formaction')); - return setData(form, 'ujs:submit-button-formmethod', button.getAttribute('formmethod')); - }; - - Rails.handleMetaClick = function (e) { - var data, link, metaClick, method; - link = this; - method = (link.getAttribute('data-method') || 'GET').toUpperCase(); - data = link.getAttribute('data-params'); - metaClick = e.metaKey || e.ctrlKey; - if (metaClick && method === 'GET' && !data) { - return e.stopImmediatePropagation(); - } - }; - - }).call(this); - (function () { - var $, CSRFProtection, delegate, disableElement, enableElement, fire, formSubmitButtonClick, getData, - handleConfirm, handleDisabledElement, handleMetaClick, handleMethod, handleRemote, refreshCSRFTokens; - - fire = Rails.fire, delegate = Rails.delegate, getData = Rails.getData, $ = Rails.$, refreshCSRFTokens = Rails.refreshCSRFTokens, CSRFProtection = Rails.CSRFProtection, enableElement = Rails.enableElement, disableElement = Rails.disableElement, handleDisabledElement = Rails.handleDisabledElement, handleConfirm = Rails.handleConfirm, handleRemote = Rails.handleRemote, formSubmitButtonClick = Rails.formSubmitButtonClick, handleMetaClick = Rails.handleMetaClick, handleMethod = Rails.handleMethod; - - if ((typeof jQuery !== "undefined" && jQuery !== null) && (jQuery.ajax != null) && !jQuery.rails) { - jQuery.rails = Rails; - jQuery.ajaxPrefilter(function (options, originalOptions, xhr) { - if (!options.crossDomain) { - return CSRFProtection(xhr); - } - }); - } - - Rails.start = function () { - if (window._rails_loaded) { - throw new Error('rails-ujs has already been loaded!'); - } - window.addEventListener('pageshow', function () { - $(Rails.formEnableSelector).forEach(function (el) { - if (getData(el, 'ujs:disabled')) { - return enableElement(el); - } - }); - return $(Rails.linkDisableSelector).forEach(function (el) { - if (getData(el, 'ujs:disabled')) { - return enableElement(el); - } - }); - }); - delegate(document, Rails.linkDisableSelector, 'ajax:complete', enableElement); - delegate(document, Rails.linkDisableSelector, 'ajax:stopped', enableElement); - delegate(document, Rails.buttonDisableSelector, 'ajax:complete', enableElement); - delegate(document, Rails.buttonDisableSelector, 'ajax:stopped', enableElement); - delegate(document, Rails.linkClickSelector, 'click', handleDisabledElement); - delegate(document, Rails.linkClickSelector, 'click', handleConfirm); - delegate(document, Rails.linkClickSelector, 'click', handleMetaClick); - delegate(document, Rails.linkClickSelector, 'click', disableElement); - delegate(document, Rails.linkClickSelector, 'click', handleRemote); - delegate(document, Rails.linkClickSelector, 'click', handleMethod); - delegate(document, Rails.buttonClickSelector, 'click', handleDisabledElement); - delegate(document, Rails.buttonClickSelector, 'click', handleConfirm); - delegate(document, Rails.buttonClickSelector, 'click', disableElement); - delegate(document, Rails.buttonClickSelector, 'click', handleRemote); - delegate(document, Rails.inputChangeSelector, 'change', handleDisabledElement); - delegate(document, Rails.inputChangeSelector, 'change', handleConfirm); - delegate(document, Rails.inputChangeSelector, 'change', handleRemote); - delegate(document, Rails.formSubmitSelector, 'submit', handleDisabledElement); - delegate(document, Rails.formSubmitSelector, 'submit', handleConfirm); - delegate(document, Rails.formSubmitSelector, 'submit', handleRemote); - delegate(document, Rails.formSubmitSelector, 'submit', function (e) { - return setTimeout((function () { - return disableElement(e); - }), 13); - }); - delegate(document, Rails.formSubmitSelector, 'ajax:send', disableElement); - delegate(document, Rails.formSubmitSelector, 'ajax:complete', enableElement); - delegate(document, Rails.formInputClickSelector, 'click', handleDisabledElement); - delegate(document, Rails.formInputClickSelector, 'click', handleConfirm); - delegate(document, Rails.formInputClickSelector, 'click', formSubmitButtonClick); - document.addEventListener('DOMContentLoaded', refreshCSRFTokens); - return window._rails_loaded = true; - }; - - if (window.Rails === Rails && fire(document, 'rails:attachBindings')) { - Rails.start(); - } - - }).call(this); - }).call(this); - - if (typeof module === "object" && module.exports) { - module.exports = Rails; - } else if (typeof define === "function" && define.amd) { - define(Rails); - } -}).call(this); -!function (t, e) { - "object" == typeof exports && "object" == typeof module ? module.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports ? exports.ActiveStorage = e() : t.ActiveStorage = e() -}(this, function () { - return function (t) { - function e(n) { - if (r[n]) return r[n].exports; - var i = r[n] = {i: n, l: !1, exports: {}}; - return t[n].call(i.exports, i, i.exports, e), i.l = !0, i.exports - } - - var r = {}; - return e.m = t, e.c = r, e.d = function (t, r, n) { - e.o(t, r) || Object.defineProperty(t, r, {configurable: !1, enumerable: !0, get: n}) - }, e.n = function (t) { - var r = t && t.__esModule ? function () { - return t.default - } : function () { - return t - }; - return e.d(r, "a", r), r - }, e.o = function (t, e) { - return Object.prototype.hasOwnProperty.call(t, e) - }, e.p = "", e(e.s = 2) - }([function (t, e, r) { - "use strict"; - - function n(t) { - var e = a(document.head, 'meta[name="' + t + '"]'); - if (e) return e.getAttribute("content") - } - - function i(t, e) { - return "string" == typeof t && (e = t, t = document), o(t.querySelectorAll(e)) - } - - function a(t, e) { - return "string" == typeof t && (e = t, t = document), t.querySelector(e) - } - - function u(t, e) { - var r = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : {}, n = t.disabled, i = r.bubbles, - a = r.cancelable, u = r.detail, o = document.createEvent("Event"); - o.initEvent(e, i || !0, a || !0), o.detail = u || {}; - try { - t.disabled = !1, t.dispatchEvent(o) - } finally { - t.disabled = n - } - return o - } - - function o(t) { - return Array.isArray(t) ? t : Array.from ? Array.from(t) : [].slice.call(t) - } - - e.d = n, e.c = i, e.b = a, e.a = u, e.e = o - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - function i(t, e) { - if (t && "function" == typeof t[e]) { - for (var r = arguments.length, n = Array(r > 2 ? r - 2 : 0), i = 2; i < r; i++) n[i - 2] = arguments[i]; - return t[e].apply(t, n) - } - } - - r.d(e, "a", function () { - return c - }); - var a = r(6), u = r(8), o = r(9), s = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), f = 0, c = function () { - function t(e, r, i) { - n(this, t), this.id = ++f, this.file = e, this.url = r, this.delegate = i - } - - return s(t, [{ - key: "create", value: function (t) { - var e = this; - a.a.create(this.file, function (r, n) { - if (r) return void t(r); - var a = new u.a(e.file, n, e.url); - i(e.delegate, "directUploadWillCreateBlobWithXHR", a.xhr), a.create(function (r) { - if (r) t(r); else { - var n = new o.a(a); - i(e.delegate, "directUploadWillStoreFileWithXHR", n.xhr), n.create(function (e) { - e ? t(e) : t(null, a.toJSON()) - }) - } - }) - }) - } - }]), t - }() - }, function (t, e, r) { - "use strict"; - - function n() { - window.ActiveStorage && Object(i.a)() - } - - Object.defineProperty(e, "__esModule", {value: !0}); - var i = r(3), a = r(1); - r.d(e, "start", function () { - return i.a - }), r.d(e, "DirectUpload", function () { - return a.a - }), setTimeout(n, 1) - }, function (t, e, r) { - "use strict"; - - function n() { - d || (d = !0, document.addEventListener("submit", i), document.addEventListener("ajax:before", a)) - } - - function i(t) { - u(t) - } - - function a(t) { - "FORM" == t.target.tagName && u(t) - } - - function u(t) { - var e = t.target; - if (e.hasAttribute(l)) return void t.preventDefault(); - var r = new c.a(e), n = r.inputs; - n.length && (t.preventDefault(), e.setAttribute(l, ""), n.forEach(s), r.start(function (t) { - e.removeAttribute(l), t ? n.forEach(f) : o(e) - })) - } - - function o(t) { - var e = Object(h.b)(t, "input[type=submit]"); - if (e) { - var r = e, n = r.disabled; - e.disabled = !1, e.focus(), e.click(), e.disabled = n - } else e = document.createElement("input"), e.type = "submit", e.style.display = "none", t.appendChild(e), e.click(), t.removeChild(e) - } - - function s(t) { - t.disabled = !0 - } - - function f(t) { - t.disabled = !1 - } - - e.a = n; - var c = r(4), h = r(0), l = "data-direct-uploads-processing", d = !1 - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - r.d(e, "a", function () { - return s - }); - var i = r(5), a = r(0), u = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), o = "input[type=file][data-direct-upload-url]:not([disabled])", s = function () { - function t(e) { - n(this, t), this.form = e, this.inputs = Object(a.c)(e, o).filter(function (t) { - return t.files.length - }) - } - - return u(t, [{ - key: "start", value: function (t) { - var e = this, r = this.createDirectUploadControllers(); - this.dispatch("start"), function n() { - var i = r.shift(); - i ? i.start(function (r) { - r ? (t(r), e.dispatch("end")) : n() - }) : (t(), e.dispatch("end")) - }() - } - }, { - key: "createDirectUploadControllers", value: function () { - var t = []; - return this.inputs.forEach(function (e) { - Object(a.e)(e.files).forEach(function (r) { - var n = new i.a(e, r); - t.push(n) - }) - }), t - } - }, { - key: "dispatch", value: function (t) { - var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; - return Object(a.a)(this.form, "direct-uploads:" + t, {detail: e}) - } - }]), t - }() - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - r.d(e, "a", function () { - return o - }); - var i = r(1), a = r(0), u = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), o = function () { - function t(e, r) { - n(this, t), this.input = e, this.file = r, this.directUpload = new i.a(this.file, this.url, this), this.dispatch("initialize") - } - - return u(t, [{ - key: "start", value: function (t) { - var e = this, r = document.createElement("input"); - r.type = "hidden", r.name = this.input.name, this.input.insertAdjacentElement("beforebegin", r), this.dispatch("start"), this.directUpload.create(function (n, i) { - n ? (r.parentNode.removeChild(r), e.dispatchError(n)) : r.value = i.signed_id, e.dispatch("end"), t(n) - }) - } - }, { - key: "uploadRequestDidProgress", value: function (t) { - var e = t.loaded / t.total * 100; - e && this.dispatch("progress", {progress: e}) - } - }, { - key: "dispatch", value: function (t) { - var e = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {}; - return e.file = this.file, e.id = this.directUpload.id, Object(a.a)(this.input, "direct-upload:" + t, {detail: e}) - } - }, { - key: "dispatchError", value: function (t) { - this.dispatch("error", {error: t}).defaultPrevented || alert(t) - } - }, { - key: "directUploadWillCreateBlobWithXHR", value: function (t) { - this.dispatch("before-blob-request", {xhr: t}) - } - }, { - key: "directUploadWillStoreFileWithXHR", value: function (t) { - var e = this; - this.dispatch("before-storage-request", {xhr: t}), t.upload.addEventListener("progress", function (t) { - return e.uploadRequestDidProgress(t) - }) - } - }, { - key: "url", get: function () { - return this.input.getAttribute("data-direct-upload-url") - } - }]), t - }() - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - r.d(e, "a", function () { - return s - }); - var i = r(7), a = r.n(i), u = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), o = File.prototype.slice || File.prototype.mozSlice || File.prototype.webkitSlice, s = function () { - function t(e) { - n(this, t), this.file = e, this.chunkSize = 2097152, this.chunkCount = Math.ceil(this.file.size / this.chunkSize), this.chunkIndex = 0 - } - - return u(t, null, [{ - key: "create", value: function (e, r) { - new t(e).create(r) - } - }]), u(t, [{ - key: "create", value: function (t) { - var e = this; - this.callback = t, this.md5Buffer = new a.a.ArrayBuffer, this.fileReader = new FileReader, this.fileReader.addEventListener("load", function (t) { - return e.fileReaderDidLoad(t) - }), this.fileReader.addEventListener("error", function (t) { - return e.fileReaderDidError(t) - }), this.readNextChunk() - } - }, { - key: "fileReaderDidLoad", value: function (t) { - if (this.md5Buffer.append(t.target.result), !this.readNextChunk()) { - var e = this.md5Buffer.end(!0), r = btoa(e); - this.callback(null, r) - } - } - }, { - key: "fileReaderDidError", value: function (t) { - this.callback("Error reading " + this.file.name) - } - }, { - key: "readNextChunk", value: function () { - if (this.chunkIndex < this.chunkCount || 0 == this.chunkIndex && 0 == this.chunkCount) { - var t = this.chunkIndex * this.chunkSize, e = Math.min(t + this.chunkSize, this.file.size), - r = o.call(this.file, t, e); - return this.fileReader.readAsArrayBuffer(r), this.chunkIndex++, !0 - } - return !1 - } - }]), t - }() - }, function (t, e, r) { - !function (e) { - t.exports = e() - }(function (t) { - "use strict"; - - function e(t, e) { - var r = t[0], n = t[1], i = t[2], a = t[3]; - r += (n & i | ~n & a) + e[0] - 680876936 | 0, r = (r << 7 | r >>> 25) + n | 0, a += (r & n | ~r & i) + e[1] - 389564586 | 0, a = (a << 12 | a >>> 20) + r | 0, i += (a & r | ~a & n) + e[2] + 606105819 | 0, i = (i << 17 | i >>> 15) + a | 0, n += (i & a | ~i & r) + e[3] - 1044525330 | 0, n = (n << 22 | n >>> 10) + i | 0, r += (n & i | ~n & a) + e[4] - 176418897 | 0, r = (r << 7 | r >>> 25) + n | 0, a += (r & n | ~r & i) + e[5] + 1200080426 | 0, a = (a << 12 | a >>> 20) + r | 0, i += (a & r | ~a & n) + e[6] - 1473231341 | 0, i = (i << 17 | i >>> 15) + a | 0, n += (i & a | ~i & r) + e[7] - 45705983 | 0, n = (n << 22 | n >>> 10) + i | 0, r += (n & i | ~n & a) + e[8] + 1770035416 | 0, r = (r << 7 | r >>> 25) + n | 0, a += (r & n | ~r & i) + e[9] - 1958414417 | 0, a = (a << 12 | a >>> 20) + r | 0, i += (a & r | ~a & n) + e[10] - 42063 | 0, i = (i << 17 | i >>> 15) + a | 0, n += (i & a | ~i & r) + e[11] - 1990404162 | 0, n = (n << 22 | n >>> 10) + i | 0, r += (n & i | ~n & a) + e[12] + 1804603682 | 0, r = (r << 7 | r >>> 25) + n | 0, a += (r & n | ~r & i) + e[13] - 40341101 | 0, a = (a << 12 | a >>> 20) + r | 0, i += (a & r | ~a & n) + e[14] - 1502002290 | 0, i = (i << 17 | i >>> 15) + a | 0, n += (i & a | ~i & r) + e[15] + 1236535329 | 0, n = (n << 22 | n >>> 10) + i | 0, r += (n & a | i & ~a) + e[1] - 165796510 | 0, r = (r << 5 | r >>> 27) + n | 0, a += (r & i | n & ~i) + e[6] - 1069501632 | 0, a = (a << 9 | a >>> 23) + r | 0, i += (a & n | r & ~n) + e[11] + 643717713 | 0, i = (i << 14 | i >>> 18) + a | 0, n += (i & r | a & ~r) + e[0] - 373897302 | 0, n = (n << 20 | n >>> 12) + i | 0, r += (n & a | i & ~a) + e[5] - 701558691 | 0, r = (r << 5 | r >>> 27) + n | 0, a += (r & i | n & ~i) + e[10] + 38016083 | 0, a = (a << 9 | a >>> 23) + r | 0, i += (a & n | r & ~n) + e[15] - 660478335 | 0, i = (i << 14 | i >>> 18) + a | 0, n += (i & r | a & ~r) + e[4] - 405537848 | 0, n = (n << 20 | n >>> 12) + i | 0, r += (n & a | i & ~a) + e[9] + 568446438 | 0, r = (r << 5 | r >>> 27) + n | 0, a += (r & i | n & ~i) + e[14] - 1019803690 | 0, a = (a << 9 | a >>> 23) + r | 0, i += (a & n | r & ~n) + e[3] - 187363961 | 0, i = (i << 14 | i >>> 18) + a | 0, n += (i & r | a & ~r) + e[8] + 1163531501 | 0, n = (n << 20 | n >>> 12) + i | 0, r += (n & a | i & ~a) + e[13] - 1444681467 | 0, r = (r << 5 | r >>> 27) + n | 0, a += (r & i | n & ~i) + e[2] - 51403784 | 0, a = (a << 9 | a >>> 23) + r | 0, i += (a & n | r & ~n) + e[7] + 1735328473 | 0, i = (i << 14 | i >>> 18) + a | 0, n += (i & r | a & ~r) + e[12] - 1926607734 | 0, n = (n << 20 | n >>> 12) + i | 0, r += (n ^ i ^ a) + e[5] - 378558 | 0, r = (r << 4 | r >>> 28) + n | 0, a += (r ^ n ^ i) + e[8] - 2022574463 | 0, a = (a << 11 | a >>> 21) + r | 0, i += (a ^ r ^ n) + e[11] + 1839030562 | 0, i = (i << 16 | i >>> 16) + a | 0, n += (i ^ a ^ r) + e[14] - 35309556 | 0, n = (n << 23 | n >>> 9) + i | 0, r += (n ^ i ^ a) + e[1] - 1530992060 | 0, r = (r << 4 | r >>> 28) + n | 0, a += (r ^ n ^ i) + e[4] + 1272893353 | 0, a = (a << 11 | a >>> 21) + r | 0, i += (a ^ r ^ n) + e[7] - 155497632 | 0, i = (i << 16 | i >>> 16) + a | 0, n += (i ^ a ^ r) + e[10] - 1094730640 | 0, n = (n << 23 | n >>> 9) + i | 0, r += (n ^ i ^ a) + e[13] + 681279174 | 0, r = (r << 4 | r >>> 28) + n | 0, a += (r ^ n ^ i) + e[0] - 358537222 | 0, a = (a << 11 | a >>> 21) + r | 0, i += (a ^ r ^ n) + e[3] - 722521979 | 0, i = (i << 16 | i >>> 16) + a | 0, n += (i ^ a ^ r) + e[6] + 76029189 | 0, n = (n << 23 | n >>> 9) + i | 0, r += (n ^ i ^ a) + e[9] - 640364487 | 0, r = (r << 4 | r >>> 28) + n | 0, a += (r ^ n ^ i) + e[12] - 421815835 | 0, a = (a << 11 | a >>> 21) + r | 0, i += (a ^ r ^ n) + e[15] + 530742520 | 0, i = (i << 16 | i >>> 16) + a | 0, n += (i ^ a ^ r) + e[2] - 995338651 | 0, n = (n << 23 | n >>> 9) + i | 0, r += (i ^ (n | ~a)) + e[0] - 198630844 | 0, r = (r << 6 | r >>> 26) + n | 0, a += (n ^ (r | ~i)) + e[7] + 1126891415 | 0, a = (a << 10 | a >>> 22) + r | 0, i += (r ^ (a | ~n)) + e[14] - 1416354905 | 0,i = (i << 15 | i >>> 17) + a | 0,n += (a ^ (i | ~r)) + e[5] - 57434055 | 0,n = (n << 21 | n >>> 11) + i | 0,r += (i ^ (n | ~a)) + e[12] + 1700485571 | 0,r = (r << 6 | r >>> 26) + n | 0,a += (n ^ (r | ~i)) + e[3] - 1894986606 | 0,a = (a << 10 | a >>> 22) + r | 0,i += (r ^ (a | ~n)) + e[10] - 1051523 | 0,i = (i << 15 | i >>> 17) + a | 0,n += (a ^ (i | ~r)) + e[1] - 2054922799 | 0,n = (n << 21 | n >>> 11) + i | 0,r += (i ^ (n | ~a)) + e[8] + 1873313359 | 0,r = (r << 6 | r >>> 26) + n | 0,a += (n ^ (r | ~i)) + e[15] - 30611744 | 0,a = (a << 10 | a >>> 22) + r | 0,i += (r ^ (a | ~n)) + e[6] - 1560198380 | 0,i = (i << 15 | i >>> 17) + a | 0,n += (a ^ (i | ~r)) + e[13] + 1309151649 | 0,n = (n << 21 | n >>> 11) + i | 0,r += (i ^ (n | ~a)) + e[4] - 145523070 | 0,r = (r << 6 | r >>> 26) + n | 0,a += (n ^ (r | ~i)) + e[11] - 1120210379 | 0,a = (a << 10 | a >>> 22) + r | 0,i += (r ^ (a | ~n)) + e[2] + 718787259 | 0,i = (i << 15 | i >>> 17) + a | 0,n += (a ^ (i | ~r)) + e[9] - 343485551 | 0,n = (n << 21 | n >>> 11) + i | 0,t[0] = r + t[0] | 0,t[1] = n + t[1] | 0,t[2] = i + t[2] | 0,t[3] = a + t[3] | 0 - } - - function r(t) { - var e, r = []; - for (e = 0; e < 64; e += 4) r[e >> 2] = t.charCodeAt(e) + (t.charCodeAt(e + 1) << 8) + (t.charCodeAt(e + 2) << 16) + (t.charCodeAt(e + 3) << 24); - return r - } - - function n(t) { - var e, r = []; - for (e = 0; e < 64; e += 4) r[e >> 2] = t[e] + (t[e + 1] << 8) + (t[e + 2] << 16) + (t[e + 3] << 24); - return r - } - - function i(t) { - var n, i, a, u, o, s, f = t.length, c = [1732584193, -271733879, -1732584194, 271733878]; - for (n = 64; n <= f; n += 64) e(c, r(t.substring(n - 64, n))); - for (t = t.substring(n - 64), i = t.length, a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], n = 0; n < i; n += 1) a[n >> 2] |= t.charCodeAt(n) << (n % 4 << 3); - if (a[n >> 2] |= 128 << (n % 4 << 3), n > 55) for (e(c, a), n = 0; n < 16; n += 1) a[n] = 0; - return u = 8 * f, u = u.toString(16).match(/(.*?)(.{0,8})$/), o = parseInt(u[2], 16), s = parseInt(u[1], 16) || 0, a[14] = o, a[15] = s, e(c, a), c - } - - function a(t) { - var r, i, a, u, o, s, f = t.length, c = [1732584193, -271733879, -1732584194, 271733878]; - for (r = 64; r <= f; r += 64) e(c, n(t.subarray(r - 64, r))); - for (t = r - 64 < f ? t.subarray(r - 64) : new Uint8Array(0), i = t.length, a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], r = 0; r < i; r += 1) a[r >> 2] |= t[r] << (r % 4 << 3); - if (a[r >> 2] |= 128 << (r % 4 << 3), r > 55) for (e(c, a), r = 0; r < 16; r += 1) a[r] = 0; - return u = 8 * f, u = u.toString(16).match(/(.*?)(.{0,8})$/), o = parseInt(u[2], 16), s = parseInt(u[1], 16) || 0, a[14] = o, a[15] = s, e(c, a), c - } - - function u(t) { - var e, r = ""; - for (e = 0; e < 4; e += 1) r += p[t >> 8 * e + 4 & 15] + p[t >> 8 * e & 15]; - return r - } - - function o(t) { - var e; - for (e = 0; e < t.length; e += 1) t[e] = u(t[e]); - return t.join("") - } - - function s(t) { - return /[\u0080-\uFFFF]/.test(t) && (t = unescape(encodeURIComponent(t))), t - } - - function f(t, e) { - var r, n = t.length, i = new ArrayBuffer(n), a = new Uint8Array(i); - for (r = 0; r < n; r += 1) a[r] = t.charCodeAt(r); - return e ? a : i - } - - function c(t) { - return String.fromCharCode.apply(null, new Uint8Array(t)) - } - - function h(t, e, r) { - var n = new Uint8Array(t.byteLength + e.byteLength); - return n.set(new Uint8Array(t)), n.set(new Uint8Array(e), t.byteLength), r ? n : n.buffer - } - - function l(t) { - var e, r = [], n = t.length; - for (e = 0; e < n - 1; e += 2) r.push(parseInt(t.substr(e, 2), 16)); - return String.fromCharCode.apply(String, r) - } - - function d() { - this.reset() - } - - var p = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"]; - return "5d41402abc4b2a76b9719d911017c592" !== o(i("hello")) && function (t, e) { - var r = (65535 & t) + (65535 & e); - return (t >> 16) + (e >> 16) + (r >> 16) << 16 | 65535 & r - }, "undefined" == typeof ArrayBuffer || ArrayBuffer.prototype.slice || function () { - function e(t, e) { - return t = 0 | t || 0, t < 0 ? Math.max(t + e, 0) : Math.min(t, e) - } - - ArrayBuffer.prototype.slice = function (r, n) { - var i, a, u, o, s = this.byteLength, f = e(r, s), c = s; - return n !== t && (c = e(n, s)), f > c ? new ArrayBuffer(0) : (i = c - f, a = new ArrayBuffer(i), u = new Uint8Array(a), o = new Uint8Array(this, f, i), u.set(o), a) - } - }(), d.prototype.append = function (t) { - return this.appendBinary(s(t)), this - }, d.prototype.appendBinary = function (t) { - this._buff += t, this._length += t.length; - var n, i = this._buff.length; - for (n = 64; n <= i; n += 64) e(this._hash, r(this._buff.substring(n - 64, n))); - return this._buff = this._buff.substring(n - 64), this - }, d.prototype.end = function (t) { - var e, r, n = this._buff, i = n.length, a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (e = 0; e < i; e += 1) a[e >> 2] |= n.charCodeAt(e) << (e % 4 << 3); - return this._finish(a, i), r = o(this._hash), t && (r = l(r)), this.reset(), r - }, d.prototype.reset = function () { - return this._buff = "", this._length = 0, this._hash = [1732584193, -271733879, -1732584194, 271733878], this - }, d.prototype.getState = function () { - return {buff: this._buff, length: this._length, hash: this._hash} - }, d.prototype.setState = function (t) { - return this._buff = t.buff, this._length = t.length, this._hash = t.hash, this - }, d.prototype.destroy = function () { - delete this._hash, delete this._buff, delete this._length - }, d.prototype._finish = function (t, r) { - var n, i, a, u = r; - if (t[u >> 2] |= 128 << (u % 4 << 3), u > 55) for (e(this._hash, t), u = 0; u < 16; u += 1) t[u] = 0; - n = 8 * this._length, n = n.toString(16).match(/(.*?)(.{0,8})$/), i = parseInt(n[2], 16), a = parseInt(n[1], 16) || 0, t[14] = i, t[15] = a, e(this._hash, t) - }, d.hash = function (t, e) { - return d.hashBinary(s(t), e) - }, d.hashBinary = function (t, e) { - var r = i(t), n = o(r); - return e ? l(n) : n - }, d.ArrayBuffer = function () { - this.reset() - }, d.ArrayBuffer.prototype.append = function (t) { - var r, i = h(this._buff.buffer, t, !0), a = i.length; - for (this._length += t.byteLength, r = 64; r <= a; r += 64) e(this._hash, n(i.subarray(r - 64, r))); - return this._buff = r - 64 < a ? new Uint8Array(i.buffer.slice(r - 64)) : new Uint8Array(0), this - }, d.ArrayBuffer.prototype.end = function (t) { - var e, r, n = this._buff, i = n.length, a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; - for (e = 0; e < i; e += 1) a[e >> 2] |= n[e] << (e % 4 << 3); - return this._finish(a, i), r = o(this._hash), t && (r = l(r)), this.reset(), r - }, d.ArrayBuffer.prototype.reset = function () { - return this._buff = new Uint8Array(0), this._length = 0, this._hash = [1732584193, -271733879, -1732584194, 271733878], this - }, d.ArrayBuffer.prototype.getState = function () { - var t = d.prototype.getState.call(this); - return t.buff = c(t.buff), t - }, d.ArrayBuffer.prototype.setState = function (t) { - return t.buff = f(t.buff, !0), d.prototype.setState.call(this, t) - }, d.ArrayBuffer.prototype.destroy = d.prototype.destroy, d.ArrayBuffer.prototype._finish = d.prototype._finish, d.ArrayBuffer.hash = function (t, e) { - var r = a(new Uint8Array(t)), n = o(r); - return e ? l(n) : n - }, d - }) - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - r.d(e, "a", function () { - return u - }); - var i = r(0), a = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), u = function () { - function t(e, r, a) { - var u = this; - n(this, t), this.file = e, this.attributes = { - filename: e.name, - content_type: e.type, - byte_size: e.size, - checksum: r - }, this.xhr = new XMLHttpRequest, this.xhr.open("POST", a, !0), this.xhr.responseType = "json", this.xhr.setRequestHeader("Content-Type", "application/json"), this.xhr.setRequestHeader("Accept", "application/json"), this.xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest"), this.xhr.setRequestHeader("X-CSRF-Token", Object(i.d)("csrf-token")), this.xhr.addEventListener("load", function (t) { - return u.requestDidLoad(t) - }), this.xhr.addEventListener("error", function (t) { - return u.requestDidError(t) - }) - } - - return a(t, [{ - key: "create", value: function (t) { - this.callback = t, this.xhr.send(JSON.stringify({blob: this.attributes})) - } - }, { - key: "requestDidLoad", value: function (t) { - if (this.status >= 200 && this.status < 300) { - var e = this.response, r = e.direct_upload; - delete e.direct_upload, this.attributes = e, this.directUploadData = r, this.callback(null, this.toJSON()) - } else this.requestDidError(t) - } - }, { - key: "requestDidError", value: function (t) { - this.callback('Error creating Blob for "' + this.file.name + '". Status: ' + this.status) - } - }, { - key: "toJSON", value: function () { - var t = {}; - for (var e in this.attributes) t[e] = this.attributes[e]; - return t - } - }, { - key: "status", get: function () { - return this.xhr.status - } - }, { - key: "response", get: function () { - var t = this.xhr, e = t.responseType, r = t.response; - return "json" == e ? r : JSON.parse(r) - } - }]), t - }() - }, function (t, e, r) { - "use strict"; - - function n(t, e) { - if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function") - } - - r.d(e, "a", function () { - return a - }); - var i = function () { - function t(t, e) { - for (var r = 0; r < e.length; r++) { - var n = e[r]; - n.enumerable = n.enumerable || !1, n.configurable = !0, "value" in n && (n.writable = !0), Object.defineProperty(t, n.key, n) - } - } - - return function (e, r, n) { - return r && t(e.prototype, r), n && t(e, n), e - } - }(), a = function () { - function t(e) { - var r = this; - n(this, t), this.blob = e, this.file = e.file; - var i = e.directUploadData, a = i.url, u = i.headers; - this.xhr = new XMLHttpRequest, this.xhr.open("PUT", a, !0), this.xhr.responseType = "text"; - for (var o in u) this.xhr.setRequestHeader(o, u[o]); - this.xhr.addEventListener("load", function (t) { - return r.requestDidLoad(t) - }), this.xhr.addEventListener("error", function (t) { - return r.requestDidError(t) - }) - } - - return i(t, [{ - key: "create", value: function (t) { - this.callback = t, this.xhr.send(this.file.slice()) - } - }, { - key: "requestDidLoad", value: function (t) { - var e = this.xhr, r = e.status, n = e.response; - r >= 200 && r < 300 ? this.callback(null, n) : this.requestDidError(t) - } - }, { - key: "requestDidError", value: function (t) { - this.callback('Error storing "' + this.file.name + '". Status: ' + this.xhr.status) - } - }]), t - }() - }]) -}); -/* -Turbolinks 5.2.0 -Copyright © 2018 Basecamp, LLC - */ - -(function () { - var t = this; - (function () { - (function () { - this.Turbolinks = { - supported: function () { - return null != window.history.pushState && null != window.requestAnimationFrame && null != window.addEventListener - }(), visit: function (t, r) { - return e.controller.visit(t, r) - }, clearCache: function () { - return e.controller.clearCache() - }, setProgressBarDelay: function (t) { - return e.controller.setProgressBarDelay(t) - } - } - }).call(this) - }).call(t); - var e = t.Turbolinks; - (function () { - (function () { - var t, r, n, o = [].slice; - e.copyObject = function (t) { - var e, r, n; - r = {}; - for (e in t) n = t[e], r[e] = n; - return r - }, e.closest = function (e, r) { - return t.call(e, r) - }, t = function () { - var t, e; - return t = document.documentElement, null != (e = t.closest) ? e : function (t) { - var e; - for (e = this; e;) { - if (e.nodeType === Node.ELEMENT_NODE && r.call(e, t)) return e; - e = e.parentNode - } - } - }(), e.defer = function (t) { - return setTimeout(t, 1) - }, e.throttle = function (t) { - var e; - return e = null, function () { - var r; - return r = 1 <= arguments.length ? o.call(arguments, 0) : [], null != e ? e : e = requestAnimationFrame(function (n) { - return function () { - return e = null, t.apply(n, r) - } - }(this)) - } - }, e.dispatch = function (t, e) { - var r, o, i, s, a, u; - return a = null != e ? e : {}, u = a.target, r = a.cancelable, o = a.data, i = document.createEvent("Events"), i.initEvent(t, !0, r === !0), i.data = null != o ? o : {}, i.cancelable && !n && (s = i.preventDefault, i.preventDefault = function () { - return this.defaultPrevented || Object.defineProperty(this, "defaultPrevented", { - get: function () { - return !0 - } - }), s.call(this) - }), (null != u ? u : document).dispatchEvent(i), i - }, n = function () { - var t; - return t = document.createEvent("Events"), t.initEvent("test", !0, !0), t.preventDefault(), t.defaultPrevented - }(), e.match = function (t, e) { - return r.call(t, e) - }, r = function () { - var t, e, r, n; - return t = document.documentElement, null != (e = null != (r = null != (n = t.matchesSelector) ? n : t.webkitMatchesSelector) ? r : t.msMatchesSelector) ? e : t.mozMatchesSelector - }(), e.uuid = function () { - var t, e, r; - for (r = "", t = e = 1; 36 >= e; t = ++e) r += 9 === t || 14 === t || 19 === t || 24 === t ? "-" : 15 === t ? "4" : 20 === t ? (Math.floor(4 * Math.random()) + 8).toString(16) : Math.floor(15 * Math.random()).toString(16); - return r - } - }).call(this), function () { - e.Location = function () { - function t(t) { - var e, r; - null == t && (t = ""), r = document.createElement("a"), r.href = t.toString(), this.absoluteURL = r.href, e = r.hash.length, 2 > e ? this.requestURL = this.absoluteURL : (this.requestURL = this.absoluteURL.slice(0, -e), this.anchor = r.hash.slice(1)) - } - - var e, r, n, o; - return t.wrap = function (t) { - return t instanceof this ? t : new this(t) - }, t.prototype.getOrigin = function () { - return this.absoluteURL.split("/", 3).join("/") - }, t.prototype.getPath = function () { - var t, e; - return null != (t = null != (e = this.requestURL.match(/\/\/[^\/]*(\/[^?;]*)/)) ? e[1] : void 0) ? t : "/" - }, t.prototype.getPathComponents = function () { - return this.getPath().split("/").slice(1) - }, t.prototype.getLastPathComponent = function () { - return this.getPathComponents().slice(-1)[0] - }, t.prototype.getExtension = function () { - var t, e; - return null != (t = null != (e = this.getLastPathComponent().match(/\.[^.]*$/)) ? e[0] : void 0) ? t : "" - }, t.prototype.isHTML = function () { - return this.getExtension().match(/^(?:|\.(?:htm|html|xhtml))$/) - }, t.prototype.isPrefixedBy = function (t) { - var e; - return e = r(t), this.isEqualTo(t) || o(this.absoluteURL, e) - }, t.prototype.isEqualTo = function (t) { - return this.absoluteURL === (null != t ? t.absoluteURL : void 0) - }, t.prototype.toCacheKey = function () { - return this.requestURL - }, t.prototype.toJSON = function () { - return this.absoluteURL - }, t.prototype.toString = function () { - return this.absoluteURL - }, t.prototype.valueOf = function () { - return this.absoluteURL - }, r = function (t) { - return e(t.getOrigin() + t.getPath()) - }, e = function (t) { - return n(t, "/") ? t : t + "/" - }, o = function (t, e) { - return t.slice(0, e.length) === e - }, n = function (t, e) { - return t.slice(-e.length) === e - }, t - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.HttpRequest = function () { - function r(r, n, o) { - this.delegate = r, this.requestCanceled = t(this.requestCanceled, this), this.requestTimedOut = t(this.requestTimedOut, this), this.requestFailed = t(this.requestFailed, this), this.requestLoaded = t(this.requestLoaded, this), this.requestProgressed = t(this.requestProgressed, this), this.url = e.Location.wrap(n).requestURL, this.referrer = e.Location.wrap(o).absoluteURL, this.createXHR() - } - - return r.NETWORK_FAILURE = 0, r.TIMEOUT_FAILURE = -1, r.timeout = 60, r.prototype.send = function () { - var t; - return this.xhr && !this.sent ? (this.notifyApplicationBeforeRequestStart(), this.setProgress(0), this.xhr.send(), this.sent = !0, "function" == typeof (t = this.delegate).requestStarted ? t.requestStarted() : void 0) : void 0 - }, r.prototype.cancel = function () { - return this.xhr && this.sent ? this.xhr.abort() : void 0 - }, r.prototype.requestProgressed = function (t) { - return t.lengthComputable ? this.setProgress(t.loaded / t.total) : void 0 - }, r.prototype.requestLoaded = function () { - return this.endRequest(function (t) { - return function () { - var e; - return 200 <= (e = t.xhr.status) && 300 > e ? t.delegate.requestCompletedWithResponse(t.xhr.responseText, t.xhr.getResponseHeader("Turbolinks-Location")) : (t.failed = !0, t.delegate.requestFailedWithStatusCode(t.xhr.status, t.xhr.responseText)) - } - }(this)) - }, r.prototype.requestFailed = function () { - return this.endRequest(function (t) { - return function () { - return t.failed = !0, t.delegate.requestFailedWithStatusCode(t.constructor.NETWORK_FAILURE) - } - }(this)) - }, r.prototype.requestTimedOut = function () { - return this.endRequest(function (t) { - return function () { - return t.failed = !0, t.delegate.requestFailedWithStatusCode(t.constructor.TIMEOUT_FAILURE) - } - }(this)) - }, r.prototype.requestCanceled = function () { - return this.endRequest() - }, r.prototype.notifyApplicationBeforeRequestStart = function () { - return e.dispatch("turbolinks:request-start", {data: {url: this.url, xhr: this.xhr}}) - }, r.prototype.notifyApplicationAfterRequestEnd = function () { - return e.dispatch("turbolinks:request-end", {data: {url: this.url, xhr: this.xhr}}) - }, r.prototype.createXHR = function () { - return this.xhr = new XMLHttpRequest, this.xhr.open("GET", this.url, !0), this.xhr.timeout = 1e3 * this.constructor.timeout, this.xhr.setRequestHeader("Accept", "text/html, application/xhtml+xml"), this.xhr.setRequestHeader("Turbolinks-Referrer", this.referrer), this.xhr.onprogress = this.requestProgressed, this.xhr.onload = this.requestLoaded, this.xhr.onerror = this.requestFailed, this.xhr.ontimeout = this.requestTimedOut, this.xhr.onabort = this.requestCanceled - }, r.prototype.endRequest = function (t) { - return this.xhr ? (this.notifyApplicationAfterRequestEnd(), null != t && t.call(this), this.destroy()) : void 0 - }, r.prototype.setProgress = function (t) { - var e; - return this.progress = t, "function" == typeof (e = this.delegate).requestProgressed ? e.requestProgressed(this.progress) : void 0 - }, r.prototype.destroy = function () { - var t; - return this.setProgress(1), "function" == typeof (t = this.delegate).requestFinished && t.requestFinished(), this.delegate = null, this.xhr = null - }, r - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.ProgressBar = function () { - function e() { - this.trickle = t(this.trickle, this), this.stylesheetElement = this.createStylesheetElement(), this.progressElement = this.createProgressElement() - } - - var r; - return r = 300, e.defaultCSS = ".turbolinks-progress-bar {\n position: fixed;\n display: block;\n top: 0;\n left: 0;\n height: 3px;\n background: #0076ff;\n z-index: 9999;\n transition: width " + r + "ms ease-out, opacity " + r / 2 + "ms " + r / 2 + "ms ease-in;\n transform: translate3d(0, 0, 0);\n}", e.prototype.show = function () { - return this.visible ? void 0 : (this.visible = !0, this.installStylesheetElement(), this.installProgressElement(), this.startTrickling()) - }, e.prototype.hide = function () { - return this.visible && !this.hiding ? (this.hiding = !0, this.fadeProgressElement(function (t) { - return function () { - return t.uninstallProgressElement(), t.stopTrickling(), t.visible = !1, t.hiding = !1 - } - }(this))) : void 0 - }, e.prototype.setValue = function (t) { - return this.value = t, this.refresh() - }, e.prototype.installStylesheetElement = function () { - return document.head.insertBefore(this.stylesheetElement, document.head.firstChild) - }, e.prototype.installProgressElement = function () { - return this.progressElement.style.width = 0, this.progressElement.style.opacity = 1, document.documentElement.insertBefore(this.progressElement, document.body), this.refresh() - }, e.prototype.fadeProgressElement = function (t) { - return this.progressElement.style.opacity = 0, setTimeout(t, 1.5 * r) - }, e.prototype.uninstallProgressElement = function () { - return this.progressElement.parentNode ? document.documentElement.removeChild(this.progressElement) : void 0 - }, e.prototype.startTrickling = function () { - return null != this.trickleInterval ? this.trickleInterval : this.trickleInterval = setInterval(this.trickle, r) - }, e.prototype.stopTrickling = function () { - return clearInterval(this.trickleInterval), this.trickleInterval = null - }, e.prototype.trickle = function () { - return this.setValue(this.value + Math.random() / 100) - }, e.prototype.refresh = function () { - return requestAnimationFrame(function (t) { - return function () { - return t.progressElement.style.width = 10 + 90 * t.value + "%" - } - }(this)) - }, e.prototype.createStylesheetElement = function () { - var t; - return t = document.createElement("style"), t.type = "text/css", t.textContent = this.constructor.defaultCSS, t - }, e.prototype.createProgressElement = function () { - var t; - return t = document.createElement("div"), t.className = "turbolinks-progress-bar", t - }, e - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.BrowserAdapter = function () { - function r(r) { - this.controller = r, this.showProgressBar = t(this.showProgressBar, this), this.progressBar = new e.ProgressBar - } - - var n, o, i; - return i = e.HttpRequest, n = i.NETWORK_FAILURE, o = i.TIMEOUT_FAILURE, r.prototype.visitProposedToLocationWithAction = function (t, e) { - return this.controller.startVisitToLocationWithAction(t, e) - }, r.prototype.visitStarted = function (t) { - return t.issueRequest(), t.changeHistory(), t.loadCachedSnapshot() - }, r.prototype.visitRequestStarted = function (t) { - return this.progressBar.setValue(0), t.hasCachedSnapshot() || "restore" !== t.action ? this.showProgressBarAfterDelay() : this.showProgressBar() - }, r.prototype.visitRequestProgressed = function (t) { - return this.progressBar.setValue(t.progress) - }, r.prototype.visitRequestCompleted = function (t) { - return t.loadResponse() - }, r.prototype.visitRequestFailedWithStatusCode = function (t, e) { - switch (e) { - case n: - case o: - return this.reload(); - default: - return t.loadResponse() - } - }, r.prototype.visitRequestFinished = function (t) { - return this.hideProgressBar() - }, r.prototype.visitCompleted = function (t) { - return t.followRedirect() - }, r.prototype.pageInvalidated = function () { - return this.reload() - }, r.prototype.showProgressBarAfterDelay = function () { - return this.progressBarTimeout = setTimeout(this.showProgressBar, this.controller.progressBarDelay) - }, r.prototype.showProgressBar = function () { - return this.progressBar.show() - }, r.prototype.hideProgressBar = function () { - return this.progressBar.hide(), clearTimeout(this.progressBarTimeout) - }, r.prototype.reload = function () { - return window.location.reload() - }, r - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.History = function () { - function r(e) { - this.delegate = e, this.onPageLoad = t(this.onPageLoad, this), this.onPopState = t(this.onPopState, this) - } - - return r.prototype.start = function () { - return this.started ? void 0 : (addEventListener("popstate", this.onPopState, !1), addEventListener("load", this.onPageLoad, !1), this.started = !0) - }, r.prototype.stop = function () { - return this.started ? (removeEventListener("popstate", this.onPopState, !1), removeEventListener("load", this.onPageLoad, !1), this.started = !1) : void 0 - }, r.prototype.push = function (t, r) { - return t = e.Location.wrap(t), this.update("push", t, r) - }, r.prototype.replace = function (t, r) { - return t = e.Location.wrap(t), this.update("replace", t, r) - }, r.prototype.onPopState = function (t) { - var r, n, o, i; - return this.shouldHandlePopState() && (i = null != (n = t.state) ? n.turbolinks : void 0) ? (r = e.Location.wrap(window.location), o = i.restorationIdentifier, this.delegate.historyPoppedToLocationWithRestorationIdentifier(r, o)) : void 0 - }, r.prototype.onPageLoad = function (t) { - return e.defer(function (t) { - return function () { - return t.pageLoaded = !0 - } - }(this)) - }, r.prototype.shouldHandlePopState = function () { - return this.pageIsLoaded() - }, r.prototype.pageIsLoaded = function () { - return this.pageLoaded || "complete" === document.readyState - }, r.prototype.update = function (t, e, r) { - var n; - return n = {turbolinks: {restorationIdentifier: r}}, history[t + "State"](n, null, e) - }, r - }() - }.call(this), function () { - e.HeadDetails = function () { - function t(t) { - var e, r, n, s, a, u; - for (this.elements = {}, n = 0, a = t.length; a > n; n++) u = t[n], u.nodeType === Node.ELEMENT_NODE && (s = u.outerHTML, r = null != (e = this.elements)[s] ? e[s] : e[s] = { - type: i(u), - tracked: o(u), - elements: [] - }, r.elements.push(u)) - } - - var e, r, n, o, i; - return t.fromHeadElement = function (t) { - var e; - return new this(null != (e = null != t ? t.childNodes : void 0) ? e : []) - }, t.prototype.hasElementWithKey = function (t) { - return t in this.elements - }, t.prototype.getTrackedElementSignature = function () { - var t, e; - return function () { - var r, n; - r = this.elements, n = []; - for (t in r) e = r[t].tracked, e && n.push(t); - return n - }.call(this).join("") - }, t.prototype.getScriptElementsNotInDetails = function (t) { - return this.getElementsMatchingTypeNotInDetails("script", t) - }, t.prototype.getStylesheetElementsNotInDetails = function (t) { - return this.getElementsMatchingTypeNotInDetails("stylesheet", t) - }, t.prototype.getElementsMatchingTypeNotInDetails = function (t, e) { - var r, n, o, i, s, a; - o = this.elements, s = []; - for (n in o) i = o[n], a = i.type, r = i.elements, a !== t || e.hasElementWithKey(n) || s.push(r[0]); - return s - }, t.prototype.getProvisionalElements = function () { - var t, e, r, n, o, i, s; - r = [], n = this.elements; - for (e in n) o = n[e], s = o.type, i = o.tracked, t = o.elements, null != s || i ? t.length > 1 && r.push.apply(r, t.slice(1)) : r.push.apply(r, t); - return r - }, t.prototype.getMetaValue = function (t) { - var e; - return null != (e = this.findMetaElementByName(t)) ? e.getAttribute("content") : void 0 - }, t.prototype.findMetaElementByName = function (t) { - var r, n, o, i; - r = void 0, i = this.elements; - for (o in i) n = i[o].elements, e(n[0], t) && (r = n[0]); - return r - }, i = function (t) { - return r(t) ? "script" : n(t) ? "stylesheet" : void 0 - }, o = function (t) { - return "reload" === t.getAttribute("data-turbolinks-track") - }, r = function (t) { - var e; - return e = t.tagName.toLowerCase(), "script" === e - }, n = function (t) { - var e; - return e = t.tagName.toLowerCase(), "style" === e || "link" === e && "stylesheet" === t.getAttribute("rel") - }, e = function (t, e) { - var r; - return r = t.tagName.toLowerCase(), "meta" === r && t.getAttribute("name") === e - }, t - }() - }.call(this), function () { - e.Snapshot = function () { - function t(t, e) { - this.headDetails = t, this.bodyElement = e - } - - return t.wrap = function (t) { - return t instanceof this ? t : "string" == typeof t ? this.fromHTMLString(t) : this.fromHTMLElement(t) - }, t.fromHTMLString = function (t) { - var e; - return e = document.createElement("html"), e.innerHTML = t, this.fromHTMLElement(e) - }, t.fromHTMLElement = function (t) { - var r, n, o, i; - return o = t.querySelector("head"), r = null != (i = t.querySelector("body")) ? i : document.createElement("body"), n = e.HeadDetails.fromHeadElement(o), new this(n, r) - }, t.prototype.clone = function () { - return new this.constructor(this.headDetails, this.bodyElement.cloneNode(!0)) - }, t.prototype.getRootLocation = function () { - var t, r; - return r = null != (t = this.getSetting("root")) ? t : "/", new e.Location(r) - }, t.prototype.getCacheControlValue = function () { - return this.getSetting("cache-control") - }, t.prototype.getElementForAnchor = function (t) { - try { - return this.bodyElement.querySelector("[id='" + t + "'], a[name='" + t + "']") - } catch (e) { - } - }, t.prototype.getPermanentElements = function () { - return this.bodyElement.querySelectorAll("[id][data-turbolinks-permanent]") - }, t.prototype.getPermanentElementById = function (t) { - return this.bodyElement.querySelector("#" + t + "[data-turbolinks-permanent]") - }, t.prototype.getPermanentElementsPresentInSnapshot = function (t) { - var e, r, n, o, i; - for (o = this.getPermanentElements(), i = [], r = 0, n = o.length; n > r; r++) e = o[r], t.getPermanentElementById(e.id) && i.push(e); - return i - }, t.prototype.findFirstAutofocusableElement = function () { - return this.bodyElement.querySelector("[autofocus]") - }, t.prototype.hasAnchor = function (t) { - return null != this.getElementForAnchor(t) - }, t.prototype.isPreviewable = function () { - return "no-preview" !== this.getCacheControlValue() - }, t.prototype.isCacheable = function () { - return "no-cache" !== this.getCacheControlValue() - }, t.prototype.isVisitable = function () { - return "reload" !== this.getSetting("visit-control") - }, t.prototype.getSetting = function (t) { - return this.headDetails.getMetaValue("turbolinks-" + t) - }, t - }() - }.call(this), function () { - var t = [].slice; - e.Renderer = function () { - function e() { - } - - var r; - return e.render = function () { - var e, r, n, o; - return n = arguments[0], r = arguments[1], e = 3 <= arguments.length ? t.call(arguments, 2) : [], o = function (t, e, r) { - r.prototype = t.prototype; - var n = new r, o = t.apply(n, e); - return Object(o) === o ? o : n - }(this, e, function () { - }), o.delegate = n, o.render(r), o - }, e.prototype.renderView = function (t) { - return this.delegate.viewWillRender(this.newBody), t(), this.delegate.viewRendered(this.newBody) - }, e.prototype.invalidateView = function () { - return this.delegate.viewInvalidated() - }, e.prototype.createScriptElement = function (t) { - var e; - return "false" === t.getAttribute("data-turbolinks-eval") ? t : (e = document.createElement("script"), e.textContent = t.textContent, e.async = !1, r(e, t), e) - }, r = function (t, e) { - var r, n, o, i, s, a, u; - for (i = e.attributes, a = [], r = 0, n = i.length; n > r; r++) s = i[r], o = s.name, u = s.value, a.push(t.setAttribute(o, u)); - return a - }, e - }() - }.call(this), function () { - var t, r, n = function (t, e) { - function r() { - this.constructor = t - } - - for (var n in e) o.call(e, n) && (t[n] = e[n]); - return r.prototype = e.prototype, t.prototype = new r, t.__super__ = e.prototype, t - }, o = {}.hasOwnProperty; - e.SnapshotRenderer = function (e) { - function o(t, e, r) { - this.currentSnapshot = t, this.newSnapshot = e, this.isPreview = r, this.currentHeadDetails = this.currentSnapshot.headDetails, this.newHeadDetails = this.newSnapshot.headDetails, this.currentBody = this.currentSnapshot.bodyElement, this.newBody = this.newSnapshot.bodyElement - } - - return n(o, e), o.prototype.render = function (t) { - return this.shouldRender() ? (this.mergeHead(), this.renderView(function (e) { - return function () { - return e.replaceBody(), e.isPreview || e.focusFirstAutofocusableElement(), t() - } - }(this))) : this.invalidateView() - }, o.prototype.mergeHead = function () { - return this.copyNewHeadStylesheetElements(), this.copyNewHeadScriptElements(), this.removeCurrentHeadProvisionalElements(), this.copyNewHeadProvisionalElements() - }, o.prototype.replaceBody = function () { - var t; - return t = this.relocateCurrentBodyPermanentElements(), this.activateNewBodyScriptElements(), this.assignNewBody(), this.replacePlaceholderElementsWithClonedPermanentElements(t) - }, o.prototype.shouldRender = function () { - return this.newSnapshot.isVisitable() && this.trackedElementsAreIdentical() - }, o.prototype.trackedElementsAreIdentical = function () { - return this.currentHeadDetails.getTrackedElementSignature() === this.newHeadDetails.getTrackedElementSignature() - }, o.prototype.copyNewHeadStylesheetElements = function () { - var t, e, r, n, o; - for (n = this.getNewHeadStylesheetElements(), o = [], e = 0, r = n.length; r > e; e++) t = n[e], o.push(document.head.appendChild(t)); - return o - }, o.prototype.copyNewHeadScriptElements = function () { - var t, e, r, n, o; - for (n = this.getNewHeadScriptElements(), o = [], e = 0, r = n.length; r > e; e++) t = n[e], o.push(document.head.appendChild(this.createScriptElement(t))); - return o - }, o.prototype.removeCurrentHeadProvisionalElements = function () { - var t, e, r, n, o; - for (n = this.getCurrentHeadProvisionalElements(), o = [], e = 0, r = n.length; r > e; e++) t = n[e], o.push(document.head.removeChild(t)); - return o - }, o.prototype.copyNewHeadProvisionalElements = function () { - var t, e, r, n, o; - for (n = this.getNewHeadProvisionalElements(), o = [], e = 0, r = n.length; r > e; e++) t = n[e], o.push(document.head.appendChild(t)); - return o - }, o.prototype.relocateCurrentBodyPermanentElements = function () { - var e, n, o, i, s, a, u; - for (a = this.getCurrentBodyPermanentElements(), u = [], e = 0, n = a.length; n > e; e++) i = a[e], s = t(i), o = this.newSnapshot.getPermanentElementById(i.id), r(i, s.element), r(o, i), u.push(s); - return u - }, o.prototype.replacePlaceholderElementsWithClonedPermanentElements = function (t) { - var e, n, o, i, s, a, u; - for (u = [], o = 0, i = t.length; i > o; o++) a = t[o], n = a.element, s = a.permanentElement, e = s.cloneNode(!0), u.push(r(n, e)); - return u - }, o.prototype.activateNewBodyScriptElements = function () { - var t, e, n, o, i, s; - for (i = this.getNewBodyScriptElements(), s = [], e = 0, o = i.length; o > e; e++) n = i[e], t = this.createScriptElement(n), s.push(r(n, t)); - return s - }, o.prototype.assignNewBody = function () { - return document.body = this.newBody - }, o.prototype.focusFirstAutofocusableElement = function () { - var t; - return null != (t = this.newSnapshot.findFirstAutofocusableElement()) ? t.focus() : void 0 - }, o.prototype.getNewHeadStylesheetElements = function () { - return this.newHeadDetails.getStylesheetElementsNotInDetails(this.currentHeadDetails) - }, o.prototype.getNewHeadScriptElements = function () { - return this.newHeadDetails.getScriptElementsNotInDetails(this.currentHeadDetails) - }, o.prototype.getCurrentHeadProvisionalElements = function () { - return this.currentHeadDetails.getProvisionalElements() - }, o.prototype.getNewHeadProvisionalElements = function () { - return this.newHeadDetails.getProvisionalElements() - }, o.prototype.getCurrentBodyPermanentElements = function () { - return this.currentSnapshot.getPermanentElementsPresentInSnapshot(this.newSnapshot) - }, o.prototype.getNewBodyScriptElements = function () { - return this.newBody.querySelectorAll("script") - }, o - }(e.Renderer), t = function (t) { - var e; - return e = document.createElement("meta"), e.setAttribute("name", "turbolinks-permanent-placeholder"), e.setAttribute("content", t.id), { - element: e, - permanentElement: t - } - }, r = function (t, e) { - var r; - return (r = t.parentNode) ? r.replaceChild(e, t) : void 0 - } - }.call(this), function () { - var t = function (t, e) { - function n() { - this.constructor = t - } - - for (var o in e) r.call(e, o) && (t[o] = e[o]); - return n.prototype = e.prototype, t.prototype = new n, t.__super__ = e.prototype, t - }, r = {}.hasOwnProperty; - e.ErrorRenderer = function (e) { - function r(t) { - var e; - e = document.createElement("html"), e.innerHTML = t, this.newHead = e.querySelector("head"), this.newBody = e.querySelector("body") - } - - return t(r, e), r.prototype.render = function (t) { - return this.renderView(function (e) { - return function () { - return e.replaceHeadAndBody(), e.activateBodyScriptElements(), t() - } - }(this)) - }, r.prototype.replaceHeadAndBody = function () { - var t, e; - return e = document.head, t = document.body, e.parentNode.replaceChild(this.newHead, e), t.parentNode.replaceChild(this.newBody, t) - }, r.prototype.activateBodyScriptElements = function () { - var t, e, r, n, o, i; - for (n = this.getScriptElements(), i = [], e = 0, r = n.length; r > e; e++) o = n[e], t = this.createScriptElement(o), i.push(o.parentNode.replaceChild(t, o)); - return i - }, r.prototype.getScriptElements = function () { - return document.documentElement.querySelectorAll("script") - }, r - }(e.Renderer) - }.call(this), function () { - e.View = function () { - function t(t) { - this.delegate = t, this.htmlElement = document.documentElement - } - - return t.prototype.getRootLocation = function () { - return this.getSnapshot().getRootLocation() - }, t.prototype.getElementForAnchor = function (t) { - return this.getSnapshot().getElementForAnchor(t) - }, t.prototype.getSnapshot = function () { - return e.Snapshot.fromHTMLElement(this.htmlElement) - }, t.prototype.render = function (t, e) { - var r, n, o; - return o = t.snapshot, r = t.error, n = t.isPreview, this.markAsPreview(n), null != o ? this.renderSnapshot(o, n, e) : this.renderError(r, e) - }, t.prototype.markAsPreview = function (t) { - return t ? this.htmlElement.setAttribute("data-turbolinks-preview", "") : this.htmlElement.removeAttribute("data-turbolinks-preview") - }, t.prototype.renderSnapshot = function (t, r, n) { - return e.SnapshotRenderer.render(this.delegate, n, this.getSnapshot(), e.Snapshot.wrap(t), r) - }, t.prototype.renderError = function (t, r) { - return e.ErrorRenderer.render(this.delegate, r, t) - }, t - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.ScrollManager = function () { - function r(r) { - this.delegate = r, this.onScroll = t(this.onScroll, this), this.onScroll = e.throttle(this.onScroll) - } - - return r.prototype.start = function () { - return this.started ? void 0 : (addEventListener("scroll", this.onScroll, !1), this.onScroll(), this.started = !0) - }, r.prototype.stop = function () { - return this.started ? (removeEventListener("scroll", this.onScroll, !1), this.started = !1) : void 0 - }, r.prototype.scrollToElement = function (t) { - return t.scrollIntoView() - }, r.prototype.scrollToPosition = function (t) { - var e, r; - return e = t.x, r = t.y, window.scrollTo(e, r) - }, r.prototype.onScroll = function (t) { - return this.updatePosition({x: window.pageXOffset, y: window.pageYOffset}) - }, r.prototype.updatePosition = function (t) { - var e; - return this.position = t, null != (e = this.delegate) ? e.scrollPositionChanged(this.position) : void 0 - }, r - }() - }.call(this), function () { - e.SnapshotCache = function () { - function t(t) { - this.size = t, this.keys = [], this.snapshots = {} - } - - var r; - return t.prototype.has = function (t) { - var e; - return e = r(t), e in this.snapshots - }, t.prototype.get = function (t) { - var e; - if (this.has(t)) return e = this.read(t), this.touch(t), e - }, t.prototype.put = function (t, e) { - return this.write(t, e), this.touch(t), e - }, t.prototype.read = function (t) { - var e; - return e = r(t), this.snapshots[e] - }, t.prototype.write = function (t, e) { - var n; - return n = r(t), this.snapshots[n] = e - }, t.prototype.touch = function (t) { - var e, n; - return n = r(t), e = this.keys.indexOf(n), e > -1 && this.keys.splice(e, 1), this.keys.unshift(n), this.trim() - }, t.prototype.trim = function () { - var t, e, r, n, o; - for (n = this.keys.splice(this.size), o = [], t = 0, r = n.length; r > t; t++) e = n[t], o.push(delete this.snapshots[e]); - return o - }, r = function (t) { - return e.Location.wrap(t).toCacheKey() - }, t - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.Visit = function () { - function r(r, n, o) { - this.controller = r, this.action = o, this.performScroll = t(this.performScroll, this), this.identifier = e.uuid(), this.location = e.Location.wrap(n), this.adapter = this.controller.adapter, this.state = "initialized", this.timingMetrics = {} - } - - var n; - return r.prototype.start = function () { - return "initialized" === this.state ? (this.recordTimingMetric("visitStart"), this.state = "started", this.adapter.visitStarted(this)) : void 0 - }, r.prototype.cancel = function () { - var t; - return "started" === this.state ? (null != (t = this.request) && t.cancel(), this.cancelRender(), this.state = "canceled") : void 0 - }, r.prototype.complete = function () { - var t; - return "started" === this.state ? (this.recordTimingMetric("visitEnd"), this.state = "completed", "function" == typeof (t = this.adapter).visitCompleted && t.visitCompleted(this), this.controller.visitCompleted(this)) : void 0 - }, r.prototype.fail = function () { - var t; - return "started" === this.state ? (this.state = "failed", "function" == typeof (t = this.adapter).visitFailed ? t.visitFailed(this) : void 0) : void 0 - }, r.prototype.changeHistory = function () { - var t, e; - return this.historyChanged ? void 0 : (t = this.location.isEqualTo(this.referrer) ? "replace" : this.action, e = n(t), this.controller[e](this.location, this.restorationIdentifier), this.historyChanged = !0) - }, r.prototype.issueRequest = function () { - return this.shouldIssueRequest() && null == this.request ? (this.progress = 0, this.request = new e.HttpRequest(this, this.location, this.referrer), this.request.send()) : void 0 - }, r.prototype.getCachedSnapshot = function () { - var t; - return !(t = this.controller.getCachedSnapshotForLocation(this.location)) || null != this.location.anchor && !t.hasAnchor(this.location.anchor) || "restore" !== this.action && !t.isPreviewable() ? void 0 : t - }, r.prototype.hasCachedSnapshot = function () { - return null != this.getCachedSnapshot() - }, r.prototype.loadCachedSnapshot = function () { - var t, e; - return (e = this.getCachedSnapshot()) ? (t = this.shouldIssueRequest(), this.render(function () { - var r; - return this.cacheSnapshot(), this.controller.render({ - snapshot: e, - isPreview: t - }, this.performScroll), "function" == typeof (r = this.adapter).visitRendered && r.visitRendered(this), t ? void 0 : this.complete() - })) : void 0 - }, r.prototype.loadResponse = function () { - return null != this.response ? this.render(function () { - var t, e; - return this.cacheSnapshot(), this.request.failed ? (this.controller.render({error: this.response}, this.performScroll), "function" == typeof (t = this.adapter).visitRendered && t.visitRendered(this), this.fail()) : (this.controller.render({snapshot: this.response}, this.performScroll), "function" == typeof (e = this.adapter).visitRendered && e.visitRendered(this), this.complete()) - }) : void 0 - }, r.prototype.followRedirect = function () { - return this.redirectedToLocation && !this.followedRedirect ? (this.location = this.redirectedToLocation, this.controller.replaceHistoryWithLocationAndRestorationIdentifier(this.redirectedToLocation, this.restorationIdentifier), this.followedRedirect = !0) : void 0 - }, r.prototype.requestStarted = function () { - var t; - return this.recordTimingMetric("requestStart"), "function" == typeof (t = this.adapter).visitRequestStarted ? t.visitRequestStarted(this) : void 0 - }, r.prototype.requestProgressed = function (t) { - var e; - return this.progress = t, "function" == typeof (e = this.adapter).visitRequestProgressed ? e.visitRequestProgressed(this) : void 0 - }, r.prototype.requestCompletedWithResponse = function (t, r) { - return this.response = t, null != r && (this.redirectedToLocation = e.Location.wrap(r)), this.adapter.visitRequestCompleted(this) - }, r.prototype.requestFailedWithStatusCode = function (t, e) { - return this.response = e, this.adapter.visitRequestFailedWithStatusCode(this, t) - }, r.prototype.requestFinished = function () { - var t; - return this.recordTimingMetric("requestEnd"), "function" == typeof (t = this.adapter).visitRequestFinished ? t.visitRequestFinished(this) : void 0 - }, r.prototype.performScroll = function () { - return this.scrolled ? void 0 : ("restore" === this.action ? this.scrollToRestoredPosition() || this.scrollToTop() : this.scrollToAnchor() || this.scrollToTop(), this.scrolled = !0) - }, r.prototype.scrollToRestoredPosition = function () { - var t, e; - return t = null != (e = this.restorationData) ? e.scrollPosition : void 0, null != t ? (this.controller.scrollToPosition(t), !0) : void 0 - }, r.prototype.scrollToAnchor = function () { - return null != this.location.anchor ? (this.controller.scrollToAnchor(this.location.anchor), !0) : void 0 - }, r.prototype.scrollToTop = function () { - return this.controller.scrollToPosition({x: 0, y: 0}) - }, r.prototype.recordTimingMetric = function (t) { - var e; - return null != (e = this.timingMetrics)[t] ? e[t] : e[t] = (new Date).getTime() - }, r.prototype.getTimingMetrics = function () { - return e.copyObject(this.timingMetrics) - }, n = function (t) { - switch (t) { - case"replace": - return "replaceHistoryWithLocationAndRestorationIdentifier"; - case"advance": - case"restore": - return "pushHistoryWithLocationAndRestorationIdentifier" - } - }, r.prototype.shouldIssueRequest = function () { - return "restore" === this.action ? !this.hasCachedSnapshot() : !0 - }, r.prototype.cacheSnapshot = function () { - return this.snapshotCached ? void 0 : (this.controller.cacheSnapshot(), this.snapshotCached = !0) - }, r.prototype.render = function (t) { - return this.cancelRender(), this.frame = requestAnimationFrame(function (e) { - return function () { - return e.frame = null, t.call(e) - } - }(this)) - }, r.prototype.cancelRender = function () { - return this.frame ? cancelAnimationFrame(this.frame) : void 0 - }, r - }() - }.call(this), function () { - var t = function (t, e) { - return function () { - return t.apply(e, arguments) - } - }; - e.Controller = function () { - function r() { - this.clickBubbled = t(this.clickBubbled, this), this.clickCaptured = t(this.clickCaptured, this), this.pageLoaded = t(this.pageLoaded, this), this.history = new e.History(this), this.view = new e.View(this), this.scrollManager = new e.ScrollManager(this), this.restorationData = {}, this.clearCache(), this.setProgressBarDelay(500) - } - - return r.prototype.start = function () { - return e.supported && !this.started ? (addEventListener("click", this.clickCaptured, !0), addEventListener("DOMContentLoaded", this.pageLoaded, !1), this.scrollManager.start(), this.startHistory(), this.started = !0, this.enabled = !0) : void 0 - }, r.prototype.disable = function () { - return this.enabled = !1 - }, r.prototype.stop = function () { - return this.started ? (removeEventListener("click", this.clickCaptured, !0), removeEventListener("DOMContentLoaded", this.pageLoaded, !1), this.scrollManager.stop(), this.stopHistory(), this.started = !1) : void 0 - }, r.prototype.clearCache = function () { - return this.cache = new e.SnapshotCache(10) - }, r.prototype.visit = function (t, r) { - var n, o; - return null == r && (r = {}), t = e.Location.wrap(t), this.applicationAllowsVisitingLocation(t) ? this.locationIsVisitable(t) ? (n = null != (o = r.action) ? o : "advance", this.adapter.visitProposedToLocationWithAction(t, n)) : window.location = t : void 0 - }, r.prototype.startVisitToLocationWithAction = function (t, r, n) { - var o; - return e.supported ? (o = this.getRestorationDataForIdentifier(n), this.startVisit(t, r, {restorationData: o})) : window.location = t - }, r.prototype.setProgressBarDelay = function (t) { - return this.progressBarDelay = t - }, r.prototype.startHistory = function () { - return this.location = e.Location.wrap(window.location), this.restorationIdentifier = e.uuid(), this.history.start(), this.history.replace(this.location, this.restorationIdentifier) - }, r.prototype.stopHistory = function () { - return this.history.stop() - }, r.prototype.pushHistoryWithLocationAndRestorationIdentifier = function (t, r) { - return this.restorationIdentifier = r, this.location = e.Location.wrap(t), this.history.push(this.location, this.restorationIdentifier) - }, r.prototype.replaceHistoryWithLocationAndRestorationIdentifier = function (t, r) { - return this.restorationIdentifier = r, this.location = e.Location.wrap(t), this.history.replace(this.location, this.restorationIdentifier) - }, r.prototype.historyPoppedToLocationWithRestorationIdentifier = function (t, r) { - var n; - return this.restorationIdentifier = r, this.enabled ? (n = this.getRestorationDataForIdentifier(this.restorationIdentifier), this.startVisit(t, "restore", { - restorationIdentifier: this.restorationIdentifier, - restorationData: n, - historyChanged: !0 - }), this.location = e.Location.wrap(t)) : this.adapter.pageInvalidated() - }, r.prototype.getCachedSnapshotForLocation = function (t) { - var e; - return null != (e = this.cache.get(t)) ? e.clone() : void 0 - }, r.prototype.shouldCacheSnapshot = function () { - return this.view.getSnapshot().isCacheable(); - }, r.prototype.cacheSnapshot = function () { - var t, r; - return this.shouldCacheSnapshot() ? (this.notifyApplicationBeforeCachingSnapshot(), r = this.view.getSnapshot(), t = this.lastRenderedLocation, e.defer(function (e) { - return function () { - return e.cache.put(t, r.clone()) - } - }(this))) : void 0 - }, r.prototype.scrollToAnchor = function (t) { - var e; - return (e = this.view.getElementForAnchor(t)) ? this.scrollToElement(e) : this.scrollToPosition({x: 0, y: 0}) - }, r.prototype.scrollToElement = function (t) { - return this.scrollManager.scrollToElement(t) - }, r.prototype.scrollToPosition = function (t) { - return this.scrollManager.scrollToPosition(t) - }, r.prototype.scrollPositionChanged = function (t) { - var e; - return e = this.getCurrentRestorationData(), e.scrollPosition = t - }, r.prototype.render = function (t, e) { - return this.view.render(t, e) - }, r.prototype.viewInvalidated = function () { - return this.adapter.pageInvalidated() - }, r.prototype.viewWillRender = function (t) { - return this.notifyApplicationBeforeRender(t) - }, r.prototype.viewRendered = function () { - return this.lastRenderedLocation = this.currentVisit.location, this.notifyApplicationAfterRender() - }, r.prototype.pageLoaded = function () { - return this.lastRenderedLocation = this.location, this.notifyApplicationAfterPageLoad() - }, r.prototype.clickCaptured = function () { - return removeEventListener("click", this.clickBubbled, !1), addEventListener("click", this.clickBubbled, !1) - }, r.prototype.clickBubbled = function (t) { - var e, r, n; - return this.enabled && this.clickEventIsSignificant(t) && (r = this.getVisitableLinkForNode(t.target)) && (n = this.getVisitableLocationForLink(r)) && this.applicationAllowsFollowingLinkToLocation(r, n) ? (t.preventDefault(), e = this.getActionForLink(r), this.visit(n, {action: e})) : void 0 - }, r.prototype.applicationAllowsFollowingLinkToLocation = function (t, e) { - var r; - return r = this.notifyApplicationAfterClickingLinkToLocation(t, e), !r.defaultPrevented - }, r.prototype.applicationAllowsVisitingLocation = function (t) { - var e; - return e = this.notifyApplicationBeforeVisitingLocation(t), !e.defaultPrevented - }, r.prototype.notifyApplicationAfterClickingLinkToLocation = function (t, r) { - return e.dispatch("turbolinks:click", {target: t, data: {url: r.absoluteURL}, cancelable: !0}) - }, r.prototype.notifyApplicationBeforeVisitingLocation = function (t) { - return e.dispatch("turbolinks:before-visit", {data: {url: t.absoluteURL}, cancelable: !0}) - }, r.prototype.notifyApplicationAfterVisitingLocation = function (t) { - return e.dispatch("turbolinks:visit", {data: {url: t.absoluteURL}}) - }, r.prototype.notifyApplicationBeforeCachingSnapshot = function () { - return e.dispatch("turbolinks:before-cache") - }, r.prototype.notifyApplicationBeforeRender = function (t) { - return e.dispatch("turbolinks:before-render", {data: {newBody: t}}) - }, r.prototype.notifyApplicationAfterRender = function () { - return e.dispatch("turbolinks:render") - }, r.prototype.notifyApplicationAfterPageLoad = function (t) { - return null == t && (t = {}), e.dispatch("turbolinks:load", { - data: { - url: this.location.absoluteURL, - timing: t - } - }) - }, r.prototype.startVisit = function (t, e, r) { - var n; - return null != (n = this.currentVisit) && n.cancel(), this.currentVisit = this.createVisit(t, e, r), this.currentVisit.start(), this.notifyApplicationAfterVisitingLocation(t) - }, r.prototype.createVisit = function (t, r, n) { - var o, i, s, a, u; - return i = null != n ? n : {}, a = i.restorationIdentifier, s = i.restorationData, o = i.historyChanged, u = new e.Visit(this, t, r), u.restorationIdentifier = null != a ? a : e.uuid(), u.restorationData = e.copyObject(s), u.historyChanged = o, u.referrer = this.location, u - }, r.prototype.visitCompleted = function (t) { - return this.notifyApplicationAfterPageLoad(t.getTimingMetrics()) - }, r.prototype.clickEventIsSignificant = function (t) { - return !(t.defaultPrevented || t.target.isContentEditable || t.which > 1 || t.altKey || t.ctrlKey || t.metaKey || t.shiftKey) - }, r.prototype.getVisitableLinkForNode = function (t) { - return this.nodeIsVisitable(t) ? e.closest(t, "a[href]:not([target]):not([download])") : void 0 - }, r.prototype.getVisitableLocationForLink = function (t) { - var r; - return r = new e.Location(t.getAttribute("href")), this.locationIsVisitable(r) ? r : void 0 - }, r.prototype.getActionForLink = function (t) { - var e; - return null != (e = t.getAttribute("data-turbolinks-action")) ? e : "advance" - }, r.prototype.nodeIsVisitable = function (t) { - var r; - return (r = e.closest(t, "[data-turbolinks]")) ? "false" !== r.getAttribute("data-turbolinks") : !0 - }, r.prototype.locationIsVisitable = function (t) { - return t.isPrefixedBy(this.view.getRootLocation()) && t.isHTML() - }, r.prototype.getCurrentRestorationData = function () { - return this.getRestorationDataForIdentifier(this.restorationIdentifier) - }, r.prototype.getRestorationDataForIdentifier = function (t) { - var e; - return null != (e = this.restorationData)[t] ? e[t] : e[t] = {} - }, r - }() - }.call(this), function () { - !function () { - var t, e; - if ((t = e = document.currentScript) && !e.hasAttribute("data-turbolinks-suppress-warning")) for (; t = t.parentNode;) if (t === document.body) return console.warn("You are loading Turbolinks from a\n' + ' \n' + '\n' + '