diff --git a/plugins/tabs/index.coffee b/plugins/tabs/index.coffee
index c10e9a3c8..183d71a50 100644
--- a/plugins/tabs/index.coffee
+++ b/plugins/tabs/index.coffee
@@ -1,2 +1,2 @@
define (require, exports, module) ->
- exports.Tabs = require('tabs/tabs').show()
\ No newline at end of file
+ exports.Tabs = Tabs = require('tabs/tabs')
diff --git a/plugins/tabs/tabs.coffee b/plugins/tabs/tabs.coffee
index 7974476cc..3da62c5f0 100644
--- a/plugins/tabs/tabs.coffee
+++ b/plugins/tabs/tabs.coffee
@@ -1,31 +1,47 @@
define (require, exports, module) ->
{Chrome, File, Dir, Process} = require 'osx'
+ {bindKey} = require 'editor'
- exports.show = ->
- root = OSX.NSBundle.mainBundle.resourcePath + '/plugins/tabs'
- tabs = OSX.NSString.stringWithContentsOfFile "#{root}/tabs.html"
- console.log tabs
- # edit = OSX.NSString.stringWithContentsOfFile "#{root}/editor.html"
- Chrome.addPane 'main', 'derp'
+ # click tab
+ $(document).delegate '#tabs ul li:not(.add) a', 'click', ->
+ switchToTab this
+ false
- # events
- $('#tabs ul li:not(.add) a').live 'click', ->
- $('#tabs ul .active').removeClass()
- $(this).parents('li').addClass 'active'
+ # click 'add' tab
+ $(document).delegate '#tabs .add a', 'click', ->
+ addTab()
+ false
- idx = $('#tabs ul a').index this
- $('.content iframe').hide().eq(idx).show().focus()
+ # toggle
+ bindKey 'toggleTabs', 'Command-Ctrl-T', (env) ->
+ if $('#tabs').length
+ hideTabs()
+ else
+ showTabs()
- false
- $('#tabs .add a').click ->
- $('#tabs ul .active').removeClass()
- $('#tabs ul .add').before '
untitled'
+ showTabs = ->
+ Chrome.addPane 'top', require('tabs/tabs.html')
+ $('#tabs').parents('.pane').css height: 'inherit'
+ css = $('').html require('tabs/tabs.css')
+ $('head').append css
- $('.content iframe').hide()
- $('.content').append ''
+ hideTabs = ->
+ $('#tabs').parents('.pane').remove()
+ $('#tabs-style').remove()
- $('#tabs ul .add').prev().addClass 'active'
+ addTab = ->
+ $('#tabs ul .add').before 'untitled'
+ $('#tabs ul .active').removeClass()
+ $('#tabs ul .add').prev().addClass 'active'
- false
+ switchToTab = (tab) ->
+ $('#tabs ul .active').removeClass()
+ $(tab).parents('li').addClass 'active'
+
+
+ exports.show = exports.showTabs = showTabs
+ exports.hideTabs = hideTabs
+ exports.addTab = addTab
+ exports.switchToTab = switchToTab
\ No newline at end of file
diff --git a/plugins/tabs/tabs.css b/plugins/tabs/tabs.css
index 7bfe9c9b0..d0d5ddc7b 100644
--- a/plugins/tabs/tabs.css
+++ b/plugins/tabs/tabs.css
@@ -1,11 +1,11 @@
-* { margin: 0; padding: 0; }
-body {
+#tabs * {
+ margin: 0;
+ padding: 0;
font: 12px "Lucida Grande", Helvetica, Arial, serif;
overflow: hidden;
}
-iframe { border: 0; }
-.clearfix:after {
+#tabs .clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
@@ -78,9 +78,3 @@ iframe { border: 0; }
border: 1px solid #a0a0a0;
border-bottom: 0;
}
-
-.content {
- -webkit-box-shadow: inset 0 1px 0 white;
- -moz-box-shadow: inset 0 1px 0 white;
- height: 97%;
-}
\ No newline at end of file
diff --git a/plugins/tabs/tabs.html b/plugins/tabs/tabs.html
index 088528789..2829451ac 100644
--- a/plugins/tabs/tabs.html
+++ b/plugins/tabs/tabs.html
@@ -5,5 +5,3 @@
-
-