dijon 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb69bdf0d770655dc375e3370864585f2a680934
4
- data.tar.gz: 392cdb059a0040efb4f4deabc58e190dc12d5527
3
+ metadata.gz: bcf77a326aa10ec4ad1802c7a2be5b5799f52963
4
+ data.tar.gz: 9a156f54b29d0ae112a612085b8c1736f11742a3
5
5
  SHA512:
6
- metadata.gz: 2d61d20bba08ea7aeb9cc7efcefe33a71425001779544ad29322c3bb3746a892304571a376cb17f27280ae758a4b07e042a932e4de420efe286c33f58f0cb317
7
- data.tar.gz: 32cccf4ffc767656adfd732cd2c62b7847fdf53a86e4582ae0d72b1975608ee658e433018d8540429ab7f67a32f9e587376e694a8cdcb961201b7d4d961160cc
6
+ metadata.gz: 3b752fe22b9f9613d9f5aed05c413987a809b60167b0a1ff1fee3ba4aac14c7ba696ac0acc4ff77051da6a0e91c19b2f942bb7bfa9f9c0bd3a015261a59481df
7
+ data.tar.gz: 13445ea10e0e65c5985439ffe55123b2c5db74475c287ef681f331d5ec11e2c11d54fccdd2405cdcbe90ead90310238cbae37b1745b5ed0db7c4dea79021ac98
data/README.md CHANGED
@@ -12,6 +12,7 @@ Safari 8+
12
12
 
13
13
  ### Helper Functions
14
14
  ```javascript
15
+ create(type[, content, attributes]) // creates an element of the given type, optionally with content as a String, Array of Nodes, or NodeList, and provided attributes
15
16
  get(id) // returns Element
16
17
  getClass(name) // returns NodeList
17
18
  getName(name) // returns NodeList
@@ -1,5 +1,5 @@
1
1
  module Dijon
2
2
  module Rails
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -1,4 +1,4 @@
1
- /* dijon.js ~ created by Dylan Waits ~ https://github.com/waits/dijon ~ updated 2015-04-2 */
1
+ /*! dijon.js ~ created by Dylan Waits ~ https://github.com/waits/dijon ~ updated 2015-04-11 */
2
2
 
3
3
  function ajax(method, url, data, callback) {
4
4
  method = method.toUpperCase();
@@ -22,11 +22,54 @@ function ajax(method, url, data, callback) {
22
22
  request.send(data);
23
23
  }
24
24
  }
25
+ function is(object) {
26
+ return Object.prototype.toString.call(object).slice(8, -1);
27
+ }
25
28
  function get(id) {return document.getElementById(id) || document.createDocumentFragment().childNodes;}
26
29
  function getClass(name) {return document.getElementsByClassName(name);}
27
30
  function getName(name) {return document.getElementsByName(name);}
28
31
  function getTag(name) {return document.getElementsByTagName(name);}
29
32
 
33
+ function create(type, child, options) {
34
+ var el = document.createElement(type);
35
+
36
+ if (options) {
37
+ for (var k in options) {
38
+ if (k == 'style') {
39
+ for (var s in options.style) {
40
+ el.style[s] = options.style[s];
41
+ }
42
+ }
43
+ else if (k == 'data') {
44
+ for (var d in options.data) {
45
+ el.dataset[d] = options.data[d];
46
+ }
47
+ }
48
+ else {
49
+ el[k] = options[k];
50
+ }
51
+ }
52
+ }
53
+
54
+ switch (is(child)) {
55
+ case "Null":
56
+ case "Undefined":
57
+ break;
58
+ case "String":
59
+ el.appendChild(document.createTextNode(child));
60
+ break;
61
+ case "NodeList":
62
+ child = Array.prototype.slice.call(child);
63
+ case "Array":
64
+ for (var c in child) el.appendChild(child[c]);
65
+ break;
66
+ default:
67
+ el.appendChild(child);
68
+ }
69
+
70
+ return el;
71
+ }
72
+
30
73
  Document.prototype.ready = function(callback) {
31
74
  callback(this);
32
75
  document.addEventListener('load', callback);
@@ -57,7 +100,7 @@ HTMLCollection.prototype.on = NodeList.prototype.on = function(event, callback)
57
100
  if (node.nodeType == 1) {
58
101
  node.on(event, callback);
59
102
  }
60
- }
103
+ }
61
104
  };
62
105
 
63
106
  HTMLCollection.prototype.each = NodeList.prototype.each = function(callback) {
@@ -100,7 +143,4 @@ Element.prototype.siblings = function() {
100
143
 
101
144
  Element.prototype.index = function() {
102
145
  return [].slice.call(this.parentNode.children).indexOf(this);
103
- };
104
- function is(object) {
105
- return Object.prototype.toString.call(object).replace(/^\[object (.+)\]$/, "$1");
106
- }
146
+ };
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dijon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dylan Waits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-03 00:00:00.000000000 Z
11
+ date: 2015-04-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  requirements:
90
90
  - - "~>"
91
91
  - !ruby/object:Gem::Version
92
- version: '2.1'
92
+ version: '2.2'
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - ">="