<commit_before>class DevToolsMainView extends KDView

  COFFEE = "//cdnjs.cloudflare.com/ajax/libs/coffee-script/1.6.3/coffee-script.min.js"

  constructor:->
    super

    @storage = KD.singletons.localStorageController.storage "DevTools"
    @liveMode = @storage.getAt 'liveMode'

  getToggleLiveReloadMenuView: (item, menu)->

    itemLabel = "#{if @liveMode then 'Disable' else 'Enable'} live compile"

    toggleLiveReload = new KDView
      partial : "<span>#{itemLabel}</span>"
      click   : =>
        @toggleLiveReload()
        menu.contextMenu.destroy()

    toggleLiveReload.on "viewAppended", ->
      toggleLiveReload.parent.setClass "default"

  getToggleFullscreenMenuView: (item, menu)->
    labels = [
      "Enter Fullscreen"
      "Exit Fullscreen"
    ]
    mainView = KD.getSingleton "mainView"
    state    = mainView.isFullscreen() or 0
    toggleFullscreen = new KDView
      partial : "<span>#{labels[Number state]}</span>"
      click   : =>
        mainView.toggleFullscreen()
        menu.contextMenu.destroy()

    toggleFullscreen.on "viewAppended", ->
      toggleFullscreen.parent.setClass "default"


  viewAppended:->

    @addSubView @workspace      = new CollaborativeWorkspace
      name                      : "Koding DevTools"
      delegate                  : this
      firebaseInstance          : "tw-local"
      panels                    : [
        title                   : "Koding DevTools"
        layout                  :
          direction             : "vertical"
          sizes                 : [ "264px", null ]
          splitName             : "BaseSplit"
          views                 : [
            {
              type              : "finder"
              name              : "finder"
              editor            : "JSEditor"
              handleFileOpen    : (file, content) =>

                {CSSEditor, JSEditor} = @workspace.activePanel.panesByName

                switch FSItem.getFileExtension file.path
                  when 'css', 'styl'
                  then editor = CSSEditor
                  else editor = JSEditor

                editor.openFile file, content
            }
            {
              type              : "split"
              options           :
                direction       : "vertical"
                sizes           : [ "50%", "50%" ]
                splitName       : "InnerSplit"
                cssClass        : "inner-split"
              views             : [
                {
                  type          : "split"
                  options       :
                    direction   : "horizontal"
                    sizes       : [ "50%", "50%" ]
                    splitName   : "EditorSplit"
                    cssClass    : "editor-split"
                  views         : [
                    {
                      type      : "custom"
                      name      : "JSEditor"
                      paneClass : DevToolsEditorPane
                      title     : "JavaScript"
                      # buttons : [
                      #   {
                      #     itemClass: KDOnOffSwitch
                      #     callback: ->
                      #       log arguments
                      #   }
                      # ]
                    }
                    {
                      type      : "custom"
                      name      : "CSSEditor"
                      title     : "Style"
                      paneClass : DevToolsCssEditorPane
                    }
                  ]
                }
                {
                  type          : "custom"
                  name          : "PreviewPane"
                  title         : "Preview"
                  paneClass     : CollaborativePane
                }
              ]
            }
          ]
      ]

    @workspace.ready =>


      {JSEditor, CSSEditor} = panes = @workspace.activePanel.panesByName

      KD.singletons.vmController.ready =>

        JSEditor.ready =>

          JSEditor.loadLastOpenFile()
          JSEditor.codeMirrorEditor.on "change", \
            _.debounce (@lazyBound 'previewApp', no), 500

          JSEditor.on "RunRequested", @lazyBound 'previewApp', yes
          JSEditor.on "AutoRunRequested", @bound 'toggleLiveReload'

          @on 'closeAllMenuItemClicked', =>
            CSSEditor.closeFile(); JSEditor.closeFile()

        CSSEditor.ready =>

          CSSEditor.loadLastOpenFile()
          CSSEditor.codeMirrorEditor.on "change", \
            _.debounce (@lazyBound 'previewCss', no), 500

          CSSEditor.on "RunRequested", @lazyBound 'previewCss', yes
          CSSEditor.on "AutoRunRequested", @bound 'toggleLiveReload'<commit_msg>DevTools: disable workspace's broadCast feature for now, we will handle messages inline<commit_after>class DevToolsMainView extends KDView

  COFFEE = "//cdnjs.cloudflare.com/ajax/libs/coffee-script/1.6.3/coffee-script.min.js"

  constructor:->
    super

    @storage = KD.singletons.localStorageController.storage "DevTools"
    @liveMode = @storage.getAt 'liveMode'

  getToggleLiveReloadMenuView: (item, menu)->

    itemLabel = "#{if @liveMode then 'Disable' else 'Enable'} live compile"

    toggleLiveReload = new KDView
      partial : "<span>#{itemLabel}</span>"
      click   : =>
        @toggleLiveReload()
        menu.contextMenu.destroy()

    toggleLiveReload.on "viewAppended", ->
      toggleLiveReload.parent.setClass "default"

  getToggleFullscreenMenuView: (item, menu)->
    labels = [
      "Enter Fullscreen"
      "Exit Fullscreen"
    ]
    mainView = KD.getSingleton "mainView"
    state    = mainView.isFullscreen() or 0
    toggleFullscreen = new KDView
      partial : "<span>#{labels[Number state]}</span>"
      click   : =>
        mainView.toggleFullscreen()
        menu.contextMenu.destroy()

    toggleFullscreen.on "viewAppended", ->
      toggleFullscreen.parent.setClass "default"


  viewAppended:->

    @addSubView @workspace      = new CollaborativeWorkspace
      name                      : "Koding DevTools"
      delegate                  : this
      firebaseInstance          : "tw-local"
      panels                    : [
        title                   : "Koding DevTools"
        layout                  :
          direction             : "vertical"
          sizes                 : [ "264px", null ]
          splitName             : "BaseSplit"
          views                 : [
            {
              type              : "finder"
              name              : "finder"
              editor            : "JSEditor"
              handleFileOpen    : (file, content) =>

                {CSSEditor, JSEditor} = @workspace.activePanel.panesByName

                switch FSItem.getFileExtension file.path
                  when 'css', 'styl'
                  then editor = CSSEditor
                  else editor = JSEditor

                editor.openFile file, content
            }
            {
              type              : "split"
              options           :
                direction       : "vertical"
                sizes           : [ "50%", "50%" ]
                splitName       : "InnerSplit"
                cssClass        : "inner-split"
              views             : [
                {
                  type          : "split"
                  options       :
                    direction   : "horizontal"
                    sizes       : [ "50%", "50%" ]
                    splitName   : "EditorSplit"
                    cssClass    : "editor-split"
                  views         : [
                    {
                      type      : "custom"
                      name      : "JSEditor"
                      paneClass : DevToolsEditorPane
                      title     : "JavaScript"
                      # buttons : [
                      #   {
                      #     itemClass: KDOnOffSwitch
                      #     callback: ->
                      #       log arguments
                      #   }
                      # ]
                    }
                    {
                      type      : "custom"
                      name      : "CSSEditor"
                      title     : "Style"
                      paneClass : DevToolsCssEditorPane
                    }
                  ]
                }
                {
                  type          : "custom"
                  name          : "PreviewPane"
                  title         : "Preview"
                  paneClass     : CollaborativePane
                }
              ]
            }
          ]
      ]

    # DISABLE broadcastMessaging in workspace
    @workspace.broadcastMessage = noop

    @workspace.ready =>

      {JSEditor, CSSEditor} = panes = @workspace.activePanel.panesByName

      KD.singletons.vmController.ready =>

        JSEditor.ready =>

          JSEditor.loadLastOpenFile()
          JSEditor.codeMirrorEditor.on "change", \
            _.debounce (@lazyBound 'previewApp', no), 500

          JSEditor.on "RunRequested", @lazyBound 'previewApp', yes
          JSEditor.on "AutoRunRequested", @bound 'toggleLiveReload'

          @on 'closeAllMenuItemClicked', =>
            CSSEditor.closeFile(); JSEditor.closeFile()

        CSSEditor.ready =>

          CSSEditor.loadLastOpenFile()
          CSSEditor.codeMirrorEditor.on "change", \
            _.debounce (@lazyBound 'previewCss', no), 500

          CSSEditor.on "RunRequested", @lazyBound 'previewCss', yes
          CSSEditor.on "AutoRunRequested", @bound 'toggleLiveReload'
{'fraction_non_alphanumeric': 0.08861814016453191, 'fraction_numerical': 0.0043736332396126214, 'mean_word_length': 1.1346965992442766, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5976795', 'n_tokens_mistral': 2607, 'n_tokens_neox': 2396, 'n_words': 456}