<%#-- copyright OpenProject is a project management system. Copyright (C) 2012-2013 the OpenProject Foundation (OPF) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3. OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: Copyright (C) 2006-2013 Jean-Philippe Lang Copyright (C) 2010-2013 the ChiliProject Team This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. See doc/COPYRIGHT.rdoc for more details. ++#%> // TODO check if this is still needed var WorkPackage = WorkPackage || {}; (function($) { var init; init = function () { $.ajaxAppend({ trigger: '.action_menu_specific .edit', indicator_class: 'ajax-indicator', load_target: '#update', loading_text: I18n.t("js.ajax.loading"), loading_class: 'box loading', loading: function(update) { $('html, body').animate({ scrollTop: $(update).offset().top }, 200); }, loaded: function(update) { $('html, body').animate({ scrollTop: $(update).offset().top }, 200); enable_textarea_auto_completion($("#work_package_notes")); $("#work_package_notes").focus(); } }); $.ajaxAppend({ trigger: '.quote-link', indicator_class: 'ajax-indicator', load_target: '#update', loading_text: I18n.t("js.ajax.loading"), loading_class: 'box loading', loading: function(update) { $('html, body').animate({ scrollTop: $(update).offset().top }, 200); }, loaded: function(update, target) { var content = $(target.context).parent().siblings('.wikicontent'); var text = content.text(); var user = content.attr('data-user'); text = text.trim().replace(/
((.|\s)*?)<\/pre>/g, '[...]');
                // remove blank lines generated by redmine textilizable
                text = text.replace(/^\s*$[\n\r]{1,}/gm, '');

                var quotedText = "<%= ::I18n.t(:text_user_wrote, :value => "{{{user}}}", :locale => Setting.default_language.to_s.gsub(%r{(.+)\-(.+)$}) { "#{$1}-#{$2.upcase}" }) %>\n> ";
                quotedText = quotedText.replace("{{{user}}}", user);
                quotedText += text.replace(/(\r?\n|\r\n?)/g, "\n> ") + "\n\n";

                $('#notes').text(quotedText);
                $('html, body').animate({
                  scrollTop: $(update).offset().top
                }, 200);
                enable_textarea_auto_completion($("#work_package_notes"));
                $("#work_package_notes").focus();
      }
    });

    $.ajaxAppend({
      trigger: '.description-details',
      indicator_class: 'ajax-indicator',
      loading_class: 'text-diff',
      hide_text: I18n.t("js.ajax.hide")
    } );
  };

  $('document').ready(function () {
    init();
  });
})(jQuery);