src/cm/media/js/site/f_text_view_frame.js
author gibus
Thu, 28 Nov 2013 09:11:51 +0100
changeset 565 95a5c06c4008
parent 553 bf26fb47a14c
child 600 fda73ac53450
permissions -rw-r--r--
With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     1
var gResetOtherFieldsOnFilterFieldChange = true;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     2
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
     3
var myDefaultOuterLayoutSettings = {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
     4
  center : {
553
bf26fb47a14c To allow scrolling in Safari mobile, we set the content of text_view_comments frame in a jQuery UI layout.
Simon Descarpentries <sid@sopinspace.com>
parents: 536
diff changeset
     5
    paneSelector : '#outer-center'
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
     6
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
     7
  north : {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
     8
    size :50,//30,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
     9
    spacing_open :0,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    10
    closable :false,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    11
    resizable :false
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    12
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    13
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    14
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    15
var innerNorthPaneDefaults = {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    16
  'innerNorthPaneOpened' :'0',
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    17
  'selectedTab' :'0'
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    18
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    19
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    20
onInnerNorthPaneClose = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    21
  _setCookie('innerNorthPaneOpened', '0');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    22
  $('#add_comment_btn').css('top', 63) ;
425
d70552fc1a66 Fix some javascript error with IE8 (getElementsByClassName() is unknown).
gibus
parents: 424
diff changeset
    23
  if (document.getElementById('text_view_comments').contentDocument != null)
d70552fc1a66 Fix some javascript error with IE8 (getElementsByClassName() is unknown).
gibus
parents: 424
diff changeset
    24
    document.getElementById('text_view_comments').contentDocument.getElementById('the-toc').style.height = (parseInt(document.getElementById('text_view_comments').clientHeight) - 50).toString() + 'px';
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    25
  return true;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    26
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    27
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    28
onInnerNorthPaneOpen = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    29
  _setCookie('innerNorthPaneOpened', '1');
534
2ee166f109ae Filter pane should have bigger height to display category dropdown list.
gibus
parents: 532
diff changeset
    30
  $('#add_comment_btn').css('top', 159) ;
425
d70552fc1a66 Fix some javascript error with IE8 (getElementsByClassName() is unknown).
gibus
parents: 424
diff changeset
    31
  if (document.getElementById('text_view_comments').contentDocument != null)
d70552fc1a66 Fix some javascript error with IE8 (getElementsByClassName() is unknown).
gibus
parents: 424
diff changeset
    32
    document.getElementById('text_view_comments').contentDocument.getElementById('the-toc').style.height = (parseInt(document.getElementById('text_view_comments').clientHeight) - 50).toString() + 'px';
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    33
  return true;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    34
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    35
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    36
// DEFAULT LAYOUT SETTINGS
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    37
var myDefaultInnerLayoutSettings = {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    38
  north : {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    39
    // size: 66, /* 66 for FF */
534
2ee166f109ae Filter pane should have bigger height to display category dropdown list.
gibus
parents: 532
diff changeset
    40
    size :98, /* 66 for FF */
383
661248a4ef4a add arrows on toggle bars
gibus
parents: 368
diff changeset
    41
    spacing_open :8,
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    42
    spacing_closed :8,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    43
    slidable :false,    
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    44
    resizable :false, /* important */
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    45
    togglerLength_closed :"100%",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    46
    togglerLength_open :"100%",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    47
    togglerAlign_closed :"center",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    48
    togglerTip_closed :gettext("click to show options"),
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    49
    togglerTip_open :gettext("click to hide options"),
385
c67ddb086074 better use images for arrows on toggle bar to avoid font size dofferences and ut8 non-compatible browsers
gibus
parents: 383
diff changeset
    50
    togglerContent_open :"<img alt='arrow up' src='" + sv_media_url + "img/arrow-up.png' />",
c67ddb086074 better use images for arrows on toggle bar to avoid font size dofferences and ut8 non-compatible browsers
gibus
parents: 383
diff changeset
    51
    togglerContent_closed :"<img alt='arrow down' src='" + sv_media_url + "img/arrow-down.png' />",
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    52
    initClosed :false,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    53
    paneSelector :".inner-north",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    54
    onopen :"onInnerNorthPaneOpen",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    55
    onclose :"onInnerNorthPaneClose"
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    56
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    57
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    58
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    59
var outerLayout, innerLayout;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    60
layoutFrames = function() {
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    61
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    62
  var innerNorthPaneOpened = $.cookie('innerNorthPaneOpened');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    63
  myDefaultInnerLayoutSettings.north.initClosed = (innerNorthPaneOpened === null) ? (innerNorthPaneDefaults['innerNorthPaneOpened'] == '0')
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    64
      : (innerNorthPaneOpened == "0");
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    65
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    66
  outerLayout = $('body').layout(myDefaultOuterLayoutSettings);
553
bf26fb47a14c To allow scrolling in Safari mobile, we set the content of text_view_comments frame in a jQuery UI layout.
Simon Descarpentries <sid@sopinspace.com>
parents: 536
diff changeset
    67
  innerLayout = $('#outer-center').layout(myDefaultInnerLayoutSettings);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    68
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    69
  // to trigger add_comment_btn positioning
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    70
  if (myDefaultInnerLayoutSettings.north.initClosed)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    71
    onInnerNorthPaneClose() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    72
  else 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    73
    onInnerNorthPaneOpen() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    74
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    75
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
    76
fillFilterTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    77
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    78
  var tab = $('#c_filter');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    79
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    80
  var html = '<div style="float:right">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    81
        '<table>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    82
          '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    83
          '<td style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    84
          gettext('Text') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    85
        '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    86
        '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    87
          '<input id="filter_text" type="text"></input>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    88
          '<input id="c_filter_btn" type="button" value="' + gettext('Search') + '"></input>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    89
        '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    90
          '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    91
          '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    92
            '<td colspan="3" style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    93
              '<input id="c_filterreset_btn" type="button" value="' + gettext('Reset') + '"></input>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    94
              '<input id="c_filterhideall_btn" type="button" value="' + gettext('Hide all Comments') + '"></input>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    95
            '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    96
          '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    97
        '</table>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    98
      '</div>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
    99
      '<table>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   100
        '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   101
          '<td style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   102
          gettext('Authors') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   103
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   104
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   105
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   106
            '<select id="filter_name"></select>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   107
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   108
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   109
          '<td style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   110
          gettext('States') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   111
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   112
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   113
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   114
            '<select id="filter_state"></select>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   115
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   116
        '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   117
        '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   118
          '<td style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   119
            gettext('Dates') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   120
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   121
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   122
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   123
            '<select id="filter_date"></select>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   124
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   125
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   126
          '<td style="text-align:right;">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   127
            gettext('Tags') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   128
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   129
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   130
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   131
            '<select id="filter_tag"></select>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   132
          '</td>' +
528
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   133
        '<tr>' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   134
          '<td style="text-align:right;"><span id="filter_cat_label">' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   135
          gettext('Categories') +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   136
          '</span></td>' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   137
          '<td>&nbsp;</td>' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   138
          '<td>' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   139
            '<select id="filter_cat"></select>' +
cbe216651b19 Resize filters for small screen.
Production Moz <dev@sopinspace.com>
parents: 525
diff changeset
   140
          '</td>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   141
        '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   142
      '</table>';
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   143
  tab.append($(html));  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   144
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   145
  $("#c_filter input[type='text']").add("#c_filter select").addClass('c_filter_field') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   146
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   147
  $("#filter_name").add("#filter_date").add("#filter_tag").add("#filter_cat").add("#filter_state").change(function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   148
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   149
      var elt = $(this) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   150
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   151
        //console.info($(this)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   152
        //console.info(elt) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   153
        //applyFilter($(this)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   154
        applyFilter(elt) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   155
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   156
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   157
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   158
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   159
  $("#c_filter_btn").click(function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   160
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   161
      var elt = $("#filter_text") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   162
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   163
        applyFilter(elt) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   164
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   165
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   166
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   167
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   168
  $('#filter_text').keyup( function(e) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   169
    if (e.keyCode == 13) {$("#c_filter_btn").click();}
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   170
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   171
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   172
  $("#c_filterreset_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   173
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   174
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   175
        resetFilter();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   176
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   177
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   178
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   179
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   180
  $("#c_filterhideall_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   181
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   182
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   183
        frames['text_view_comments'].hideAll() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   184
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   185
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   186
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   187
  
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   188
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   189
fillTopToolbar = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   190
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   191
  var parent = $('#outer-north');
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   192
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   193
  var viewPrev = gettext('view previous comment') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   194
  var viewNext = gettext('view next comment') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   195
  var viewFirst = gettext('view first comment') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   196
  var viewLast = gettext('view last next comment') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   197
  var viewAll = gettext('view all comments') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   198
  var viewScopeRemoved = gettext('view all detached comments') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   199
  var advancedInterface = gettext('toggle advance interface') ;
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   200
  var toggleToc = gettext('toggle table of contents') ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   201
  var print = gettext('print document with/without comments') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   202
  var exportDoc = gettext('export document with/without comments') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   203
  var fullscreen = gettext('toggle full screen view') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   204
  var feed = gettext('text feed') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   205
  var addComment = gettext('add a comment') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   206
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   207
  var html = '<div id="c-right-btn">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   208
            '<img id="c_fullscreen_btn" src="' + sv_media_url + '/img/arrow_out.png" title="'+ fullscreen +'" alt="'+ fullscreen +'"/>' +      
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   209
            '<img id="c_print_btn" src="' + sv_media_url + '/img/printer.png" title="'+ print +'" alt="'+ print +'"/>' +         
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   210
            '<img id="c_export_btn" src="' + sv_media_url + '/img/page_go.png" title="'+ exportDoc +'" alt="'+ exportDoc +'"/>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   211
            '<a target="_blank" href="' + frames['text_view_comments'].sv_text_feed_url + '"><img id="c_feed_btn" src="' + sv_media_url + '/img/feed.png" title="'+ feed +'" alt="'+ feed +'"/></a>' +         
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   212
          '</div>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   213
        '<div id="c-msg-wrapper">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   214
      '</div>' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   215
      '<table style="margin-bottom:.3em;">' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   216
      '<tbody>' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   217
      '<tr>' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   218
      '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   219
        '<span id="c_filter_results" >' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   220
          '<span id="c_browse_indx_scope">-</span>' +
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   221
          '<span id="c_browse_indx_modif_thread" style="display: none;">-</span>' +
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   222
          '/' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   223
        '<b>&nbsp;<span id="c_f_res_nb_dis"></span></b>&nbsp;<span id="c_f_res_nb_dis_txt"></span>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   224
        '<span id="c_f_res_details">&nbsp;(' + gettext('filter:') + '&nbsp;<span id="c_f_res_nb_com"></span>/<span id="c_f_res_nb_tot_com"></span>&nbsp;<span id="c_f_res_nb_com_txt"></span>&nbsp;<span id="c_f_res_nb_rep"></span>/<span id="c_f_res_nb_tot_rep"></span><span id="c_f_res_nb_rep_txt"></span>)</span>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   225
        '</span>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   226
      '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   227
      '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   228
      '<span id="browse_section">' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   229
      ', ' + gettext('browse by:') + ' ' + 
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   230
        '<select id="browse_by" style="margin-right: 7px;">' + 
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   231
        '<option value="scope">' + gettext('location') + '</option>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   232
        '<option value="modif_thread">' + gettext('modification') + '</option>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   233
        '</select>' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   234
      '</span>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   235
      '</td>' + 
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   236
      '<td style="width: 40px; text-align: right;">' + 
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   237
        '<a href="#" id="c_browse_first"><img title="'+ viewFirst +'" alt="'+ viewFirst +'" src="' + sv_media_url + '/img/control_fastbackward_blue.png"/></a>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   238
        '<a href="#" id="c_browse_prev"><img title="'+ viewPrev +'" alt="'+ viewPrev +'" src="' + sv_media_url + '/img/control_playback_blue.png" style="margin-right: 3px;"/></a>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   239
      '</td>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   240
      '<td style="width: 44px; text-align: left; border-right: 1px dotted #b1b1b1;">' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   241
        '<a href="#" id="c_browse_next"><img title="'+ viewNext +'" alt="'+ viewNext +'" src="' + sv_media_url + '/img/control_play_blue.png"/></a>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   242
        '<a href="#" id="c_browse_last"><img title="'+ viewLast +'" alt="'+ viewLast +'" src="' + sv_media_url + '/img/control_fastforward_blue.png"/></a>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   243
      '</td>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   244
      '<td style="width: 20px; text-align: left;">' +
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   245
      '<a href="#" id="c_browse_all"><img title="'+ viewAll +'" alt="'+ viewAll +'" src="' + sv_media_url + '/img/view_all.png" style="margin-left: 11px; margin-right: 8px;" /></a>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   246
      '</td>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   247
      '<td style="width: 20px; text-align: left;">' +
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   248
      '<a href="#" id="c_browse_scope_removed"><img title="'+ viewScopeRemoved +'" alt="'+ viewScopeRemoved +'" src="' + sv_media_url + '/img/view_scope_removed2.png" style="margin-top: -8px; margin-right: 3px;" /></a>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   249
      '</td>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   250
      '<td style="width: 20px; text-align: left;">' +
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   251
        '<a href="#" id="c_thread_unthread"><img id="c_thread_unthread_img" style="margin-right: 8px;"/></a>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   252
      '</td>' +
485
af74b898d551 New icons.
gibus
parents: 474
diff changeset
   253
      '<td style="width: 20px; text-align: left;">' +
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   254
        '<a href="#" id="c_toc_btn"><img title="'+ toggleToc +'" alt="'+ toggleToc +'" src="' + sv_media_url + '/img/document_index.png"/></a>' +
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   255
      '</td>' +
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   256
      '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   257
      '</tbody>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   258
      '</table>' ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   259
  parent.prepend($(html));
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   260
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   261
  $("#add_comment_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   262
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   263
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   264
        frames['text_view_comments'].gSync.showCommentForm(null) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   265
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   266
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   267
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   268
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   269
  var showBrowseIndx = function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   270
    $("#browse_by option").each(function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   271
      $("#c_browse_indx_"+this.value).hide() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   272
    }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   273
    $('#c_browse_indx_' + $('#browse_by').val()).show() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   274
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   275
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   276
  var first_browse_by_val = $.cookie('browse_by');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   277
  first_browse_by_val = (first_browse_by_val == null) ? "location" : first_browse_by_val ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   278
  _setCookie('browse_by', $('#browse_by').val());
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   279
  $("#browse_by option[value="+ first_browse_by_val +"]").prop("selected", true);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   280
  showBrowseIndx() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   281
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   282
  $("#browse_by").change(function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   283
    _setCookie('browse_by', $('#browse_by').val());
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   284
    showBrowseIndx() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   285
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   286
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   287
  var lBrowse = function(whereto) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   288
    if (frames['text_view_comments'].readyForAction()) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   289
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   290
        frames['text_view_comments'].browse($('#browse_by').val(), whereto); 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   291
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   292
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   293
  $("#c_browse_prev").click( function() {lBrowse("prev");});
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   294
  $("#c_browse_next").click( function() {lBrowse("next");});
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   295
  $("#c_browse_first").click( function() {lBrowse("first");});
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   296
  $("#c_browse_last").click( function() {lBrowse("last");});
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   297
  $("#c_browse_all").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   298
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   299
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   300
        frames['text_view_comments'].gSync.showAllComments() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   301
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   302
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   303
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   304
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   305
  $("#c_browse_scope_removed").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   306
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   307
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   308
        frames['text_view_comments'].gSync.showScopeRemovedComments() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   309
      }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   310
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   311
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   312
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   313
  $("#c_print_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   314
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   315
      var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   316
      frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   317
      openPrintDialog() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   318
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   319
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   320
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   321
  $("#c_export_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   322
    if (frames['text_view_comments'].readyForAction()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   323
      var ids = frames['text_view_comments'].gDb.getFilteredCommentIdsAsString() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   324
      frames['text_view_comments'].CY.log($("#filteredIds").val(ids)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   325
      openExportDialog() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   326
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   327
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   328
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   329
  if (frames['text_view_comments'].gLayout.isInComentSite()) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   330
    $("#c_fullscreen_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   331
        toggleFrameSize();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   332
    });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   333
  } ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   334
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   335
  $("#c_advanced_btn").click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   336
    $('.ui-layout-toggler').click() ; // calling the layout method did not work well edo that instead   
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   337
  }) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   338
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   339
  setThreadPref = function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   340
    var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad');
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   341
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   342
    var btn_src = sv_media_url + '/img/unthread_box.png' ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   343
    var btn_desc = gettext('unthread discussions') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   344
    if (v == '0') { 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   345
      btn_src = sv_media_url + '/img/thread_box.png' ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   346
      btn_desc = gettext('thread discussions') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   347
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   348
    $('#c_thread_unthread_img').attr('src', btn_src).attr('alt', btn_desc).attr('title', btn_desc) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   349
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   350
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   351
  setThreadPref();  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   352
  $('#c_thread_unthread').click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   353
    var v = frames['text_view_comments'].c_readPreference('comments', 'threadpad');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   354
    var anti_v = (v == '0') ? '1' : '0';
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   355
    frames['text_view_comments'].c_persistPreference('comments', 'threadpad', anti_v);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   356
    setThreadPref();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   357
    frames['text_view_comments'].gSync.animateToTop() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   358
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   359
  
421
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   360
  $("#c_toc_btn").click( function() {
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   361
    if (frames['text_view_comments'].readyForAction()) {
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   362
      frames['text_view_comments'].checkForOpenedDialog(null, function() {
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   363
        frames['text_view_comments'].toggleTocFn() ;
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   364
      }) ;
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   365
    }
3ddbfa64f596 Adds a table of content.
gibus
parents: 385
diff changeset
   366
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   367
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   368
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   369
onSliderStop = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   370
  var slideVal = $("#c_slider").slider('value') ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   371
//  console.info("in onSliderStop slider val : " + slideVal) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   372
  if (slideVal > (frames['text_view_comments'].gConf['sliderFixedMin'] * 100)) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   373
    $("#c_slider").slider('value', [90]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   374
  if (slideVal < (frames['text_view_comments'].gConf['sliderFixedMax'] * 100)) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   375
    $("#c_slider").slider('value', [10]) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   376
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   377
  frames['text_view_comments'].c_setCommentsColWidth(slideVal) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   378
  frames['text_view_comments'].c_persistPreference('layout', 'comments_col_width', slideVal);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   379
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   380
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   381
fillTextPreferencesTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   382
  var tab = $('#c_text_preferences');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   383
  tab.append($(
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   384
      '<table>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   385
      '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   386
      '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   387
      gettext('Text style') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   388
      '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   389
      '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   390
      '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   391
      '<select id="c_textpref_style"></select>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   392
      '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   393
      '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   394
      '</table>')) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   395
  var styles = frames['text_view_comments'].gTextStyles ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   396
  for (var key in styles) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   397
    $("#c_textpref_style").append($("<option value='"+ key +"'>" + styles[key] + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   398
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   399
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   400
  var setTextStyle = function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   401
    var styles = frames['text_view_comments'].gTextStyles ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   402
    var wish = $('#c_textpref_style').val() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   403
    for (var key in styles) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   404
      if (key == wish)
532
0bad3613f59d Reverse to YUI 3.0.0 since with YUI.3.10.3, comment content including words 'paragraph' or 'section' do not show up on Firefox, this is weird and has to be investigated.
gibus
parents: 528
diff changeset
   405
        frames['text_view_comments'].CY.get("#textcontainer").addClass(key) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   406
      else 
532
0bad3613f59d Reverse to YUI 3.0.0 since with YUI.3.10.3, comment content including words 'paragraph' or 'section' do not show up on Firefox, this is weird and has to be investigated.
gibus
parents: 528
diff changeset
   407
        frames['text_view_comments'].CY.get("#textcontainer").removeClass(key) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   408
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   409
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   410
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   411
  var setTextStyleField = function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   412
    var v = frames['text_view_comments'].c_readPreference('text', 'style');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   413
    $('#c_textpref_style').val(v);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   414
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   415
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   416
  $("#c_textpref_style").change(function(v) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   417
    frames['text_view_comments'].c_persistPreference('text', 'style', $("#c_textpref_style").val());
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   418
    setTextStyle();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   419
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   420
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   421
  setTextStyleField();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   422
  setTextStyle();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   423
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   424
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   425
fillPreferencesTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   426
  var tab = $('#c_preferences');
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   427
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   428
  var html = '<div style="float:right"><input id="c_pref_save_btn" type="button" value="' + gettext('Save') + '"></input><input id="c_pref_reset_btn" type="button" value="' + gettext('Reset') + '"></input></div>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   429
        '<table>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   430
        '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   431
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   432
            gettext('Animation duration') +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   433
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   434
          '<td>&nbsp;</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   435
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   436
            '<input id="c_pref_animduration" type="text" style="width:3em" value="" />' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   437
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   438
        '</tr>' + 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   439
        '<tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   440
          '<td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   441
            '<span class="frame_helptext">' + gettext('(0.001 to 1 second)') + '</span>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   442
          '</td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   443
          '<td></td><td></td>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   444
        '</tr>' +
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   445
        '</table>';
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   446
  tab.append($(html)) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   447
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   448
  setPreferencesFieldsValue = function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   449
    var v = frames['text_view_comments'].c_readPreference('general', 'animduration');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   450
    $('#c_pref_animduration').val(v);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   451
  };
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   452
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   453
  setPreferencesFieldsValue();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   454
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   455
  $('#c_pref_animduration').blur( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   456
    var v = parseFloat($(this).val());
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   457
    if (isNaN(v) || (v <= 0) || (v > 1)) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   458
      v = frames['text_view_comments'].c_readDefaultPreference('general', 'animduration');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   459
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   460
    $(this).val(v);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   461
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   462
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   463
  $('#c_pref_reset_btn').click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   464
    frames['text_view_comments'].c_resetPreferences(['general']);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   465
    setPreferencesFieldsValue();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   466
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   467
    enqueueMsg(gettext('preferences reset (will apply on next load)'));
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   468
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   469
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   470
  $('#c_pref_save_btn').click( function() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   471
    frames['text_view_comments'].c_persistPreference('general', 'animduration', $('#c_pref_animduration').val());
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   472
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   473
    enqueueMsg(gettext('preferences saved (will apply on next load)'));
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   474
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   475
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   476
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   477
initFrame = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   478
  _initYesNoDialog();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   479
  _initPrintDialog() ;  
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   480
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   481
  $(window).resize(function(){
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   482
    onSliderStop(); 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   483
//    console.log('in frame resize' +  $("#c_slider").slider('value')) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   484
//    console.log('in frame resize' + frames['text_view_comments'].CY.DOM.winWidth()) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   485
//    console.log('in frame resize' + $(window).width()) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   486
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   487
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   488
  //$('<div id="c_slider"></div>').appendTo("#c-btns").slider({ 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   489
  $('#c_slider').slider({ 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   490
  animate: true,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   491
  range: "min",
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   492
  value: frames['text_view_comments'].c_readPreference('layout','comments_col_width'),
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   493
  min: 1,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   494
  iframeFix: true,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   495
  max: 100,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   496
//  step: 5,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   497
  slide: function(event, ui) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   498
    var slideVal = ui.value ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   499
    frames['text_view_comments'].c_setCommentsColWidth(slideVal) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   500
  },
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   501
  stop:function(event, ui) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   502
    onSliderStop() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   503
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   504
  }) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   505
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   506
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   507
  _initTabs();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   508
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   509
  f_interfaceFreeze();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   510
};
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   511
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   512
_initTabs = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   513
  $(".inner-north").tabs();
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   514
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   515
  var selectedTab = $.cookie('selectedTab');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   516
  selectedTab = (selectedTab === null) ? innerNorthPaneDefaults['selectedTab'] : parseInt(selectedTab);
536
0c625ce49a81 - updating jQuery (1.3.2 -> 1.10.2), jQuery UI, jQuery modules
Simon Descarpentries <sid@sopinspace.com>
parents: 534
diff changeset
   517
  $(".inner-north").tabs('option', 'active', selectedTab);
0c625ce49a81 - updating jQuery (1.3.2 -> 1.10.2), jQuery UI, jQuery modules
Simon Descarpentries <sid@sopinspace.com>
parents: 534
diff changeset
   518
  $(".inner-north").bind('tabsactivate', function(event, ui) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   519
    // // Objects available in the function context:
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   520
      // ui.tab // anchor element of the selected (clicked) tab
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   521
      // ui.panel // element, that contains the selected/clicked tab
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   522
      // contents
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   523
      // ui.index // zero-based index of the selected (clicked) tab
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   524
      _setCookie('selectedTab', ui.index);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   525
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   526
    });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   527
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   528
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   529
_initYesNoDialog = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   530
  $('#dialog_h').dialog( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   531
    // bgiframe: true, // why would we ?
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   532
    autoOpen :false,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   533
    modal :true
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   534
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   535
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   536
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   537
_setCookie = function(name, value) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   538
  var cookieExpire = new Date();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   539
  cookieExpire.setFullYear(2100, 0, 1);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   540
  $.cookie(name, value, {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   541
    'expires' :cookieExpire,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   542
    'path': '/'
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   543
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   544
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   545
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   546
//contains code thats offered by the text_view_comment_frame to its child frame text_view_comment
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   547
f_getFrameFilterData = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   548
  var name = $('#filter_name').val(); ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   549
  var date_str = $('#filter_date').val(); ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   550
  var text = $('#filter_text').val(); ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   551
  var tag = $('#filter_tag').val(); ; 
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   552
  var cat = $('#filter_cat').val(); ; 
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   553
  var state = $('#filter_state').val(); ; 
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   554
  return {'name':name, 'date':date_str, 'text':text, 'tag':tag, 'cat':cat, 'state':state} ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   555
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   556
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   557
f_setFilterValue = function (obj) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   558
  for (key in obj) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   559
    if (key.indexOf('filter_') == 0) 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   560
      $('#'+key).val(obj[key]); // wont explode even if argument is silly
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   561
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   562
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   563
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   564
f_isFrameFilterFieldsInit = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   565
  var obj = f_getFrameFilterData() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   566
  var ret = true ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   567
  for (key in obj) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   568
    ret = ret && (obj[key] == "") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   569
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   570
  return ret ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   571
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   572
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   573
initFilterFields = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   574
  $('.c_filter_field').val("") ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   575
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   576
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   577
resetFilter = function () {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   578
  initFilterFields() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   579
  frames['text_view_comments'].reinit() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   580
  enqueueMsg(gettext("filter reset")) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   581
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   582
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   583
applyFilter = function(self) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   584
  var val = self.val() ;  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   585
  if (gResetOtherFieldsOnFilterFieldChange) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   586
    initFilterFields() ;  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   587
    self.val(val) ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   588
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   589
  frames['text_view_comments'].reinit();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   590
  enqueueMsg(gettext("filter applied"));
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   591
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   592
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   593
f_updateFilterCountResult = function(nbDiscussions, nbComments, nbReplies, nbAllComments, nbAllReplies) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   594
  // update result counter message field.
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   595
  $("#c_f_res_nb_dis").html(nbDiscussions) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   596
  $("#c_f_res_nb_dis_txt").html(ngettext('discussion', 'discussions', nbDiscussions)) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   597
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   598
  $("#c_f_res_nb_com").html(nbComments) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   599
  $("#c_f_res_nb_tot_com").html(nbAllComments) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   600
  $("#c_f_res_nb_com_txt").html(ngettext('comment', 'comments', nbComments)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   601
  $("#c_f_res_nb_rep").html(nbReplies) ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   602
  $("#c_f_res_nb_tot_rep").html(nbAllReplies) ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   603
  $("#c_f_res_nb_rep_txt").html('&nbsp;' + ngettext('reply', 'replies', nbReplies)) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   604
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   605
  //console.info('nbDiscussions + typeof nbDiscussions +nbComments + typeof nbComments) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   606
  $("#c_filter_results").show() ; 
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   607
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   608
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   609
f_updateFilterCountDetailed = function(detailed) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   610
  if (detailed) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   611
    $("#c_f_res_details").show() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   612
    $("c_browse_all").val('View all (filtered) comments')
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   613
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   614
  else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   615
    $("#c_f_res_details").hide() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   616
    $("#c_browse_all").val('View all comments')
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   617
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   618
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   619
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   620
f_updateFilterData = function(newFilterData) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   621
//  console.info(newFilterData) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   622
  // users
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   623
  var selectedNameOption = $("#filter_name option:selected").attr("name") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   624
  var all = gettext("all") ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   625
  $("#filter_name option").remove() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   626
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   627
  $("#filter_name").append($("<option name='c_f2_user_all' value=''>" + all + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   628
  for (var  i=0, ilen=newFilterData['names'].length; i < ilen ; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   629
    var item = newFilterData['names'][i] ;
426
7c31b3a1284b Added 'me' and 'author' in filter by name.
gibus
parents: 425
diff changeset
   630
    $("#filter_name").append($("<option name='c_f2_user_"+ item.name +"' value='"+ item.name +"'>" + item.display +" ("+item.nb_comments+")</option>")) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   631
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   632
  
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   633
  $("#filter_name option[name="+selectedNameOption+"]").prop("selected", true);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   634
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   635
  // dates
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   636
  var selectedDateOption = $("#filter_date option:selected").attr("name") ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   637
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   638
  $("#filter_date option").remove() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   639
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   640
  $("#filter_date").append($("<option name='c_f_date_all' value=''>" + all + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   641
  for (var  i=0, ilen=newFilterData['dates'].length; i < ilen ; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   642
    var item = newFilterData['dates'][i] ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   643
    var ddd = ngettext('last 24 hours (%(nb_comments)s)', 'last %(nb_days)s days (%(nb_comments)s)', item.nb_day) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   644
    var ccc = interpolate(ddd,{'nb_days':item.nb_day, 'nb_comments':item.nb_comments}, true) ;    
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   645
    
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   646
    $("#filter_date").append($("<option name='c_f_date_"+ item.nb_day +"' value='"+ item.nb_day_date +"'>" + ccc + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   647
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   648
  
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   649
  $("#filter_date option[name="+selectedDateOption+"]").prop("selected", true);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   650
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   651
  // text : nothing to do
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   652
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   653
  // tags
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   654
  var selectedTagOption = $("#filter_tag option:selected").attr("name") ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   655
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   656
  $("#filter_tag option").remove() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   657
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   658
  $("#filter_tag").append($("<option name='c_f2_tag_all' value=''>" + all + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   659
  for (var  i=0, ilen=newFilterData['tags'].length; i < ilen ; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   660
    var item = newFilterData['tags'][i] ;
368
7279252f7bd9 Add spaces before item.count(s) in lists of com state/author/tags/time in com filtering facilities.
Simon Descarpentries <sid1@sopinspace.com>
parents: 341
diff changeset
   661
    $("#filter_tag").append($("<option name='c_f2_tag_"+ item.name +"' value='"+ item.name +"'>" + item.name +" ("+item.nb_comments+")</option>")) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   662
  }
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   663
  $("#filter_tag option[name="+selectedTagOption+"]").prop("selected", true);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   664
  
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   665
  // categories
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   666
  var selectedCatOption = $("#filter_cat option:selected").attr("cat") ;
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   667
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   668
  $("#filter_cat option").remove() ;
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   669
  
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   670
  categories = frames['text_view_comments'].CY.JSON.parse(frames['text_view_comments'].sv_categories);
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   671
  if (categories.hasOwnProperty('0')) {
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   672
    $("#filter_cat").append($("<option name='c_f2_cat_all' value=''>" + all + "</option>")) ;
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   673
    for (var  i=0, ilen=newFilterData['categories'].length; i < ilen ; i++) {
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   674
      var item = newFilterData['categories'][i] ;
510
8bde4b6584eb Do not proposed undefined categories in filter.
gibus
parents: 504
diff changeset
   675
      if (categories[item.cat] != null) {
8bde4b6584eb Do not proposed undefined categories in filter.
gibus
parents: 504
diff changeset
   676
        $("#filter_cat").append($("<option name='c_f2_cat_"+ item.cat +"' value='"+ gettext(item.cat) +"'>" + categories[item.cat] +" ("+item.nb_comments+")</option>")) ;
8bde4b6584eb Do not proposed undefined categories in filter.
gibus
parents: 504
diff changeset
   677
      }
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   678
    }
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   679
    $("#filter_cat option[name="+selectedCatOption+"]").prop("selected", true);
504
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   680
  }
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   681
  else {
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   682
    $("#filter_cat").remove()
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   683
    $("#filter_cat_label").remove()
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   684
  }
b2e0186daa5b Adds a category to comments, painted with colored vertical bar.
gibus
parents: 485
diff changeset
   685
  
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   686
  // states
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   687
  var selectedStateOption = $("#filter_state option:selected").attr("state") ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   688
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   689
  $("#filter_state option").remove() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   690
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   691
  $("#filter_state").append($("<option name='c_f2_state_all' value=''>" + all + "</option>")) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   692
  for (var  i=0, ilen=newFilterData['states'].length; i < ilen ; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   693
    var item = newFilterData['states'][i] ;
368
7279252f7bd9 Add spaces before item.count(s) in lists of com state/author/tags/time in com filtering facilities.
Simon Descarpentries <sid1@sopinspace.com>
parents: 341
diff changeset
   694
    $("#filter_state").append($("<option name='c_f2_state_"+ item.state +"' value='"+ item.state +"'>" + gettext(item.state) +" ("+item.nb_comments+")</option>")) ;
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   695
  }
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   696
  $("#filter_state option[name="+selectedStateOption+"]").prop("selected", true);
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   697
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   698
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   699
f_interfaceUnfreeze = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   700
  // tabs headers
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   701
  for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   702
    $(".inner-north").tabs("enable", i);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   703
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   704
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   705
  $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() {
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   706
    $(this).prop("disabled", false);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   707
  });
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   708
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   709
  $("#c_slider").slider('enable') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   710
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   711
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   712
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   713
f_interfaceFreeze = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   714
  // tabs headers
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   715
  for ( var i = 0, ilen = $(".c_tab").length; i < ilen; i++) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   716
    $(".inner-north").tabs("disable", i);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   717
  }
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   718
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   719
  $(".inner-north select").add(".inner-north input").add("#outer-north select").add("#outer-north input").each( function() {
565
95a5c06c4008 With JQuery > 1.6 replace .attr() by .prop() or .val(), see http://api.jquery.com/prop/
gibus
parents: 553
diff changeset
   720
    $(this).prop("disabled", true);
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   721
  });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   722
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   723
  $("#c_slider").slider('disable') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   724
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   725
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   726
f_enqueueMsg = function(msg) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   727
  enqueueMsg(msg) ;   
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   728
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   729
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   730
f_enqueueErrorMsg = function(msg) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   731
  enqueueErrorMsg(msg) ;  
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   732
} ;
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   733
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   734
f_removeLoadingMsg = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   735
  removeLoadingMsg() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   736
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   737
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   738
f_initFrame = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   739
  initFrame() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   740
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   741
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   742
f_layoutFrames = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   743
  layoutFrames() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   744
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   745
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   746
f_fillTextPreferencesTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   747
  fillTextPreferencesTab() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   748
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   749
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   750
f_fillPreferencesTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   751
  fillPreferencesTab() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   752
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   753
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   754
f_fillBrowseSection = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   755
  fillBrowseSection() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   756
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   757
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   758
f_fillFilterTab = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   759
  fillFilterTab() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   760
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   761
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   762
f_fillTopToolbar = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   763
  fillTopToolbar() ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   764
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   765
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   766
f_yesNoDialog = function(htmlContent, title, noFunction, noFunctionContext, noFunctionArgs, yesFunction, yesFunctionContext, yesFunctionArgs) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   767
  $('#dialog_h').html(htmlContent) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   768
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   769
  $('#dialog_h').dialog('option', 'title', title) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   770
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   771
  function onNo() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   772
    if (noFunction != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   773
      noFunction.call(noFunctionContext, noFunctionArgs) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   774
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   775
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   776
  function onYes() {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   777
    if (yesFunction != null)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   778
      yesFunction.call(yesFunctionContext, yesFunctionArgs) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   779
  }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   780
  var buttons = {} ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   781
  buttons[gettext('No')] = function() {$(this).dialog('close');onNo();} ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   782
  buttons[gettext('Yes')] = function() {$(this).dialog('close');onYes();} ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   783
  $('#dialog_h').dialog('option', 'buttons', buttons) ;        
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   784
  $('#dialog_h').dialog('open') ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   785
}
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   786
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   787
f_setCookie = function(name, value) {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   788
  _setCookie(name, value) ;
0
40c8f766c9b8 import from internal svn r 4007
raph
parents:
diff changeset
   789
}
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   790
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   791
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   792
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   793
/*****************************************************************************/
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   794
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   795
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   796
gInFullScreen = false;
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   797
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   798
_setFrameSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   799
  if (parent != window) { // (this condition is to enable accessing "comments_frame" view from top window) TODO test under IE   
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   800
    if (gInFullScreen) {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   801
      var headerHeight = parent.$("#header").height();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   802
      var windowHeight = parent.$(parent).height();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   803
      var frameHeight = (windowHeight - headerHeight - 2) + 'px'; // - 2 to prevent scrollbars ? --> TODO test it without -2
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   804
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   805
      var windowWidth = parent.$(parent).width();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   806
      var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ?// --> TODO test it without -2
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   807
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   808
      // TODO we should be embeded ! shouldn't work otherwise anyway (frame security concerns)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   809
      parent.$("#text_view_frame").css( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   810
        'position' :'absolute',
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   811
        'left' :'0px',
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   812
        'top' :headerHeight,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   813
        'width' :frameWidth,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   814
        'height' :frameHeight
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   815
      });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   816
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   817
    else {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   818
      var frameTop = Math.ceil(parent.$("#autoexpand_text_view_frame_container").position()["top"]);
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   819
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   820
      var windowHeight = parent.$(parent).height();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   821
      var frameHeight = (windowHeight - frameTop - 2) + 'px'; // - 2 to prevent scrollbars // ? --> TODO test it without -2
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   822
      
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   823
      var windowWidth = parent.$(parent).width();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   824
      var frameWidth = (windowWidth - 2) + 'px'; // - 2 to prevent scrollbars ? // --> TODO test it without -2
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   825
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   826
      // TODO test if we're embeded ! wont work otherwise anyway (frame security)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   827
      parent.$("#text_view_frame").css( {
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   828
        'position' :'relative',
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   829
        'width' :'99.9%',
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   830
        'height' :frameHeight,
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   831
        'top' :'0px'
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   832
      });
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   833
    }
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   834
  }
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   835
}
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   836
_toFullScreenSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   837
  gInFullScreen = true;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   838
  _setFrameSize() ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   839
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   840
  $("#c_fullscreen_btn").attr('src', sv_media_url + '/img/arrow_in.png');
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   841
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   842
  f_setCookie('fullscreen', '1') ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   843
};
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   844
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   845
_toNormalSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   846
  gInFullScreen = false;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   847
  _setFrameSize() ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   848
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   849
  $("#c_fullscreen_btn").attr('src', sv_media_url + 'img/arrow_out.png');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   850
  
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   851
  f_setCookie('fullscreen', '0') ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   852
};
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   853
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   854
_toInitialSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   855
  //console.info('_toInitialSize') ; 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   856
  var fullscreen = ($.cookie('fullscreen') == '1');
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   857
  if (fullscreen)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   858
    _toFullScreenSize() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   859
  else 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   860
    _toNormalSize() ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   861
};
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   862
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   863
toInitialSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   864
  _toInitialSize() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   865
  parent.$(parent).resize(function(){
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   866
//    console.log('before setFramesize in top resize winwidth' +  frames['text_view_comments'].CY.DOM.winWidth()) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   867
    _setFrameSize();
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   868
//    console.log('after setFramesize in top resize winwidth' +   frames['text_view_frame'].frames['text_view_comments'].CY.DOM.winWidth()) ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   869
  });
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   870
}
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   871
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   872
toggleFrameSize = function() {
341
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   873
  if (gInFullScreen)
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   874
    _toNormalSize() ;
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   875
  else 
053551f213fb Coding style for js: expand tabs
gibus
parents: 206
diff changeset
   876
    _toFullScreenSize() ;
59
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   877
}
8a2d933209aa BUG FIX : in text history tab text view frame now expands to maximum
reno
parents: 0
diff changeset
   878