Web · Wiki · Activities · Blog · Lists · Chat · Meeting · Bugs · Git · Translate · Archive · People · Donate
1
<!DOCTYPE HTML>
2
<head>
3
	<meta charset="UTF-8" />
4
	<title>{{_('Welcome to Sugar Network')}}</title>
5
    <script src="/static/js/jquery.tools.min.js"></script>
6
    <script src="/static/js/jquery.history.js"></script>
7
    <script src="/static/js/jquery-ui-1.8.16.sugar.min.js" type="text/javascript"></script>
8
    <link rel="stylesheet" href="/static/css/browser.css" type="text/css" /> 
9
    <link rel="stylesheet" href="/static/css/sugar-theme/jquery-ui-1.8.16.sugar.css" />
10
    <link rel="shortcut icon" href="{{ url_for('static', filename='icons/favicon.ico') }}">
11
    <style>
12
        .sugar-network-online { 
13
            background-color: {{fill}};
14
            border: 4px solid {{stroke}};
15
            border-radius: 15px;
16
            -moz-border-radius: 15px;
17
            -webkit-border-radius: 15px;
18
            padding: 2px;
19
            }
20
        .ui-autocomplete-loading { 
21
            background: white url('/static/images/throbber5.gif') right center no-repeat; 
22
            }
23
        .grid-icon:hover {
24
            color: white;
25
            padding: 28px;
26
            background-color: {{fill}};
27
            border: 4px solid {{stroke}};
28
            border-radius: 15px;
29
            -moz-border-radius: 15px;
30
            -webkit-border-radius: 15px;
31
            z-index: 50; 
32
            }
33
    </style>
34
</head>
35
<body>
36
    {% include 'toolbar.html' %}
37
    <div id="content">
38
    {% block view %}{% endblock view %}
39
    </div>
40
    <div id='bottom-palette'>
41
        {%- block bottom_palette %}
42
        <div id='nav-buttons'>
43
            <a class="prev browse up"></a>
44
            <a class="next browse down"></a>
45
        </div>
46
        {%- endblock bottom_palette %}
47
        <span id="info">{{info}}</span>
48
    </div>
49
    <!--div id="edit-form" class="dialog">
50
            <div class="window-buttons top-out">
51
                <img id="accept-button" class="button window-button" src="/static/icons/dialog-ok.png" />
52
                <img id="cancel-button" class="button window-button" src="/static/icons/dialog-cancel.png" />
53
            </div>
54
        <form method="POST" action="/submit_edit">
55
            <input name="resource-type" type="hidden" value="" />
56
            <input name="guid" type="hidden" value="" />
57
            <input id="edit-title" name="title" class="resource-input" type="text" value="" />
58
            <textarea id="edit-description" class="resource-input" name="description"></textarea>
59
        </form>
60
    </div-->
61
    <div class="dialog" id="mejorar-sistema-form">
62
        <div id="resource-card-title">
63
            <span id="dialog-title">{{_('Improve the system')}} : {{session.get('last_context_title') or _('Sugar Network')}}</span>
64
            <div class="window-buttons">
65
                <img id="cancel-button" class="button window-button" src="/static/icons/dialog-cancel.png" />
66
                <img id="accept-button" class="button window-button" src="/static/icons/dialog-ok.png" />
67
            </div>
68
        </div>
69
        <form id="resource-form1" method="POST" action="/submit_resource">
70
        <div class="resource-form-field">
71
            <span id="title_label">{{_('Title')}}</span><br/> 
72
            <input name="guid" type="hidden" value="{{session['last_context']}}" />
73
            <input onkeypress="return event.keyCode != 13;" name="title" class="resource-input" type="text"/>
74
            <input id="resource_type" name="resource_type" type="hidden" value="" />
75
            <input id="href" name="href" type="hidden" value="" />
76
            <input id="edit_guid" name="edit_guid" type="hidden" value="" />
77
        </div>
78
        <div class="resource-form-field" id="summary_section">
79
            <span id="summary_label">{{_('Summary')}}</span><br/> 
80
            <input onkeypress="return event.keyCode != 13;" name="summary" class="resource-input" type="text"/>
81
        </div>
82
        <div class="resource-form-field">
83
            <span id="details_label">{{_('Details')}}</span><br/>
84
            <textarea name="content" class="resource-inputarea" ></textarea>
85
        </div>
86
        </form>
87
        <div id="submit-buttons">
88
            <img class="question-button button" src="/static/icons/emblem-question.png" />
89
            <br />
90
            <img class="idea-button button" src="/static/icons/emblem-charging.png" />
91
            <br />
92
            <img class="problem-button button" src="/static/icons/emblem-notification.png" />
93
        </div>
94
    </div>
95
    <script type="text/javascript">
