Project

General

Profile

Feature #1575 » 0001-feature-1575-patch-with-table-icon.patch

Mizuki ISHIKAWA, 2020-02-21 08:16

View differences:

public/javascripts/jstoolbar/jstoolbar.js
471 471
  });
472 472
  return false;
473 473
};
474

  
475
/* Table generator */
476
jsToolBar.prototype.tableMenu = function(fn){
477
  var alphabets = "ABCDEFGHIJ".split('');
478
  var menu = $("<table class='table-generator'></table>");
479

  
480
  for (var r = 1;  r <= 5;  r++) {
481
    var row = $("<tr></tr>").appendTo(menu);
482
    for (var c = 1;  c <= 10;  c++) {
483
      $("<td data-row="+r+" data-col="+c+" title="+(c)+'&times;'+(r)+"></td>").mousedown(function(){
484
        fn(alphabets.slice(0, $(this).data('col')), $(this).data('row'));
485
      }).hover(function(){
486
        var hoverRow = $(this).data('row');
487
        var hoverCol = $(this).data('col');
488
        $(this).closest('table').find('td').each(function(_index, element){
489
          if ($(element).data('row') <= hoverRow && $(element).data('col') <= hoverCol){
490
            $(element).addClass('selected-cell');
491
          } else {
492
            $(element).removeClass('selected-cell');
493
          }
494
        });
495
      }).appendTo(row);
496
    }
497
  }
498
  $("body").append(menu);
499
  menu.position({
500
    my: "left top",
501
    at: "left bottom",
502
    of: this.toolNodes['table']
503
  });
504
  $(document).on("mousedown", function() {
505
    menu.remove();
506
  });
507
  return false;
508
};
public/javascripts/jstoolbar/lang/jstoolbar-en.js
12 12
jsToolBar.strings['Ordered list'] = 'Ordered list';
13 13
jsToolBar.strings['Quote'] = 'Quote';
14 14
jsToolBar.strings['Unquote'] = 'Remove Quote';
15
jsToolBar.strings['Table'] = 'Table';
15 16
jsToolBar.strings['Preformatted text'] = 'Preformatted text';
16 17
jsToolBar.strings['Wiki link'] = 'Link to a Wiki page';
17 18
jsToolBar.strings['Image'] = 'Image';
public/javascripts/jstoolbar/markdown.js
170 170
  }
171 171
}
172 172

  
173
// table
174
jsToolBar.prototype.elements.table = {
175
  type: 'button',
176
  title: 'Table',
177
  fn: {
178
    wiki: function() {
179
      var This = this;
180
      this.tableMenu(function(cols, rowCount){
181
        This.encloseLineSelection(('|'+cols.join(' |')+' |\n') + ('|--'.repeat(cols.length)+'|\n') + (('|  '.repeat(cols.length))+'|\n').repeat(rowCount));
182
      });
183
    }
184
  }
185
}
186

  
173 187
// pre
174 188
jsToolBar.prototype.elements.pre = {
175 189
  type: 'button',
public/javascripts/jstoolbar/textile.js
170 170
  }
171 171
}
172 172

  
173
// table
174
jsToolBar.prototype.elements.table = {
175
  type: 'button',
176
  title: 'Table',
177
  fn: {
178
    wiki: function() {
179
      var This = this;
180
      this.tableMenu(function(cols, rowCount){
181
        This.encloseLineSelection(('|_.'+cols.join('|_.')+'|\n') + (('|  '.repeat(cols.length))+'|\n').repeat(rowCount));
182
      });
183
    }
184
  }
185
}
186

  
173 187
// pre
174 188
jsToolBar.prototype.elements.pre = {
175 189
  type: 'button',
public/stylesheets/jstoolbar.css
80 80
.jstElements .help { float: right; margin-right: 0.5em; padding-top: 8px; font-size: 0.9em; }
81 81
.jstElements .help a {padding: 2px 0 2px 20px; background: url(../images/help.png) no-repeat 0 50%;}
82 82

  
83
.table-generator td {
84
    position: relative;
85
    border: 2px solid #ccc;
86
    background-color: white;
87
    padding: 10px;
88
    cursor: pointer;
89
}
90

  
91
.table-generator td.selected-cell, .table-generator td:hover {
92
    background-color: #759FCF;
93
}
94

  
95
.table-generator {
96
    position: absolute;
97
    border-collapse: collapse;
98
}
99

  
83 100
/* Buttons
84 101
-------------------------------------------------------- */
85 102
.jstb_strong {
......
130 147
.jstb_img {
131 148
    background-image: url(../images/jstoolbar/bt_img.png);
132 149
}
150
.jstb_table {
151
    background-image: url(../images/jstoolbar/bt_table.png);
152
}
133 153
.jstb_help {
134 154
    background-image: url(../images/help.png);
135 155
}
(6-6/12)