tabs (enable with Cmd-Ctrl-T)

This commit is contained in:
Chris Wanstrath
2011-08-28 01:18:55 -07:00
parent d7ef98de4f
commit acde2b1961
4 changed files with 41 additions and 33 deletions

View File

@@ -1,2 +1,2 @@
define (require, exports, module) ->
exports.Tabs = require('tabs/tabs').show()
exports.Tabs = Tabs = require('tabs/tabs')

View File

@@ -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 '<li><a href="#">untitled</a></li>'
showTabs = ->
Chrome.addPane 'top', require('tabs/tabs.html')
$('#tabs').parents('.pane').css height: 'inherit'
css = $('<style id="tabs-style"></style>').html require('tabs/tabs.css')
$('head').append css
$('.content iframe').hide()
$('.content').append '<iframe src="editor.html" width="100%" height="100%"></iframe>'
hideTabs = ->
$('#tabs').parents('.pane').remove()
$('#tabs-style').remove()
$('#tabs ul .add').prev().addClass 'active'
addTab = ->
$('#tabs ul .add').before '<li><a href="#">untitled</a></li>'
$('#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

View File

@@ -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%;
}

View File

@@ -5,5 +5,3 @@
</ul>
</div>
<div class="content">
</div>