the_data_role_block_jquery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e71e274f09068b5c8e8e23b2d7fec0555fd90dbe
4
+ data.tar.gz: 2266b19534c1ad9e3e5ae74c3c602d62cea53e3a
5
+ SHA512:
6
+ metadata.gz: 3e8e944153bd9f3af0b2f0972fa3fb175f4f5d760016ee17860233d44e9fab4436ea63f1dd8ab75bd959bf77fc9f8cc01b56ffd6045b26a4819fcf0bf47e4b95
7
+ data.tar.gz: 5eb402ac763f756f812ffc7ae482efc4858c52d75243a5be0fbaa9d6ea8ce50f0eae6dcd435d9e6453b4539d28ffa14689ce0b1ba8cb083240aea06dccfd3b43
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ *.gem
16
+ .DS_Store
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in the_data_role_block_jquery.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Ilya N. Zykin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # TheDataRoleBlockJquery
2
+
3
+ Mix of `data-role`, `data-block` solutions from:
4
+
5
+ 1. https://github.com/ai/evil-blocks
6
+ 2. https://github.com/kossnocorp/role
7
+
8
+ Gem provide
9
+
10
+ selector `@` for `data-role` and selector `@@` for `data-block` for `JQUERY`
11
+
12
+ JQ selectors for `data-role` and `data-block` items
13
+
14
+ ```coffeescript
15
+ $ ->
16
+ $('@hello-world').addRole 'sunshine'
17
+ $('@hello-world').removeRole 'sunshine'
18
+ $('@hello-world').toggleRole 'sunshine'
19
+
20
+ $('@@some-block').addBlock 'stone'
21
+ $('@@some-block').removeBlock 'stone'
22
+ $('@@some-block').toggleBlock 'stone'
23
+ ```
24
+
25
+ And SLIM template
26
+
27
+ ```slim
28
+ @hello-world
29
+ | Hello World
30
+
31
+ @@some-block
32
+ | WebBrick
33
+ ```
34
+
35
+ ## DATA-ATTRIBUTES notice
36
+
37
+ I use
38
+
39
+ 1. `data-block` aka `@@` for containers
40
+ 2. `data-role` aka `@` for items with handlers or for items with values
41
+
42
+ for example
43
+
44
+ **SLIM**
45
+ ```slim
46
+ button@btn-action
47
+
48
+ @@home
49
+ | Hello World
50
+ a#bird(href='#') Tweet
51
+ a#cat(href='#') Meow
52
+ a#dog(href='#') Woof
53
+ ```
54
+
55
+ **JS (CoffeeScript)**
56
+ ```coffeescript
57
+ $ ->
58
+ $('@btn-action').on 'click', (e) ->
59
+ $('@@home a').addClass 'pet'
60
+ false
61
+
62
+ $('@@home a').on 'click', (e) ->
63
+ link = $ e.target
64
+ console.log link.text()
65
+ false
66
+ ```
67
+
68
+ ## Installation
69
+
70
+ Add this line to your application's Gemfile:
71
+
72
+ ```ruby
73
+ gem 'the_data_role_block_jquery'
74
+ gem 'the_data_role_block_slim'
75
+
76
+ # or HAML version
77
+ # gem 'the_data_role_block_haml_40'
78
+ # gem 'the_data_role_block_haml_41'
79
+ ```
80
+
81
+ And then execute:
82
+
83
+ ```
84
+ bundle
85
+ ```
86
+
87
+ ## Usage
88
+
89
+ app/assets/javascripts/application.js
90
+
91
+ ```
92
+ //= require jquery.data-role-block
93
+ ```
94
+
95
+ ## MIT license
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,110 @@
1
+ !function($){
2
+ // https://github.com/kossnocorp/role gem based on role param
3
+ // https://github.com/ai/evil-blocks/ gem based on data-role and data-block param and created for slim
4
+ // this gem based on data-role and has patch for slim and haml
5
+ var rewriteSelector = function (context, name, pos) {
6
+ var original = context[name];
7
+ if ( !original ) return;
8
+
9
+ context[name] = function () {
10
+ arguments[pos] = arguments[pos].replace(
11
+ /@@([\w\u00c0-\uFFFF\-]+)/g, '[data-block~="$1"]');
12
+ arguments[pos] = arguments[pos].replace(
13
+ /@([\w\u00c0-\uFFFF\-]+)/g, '[data-role~="$1"]');
14
+ return original.apply(context, arguments);
15
+ };
16
+
17
+ $.extend(context[name], original);
18
+ };
19
+
20
+ rewriteSelector($, 'find', 0);
21
+ rewriteSelector($, 'multiFilter', 0);
22
+ rewriteSelector($.find, 'matchesSelector', 1);
23
+ rewriteSelector($.find, 'matches', 0);
24
+
25
+ function parse(roleString, without){
26
+ var role, result = [], roles = $.trim(roleString).split(/\s+/);
27
+
28
+ for(var i=0; i<roles.length; i++) {
29
+ role = roles[i];
30
+ if (!~$.inArray(role, result) && (!without || !~$.inArray(role, without)))
31
+ result.push(role);
32
+ }
33
+
34
+ return result;
35
+ };
36
+
37
+ $.extend($.fn, {
38
+ // roles
39
+ roles: function(){ return parse(this.attr('data-role')); },
40
+
41
+ hasRole: function(roleName){
42
+ var roles = parse(roleName);
43
+ for(var i=0;i<roles.length;i++)
44
+ if (!this.is('@'+roles[i])) return false;
45
+
46
+ return true;
47
+ },
48
+
49
+ addRole: function(roleName){
50
+ if (this.hasRole(roleName)) return this;
51
+
52
+ return this.each(function(_, element){
53
+ var $el = $(element);
54
+ $el.attr('data-role', parse($el.attr('data-role') + ' ' + roleName).join(' '));
55
+ });
56
+ },
57
+
58
+ removeRole: function(roleName){
59
+ if (!this.hasRole(roleName)) return this;
60
+
61
+ return this.each(function(_, element){
62
+ var $el = $(element);
63
+ $el.attr('data-role', parse($el.attr('data-role'), parse(roleName)).join(' '));
64
+ });
65
+ },
66
+
67
+ toggleRole: function(roleName){
68
+ var roles = parse(roleName);
69
+ for(var i=0;i<roles.length;i++)
70
+ this[this.hasRole(roles[i]) ? 'removeRole' : 'addRole'].call(this, roles[i]);
71
+ return this;
72
+ },
73
+
74
+ // Blocks
75
+ blocks: function(){ return parse(this.attr('data-block')); },
76
+
77
+ hasBlock: function(blockName){
78
+ var blocks = parse(blockName);
79
+ for(var i=0;i<blocks.length;i++)
80
+ if (!this.is('@@'+blocks[i])) return false;
81
+
82
+ return true;
83
+ },
84
+
85
+ addBlock: function(blockName){
86
+ if (this.hasBlock(blockName)) return this;
87
+
88
+ return this.each(function(_, element){
89
+ var $el = $(element);
90
+ $el.attr('data-block', parse($el.attr('data-block') + ' ' + blockName).join(' '));
91
+ });
92
+ },
93
+
94
+ removeBlock: function(blockName){
95
+ if (!this.hasBlock(blockName)) return this;
96
+
97
+ return this.each(function(_, element){
98
+ var $el = $(element);
99
+ $el.attr('data-block', parse($el.attr('data-block'), parse(blockName)).join(' '));
100
+ });
101
+ },
102
+
103
+ toggleBlock: function(blockName){
104
+ var blocks = parse(blockName);
105
+ for(var i=0;i<blocks.length;i++)
106
+ this[this.hasBlock(blocks[i]) ? 'removeBlock' : 'addBlock'].call(this, blocks[i]);
107
+ return this;
108
+ }
109
+ });
110
+ }(jQuery)
data/gem_version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module TheDataRoleBlockJquery
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "the_data_role_block_jquery/version"
2
+
3
+ module TheDataRoleBlockJquery
4
+ class Engine < ::Rails::Engine; end
5
+ end
@@ -0,0 +1 @@
1
+ require_relative '../../gem_version'
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'the_data_role_block_jquery/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "the_data_role_block_jquery"
8
+ spec.version = TheDataRoleBlockJquery::VERSION
9
+ spec.authors = ["Ilya N. Zykin"]
10
+ spec.email = ["zykin-ilya@ya.ru"]
11
+ spec.summary = %q{data-role(@), data-block(@@) selectors for JQUERY}
12
+ spec.description = %q{add data-role(@), data-block(@@) selectors into your Rails App}
13
+ spec.homepage = "https://github.com/data-role-block/the_data_role_block_jquery"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: the_data_role_block_jquery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ilya N. Zykin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: add data-role(@), data-block(@@) selectors into your Rails App
42
+ email:
43
+ - zykin-ilya@ya.ru
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - app/assets/javascripts/jquery.data-role-block.js
54
+ - gem_version.rb
55
+ - lib/the_data_role_block_jquery.rb
56
+ - lib/the_data_role_block_jquery/version.rb
57
+ - the_data_role_block_jquery.gemspec
58
+ homepage: https://github.com/data-role-block/the_data_role_block_jquery
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: data-role(@), data-block(@@) selectors for JQUERY
82
+ test_files: []