96
    {%- block script %}
97
        var oldh;
98
        var oldw;
99
100
        (function(window,undefined){   
101
            // Prepare History.js
102
            var History = window.History; // Note: We are using a capital H instead of a lower h
103
            if ( !History.enabled ) {
104
                 // History.js is disabled for this browser.
105
                 // This is because we can optionally choose to support HTML4 browsers or not.
106
                return false;
107
            }
108
        })(window);
109
110
        function new_context(resource_type, guid, content, title) {
111
            dialog = $('#mejorar-sistema-form');
112
            oldh = dialog.css('height');
113
            oldw = dialog.css('width');
114
            dialog.css('height', '450px');
115
            dialog.css('width', '700px');
116
            $('#summary_section').css('height', '73px');
117
            $('#summary_section').css('padding', '7px 20px');
118
            $('#dialog-title').empty().append('{{_("Create new context")}}');
119
            $('#title_label').empty().append('{{_("Name")}}');
120
            $('#details_label').empty().append('{{_("Article (optional)")}}');
121
            $('textarea.resource-inputarea').css('height', '170px');
122
            dialog.expose({
123
                closeOnClick: false, 
124
                onBeforeClose: function(event) {
125
                    dialog.fadeOut(
126
                        function () {
127
                            dialog.css('height', oldh);
128
                            dialog.css('width', oldw);
129
                            $('#title_label').empty().append('{{_("Title")}}');
130
                            $('#details_label').empty().append('{{_("Details")}}');
131
                            $('#summary_section').css('height', '0px');
132
                            $('#summary_section').css('padding', '0px 0px');
133
                            $('textarea.resource-inputarea').css('height', '100px');
134
                        }
135
                    );
136
                    } 
137
                });
138
            dialog.fadeIn();
139
            $('input.resource-input').val(title);
140
            $('input#resource_type').val(resource_type);
141
            $('input#edit_guid').val(guid);
142
            $('input#href').val(location.href);
143
            $('input.resource-input').focus();
144
            $('textarea.resource-inputarea').val(content);
145
146
            $('#submit-buttons').hide();
147
            $('#accept-button').show();
148
            if (title==false) {
149
                $('input.resource-input').parent().hide();
150
                $('#details_label').hide();
151
                $('input.resource-input').val('');
152
                }
153
            else {
154
                $('#details_label').show();
155
                $('input.resource-input').parent().show();
156
                }
157
            $('#accept-button').click( function () {
158
                $("#resource-form1").attr('action', '/submit_context');
159
                $("#resource-form1").submit();
160
                $('#mejorar-sistema-form').fadeOut();
161
                });
162
                
163
            $('#cancel-button').click( function () {
164
                $('#mejorar-sistema-form').fadeOut();
165
                $.mask.close();
166
                });
167
            }
168
169
        function edit_resource(resource_type, guid, content, title) {
170
            dialog = $('#mejorar-sistema-form');
171
            $('#dialog-title').empty().append('{{_("Edit resource")}}');
172
            dialog.expose({
173
                closeOnClick: false, 
174
                onBeforeClose: function(event) {
175
                    dialog.fadeOut();
176
                    } 
177
                });
178
            dialog.fadeIn();
179
            $('input.resource-input').val(title);
180
            $('input#resource_type').val(resource_type);
181
            $('input#edit_guid').val(guid);
182
            $('input#href').val(location.href);
183
            $('input.resource-input').focus();
184
            $('textarea.resource-inputarea').val(content);
185
186
            $('#submit-buttons').hide();
187
            $('#accept-button').show();
188
            if (title==false) {
189
                $('input.resource-input').parent().hide();
190
                $('#details_label').hide();
191
                $('input.resource-input').val('');
192
                }
193
            else {
194
                $('#details_label').show();
195
                $('input.resource-input').parent().show();
196
                }
197
            $('#accept-button').click( function () {
198
                $("#resource-form1").attr('action', '/submit_edit');
199
                $("#resource-form1").submit();
200
                $('#mejorar-sistema-form').fadeOut();
201
                });
202
                
203
            $('#cancel-button').click( function () {
204
                $('#mejorar-sistema-form').fadeOut();
205
                $.mask.close();
206
                });
207
            }
