cd2_tabs 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -2
- data/app/assets/javascripts/cd2_tabs_cookies.js +25 -0
- data/app/assets/javascripts/jscookie.js +165 -0
- data/lib/cd2_tabs/version.rb +1 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1df111b6813a8d39b86a6fae2e92100a24e36225
|
4
|
+
data.tar.gz: 1896654a027fa86d7d9d46c62db0312ea8c5dfdb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 375bf93f023377e235370f38badb651d28c0c2f2684d7d9407093c3acf2e44cbb0f09a5e156c1d51f253e8f99270011dcb5f4896ea058adf9dddfa60f640194a
|
7
|
+
data.tar.gz: 885f75e6cf0ad9b463b4a034ab57d050f3a71d0e99e881ee35f00b04ceb68d30229ace4ae66250601d78804551e069d650158b680a3c711e25c2d8522f2f8dd0
|
data/README.md
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
# Cd2Tabs
|
2
|
-
|
2
|
+
Allows you to easily create tabs.
|
3
3
|
|
4
4
|
## Usage
|
5
|
-
How to use my plugin.
|
6
5
|
|
6
|
+
```
|
7
|
+
<%= tabs do %>
|
8
|
+
<%= tab :name, 'Display Name', class: 'class_name' do %>
|
9
|
+
<h1>text</h1>
|
10
|
+
<% end %>
|
11
|
+
<% end %>
|
12
|
+
```
|
13
|
+
|
14
|
+
```
|
15
|
+
= tabs do
|
16
|
+
= tab :name, 'Display Name', class: 'class_name' do
|
17
|
+
%span text
|
18
|
+
```
|
19
|
+
|
20
|
+
Add
|
21
|
+
```
|
22
|
+
//= require cd2_tabs_cookies
|
23
|
+
```
|
24
|
+
to application.js enable remembering last clicked tab
|
7
25
|
## Installation
|
8
26
|
Add this line to your application's Gemfile:
|
9
27
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//= require jscookie
|
2
|
+
|
3
|
+
$(function (){
|
4
|
+
var cookieName = "tab_" + window.location.pathname;
|
5
|
+
var cookieTab = Cookies.get(cookieName);
|
6
|
+
|
7
|
+
if ( typeof cookieTab !== 'undefined' && cookieTab.length > 0 ) {
|
8
|
+
|
9
|
+
// Switching tabs on ajax load & switch tab on page load
|
10
|
+
$( document ).ajaxComplete(function( event, request, settings ) {
|
11
|
+
$(".tabs_container input[value='"+cookieTab+"']").prop( "checked", true );
|
12
|
+
});
|
13
|
+
|
14
|
+
$(".tabs_container input[value='"+cookieTab+"']").prop( "checked", true );
|
15
|
+
|
16
|
+
}
|
17
|
+
|
18
|
+
// Delegated event listener for tab heads for when ajax loading
|
19
|
+
$("body").on("click", ".tab_heads_container label", function(){
|
20
|
+
|
21
|
+
Cookies.set(cookieName, $(this).attr('class'), { expires: 0.01 });
|
22
|
+
|
23
|
+
})
|
24
|
+
|
25
|
+
})
|
@@ -0,0 +1,165 @@
|
|
1
|
+
/*!
|
2
|
+
* JavaScript Cookie v2.1.3
|
3
|
+
* https://github.com/js-cookie/js-cookie
|
4
|
+
*
|
5
|
+
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
|
6
|
+
* Released under the MIT license
|
7
|
+
*/
|
8
|
+
;(function (factory) {
|
9
|
+
var registeredInModuleLoader = false;
|
10
|
+
if (typeof define === 'function' && define.amd) {
|
11
|
+
define(factory);
|
12
|
+
registeredInModuleLoader = true;
|
13
|
+
}
|
14
|
+
if (typeof exports === 'object') {
|
15
|
+
module.exports = factory();
|
16
|
+
registeredInModuleLoader = true;
|
17
|
+
}
|
18
|
+
if (!registeredInModuleLoader) {
|
19
|
+
var OldCookies = window.Cookies;
|
20
|
+
var api = window.Cookies = factory();
|
21
|
+
api.noConflict = function () {
|
22
|
+
window.Cookies = OldCookies;
|
23
|
+
return api;
|
24
|
+
};
|
25
|
+
}
|
26
|
+
}(function () {
|
27
|
+
function extend () {
|
28
|
+
var i = 0;
|
29
|
+
var result = {};
|
30
|
+
for (; i < arguments.length; i++) {
|
31
|
+
var attributes = arguments[ i ];
|
32
|
+
for (var key in attributes) {
|
33
|
+
result[key] = attributes[key];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return result;
|
37
|
+
}
|
38
|
+
|
39
|
+
function init (converter) {
|
40
|
+
function api (key, value, attributes) {
|
41
|
+
var result;
|
42
|
+
if (typeof document === 'undefined') {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
|
46
|
+
// Write
|
47
|
+
|
48
|
+
if (arguments.length > 1) {
|
49
|
+
attributes = extend({
|
50
|
+
path: '/'
|
51
|
+
}, api.defaults, attributes);
|
52
|
+
|
53
|
+
if (typeof attributes.expires === 'number') {
|
54
|
+
var expires = new Date();
|
55
|
+
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
|
56
|
+
attributes.expires = expires;
|
57
|
+
}
|
58
|
+
|
59
|
+
// We're using "expires" because "max-age" is not supported by IE
|
60
|
+
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
|
61
|
+
|
62
|
+
try {
|
63
|
+
result = JSON.stringify(value);
|
64
|
+
if (/^[\{\[]/.test(result)) {
|
65
|
+
value = result;
|
66
|
+
}
|
67
|
+
} catch (e) {}
|
68
|
+
|
69
|
+
if (!converter.write) {
|
70
|
+
value = encodeURIComponent(String(value))
|
71
|
+
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
|
72
|
+
} else {
|
73
|
+
value = converter.write(value, key);
|
74
|
+
}
|
75
|
+
|
76
|
+
key = encodeURIComponent(String(key));
|
77
|
+
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
|
78
|
+
key = key.replace(/[\(\)]/g, escape);
|
79
|
+
|
80
|
+
var stringifiedAttributes = '';
|
81
|
+
|
82
|
+
for (var attributeName in attributes) {
|
83
|
+
if (!attributes[attributeName]) {
|
84
|
+
continue;
|
85
|
+
}
|
86
|
+
stringifiedAttributes += '; ' + attributeName;
|
87
|
+
if (attributes[attributeName] === true) {
|
88
|
+
continue;
|
89
|
+
}
|
90
|
+
stringifiedAttributes += '=' + attributes[attributeName];
|
91
|
+
}
|
92
|
+
return (document.cookie = key + '=' + value + stringifiedAttributes);
|
93
|
+
}
|
94
|
+
|
95
|
+
// Read
|
96
|
+
|
97
|
+
if (!key) {
|
98
|
+
result = {};
|
99
|
+
}
|
100
|
+
|
101
|
+
// To prevent the for loop in the first place assign an empty array
|
102
|
+
// in case there are no cookies at all. Also prevents odd result when
|
103
|
+
// calling "get()"
|
104
|
+
var cookies = document.cookie ? document.cookie.split('; ') : [];
|
105
|
+
var rdecode = /(%[0-9A-Z]{2})+/g;
|
106
|
+
var i = 0;
|
107
|
+
|
108
|
+
for (; i < cookies.length; i++) {
|
109
|
+
var parts = cookies[i].split('=');
|
110
|
+
var cookie = parts.slice(1).join('=');
|
111
|
+
|
112
|
+
if (cookie.charAt(0) === '"') {
|
113
|
+
cookie = cookie.slice(1, -1);
|
114
|
+
}
|
115
|
+
|
116
|
+
try {
|
117
|
+
var name = parts[0].replace(rdecode, decodeURIComponent);
|
118
|
+
cookie = converter.read ?
|
119
|
+
converter.read(cookie, name) : converter(cookie, name) ||
|
120
|
+
cookie.replace(rdecode, decodeURIComponent);
|
121
|
+
|
122
|
+
if (this.json) {
|
123
|
+
try {
|
124
|
+
cookie = JSON.parse(cookie);
|
125
|
+
} catch (e) {}
|
126
|
+
}
|
127
|
+
|
128
|
+
if (key === name) {
|
129
|
+
result = cookie;
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
|
133
|
+
if (!key) {
|
134
|
+
result[name] = cookie;
|
135
|
+
}
|
136
|
+
} catch (e) {}
|
137
|
+
}
|
138
|
+
|
139
|
+
return result;
|
140
|
+
}
|
141
|
+
|
142
|
+
api.set = api;
|
143
|
+
api.get = function (key) {
|
144
|
+
return api.call(api, key);
|
145
|
+
};
|
146
|
+
api.getJSON = function () {
|
147
|
+
return api.apply({
|
148
|
+
json: true
|
149
|
+
}, [].slice.call(arguments));
|
150
|
+
};
|
151
|
+
api.defaults = {};
|
152
|
+
|
153
|
+
api.remove = function (key, attributes) {
|
154
|
+
api(key, '', extend(attributes, {
|
155
|
+
expires: -1
|
156
|
+
}));
|
157
|
+
};
|
158
|
+
|
159
|
+
api.withConverter = init;
|
160
|
+
|
161
|
+
return api;
|
162
|
+
}
|
163
|
+
|
164
|
+
return init(function () {});
|
165
|
+
}));
|
data/lib/cd2_tabs/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cd2_tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CD2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '5.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: jquery-rails
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: sqlite3
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,6 +82,8 @@ files:
|
|
68
82
|
- MIT-LICENSE
|
69
83
|
- README.md
|
70
84
|
- Rakefile
|
85
|
+
- app/assets/javascripts/cd2_tabs_cookies.js
|
86
|
+
- app/assets/javascripts/jscookie.js
|
71
87
|
- app/assets/stylesheets/tabs.sass
|
72
88
|
- lib/cd2_tabs.rb
|
73
89
|
- lib/cd2_tabs/engine.rb
|
@@ -94,7 +110,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
110
|
version: '0'
|
95
111
|
requirements: []
|
96
112
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
113
|
+
rubygems_version: 2.6.6
|
98
114
|
signing_key:
|
99
115
|
specification_version: 4
|
100
116
|
summary: Generates tabs using css
|