fe-popup.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * FeHelper弹出(下拉)页面
  3. * @author zhaoxianlie
  4. */
  5. $(function () {
  6. // 获取后台页面,返回window对象
  7. var bgPage = chrome.extension.getBackgroundPage();
  8. // 菜单点击以后执行的动作
  9. jQuery('ul.fe-function-list li').click(function (e) {
  10. var msgType = $(this).attr('data-msgtype');
  11. var isUseFile = $(this).attr('data-usefile');
  12. if (msgType == 'COLOR_PICKER') {
  13. bgPage.BgPageInstance.showColorPicker();
  14. } else {
  15. bgPage.BgPageInstance.runHelper({
  16. msgType: MSG_TYPE[msgType],
  17. useFile: isUseFile
  18. });
  19. }
  20. window.close();
  21. });
  22. // ajax debugger开关文案控制
  23. bgPage.BgPageInstance.tellMeAjaxDbgSwitch(function (dbgSwitchOn) {
  24. $('li.-x-ajax-debugger span i').html(dbgSwitchOn ? '已开' : '已关');
  25. });
  26. // 设置
  27. jQuery('.fe-feedback .x-settings').click(function (e) {
  28. chrome.tabs.create({
  29. url: "template/fehelper_options.html",
  30. active: true
  31. });
  32. });
  33. // 根据配置,控制功能菜单的显示与隐藏
  34. baidu.feOption.doGetOptions(baidu.feOption.optionItems, function (opts) {
  35. opts && Object.keys(opts).forEach(function (item) {
  36. if (opts[item] == 'false') {
  37. $('li[data-msgtype="' + item + '"]').hide();
  38. }
  39. });
  40. })
  41. });