208
209
        function improve_the_system(context_guid) {
210
            if (context_guid=='None') {
211
                context_guid='sugar-network'; }
212
            $('#mejorar-sistema-form').expose({
213
                closeOnClick: false, 
214
                onBeforeClose: function(event) {
215
                    $('#mejorar-sistema-form').fadeOut();
216
                    } 
217
                });
218
            $('#dialog-title').empty().append('{{_('Improve the system')}} : {{session.get('last_context_title') or _('Sugar Network')}}')
219
            $('#mejorar-sistema-form').fadeIn();
220
            $('#submit-buttons').show();
221
            $('#accept-button').hide();
222
            $('input.resource-input').parent().show();
223
            $('#details_label').show();
224
            $('input.resource-input').focus();
225
            /*$('#mejorar-sistema-form').animate({
226
                right:'20px' }, 'slow');*/
227
            $('#cancel-button').click( function () {
228
                $('#mejorar-sistema-form').fadeOut();
229
                $.mask.close();
230
                });
231
            $(".question-button").click(function() {
232
                $("#resource-form1").attr('action', '/submit_resource/question');
233
                $("#resource-form1").submit();
234
                $('#mejorar-sistema-form').fadeOut();
235
                });
236
            $(".idea-button").click(function() {
237
                $("#resource-form1").attr('action', '/submit_resource/idea');
238
                $("#resource-form1").submit();
239
                $('#mejorar-sistema-form').fadeOut();
240
                });
241
            $(".problem-button").click(function() {
242
                $("#resource-form1").attr('action', '/submit_resource/problem');
243
                $("#resource-form1").submit();
244
                $('#mejorar-sistema-form').fadeOut();
245
                });
246
        }
247
248
        var _selected = false;
249
        var _query = false;
250
        /* var source = new EventSource('/_events/comment');
251
        source.onmessage = function(e) {
252
            alert('DEBUG: got event');
253
            var last_event = e;
254
            alert(e.data);
255
            };  */
256
        function init_styles(inactive_color) {
257
            if (inactive_color == null){
258
               inactive_color = '#c9c9c9';
259
                }
260
            /* $('.star-emblem').hover( function() {
261
                $(this).css('background-color','{{fill}}');
262
                $(this).css('border','1px solid {{stroke}}');
263
            }, function() {
264
                $(this).css('background-color', '#fff');
265
                $(this).css('border','1px solid #fff');
266
                });
267
            $('.moon-emblem').hover( function() {
268
                $(this).css('background-color','{{fill}}');
269
                $(this).css('border','1px solid {{stroke}}');
270
            }, function() {
271
                $(this).css('background-color', '#fff');
272
                $(this).css('border','1px solid #fff');
273
                }); */
274
            $('.grid-icon').hover( function() {
275
                    /* FIXME messy*/
276
                    $(this).parent().parent().parent().find('img:first').css('background-color', '#c5c5c5');
277
                    $(this).parent().parent().parent().find('img:eq(1)').css('background-color', '#c5c5c5');
278
                    $(this).parent().parent().parent().find('img:eq(2)').css('background-color', '#c5c5c5');
279
                    $(this).parent().parent().parent().find('img:eq(3)').css('background-color', '#c5c5c5');
280
                    $(this).parent().parent().parent().find('img:eq(4)').css('background-color', '#c5c5c5');
281
                    $(this).parent().parent().parent().find('img:eq(5)').css('background-color', '#c5c5c5');
282
                    $('.button_selected').css('background-color', "#282828");
283
                }, function() {
284
                    $(this).parent().parent().parent().find('img:first').css('background-color', inactive_color);
285
                    $(this).parent().parent().parent().find('img:eq(1)').css('background-color', inactive_color);
286
                    $(this).parent().parent().parent().find('img:eq(2)').css('background-color', inactive_color);
287
                    $(this).parent().parent().parent().find('img:eq(3)').css('background-color', inactive_color);
288
                    $(this).parent().parent().parent().find('img:eq(4)').css('background-color', inactive_color);
289
                    $(this).parent().parent().parent().find('img:eq(5)').css('background-color', inactive_color);
290
                    $('.button_selected').css('background-color', "#282828");
291
                });
292
            $('.question-icon').css('background-color', inactive_color);
293
            $('.question-icon').hover( function() {
294
                    $(this).css('background-color', '#808080');
295
                }, function() {
296
                    $(this).css('background-color', inactive_color);
297
                });
298
            $('.idea-icon').css('background-color', inactive_color);
299
            $('.idea-icon').hover( function() {
300
                    $(this).css('background-color', '#808080');
301
                }, function() {
302
                    $(this).css('background-color', inactive_color);
303
                });
304
            $('.problem-icon').css('background-color', inactive_color);
305
            $('.problem-icon').hover( function() {
306
                    $(this).css('background-color', '#808080');
307
                }, function() {
308
                    $(this).css('background-color', inactive_color);
309
                });
310
            $('.review-icon').css('background-color', inactive_color);
311
            $('.review-icon').hover( function() {
312
                    $(this).css('background-color', '#808080');
313
                }, function() {
314
                    $(this).css('background-color', inactive_color);
315
                });
316
            $('.gallery-icon').css('background-color', inactive_color);
317
            $('.gallery-icon').hover( function() {
318
                    $(this).css('background-color', '#808080');
319
                }, function() {
320
                    $(this).css('background-color', inactive_color);
321
                });
322
            $('.wiki-icon').css('background-color', inactive_color);
323
            $('.wiki-icon').hover( function() {
324
                    $(this).css('background-color', '#808080');
325
                }, function() {
326
                    $(this).css('background-color', inactive_color);
327
                });
328
            // Make sure selected resource is highlighted
329
            resource='.{{resource_type}}';
330
            $(resource+'-icon').css('background-color', "#808080");
331
            $(resource+'-icon').unbind('mouseenter mouseleave');
332
            $('.button_selected').css('background-color', "#282828");
333
            $('.button_selected').unbind('mouseenter mouseleave');
334
            //
335
            $('.star-emblem').click( function() {
336
                if ( $(this).data('keep') == true) {
337
                    $(this).css('background-color', '#fff');
338
                    $(this).css('border','1px solid #fff');
339
                    $(this).data('keep', false);
340
                    }
341
                else {
342
                    $(this).css('background-color','{{fill}}');
343
                    $(this).css('border','1px solid {{stroke}}');
344
                    $(this).data('keep', true);
345
                    }
346
                $.get('/_stars/' + $(this).attr("id") + '?keep=' +
347
                    $(this).data('keep'),
348
                    function (data) {/* alert (data.keep) */} );
349
                });
350
            $('.moon-emblem').click( function() {
351
                if ( $(this).data('keep_impl') == true) {
352
                    $(this).css('background-color', '#fff');
353
                    $(this).css('border','1px solid #fff');
354
                    $(this).data('keep_impl', false);
355
                    }
356
                else {
357
                    $(this).css('background-color','{{fill}}');
358
                    $(this).css('border','1px solid {{stroke}}');
359
                    $(this).data('keep_impl', true);
360
                    }
361
                $.get('/_moon/' + $(this).attr("id") + '?keep_impl=' +
362
                    $(this).data('keep_impl'),
363
                    function (data) {/* alert (data.keep) */} );
364
                });
365
        };
