Add editorconfig

This commit is contained in:
Buu Nguyen 2014-06-06 17:38:50 -07:00
parent 8d8c8f2a01
commit 3d9123a259
9 changed files with 311 additions and 299 deletions

12
.editorconfig Normal file
View File

@ -0,0 +1,12 @@
root = true
[src/**]
indent_size = 2
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = false
[*.md]
trim_trailing_whitespace = false

View File

@ -1,6 +1,6 @@
const const
RESERVED_USER_NAMES = [ RESERVED_USER_NAMES = [
'settings', 'orgs', 'organizations', 'settings', 'orgs', 'organizations',
'site', 'blog', 'about', 'explore', 'site', 'blog', 'about', 'explore',
'styleguide', 'showcases', 'trending', 'styleguide', 'showcases', 'trending',
'stars', 'dashboard', 'notifications' 'stars', 'dashboard', 'notifications'
@ -28,7 +28,7 @@ GitHub.prototype.selectSubmodule = function(url) {
GitHub.prototype.selectFile = function(url) { GitHub.prototype.selectFile = function(url) {
var container = $(GH_PJAX_SEL) var container = $(GH_PJAX_SEL)
if (container.length) { if (container.length) {
$.pjax({ $.pjax({
url : url, url : url,
container : container container : container
}) })
@ -72,8 +72,8 @@ GitHub.prototype.getRepoFromPath = function() {
// can actually check if *[data-master-branch] exists and remove all the checks above // can actually check if *[data-master-branch] exists and remove all the checks above
// but the current approach is less fragile in case of GitHub DOM changes // but the current approach is less fragile in case of GitHub DOM changes
var branch = $(GH_BRANCH_SEL).data('ref') || $(GH_BRANCH_BTN_SEL).text() || 'master' var branch = $(GH_BRANCH_SEL).data('ref') || $(GH_BRANCH_BTN_SEL).text() || 'master'
return { return {
username : match[1], username : match[1],
reponame : match[2], reponame : match[2],
branch : branch branch : branch
} }
@ -144,8 +144,8 @@ GitHub.prototype.fetchData = function(opts, cb) {
} }
} }
setTimeout(function() { setTimeout(function() {
nextChunk(iteration + 1) nextChunk(iteration + 1)
}, 0) }, 0)
} }
}) })

View File

@ -1,5 +1,5 @@
{ {
"name": "Octotree", "name": "Octotree",
"version": "1.2.0", "version": "1.2.0",
"manifest_version": 2, "manifest_version": 2,
"author": "Buu Nguyen", "author": "Buu Nguyen",

View File

@ -1,4 +1,4 @@
const const
PREFIX = 'octotree' PREFIX = 'octotree'
, STORE = { , STORE = {
@ -10,7 +10,7 @@ const
POPUP : 'octotree.popup_shown', POPUP : 'octotree.popup_shown',
SHOWN : 'octotree.sidebar_shown', SHOWN : 'octotree.sidebar_shown',
} }
, EVENT = { , EVENT = {
TOGGLE : 'octotree:toggle', TOGGLE : 'octotree:toggle',
LOC_CHANGE : 'octotree:location', LOC_CHANGE : 'octotree:location',

View File

@ -86,7 +86,7 @@
}) })
} }
else treeView.syncSelection() else treeView.syncSelection()
} }
else { else {
$toggleBtn.hide() $toggleBtn.hide()
toggleSidebar(false) toggleSidebar(false)
@ -107,7 +107,7 @@
if (visibility !== undefined) { if (visibility !== undefined) {
if ($html.hasClass(PREFIX) === visibility) return if ($html.hasClass(PREFIX) === visibility) return
toggleSidebar() toggleSidebar()
} }
else { else {
$html.toggleClass(PREFIX) $html.toggleClass(PREFIX)
$document.trigger(EVENT.TOGGLE, $html.hasClass(PREFIX)) $document.trigger(EVENT.TOGGLE, $html.hasClass(PREFIX))
@ -118,6 +118,6 @@
var width = $sidebar.width() var width = $sidebar.width()
adapter.updateLayout($html.hasClass(PREFIX), width) adapter.updateLayout($html.hasClass(PREFIX), width)
store.set(STORE.WIDTH, width) store.set(STORE.WIDTH, width)
} }
}) })
})() })()

View File

@ -1,317 +1,317 @@
html, .header > .container, .repohead > .container, .site > .container { html, .header > .container, .repohead > .container, .site > .container {
transition: margin-left .2s ease; transition: margin-left .2s ease;
} }
.octotree_sidebar { .octotree_sidebar {
position: fixed; position: fixed;
padding-top: 41px; padding-top: 41px;
overflow: visible; overflow: visible;
top: 0; top: 0;
right: 0; right: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
background-color: #f7f7f7; background-color: #f7f7f7;
border-right: 1px solid #ddd; border-right: 1px solid #ddd;
z-index: 999991; z-index: 999991;
user-select: none; user-select: none;
transition: transform .2s ease; transition: transform .2s ease;
transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0);
.ui-resizable-e { .ui-resizable-e {
position: absolute; position: absolute;
cursor: col-resize; cursor: col-resize;
width: 5px; width: 5px;
right: 0; right: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
} }
} }
.octotree { .octotree {
.octotree_sidebar { .octotree_sidebar {
transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0);
} }
a.octotree_toggle { a.octotree_toggle {
right: 5px; right: 5px;
& > span:after { & > span:after {
content: '\f0a4'; content: '\f0a4';
}
} }
}
} }
.octotree_views { .octotree_views {
height: 100%; height: 100%;
overflow: auto; overflow: auto;
.octotree_view { .octotree_view {
display: none; display: none;
&.current { &.current {
display: block; display: block;
} }
.octotree_view_header { .octotree_view_header {
width: 100%; width: 100%;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;
height: 46px; height: 46px;
font-size: 16px; font-size: 16px;
line-height: 2.7; line-height: 2.7;
background-color: #f3f3f3; background-color: #f3f3f3;
background-image: linear-gradient(#f9f9f9, #f3f3f3); background-image: linear-gradient(#f9f9f9, #f3f3f3);
background-repeat: repeat-x; background-repeat: repeat-x;
margin: -5px 0 0; margin: -5px 0 0;
text-shadow: 0 1px 0 #fff; text-shadow: 0 1px 0 #fff;
border-bottom: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5;
} }
}
.octotree_treeview {
.octotree_view_header {
padding-left: 13px;
}
.octotree_header_repo {
font-size: 13px;
font-weight: bold;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.octotree_header_repo:before {
font-family: octicons;
content: '\f001';
color: #bbb;
margin-right: 6px;
line-height: 28px;
}
.octotree_header_branch {
line-height: 1;
margin-top: -10px;
margin-bottom: 5px;
font-size: 12px;
margin-top: -6px;
font-size: 11px;
}
.octotree_header_branch:before {
font-family: octicons;
content: '\f020';
color: #bbb;
margin-right: 8px;
margin-left: 3px;
}
.jstree-icon.tree:before {
content: '\f016';
color: #80a6cd;
}
.jstree-icon.blob:before {
content: '\f011';
color: #777;
}
.jstree-icon.commit:before {
content: '\f017';
color: #777;
}
.jstree-anchor {
color: #4183c4 !important;
text-decoration: none;
outline: none;
& > span {
color: black;
}
}
.jstree-anchor:hover {
text-decoration: none !important;
}
.jstree-default {
.jstree-wholerow {
height: auto;
}
.jstree-wholerow-hovered {
background: #eee;
}
.jstree-wholerow-clicked {
background: #dbeeff;
}
.jstree-node {
line-height: 24px;
margin-left: 12px;
}
.jstree-icon.jstree-ocl {
margin-right: -6px;
}
} }
.octotree_treeview { .jstree-icon.tree, .jstree-icon.blob, .jstree-icon.commit {
.octotree_view_header { font: normal normal 16px octicons;
padding-left: 13px; display: inline-block;
} margin-right: 3px;
.octotree_header_repo { text-decoration: none;
font-size: 13px; font-smoothing: antialiased;
font-weight: bold;
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.octotree_header_repo:before {
font-family: octicons;
content: '\f001';
color: #bbb;
margin-right: 6px;
line-height: 28px;
}
.octotree_header_branch {
line-height: 1;
margin-top: -10px;
margin-bottom: 5px;
font-size: 12px;
margin-top: -6px;
font-size: 11px;
}
.octotree_header_branch:before {
font-family: octicons;
content: '\f020';
color: #bbb;
margin-right: 8px;
margin-left: 3px;
}
.jstree-icon.tree:before {
content: '\f016';
color: #80a6cd;
}
.jstree-icon.blob:before {
content: '\f011';
color: #777;
}
.jstree-icon.commit:before {
content: '\f017';
color: #777;
}
.jstree-anchor {
color: #4183c4 !important;
text-decoration: none;
outline: none;
& > span {
color: black;
}
}
.jstree-anchor:hover {
text-decoration: none !important;
}
.jstree-default {
.jstree-wholerow {
height: auto;
}
.jstree-wholerow-hovered {
background: #eee;
}
.jstree-wholerow-clicked {
background: #dbeeff;
}
.jstree-node {
line-height: 24px;
margin-left: 12px;
}
.jstree-icon.jstree-ocl {
margin-right: -6px;
}
}
.jstree-icon.tree, .jstree-icon.blob, .jstree-icon.commit {
font: normal normal 16px octicons;
display: inline-block;
margin-right: 3px;
text-decoration: none;
font-smoothing: antialiased;
}
.jstree-default .jstree-icon, .jstree-default .jstree-icon:empty, .jstree-default .jstree-anchor {
line-height: 24px;
}
} }
.jstree-default .jstree-icon, .jstree-default .jstree-icon:empty, .jstree-default .jstree-anchor {
.octotree_errorview { line-height: 24px;
.octotree_view_header {
padding-left: 5px;
padding-top: 5px;
}
& > form {
div {
margin: 6px;
}
input {
width: 100%;
max-width: 350px;
}
.error {
color: #900;
}
.button {
margin-right: 5px;
}
}
} }
}
.octotree_optsview { .octotree_errorview {
.octotree_view_header { .octotree_view_header {
padding-left: 5px; padding-left: 5px;
padding-top: 5px; padding-top: 5px;
}
& > form {
margin: 6px;
& > div {
padding-top: 5px;
padding-bottom: 12px;
a {
display: inline-block;
float: right;
}
}
label {
font-weight: normal;
}
input[type=text], textarea {
width: 100%;
max-width: 350px;
}
}
} }
& > form {
div {
margin: 6px;
}
input {
width: 100%;
max-width: 350px;
}
.error {
color: #900;
}
.button {
margin-right: 5px;
}
}
}
.octotree_optsview {
.octotree_view_header {
padding-left: 5px;
padding-top: 5px;
}
& > form {
margin: 6px;
& > div {
padding-top: 5px;
padding-bottom: 12px;
a {
display: inline-block;
float: right;
}
}
label {
font-weight: normal;
}
input[type=text], textarea {
width: 100%;
max-width: 350px;
}
}
}
} }
a.octotree_toggle, a.octotree_opts { a.octotree_toggle, a.octotree_opts {
position: absolute; position: absolute;
text-align: center; text-align: center;
line-height: 1; line-height: 1;
z-index: 999992; z-index: 999992;
cursor: pointer; cursor: pointer;
color: black; color: black;
& > span { & > span {
line-height: 1; line-height: 1;
display: inline-block; display: inline-block;
text-decoration: none; text-decoration: none;
} }
&:hover, &.selected { &:hover, &.selected {
color: #4183C4; color: #4183C4;
} }
} }
a.octotree_opts { a.octotree_opts {
width: 15px; width: 15px;
height: 15px; height: 15px;
top: 13px; top: 13px;
right: 42px; right: 42px;
& > span { & > span {
font: normal normal 12px octicons; font: normal normal 12px octicons;
} }
& > span:before { & > span:before {
content: '\f031'; content: '\f031';
} }
} }
a.octotree_toggle { a.octotree_toggle {
width: 30px; width: 30px;
height: 30px; height: 30px;
padding: 6px 6px !important; padding: 6px 6px !important;
top: 5px; top: 5px;
right: -35px; right: -35px;
& > span { & > span {
font: normal normal 16px octicons; font: normal normal 16px octicons;
} }
& > span:after {
content: '\f078';
}
&.loading {
& > span:after { & > span:after {
content: '\f078'; content: '';
} }
&.loading { .loader {
& > span:after { border-radius: 50%;
content: ''; border: 2px solid #000;
} border-top: 2px solid rgba(0,0,0,0);
.loader { border-left: 2px solid rgba(0,0,0,0);
border-radius: 50%; width: 16px;
border: 2px solid #000; height: 16px;
border-top: 2px solid rgba(0,0,0,0); animation: loading .5s infinite linear;
border-left: 2px solid rgba(0,0,0,0);
width: 16px;
height: 16px;
animation: loading .5s infinite linear;
}
}
@keyframes loading {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
} }
}
@keyframes loading {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
} }
.octotree_popup { .octotree_popup {
position: fixed; position: fixed;
cursor: pointer; cursor: pointer;
display: none; display: none;
opacity: 0; opacity: 0;
top: 40px; top: 40px;
left: 5px; left: 5px;
z-index: 999993; z-index: 999993;
width: 260px; width: 260px;
text-align: left; text-align: left;
background-color: #fff; background-color: #fff;
background-clip: padding-box; background-clip: padding-box;
border: 1px solid rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.15);
border-radius: 5px; border-radius: 5px;
box-shadow: 0 3px 12px rgba(0,0,0,0.25); box-shadow: 0 3px 12px rgba(0,0,0,0.25);
white-space: normal; white-space: normal;
transition: opacity .3s linear; transition: opacity .3s linear;
&.show { &.show {
opacity: 1; opacity: 1;
} }
& > .arrow, & > .arrow:after { & > .arrow, & > .arrow:after {
position: absolute; position: absolute;
display: block; display: block;
width: 0; width: 0;
height: 0; height: 0;
border-color: transparent; border-color: transparent;
border-style: solid; border-style: solid;
} }
& > .arrow { & > .arrow {
left: 15px; left: 15px;
top: -6px; top: -6px;
border-width: 6px; border-width: 6px;
margin-left: -6px; margin-left: -6px;
border-top-width: 0; border-top-width: 0;
border-bottom-color: rgba(0, 0, 0, .25); border-bottom-color: rgba(0, 0, 0, .25);
} }
& > .arrow:after { & > .arrow:after {
border-width: 5px; border-width: 5px;
content: ''; content: '';
top: 1px; top: 1px;
margin-left: -5px; margin-left: -5px;
border-top-width: 0; border-top-width: 0;
border-bottom-color: #fff; border-bottom-color: #fff;
} }
& > .content { & > .content {
padding: 9px 14px; padding: 9px 14px;
font-size: 13px; font-size: 13px;
} }
} }

View File

@ -1,5 +1,5 @@
// regexps from https://github.com/shockie/node-iniparser // regexps from https://github.com/shockie/node-iniparser
const const
INI_SECTION = /^\s*\[\s*([^\]]*)\s*\]\s*$/ INI_SECTION = /^\s*\[\s*([^\]]*)\s*\]\s*$/
, INI_COMMENT = /^\s*;.*$/ , INI_COMMENT = /^\s*;.*$/
, INI_PARAM = /^\s*([\w\.\-\_]+)\s*=\s*(.*?)\s*$/ , INI_PARAM = /^\s*([\w\.\-\_]+)\s*=\s*(.*?)\s*$/

View File

@ -17,7 +17,7 @@ function OptionsView($dom, store) {
if (visibility !== undefined) { if (visibility !== undefined) {
if ($view.hasClass('current') === visibility) return if ($view.hasClass('current') === visibility) return
return toggle() return toggle()
} }
if ($toggleBtn.hasClass('selected')) { if ($toggleBtn.hasClass('selected')) {
$toggleBtn.removeClass('selected') $toggleBtn.removeClass('selected')
$(self).trigger(EVENT.VIEW_CLOSE) $(self).trigger(EVENT.VIEW_CLOSE)

View File

@ -14,8 +14,8 @@ function TreeView($dom, store, adapter) {
if (!$target.is('a.jstree-anchor')) return if (!$target.is('a.jstree-anchor')) return
var href = $target.attr('href') var href = $target.attr('href')
, $icon = $target.children().length , $icon = $target.children().length
? $target.children(':first') ? $target.children(':first')
: $target.siblings(':first') // handles child links in submodule : $target.siblings(':first') // handles child links in submodule
if ($icon.hasClass('commit')) adapter.selectSubmodule(href) if ($icon.hasClass('commit')) adapter.selectSubmodule(href)
@ -27,7 +27,7 @@ function TreeView($dom, store, adapter) {
}) })
} }
TreeView.prototype.showHeader = function(repo) { TreeView.prototype.showHeader = function(repo) {
this.$view.find('.octotree_view_header').html( this.$view.find('.octotree_view_header').html(
'<div class="octotree_header_repo">' + '<div class="octotree_header_repo">' +
repo.username + ' / ' + repo.reponame + repo.username + ' / ' + repo.reponame +
@ -44,11 +44,11 @@ TreeView.prototype.show = function(repo, treeData) {
, store = this.store , store = this.store
, treeContainer = $view.find('.octotree_view_body') , treeContainer = $view.find('.octotree_view_body')
, tree = treeContainer.jstree(true) , tree = treeContainer.jstree(true)
treeData = sort(treeData) treeData = sort(treeData)
if (store.get(STORE.COLLAPSE)) treeData = collapse(treeData) if (store.get(STORE.COLLAPSE)) treeData = collapse(treeData)
tree.settings.core.data = treeData tree.settings.core.data = treeData
tree.settings.state.key = PREFIX + '.' + repo.username + '/' + repo.reponame tree.settings.state.key = PREFIX + '.' + repo.username + '/' + repo.reponame
treeContainer.one('refresh.jstree', function() { treeContainer.one('refresh.jstree', function() {
self.syncSelection() self.syncSelection()