Commit b6e3b4c4449102ff8ff60f95d431b934f0df033a
1 parent
6dc597a2
zmieniony tytuł strony w widokach czytelniczki
--HG-- branch : beta
Showing
6 changed files
with
54 additions
and
38 deletions
common/static/js/edit.js
1 | -/* global $dj, getBusyOverlay, common, gettext */ | |
1 | +/* global $dj, getBusyOverlay, common, gettext, slickgrid */ | |
2 | 2 | |
3 | 3 | var edit = { |
4 | 4 | reader: false, |
... | ... | @@ -49,11 +49,6 @@ var edit = { |
49 | 49 | jq.next().width('100px'); |
50 | 50 | }, |
51 | 51 | |
52 | - get_id: function() { | |
53 | - "use strict"; | |
54 | - return edit.active_id; | |
55 | - }, | |
56 | - | |
57 | 52 | // busy |
58 | 53 | |
59 | 54 | busy_ctrl: null, |
... | ... | @@ -145,7 +140,7 @@ $(function() { |
145 | 140 | method: 'get', |
146 | 141 | dest: $('#edit'), |
147 | 142 | url: $dj.ajax_edit_form, |
148 | - data: {id: edit.get_id()}, | |
143 | + data: {id: slickgrid.get_id()}, | |
149 | 144 | callback: edit.form_init |
150 | 145 | }); |
151 | 146 | }); |
... | ... | @@ -165,7 +160,7 @@ $(function() { |
165 | 160 | method: 'get', |
166 | 161 | dest: $('#edit'), |
167 | 162 | url: $dj.ajax_edit_form, |
168 | - data: {id: edit.get_id()}, | |
163 | + data: {id: slickgrid.get_id()}, | |
169 | 164 | callback: edit.form_init |
170 | 165 | }); |
171 | 166 | }); |
... | ... |
common/static/js/slickgrid.js
... | ... | @@ -62,6 +62,11 @@ var slickgrid = { |
62 | 62 | return slickgrid.grid.getDataItem(row).id; |
63 | 63 | }, |
64 | 64 | |
65 | + get_id: function() { | |
66 | + "use strict"; | |
67 | + return edit.active_id; | |
68 | + }, | |
69 | + | |
65 | 70 | search_counter: 0, |
66 | 71 | |
67 | 72 | scroll_search: function() { |
... | ... | @@ -129,6 +134,18 @@ var slickgrid = { |
129 | 134 | "use strict"; |
130 | 135 | var vp = slickgrid.grid.getViewport(); |
131 | 136 | slickgrid.loader.reloadData(vp.top, vp.bottom); |
137 | + }, | |
138 | + | |
139 | + title_part: function() { | |
140 | + "use strict"; | |
141 | + return slickgrid.grid_caption; | |
142 | + }, | |
143 | + | |
144 | + refresh_title: function() { | |
145 | + "use strict"; | |
146 | + var num = slickgrid.grid.getDataLength(); | |
147 | + document.title = slickgrid.title_part() + | |
148 | + ' – SGJP (' + num + ' ' + slickgrid.counter(num) + ')'; | |
132 | 149 | } |
133 | 150 | }; |
134 | 151 | |
... | ... | @@ -379,7 +396,7 @@ $(function() { |
379 | 396 | slickgrid.skip_cell_changed = false; |
380 | 397 | return; |
381 | 398 | } |
382 | - if (edit.get_id() === slickgrid.active_id()) | |
399 | + if (slickgrid.get_id() === slickgrid.active_id()) | |
383 | 400 | return; |
384 | 401 | if (edit.changed && !edit.confirm_discard()) { |
385 | 402 | setTimeout(function() { |
... | ... | @@ -431,9 +448,7 @@ $(function() { |
431 | 448 | |
432 | 449 | loading_off(); |
433 | 450 | layout.adjust_grid_size(); |
434 | - var num = slickgrid.grid.getDataLength(); | |
435 | - document.title = slickgrid.grid_caption + | |
436 | - ' (' + num + ' ' + slickgrid.counter(num) + ')'; | |
451 | + slickgrid.refresh_title(); | |
437 | 452 | |
438 | 453 | if (slickgrid.set_active_when_loaded !== undefined) { |
439 | 454 | if (location.hash && !common.hash_interpreted) { |
... | ... |
dictionary/static/js/lexeme-edit.js
... | ... | @@ -100,7 +100,7 @@ $.extend(edit, { |
100 | 100 | reload_attributes(); |
101 | 101 | }); |
102 | 102 | $(document).on('click', '#add-row', function () { |
103 | - var id = edit.get_id(); | |
103 | + var id = slickgrid.get_id(); | |
104 | 104 | var new_row = $(get_new_row_html(id)); |
105 | 105 | common.init_selection(new_row.find('.gender')); |
106 | 106 | var pattern_list = $('#pattern-list'); |
... | ... | @@ -117,7 +117,7 @@ $.extend(edit, { |
117 | 117 | edit.show_changed(); |
118 | 118 | }); |
119 | 119 | $(document).on('click', '#add-cr-row', function () { |
120 | - var id = edit.get_id(); | |
120 | + var id = slickgrid.get_id(); | |
121 | 121 | var pos = get_pos(); |
122 | 122 | $.ajaxJSON({ |
123 | 123 | method: 'get', |
... | ... | @@ -438,7 +438,7 @@ $.extend(edit, { |
438 | 438 | description: gettext("Zapisanie zmian"), |
439 | 439 | callback: function (data) { |
440 | 440 | edit.hide_changed(); |
441 | - var edit_id = edit.get_id(); | |
441 | + var edit_id = slickgrid.get_id(); | |
442 | 442 | var grid_id = slickgrid.active_id(); |
443 | 443 | slickgrid.reload_data(); // dziwne miejsce |
444 | 444 | if (edit_id !== grid_id) { |
... | ... | @@ -503,7 +503,7 @@ function create_auto_derivatives() { |
503 | 503 | } |
504 | 504 | chosen_derivatives.push(der_data); |
505 | 505 | }); |
506 | - var edit_id = edit.get_id(); | |
506 | + var edit_id = slickgrid.get_id(); | |
507 | 507 | $.ajaxJSON({ |
508 | 508 | method: 'post', |
509 | 509 | url: $dj.ajax_create_derivatives, |
... | ... | @@ -658,7 +658,7 @@ function join_classifications(clas_ids) { |
658 | 658 | function reload_classifications() { |
659 | 659 | "use strict"; |
660 | 660 | var data = { |
661 | - lexeme_id: edit.get_id(), | |
661 | + lexeme_id: slickgrid.get_id(), | |
662 | 662 | vocab_id: get_owner(), |
663 | 663 | pos: get_pos() |
664 | 664 | }; |
... | ... | @@ -676,7 +676,7 @@ function reload_attributes() { |
676 | 676 | "use strict"; |
677 | 677 | // TODO zachować wartości atrybutów |
678 | 678 | var data = { |
679 | - lexeme_id: edit.get_id(), | |
679 | + lexeme_id: slickgrid.get_id(), | |
680 | 680 | pos: get_pos(), |
681 | 681 | genders: get_gender_ids() |
682 | 682 | }; |
... | ... | @@ -741,7 +741,7 @@ var set_active_lip_row = function () { |
741 | 741 | $(this).addClass('lip-row-active ui-state-active'); |
742 | 742 | // tabelka |
743 | 743 | var data = { |
744 | - lexeme_id: edit.get_id(), | |
744 | + lexeme_id: slickgrid.get_id(), | |
745 | 745 | entry: get_entry(), |
746 | 746 | pos: get_pos(), |
747 | 747 | pattern: $('input.pattern', this).value(), |
... | ... | @@ -762,7 +762,7 @@ var set_active_lip_row = function () { |
762 | 762 | |
763 | 763 | function delete_lexeme() { |
764 | 764 | "use strict"; |
765 | - var id = edit.get_id(); | |
765 | + var id = slickgrid.get_id(); | |
766 | 766 | if (window.confirm(gettext("Na pewno usunąć leksem?"))) { |
767 | 767 | slickgrid.loader.onDataLoading.notify(); |
768 | 768 | $.ajaxJSON({ |
... | ... | @@ -823,7 +823,7 @@ function reload_prompter(arg) { |
823 | 823 | else |
824 | 824 | elem = $('.lip-row-active'); |
825 | 825 | var gender = elem.find('.gender').val(); |
826 | - var id = edit.get_id(); | |
826 | + var id = slickgrid.get_id(); | |
827 | 827 | var cvs = $('#id_cl' + $dj.commonness + '-values').val(); |
828 | 828 | if (!cvs) cvs = []; |
829 | 829 | var gender_check, cv_check, bl_check; |
... | ... | @@ -860,7 +860,7 @@ var set_active_prompter_row = function () { |
860 | 860 | $(this).addClass('prompter-row-active'); |
861 | 861 | // tabelka |
862 | 862 | var data = { |
863 | - lexeme_id: edit.get_id(), | |
863 | + lexeme_id: slickgrid.get_id(), | |
864 | 864 | entry: get_entry(), |
865 | 865 | pos: get_pos(), |
866 | 866 | pattern: $('.pattern', this).text(), |
... | ... | @@ -896,7 +896,7 @@ function check_classifications() { |
896 | 896 | var new_classifications = $.ajaxJSON({ |
897 | 897 | method: 'get', |
898 | 898 | url: $dj.ajax_check_classifications, |
899 | - data: {lexeme_id: edit.get_id(), pos: get_pos(), owner_id: get_owner()}, | |
899 | + data: {lexeme_id: slickgrid.get_id(), pos: get_pos(), owner_id: get_owner()}, | |
900 | 900 | async: false |
901 | 901 | }).classifications; |
902 | 902 | var old_classifications = $('#classifications').find('.classification-values') |
... | ... | @@ -918,7 +918,7 @@ function check_attrs(genders) { |
918 | 918 | var new_attrs = $.ajaxJSON({ |
919 | 919 | method: 'get', |
920 | 920 | url: $dj.ajax_check_attributes, |
921 | - data: {lexeme_id: edit.get_id(), pos: get_pos(), genders: genders}, | |
921 | + data: {lexeme_id: slickgrid.get_id(), pos: get_pos(), genders: genders}, | |
922 | 922 | async: false |
923 | 923 | }).attrs; |
924 | 924 | var old_attrs = $('#extra-attributes').find('select').map(function (i, el) { |
... | ... | @@ -1059,7 +1059,7 @@ function clone_lexeme() { |
1059 | 1059 | $.ajaxJSON({ |
1060 | 1060 | method: 'post', |
1061 | 1061 | url: $dj.ajax_clone_lexeme, |
1062 | - data: {lexeme_id: edit.get_id()}, | |
1062 | + data: {lexeme_id: slickgrid.get_id()}, | |
1063 | 1063 | description: gettext("Sklonowanie leksemu"), |
1064 | 1064 | callback: function(data) { |
1065 | 1065 | slickgrid.reload_data(); |
... | ... | @@ -1074,7 +1074,7 @@ function show_homonym_count() { |
1074 | 1074 | $.ajaxJSON({ |
1075 | 1075 | method: 'get', |
1076 | 1076 | url: $dj.ajax_homonym_count, |
1077 | - data: {entry: entry, lexeme_id: edit.get_id()}, | |
1077 | + data: {entry: entry, lexeme_id: slickgrid.get_id()}, | |
1078 | 1078 | descripton: gettext("Pobranie liczby homonimów"), |
1079 | 1079 | callback: function (data) { |
1080 | 1080 | var info = ''; |
... | ... |
dictionary/static/js/lexeme-view.js
... | ... | @@ -326,7 +326,7 @@ $.extend(slickgrid, { |
326 | 326 | |
327 | 327 | $('#lexeme-tabs').on('tabsactivate', function(e, ui) { |
328 | 328 | if (ui.newPanel.html() === '') { |
329 | - edit.load_tab(ui.newPanel.attr('id'), edit.get_id()); | |
329 | + edit.load_tab(ui.newPanel.attr('id'), slickgrid.get_id()); | |
330 | 330 | } |
331 | 331 | }); |
332 | 332 | }, |
... | ... |
dictionary/static/js/reader-view.js
... | ... | @@ -64,7 +64,7 @@ $(function () { |
64 | 64 | var tab_id = $t.attr('data-tab'); |
65 | 65 | var tab = $('#' + tab_id); |
66 | 66 | if (tab.html() === '') { |
67 | - edit.load_tab(tab_id, edit.get_id()); | |
67 | + edit.load_tab(tab_id, slickgrid.get_id()); | |
68 | 68 | } |
69 | 69 | divs.hide(); |
70 | 70 | tab.show(); |
... | ... | @@ -99,10 +99,6 @@ var edit = { |
99 | 99 | reader: true, |
100 | 100 | changed: false, |
101 | 101 | |
102 | - get_id: function() { | |
103 | - "use strict"; | |
104 | - return edit.active_id; | |
105 | - }, | |
106 | 102 | load_tab: function(tab_id, lexeme_id, check_callback) { |
107 | 103 | "use strict"; |
108 | 104 | var key, callback; |
... | ... | @@ -147,6 +143,8 @@ var edit = { |
147 | 143 | }, |
148 | 144 | callback: function(data) { |
149 | 145 | common.update_hash('' + id + '/' + data.entry); |
146 | + slickgrid.main_field_value = data.entry; | |
147 | + slickgrid.refresh_title(); | |
150 | 148 | } |
151 | 149 | }); |
152 | 150 | var divs = $('#right').children('div'); |
... | ... | @@ -187,4 +185,9 @@ slickgrid.update_sort_button = function(sort_rules) { |
187 | 185 | $('#afronte-button').removeClass('menu-button-active'); |
188 | 186 | } |
189 | 187 | backup_update_sort_button(sort_rules); |
188 | +}; | |
189 | + | |
190 | +slickgrid.title_part = function() { | |
191 | + "use strict"; | |
192 | + return slickgrid.main_field_value || slickgrid.grid_caption; | |
190 | 193 | }; |
191 | 194 | \ No newline at end of file |
... | ... |
patterns/static/js/pattern-reader-view.js
1 | -/* global $dj, getBusyOverlay, common */ | |
1 | +/* global $dj, getBusyOverlay, common, slickgrid, gettext */ | |
2 | 2 | |
3 | 3 | var default_root; |
4 | 4 | |
... | ... | @@ -6,11 +6,6 @@ var edit = { |
6 | 6 | reader: true, |
7 | 7 | changed: false, |
8 | 8 | |
9 | - get_id: function() { | |
10 | - "use strict"; | |
11 | - return edit.active_id; | |
12 | - }, | |
13 | - | |
14 | 9 | load_content: function(id, is_created, check_callback) { |
15 | 10 | "use strict"; |
16 | 11 | $.ajaxJSON({ |
... | ... | @@ -21,6 +16,8 @@ var edit = { |
21 | 16 | }, |
22 | 17 | callback: function(data) { |
23 | 18 | common.update_hash('' + id + '/' + data.name); |
19 | + slickgrid.main_field_value = data.name; | |
20 | + slickgrid.refresh_title(); | |
24 | 21 | } |
25 | 22 | }); |
26 | 23 | $.ajaxJSON({ |
... | ... | @@ -55,6 +52,12 @@ var edit = { |
55 | 52 | } |
56 | 53 | }; |
57 | 54 | |
55 | +slickgrid.title_part = function() { | |
56 | + "use strict"; | |
57 | + return (gettext("Wzór") + ' ' + slickgrid.main_field_value) || | |
58 | + slickgrid.grid_caption; | |
59 | +}; | |
60 | + | |
58 | 61 | $(function() { |
59 | 62 | "use strict"; |
60 | 63 | $(document).on('click', '.switch-example', function () { |
... | ... |