diff --git a/mkrfile.js b/mkrfile.js index ff3da631..71c8e30b 100644 --- a/mkrfile.js +++ b/mkrfile.js @@ -81,6 +81,7 @@ module.exports = function (suite) { $(src + ': _h5ai/client/css/*.less') .newerThan(mapSrc, $(src + ': _h5ai/client/css/**')) + .includeit() .less() .autoprefixer() .if(!suite.args.uncompressed, function () { this.cssmin(); }) @@ -135,6 +136,7 @@ module.exports = function (suite) { var env = {pkg: pkg}; $(src + '/_h5ai/client/css/styles.less') + .includeit() .less() .autoprefixer() .write(build + '/test/h5ai-styles.css', true); @@ -144,6 +146,7 @@ module.exports = function (suite) { .write(build + '/test/h5ai-scripts.js', true); $(root + '/test/styles.less') + .includeit() .less() .autoprefixer() .write(build + '/test/styles.css', true); diff --git a/src/_h5ai/client/css/inc/crumb.less b/src/_h5ai/client/css/inc/crumb.less new file mode 100644 index 00000000..c170c637 --- /dev/null +++ b/src/_h5ai/client/css/inc/crumb.less @@ -0,0 +1,50 @@ +#crumbbar { + overflow: hidden; + height: 48px; + font-size: 16px; + padding: 0 8px; + // border-left: 1px solid rgba(0,0,0,0.05); + + a, a:active, a:visited { + color: @col; + cursor: pointer; + text-decoration: none; + + &.active { + font-weight: bold; + color: @col-text-highlight; + } + &:hover { + color: @col-hover; + } + &:focus { + outline: 0; + } + } + .crumb { + display: inline-block; + .transition(all 0.2s ease-in-out); + } + .sep { + width: 24px; + height: 24px; + padding: 12px 0; + line-height: 48px; + display: inline-block; + vertical-align: top; + } + .label { + line-height: 48px; + display: inline-block; + vertical-align: top; + padding: 0 8px; + } + .hint { + width: 16px; + height: 16px; + padding: 16px 4px 16px 0; + line-height: 48px; + display: inline-block; + vertical-align: top; + } +} diff --git a/src/_h5ai/client/css/inc/topbar.less b/src/_h5ai/client/css/inc/topbar.less index 82f137fa..a09ce19e 100644 --- a/src/_h5ai/client/css/inc/topbar.less +++ b/src/_h5ai/client/css/inc/topbar.less @@ -1,4 +1,3 @@ - #topbar { overflow: hidden; flex: 0 0 auto; @@ -17,6 +16,40 @@ } +#toolbar { + overflow: hidden; + flex: 0 0 auto; + order: 1; + height: 48px; + + .tool { + display: inline-block; + cursor: pointer; + .transition(all 0.2s ease-in-out); + + img { + display: inline-block; + width: 24px; + height: 24px; + padding: 12px; + } + + &:hover { + background: rgba(0,0,0,0.03); + } + } +} + + +#flowbar { + overflow: hidden; + flex: 1 1 auto; + order: 2; + height: 48px; + font-size: 16px; +} + + #backlink { display: block; overflow: hidden; @@ -24,7 +57,6 @@ order: 99; text-align: center; padding: 6px 12px; - max-width: 80px; overflow: hidden; height: 36px; .transition(all 0.2s ease-in-out); @@ -47,82 +79,3 @@ white-space: nowrap; } } - - -#toolbar { - overflow: hidden; - flex: 0 0 auto; - order: 1; - height: 48px; - - .tool { - display: inline-block; - cursor: pointer; - - img { - display: inline-block; - width: 24px; - height: 24px; - padding: 12px; - .transition(all 0.2s ease-in-out); - } - - &:hover img { - background: rgba(0,0,0,0.03); - } - } -} - - -#crumbbar { - overflow: hidden; - flex: 1 1 auto; - order: 2; - height: 48px; - font-size: 16px; - padding: 0 8px; - // border-left: 1px solid rgba(0,0,0,0.05); - - a, a:active, a:visited { - color: @col; - cursor: pointer; - text-decoration: none; - - &.active { - font-weight: bold; - color: @col-text-highlight; - } - &:hover { - color: @col-hover; - } - &:focus { - outline: 0; - } - } - .crumb { - display: inline-block; - .transition(all 0.2s ease-in-out); - } - .sep { - width: 24px; - height: 24px; - padding: 12px 0; - line-height: 48px; - display: inline-block; - vertical-align: top; - } - .label { - line-height: 48px; - display: inline-block; - vertical-align: top; - padding: 0 8px; - } - .hint { - width: 16px; - height: 16px; - padding: 16px 4px 16px 0; - line-height: 48px; - display: inline-block; - vertical-align: top; - } -} diff --git a/src/_h5ai/client/css/styles.less b/src/_h5ai/client/css/styles.less index f72bc4af..e9615f22 100644 --- a/src/_h5ai/client/css/styles.less +++ b/src/_h5ai/client/css/styles.less @@ -3,6 +3,7 @@ @import "inc/general"; @import "inc/topbar"; +@import "inc/crumb"; @import "inc/sidebar"; @import "inc/download"; @import "inc/filter"; diff --git a/src/_h5ai/client/js/inc/ext/crumb.js b/src/_h5ai/client/js/inc/ext/crumb.js index 92251009..2892ce6a 100644 --- a/src/_h5ai/client/js/inc/ext/crumb.js +++ b/src/_h5ai/client/js/inc/ext/crumb.js @@ -1,29 +1,24 @@ -modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings'], function (_, $, event, location, resource, allsettings) { +modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/resource', 'core/settings', 'view/topbar'], function (_, $, event, location, resource, allsettings, topbar) { var settings = _.extend({ enabled: false }, allsettings.crumb); - var template = + var template = '
'; + var crumbTemplate = '' + '>' + '' + ''; var pageHintTemplate = 'has index page'; + var $crumbbar = $(template).appendTo(topbar.$flowbar); - function update(item, force) { - - if (!force && item.$crumb) { - return item.$crumb; - } - - var $html = $(template); - - $html - .addClass(item.isFolder() ? 'folder' : 'file') - .data('item', item); + function createHtml(item) { + var $html = $(crumbTemplate).data('item', item); + item.$crumb = $html; location.setLink($html, item); + $html.find('.label').text(item.label); if (item.isDomain() || item.isRoot()) { @@ -38,36 +33,20 @@ modulejs.define('ext/crumb', ['_', '$', 'core/event', 'core/location', 'core/res $html.append($(pageHintTemplate)); } - if (item.$crumb) { - item.$crumb.replaceWith($html); - } - item.$crumb = $html; - return $html; } function onLocationChanged(item) { - var crumb = item.getCrumb(); - var $crumbbar = $('#crumbbar'); - var found = false; + var $crumb = item.$crumb; - $crumbbar.find('.crumb').each(function () { - - var $html = $(this); - if ($html.data('item') === item) { - found = true; - $html.addClass('active'); - } else { - $html.removeClass('active'); - } - }); - - if (!found) { - $crumbbar.find('.crumb').remove(); - _.each(crumb, function (e) { - - $crumbbar.append(update(e, true)); + if ($crumb && $crumb.parent()[0] === $crumbbar[0]) { + $crumbbar.children().removeClass('active'); + $crumb.addClass('active'); + } else { + $crumbbar.empty(); + _.each(item.getCrumb(), function (item) { + $crumbbar.append(createHtml(item)); }); } } diff --git a/src/_h5ai/client/js/inc/view/topbar.js b/src/_h5ai/client/js/inc/view/topbar.js index e8c35943..eba49de8 100644 --- a/src/_h5ai/client/js/inc/view/topbar.js +++ b/src/_h5ai/client/js/inc/view/topbar.js @@ -3,7 +3,7 @@ modulejs.define('view/topbar', ['$', 'config', 'view/root'], function ($, config var template = '
' + '
' + - '