angular-tabs 0.0.1

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f4b7fdd1ed2125fff8f56bc62ad8d0c56276306d
4
+ data.tar.gz: 45bc007c72e3964a247692f8e947e2147a240e98
5
+ SHA512:
6
+ metadata.gz: 3a848fbc71c7bd993e3f92fafb5b94f41df0e5b1bc6d2feecd5e310e7afddec41ac2d2569f7ec533f111c15c80caa7151382f6f0e0005c3b8bc1a34820500ad2
7
+ data.tar.gz: c95498895f1e64a3d4e752faebe84c83646b5a50152aeaab48aa12d52b6f98f3b59e0d98de791fbae57e2ccdeb2d1a8ab05bbead6b39406576e362d06388e184
@@ -0,0 +1,108 @@
1
+ // author: Samuel Mueller
2
+ // version: 0.0.1
3
+ // license: MIT
4
+ // homepage: http://github.com/ssmm/angular-tabs
5
+ (function() {
6
+ angular.module("angular-tabs", []);
7
+
8
+ angular.module("angular-tabs").service("angularTabs", [
9
+ function() {
10
+ var activeTabs;
11
+
12
+ activeTabs = {};
13
+ return {
14
+ getActiveTab: function(id) {
15
+ return activeTabs[id];
16
+ },
17
+ setActiveTab: function(id, title) {
18
+ return activeTabs[id] = title;
19
+ }
20
+ };
21
+ }
22
+ ]);
23
+
24
+ angular.module("angular-tabs").directive("angularTabs", [
25
+ "$compile", "angularTabs", function($compile, angularTabs) {
26
+ var compileTabsBody, createControl, createTab;
27
+
28
+ compileTabsBody = function(divs) {
29
+ var div, title, titles, _i, _len;
30
+
31
+ titles = [];
32
+ for (_i = 0, _len = divs.length; _i < _len; _i++) {
33
+ div = divs[_i];
34
+ div = angular.element(div);
35
+ title = div.attr("title");
36
+ titles.push(title);
37
+ div.attr("ng-show", "isActive('" + title + "')");
38
+ }
39
+ return titles;
40
+ };
41
+ createControl = function(classes, titles) {
42
+ var tabs, title, _i, _len;
43
+
44
+ tabs = angular.element("<ul></ul>");
45
+ if (!classes) {
46
+ tabs.addClass("nav");
47
+ tabs.addClass("nav-tabs");
48
+ } else {
49
+ tabs.addClass(classes);
50
+ }
51
+ for (_i = 0, _len = titles.length; _i < _len; _i++) {
52
+ title = titles[_i];
53
+ tabs.append(createTab(title));
54
+ }
55
+ return tabs;
56
+ };
57
+ createTab = function(title) {
58
+ var a, li;
59
+
60
+ li = angular.element("<li></li>");
61
+ li.attr("ng-class", "{active: isActive('" + title + "')}");
62
+ li.append(a = angular.element("<a>" + title + "</a>"));
63
+ a.attr("href", "");
64
+ a.attr("ng-click", "setActive('" + title + "')");
65
+ return li;
66
+ };
67
+ return {
68
+ restrict: "E",
69
+ scope: true,
70
+ compile: function(element, attributes, transclude) {
71
+ var control, divs, id, tabControls, titles;
72
+
73
+ id = attributes.id;
74
+ divs = element.children("div");
75
+ titles = compileTabsBody(divs);
76
+ tabControls = angular.element("angular-tabs-control[for=" + id + "]");
77
+ if (tabControls.length <= 0) {
78
+ control = createControl(attributes["class"], titles);
79
+ element.prepend(control);
80
+ }
81
+ return {
82
+ post: function($scope, $element, $attributes) {
83
+ var tabControl, _i, _len;
84
+
85
+ if (tabControls.length > 0) {
86
+ for (_i = 0, _len = tabControls.length; _i < _len; _i++) {
87
+ tabControl = tabControls[_i];
88
+ tabControl = angular.element(tabControl);
89
+ control = createControl(tabControl.attr("class"), titles);
90
+ $compile(control)($scope);
91
+ tabControl.append(control);
92
+ }
93
+ }
94
+ $scope.setActive = function(title) {
95
+ return angularTabs.setActiveTab(id, title);
96
+ };
97
+ $scope.isActive = function(title) {
98
+ return angularTabs.getActiveTab(id) === title;
99
+ };
100
+ $scope.setActive($attributes.activeTab);
101
+ }
102
+ };
103
+ }
104
+ };
105
+ }
106
+ ]);
107
+
108
+ }).call(this);
@@ -0,0 +1,4 @@
1
+ module AngularTabs
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module AngularTabs
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: angular-tabs
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Samuel Mueller
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-23 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.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Simple angular directive for declaring tabs.
42
+ email:
43
+ - mueller.samu@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - lib/angular-tabs/version.rb
49
+ - lib/angular-tabs.rb
50
+ - app/assets/javascripts/angular-tabs.js
51
+ homepage: https://github.com/ssmm/angular-tabs
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.0.3
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Simple angular directive for declaring tabs.
75
+ test_files: []