日期:2014-05-16  浏览次数:20375 次

请问 jHtmlArea 0.7.0 中的一段代码的含义?
jHtmlArea 0.7.0 http://jhtmlarea.codeplex.com中var m = priv.toolbarButtons[e] || e;是什么意思?

是不是priv.toolbarButtons[e]和e,无论哪一个不为空就赋值给m ?

  function addButtons(arr) {
  var ul = $("<ul/>").appendTo(that.toolbar);
  for (var i = 0; i < arr.length; i++) {
  var e = arr[i];
  if ((typeof (e)).toLowerCase() === "string") {
  if (e === "|") {
  ul.append($('<li class="separator"/>'));
  } else {
  var f = (function (e) {
  // If button name exists in priv.toolbarButtons then call the "method" defined there, otherwise call the method with the same name
  var m = priv.toolbarButtons[e] || e;
  if ((typeof (m)).toLowerCase() === "function") {
  return function (btn) { m.call(this, btn); };
  } else {
  return function () { this[m](); this.editor.body.focus(); };
  }
  })(e.toLowerCase());
  var t = options.toolbarText[e.toLowerCase()];
  ul.append(menuItem(e.toLowerCase(), t || e, f));
  }
  } else {
  ul.append(menuItem(e.css, e.text, e.action));
  }
  }
  };
  if (options.toolbar.length !== 0 && priv.isArray(options.toolbar[0])) {
  for (var i = 0; i < options.toolbar.length; i++) {
  addButtons(options.toolbar[i]);
  }
  } else {
  addButtons(options.toolbar);
  }
  },


------解决方案--------------------
var m = priv.toolbarButtons[e] || e;
相当于
if ( priv.toolbarButtons[e]){
 m = priv.toolbarButtons[e]
}else{
m=e
}