Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit 54518b1

Browse files
committed
Add "handles" to note section edit bar
Dragging is now the only way to create new sections- clicking on the new section elements like buttons no longer works. This adds little grip handles to make clear that the elements are draggable, and adds a little help text towards the same end. Same done for topic citation editing.
1 parent 8610bd9 commit 54518b1

File tree

9 files changed

+114
-35
lines changed

9 files changed

+114
-35
lines changed

editorsnotes/main/templates/citation.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<div class="note-section">
44
<div class="citation-side">
5-
<i class="fa fa-file"></i>
5+
<i class="fa fa-file-text-o"></i>
66
</div>
77
<div class="citation-main">
88
<div class="citation-document">

editorsnotes/main/templates/includes/note_sections/citationns.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="note-section note-section-citation" id="citation-{{ section.document_id }}-{{ section.note_section_id }}">
44

55
<div class="citation-side">
6-
<a href="#citation-{{ section.document_id }}-{{ section.note_section_id }}"><i class="fa fa-file"></i></a>
6+
<a href="#citation-{{ section.document_id }}-{{ section.note_section_id }}"><i class="fa fa-file-text-o"></i></a>
77
</div>
88

99
<div class="citation-main">

editorsnotes/static/style/components.less

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
width: 16px;
1010
margin-left: 0;
1111
line-height: 19px;
12-
i { font-size: 24px; color: #333; }
12+
i { font-size: 18px; color: #333; }
1313
}
1414

1515
> div[class*='-main'] {

editorsnotes/static/style/layouts.less

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,9 @@ a.license-link {
552552
border: 1px solid #999;
553553
background: #fff;
554554
text-align: center;
555+
padding-left: 20px;
556+
padding-right: 20px;
557+
.section-drag-handle { display: none; }
555558
}
556559

557560
}
@@ -569,18 +572,53 @@ a.license-link {
569572
left: 0;
570573
width: 100%;
571574
z-index: 100;
575+
box-shadow: 0px 1px 2px #bbb;
576+
}
577+
578+
i.section-drag-handle {
579+
box-sizing: border-box;
580+
display: inline-block;
581+
position: absolute;
582+
top: 0;
583+
right: 0;
584+
height: 34px;
585+
padding: 10px 8px;
586+
587+
color: #777;
588+
border-left: 1px solid black;
572589
}
573590

574-
i { vertical-align: middle; font-size: 22px; color: #333; }
591+
i.section-icon {
592+
vertical-align: baseline;
593+
margin-right: 3px;
594+
font-size: 16px;
595+
color: #333;
596+
}
575597

576-
h4 { display: inline-block; margin: 0 12px 0 0; }
598+
h4 {
599+
display: inline-block;
600+
margin: 0 20px 0 0;
601+
a {
602+
font-size: 18px;
603+
vertical-align: middle;
604+
}
605+
}
577606
.add-section {
578-
.btn;
607+
position: relative;
608+
609+
display: inline-block;
610+
padding: 4px 34px 4px 20px;
611+
border: 1px solid #333;
612+
border-radius: 2px;
613+
background: white;
614+
box-shadow: 2px 2px 3px #bbb;
615+
cursor: pointer;
616+
579617
margin-right: 18px;
580618
line-height: 26px;
581-
padding-left: 20px;
582-
padding-right: 20px;
583619
min-width: 100px;
620+
621+
&:hover { background: #f8f8f8; }
584622
}
585623
img.loader {
586624
display: none;
@@ -618,7 +656,7 @@ a.license-link {
618656
.note-section-text .btn-toolbar { margin-top: 0px; }
619657

620658
// Include some whitespace at the bottom of the note section container
621-
.note-section-list { padding-bottom: 200px; }
659+
.note-section-list, .citation-list { padding-bottom: 200px; }
622660

623661
}
624662

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<h3>Citations</h3>
2-
<div id="citation-edit-bar">
3-
<a class="add-citation btn"><i class="fa fa-file"></i> Add citation</a>
2+
<div id="section-add-bar-container">
3+
<div id="citation-edit-bar">
4+
<h4>Add citation
5+
<a title="Drag handle to the area below to add a new citation."
6+
data-toggle="tooltip" href="#"><i class="fa fa-question-circle"></i></a>
7+
</h4>
8+
<div class="add-section">
9+
<i class="section-drag-handle fa fa-ellipsis-v"></i>
10+
<i class="section-icon fa fa-file-text-o"></i> Add citation
11+
</div>
12+
</div>
413
</div>
514
<div class="citation-list"></div>

editorsnotes_app/js/templates/note_section_citation.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="citation-side"><i class="fa fa-file"></i></div>
1+
<div class="citation-side"><i class="fa fa-file-text-o"></i></div>
22

33
<div class="citation-main">
44
<div class="citation-document">

editorsnotes_app/js/templates/note_section_list.html

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
<div id="section-add-bar-container">
22
<div id="citation-edit-bar">
3-
<h4>Add section: </h4>
4-
<a class="add-section" data-section-type="citation">
5-
<i class="fa fa-file"></i> Citation
6-
</a>
7-
<a class="add-section" data-section-type="text">Text</a>
8-
<a class="add-section" data-section-type="note_reference">
9-
<i class="fa fa-pencil"></i> Note reference
10-
</a>
3+
<h4>Add section
4+
<a title="Drag new sections to the area below in order to add to this note."
5+
data-toggle="tooltip" href="#"><i class="fa fa-question-circle"></i></a>
6+
</h4>
7+
<div class="add-section" data-section-type="citation">
8+
<i class="section-drag-handle fa fa-ellipsis-v"></i>
9+
<i class="section-icon fa fa-file-text-o"></i> Citation
10+
</div>
11+
<div class="add-section" data-section-type="text">
12+
<i class="section-drag-handle fa fa-ellipsis-v"></i>
13+
Text
14+
</div>
15+
<div class="add-section" data-section-type="note_reference">
16+
<i class="section-drag-handle fa fa-ellipsis-v"></i>
17+
<i class="section-icon fa fa-pencil"></i> Note reference
18+
</div>
1119
<span class="status-message">All changes saved.</span>
1220
<img class="loader" src="/static/style/icons/ajax-loader.gif">
1321
</div>

editorsnotes_app/js/views/citations.js

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@ var OrderedCollectionView = require('./generic/ordered_collection_base')
66

77
module.exports = OrderedCollectionView.extend({
88
itemViewConstructor: CitationView,
9-
events: {
10-
'click .add-citation': 'handleAddCitationButton'
11-
},
129
render: function () {
1310
var that = this
1411
, template = require('../templates/citation_list.html')
1512

1613
this.$el.empty().html( template() );
1714
this.$itemsEl = this.$('.citation-list');
1815
this.renderItems();
19-
this.initDrag();
16+
this.$el.closest('body').addClass('editing');
2017
this.initSort({
2118
stop: function (event, ui) {
2219
$(this).removeClass('sort-active');
23-
if (ui.item.hasClass('add-citation')) {
20+
if (ui.item.hasClass('add-section')) {
2421
that.collection.add({}, { at: ui.item.index() });
2522
ui.item.remove();
2623
}
2724
}
2825
});
26+
this.initDrag();
27+
this.initStickyBar();
2928
},
3029
onAddItemView: function (view) {
3130
if (view.model.isNew()) {
@@ -36,26 +35,53 @@ module.exports = OrderedCollectionView.extend({
3635
e.preventDefault();
3736
this.collection.add({});
3837
},
38+
39+
initStickyBar: function () {
40+
var $window = $(window)
41+
, $barContainer = this.$('#section-add-bar-container')
42+
, $bar = $barContainer.find('#citation-edit-bar')
43+
44+
$window
45+
.off('scroll.citation-list')
46+
.on('scroll.citation-list', function () {
47+
var scrollTop = $window.scrollTop()
48+
, offsetTop = $barContainer.offset().top
49+
50+
if (scrollTop > offsetTop) {
51+
$bar.addClass('sticky');
52+
} else {
53+
$bar.removeClass('sticky');
54+
}
55+
});
56+
},
57+
3958
initDrag: function () {
4059
var that = this
4160
, $addBar = this.$('#citation-edit-bar').css('overflow', 'auto')
42-
, st
61+
, threshold
4362

44-
$('.add-citation', $addBar).draggable({
63+
$('.add-section', $addBar).draggable({
4564
axis: 'y',
46-
distance: 10,
47-
appendTo: $addBar,
65+
distance: 2,
66+
appendTo: $addBar.parent(),
67+
cursor: 'move',
4868
connectToSortable: that.$itemsEl,
4969
helper: function () {
5070
return $('<div class="drag-placeholder">')
5171
.html( $(this).html() )
5272
.css('width', that.$itemsEl.innerWidth() - 22)
5373
},
5474
start: function () {
55-
st = $(this).offsetParent().scrollTop();
75+
threshold = $('.citation-list').offset().top;
5676
},
5777
drag: function (e, ui) {
58-
ui.position.top -= st;
78+
ui.position.top = null;
79+
80+
if (e.pageY < threshold) {
81+
ui.helper.css('top', e.pageY - 10);
82+
} else {
83+
ui.helper.show();
84+
}
5985
}
6086
});
6187
}

editorsnotes_app/js/views/note_section_list.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ var OrderedCollectionView = require('./generic/ordered_collection_base')
44
, $ = require('../jquery')
55

66
module.exports = OrderedCollectionView.extend({
7-
events: {
8-
'click .add-section': 'handleAddSectionButton'
9-
},
107
initialize: function () {
118
$('body').addClass('editing');
129
OrderedCollectionView.prototype.initialize.apply(this, arguments);
@@ -83,8 +80,9 @@ module.exports = OrderedCollectionView.extend({
8380

8481
$('.add-section', $addBar).draggable({
8582
axis: 'y',
86-
distance: 5,
83+
distance: 2,
8784
appendTo: $addBar.parent(),
85+
cursor: 'move',
8886
connectToSortable: that.$itemsEl,
8987
helper: function () {
9088
return $('<div class="drag-placeholder">')

0 commit comments

Comments
 (0)