Skip to content

Commit e697978

Browse files
committed
Add basic UI front end code for drag/drop.
* Use jquery-ui.sortable to move elements. * Open folders have some extra height to allow you to drop items into them Needs Improvement * Placement is a bit fiddly
1 parent a885453 commit e697978

File tree

3 files changed

+50
-17
lines changed

3 files changed

+50
-17
lines changed

app/assets/javascripts/cms/new-sitemap.js

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//= require 'jquery'
2+
//= require 'jquery-ui'
23
//= require 'bootstrap'
34
//= require 'cms/ajax'
45

@@ -9,16 +10,16 @@ var GlobalMenu = function() {
910
};
1011

1112
// Setting the 'New Page' path should update the global menu
12-
GlobalMenu.prototype.addPagePath = function(path){
13+
GlobalMenu.prototype.addPagePath = function(path) {
1314
$('#new-content-button').attr('href', path);
1415
$('.add-page-button').attr('href', path);
1516
};
1617

17-
GlobalMenu.prototype.addSectionPath = function(path){
18+
GlobalMenu.prototype.addSectionPath = function(path) {
1819
$('.add-link-button').attr('href', path);
1920
};
2021

21-
GlobalMenu.prototype.addLinkPath = function(path){
22+
GlobalMenu.prototype.addLinkPath = function(path) {
2223
$('.add-section-button').attr('href', path);
2324
};
2425

@@ -29,7 +30,7 @@ var Sitemap = function() {
2930

3031
// @return [Selector] The currently selected section in the sitemap. If a page or other child is selected, this will be
3132
// that element's parent.
32-
Sitemap.prototype.currentSection = function(){
33+
Sitemap.prototype.currentSection = function() {
3334
return $(this.selectedSection);
3435
};
3536

@@ -42,16 +43,15 @@ Sitemap.prototype.clearSelection = function() {
4243
};
4344

4445
// Different Content types have different behaviors when double clicked.
45-
Sitemap.prototype._doubleClick = function(event){
46+
Sitemap.prototype._doubleClick = function(event) {
4647
var type = $(event.target).data('type');
47-
switch(type)
48-
{
49-
case 'section':
50-
case 'link':
51-
$('#properties-button')[0].click();
52-
break;
53-
default:
54-
$('#edit-button')[0].click();
48+
switch(type) {
49+
case 'section':
50+
case 'link':
51+
$('#properties-button')[0].click();
52+
break;
53+
default:
54+
$('#edit-button')[0].click();
5555
}
5656
};
5757

@@ -78,7 +78,7 @@ Sitemap.prototype.selectRow = function(row) {
7878
};
7979

8080
// Configure the 'New' button for content that is added directly to sections.
81-
Sitemap.prototype.configureNewButton = function(){
81+
Sitemap.prototype.configureNewButton = function() {
8282
globalMenu.addPagePath(this.currentSection().data('add-page-path'));
8383
globalMenu.addLinkPath(this.currentSection().data('add-link-path'));
8484
globalMenu.addSectionPath(this.currentSection().data('add-section-path'));
@@ -145,6 +145,15 @@ $(function() {
145145
});
146146
$('.selectable').on('dblclick', sitemap._doubleClick);
147147
sitemap.clickWebsite();
148+
$('#sitemap ul ul').sortable({
149+
connectWith: '#sitemap ul ul',
150+
placeholder: 'ui-placeholder',
151+
delay: 250,
152+
start: function(event, ui) {
153+
sitemap.clearSelection();
154+
}
155+
});
156+
148157
});
149158

150159
// Change the folder icon when they are opened/closed.

app/assets/stylesheets/cms/sitemap.css.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ body {
6868
margin-left: 28px;
6969
}
7070

71+
7172
#sitemap .phidden + i {
7273
margin-left: 10px;
7374
}
@@ -77,6 +78,16 @@ body {
7778
clear: both;
7879
}
7980

81+
// Ensures open folders have a hitable drop target.
82+
ul.in { min-height:10px; }
83+
84+
// Drop location for pages or sections within sitemap.
85+
.ui-placeholder {
86+
background-color: #EE5F5B;
87+
padding-right: 10px;
88+
height: 30px;
89+
}
90+
8091

8192

8293

todo_ui_Revamp.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
Tasks:
22

3+
- Move sitemap items
4+
-- Add ajax calls to move items.
5+
-- Need to expand sections as you pass over them.
6+
-- Need an image/section name for hover element when it leaves a parent section.
7+
38
## UI Merge
49

510
* Move/drag/drop sections
@@ -22,11 +27,19 @@ Tasks:
2227
* Implement search
2328
* Implement notifications
2429

25-
## Developer Tasks
30+
## UI Open Issues
31+
32+
Things that need to be updated in the CSS for the new UI.
33+
34+
* Selecting a row in content tables have no visual indicator.
35+
* New button looks bad when you hover over it.
36+
* When viewing a page, the draft button is on the right (rather than left) [Bad Merge?]
37+
* Flash messages still don't look right.
38+
* Select boxes are not styled.
39+
* RTE drop down isn't styled correctly
40+
* Form pages need to be styled
2641

27-
Style the following elements
2842

29-
* Edit Properties popover (currently centered and too small text)
3043

3144
# Points of Design Discussion
3245

0 commit comments

Comments
 (0)