├── tool
├── lib
│ ├── exclude.lst
│ └── html.sed
├── d2d
└── d2j
├── testcase
├── web
│ ├── core-01-html.dart
│ ├── core-01-html.html
│ ├── event-04-massive.html
│ ├── offset-01.dart
│ ├── css-01.dart
│ ├── manipulation-01.dart
│ ├── event-05-on-off.html
│ ├── manipulation-01.html
│ ├── data-01.html
│ ├── data-01.dart
│ ├── event-03-namespace.html
│ ├── event-01.dart
│ ├── event-05-on-off.dart
│ ├── manipulation-02.dart
│ ├── event-04-massive.dart
│ ├── event-01.html
│ ├── manipulation-02.html
│ ├── offset-01.html
│ ├── event-03-namespace.dart
│ ├── index.html
│ ├── css-01.html
│ ├── event-02-blur.html
│ └── event-02-blur.dart
└── pubspec.yaml
├── analysis_options.yaml
├── NOTICE
├── .gitattributes
├── pubspec.yaml
├── .gitignore
├── lib
├── src
│ ├── util
│ │ └── util.dart
│ ├── selector.dart
│ ├── cookie.dart
│ ├── data.dart
│ ├── dimension.dart
│ ├── offset.dart
│ ├── manipulation.dart
│ ├── css.dart
│ ├── traversing.dart
│ ├── dquery_api.dart
│ ├── dquery_impl.dart
│ └── event.dart
└── dquery.dart
├── CHANGELOG.md
├── README.md
├── doc
└── Comparison.md
└── LICENSE
/tool/lib/exclude.lst:
--------------------------------------------------------------------------------
1 | meta
2 | metadata
3 |
--------------------------------------------------------------------------------
/testcase/web/core-01-html.dart:
--------------------------------------------------------------------------------
1 | import 'package:dquery/dquery.dart';
2 |
3 | void main() {
4 | $('#div').append($(''));
5 | }
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | analyzer:
2 | errors:
3 | todo: ignore
4 | linter:
5 | rules:
6 | - annotate_overrides
7 | - avoid_init_to_null
8 | - camel_case_types
9 | - constant_identifier_names
10 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | Rikulo DQuery
2 | Copyright 2013 Potix corporation
3 |
4 | Portions of this software were developed based on the following:
5 | - Copyright 2013 jQuery Foundation and other contributors
6 | http://jquery.com/
7 | MIT License
8 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.dart text eol=lf
2 | *.html text eol=lf
3 | *.css text eof=lf
4 | *.less text eof=lf
5 | *.xml text eol=lf
6 | *.md text eol=lf
7 | *.yaml text eol=lf
8 | *.txt text eol=lf
9 | *.js text eof=lf
10 | *.lst text eof=lf
11 | d2d text eof=lf
12 | d2j text eof=lf
13 | l2c text eof=lf
14 |
--------------------------------------------------------------------------------
/testcase/web/core-01-html.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | core-01-html
5 |
6 |
7 |
8 | You shall see button append to here
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/testcase/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: dquery_example_app
2 | description: A web app example for dquery.
3 |
4 | environment:
5 | sdk: '>=3.7.0 <4.0.0'
6 |
7 | dependencies:
8 | dquery:
9 | path: ../
10 |
11 | dev_dependencies:
12 | build_runner: ^2.4.1
13 | build_test: ^2.1.7
14 | build_web_compilers: ^4.0.3
15 |
--------------------------------------------------------------------------------
/testcase/web/event-04-massive.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | event-04-massive
5 |
6 |
7 |
8 |
9 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: dquery
2 | version: 4.0.0+1
3 | description: |
4 | DQuery is a porting of jQuery in Dart.
5 | homepage: https://github.com/rikulo/dquery
6 | documentation: https://pub.dev/documentation/dquery/latest/
7 | environment:
8 | sdk: '>=3.7.0 <4.0.0'
9 | dependencies:
10 | intl: any
11 | web: '>=1.0.0'
12 | dev_dependencies:
13 | test: any
14 |
--------------------------------------------------------------------------------
/testcase/web/offset-01.dart:
--------------------------------------------------------------------------------
1 | import 'dart:js_interop';
2 |
3 | import 'package:web/web.dart';
4 | import 'package:dquery/dquery.dart';
5 |
6 | void main() {
7 |
8 | final offset = $('#target').offset!;
9 |
10 | final info = document.querySelector('#info')!;
11 | info.innerHTML = "${info.innerHTML} (${offset.x}, ${offset.y})".toJS;
12 |
13 | $('span').offset = offset;
14 |
15 | }
--------------------------------------------------------------------------------
/testcase/web/css-01.dart:
--------------------------------------------------------------------------------
1 | import 'package:dquery/dquery.dart';
2 |
3 | void main() {
4 |
5 | $('#show').on('click', (QueryEvent e) {
6 | $(':checked + .target').show();
7 | });
8 |
9 | $('#hide').on('click', (QueryEvent e) {
10 | $(':checked + .target').hide();
11 | });
12 |
13 | $('#toggle').on('click', (QueryEvent e) {
14 | $(':checked + .target').toggle();
15 | });
16 |
17 | }
--------------------------------------------------------------------------------
/testcase/web/manipulation-01.dart:
--------------------------------------------------------------------------------
1 | import 'package:web/web.dart';
2 | import 'package:dquery/dquery.dart';
3 |
4 | void main() {
5 |
6 | final input = document.querySelector('#input') as HTMLInputElement;
7 | final $html = $('#html');
8 | final $text = $('#text');
9 |
10 | $('#go').on('click', (QueryEvent event) {
11 | $html.html = input.value;
12 | $text.text = input.value;
13 | });
14 |
15 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .pub
3 | .idea/
4 | .packages
5 | debug
6 | codegen
7 | *.local
8 | *.class
9 | Thumbs.db
10 | .project
11 | .children
12 | *.dart.js
13 | *.dart.js_
14 | *.dart.js.map
15 | *.dart.js.deps
16 | out.js
17 | out.js.map
18 | out.js.deps
19 | out
20 | *.bak
21 | ~$*.pptx
22 | ~$*.docx
23 | ~$*.xlsx
24 | *.tmp
25 | packages
26 | packages/
27 | pubspec.lock
28 | .pub
29 | dquery.iml
30 | .dart_tool
31 |
--------------------------------------------------------------------------------
/testcase/web/event-05-on-off.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | event-05-on-off
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/testcase/web/manipulation-01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | manipulation-01
5 |
6 |
7 |
8 |
9 |
10 | html
11 |
12 | text
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/testcase/web/data-01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | data-01
6 |
7 |
8 |
9 |
10 |
11 | Element
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/testcase/web/data-01.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:dquery/dquery.dart';
3 |
4 | void main() {
5 | $('#addBtn').on('click', (QueryEvent e) {
6 | $('#e').data.set('time', DateTime.now());
7 | });
8 | $('#rmBtn').on('click', (QueryEvent e) {
9 | $('#e').data.remove('time');
10 | });
11 |
12 | $('#showBtn').on('click', (QueryEvent e) {
13 | Data d = $('#e').data;
14 | $('#msg').append('time: ${d.get("time")}
');
15 | });
16 |
17 | }
--------------------------------------------------------------------------------
/testcase/web/event-03-namespace.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | event-03-namespace
6 |
7 |
8 |
9 |
10 |
11 | Element
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/lib/src/util/util.dart:
--------------------------------------------------------------------------------
1 | part of dquery;
2 |
3 | // TODO: shall move to commons later
4 |
5 | int? _max(List nums) {
6 | if (nums.isEmpty)
7 | return null;
8 | int? m;
9 | for (final n in nums)
10 | m = m == null ? n: n == null ? m: max(m, n);
11 | return m;
12 | }
13 |
14 |
15 | // html //
16 |
17 | bool _hasAction(node, String name) {
18 | // TODO
19 | return false;
20 | }
21 |
22 | void _performAction(node, String name) {
23 | // TODO
24 | }
25 |
--------------------------------------------------------------------------------
/testcase/web/event-01.dart:
--------------------------------------------------------------------------------
1 | import 'package:dquery/dquery.dart';
2 | import 'package:web/web.dart';
3 | void main() {
4 |
5 | $document().on('click', (QueryEvent event) {
6 | print("${event.target}, data:${event.data}");
7 |
8 | }, selector: 'div.button');
9 |
10 | $('#trigger').on('click', (QueryEvent event) {
11 | print('trigger');
12 | $('div.button').trigger('click', data: 88);
13 | });
14 | $('#trigger').click((QueryEvent event) { print(event.type);});
15 | $('#input1').change((QueryEvent event) {
16 | var value=(event.target as HTMLInputElement).value;
17 | print("${event.target}, value:${value}");
18 | });
19 | }
20 |
--------------------------------------------------------------------------------
/testcase/web/event-05-on-off.dart:
--------------------------------------------------------------------------------
1 | import 'package:web/web.dart';
2 | import 'package:dquery/dquery.dart';
3 |
4 | void main() {
5 |
6 | final on = document.querySelector('#on') as HTMLButtonElement;
7 | final off = document.querySelector('#off') as HTMLButtonElement;
8 |
9 | $(on).on('click', (_) {
10 | $('#btn').on('click', f);
11 | off.disabled = false;
12 | on.disabled = true;
13 | });
14 |
15 | $(off).on('click', (_) {
16 | $('#btn').off('click', handler: f);
17 | off.disabled = true;
18 | on.disabled = false;
19 | });
20 |
21 | $('#one').one('click', (_) {
22 | window.alert('one');
23 | });
24 | }
25 |
26 | void f(QueryEvent event) {
27 | window.alert('hit!');
28 | }
29 |
--------------------------------------------------------------------------------
/testcase/web/manipulation-02.dart:
--------------------------------------------------------------------------------
1 | import 'package:web/web.dart';
2 | import 'package:dquery/dquery.dart';
3 |
4 | void main() {
5 |
6 | final input = document.querySelector('#input') as HTMLInputElement;
7 | final $target = $('#target');
8 |
9 | $('#append').on('click', (QueryEvent event) => $target.append(input.value));
10 | $('#prepend').on('click', (QueryEvent event) => $target.prepend(input.value));
11 | $('#after').on('click', (QueryEvent event) => $target.after(input.value));
12 | $('#before').on('click', (QueryEvent event) => $target.before(input.value));
13 |
14 | $('#appendTo').on('click', (QueryEvent event) => $(input.value).appendTo('#target'));
15 | $('#prependTo').on('click', (QueryEvent event) => $(input.value).prependTo('#target'));
16 |
17 | }
--------------------------------------------------------------------------------
/testcase/web/event-04-massive.dart:
--------------------------------------------------------------------------------
1 | import 'dart:js_interop';
2 |
3 | import 'package:web/web.dart';
4 | import 'package:dquery/dquery.dart';
5 |
6 | void main() {
7 |
8 | $('#btn').on('click', render);
9 |
10 | }
11 |
12 | void render(QueryEvent event) {
13 | final root = HTMLUListElement();
14 | final container = document.querySelector('#list')!;
15 | Element item;
16 |
17 | container.children.item(0)?.remove();
18 | final t = DateTime.now().millisecondsSinceEpoch;
19 | for (var i = 0; i < 1000; i++) {
20 | item = HTMLLIElement()..innerHTML = '$i'.toJS;
21 | $(item).on('click', (QueryEvent e) {
22 | window.alert("$i");
23 | });
24 | root.append(item);
25 | }
26 | print(DateTime.now().millisecondsSinceEpoch - t);
27 | container.append(root);
28 | }
29 |
--------------------------------------------------------------------------------
/testcase/web/event-01.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | test
6 |
7 |
8 |
9 |
10 |
11 |
20 | Text
21 |
22 |
23 | -
24 |
Button 1
25 |
26 | -
27 |
Button 2
28 |
29 |
30 |
31 |
32 |
33 |
34 |