vanilla-ujs 1.0.0 → 1.1.0

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: 14f0ac83907fa951b85f8c36a4abf4397564a61f
4
- data.tar.gz: f5bc439ec76f575df0d5b20fd0704e6a10c2f05c
3
+ metadata.gz: a47b807949142afc85940da96b26d29b531b3cf2
4
+ data.tar.gz: ce7d950d9958a0fe6976e4beeebe9d95a29ae5f6
5
5
  SHA512:
6
- metadata.gz: 5ecd119488a24f9c6e451556ac0dfce5727834b45a9aef0a7ce3e3818bad70b174c20ef8ebcf21935c584121f2e907b75475b8dedd389659535638c360e45218
7
- data.tar.gz: 4ae3bd3834ed47ff4898a8d653c6b35a8530da734c62616319646c79897ad2e21d8e24f2e2fb04f5ec8babf36f175065db338215f2701f2084fcf39f7d8b3ecc
6
+ metadata.gz: 7e98ef47919ab1d8aee800f1a5f5726cb6032e08f5bc7d26e8f2f00a9c55c0978dad255df132cdbb71b978f1e3e6981d14c5cd703e3c496fa4315d7a73ee17c7
7
+ data.tar.gz: b61890eee2ff6555fc591876fa213975992fc706c44a49238be8a46701f807d0e90ba7ff82b34745fd03b12111cd1cf02c52a27e9419a27578b78bf290c47df0
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /node_modules
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: node_js
2
+ before_script:
3
+ - npm install grunt-cli
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at lukasz@niemier.pl. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vanilla-ujs.gemspec
4
+ gemspec
data/Gruntfile.js ADDED
@@ -0,0 +1,67 @@
1
+ module.exports = function (grunt) {
2
+ grunt.initConfig({
3
+ pkg: grunt.file.readJSON('package.json'),
4
+ mocha: {
5
+ all: {
6
+ options: {
7
+ reporter: 'Spec'
8
+ }
9
+ },
10
+ ci: {
11
+ options: {
12
+ }
13
+ },
14
+ options: {
15
+ run: true,
16
+ urls: ['http://localhost:8000/index.html'],
17
+ }
18
+ },
19
+ concat: {
20
+ options: {
21
+ stripBanners: true,
22
+ banner: "(function (window, document) {\n'use strict';\n",
23
+ footer: '}).call(void(0), window, document);'
24
+ },
25
+ dist: {
26
+ src: [
27
+ 'lib/assets/javascripts/vanilla-ujs/polyfills.js',
28
+ 'lib/assets/javascripts/vanilla-ujs/liteajax.js',
29
+ 'lib/assets/javascripts/vanilla-ujs/method.js',
30
+ 'lib/assets/javascripts/vanilla-ujs/confirm.js',
31
+ 'lib/assets/javascripts/vanilla-ujs/disable.js',
32
+ 'lib/assets/javascripts/vanilla-ujs/csrf.js',
33
+ ],
34
+ dest: 'lib/assets/javascripts/vanilla-ujs.js'
35
+ }
36
+ },
37
+ express: {
38
+ test: {
39
+ options: {
40
+ port: 8000,
41
+ hostname: 'localhost',
42
+ server: 'test/helpers/serv.js',
43
+ bases: ['./lib/', './test/']
44
+ }
45
+ }
46
+ },
47
+ watch: {
48
+ tests: {
49
+ files: ["lib/**/*.js", "test/**/*.spec.js"],
50
+ tasks: ["test"],
51
+ },
52
+ }
53
+ });
54
+
55
+ grunt.registerTask('test', ['express:test', 'mocha:all']);
56
+ grunt.registerTask('webtest', ['express:test', 'express-keepalive']);
57
+ grunt.registerTask('ci', ['express:test', 'mocha:ci']);
58
+
59
+ grunt.registerTask('dist', ['concat']);
60
+ grunt.registerTask('default', ['test']);
61
+
62
+ grunt.loadNpmTasks('grunt-contrib-jshint');
63
+ grunt.loadNpmTasks('grunt-contrib-concat');
64
+ grunt.loadNpmTasks('grunt-contrib-watch');
65
+ grunt.loadNpmTasks('grunt-express');
66
+ grunt.loadNpmTasks('grunt-mocha');
67
+ };
data/LICENSE.txt CHANGED
@@ -1,4 +1,5 @@
1
- Copyright (c) 2015 Tsokurov Alex
1
+ Copyright (c) 2013 Łukasz Niemier
2
+
2
3
 
