jquery-multi-open-accordion-rails 1.5.3.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.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Claudio Carotenuto
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.
@@ -0,0 +1,29 @@
1
+ # Jquery::Multi::Open::Accordion::Rails
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'jquery-multi-open-accordion-rails'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install jquery-multi-open-accordion-rails
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require "jquery-multi-open-accordion-rails/version"
2
+
3
+ module JqueryMultiOpenAccordionRails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module JqueryMultiOpenAccordionRails
2
+ VERSION = "1.5.3.0"
3
+ end
@@ -0,0 +1,266 @@
1
+ /*
2
+ * jQuery UI Multi Open Accordion Plugin
3
+ * Author : Anas Nakawa (http://anasnakawa.wordpress.com/)
4
+ * Date : 22-Jul-2011
5
+ * Released Under MIT License
6
+ * You are welcome to enhance this plugin at https://code.google.com/p/jquery-multi-open-accordion/
7
+ */
8
+ (function($){
9
+
10
+ $.widget('ui.multiOpenAccordion', {
11
+ options: {
12
+ active: 0,
13
+ showAll: null,
14
+ hideAll: null,
15
+ _classes: {
16
+ accordion: 'ui-accordion ui-widget ui-helper-reset', // ui-accordion-icons',
17
+ h3: 'ui-accordion-header ui-helper-reset ui-state-default ui-accordion-icons ui-corner-all',
18
+ div: 'ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom',
19
+ divActive: 'ui-accordion-content-active',
20
+ span: 'ui-accordion-header-icon ui-icon ui-icon-triangle-1-e',
21
+ stateDefault: 'ui-state-default',
22
+ stateHover: 'ui-state-hover'
23
+ }
24
+ },
25
+
26
+ _create: function() {
27
+ var self = this,
28
+
29
+ options = self.options,
30
+
31
+ $this = self.element,
32
+
33
+ $h3 = $this.children('h3'),
34
+
35
+ $div = $this.children('div');
36
+
37
+ $this.addClass(options._classes.accordion);
38
+
39
+ $h3.each(function(index){
40
+ var $this = $(this);
41
+ $this.addClass(options._classes.h3).prepend('<span class="{class}"></span>'.replace(/{class}/, options._classes.span));
42
+ if(self._isActive(index)) {
43
+ self._showTab($this);
44
+ } else{
45
+ self._hideTab($this);
46
+ }
47
+ }); // end h3 each
48
+
49
+ $this.children('div').each(function(index){
50
+ var $this = $(this);
51
+ $this.addClass(options._classes.div);
52
+ }); // end each
53
+
54
+ $h3.bind('click', function(e){
55
+ // preventing on click to navigate to the top of document
56
+ e.preventDefault();
57
+ var $this = $(this);
58
+ var ui = {
59
+ tab: $this,
60
+ content: $this.next('div')
61
+ };
62
+ self._trigger('click', null, ui);
63
+ if ($this.hasClass(options._classes.stateDefault)) {
64
+ self._showTab($this);
65
+ } else {
66
+ self._hideTab($this);
67
+ }
68
+ });
69
+
70
+
71
+ $h3.bind('mouseover', function(){
72
+ $(this).addClass(options._classes.stateHover);
73
+ });
74
+
75
+ $h3.bind('mouseout', function(){
76
+ $(this).removeClass(options._classes.stateHover);
77
+ });
78
+
79
+ // triggering initialized
80
+ self._trigger('init', null, $this);
81
+
82
+ },
83
+
84
+ // destroying the whole multi open widget
85
+ destroy: function() {
86
+ var self = this;
87
+ var $this = self.element;
88
+ var $h3 = $this.children('h3');
89
+ var $div = $this.children('div');
90
+ var options = self.options;
91
+ $this.children('h3').unbind('click mouseover mouseout');
92
+ $this.removeClass(options._classes.accordion);
93
+ $h3.removeClass(options._classes.h3).removeClass('ui-state-default ui-corner-all ui-state-active ui-corner-top').children('span').remove();
94
+ $div.removeClass(options._classes.div + ' ' + options._classes.divActive).show();
95
+ },
96
+
97
+ // private helper method that used to show tabs
98
+ _showTab: function($this) {
99
+ var $span = $this.children('span.ui-icon');
100
+ var $div = $this.next();
101
+ var options = this.options;
102
+ $this.removeClass('ui-state-default ui-corner-all').addClass('ui-state-active ui-corner-top');
103
+ $span.removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
104
+ $div.slideDown('fast', function(){
105
+ $div.addClass(options._classes.divActive);
106
+ });
107
+ var ui = {
108
+ tab: $this,
109
+ content: $this.next('div')
110
+ };
111
+ this._trigger('tabShown', null, ui);
112
+ },
113
+
114
+ // private helper method that used to show tabs
115
+ _hideTab: function($this) {
116
+ var $span = $this.children('span.ui-icon');
117
+ var $div = $this.next();
118
+ var options = this.options;
119
+ $this.removeClass('ui-state-active ui-corner-top').addClass('ui-state-default ui-corner-all');
120
+ $span.removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
121
+ $div.slideUp('fast', function(){
122
+ $div.removeClass(options._classes.divActive);
123
+ });
124
+ var ui = {
125
+ tab: $this,
126
+ content: $this.next('div')
127
+ };
128
+ this._trigger('tabHidden', null, ui);
129
+ },
130
+
131
+ // helper method to determine wether passed parameter is an index of an active tab or not
132
+ _isActive: function(num) {
133
+ var options = this.options;
134
+ // if array
135
+ if(typeof options.active == "boolean" && !options.active) {
136
+ return false;
137
+ } else {
138
+ if(options.active.length != undefined) {
139
+ for (var i = 0; i < options.active.length ; i++) {
140
+ if(options.active[i] == num)
141
+ return true;
142
+ }
143
+ } else {
144
+ return options.active == num;
145
+ }
146
+ }
147
+ return false;
148
+ },
149
+
150
+ // return object contain currently opened tabs
151
+ _getActiveTabs: function() {
152
+ var $this = this.element;
153
+ var ui = [];
154
+ $this.children('div').each(function(index){
155
+ var $content = $(this);
156
+ if($content.is(':visible')) {
157
+ //ui = ui ? ui : [];
158
+ ui.push({
159
+ index: index,
160
+ tab: $content.prev('h3'),
161
+ content: $content
162
+ });
163
+ }
164
+ });
165
+ return (ui.length == 0 ? undefined : ui);
166
+ },
167
+
168
+ getActiveTabs: function() {
169
+ var el = this.element;
170
+ var tabs = [];
171
+ el.children('div').each(function(index){
172
+ if($(this).is(':visible')) {
173
+ tabs.push(index);
174
+ }
175
+ });
176
+ return (tabs.length == 0 ? [-1] : tabs);
177
+ },
178
+
179
+ // setting array of active tabs
180
+ _setActiveTabs: function(tabs) {
181
+ var self = this;
182
+ var $this = this.element;
183
+ if(typeof tabs != 'undefined') {
184
+ $this.children('div').each(function(index){
185
+ var $tab = $(this).prev('h3');
186
+ if(tabs.hasObject(index)) {
187
+ self._showTab($tab);
188
+ } else {
189
+ self._hideTab($tab);
190
+ }
191
+ });
192
+ }
193
+ },
194
+
195
+ // active option passed by plugin, this method will read it and convert it into array of tab indexes
196
+ _generateTabsArrayFromOptions: function(tabOption) {
197
+ var tabs = [];
198
+ var self = this;
199
+ var $this = self.element;
200
+ var size = $this.children('h3').size();
201
+ if($.type(tabOption) === 'array') {
202
+ return tabOption;
203
+ } else if($.type(tabOption) === 'number') {
204
+ return [tabOption];
205
+ } else if($.type(tabOption) === 'string') {
206
+ switch(tabOption.toLowerCase()) {
207
+ case 'all':
208
+ var size = $this.children('h3').size();
209
+ for(var n = 0 ; n < size ; n++) {
210
+ tabs.push(n);
211
+ }
212
+ return tabs;
213
+ break;
214
+ case 'none':
215
+ tabs = [-1];
216
+ return tabs;
217
+ break;
218
+ default:
219
+ return undefined;
220
+ break;
221
+ }
222
+ }
223
+ },
224
+
225
+ // required method by jquery ui widget framework, used to provide the ability to pass options
226
+ // currently only active option is used here, may grow in the future
227
+ _setOption: function(option, value){
228
+ $.Widget.prototype._setOption.apply( this, arguments );
229
+ var el = this.element;
230
+ switch(option) {
231
+ case 'active':
232
+ this._setActiveTabs(this._generateTabsArrayFromOptions(value));
233
+ break;
234
+ case 'getActiveTabs':
235
+ var el = this.element;
236
+ var tabs;
237
+ el.children('div').each(function(index){
238
+ if($(this).is(':visible')) {
239
+ tabs = tabs ? tabs : [];
240
+ tabs.push(index);
241
+ }
242
+ });
243
+ return (tabs.length == 0 ? [-1] : tabs);
244
+ break;
245
+ }
246
+ }
247
+
248
+ });
249
+
250
+ // helper array has object function
251
+ // thanks to @Vinko Vrsalovic
252
+ // http://stackoverflow.com/questions/143847/best-way-to-find-an-item-in-a-javascript-array
253
+ Array.prototype.hasObject = (!Array.indexOf ? function (o) {
254
+ var l = this.length + 1;
255
+ while (l -= 1) {
256
+ if (this[l - 1] === o) {
257
+ return true;
258
+ }
259
+ }
260
+ return false;
261
+ }: function (o) {
262
+ return (this.indexOf(o) !== -1);
263
+ }
264
+ );
265
+
266
+ })(jQuery);
@@ -0,0 +1,8 @@
1
+ /*
2
+ * jQuery UI Multi Open Accordion Plugin
3
+ * Author : Anas Nakawa (http://anasnakawa.wordpress.com/)
4
+ * Date : 22-Jul-2011
5
+ * Released Under MIT License
6
+ * You are welcome to enhance this plugin at https://code.google.com/p/jquery-multi-open-accordion/
7
+ */
8
+ (function(a){a.widget("ui.multiOpenAccordion",{options:{active:0,showAll:null,hideAll:null,_classes:{accordion:"ui-accordion ui-widget ui-helper-reset ui-accordion-icons",h3:"ui-accordion-header ui-helper-reset ui-state-default ui-corner-all",div:"ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom",divActive:"ui-accordion-content-active",span:"ui-icon ui-icon-triangle-1-e",stateDefault:"ui-state-default",stateHover:"ui-state-hover"}},_create:function(){var b=this,c=b.options,d=b.element,e=d.children("h3"),f=d.children("div");d.addClass(c._classes.accordion);e.each(function(d){var e=a(this);e.addClass(c._classes.h3).prepend('<span class="{class}"></span>'.replace(/{class}/,c._classes.span));if(b._isActive(d)){b._showTab(e)}});d.children("div").each(function(b){var d=a(this);d.addClass(c._classes.div)});e.bind("click",function(d){d.preventDefault();var e=a(this);var f={tab:e,content:e.next("div")};b._trigger("click",null,f);if(e.hasClass(c._classes.stateDefault)){b._showTab(e)}else{b._hideTab(e)}});e.bind("mouseover",function(){a(this).addClass(c._classes.stateHover)});e.bind("mouseout",function(){a(this).removeClass(c._classes.stateHover)});b._trigger("init",null,d)},destroy:function(){var a=this;var b=a.element;var c=b.children("h3");var d=b.children("div");var e=a.options;b.children("h3").unbind("click mouseover mouseout");b.removeClass(e._classes.accordion);c.removeClass(e._classes.h3).removeClass("ui-state-default ui-corner-all ui-state-active ui-corner-top").children("span").remove();d.removeClass(e._classes.div+" "+e._classes.divActive).show()},_showTab:function(a){var b=a.children("span.ui-icon");var c=a.next();var d=this.options;a.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top");b.removeClass("ui-icon-triangle-1-e").addClass("ui-icon-triangle-1-s");c.slideDown("fast",function(){c.addClass(d._classes.divActive)});var e={tab:a,content:a.next("div")};this._trigger("tabShown",null,e)},_hideTab:function(a){var b=a.children("span.ui-icon");var c=a.next();var d=this.options;a.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all");b.removeClass("ui-icon-triangle-1-s").addClass("ui-icon-triangle-1-e");c.slideUp("fast",function(){c.removeClass(d._classes.divActive)});var e={tab:a,content:a.next("div")};this._trigger("tabHidden",null,e)},_isActive:function(a){var b=this.options;if(typeof b.active=="boolean"&&!b.active){return false}else{if(b.active.length!=undefined){for(var c=0;c<b.active.length;c++){if(b.active[c]==a)return true}}else{return b.active==a}}return false},_getActiveTabs:function(){var b=this.element;var c=[];b.children("div").each(function(b){var d=a(this);if(d.is(":visible")){c.push({index:b,tab:d.prev("h3"),content:d})}});return c.length==0?undefined:c},getActiveTabs:function(){var b=this.element;var c=[];b.children("div").each(function(b){if(a(this).is(":visible")){c.push(b)}});return c.length==0?[-1]:c},_setActiveTabs:function(b){var c=this;var d=this.element;if(typeof b!="undefined"){d.children("div").each(function(d){var e=a(this).prev("h3");if(b.hasObject(d)){c._showTab(e)}else{c._hideTab(e)}})}},_generateTabsArrayFromOptions:function(b){var c=[];var d=this;var e=d.element;var f=e.children("h3").size();if(a.type(b)==="array"){return b}else if(a.type(b)==="number"){return[b]}else if(a.type(b)==="string"){switch(b.toLowerCase()){case"all":var f=e.children("h3").size();for(var g=0;g<f;g++){c.push(g)}return c;break;case"none":c=[-1];return c;break;default:return undefined;break}}},_setOption:function(b,c){a.Widget.prototype._setOption.apply(this,arguments);var d=this.element;switch(b){case"active":this._setActiveTabs(this._generateTabsArrayFromOptions(c));break;case"getActiveTabs":var d=this.element;var e;d.children("div").each(function(b){if(a(this).is(":visible")){e=e?e:[];e.push(b)}});return e.length==0?[-1]:e;break}}});Array.prototype.hasObject=!Array.indexOf?function(a){var b=this.length+1;while(b-=1){if(this[b-1]===a){return true}}return false}:function(a){return this.indexOf(a)!==-1}})(jQuery)
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-multi-open-accordion-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.5.3.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Claudio Carotenuto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.3'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: jquery-ui-sass-rails
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
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
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Jquery Multi Open Accordion for Rails
63
+ email:
64
+ - ing.claudio.carotenuto@gmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - lib/jquery-multi-open-accordion-rails/version.rb
70
+ - lib/jquery-multi-open-accordion-rails.rb
71
+ - vendor/assets/javascripts/jquery.multi-open-accordion.js
72
+ - vendor/assets/javascripts/jquery.multi-open-accordion.min.js
73
+ - LICENSE.txt
74
+ - README.md
75
+ homepage: ''
76
+ licenses:
77
+ - MIT
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 1.8.24
97
+ signing_key:
98
+ specification_version: 3
99
+ summary: Jquery Multi Open Accordion for Rails
100
+ test_files: []