366
    /* For deleting elements from tag palette */
367
    function bind_del () {
368
        $('.tag').click( function () {
369
            $(this).fadeOut();
370
            $.ajax({
371
                url: '/_tags/'+$(this).html(),
372
                type: 'DELETE',
373
                success: function(result) {
374
                    location.reload();
375
                    }
376
                });
377
            });
378
        }
379
   $(document).ready( function() {
380
        bind_del(); 
381
        $( "#sn-button" ).tooltip({position:"bottom right", offset:[-3,-60], predelay:500});
382
        $( "#browser-button" ).tooltip({position:"bottom right", offset:[-3,-60], predelay:500});
383
        /*$( "#list-button" ).tooltip({position:"bottom right", offset:[-3,-60], predelay:500});*/
384
        $( "#query" ).autocomplete({
385
            source: "/query",
386
            dataType: "json",
387
            minLength: 2,
388
            change: function( ev ) {
389
                var term = $('#query').val();
390
                _query = term;
391
                if(ev.keyCode == 13) {
392
                    location='/context/search/'+term;
393
                    }
394
                },
395
            select: function( ev, ui ) {
396
                var e = ev || event;
397
                _selected = true;
398
                var term = $('#query').val();
399
                location='/context/reviews/'+ui.item.value;
400
                return false;
401
                },
402
            focus: function (ev, ui) {
403
                return false;
404
                },
405
            search: function (ev, ui) {
406
                var term = $('#query').val();
407
                if (term.indexOf(' ')!=-1) {
408
                    $('#query').autocomplete('close');
409
                    return false;
410
                    }
411
                }
412
            }
413
        );
414
        $( "#query" ).keyup(onKeyPressed);
415
    });
416
417
    function onKeyPressed(ev) {
418
        var e = ev || event;
419
        var term = $('#query').val();
420
        if(e.keyCode == 13 && _selected==false) {
421
            location='/context/search/'+term;
422
            /* For adding tag filters */
423
            /** if (term[0]=='#') {
424
                /* Send the data using post *
425
                $('#query').val('{{query or ''}}');
426
                $.post( '/_tags', { tag:term },
427
                  function( data ) {
428
                    $( "#tags-section" ).empty().append( data );
429
                    /* bind_del(); *
430
                    location.reload();
431
                  }
432
                );
433
                } 
434
            else {
435
                /* location='/resource/{{resource_type}}s/'+term; *
436
                location='/context/search/'+term;
437
                }*/
438
            return false; //prevents form from being submitted.
439
        }
440
    }
441
    {%- endblock script %}
442
    </script>
443
</body>
444
</html>