##// END OF EJS Templates
Rewriting gallery mode.
rt@lightning -
r253:b5b2e3a6 default
parent child Browse files
Show More
@@ -1,78 +1,28 b''
1 var image_mode = 0;
1 function addGalleryPanel() {
2 var normal_dom, table_dom;
2 var gallery = $('a[class="thumb"]').clone(true),
3
3 normal = $('.post').clone(true);
4 function add_panel(after)
5 {
6 var nav_top = $(after);
7 if (nav_top.length === 0) return;
8 nav_top = nav_top[0];
9
10 var tab_bar = $('<div class="image-mode-tab" role="radiogroup" aria-label="Image mode"></div>');
11
12 var tab;
13
14 tab = $('<input type="radio" class="image-mode-normal" name="image-mode" value="0" checked="checked"/>');
15 tab.on("change", tab_handler);
16
17 var label_normal = gettext('Normal');
18 tab = $('<label>' + label_normal + '</label>').prepend(tab);
19 tab_bar.append(tab);
20
21 tab = $('<input type="radio" class="image-mode-table" name="image-mode" value="1"/>');
22 tab.on("change", tab_handler);
23
24 var label_gallery = gettext('Gallery');
25 tab = $('<label>' + label_gallery + '</label>').prepend(tab);
26 tab_bar.append(tab);
27
28 tab_bar.insertAfter(nav_top);
29 }
30
31 function tab_handler(ev)
32 {
33 var current_el = $(this);
34
35 if (!current_el.prop('checked')) return;
36
4
37 var new_mode = parseInt(current_el.val(), 10);
5 $('.navigation_panel').filter(':first').after(
38 if (new_mode === image_mode) return;
6 '<div class="image-mode-tab" role="radiogroup" aria-label="Image mode2">' +
39 image_mode = new_mode;
7 '<label><input type="radio" class="image-mode-normal" name="image-mode" value="0" checked="checked"/>'+ gettext('Normal') +'</label>' +
40
8 '<label><input type="radio" class="image-mode-table" name="image-mode" value="1"/>'+ gettext('Gallery') +'</label>' +
41 make_normal_dom();
9 '</div>'
42 make_table_dom();
10 );
43
44 switch(new_mode) {
45 case 0:
46 $('#posts-table').replaceWith(normal_dom);
47 break;
48 case 1:
49 $('#posts').replaceWith(table_dom);
50 break;
51 }
52
11
53 //TODO: Π²Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎ
12 $('input[name="image-mode"]').change(function() {
54 addImgPreview();
13 //gallery mode
55 }
14 if($(this).val() === '1') {
56
15 $('#posts').replaceWith(
57 function make_normal_dom()
16 $('<div id="posts-table"></div>').append(gallery)
58 {
59 if (typeof normal_dom === 'undefined') {
60 normal_dom = $('#posts').clone(true);
61 }
62 }
63
64 function make_table_dom()
65 {
66 if (typeof table_dom !== 'undefined') return;
67
68 table_dom = $('<div id="posts-table"></div>');
69 $('#posts > .post > .image > a').each(
70 function(){
71 table_dom.append(
72 $(this).clone().attr('target', '_blank')
73 );
17 );
74 }
18 }
75 );
19 //normal mode
20 else {
21 $('#posts-table').replaceWith(
22 $('<div id="posts"></div>').append(normal)
23 );
24 }
25 });
76 }
26 }
77
27
78 function moveCaretToEnd(el) {
28 function moveCaretToEnd(el) {
@@ -101,6 +51,6 b' function addQuickReply(postId) {'
101
51
102
52
103 $(document).ready(function(){
53 $(document).ready(function(){
104 add_panel('.navigation_panel');
54 addGalleryPanel();
105 addRefLinkMap();
55 addRefLinkMap();
106 });
56 });
General Comments 0
You need to be logged in to leave comments. Login now