diff --git a/src/c3nav/editor/static/editor/css/editor.css b/src/c3nav/editor/static/editor/css/editor.css index 695cd3ca..ef251368 100644 --- a/src/c3nav/editor/static/editor/css/editor.css +++ b/src/c3nav/editor/static/editor/css/editor.css @@ -42,16 +42,29 @@ form button.invisiblesubmit { font-size: 14px; padding: 0 7px; } +.leaflet-touch .leaflet-control-sections a, .leaflet-touch .leaflet-control-sections a:hover { + width: auto; + height:36px; + line-height:37px; + font-size: 14px; + padding: 0 12px; +} .leaflet-control-sections a, .leaflet-control-sections a:hover { opacity:0; margin-top:-26px; } -.leaflet-control-sections a.current, .leaflet-control-sections-expanded a, .leaflet-control-sections-expanded a:hover { +.leaflet-touch .leaflet-control-sections a, .leaflet-touch .leaflet-control-sections a:hover { + margin-top:-36px; +} +.leaflet-control-sections a.current, .leaflet-control-sections-expanded a, .leaflet-control-sections-expanded a:hover, +.leaflet-touch .leaflet-control-sections a.current, .leaflet-touch .leaflet-control-sections-expanded a, +.leaflet-touch .leaflet-control-sections-expanded a:hover { opacity:1; margin-top:0; } .leaflet-control-sections:not(.leaflet-control-sections-expanded) a.current { border-radius:4px; + border-width:0; } .leaflet-control-sections a.current { font-weight:bold; diff --git a/src/c3nav/editor/static/editor/js/editor.js b/src/c3nav/editor/static/editor/js/editor.js index af453bf3..ee99a77d 100644 --- a/src/c3nav/editor/static/editor/js/editor.js +++ b/src/c3nav/editor/static/editor/js/editor.js @@ -432,6 +432,7 @@ SectionControl = L.Control.extend({ this._container = L.DomUtil.create('div', 'leaflet-control-sections leaflet-bar'); this._sectionButtons = []; this._disabled = true; + this._expanded = false; this.hide(); if (!L.Browser.android) { @@ -441,11 +442,7 @@ SectionControl = L.Control.extend({ }, this); } - if (L.Browser.touch) { - L.DomEvent - .on(this._container, 'click', L.DomEvent.stop) - .on(this._container, 'click', this.collapse, this); - } else { + if (!L.Browser.touch) { L.DomEvent.on(this._container, 'focus', this.expand, this); } @@ -461,7 +458,7 @@ SectionControl = L.Control.extend({ L.DomEvent .on(link, 'mousedown dblclick', L.DomEvent.stopPropagation) - .on(link, 'click', this._sectionClick, this) + .on(link, 'click', this._sectionClick, this); this._sectionButtons.push(link); return link; @@ -498,9 +495,12 @@ SectionControl = L.Control.extend({ }, _sectionClick: function (e) { - console.log('click'); e.preventDefault(); - if (!this._disabled) { + e.stopPropagation(); + if (!this._expanded) { + this.expand(); + } else if (!this._disabled) { + $(e.target).addClass('current').siblings().removeClass('current'); editor.sidebar_get(e.target.href); this.collapse(); } @@ -508,11 +508,13 @@ SectionControl = L.Control.extend({ expand: function () { if (this._disabled) return; + this._expanded = true; L.DomUtil.addClass(this._container, 'leaflet-control-sections-expanded'); return this; }, collapse: function () { + this._expanded = false; L.DomUtil.removeClass(this._container, 'leaflet-control-sections-expanded'); return this; }