3
4
  MIT License
4
5
 
data/MAINTAINERS ADDED
@@ -0,0 +1 @@
1
+ Łukasz Jan Niemier <lukasz@niemier.pl> (@hauleth)
data/README.md CHANGED
@@ -1,22 +1,62 @@
1
1
  # Vanilla UJS
2
+ [![Build Status][travis-img]][travis-link][![Dependency Status](https://gemnasium.com/hauleth/vanilla-ujs.png)](https://gemnasium.com/hauleth/vanilla-ujs)
2
3
 
3
- It is implementation of Rails jQuery UJS in pure JavaScript. Based on [code of Łukasz Niemier](http://github.com/hauleth/vanilla-ujs).
4
+ It is implementation of Rails [jQuery UJS][jq-ujs] in pure JavaScript.
4
5
  No extra dependencies.
5
6
 
6
- ## Installation
7
+ ## Installation using the vanilla-ujs gem
7
8
 
8
- _Vanilla UJS_ is meant to work as a Rails plugin. To install it in your current application, add the following to your `Gemfile`:
9
+ For automated installation in Rails, use the `vanilla-ujs` gem.
10
+ Place this in your Gemfile:
9
11
 
10
12
  ```ruby
11
13
  gem 'vanilla-ujs'
12
14
  ```
13
15
 
14
- The _Vanilla UJS_ files will be added to the asset pipeline and available for you to use. Just add these lines in `app/assets/javascripts/application.js`:
16
+ And run:
15
17
 
16
- ```js
18
+ ```shell
19
+ $ bundle install
20
+ ```
21
+
22
+ Require `vanilla-ujs` into your application.js manifest.
23
+
24
+ ```javascript
17
25
  //= require vanilla-ujs
18
26
  ```
19
27
 
20
- ## Browser support
28
+ ## Does it mean that I shouldn't use jQuery
29
+
30
+ No. You should if you want. This library is created to make your Rails code
31
+ independent from front-end library.
32
+
33
+ ## Contribute
34
+
35
+ 1. Clone repo
36
+
37
+ $ git clone git://github.com/hauleth/vanilla-js.git
38
+ $ cd vanilla-js/
39
+
40
+ 2. Install dependencies
41
+
42
+ $ npm install
43
+
44
+ 3. Run tests
45
+
46
+ $ grunt test
47
+
48
+ ## Thanks
49
+
50
+ - Alex Tsokurov ([@ximik](https://github.com/ximik))
51
+ - Matt Huggins ([@mhuggins](https://github.com/mhuggins))
52
+ - Tasveer Singh ([@tazsingh](https://github.com/tazsingh))
53
+ - Tim O'Sulg ([@timgluz](https://github.com/timgluz))
54
+ - Walter Lee Davis ([@walterdavis](https://github.com/walterdavis))
55
+
56
+ # License
57
+
58
+ See [`LICENSE`](LICENSE.txt) file.
21
59
 
22
- This gem supports all modern browsers and IE10+.
60
+ [travis-img]: https://travis-ci.org/hauleth/vanilla-ujs.png?branch=master
61
+ [travis-link]: https://travis-ci.org/hauleth/vanilla-ujs
62
+ [jq-ujs]: https://github.com/rails/jquery-ujs
@@ -0,0 +1 @@
1
+ //= require_tree ./vanilla-ujs
@@ -0,0 +1,18 @@
1
+ document.addEventListener('click', function (event) {
2
+ var message, element;
3
+
4
+ element = event.target;
5
+
6
+ if (matches.call(element, 'a[data-disable-with], button[data-disable-with], input[data-disable-with]')) {
7
+ message = element.getAttribute('data-disable-with');
8
+ if(!!element.value){
9
+ element.value = message;
10
+ }else{
11
+ element.innerHTML = message;
12
+ }
13
+ // timeout is needed because Safari stops the submit if the button is immediately disabled
14
+ setTimeout(function(){
15
+ element.setAttribute('disabled', 'disabled');
16
+ }, 0);
17
+ }
18
+ }, false);
@@ -14,11 +14,9 @@ var LiteAjax = (function () {
14
14
 
15
15
  options = options || {};
16
16
  url = url || options.url || location.href || '';
17
- data = options.data;
17
+ var data = options.data;
18
18
 
19
- var xhr;
20
-
21
- xhr = new XMLHttpRequest();
19
+ var xhr = new XMLHttpRequest();
22
20
 
23
21
  xhr.addEventListener('load', function () {
24
22
  responseType = xhr.getResponseHeader('content-type');
@@ -51,7 +49,7 @@ var LiteAjax = (function () {
51
49
 
52
50
  if(options.json) {
53
51
  xhr.setRequestHeader('Content-type', 'application/json');
54
- data = JSON.stringify(data)
52
+ data = JSON.stringify(data);
55
53
  }
56
54
 
57
55
  var beforeSend = new CustomEvent('ajax:before', {detail: xhr});
data/lib/vanilla-ujs.rb CHANGED
@@ -1,4 +1 @@
1
- module VanillaUJS
2
- class Engine < ::Rails::Engine
3
- end
4
- end
1
+ require 'vanilla/ujs'
@@ -0,0 +1,8 @@
1
+ require 'vanilla/ujs/version'
2
+ require 'vanilla/ujs/rails'
3
+
4
+ module Vanilla
5
+ module Rails
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Vanilla
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Vanilla
2
+ module Ujs
3
+ VERSION = "1.1.0"
4
+ end
5
+ end
data/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "vanilla-ujs",
3
+ "version": "1.1.0",
4
+ "description": "Rails UJS in VanillaJS",
5
+ "main": "lib/assets/javascripts/vanilla-ujs.js",
6
+ "scripts": {
7
+ "build": "npm install && grunt dist",
8
+ "test": "grunt test",
9
+ "webtest": "grunt webtest"
10
+ },
11
+ "devDependencies": {
12
+ "body-parser": "*",
13
+ "express": "~4.13.0",
14
+ "grunt": "^0.4.5",
15
+ "grunt-contrib-concat": "*",
16
+ "grunt-contrib-jshint": "*",
17
+ "grunt-contrib-uglify": "*",
18
+ "grunt-contrib-watch": "*",
19
+ "grunt-express": "*",
20
+ "grunt-mocha": "*",
21
+ "grunt-parallel": "^0.4.1"
22
+ },
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git://github.com/hauleth/vanilla-ujs.git"
26
+ },
27
+ "keywords": [
28
+ "ujs",
29
+ "rails",
30
+ "vanilla"
31
+ ],
32
+ "author": "Łukasz Niemier",
33
+ "license": "MIT",
34
+ "bugs": {
35
+ "url": "https://github.com/hauleth/vanilla-ujs/issues"
36
+ },
37
+ "homepage": "https://github.com/hauleth/vanilla-ujs"
38
+ }
data/vanilla-ujs.gemspec CHANGED
@@ -1,18 +1,25 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vanilla/ujs/version'
2
5
 
3
- Gem::Specification.new do |s|
4
- s.name = "vanilla-ujs"
5
- s.version = "1.0.0"
6
- s.platform = Gem::Platform::RUBY
7
- s.authors = ["Alex Tsokurov", "Łukasz Niemier", "Kirill Pimenov"]
8
- s.email = ["me@ximik.net"]
9
- s.homepage = "https://github.com/Ximik/vanilla-ujs"
10
- s.summary = "UJS without jQuery dependency"
11
- s.description = "This gem provides Rails UJS features without jQuery library."
12
- s.license = "MIT"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'vanilla-ujs'
8
+ spec.version = Vanilla::Ujs::VERSION
9
+ spec.authors = ['Łukasz Jan Niemier', 'Alex Tsukurov', 'Kirill Pimenov']
10
+ spec.email = ['lukasz@niemier.pl', 'me@ximik.net']
13
11
 
14
- s.required_rubygems_version = ">= 1.3.6"
12
+ spec.summary = 'UJS without jQuery dependency'
13
+ spec.description = 'This gem provides Rails UJS features without jQuery library.'
14
+ spec.homepage = 'https://github.com/hauleth/vanilla-ujs'
15
+ spec.license = 'MIT'
15
16
 
16
- s.files = `git ls-files`.split("\n")
17
- s.require_path = 'lib'
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.required_rubygems_version = '>= 1.3.6'
21
+
22
+ spec.add_dependency 'railties', '>= 4.2.0'
23
+
24
+ spec.add_development_dependency 'bundler', '~> 1.11'
18
25
  end
metadata CHANGED
@@ -1,36 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanilla-ujs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
- - Alex Tsokurov
8
- - "Łukasz Niemier"
7
+ - "Łukasz Jan Niemier"
8
+ - Alex Tsukurov
9
9
  - Kirill Pimenov
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-12-12 00:00:00.000000000 Z
14
- dependencies: []
13
+ date: 2016-02-25 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: railties
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ">="
20
+ - !ruby/object:Gem::Version
21
+ version: 4.2.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ version: 4.2.0
29
+ - !ruby/object:Gem::Dependency
30
+ name: bundler
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - "~>"
34
+ - !ruby/object:Gem::Version
35
+ version: '1.11'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '1.11'
15
43
  description: This gem provides Rails UJS features without jQuery library.
16
44
  email:
45
+ - lukasz@niemier.pl
17
46
  - me@ximik.net
18
47
  executables: []
19
48
  extensions: []
20
49
  extra_rdoc_files: []
21
50
  files:
51
+ - ".gitignore"
52
+ - ".travis.yml"
53
+ - CODE_OF_CONDUCT.md
54
+ - Gemfile
55
+ - Gruntfile.js
22
56
  - LICENSE.txt
57
+ - MAINTAINERS
23
58
  - README.md
59
+ - lib/assets/javascripts/vanilla-ujs.js
60
+ - lib/assets/javascripts/vanilla-ujs/confirm.js
61
+ - lib/assets/javascripts/vanilla-ujs/csrf.js
62
+ - lib/assets/javascripts/vanilla-ujs/disable.js
63
+ - lib/assets/javascripts/vanilla-ujs/form.js
64
+ - lib/assets/javascripts/vanilla-ujs/liteajax.js
65
+ - lib/assets/javascripts/vanilla-ujs/method.js
66
+ - lib/assets/javascripts/vanilla-ujs/polyfills.js
24
67
  - lib/vanilla-ujs.rb
68
+ - lib/vanilla/ujs.rb
69
+ - lib/vanilla/ujs/rails.rb
70
+ - lib/vanilla/ujs/version.rb
71
+ - package.json
25
72
  - vanilla-ujs.gemspec
26
- - vendor/assets/javascripts/src/confirm.js
27
- - vendor/assets/javascripts/src/csrf.js
28
- - vendor/assets/javascripts/src/form.js
29
- - vendor/assets/javascripts/src/liteajax.js
30
- - vendor/assets/javascripts/src/method.js
31
- - vendor/assets/javascripts/src/polyfills.js
32
- - vendor/assets/javascripts/vanilla-ujs.js
33
- homepage: https://github.com/Ximik/vanilla-ujs
73
+ homepage: https://github.com/hauleth/vanilla-ujs
34
74
  licenses:
35
75
  - MIT
36
76
  metadata: {}
@@ -1 +0,0 @@
1
- //= require_tree ./src