Skip to content

Commit

Permalink
Sort tabs with jQuery UI
Browse files Browse the repository at this point in the history
  • Loading branch information
jpallen committed May 20, 2012
1 parent 066389b commit b4784c2
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 12 deletions.
3 changes: 2 additions & 1 deletion public/editor/components/dialog/dialog.js
Expand Up @@ -9,7 +9,8 @@ define(function() {
this.$el.append(this.dialog);
this.dialog.modal({
show : false,
keyboard : false
keyboard : false,
backdrop : "static" // Don't close on click
});
this.dialog.hide();
},
Expand Down
32 changes: 21 additions & 11 deletions public/editor/components/tabs/tabs.js
Expand Up @@ -12,6 +12,8 @@ define(["components/base", "lib/path_util"], function(Base, PathUtil) {
// tabPaneEl : ... // The jQuery wrapped element of the tab pane
// }
this.openTabs = {};

$("#tab-bar").sortable();
},

open : function(file, fileView) {
Expand Down Expand Up @@ -59,17 +61,25 @@ define(["components/base", "lib/path_util"], function(Base, PathUtil) {
delete this.openTabs[file.id];
editor.get("openFiles").remove(file);

// Open the previous tab
var previousTabEl = tab.tabEl.prev();
if (previousTabEl.length > 0) {
setTimeout(function() {
previousTabEl.find("a").tab("show");
}, 10);
} else {
editor.set({
openFile : null,
openFileView : null
})
// If the tab is currently selected we open either the previous of
// next tab (unless there are no more tabs!)
if (tab.tabEl.hasClass("active")) {
var previousTabEl = tab.tabEl.prev();
var nextTabEl = tab.tabEl.next();
if (previousTabEl.length > 0) {
setTimeout(function() {
previousTabEl.find("a").tab("show");
}, 10);
} else if (nextTabEl.length > 0) {
setTimeout(function() {
nextTabEl.find("a").tab("show");
}, 10);
} else {
editor.set({
openFile : null,
openFileView : null
})
}
}

tab.tabEl.prev().tab("show")
Expand Down
1 change: 1 addition & 0 deletions public/editor/index.html
Expand Up @@ -9,6 +9,7 @@
<link rel="stylesheet" href='/editor/bootstrap/bootstrap/css/bootstrap.css'></link>

<script src='/editor/support/jquery-1.7.2.min.js'></script>
<script src='/editor/support/jquery-ui-1.8.20.min.js'></script>
<script src='/editor/bootstrap/js/bootstrap-dropdown.js'></script>
<script src='/editor/bootstrap/js/bootstrap-modal.js'></script>
<script src='/editor/bootstrap/js/bootstrap-tab.js'></script>
Expand Down
17 changes: 17 additions & 0 deletions public/editor/support/jquery-ui-1.8.20.min.js

Large diffs are not rendered by default.

0 comments on commit b4784c2

Please sign in to comment.