{"hidden":false,"children":[{"configs":{"itemId":"module","loginRequired":"false"},"expanded":true,"children":[{"configs":{"itemId":"container"},"expanded":false,"children":[],"type":"container"}],"type":"module","events":{"initialize":"Wb.apply(app, {\n  /**\n   * 设置脚本编辑器中的脚本内容。\n   * @param {String} value 脚本内容。\n   * @param {String} [type] 编辑脚本的类型。仅在首次调用方法时有效。默认为js。\n   * @param {Boolean} [readOnly] 是否只读。在每次调用该方法时均有效。默认为false。\n   */\n  setValue: function(value, type, readOnly) {\n    app.valueParam = value;\n    app.typeParam = type;\n    app.readOnlyParam = readOnly;\n    if (window.CodeMirror)\n      app.doSetValue();\n    else {\n      Wb.addLink(['wb/libs/cm/cmirror.css', 'wb/libs/cm/cmirror.js'],\n        app.doSetValue\n      );\n    }\n  },\n  doSetValue: function() {\n    if (!app.editor)\n      app.renderEditor();\n    app.editor.setOption('readOnly', app.readOnlyParam);\n    app.editor.setValue(app.valueParam || '');\n    setTimeout(function() {\n      app.editor.focus();\n    }, 10);\n  },\n  renderEditor: function() {\n    var comp = app.container;\n    comp.update('<textarea><\/textarea>');\n    app.editor = CodeMirror.fromTextArea(comp.el.down('textarea', true), app.getConfig());\n    comp.mon(comp, 'resize', function(comp, width, height) {\n      if (app.editor && !comp.destroying) {\n        Ext.fly(app.editor.getScrollerElement()).setHeight(comp.getHeight());\n        app.editor.refresh();\n      }\n    });\n  },\n  getConfig: function() {\n    var config, extConfig;\n    config = {\n      lineNumbers: true,\n      mode: 'text/javascript',\n      theme: Wb.editTheme,\n      extraKeys: {\n        'Ctrl-/': 'toggleComment',\n        'Ctrl-,': function(doc) {\n          if (doc.modifyCursor)\n            doc.setCursor(doc.modifyCursor);\n        },\n        'Shift-Ctrl-F': function(doc) {\n          if (doc.options.readOnly)\n            return;\n          var cursor = doc.getCursor(),\n            scroll = doc.getScrollInfo();\n          doc.autoFormatRange({\n            line: 0,\n            ch: 0\n          }, {\n            line: Number.MAX_VALUE,\n            ch: Number.MAX_VALUE\n          });\n          doc.scrollTo(scroll.left, scroll.top);\n          doc.setCursor(cursor);\n        }\n      }\n    };\n    switch (app.typeParam || 'js') {\n      case 'js':\n      case 'ss':\n        config.highlightSelectionMatches = {\n          showToken: /\\w/\n        };\n        config.extraKeys['Alt-/'] = 'autocomplete';\n        config.extraKeys['.'] = function(doc) {\n          if (doc.options.readOnly)\n            return;\n          doc.replaceSelection('.');\n          if (doc.hintTimer)\n            clearTimeout(doc.hintTimer);\n          doc.hintTimer = setTimeout(function() {\n            CodeMirror.showHint(doc);\n          }, 100);\n        };\n        extConfig = {\n          mode: {\n            name: 'text/javascript',\n            globalVars: true\n          },\n          gutters: ['CodeMirror-lint-markers'],\n          lint: true,\n          matchBrackets: true\n        };\n        break;\n      case 'css':\n        extConfig = {\n          mode: 'text/css',\n          gutters: ['CodeMirror-lint-markers'],\n          lint: true,\n          matchBrackets: true\n        };\n        break;\n      case 'java':\n        config.highlightSelectionMatches = {\n          showToken: /\\w/\n        };\n        extConfig = {\n          mode: 'text/x-java',\n          matchBrackets: true\n        };\n        break;\n      case 'xml':\n        extConfig = {\n          mode: 'application/xml',\n          matchBrackets: true\n        };\n        break;\n      case 'html':\n      case 'htm':\n        extConfig = {\n          mode: 'htmlmixed',\n          matchBrackets: true\n        };\n        break;\n      case 'jsp':\n      case 'jspx':\n        config.highlightSelectionMatches = {\n          showToken: /\\w/\n        };\n        extConfig = {\n          mode: 'application/x-jsp',\n          matchBrackets: true\n        };\n        break;\n      case 'json':\n      case 'xwl':\n      case 'expjson':\n        extConfig = {\n          mode: 'application/json',\n          gutters: ['CodeMirror-lint-markers'],\n          matchBrackets: true\n        };\n        break;\n      case 'sql':\n        extConfig = {\n          mode: 'text/x-sql',\n          matchBrackets: true\n        };\n        break;\n      default:\n        extConfig = {\n          mode: 'text/plain'\n        };\n    }\n    return Ext.apply(config, extConfig);\n  }\n});"}}],"roles":{},"title":"脚本编辑器","iconCls":"","inframe":false,"pageLink":""}