Commit be5dd6d2 by Christina Roberts

Merge pull request #1411 from MITx/feature/dhm/dnd

Attempt to patch the dnd hesitation fixes onto master
parents 486e747b 902cdefe
...@@ -8,7 +8,9 @@ $(document).ready(function() { ...@@ -8,7 +8,9 @@ $(document).ready(function() {
handle: '.drag-handle', handle: '.drag-handle',
zIndex: 999, zIndex: 999,
start: initiateHesitate, start: initiateHesitate,
drag: checkHoverState, // left 2nd arg in as inert selector b/c i was uncertain whether we'd try to get the shove up/down
// to work in the future
drag: generateCheckHoverState('.collapsed', ''),
stop: removeHesitate, stop: removeHesitate,
revert: "invalid" revert: "invalid"
}); });
...@@ -19,7 +21,7 @@ $(document).ready(function() { ...@@ -19,7 +21,7 @@ $(document).ready(function() {
handle: '.section-item .drag-handle', handle: '.section-item .drag-handle',
zIndex: 999, zIndex: 999,
start: initiateHesitate, start: initiateHesitate,
drag: checkHoverState, drag: generateCheckHoverState('.courseware-section.collapsed', ''),
stop: removeHesitate, stop: removeHesitate,
revert: "invalid" revert: "invalid"
}); });
...@@ -56,64 +58,100 @@ $(document).ready(function() { ...@@ -56,64 +58,100 @@ $(document).ready(function() {
drop: onSectionReordered, drop: onSectionReordered,
greedy: true greedy: true
}); });
});
});
CMS.HesitateEvent.toggleXpandHesitation = null; CMS.HesitateEvent.toggleXpandHesitation = null;
function initiateHesitate(event, ui) { function initiateHesitate(event, ui) {
CMS.HesitateEvent.toggleXpandHesitation = new CMS.HesitateEvent(expandSection, 'dragLeave', true); CMS.HesitateEvent.toggleXpandHesitation = new CMS.HesitateEvent(expandSection, 'dragLeave', true);
$('.collapsed').on('dragEnter', CMS.HesitateEvent.toggleXpandHesitation, CMS.HesitateEvent.toggleXpandHesitation.trigger); $('.collapsed').on('dragEnter', CMS.HesitateEvent.toggleXpandHesitation, CMS.HesitateEvent.toggleXpandHesitation.trigger);
$('.collapsed').each(function() { $('.collapsed, .unit, .id-holder').each(function() {
this.proportions = {width : this.offsetWidth, height : this.offsetHeight }; this.proportions = {width : this.offsetWidth, height : this.offsetHeight };
// reset b/c these were holding values from aborts // reset b/c these were holding values from aborts
this.isover = false; this.isover = false;
}); });
} }
function checkHoverState(event, ui) {
function computeIntersection(droppable, uiHelper, y) {
/*
* Test whether y falls within the bounds of the droppable on the Y axis
*/
// NOTE: this only judges y axis intersection b/c that's all we're doing right now
// don't expand the thing being carried
if (uiHelper.is(droppable)) {
return null;
}
$.extend(droppable, {offset : $(droppable).offset()});
var t = droppable.offset.top,
b = t + droppable.proportions.height;
if (t === b) {
// probably wrong values b/c invisible at the time of caching
droppable.proportions = { width : droppable.offsetWidth, height : droppable.offsetHeight };
b = t + droppable.proportions.height;
}
// equivalent to the intersects test
return (t < y && // Bottom Half
y < b ); // Top Half
}
// NOTE: selectorsToShove is not currently being used but I left this code as it did work but not well
function generateCheckHoverState(selectorsToOpen, selectorsToShove) {
return function(event, ui) {
// copied from jquery.ui.droppable.js $.ui.ddmanager.drag & other ui.intersect // copied from jquery.ui.droppable.js $.ui.ddmanager.drag & other ui.intersect
var draggable = $(this).data("ui-draggable"), var draggable = $(this).data("ui-draggable"),
x1 = (draggable.positionAbs || draggable.position.absolute).left + (draggable.helperProportions.width / 2), centerY = (draggable.positionAbs || draggable.position.absolute).top + (draggable.helperProportions.height / 2);
y1 = (draggable.positionAbs || draggable.position.absolute).top + (draggable.helperProportions.height / 2); $(selectorsToOpen).each(function() {
$('.collapsed').each(function() { var intersects = computeIntersection(this, ui.helper, centerY),
// don't expand the thing being carried c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
if (ui.helper.is(this)) {
return;
}
$.extend(this, {offset : $(this).offset()});
var droppable = this,
l = droppable.offset.left,
r = l + droppable.proportions.width,
t = droppable.offset.top,
b = t + droppable.proportions.height;
if (l === r) {
// probably wrong values b/c invisible at the time of caching
droppable.proportions = { width : droppable.offsetWidth, height : droppable.offsetHeight };
r = l + droppable.proportions.width;
b = t + droppable.proportions.height;
}
// equivalent to the intersects test
var intersects = (l < x1 && // Right Half
x1 < r && // Left Half
t < y1 && // Bottom Half
y1 < b ), // Top Half
c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
if(!c) {
return;
}
this[c] = true; if(!c) {
this[c === "isout" ? "isover" : "isout"] = false; return;
$(this).trigger(c === "isover" ? "dragEnter" : "dragLeave"); }
this[c] = true;
this[c === "isout" ? "isover" : "isout"] = false;
$(this).trigger(c === "isover" ? "dragEnter" : "dragLeave");
}); });
$(selectorsToShove).each(function() {
var intersectsBottom = computeIntersection(this, ui.helper, (draggable.positionAbs || draggable.position.absolute).top);
if ($(this).hasClass('ui-dragging-pushup')) {
if (!intersectsBottom) {
console.log('not up', $(this).data('id'));
$(this).removeClass('ui-dragging-pushup');
}
}
else if (intersectsBottom) {
console.log('up', $(this).data('id'));
$(this).addClass('ui-dragging-pushup');
}
var intersectsTop = computeIntersection(this, ui.helper,
(draggable.positionAbs || draggable.position.absolute).top + draggable.helperProportions.height);
if ($(this).hasClass('ui-dragging-pushdown')) {
if (!intersectsTop) {
console.log('not down', $(this).data('id'));
$(this).removeClass('ui-dragging-pushdown');
}
}
else if (intersectsTop) {
console.log('down', $(this).data('id'));
$(this).addClass('ui-dragging-pushdown');
}
});
}
} }
function removeHesitate(event, ui) { function removeHesitate(event, ui) {
$('.collapsed').off('dragEnter', CMS.HesitateEvent.toggleXpandHesitation.trigger); $('.collapsed').off('dragEnter', CMS.HesitateEvent.toggleXpandHesitation.trigger);
$('.ui-dragging-pushdown').removeClass('ui-dragging-pushdown');
$('.ui-dragging-pushup').removeClass('ui-dragging-pushup');
CMS.HesitateEvent.toggleXpandHesitation = null; CMS.HesitateEvent.toggleXpandHesitation = null;
} }
...@@ -189,3 +227,5 @@ function _handleReorder(event, ui, parentIdField, childrenSelector) { ...@@ -189,3 +227,5 @@ function _handleReorder(event, ui, parentIdField, childrenSelector) {
}); });
} }
input.courseware-unit-search-input { input.courseware-unit-search-input {
float: left; float: left;
width: 260px; width: 260px;
background-color: #fff; background-color: #fff;
} }
.branch { .branch {
.section-item { .section-item {
@include clearfix(); @include clearfix();
.details { .details {
display: block; display: block;
float: left; float: left;
margin-bottom: 0; margin-bottom: 0;
width: 650px; width: 650px;
} }
.gradable-status { .gradable-status {
float: right; float: right;
position: relative; position: relative;
top: -4px; top: -4px;
right: 50px; right: 50px;
width: 145px; width: 145px;
.status-label { .status-label {
position: absolute; position: absolute;
top: 2px; top: 2px;
right: -5px; right: -5px;
display: none; display: none;
width: 110px; width: 110px;
padding: 5px 40px 5px 10px; padding: 5px 40px 5px 10px;
@include border-radius(3px); @include border-radius(3px);
color: $lightGrey; color: $lightGrey;
text-align: right; text-align: right;
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
line-height: 16px; line-height: 16px;
} }
.menu-toggle { .menu-toggle {
z-index: 10; z-index: 10;
position: absolute; position: absolute;
top: 0; top: 0;
right: 5px; right: 5px;
padding: 5px; padding: 5px;
color: $mediumGrey; color: $mediumGrey;
&:hover, &.is-active { &:hover, &.is-active {
color: $blue; color: $blue;
} }
} }
.menu { .menu {
z-index: 1; z-index: 1;
display: none; display: none;
opacity: 0.0; opacity: 0.0;
position: absolute; position: absolute;
top: -1px; top: -1px;
left: 5px; left: 5px;
margin: 0; margin: 0;
padding: 8px 12px; padding: 8px 12px;
background: $white; background: $white;
border: 1px solid $mediumGrey; border: 1px solid $mediumGrey;
font-size: 12px; font-size: 12px;
@include border-radius(4px); @include border-radius(4px);
@include box-shadow(0 1px 2px rgba(0, 0, 0, .2)); @include box-shadow(0 1px 2px rgba(0, 0, 0, .2));
@include transition(opacity .15s); @include transition(opacity .15s);
li { li {
width: 115px; width: 115px;
margin-bottom: 3px; margin-bottom: 3px;
padding-bottom: 3px; padding-bottom: 3px;
border-bottom: 1px solid $lightGrey; border-bottom: 1px solid $lightGrey;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
padding-bottom: 0; padding-bottom: 0;
border: none; border: none;
a { a {
color: $darkGrey; color: $darkGrey;
} }
} }
} }
a { a {
color: $blue; color: $blue;
...@@ -127,262 +127,262 @@ input.courseware-unit-search-input { ...@@ -127,262 +127,262 @@ input.courseware-unit-search-input {
.courseware-section { .courseware-section {
position: relative; position: relative;
background: #fff; background: #fff;
border-radius: 3px; border-radius: 3px;
border: 1px solid $mediumGrey; border: 1px solid $mediumGrey;
margin-top: 15px; margin-top: 15px;
padding-bottom: 12px; padding-bottom: 12px;
@include box-shadow(0 1px 1px rgba(0, 0, 0, 0.1)); @include box-shadow(0 1px 1px rgba(0, 0, 0, 0.1));
&:first-child { &:first-child {
margin-top: 0; margin-top: 0;
} }
&.collapsed { &.collapsed {
padding-bottom: 0; padding-bottom: 0;
} }
label { label {
float: left; float: left;
line-height: 29px; line-height: 29px;
} }
.datepair { .datepair {
float: left; float: left;
margin-left: 10px; margin-left: 10px;
} }
.section-published-date { .section-published-date {
position: absolute; position: absolute;
top: 19px; top: 19px;
right: 90px; right: 90px;
padding: 4px 10px; padding: 4px 10px;
border-radius: 3px; border-radius: 3px;
background: $lightGrey; background: $lightGrey;
text-align: right; text-align: right;
.published-status { .published-status {
font-size: 12px; font-size: 12px;
margin-right: 15px; margin-right: 15px;
strong { strong {
font-weight: bold; font-weight: bold;
} }
} }
.schedule-button { .schedule-button {
@include blue-button; @include blue-button;
} }
.edit-button { .edit-button {
@include blue-button; @include blue-button;
} }
.schedule-button, .schedule-button,
.edit-button { .edit-button {
font-size: 11px; font-size: 11px;
padding: 3px 15px 5px; padding: 3px 15px 5px;
} }
} }
.datepair .date, .datepair .date,
.datepair .time { .datepair .time {
padding-left: 0; padding-left: 0;
padding-right: 0; padding-right: 0;
border: none; border: none;
background: none; background: none;
@include box-shadow(none); @include box-shadow(none);
font-size: 13px; font-size: 13px;
font-weight: bold; font-weight: bold;
color: $blue; color: $blue;
cursor: pointer; cursor: pointer;
} }
.datepair .date { .datepair .date {
width: 80px; width: 80px;
} }
.datepair .time { .datepair .time {
width: 65px; width: 65px;
} }
&.collapsed .subsection-list, &.collapsed .subsection-list,
.collapsed .subsection-list, .collapsed .subsection-list,
.collapsed > ol { .collapsed > ol {
display: none !important; display: none !important;
} }
header { header {
min-height: 75px; min-height: 75px;
@include clearfix(); @include clearfix();
.item-details, .section-published-date { .item-details, .section-published-date {
} }
.item-details { .item-details {
display: inline-block; display: inline-block;
padding: 20px 0 10px 0; padding: 20px 0 10px 0;
@include clearfix(); @include clearfix();
.section-name { .section-name {
float: left; float: left;
margin-right: 10px; margin-right: 10px;
width: 350px; width: 350px;
font-size: 19px; font-size: 19px;
font-weight: bold; font-weight: bold;
color: $blue; color: $blue;
} }
.section-name-span { .section-name-span {
cursor: pointer; cursor: pointer;
@include transition(color .15s); @include transition(color .15s);
&:hover { &:hover {
color: $orange; color: $orange;
} }
} }
.section-name-edit { .section-name-edit {
position: relative; position: relative;
width: 400px; width: 400px;
background: $white; background: $white;
input { input {
font-size: 16px; font-size: 16px;
} }
.save-button { .save-button {
@include blue-button; @include blue-button;
padding: 7px 20px 7px; padding: 7px 20px 7px;
margin-right: 5px; margin-right: 5px;
} }
.cancel-button { .cancel-button {
@include white-button; @include white-button;
padding: 7px 20px 7px; padding: 7px 20px 7px;
} }
} }
.section-published-date { .section-published-date {
float: right; float: right;
width: 265px; width: 265px;
margin-right: 220px; margin-right: 220px;
@include border-radius(3px); @include border-radius(3px);
background: $lightGrey; background: $lightGrey;
.published-status { .published-status {
font-size: 12px; font-size: 12px;
margin-right: 15px; margin-right: 15px;
strong { strong {
font-weight: bold; font-weight: bold;
} }
} }
.schedule-button { .schedule-button {
@include blue-button; @include blue-button;
} }
.edit-button { .edit-button {
@include blue-button; @include blue-button;
} }
.schedule-button, .schedule-button,
.edit-button { .edit-button {
font-size: 11px; font-size: 11px;
padding: 3px 15px 5px; padding: 3px 15px 5px;
} }
} }
.gradable-status { .gradable-status {
position: absolute; position: absolute;
top: 20px; top: 20px;
right: 70px; right: 70px;
width: 145px; width: 145px;
.status-label { .status-label {
position: absolute; position: absolute;
top: 0; top: 0;
right: 2px; right: 2px;
display: none; display: none;
width: 100px; width: 100px;
padding: 10px 35px 10px 10px; padding: 10px 35px 10px 10px;
@include border-radius(3px); @include border-radius(3px);
background: $lightGrey; background: $lightGrey;
color: $lightGrey; color: $lightGrey;
text-align: right; text-align: right;
font-size: 12px; font-size: 12px;
font-weight: bold; font-weight: bold;
line-height: 16px; line-height: 16px;
} }
.menu-toggle { .menu-toggle {
z-index: 10; z-index: 10;
position: absolute; position: absolute;
top: 2px; top: 2px;
right: 5px; right: 5px;
padding: 5px; padding: 5px;
color: $lightGrey; color: $lightGrey;
&:hover, &.is-active { &:hover, &.is-active {
color: $blue; color: $blue;
} }
} }
.menu { .menu {
z-index: 1; z-index: 1;
display: none; display: none;
opacity: 0.0; opacity: 0.0;
position: absolute; position: absolute;
top: -1px; top: -1px;
left: 2px; left: 2px;
margin: 0; margin: 0;
padding: 8px 12px; padding: 8px 12px;
background: $white; background: $white;
border: 1px solid $mediumGrey; border: 1px solid $mediumGrey;
font-size: 12px; font-size: 12px;
@include border-radius(4px); @include border-radius(4px);
@include box-shadow(0 1px 2px rgba(0, 0, 0, .2)); @include box-shadow(0 1px 2px rgba(0, 0, 0, .2));
@include transition(opacity .15s); @include transition(opacity .15s);
@include transition(display .15s); @include transition(display .15s);
li { li {
width: 115px; width: 115px;
margin-bottom: 3px; margin-bottom: 3px;
padding-bottom: 3px; padding-bottom: 3px;
border-bottom: 1px solid $lightGrey; border-bottom: 1px solid $lightGrey;
&:last-child { &:last-child {
margin-bottom: 0; margin-bottom: 0;
padding-bottom: 0; padding-bottom: 0;
border: none; border: none;
a { a {
color: $darkGrey; color: $darkGrey;
} }
} }
} }
a { a {
&.is-selected { &.is-selected {
font-weight: bold; font-weight: bold;
} }
} }
} }
// dropdown state // dropdown state
&.is-active { &.is-active {
.menu { .menu {
z-index: 1000; z-index: 1000;
display: block; display: block;
opacity: 1.0; opacity: 1.0;
} }
.menu-toggle { .menu-toggle {
...@@ -408,256 +408,278 @@ input.courseware-unit-search-input { ...@@ -408,256 +408,278 @@ input.courseware-unit-search-input {
} }
} }
.item-actions { .item-actions {
margin-top: 21px; margin-top: 21px;
margin-right: 12px; margin-right: 12px;
.edit-button, .edit-button,
.delete-button { .delete-button {
margin-top: -3px; margin-top: -3px;
} }
} }
.expand-collapse-icon { .expand-collapse-icon {
float: left; float: left;
margin: 29px 6px 16px 16px; margin: 29px 6px 16px 16px;
@include transition(none); @include transition(none);
&.expand { &.expand {
background-position: 0 0; background-position: 0 0;
} }
&.collapsed { &.collapsed {
} }
} }
.drag-handle { .drag-handle {
margin-left: 11px; margin-left: 11px;
} }
} }
h3 { h3 {
font-size: 19px; font-size: 19px;
font-weight: 700; font-weight: 700;
color: $blue; color: $blue;
} }
.section-name-span { .section-name-span {
cursor: pointer; cursor: pointer;
@include transition(color .15s); @include transition(color .15s);
&:hover { &:hover {
color: $orange; color: $orange;
} }
} }
.section-name-form { .section-name-form {
margin-bottom: 15px; margin-bottom: 15px;
} }
.section-name-edit { .section-name-edit {
input { input {
font-size: 16px; font-size: 16px;
} }
.save-button { .save-button {
@include blue-button; @include blue-button;
padding: 7px 20px 7px; padding: 7px 20px 7px;
margin-right: 5px; margin-right: 5px;
} }
.cancel-button { .cancel-button {
@include white-button; @include white-button;
padding: 7px 20px 7px; padding: 7px 20px 7px;
} }
} }
h4 { h4 {
font-size: 12px; font-size: 12px;
color: #878e9d; color: #878e9d;
strong { strong {
font-weight: bold; font-weight: bold;
} }
} }
.list-header { .list-header {
@include linear-gradient(top, transparent, rgba(0, 0, 0, .1)); @include linear-gradient(top, transparent, rgba(0, 0, 0, .1));
background-color: #ced2db; background-color: #ced2db;
border-radius: 3px 3px 0 0; border-radius: 3px 3px 0 0;
} }
.subsection-list { .subsection-list {
margin: 0 12px; margin: 0 12px;
> ol { > ol {
@include tree-view; @include tree-view;
border-top-width: 0; border-top-width: 0;
} }
} }
&.new-section { &.new-section {
header { header {
height: auto; height: auto;
@include clearfix(); @include clearfix();
} }
.expand-collapse-icon { .expand-collapse-icon {
visibility: hidden; visibility: hidden;
} }
} }
} }
.toggle-button-sections { .toggle-button-sections {
display: none; display: none;
position: relative; position: relative;
float: right; float: right;
margin-top: 10px; margin-top: 10px;
font-size: 13px; font-size: 13px;
color: $darkGrey; color: $darkGrey;
&.is-shown { &.is-shown {
display: block; display: block;
} }
.ss-icon { .ss-icon {
@include border-radius(20px); @include border-radius(20px);
position: relative; position: relative;
top: -1px; top: -1px;
display: inline-block; display: inline-block;
margin-right: 2px; margin-right: 2px;
line-height: 5px; line-height: 5px;
font-size: 11px; font-size: 11px;
} }
.label { .label {
display: inline-block; display: inline-block;
} }
} }
.new-section-name, .new-section-name,
.new-subsection-name-input { .new-subsection-name-input {
width: 515px; width: 515px;
} }
.new-section-name-save, .new-section-name-save,
.new-subsection-name-save { .new-subsection-name-save {
@include blue-button; @include blue-button;
padding: 4px 20px 7px; padding: 4px 20px 7px;
margin: 0 5px; margin: 0 5px;
color: #fff !important; color: #fff !important;
} }
.new-section-name-cancel, .new-section-name-cancel,
.new-subsection-name-cancel { .new-subsection-name-cancel {
@include white-button; @include white-button;
padding: 4px 20px 7px; padding: 4px 20px 7px;
color: #8891a1 !important; color: #8891a1 !important;
} }
.dummy-calendar { .dummy-calendar {
display: none; display: none;
position: absolute; position: absolute;
top: 55px; top: 55px;
left: 110px; left: 110px;
z-index: 9999; z-index: 9999;
border: 1px solid #3C3C3C; border: 1px solid #3C3C3C;
@include box-shadow(0 1px 15px rgba(0, 0, 0, .2)); @include box-shadow(0 1px 15px rgba(0, 0, 0, .2));
} }
.unit-name-input { .unit-name-input {
padding: 20px 40px; padding: 20px 40px;
label { label {
display: block; display: block;
} }
input { input {
width: 100%; width: 100%;
font-size: 20px; font-size: 20px;
} }
} }
.preview { .preview {
background: url(../img/preview.jpg) center top no-repeat; background: url(../img/preview.jpg) center top no-repeat;
} }
.edit-subsection-publish-settings { .edit-subsection-publish-settings {
display: none; display: none;
position: fixed; position: fixed;
top: 100px; top: 100px;
left: 50%; left: 50%;
z-index: 99999; z-index: 99999;
width: 600px; width: 600px;
margin-left: -300px; margin-left: -300px;
background: #fff; background: #fff;
text-align: center; text-align: center;
.settings { .settings {
padding: 40px; padding: 40px;
} }
h3 { h3 {
font-size: 34px; font-size: 34px;
font-weight: 300; font-weight: 300;
} }
.picker { .picker {
margin: 30px 0 65px; margin: 30px 0 65px;
} }
.description { .description {
margin-top: 30px; margin-top: 30px;
font-size: 14px; font-size: 14px;
line-height: 20px; line-height: 20px;
} }
strong { strong {
font-weight: 700; font-weight: 700;
} }
.start-date, .start-date,
.start-time { .start-time {
font-size: 19px; font-size: 19px;
} }
.save-button { .save-button {
@include blue-button; @include blue-button;
margin-right: 10px; margin-right: 10px;
} }
.cancel-button { .cancel-button {
@include white-button; @include white-button;
} }
.save-button, .save-button,
.cancel-button { .cancel-button {
font-size: 16px; font-size: 16px;
} }
} }
.collapse-all-button { .collapse-all-button {
float: right; float: right;
margin-top: 10px; margin-top: 10px;
font-size: 13px; font-size: 13px;
color: $darkGrey; color: $darkGrey;
} }
// sort/drag and drop // sort/drag and drop
.ui-droppable { .ui-droppable {
min-height: 20px; @include transition (padding 0.5s ease-in-out 0s);
min-height: 20px;
padding: 0;
&.dropover { &.dropover {
padding-top: 10px; padding: 15px 0;
padding-bottom: 10px; }
}
} }
ol.ui-droppable .branch:first-child .section-item { // sort/drag and drop - make room
border-top: none; .ui-dragging-pushdown {
@include transition (margin-top 0.5s ease-in-out 0s);
margin-top: 15px;
} }
.ui-dragging-pushup {
@include transition (margin-bottom 0.5s ease-in-out 0s);
margin-bottom: 15px;
}
.ui-draggable-dragging {
@include box-shadow(0 1px 2px rgba(0, 0, 0, .3));
border: 1px solid $darkGrey;
opacity : 0.2;
&:hover {
opacity : 1.0;
.section-item {
background: $yellow !important;
}
}
}
ol.ui-droppable .branch:first-child .section-item {
border-top: none;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment