Move issues.js to separate file and implement client-side quoting for issues.

pull/100/head
Christian Rijke 12 years ago
parent 7cf20ec24f
commit 08b88a87f1
  1. 40
      app/assets/javascripts/application.js
  2. 71
      app/assets/javascripts/issues.js.erb

@ -28,6 +28,7 @@
//= require jstoolbar //= require jstoolbar
//= require calendar //= require calendar
//= require ajaxappender //= require ajaxappender
//= require issues
//source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse //source: http://stackoverflow.com/questions/8120065/jquery-and-prototype-dont-work-together-with-array-prototype-reverse
if (typeof []._reverse == 'undefined') { if (typeof []._reverse == 'undefined') {
@ -1340,43 +1341,4 @@ var Preview = (function ($) {
}); });
})(jQuery); })(jQuery);
var Issue = Issue || {};
Issue.Show = (function($) {
var init;
init = function () {
$.ajaxAppend({
trigger: '.action_menu_main .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);
$("#notes").focus();
}
});
$.ajaxAppend({
trigger: '.description-details',
indicator_class: 'ajax-indicator',
loading_class: 'text-diff',
hide_text: I18n.t("js.ajax.hide")
} );
};
$('document').ready(function () {
if ($('body.controller-issues.action-show').size() > 0) {
init();
};
});
})(jQuery);

@ -0,0 +1,71 @@
var Issue = Issue || {};
Issue.Show = (function($) {
var init;
init = function () {
$.ajaxAppend({
trigger: '.action_menu_main .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);
$("#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(/<pre>((.|\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);
$("#notes").focus();
}
});
$.ajaxAppend({
trigger: '.description-details',
indicator_class: 'ajax-indicator',
loading_class: 'text-diff',
hide_text: I18n.t("js.ajax.hide")
} );
};
$('document').ready(function () {
if ($('body.controller-issues.action-show').size() > 0) {
init();
}
});
})(jQuery);
Loading…
Cancel
Save