jquery-simpletree-rails 0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 89e5604d4e1ee32f084b9be2603ec943b853175d
4
+ data.tar.gz: f17a481e055f318cde4734b1db87d0443ef0c56b
5
+ SHA512:
6
+ metadata.gz: 6a12d2b278f41051eb38e42f35ef0540b7e73d27b3171f35811a931abb9df6af7e5703d217551848e94bd31dcefb23e26a8c0c5ce4cb11e7a6ff37036fc66696
7
+ data.tar.gz: 2b347464bda95b3723b88b97001b6459d2dd6888ec0094eb64dc5825d5f6b04c1901326e6571142d9ef97782ecff333d28601e51ff43774a93ed22ef60ace267
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /bin/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jquery-simpletree-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Maurizio Manetti
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # jquery-simpletree-rails
2
+
3
+ This gem provides the jquery simpleTree plugin found at https://github.com/mauntrelio/jquery-simpletree/ for the Rails asset pipeline.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'jquery-simpletree-rails'
11
+ ```
12
+ And then execute:
13
+
14
+ $ bundle install
15
+
16
+ Add this to 'app/assets/javascripts/application.js':
17
+
18
+ //= require simpleTree/jquery.simpletree
19
+
20
+ Add this to 'app/assets/stylesheets/application.css':
21
+
22
+ //= require simpleTree/simpletree
23
+
24
+ That's it!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,169 @@
1
+ /*
2
+ Simple Tree jQuery plugin
3
+
4
+ Based on JS for simple unobtrusive javascript treeview plugin
5
+ developed by Krijn Hoetmer
6
+ http://krijnhoetmer.nl/stuff/javascript/list-treeview-menu/
7
+
8
+ Adapted as a jQuery plugin by Maurizio Manetti
9
+
10
+ */
11
+
12
+ ;(function( $, window, document, undefined ) {
13
+
14
+ "use strict";
15
+
16
+ var pluginName = 'simpleTree',
17
+ defaults = {
18
+ classChanged: 'st-treed',
19
+ classOpen: 'st-open',
20
+ classCollapsed: 'st-collapsed',
21
+ classLeaf: 'st-file',
22
+ classLast: 'st-last',
23
+ startCollapsed: true
24
+ };
25
+
26
+ // util function to get the real bg color of an element
27
+ var get_bgcolor = function(obj) {
28
+ var real = obj.css('backgroundColor');
29
+ var none = 'rgba(0, 0, 0, 0)';
30
+ // if bg color not set look for the color of first parent with a bg color set
31
+ if (real === none) {
32
+ real = obj.parents().filter(function() {
33
+ return $(this).css('backgroundColor') != none
34
+ }).first().css('backgroundColor');
35
+ }
36
+ // if bg color yet not set fallback to white
37
+ if (real === undefined) {
38
+ real = 'rgba(255, 255, 255, 255)';
39
+ }
40
+ return real;
41
+ }
42
+
43
+ var handleClick = function(e) {
44
+ if (!e) var e = window.event;
45
+ e.cancelBubble = true;
46
+ if (e.stopPropagation) e.stopPropagation();
47
+ }
48
+
49
+ function SimpleTree( element, options ) {
50
+ this.element = $(element);
51
+ this.settings = $.extend( {}, defaults, options);
52
+ this._defaults = defaults;
53
+ this._name = pluginName;
54
+ this.init();
55
+ }
56
+
57
+ SimpleTree.prototype.init = function () {
58
+ var settings = this.settings;
59
+ var $element = this.element;
60
+ // init the plugin on matched elements
61
+ $element.addClass(settings.classChanged);
62
+ // take all listed items
63
+ $element.find('li').each(function(index){
64
+ var $li = $(this);
65
+ // if the list item has unordered lists as children
66
+ if ($li.children('ul').length > 0) {
67
+ if (settings.startCollapsed) {
68
+ // add class collapsed if should start collapsed (it is the default setting)
69
+ // unless already has class open
70
+ if (!$li.hasClass(settings.classOpen)) {
71
+ $li.addClass(settings.classCollapsed);
72
+ }
73
+ } else {
74
+ // add class open if it should start open
75
+ // unless it already has class collapsed
76
+ if (!$li.hasClass(settings.classCollapsed)) {
77
+ $li.addClass(settings.classOpen);
78
+ }
79
+ }
80
+ // manage click on item
81
+ $li.on('mousedown',function(event) {
82
+ $li.toggleClass(settings.classOpen + ' ' + settings.classCollapsed); // toggle open / collapsed status
83
+ handleClick(event); // avoid propagation of the event to parent container(s)
84
+ });
85
+ } else {
86
+ $li.addClass(settings.classLeaf); // has no children: it's a leaf
87
+ }
88
+ // has no list items subsequent siblings: it is the last one
89
+ if ($li.next('li').length == 0) {
90
+ $li.addClass(settings.classLast);
91
+ // set the background color explicitly so to hide the UL vertical dots
92
+ $li.css('backgroundColor',get_bgcolor($li));
93
+ }
94
+ });
95
+ // avoid anchor tags click to fire collapse / open of parent containers
96
+ $element.find('a').on('mousedown',handleClick);
97
+ };
98
+
99
+ SimpleTree.prototype.expand = function(){
100
+ var settings = this.settings;
101
+ this.element.find('li.' + settings.classCollapsed).removeClass(settings.classCollapsed).addClass(settings.classOpen);
102
+ };
103
+
104
+ SimpleTree.prototype.collapse = function(){
105
+ var settings = this.settings;
106
+ this.element.find('li.' + settings.classOpen).removeClass(settings.classOpen).addClass(settings.classCollapsed);
107
+ };
108
+
109
+ SimpleTree.prototype._reset = function(){
110
+ // remove classes and event bindings
111
+ // method should never be called alone
112
+ var settings = this.settings;
113
+ var $element = this.element;
114
+ $element.removeClass(settings.classChanged);
115
+ $element.find('li').each(function(index){
116
+ var $li = $(this);
117
+ if ($li.hasClass(settings.classLast)) {
118
+ $li.css('backgroundColor','');
119
+ }
120
+ $li.removeClass(settings.classLeaf)
121
+ .removeClass(settings.classLast)
122
+ .off('mousedown');
123
+ });
124
+ };
125
+
126
+ SimpleTree.prototype.destroy = function(){
127
+ // reset interface and event binding
128
+ this._reset();
129
+ // remove data attributes (we are deleting the instance completely)
130
+ this.element.removeData('plugin_' + this._name);
131
+ };
132
+
133
+ SimpleTree.prototype.repaint = function(){
134
+ // reset and re-apply
135
+ this._reset();
136
+ this.init();
137
+ };
138
+
139
+ // evaluate method call or creation (similar to jQuery UI widget factory)
140
+ // prevent against multiple instantiations
141
+ // attach the plugin in the data-attribute of matched elements
142
+ $.fn[pluginName] = function ( options ) {
143
+ var isMethodCall = typeof options === "string";
144
+ if ( isMethodCall ) {
145
+ return this.each( function() {
146
+ var instance = $.data(this, 'plugin_' + pluginName);
147
+ if (!instance) {
148
+ // error: instance not initialized
149
+ console.error("Cannot call methods on " + pluginName + " prior to initialization; attempted to call method '" + options + "'" );
150
+ } else if ( !$.isFunction(instance[options]) ) {
151
+ // error: method not defined
152
+ console.error("No such method '" + options + "' for " + pluginName);
153
+ } else {
154
+ // finally call the desired method
155
+ instance[options].call(instance);
156
+ }
157
+ });
158
+ } else {
159
+ return this.each(function () {
160
+ if (!$.data(this, 'plugin_' + pluginName)) {
161
+ $.data(this, 'plugin_' + pluginName,
162
+ new SimpleTree( this, options ));
163
+ }
164
+ });
165
+ }
166
+ };
167
+
168
+ }( jQuery, window, document ));
169
+
@@ -0,0 +1,70 @@
1
+ /*
2
+ Simple Tree jQuery plugin
3
+
4
+ Based on CSS for simple unobtrusive javascript treeview plugin
5
+ developed by Krijn Hoetmer
6
+ http://krijnhoetmer.nl/stuff/javascript/list-treeview-menu/
7
+
8
+ Adapted as a jQuery plugin by Maurizio Manetti
9
+ */
10
+
11
+ .st-treed, .st-treed ul {
12
+ list-style-type: none;
13
+ margin: 0;
14
+ padding: 0;
15
+ background-image: url('simpleTree/vdot.gif');
16
+ background-repeat: repeat-y;
17
+ background-position: 8px 0;
18
+ }
19
+
20
+ .st-treed a {
21
+ text-decoration: none;
22
+ color: #000;
23
+ background-image: url('simpleTree/folder.gif');
24
+ background-repeat: no-repeat;
25
+ background-position: center left;
26
+ padding: 2px 0 2px 20px;
27
+ }
28
+
29
+ .st-treed li {
30
+ padding-top: 4px;
31
+ padding-left: 20px;
32
+ background-image: url('simpleTree/corner.gif');
33
+ background-repeat: no-repeat;
34
+ background-position: 8px 0;
35
+ }
36
+
37
+ .st-treed a:hover {
38
+ text-decoration: underline;
39
+ }
40
+
41
+ .st-treed .st-last {
42
+ background-image: url('simpleTree/corner.gif');
43
+ background-position: 8px 0;
44
+ }
45
+
46
+ .st-treed .st-collapsed, .st-treed .st-open {
47
+ background-repeat: no-repeat;
48
+ background-position: 4px 0;
49
+ cursor: pointer;
50
+ }
51
+
52
+ .st-treed .st-collapsed {
53
+ background-image: url('simpleTree/plus.gif');
54
+ }
55
+
56
+ .st-treed .st-open {
57
+ background-image: url('simpleTree/minus.gif');
58
+ }
59
+
60
+ .st-treed .st-collapsed ul {
61
+ display: none;
62
+ }
63
+
64
+ .st-treed .st-file a {
65
+ background-image: url('simpleTree/file.gif');
66
+ }
67
+
68
+ .st-treed a:hover {
69
+ background-color: transparent;
70
+ }
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jquery/simpletree/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jquery-simpletree-rails"
8
+ spec.version = Jquery::Simpletree::Rails::VERSION
9
+ spec.authors = ["Maurizio Manetti"]
10
+ spec.email = ["maurizio@imanetti.net"]
11
+
12
+ spec.summary = %q{}
13
+ spec.homepage = "https://github.com/mauntrelio/jquery-simpletree-rails"
14
+ spec.summary = %q{Use jQuery simpleTree with Rails 3.1 - 4.x}
15
+ spec.description = %q{This gem provides jQuery simpleTree for Rails 3.1 - 4.x application}
16
+
17
+ spec.license = "MIT"
18
+
19
+ spec.add_dependency "railties", "> 3.1", "< 5.0"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.13"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+
31
+ end
@@ -0,0 +1,8 @@
1
+ module Jquery
2
+ module Simpletree
3
+ module Rails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Jquery
2
+ module Simpletree
3
+ module Rails
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,2 @@
1
+ require 'jquery/simpletree/rails/engine'
2
+ require 'jquery/simpletree/rails/version'
@@ -0,0 +1,2 @@
1
+ require "jquery/simpletree/rails"
2
+ require "jquery/simpletree/rails"
@@ -0,0 +1,2 @@
1
+ require "jquery/simpletree/rails/version"
2
+ require "jquery/simpletree/rails/engine"
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-simpletree-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maurizio Manetti
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '5.0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '5.0'
33
+ - !ruby/object:Gem::Dependency
34
+ name: bundler
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '1.13'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.13'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rake
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '10.0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '10.0'
61
+ description: This gem provides jQuery simpleTree for Rails 3.1 - 4.x application
62
+ email:
63
+ - maurizio@imanetti.net
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - ".gitignore"
69
+ - Gemfile
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - app/assets/images/simpleTree/corner.gif
74
+ - app/assets/images/simpleTree/file.gif
75
+ - app/assets/images/simpleTree/folder.gif
76
+ - app/assets/images/simpleTree/minus.gif
77
+ - app/assets/images/simpleTree/plus.gif
78
+ - app/assets/images/simpleTree/vdot.gif
79
+ - app/assets/javascripts/simpleTree/jquery.simpletree.js
80
+ - app/assets/stylesheets/simpleTree/simpletree.css
81
+ - jquery-simpletree-rails.gemspec
82
+ - lib/jquery-simpletree-rails
83
+ - lib/jquery-simpletree-rails.rb
84
+ - lib/jquery/simpletree/rails.rb
85
+ - lib/jquery/simpletree/rails/engine.rb
86
+ - lib/jquery/simpletree/rails/version.rb
87
+ homepage: https://github.com/mauntrelio/jquery-simpletree-rails
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 2.4.8
108
+ signing_key:
109
+ specification_version: 4
110
+ summary: Use jQuery simpleTree with Rails 3.1 - 4.x
111
+ test_files: []