tagsjs-rails 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 0e895adee19d0ce08265904cf52874bab40dfa78fc9239c0b116e3c7abcc8b47
4
- data.tar.gz: 54daee958766e92a31bd613e374e3b544545f7261afc1fd655a54d5bb004c754
2
+ SHA1:
3
+ metadata.gz: 2ec661f403ea9cbb09d44ee4c4c77a5ddc034e39
4
+ data.tar.gz: 57f8ab3b8cf9d2056cbc93f55845f228eb4bb352
5
5
  SHA512:
6
- metadata.gz: 30aa49e965e24a26a8022020bad24a0df013669c4691affbca66d2b7eeadeccf6e34313296e8b831b60f865c3dac1829c2bc665ad03ef6bc9a6cf31cb4b2f9fc
7
- data.tar.gz: 10682fd5b6e9e40b4453596c2ed0ad9bad81e93b61ce116fe78c32b8da48b42d1f2b4ccb97252d22692d0471810f54da54511b5aa79a139fc937c1bac58d92b8
6
+ metadata.gz: 8ca5f91657789869f03d9a0d927eacb88081e6ce3338701a4aefcea6dd2e60d454ba50cc114e53bf85f1f1ff3eddd7eb61030a692d5c274cf97136d37bde0878
7
+ data.tar.gz: 16d556e1aba065100aaa848b1f4e5680eed0f424e04715b0671cd3fee0b2f6bffc18ff77ce047f04a22668da3045c1030a60a6648a64e8b4f2ba0048f5489bd8
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Tagsjs::Rails
2
- Short description and motivation.
2
+ Easily use [tagsjs](https://github.com/gosukiwi/tagsjs) in your Rails apps!
3
3
 
4
4
  ## Usage
5
5
  In your `application.js`
@@ -14,16 +14,14 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
14
14
  }
15
15
  })(function () {
16
16
  var jstags = {
17
- _createElement: function _createElement(tag, attributes, content) {
18
- if (typeof attributes === 'string') {
19
- content = attributes;
20
- }
21
-
17
+ _createElement: function _createElement(tag, attributes, content, events) {
22
18
  var element = document.createElement(tag);
23
19
 
20
+ this._setElementAttributes(attributes, element);
21
+
24
22
  this._setElementContents(content, element);
25
23
 
26
- this._setElementAttributes(attributes, element);
24
+ this._setElementEvents(events, element);
27
25
 
28
26
  return element;
29
27
  },
@@ -64,12 +62,24 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
64
62
  element.appendChild(content);
65
63
  }
66
64
  }
65
+ },
66
+ _setElementEvents: function _setElementEvents(events, element) {
67
+ if (!events) return;
68
+ Object.keys(events).forEach(function (name) {
69
+ element.addEventListener(name, events[name]);
70
+ });
67
71
  }
68
72
  };
69
73
  var AVAILABLE_TAGS = ['a', 'abbr', 'acronym', 'address', 'applet', 'area', 'article', 'aside', 'audio', 'b', 'base', 'basefont', 'bdi', 'bdo', 'big', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'data', 'datalist', 'dd', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'em', 'embed', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hr', 'html', 'i', 'iframe', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'link', 'main', 'map', 'mark', 'meta', 'meter', 'nav', 'noframes', 'noscript', 'object', 'ol', 'optgroup', 'option', 'output', 'p', 'param', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'script', 'section', 'select', 'small', 'source', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'svg', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'title', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr'];
70
74
  AVAILABLE_TAGS.forEach(function (tag) {
71
- jstags[tag] = function (attributes, content) {
72
- return this._createElement(tag, attributes, content);
75
+ jstags[tag] = function (attributes, content, events) {
76
+ if (typeof content === 'undefined') {
77
+ // when calling with a single argument
78
+ content = attributes;
79
+ attributes = undefined;
80
+ }
81
+
82
+ return this._createElement(tag, attributes, content, events);
73
83
  };
74
84
  });
75
85
  return jstags;
@@ -1,5 +1,5 @@
1
1
  module Tagsjs
2
2
  module Rails
3
- VERSION = '0.0.3'
3
+ VERSION = '0.1.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagsjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Federico Ramirez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -59,7 +59,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
- rubygems_version: 3.0.3
62
+ rubyforge_project:
63
+ rubygems_version: 2.5.2.3
63
64
  signing_key:
64
65
  specification_version: 4
65
66
  summary: Human-friendly API for building DOM elements in JavaScript.