Skip to content
This repository was archived by the owner on Apr 26, 2022. It is now read-only.

Commit db09dfb

Browse files
author
susanodd
committed
Issue Signbank#726, Signbank#727, Signbank#750: Adjustments to colour support.
1 parent 8a3d616 commit db09dfb

File tree

7 files changed

+123
-138
lines changed

7 files changed

+123
-138
lines changed

media/js/gloss_edit_color.js

+6-32
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,15 @@ var busy_editing = 0;
8383
});
8484

8585

86-
// a lot of console logging has been added to show events the user presses
8786
// this is needed to help check different browsers
8887
for (var i = 0; i < gloss_phonology.length; i++) {
8988
var field = gloss_phonology[i];
9089
var field_ref = '#' + gloss_phonology[i];
91-
// console.log('setup key listener '+field_ref);
9290
$(field_ref).on("customEvent", function(e) {
9391
var target = $(e.target);
9492
var this_field_name = $(target).attr("id");
9593
var classname = $(target).attr("class");
9694
$(target).clearQueue();
97-
// console.log('customEvent on '+this_field_name+' type '+e.type+' triggers select on '+this_field_name);
9895
if (phonology_list_kinds.includes(this_field_name)) {
9996
// for phonology pulldown lists do this to get list open
10097
$(target).focus().click().click();
@@ -112,8 +109,6 @@ var busy_editing = 0;
112109
var targetNodeName = e.target.nodeName;
113110
var this_element = $(this);
114111
var this_value = $(this_element).attr("value");
115-
116-
// console.log('field '+field+' key pressed '+e.keyCode+' nodeName '+targetNodeName+' value '+field_value+' option value '+this_value);
117112
if (e.keyCode === 13) { // 'return'
118113
e.preventDefault();
119114
if (targetNodeName != 'INPUT') {
@@ -143,7 +138,6 @@ var busy_editing = 0;
143138
});
144139

145140
function disable_edit() {
146-
//$('#affix-bar').show(); // The affix bar appears on top of the Delete modal popup window, so it is hidden during editting
147141
$('.edit').editable('disable');
148142
$('.edit').css('color', 'black');
149143
$('#edit_message').text('');
@@ -160,7 +154,6 @@ function disable_edit() {
160154
$('#idgloss').html('<a href="' + original_lemma_group_url + '">' + original_lemma_group_value + '</a>')
161155
}
162156
} else {
163-
// console.log('lemma group: ' + lemma_group)
164157
if (lemma_group == 'True') {
165158
new_lemma_group_url = url + 'signs/search/?search_type=sign&view_type=lemma_groups&lemmaGloss=%5E' + new_lemma_group + '%24'
166159
$('#idgloss').html('<a href="' + new_lemma_group_url + '">' + new_lemma_group + '</a>')
@@ -169,23 +162,19 @@ function disable_edit() {
169162
if (strong_machine_value == undefined) {
170163
if (original_strong_hand) {
171164
strong_hand_href = url + 'dictionary/handshape/'+ original_strong_hand + '/';
172-
// console.log('strong hand ref: ' + strong_hand_href);
173165
$('#domhndsh').html('<a id="strong_hand_link" style="color: inherit; display: visible;" href="' + strong_hand_href + '">' + strong_hand + '</a>');
174166
}
175167
} else {
176168
strong_hand_href = url + 'dictionary/handshape/'+ strong_machine_value + '/';
177-
// console.log('strong hand ref: ' + strong_hand_href);
178169
$('#domhndsh').html('<a id="strong_hand_link" style="color: inherit; display: visible;" href="' + strong_hand_href + '">' + strong_hand + '</a>');
179170
};
180171
if (weak_machine_value == undefined) {
181172
if (original_weak_hand) {
182173
weak_hand_href = url + 'dictionary/handshape/'+ original_weak_hand + '/';
183-
// console.log('weak hand ref: ' + weak_hand_href);
184174
$('#subhndsh').html('<a id="weak_hand_link" style="color: inherit; display: visible;" href="' + weak_hand_href + '">' + weak_hand + '</a>');
185175
}
186176
} else {
187177
weak_hand_href = url + 'dictionary/handshape/'+ weak_machine_value + '/';
188-
// console.log('weak hand ref: ' + weak_hand_href);
189178
$('#subhndsh').html('<a id="weak_hand_link" style="color: inherit; display: visible;" href="' + weak_hand_href + '">' + weak_hand + '</a>');
190179
};
191180
};
@@ -212,9 +201,6 @@ function disable_edit() {
212201

213202
$('.empty_row').hide();
214203

215-
// initial setup not in Edit mode
216-
// hideLemmaForm($("#lemma"));
217-
// $("#lemma a").show();
218204
$('#edit_lemma_form').hide();
219205
$("#set_lemma_form").hide();
220206
$("#add_lemma_form").hide();
@@ -248,17 +234,13 @@ function disable_edit() {
248234
};
249235

250236
function enable_edit() {
251-
//$('#affix-bar').hide(); // The affix bar appears on top of the Delete modal popup window, so it is hidden during editting
252237
$('.edit').editable('enable');
253238
$('.edit').css('color', 'red');
254239
$('#edit_message').text('Click on red text to edit ');
255240
$('#edit_message').css('color', 'black');
256241
strong_hand = $('#domhndsh').text();
257242
weak_hand = $('#subhndsh').text();
258243
lemma_group_text = $('#idgloss').text();
259-
// console.log('original lemma group: ' + lemma_group_text);
260-
// console.log("original strong hand: " + strong_hand);
261-
// console.log("original weak hand: " + weak_hand);
262244
$('#domhndsh').children().remove();
263245
$('#domhndsh').html(strong_hand);
264246
$('#subhndsh').children().remove();
@@ -357,7 +339,7 @@ function configure_edit() {
357339
$.fn.editable.defaults['indicator'] = saving_str;
358340
$.fn.editable.defaults['tooltip'] = 'Click to edit...';
359341
$.fn.editable.defaults['placeholder'] = '-';
360-
$.fn.editable.defaults['submit'] = '<button class="btn btn-primary" type="submit">Ok</button>';
342+
$.fn.editable.defaults['submit'] = '<button class="btn btn-primary" type="submit">OK</button>';
361343
$.fn.editable.defaults['cancel'] = '<button class="btn btn-default" type="cancel">Cancel</button>';
362344
$.fn.editable.defaults['cssclass'] = 'preview';
363345
$.fn.editable.defaults['width'] = 'auto';
@@ -474,7 +456,6 @@ function configure_edit() {
474456
var this_data = $(this).attr('value');
475457
var edit_list_choices = static_choice_lists[$(this).attr('id')];
476458
var edit_list_choice_colors = static_choice_list_colors[$(this).attr('id')];
477-
478459
var index_of_modified_field = '_0';
479460
for (var key in edit_list_choices) {
480461
var value = edit_list_choices[key];
@@ -556,15 +537,14 @@ function update_view_and_remember_original_value(change_summary)
556537
new_values_for_changes_made[id] = machine_value;
557538
if (new_value == '&nbsp;') {
558539
new_value = 'False';
559-
// console.log("new value changed from &nbsp; to False");
560540
}
561541

562542
if (original_values_for_changes_made[id] == undefined)
563543
{
564544
original_values_for_changes_made[id] = original_value;
565545
$(this).parent().removeClass('empty_row');
566546
if (id == 'weakprop' || id == 'weakdrop' || id == 'domhndsh_letter' || id == 'domhndsh_number' || id == 'subhndsh_letter' || id == 'subhndsh_number') {
567-
$(this).attr("value", new_value);
547+
$(this).attr("value", machine_value);
568548
if (new_value == '&nbsp;') {
569549
$(this).html("------");
570550
}
@@ -576,27 +556,25 @@ function update_view_and_remember_original_value(change_summary)
576556
if (new_value == '-' || new_value == ' ' || new_value == '' || new_value == 'None' ||
577557
new_value == 'False' || new_value == 0 || new_value == '&nbsp;')
578558
{
579-
// console.log("new value is empty, new value is: ", new_value);
580559
if (id == 'weakprop' || id == 'weakdrop' || id == 'domhndsh_letter' || id == 'domhndsh_number' || id == 'subhndsh_letter' || id == 'subhndsh_number') {
581-
$(this).attr("value", new_value);
582560
$(this).html("------");
583561
}
584562
else {
585563
if (id == 'idgloss') {
586564
// the user tried to erase the Lemma ID Gloss field, reset it in the template to what it was
587-
// console.log('attempt to delete field idgloss');
588565
$(this).html(original_value);
589566
lemma_group = original_lemma_group;
590567
} else {
591568
$(this).parent().addClass('empty_row');
592-
$(this).attr("value", new_value);
569+
$(this).attr("value", machine_value);
593570
$(this).html("------");
594571
}
595572
}
596573
}
597574
if (category_value == 'phonology') {
598-
// console.log('phonology modified');
599-
$(this).attr("value", new_value);
575+
if (id != 'weakprop' && id != 'weakdrop') {
576+
$(this).attr("value", new_value);
577+
}
600578
var index_of_modified_field = gloss_phonology.indexOf(id);
601579
var next_field_index = index_of_modified_field+1;
602580
if (next_field_index < gloss_phonology.length) {
@@ -605,10 +583,8 @@ function update_view_and_remember_original_value(change_summary)
605583
$(next_field_ref).clearQueue();
606584
if (phonology_list_kinds.includes(next_field)) {
607585
// for lists, do custom event instead of click
608-
// console.log('customEvent on '+next_field_ref);
609586
$(next_field_ref).triggerHandler("customEvent"); //.focus().click().click();
610587
} else {
611-
// console.log('click event on '+next_field_ref);
612588
$(next_field_ref).click();
613589
};
614590
}
@@ -789,7 +765,6 @@ function update_foreign_delete(change_summary)
789765
var deleted_relation = deleted_relation_for_gloss.split('_');
790766
var deleted_relation_id = deleted_relation[1];
791767
$(this).css("color", "black");
792-
// console.log("Delete foreign relation: ", deleted_relation_id);
793768
var search_id = 'foreign_' + deleted_relation_id;
794769
$(document.getElementById(search_id)).replaceWith("<tr id='" + search_id + "' class='empty_row' style='display: none;'>" + "</tr>");
795770
$(this).html('');
@@ -802,7 +777,6 @@ function update_relation_delete(change_summary)
802777
var deleted_relation = deleted_relation_for_gloss.split('_');
803778
var deleted_relation_id = deleted_relation[1];
804779
$(this).css("color", "black");
805-
// console.log("Delete relation: ", deleted_relation_id);
806780
var search_id = 'row_' + deleted_relation_id;
807781
$(document.getElementById(search_id)).replaceWith("<tr id='" + search_id + "' class='empty_row' style='display: none;'>" + "</tr>");
808782
$(this).html('');

media/js/jquery.jeditable.mini_colors.js

+36-29
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
(function ($) {
23
$.fn.editable = function (target, options) {
34
if ('disable' == target) {
@@ -191,8 +192,8 @@
191192
}
192193
$(self).html(settings.indicator);
193194
var ajaxoptions = {
194-
type: 'POST', data: submitdata, dataType: 'html', url: settings.target, success: function (result, status) {
195-
if (ajaxoptions.dataType == 'html') {
195+
type: 'POST', data: submitdata, datatype: 'text', url: settings.target, success: function (result, status) {
196+
if (ajaxoptions.datatype == 'text') {
196197
$(self).html(result);
197198
}
198199
self.editing = false; callback.apply(self,[result, settings]);
@@ -257,6 +258,9 @@
257258
form.submit();
258259
}
259260
});
261+
submit.css({
262+
'display': 'inline-block', 'position': 'absolute', 'left': settings.width-150
263+
});
260264
} else {
261265
var submit = $('<button type="submit" />');
262266
submit.html(settings.submit);
@@ -266,6 +270,9 @@
266270
if (settings.cancel) {
267271
if (settings.cancel.match(/>$/)) {
268272
var cancel = $(settings.cancel);
273+
cancel.css({
274+
'display': 'inline-block', 'position': 'absolute', 'left': settings.width-100
275+
});
269276
} else {
270277
var cancel = $('<button type="cancel" />');
271278
cancel.html(settings.cancel);
@@ -316,40 +323,40 @@
316323
},
317324
select: {
318325
element: function (settings, original) {
319-
var dropdown_button = $('<button />');
320-
dropdown_button.attr('id', 'preview_' + settings.params.field);
321-
dropdown_button.attr('class', 'btn dropdown-toggle');
322-
dropdown_button.attr('type', 'button');
323-
dropdown_button.attr('data-toggle', 'dropdown');
324-
dropdown_button.attr('aria-haspopup', 'true');
325-
dropdown_button.attr('aria-expanded', 'false');
326-
dropdown_button.css({
327-
'display': 'inline-block', 'width': 'auto', 'color': 'red'
328-
});
329-
var td_value = $('#' + settings.params.field).attr('value');
330-
var row_class = $('#' + settings.params.field).parent().attr('class');
331-
if (settings.params.field == 'weakdrop' || settings.params.field == 'weakprop') {
332-
if (td_value == 'None') {
333-
// get translated empty value Neutral
334-
td_value = handedness_weak_drop_reverse[td_value];
326+
var dropdown_button = $('<button />');
327+
dropdown_button.attr('id', 'preview_' + settings.params.field);
328+
dropdown_button.attr('class', 'btn dropdown-toggle');
329+
dropdown_button.attr('type', 'button');
330+
dropdown_button.attr('data-toggle', 'dropdown');
331+
dropdown_button.attr('aria-haspopup', 'true');
332+
dropdown_button.attr('aria-expanded', 'false');
333+
dropdown_button.css({
334+
'display': 'inline-block', 'width': 'auto', 'color': 'red', 'position': 'relative', 'z-index': 0, 'left': '0px'
335+
});
336+
var td_value = $('#' + settings.params.field).attr('value');
337+
var row_class = $('#' + settings.params.field).parent().attr('class');
338+
if (settings.params.field == 'weakdrop' || settings.params.field == 'weakprop') {
339+
if (td_value == 'None' || td_value == 'True' || td_value == 'False') {
340+
// get translated display value
341+
td_value = handedness_weak_choices[td_value];
335342
}
336-
};
337-
if (row_class != 'empty_row' && td_value != 'None') {
338-
dropdown_button.html(td_value);
339-
} else {
340-
dropdown_button.html('------');
341-
};
342-
$(this).append(dropdown_button);
343+
};
344+
if (row_class != 'empty_row' && td_value != 'None') {
345+
dropdown_button.html(td_value);
346+
} else {
347+
dropdown_button.html('------');
348+
};
349+
$(this).append(dropdown_button);
343350
var select = $('<ul />');
344351
select.attr('class', 'dropdown-menu shadow-sm p-3 mb-5 bg-white rounded');
345352
select.attr('id', 'ul_' + settings.params.field);
346353
if (settings.params.field == 'weakdrop' || settings.params.field == 'weakprop') {
347354
select.css({'overflow-y': 'scroll', 'list-style-type': 'none',
348-
'max-height': '200px', 'position': 'static', 'min-width': '80px'
355+
'max-height': '200px', 'position': 'absolute', 'min-width': '80px'
349356
});
350357
} else {
351358
select.css({'overflow-y': 'scroll', 'list-style-type': 'none',
352-
'max-height': '200px', 'position': 'static'
359+
'max-height': '200px', 'position': 'absolute', 'z-index': 10
353360
});
354361
};
355362
select.attr('role', 'listbox');
@@ -385,7 +392,7 @@
385392
var chosen_offset = 0;
386393
$('ul', this).children().each(function (index) {
387394
var indie = (settings.params === undefined) ? -1: settings.params.a;
388-
if ($(this).val() == json[ 'selected'] || $(this).data('value') == indie || $(this).text() == $.trim(original.revert)) {
395+
if ($(this).data('value') == indie || $(this).text() == $.trim(original.revert)) {
389396
$.extend(settings.submitdata, {
390397
"value": settings.params.a
391398
});
@@ -432,7 +439,7 @@
432439
}
433440
};
434441
$.fn.editable.defaults = {
435-
name: 'value', id: 'id', type: 'text', width: 'auto', height: 'auto', event: 'click.editable', onblur: 'cancel', loadtype: 'GET', loadtext: 'Loading...', placeholder: 'Click to edit', loaddata: {
442+
name: 'value', id: 'id', type: 'text', width: 'auto', height: 'auto', event: 'click.editable', onblur: 'cancel', loadtype: 'POST', loadtext: 'Loading...', placeholder: 'Click to edit', loaddata: {
436443
},
437444
submitdata: {
438445
},

0 commit comments

Comments
 (0)