Skip to content

Commit

Permalink
Update to dart libraries 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marcojakob committed Nov 11, 2013
1 parent 08b0f62 commit 9da6e11
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 48 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
Changelog
================

## Version 0.3.5 (2013-11-11) ##
* Update to dart libraries 0.9.0.

## Version 0.3.4 (2013-10-08) ##
* Fix Issue #13: html5_dnd is incompatible with js-interop and the latest SDK
* Remove dependencies on meta package
Expand Down
52 changes: 26 additions & 26 deletions example/html5_dnd_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ initLogging() {
sectionDraggableAndDropzone() {
// Install draggables (documents).
DraggableGroup dragGroup = new DraggableGroup()
..installAll(queryAll('#draggable-dropzone .document'));
..installAll(querySelectorAll('#draggable-dropzone .document'));

// Install dropzone (trash).
DropzoneGroup dropGroup = new DropzoneGroup()
..install(query('#draggable-dropzone .trash'))
..install(querySelector('#draggable-dropzone .trash'))
..accept.add(dragGroup)
..onDrop.listen((DropzoneEvent event) {
event.draggable.remove();
Expand All @@ -59,35 +59,35 @@ sectionDraggableAndDropzone() {
sectionDraggingDivs() {
// Install draggable.
DraggableGroup dragGroup = new DraggableGroup()
..installAll(queryAll('#dragging-divs .dragme'));
..install(querySelector('#dragging-divs .dragme'));

// Install dropzone.
DropzoneGroup dropGroup = new DropzoneGroup()
..install(query('#dragging-divs .dropzone'))
..install(querySelector('#dragging-divs .dropzone'))
..accept.add(dragGroup);
}

sectionDropEffects() {
// Install draggables.
DraggableGroup dragGroupMove = new DraggableGroup()
..dropEffect = DROP_EFFECT_MOVE
..install(query('#drop-effects .move'));
..install(querySelector('#drop-effects .move'));

DraggableGroup dragGroupCopy = new DraggableGroup()
..dropEffect = DROP_EFFECT_COPY
..install(query('#drop-effects .copy'));
..install(querySelector('#drop-effects .copy'));

DraggableGroup dragGroupLink = new DraggableGroup()
..dropEffect = DROP_EFFECT_LINK
..install(query('#drop-effects .link'));
..install(querySelector('#drop-effects .link'));

DraggableGroup dragGroupNone = new DraggableGroup()
..dropEffect = DROP_EFFECT_NONE
..install(query('#drop-effects .none'));
..install(querySelector('#drop-effects .none'));

// Install dropzone.
DropzoneGroup dropGroup = new DropzoneGroup()
..install(query('#drop-effects .trash'))
..install(querySelector('#drop-effects .trash'))
..accept.addAll([dragGroupMove, dragGroupCopy, dragGroupLink, dragGroupNone])
..onDrop.listen((DropzoneEvent event) {
event.draggable.remove();
Expand All @@ -108,37 +108,37 @@ sectionDragImages() {
// Install draggables.
DraggableGroup dragGroupOne = new DraggableGroup(
dragImageFunction: (Element draggable) => new DragImage(png, 40, 40))
..install(query('#drag-images .one'));
..install(querySelector('#drag-images .one'));

DraggableGroup dragGroupTwo = new DraggableGroup(
dragImageFunction: (Element draggable) => new DragImage(png, -20, -20))
..install(query('#drag-images .two'));
..install(querySelector('#drag-images .two'));

DraggableGroup dragGroupThree = new DraggableGroup(
dragImageFunction: (Element draggable) => new DragImage(canvasImage, 20, 20))
..install(query('#drag-images .three'));
..install(querySelector('#drag-images .three'));

// Install dropzone.
DropzoneGroup dropGroup = new DropzoneGroup()
..install(query('#drag-images .dropzone'))
..install(querySelector('#drag-images .dropzone'))
..accept.addAll([dragGroupOne, dragGroupTwo, dragGroupThree]);
}

sectionNestedElements() {
TextAreaElement textarea = query('#nested-elements .dropzone textarea');
InputElement input = query('#nested-elements .dropzone input');
TextAreaElement textarea = querySelector('#nested-elements .dropzone textarea');
InputElement input = querySelector('#nested-elements .dropzone input');
input.value = 'Drag here!';
textarea.text = '';
int enterLeaveCounter = 1;
int overCounter = 1;

// Install draggables.
DraggableGroup dragGroup = new DraggableGroup()
..install(query('#nested-elements .dragme'));
..install(querySelector('#nested-elements .dragme'));

// Install dropzone.
DropzoneGroup dropGroup = new DropzoneGroup()
..install(query('#nested-elements .dropzone'))
..install(querySelector('#nested-elements .dropzone'))
..accept.add(dragGroup)
..onDragEnter.listen((DropzoneEvent event) {
textarea.appendText('${enterLeaveCounter++} drag enter fired\n');
Expand All @@ -159,7 +159,7 @@ sectionNestedElements() {

sectionSortableList() {
SortableGroup sortGroup = new SortableGroup()
..installAll(queryAll('#sortable-list li'))
..installAll(querySelectorAll('#sortable-list li'))
..onSortUpdate.listen((SortableEvent event) {
// do something when user sorted the elements...
});
Expand All @@ -171,15 +171,15 @@ sectionSortableList() {
sectionSortableGrid() {
SortableGroup sortGroup = new SortableGroup()
..isGrid = true
..installAll(queryAll('#sortable-grid li'));
..installAll(querySelectorAll('#sortable-grid li'));

// Only accept elements from this section.
sortGroup.accept.add(sortGroup);
}

sectionSortableListHandles() {
SortableGroup sortGroup = new SortableGroup(handle: 'span')
..installAll(queryAll('#sortable-list-handles li'));
..installAll(querySelectorAll('#sortable-list-handles li'));

// Only accept elements from this section.
sortGroup.accept.add(sortGroup);
Expand All @@ -189,22 +189,22 @@ sectionCancelDrag() {
// Install draggable.
DraggableGroup dragGroup = new DraggableGroup(
cancel: 'textarea, button, .nodrag')
..install(query('#cancel-drag .dragme'));
..install(querySelector('#cancel-drag .dragme'));
}

sectionSortableTwoGroups() {
ImageElement png = new ImageElement(src: 'icons/smiley-happy.png');

SortableGroup sortGroup1 = new SortableGroup()
..installAll(queryAll('#sortable-two-groups .group1 li'))
..installAll(querySelectorAll('#sortable-two-groups .group1 li'))
..onSortUpdate.listen((SortableEvent event) {
event.originalGroup.uninstall(event.draggable);
event.newGroup.install(event.draggable);
});

SortableGroup sortGroup2 = new SortableGroup(
dragImageFunction: (Element draggable) => new DragImage(png, 5, 5))
..installAll(queryAll('#sortable-two-groups .group2 li'))
..installAll(querySelectorAll('#sortable-two-groups .group2 li'))
..onSortUpdate.listen((SortableEvent event) {
if (event.originalGroup != event.newGroup) {
event.originalGroup.uninstall(event.draggable);
Expand All @@ -219,22 +219,22 @@ sectionSortableTwoGroups() {


_installCodeblockTabs() {
List<AnchorElement> tabLinks = queryAll('.example-code .menu li a');
List<AnchorElement> tabLinks = querySelectorAll('.example-code .menu li a');
for (AnchorElement link in tabLinks) {
link.onClick.listen((MouseEvent event) {
event.preventDefault();

Element exampleCodeParent = link.parent.parent.parent;

// Remove active class on all menu and content tabs.
exampleCodeParent.queryAll('[tab]').forEach((Element e) {
exampleCodeParent.querySelectorAll('[tab]').forEach((Element e) {
e.classes.remove('active');
});

// Add active class.
String currentTab = link.attributes['tab'];
link.classes.add('active');
exampleCodeParent.query('.content [tab="$currentTab"]').classes.add('active');
exampleCodeParent.querySelector('.content [tab="$currentTab"]').classes.add('active');
});
}
}
4 changes: 2 additions & 2 deletions lib/src/dnd/draggable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ List<StreamSubscription> _installDraggable(Element element, DraggableGroup group
bool _isValidDragStartTarget(Element element, EventTarget target,
String handle, String cancel) {
if (handle != null) {
List<Element> handles = element.queryAll(handle);
List<Element> handles = element.querySelectorAll(handle);
if (!handles.contains(target)) {
return false;
}
}

if (cancel != null) {
List<Element> cancels = element.queryAll(cancel);
List<Element> cancels = element.querySelectorAll(cancel);
if (cancels.contains(target)) {
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: html5_dnd
version: 0.3.4+1
version: 0.3.5
author: Marco Jakob <[email protected]>
description: HTML5 Drag and Drop
homepage: https://github.com/marcojakob/dart-html5-dnd
documentation: http://edu.makery.ch/projects/dart-html5-drag-and-drop
dependencies:
logging: '>=0.7.6'
logging: '>=0.9.0 <0.10.0'
dev_dependencies:
browser: '>=0.7.6'
intl: any
browser: '>=0.9.0 <0.10.0'
intl: '>=0.9.0 <0.10.0'
2 changes: 1 addition & 1 deletion test/complex_elements/complex_elements_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ initLogging() {

void installDragAndDrop() {
SortableGroup sortGroup = new SortableGroup()
..installAll(queryAll('.group'))
..installAll(querySelectorAll('.group'))
..onSortUpdate.listen((SortableEvent event) {
int originalIndex = event.originalPosition.index;
int newIndex = event.newPosition.index;
Expand Down
6 changes: 3 additions & 3 deletions test/multi_lists/multi_groups_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ initLogging() {

void installDragAndDrop() {
SortableGroup groupA = new SortableGroup()
..installAll(queryAll('#group-a-sort li'))
..installAll(querySelectorAll('#group-a-sort li'))
..forcePlaceholderSize = false
..onSortUpdate.listen((SortableEvent event) {
if (event.originalGroup != event.newGroup) {
Expand All @@ -38,7 +38,7 @@ void installDragAndDrop() {
});

SortableGroup groupB = new SortableGroup()
..installAll(queryAll('#group-b-sort li'))
..installAll(querySelectorAll('#group-b-sort li'))
..forcePlaceholderSize = false
..onSortUpdate.listen((SortableEvent event) {
if (event.originalGroup != event.newGroup) {
Expand All @@ -48,7 +48,7 @@ void installDragAndDrop() {
});

DraggableGroup groupC = new DraggableGroup()
..installAll(queryAll('#group-c-drag li'));
..installAll(querySelectorAll('#group-c-drag li'));

groupA.accept.add(groupB);
groupB.accept.addAll([groupA, groupB, groupC]);
Expand Down
12 changes: 6 additions & 6 deletions test/nested_dropzones/nested_dropzones_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ initLogging() {
void installDragAndDrop() {
// Install draggables.
DraggableGroup dragGroup1 = new DraggableGroup()
..installAll(queryAll('.draggable1'));
..installAll(querySelectorAll('.draggable1'));

DraggableGroup dragGroup2 = new DraggableGroup()
..installAll(queryAll('.draggable2'));
..installAll(querySelectorAll('.draggable2'));

// Install dropzones.
DropzoneGroup dropGroup1 = new DropzoneGroup()
..install(query('.container'))
..install(querySelector('.container'))
..accept.add(dragGroup1)
..onDrop.listen((DropzoneEvent event) {
event.dropzone.query('span').text = '!!dropped!!';
event.dropzone.querySelector('span').text = '!!dropped!!';
});

DropzoneGroup dropGroup2 = new DropzoneGroup()
..install(query('.child'))
..install(querySelector('.child'))
..accept.add(dragGroup2)
..onDrop.listen((DropzoneEvent event) {
event.dropzone.query('span').text = '!!dropped!!';
event.dropzone.querySelector('span').text = '!!dropped!!';
});
}
12 changes: 6 additions & 6 deletions test/svg/svg_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ initLogging() {

void installSvg() {
var svgDragGroup = new DraggableGroup()
..install(query('#draggable-svg'));
..install(querySelector('#draggable-svg'));

var divDragGroup = new DraggableGroup()
..install(query('#draggable-div'));
..install(querySelector('#draggable-div'));

new DropzoneGroup()
..install(query('#svg-dropzone'))
..install(query('#div-dropzone'))
..install(querySelector('#svg-dropzone'))
..install(querySelector('#div-dropzone'))
..accept.add(svgDragGroup)
..accept.add(divDragGroup);
}

void installSvgWithin() {
var svgDragGroup = new DraggableGroup()
..install(query('#drag-within-svg'));
..install(querySelector('#drag-within-svg'));

new DropzoneGroup()
..install(query('#drop-within-svg'))
..install(querySelector('#drop-within-svg'))
..accept.add(svgDragGroup);
}

0 comments on commit 9da6e11

Please sign in to comment.