Javascript and jquery cleanup
This commit is contained in:
parent
36e0115e4f
commit
483eb09c62
@ -5,6 +5,7 @@ linters:
|
||||
ignored_cops:
|
||||
- Layout/ArgumentAlignment
|
||||
- Layout/ArrayAlignment
|
||||
- Layout/EmptyLineAfterGuardClause
|
||||
- Layout/HashAlignment
|
||||
- Layout/IndentationWidth
|
||||
- Layout/MultilineArrayBraceLayout
|
||||
|
@ -29,14 +29,10 @@ javascript:
|
||||
update: function(event, ui){
|
||||
// trigger the call on the list that receives the block only
|
||||
if ($(this).find(ui.item).length > 0) {
|
||||
$.ajax({
|
||||
url: "#{escape_javascript _order_blocks_dashboard_path(@project, dashboard)}",
|
||||
type: 'post',
|
||||
data: {
|
||||
'group': $(this).attr('id').replace(/^list-/, ''),
|
||||
'blocks': $.map($(this).children(), function(el){return $(el).attr('id').replace(/^block-/, '');})
|
||||
}
|
||||
});
|
||||
$.post("#{escape_javascript _order_blocks_dashboard_path(@project, dashboard)}",
|
||||
{ 'group': $(this).attr('id').replace(/^list-/, ''),
|
||||
'blocks': $.map($(this).children(), function(el){return $(el).attr('id').replace(/^block-/, '');})
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -71,13 +71,13 @@
|
||||
|
||||
javascript:
|
||||
$(function() {
|
||||
$("input[name='dashboard[visibility]']").change(function(){
|
||||
$("input[name='dashboard[visibility]']").change(function() {
|
||||
var roles_checked = $('#dashboard_visibility_1').is(':checked');
|
||||
var private_checked = $('#dashboard_visibility_0').is(':checked');
|
||||
$("input[name='dashboard[role_ids][]'][type=checkbox]").attr('disabled', !roles_checked);
|
||||
}).trigger('change');
|
||||
|
||||
$("input[name='dashboard[system_default]']").change(function(){
|
||||
$("input[name='dashboard[system_default]']").change(function() {
|
||||
var selection = $('#dashboard_system_default').is(':checked');
|
||||
if (selection) {
|
||||
$('#always-expose').show();
|
||||
|
@ -4,7 +4,7 @@
|
||||
$('.issue .description .contextual')
|
||||
.prepend("#{escape_javascript link_to(l(:button_edit), edit_issue_path(@issue), class: 'icon icon-edit', id: 'fast-desc-link')} ");
|
||||
|
||||
$("#fast-desc-link").click(function(){
|
||||
$("#fast-desc-link").click(function() {
|
||||
$("#issue_description_and_toolbar").parent().find('a').first().hide();
|
||||
showAndScrollTo("update", "issue_notes");
|
||||
$("#issue_description_and_toolbar").show();
|
||||
|
@ -84,11 +84,10 @@ function observeLiveSearchField(fieldId, targetId, target_url) {
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'get',
|
||||
data: formData,
|
||||
success: function(data){ if(targetId) $('#'+targetId).html(data); },
|
||||
beforeSend: function(){ $this.addClass('ajax-loading'); },
|
||||
complete: function(){ $this.removeClass('ajax-loading'); }
|
||||
success: function(data) { if(targetId) $('#'+targetId).html(data); },
|
||||
beforeSend: function() { $this.addClass('ajax-loading'); },
|
||||
complete: function() { $this.removeClass('ajax-loading'); }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
@ -17,7 +17,7 @@ jsToolBar.prototype.macroMenu = function(fn){
|
||||
var menu = $('<ul style="position:absolute;"></ul>');
|
||||
for (var i = 0; i < this.macroList.length; i++) {
|
||||
var macroItem = $('<div></div>').text(this.macroList[i]);
|
||||
$('<li></li>').html(macroItem).appendTo(menu).mousedown(function(){
|
||||
$('<li></li>').html(macroItem).appendTo(menu).mousedown(function() {
|
||||
fn($(this).text());
|
||||
});
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ function additionals_transform_to_select2(field) {
|
||||
minimumInputLength: 1,
|
||||
width: '90%',
|
||||
templateResult: formatNameWithIcon
|
||||
}).on('select2:open', function () {
|
||||
}).on('select2:open', function() {
|
||||
$(this).parent('span').find('.select2-search__field').val(' ').trigger($.Event('input', { which: 13 })).val('');
|
||||
});
|
||||
}
|
||||
@ -151,7 +151,7 @@ function transformToSelect2(field, options) {
|
||||
selectField.select2(buildSelect2Options(options));
|
||||
|
||||
var select2Instance = selectField.data('select2');
|
||||
select2Instance.on('results:message', function(){
|
||||
select2Instance.on('results:message', function() {
|
||||
this.dropdown._resizeDropdown();
|
||||
this.dropdown._positionDropdown();
|
||||
});
|
||||
@ -164,7 +164,7 @@ function select2Tag(id, options) {
|
||||
selectField.select2(buildSelect2Options(options));
|
||||
|
||||
var select2Instance = selectField.data('select2');
|
||||
select2Instance.on('results:message', function(){
|
||||
select2Instance.on('results:message', function() {
|
||||
this.dropdown._resizeDropdown();
|
||||
this.dropdown._positionDropdown();
|
||||
});
|
||||
|
@ -101,9 +101,6 @@ module Additionals
|
||||
def setup
|
||||
RenderAsync.configuration.jquery = true
|
||||
|
||||
loader.incompatible? %w[redmine_editauthor
|
||||
redmine_changeauthor]
|
||||
|
||||
loader.add_patch %w[ApplicationController
|
||||
AutoCompletesController
|
||||
Issue
|
||||
@ -131,6 +128,8 @@ module Additionals
|
||||
|
||||
loader.add_helper({ controller: 'Issues', helper: 'AdditionalsCommonJournals' })
|
||||
|
||||
loader.add_patch [{ target: Redmine::Views::LabelledFormBuilder, patch: 'LabelledFormBuilder' }]
|
||||
|
||||
loader.add_global_helper [Additionals::Helpers,
|
||||
AdditionalsFontawesomeHelper,
|
||||
AdditionalsMenuHelper,
|
||||
|
36
lib/additionals/patches/labelled_form_builder_patch.rb
Normal file
36
lib/additionals/patches/labelled_form_builder_patch.rb
Normal file
@ -0,0 +1,36 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Additionals
|
||||
module Patches
|
||||
module LabelledFormBuilderPatch
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
prepend InstanceOverwriteMethods
|
||||
end
|
||||
|
||||
module InstanceOverwriteMethods
|
||||
# add info support
|
||||
# NOTE: if info = true, label symbol + _info is used, e.g. for field_author this is field_author_info
|
||||
def label_for_field(field, options = {})
|
||||
if (info = options.delete :info) && info
|
||||
text = options[:label].is_a?(Symbol) ? l(options[:label]) : options[:label]
|
||||
text ||= @object.class.human_attribute_name field
|
||||
|
||||
title = if info.is_a?(TrueClass) && options[:label].is_a?(Symbol)
|
||||
l "#{options[:label]}_info"
|
||||
elsif info.is_a?(TrueClass) && options[:label].blank?
|
||||
l "#{field}_info"
|
||||
else
|
||||
info.is_a?(Symbol) ? l(info) : info
|
||||
end
|
||||
|
||||
options[:label] = @template.tag.span text, title: title, class: 'field-description'
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user