rails-ng-breadcrumbs 0.4.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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +22 -0
- data/README.md +21 -0
- data/lib/rails-ng-breadcrumbs.rb +9 -0
- data/lib/rails-ng-breadcrumbs/engine.rb +4 -0
- data/lib/rails-ng-breadcrumbs/version.rb +3 -0
- data/vendor/assets/javascripts/ng-breadcrumbs.js +113 -0
- data/vendor/assets/javascripts/ng-breadcrumbs.min.js +1 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9dc5ceb90acc94bca87bdaa11468ed4b6bc1a1bf
|
4
|
+
data.tar.gz: a9451fe18af0811716061ec57d895d1d4e40467e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6e64326c4bfc98c9a7d2061e900d64c5fb35766bbb03f7be25cc7efddb6c4323f78e53ac3d816a56278b45039e7f91e6d76511a4f8939229c3afd3f186e3006
|
7
|
+
data.tar.gz: c1ea7b8571d6f6b36847b9b5057e3560748c253da28a2c993c3075dbb2b9c84df61cf8392ac3bc8a15420de3cf1d2727fac5eda7edc71a364876fa8102482186
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright 2015 Alexander Bobrov
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# rails-ng-breadcrumbs <a href="http://badge.fury.io/rb/rails-ng-breadcrumbs"><img src="https://badge.fury.io/rb/rails-ng-breadcrumbs.svg" alt="Gem Version" height="18"></a>
|
2
|
+
|
3
|
+
rails-ng-breadcrumbs wraps the [ngBreadcrumbs](https://github.com/ianwalter/ng-breadcrumbs/) module for use in Rails 3.1 and above.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Add the following to your Gemfile:
|
8
|
+
|
9
|
+
gem 'rails-ng-breadcrumbs'
|
10
|
+
|
11
|
+
Add the following to your Rails JavaScript manifest file:
|
12
|
+
|
13
|
+
//= require ng-breadcrumbs
|
14
|
+
|
15
|
+
If you desire to require minified version, add the following:
|
16
|
+
|
17
|
+
//= require ng-breadcrumbs.min
|
18
|
+
|
19
|
+
## Versioning
|
20
|
+
|
21
|
+
Current version of ngBreadcrumbs - 0.4.1
|
@@ -0,0 +1,113 @@
|
|
1
|
+
/**
|
2
|
+
* ng-breadcrumb.js - v0.4.1 - A better AngularJS service to help with
|
3
|
+
* breadcrumb-style navigation between views.
|
4
|
+
*
|
5
|
+
* @author Ian Kennington Walter (http://ianvonwalter.com)
|
6
|
+
*/
|
7
|
+
(function(angular) {
|
8
|
+
'use strict';
|
9
|
+
|
10
|
+
angular
|
11
|
+
.module('ng-breadcrumbs', [])
|
12
|
+
.factory('breadcrumbs', [
|
13
|
+
'$rootScope',
|
14
|
+
'$location',
|
15
|
+
'$route',
|
16
|
+
function ($rootScope, $location, $route) {
|
17
|
+
var BreadcrumbService = {
|
18
|
+
breadcrumbs: [],
|
19
|
+
get: function(options) {
|
20
|
+
this.options = options || this.options;
|
21
|
+
if (this.options) {
|
22
|
+
for (var key in this.options) {
|
23
|
+
if (this.options.hasOwnProperty(key)) {
|
24
|
+
for (var index in this.breadcrumbs) {
|
25
|
+
if (this.breadcrumbs.hasOwnProperty(index)) {
|
26
|
+
var breadcrumb = this.breadcrumbs[index];
|
27
|
+
if (breadcrumb.label === key) {
|
28
|
+
breadcrumb.label = this.options[key];
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
return this.breadcrumbs;
|
36
|
+
},
|
37
|
+
generateBreadcrumbs: function() {
|
38
|
+
var routes = $route.routes,
|
39
|
+
_this = this,
|
40
|
+
params,
|
41
|
+
pathElements,
|
42
|
+
pathObj = {},
|
43
|
+
path = '',
|
44
|
+
originalPath = '',
|
45
|
+
param;
|
46
|
+
|
47
|
+
if ($route && $route.current && $route.current.originalPath) {
|
48
|
+
this.breadcrumbs = [];
|
49
|
+
params = $route.current.params;
|
50
|
+
pathElements = $route.current.originalPath.trim().split('/');
|
51
|
+
|
52
|
+
// Necessary to get rid of of duplicate empty string on root path
|
53
|
+
if (pathElements[1] === '') {
|
54
|
+
pathElements.splice(1, 1);
|
55
|
+
}
|
56
|
+
|
57
|
+
angular.forEach(pathElements, function(pathElement, index) {
|
58
|
+
param = pathElement[0] === ':' &&
|
59
|
+
typeof params[pathElement
|
60
|
+
.slice(1, pathElement.length)] !== 'undefined' ?
|
61
|
+
params[pathElement.slice(1, pathElement.length)] :
|
62
|
+
false;
|
63
|
+
|
64
|
+
pathObj[index] = {
|
65
|
+
path: param || pathElement,
|
66
|
+
originalPath: pathElement
|
67
|
+
};
|
68
|
+
|
69
|
+
path = Object
|
70
|
+
.keys(pathObj)
|
71
|
+
.map(function(k) { return pathObj[k].path; })
|
72
|
+
.join('/') || '/';
|
73
|
+
|
74
|
+
originalPath = Object
|
75
|
+
.keys(pathObj)
|
76
|
+
.map(function(k) { return pathObj[k].originalPath; })
|
77
|
+
.join('/') || '/';
|
78
|
+
|
79
|
+
if (routes[originalPath] &&
|
80
|
+
(routes[originalPath].label || param) &&
|
81
|
+
!routes[originalPath].excludeBreadcrumb) {
|
82
|
+
_this.breadcrumbs.push({
|
83
|
+
path: path,
|
84
|
+
originalPath: originalPath,
|
85
|
+
label: routes[originalPath].label || param,
|
86
|
+
param: param
|
87
|
+
});
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
// We want to update breadcrumbs only when a route is actually changed
|
95
|
+
// as $location.path() will get updated immediately (even if route
|
96
|
+
// change fails!)
|
97
|
+
$rootScope.$on('$routeChangeSuccess', function() {
|
98
|
+
BreadcrumbService.generateBreadcrumbs();
|
99
|
+
});
|
100
|
+
|
101
|
+
$rootScope.$watch(
|
102
|
+
function() { return BreadcrumbService.options; },
|
103
|
+
function() {
|
104
|
+
BreadcrumbService.generateBreadcrumbs();
|
105
|
+
}
|
106
|
+
);
|
107
|
+
|
108
|
+
BreadcrumbService.generateBreadcrumbs();
|
109
|
+
|
110
|
+
return BreadcrumbService;
|
111
|
+
}
|
112
|
+
]);
|
113
|
+
})(angular);
|
@@ -0,0 +1 @@
|
|
1
|
+
!function(r){"use strict";r.module("ng-breadcrumbs",[]).factory("breadcrumbs",["$rootScope","$location","$route",function(t,e,n){var a={breadcrumbs:[],get:function(r){if(this.options=r||this.options,this.options)for(var t in this.options)if(this.options.hasOwnProperty(t))for(var e in this.breadcrumbs)if(this.breadcrumbs.hasOwnProperty(e)){var n=this.breadcrumbs[e];n.label===t&&(n.label=this.options[t])}return this.breadcrumbs},generateBreadcrumbs:function(){var t,e,a,i=n.routes,o=this,s={},u="",c="";n&&n.current&&n.current.originalPath&&(this.breadcrumbs=[],t=n.current.params,e=n.current.originalPath.trim().split("/"),""===e[1]&&e.splice(1,1),r.forEach(e,function(r,e){a=":"===r[0]&&"undefined"!=typeof t[r.slice(1,r.length)]?t[r.slice(1,r.length)]:!1,s[e]={path:a||r,originalPath:r},u=Object.keys(s).map(function(r){return s[r].path}).join("/")||"/",c=Object.keys(s).map(function(r){return s[r].originalPath}).join("/")||"/",i[c]&&(i[c].label||a)&&!i[c].excludeBreadcrumb&&o.breadcrumbs.push({path:u,originalPath:c,label:i[c].label||a,param:a})}))}};return t.$on("$routeChangeSuccess",function(){a.generateBreadcrumbs()}),t.$watch(function(){return a.options},function(){a.generateBreadcrumbs()}),a.generateBreadcrumbs(),a}])}(angular);
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-ng-breadcrumbs
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander Bobrov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-28 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Injects ngBreadcrumbs into your asset pipeline.
|
14
|
+
email: alexander@devvela.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- MIT-LICENSE
|
20
|
+
- README.md
|
21
|
+
- lib/rails-ng-breadcrumbs.rb
|
22
|
+
- lib/rails-ng-breadcrumbs/engine.rb
|
23
|
+
- lib/rails-ng-breadcrumbs/version.rb
|
24
|
+
- vendor/assets/javascripts/ng-breadcrumbs.js
|
25
|
+
- vendor/assets/javascripts/ng-breadcrumbs.min.js
|
26
|
+
homepage: https://github.com/alexkpek/rails-ng-breadcrumbs
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements: []
|
45
|
+
rubyforge_project:
|
46
|
+
rubygems_version: 2.4.6
|
47
|
+
signing_key:
|
48
|
+
specification_version: 4
|
49
|
+
summary: ngBreadcrumbs on Rails
|
50
|
+
test_files: []
|
51
|
+
has_rdoc:
|