dijon 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/lib/dijon/rails/version.rb +1 -1
- data/vendor/assets/javascripts/dijon.js +18 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7452b0992a592f644a87ad6808f200c87b4f5a9a
|
4
|
+
data.tar.gz: a304396ad9083e41f100fa7c0b14e7d8e0435467
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2129f91ba2d027fb8c54e5940d26e3a8c29f923062e23f77f5af3740ca35ea9407ef1c2607f74d9a87de385614d30eddbeaeaea577c759853c3cd880caa29c29
|
7
|
+
data.tar.gz: 08b090d60f8f8bde4ebf6144383303dc0511c66b393d7a0b1c344c0bb4f5f3bc01b1b3e851e321739849967deaddf58267cdad144e97a96ca235e2b30686ed8d
|
data/README.md
CHANGED
@@ -4,11 +4,11 @@ dijon.js
|
|
4
4
|
Simple performance-focused Javascript DOM extensions and utilities. For those times when jQuery is too much.
|
5
5
|
|
6
6
|
### Browser Support
|
7
|
-
Chrome 38+
|
8
|
-
Firefox 33+
|
9
|
-
Internet Explorer
|
10
|
-
Opera 25+
|
11
|
-
Safari 8+
|
7
|
+
Chrome 38+
|
8
|
+
Firefox 33+
|
9
|
+
Internet Explorer 11+
|
10
|
+
Opera 25+
|
11
|
+
Safari 8+
|
12
12
|
|
13
13
|
### Helper Functions
|
14
14
|
```javascript
|
@@ -36,3 +36,8 @@ Element.prev() // returns previous sibling or null
|
|
36
36
|
Element.siblings() // returns NodeList of siblings excluding self
|
37
37
|
Element.index() // returns index of element in its parent container
|
38
38
|
```
|
39
|
+
|
40
|
+
### AJAX Functions
|
41
|
+
```javascript
|
42
|
+
ajax(method, url, data, callback) // sends an XMLHttpRequest with the data urlencoded for GET requests or serialized into JSON otherwise
|
43
|
+
```
|
data/lib/dijon/rails/version.rb
CHANGED
@@ -1,20 +1,26 @@
|
|
1
|
-
/* dijon.js ~ created by Dylan Waits ~ https://github.com/waits/dijon ~ updated 2015-04-
|
1
|
+
/* dijon.js ~ created by Dylan Waits ~ https://github.com/waits/dijon ~ updated 2015-04-2 */
|
2
2
|
|
3
3
|
function ajax(method, url, data, callback) {
|
4
|
+
method = method.toUpperCase();
|
4
5
|
var request = new XMLHttpRequest();
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
if (data) {
|
7
|
+
if (method == 'get' && data) {
|
8
|
+
url += '?';
|
9
|
+
for (var p in data) url += p + '=' + encodeURIComponent(data[p]) + '&';
|
10
|
+
}
|
11
|
+
else {
|
12
|
+
data = JSON.stringify(data);
|
13
|
+
}
|
11
14
|
}
|
12
15
|
request.open(method, url, true);
|
13
|
-
request.onload = function() {callback.call(this);};
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
16
|
+
if (callback) request.onload = function() {callback.call(this);};
|
17
|
+
if (method == 'get' || method == 'delete' || !data) {
|
18
|
+
request.send();
|
19
|
+
}
|
20
|
+
else {
|
21
|
+
request.setRequestHeader("Content-Type", "application/json");
|
22
|
+
request.send(data);
|
23
|
+
}
|
18
24
|
}
|
19
25
|
function get(id) {return document.getElementById(id) || document.createDocumentFragment().childNodes;}
|
20
26
|
function getClass(name) {return document.getElementsByClassName(name);}
|