Skip to content

Commit 6426220

Browse files
committed
Packages assets as Rails engine
0 parents  commit 6426220

File tree

10 files changed

+226
-0
lines changed

10 files changed

+226
-0
lines changed

.gitignore

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
*.gem
2+
*.rbc
3+
.bundle
4+
.config
5+
.yardoc
6+
Gemfile.lock
7+
InstalledFiles
8+
_yardoc
9+
coverage
10+
doc/
11+
lib/bundler/man
12+
pkg
13+
rdoc
14+
spec/reports
15+
test/tmp
16+
test/version_tmp
17+
tmp

Gemfile

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
# Specify your gem's dependencies in bootstrap-tabdrop-rails.gemspec
4+
gemspec

LICENSE.txt

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Copyright (c) 2014 Thomas Floyd Wright
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.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# bootstrap-tabdrop-rails
2+
3+
bootstrap-tabdrop-rails wraps the [bootstrap-tabdrop.js](http://www.eyecon.ro/bootstrap-tabdrop/) library in a rails engine for simple use with the Rails asset pipeline. The gem includes the development (non-minified) source for ease of exploration. The asset pipeline will minify in production.
4+
5+
## Installation
6+
7+
Add the following to your gemfile:
8+
9+
gem 'bootstrap-tabdrop-rails'
10+
11+
Add the following directive to your Javascript manifest file (application.js):
12+
13+
//= require bootstrap-tabdrop

Rakefile

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
require "bundler/gem_tasks"

bootstrap-tabdrop-rails.gemspec

+23
Original file line numberDiff line numberDiff line change
@@ -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 'bootstrap/tabdrop/rails/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = "bootstrap-tabdrop-rails"
8+
spec.version = Bootstrap::Tabdrop::Rails::VERSION
9+
spec.authors = ["Thomas Floyd Wright", "Stefan Petre"]
10+
spec.email = ["[email protected]"]
11+
spec.description = %q{bootstrap-tabdrop plugin packaged as a Rails engine}
12+
spec.summary = %q{bootstrap-tabdrop plugin packaged as a Rails engine}
13+
spec.homepage = "http://github.com/tfwright/bootstrap-tabdrop-rails"
14+
spec.license = "MIT"
15+
16+
spec.files = Dir["{lib,vendor}/**/*"] + ["LICENSE.txt", "README.md"]
17+
spec.require_paths = ["lib"]
18+
19+
spec.add_development_dependency "bundler", "~> 1.3"
20+
spec.add_development_dependency "rake"
21+
22+
spec.add_dependency "railties", "~> 4"
23+
end

lib/bootstrap/tabdrop/rails.rb

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require "bootstrap/tabdrop/rails/version"
2+
3+
module Bootstrap
4+
module Tabdrop
5+
module Rails
6+
class Engine < ::Rails::Engine
7+
end
8+
end
9+
end
10+
end
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module Bootstrap
2+
module Tabdrop
3+
module Rails
4+
VERSION = "0.0.1"
5+
end
6+
end
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/* =========================================================
2+
* bootstrap-tabdrop.js
3+
* http://www.eyecon.ro/bootstrap-tabdrop
4+
* =========================================================
5+
* Copyright 2012 Stefan Petre
6+
*
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* ========================================================= */
19+
20+
!function( $ ) {
21+
22+
var WinReszier = (function(){
23+
var registered = [];
24+
var inited = false;
25+
var timer;
26+
var resize = function(ev) {
27+
clearTimeout(timer);
28+
timer = setTimeout(notify, 100);
29+
};
30+
var notify = function() {
31+
for(var i=0, cnt=registered.length; i<cnt; i++) {
32+
registered[i].apply();
33+
}
34+
};
35+
return {
36+
register: function(fn) {
37+
registered.push(fn);
38+
if (inited === false) {
39+
$(window).bind('resize', resize);
40+
inited = true;
41+
}
42+
},
43+
unregister: function(fn) {
44+
for(var i=0, cnt=registered.length; i<cnt; i++) {
45+
if (registered[i] == fn) {
46+
delete registered[i];
47+
break;
48+
}
49+
}
50+
}
51+
}
52+
}());
53+
54+
var TabDrop = function(element, options) {
55+
this.element = $(element);
56+
this.dropdown = $('<li class="dropdown hide pull-right tabdrop"><a class="dropdown-toggle" data-toggle="dropdown" href="#">'+options.text+' <b class="caret"></b></a><ul class="dropdown-menu"></ul></li>')
57+
.prependTo(this.element);
58+
if (this.element.parent().is('.tabs-below')) {
59+
this.dropdown.addClass('dropup');
60+
}
61+
WinReszier.register($.proxy(this.layout, this));
62+
this.layout();
63+
};
64+
65+
TabDrop.prototype = {
66+
constructor: TabDrop,
67+
68+
layout: function() {
69+
var collection = [];
70+
this.dropdown.removeClass('hide');
71+
this.element
72+
.append(this.dropdown.find('li'))
73+
.find('>li')
74+
.not('.tabdrop')
75+
.each(function(){
76+
if(this.offsetTop > 0) {
77+
collection.push(this);
78+
}
79+
});
80+
if (collection.length > 0) {
81+
collection = $(collection);
82+
this.dropdown
83+
.find('ul')
84+
.empty()
85+
.append(collection);
86+
if (this.dropdown.find('.active').length == 1) {
87+
this.dropdown.addClass('active');
88+
} else {
89+
this.dropdown.removeClass('active');
90+
}
91+
} else {
92+
this.dropdown.addClass('hide');
93+
}
94+
}
95+
}
96+
97+
$.fn.tabdrop = function ( option ) {
98+
return this.each(function () {
99+
var $this = $(this),
100+
data = $this.data('tabdrop'),
101+
options = typeof option === 'object' && option;
102+
if (!data) {
103+
$this.data('tabdrop', (data = new TabDrop(this, $.extend({}, $.fn.tabdrop.defaults,options))));
104+
}
105+
if (typeof option == 'string') {
106+
data[option]();
107+
}
108+
})
109+
};
110+
111+
$.fn.tabdrop.defaults = {
112+
text: '<i class="icon-align-justify"></i>'
113+
};
114+
115+
$.fn.tabdrop.Constructor = TabDrop;
116+
117+
}( window.jQuery );

vendor/assets/stylesheets/tabdrop.css

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/*!
2+
* Tab drop for Bootstrap
3+
*
4+
* Copyright 2012 Stefan Petre
5+
* Licensed under the Apache License v2.0
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
*/
9+
.nav-tabs,
10+
.nav-pills {
11+
position: relative;
12+
}

0 commit comments

Comments
 (0)