feature-30986.patch

Mizuki ISHIKAWA, 2019-03-22 08:39

Download (4.42 KB)

View differences:

public/javascripts/jstoolbar/jstoolbar.js
451 451
  document.removeEventListener('mouseup', this.dragStopHdlr, false);
452 452
};
453 453

  
454
/* Code highlighting menu */
455
jsToolBar.prototype.precodeMenu = function(fn){
456
  var hlLanguages = ["c", "cpp", "csharp", "css", "diff", "go", "groovy", "html", "java", "javascript", "objc", "perl", "php", "python", "r", "ruby", "sass", "scala", "shell", "sql", "swift", "xml", "yaml"];
454
/* Add menu */
455
jsToolBar.prototype.addMenu = function(toolNodeName, list, fn) {
457 456
  var menu = $("<ul style='position:absolute;'></ul>");
458
  for (var i = 0; i < hlLanguages.length; i++) {
459
    $("<li></li>").text(hlLanguages[i]).appendTo(menu).mousedown(function(){
457
  for (var i = 0; i < list.length; i++) {
458
    $("<li></li>").text(list[i]).appendTo(menu).mousedown(function() {
460 459
      fn($(this).text());
461 460
    });
462 461
  }
......
464 463
  menu.menu().width(150).position({
465 464
    my: "left top",
466 465
    at: "left bottom",
467
    of: this.toolNodes['precode']
466
    of: this.toolNodes[toolNodeName]
468 467
  });
469 468
  $(document).on("mousedown", function() {
470 469
    menu.remove();
471 470
  });
472 471
  return false;
473 472
};
473

  
474
/* Code highlighting menu */
475
jsToolBar.prototype.precodeMenu = function(fn) {
476
  var hlLanguages = ["c", "cpp", "csharp", "css", "diff", "go", "groovy", "html", "java", "javascript", "objc", "perl", "php", "python", "r", "ruby", "sass", "scala", "shell", "sql", "swift", "xml", "yaml"];
477
  this.addMenu('precode', hlLanguages, fn);
478
};
479

  
480
/* Code macro menu */
481
jsToolBar.prototype.macroMenu = function() {
482
  var macros = {
483
    'child_pages': ['{{child_pages(', ')}}'],
484
    'include': ['{{include(', ')}}'],
485
    'collapse': ['{{collapse()\n', '\n}}'],
486
    'thumbnail': ['{{thumbnail(', ')}}']
487
  };
488
  var This = this;
489
  this.addMenu('macro', Object.keys(macros), function(macroName) {
490
    This.encloseLineSelection(macros[macroName][0], macros[macroName][1]);
491
  });
492
};
public/javascripts/jstoolbar/lang/jstoolbar-en.js
13 13
jsToolBar.strings['Quote'] = 'Quote';
14 14
jsToolBar.strings['Unquote'] = 'Remove Quote';
15 15
jsToolBar.strings['Preformatted text'] = 'Preformatted text';
16
jsToolBar.strings['Macro'] = 'Macro';
16 17
jsToolBar.strings['Wiki link'] = 'Link to a Wiki page';
17 18
jsToolBar.strings['Image'] = 'Image';
18 19
jsToolBar.strings['Edit'] = 'Edit';
public/javascripts/jstoolbar/markdown.js
196 196
// spacer
197 197
jsToolBar.prototype.elements.space4 = {type: 'space'}
198 198

  
199
// macro
200
jsToolBar.prototype.elements.macro = {
201
  type: 'button',
202
  title: 'Macro',
203
  fn: {
204
    wiki: function () {
205
      this.macroMenu();
206
    }
207
  }
208
}
209

  
199 210
// wiki page
200 211
jsToolBar.prototype.elements.link = {
201 212
  type: 'button',
public/javascripts/jstoolbar/textile.js
196 196
// spacer
197 197
jsToolBar.prototype.elements.space4 = {type: 'space'}
198 198

  
199
// macro
200
jsToolBar.prototype.elements.macro = {
201
  type: 'button',
202
  title: 'Macro',
203
  fn: {
204
    wiki: function(){
205
      this.macroMenu();
206
    }
207
  }
208
}
209

  
199 210
// wiki page
200 211
jsToolBar.prototype.elements.link = {
201 212
  type: 'button',
public/stylesheets/jstoolbar.css
124 124
.jstb_precode {
125 125
    background-image: url(../images/jstoolbar/bt_precode.png);
126 126
}
127
.jstb_macro {
128
    /*background-image: url(../images/jstoolbar/bt_macro.png);*/
129
}
127 130
.jstb_link {
128 131
    background-image: url(../images/jstoolbar/bt_link.png);
129 132
}