瀏覽代碼

Fix node creation for cell type switcher

Steven Silvester 8 年之前
父節點
當前提交
75341181b3
共有 1 個文件被更改,包括 19 次插入18 次删除
  1. 19 18
      src/notebook/notebook/default-toolbar.ts

+ 19 - 18
src/notebook/notebook/default-toolbar.ts

@@ -306,28 +306,11 @@ namespace ToolbarItems {
  * A toolbar widget that switches cell types.
  */
 class CellTypeSwitcher extends Widget {
-  /**
-   * Create the node for the cell type switcher.
-   */
-  static createNode(): HTMLElement {
-    let div = document.createElement('div');
-    let select = document.createElement('select');
-    for (let t of ['Code', 'Markdown', 'Raw']) {
-      let option = document.createElement('option');
-      option.value = t.toLowerCase();
-      option.textContent = t;
-      select.appendChild(option);
-    }
-    select.className = TOOLBAR_CELLTYPE_DROPDOWN;
-    div.appendChild(select);
-    return div;
-  }
-
   /**
    * Construct a new cell type switcher.
    */
   constructor(widget: Notebook) {
-    super();
+    super({ node: createCellTypeSwitcherNode() });
     this.addClass(TOOLBAR_CELLTYPE);
 
     let select = this.node.firstChild as HTMLSelectElement;
@@ -393,6 +376,24 @@ class CellTypeSwitcher extends Widget {
 }
 
 
+/**
+ * Create the node for the cell type switcher.
+ */
+function createCellTypeSwitcherNode(): HTMLElement {
+  let div = document.createElement('div');
+  let select = document.createElement('select');
+  for (let t of ['Code', 'Markdown', 'Raw']) {
+    let option = document.createElement('option');
+    option.value = t.toLowerCase();
+    option.textContent = t;
+    select.appendChild(option);
+  }
+  select.className = TOOLBAR_CELLTYPE_DROPDOWN;
+  div.appendChild(select);
+  return div;
+}
+
+
 /**
  * A toolbar item that displays kernel status.
  */