diff options
Diffstat (limited to 'js/components/layout/bread-crumb.reel/bread-crumb.js')
-rw-r--r-- | js/components/layout/bread-crumb.reel/bread-crumb.js | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js new file mode 100644 index 00000000..9782d9d1 --- /dev/null +++ b/js/components/layout/bread-crumb.reel/bread-crumb.js | |||
@@ -0,0 +1,110 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.Breadcrumb = Montage.create(Component, { | ||
11 | |||
12 | _container:{ | ||
13 | value:null | ||
14 | }, | ||
15 | |||
16 | |||
17 | container: { | ||
18 | set: function(value) { | ||
19 | if(this._container !== value) { | ||
20 | this._container = value; | ||
21 | this.createContainerElements(); | ||
22 | } | ||
23 | }, | ||
24 | get: function() { | ||
25 | return this._container; | ||
26 | } | ||
27 | }, | ||
28 | |||
29 | containerElements: { | ||
30 | value: [] | ||
31 | }, | ||
32 | |||
33 | deserializedFromTemplate : { | ||
34 | value: function() { | ||
35 | this.eventManager.addEventListener( "appLoaded", this, false); | ||
36 | this.eventManager.addEventListener( "openDocument", this, false); | ||
37 | this.eventManager.addEventListener( "breadCrumbTrail", this, false); | ||
38 | } | ||
39 | }, | ||
40 | |||
41 | handleAppLoaded : { | ||
42 | value: function() { | ||
43 | |||
44 | Object.defineBinding(this, "container", { | ||
45 | boundObject: this.application.ninja, | ||
46 | boundObjectPropertyPath: "currentSelectedContainer", | ||
47 | oneway: false | ||
48 | }); | ||
49 | } | ||
50 | }, | ||
51 | |||
52 | createContainerElements: { | ||
53 | value: function() { | ||
54 | var parentNode; | ||
55 | |||
56 | while(this.containerElements.pop()){ | ||
57 | // To empty the array to get the new parentNode of the new currentLevel | ||
58 | } | ||
59 | |||
60 | if(this.container.id === "UserContent") { | ||
61 | this.containerElements.push({selected:false,element:this.container}); | ||
62 | } else { | ||
63 | |||
64 | parentNode = this.container; | ||
65 | |||
66 | while(parentNode.id !== "UserContent") { | ||
67 | this.containerElements.unshift ({selected:false,element:parentNode}); | ||
68 | parentNode = parentNode.parentNode; | ||
69 | } | ||
70 | |||
71 | this.containerElements.unshift({selected:false,element:parentNode}); | ||
72 | |||
73 | } | ||
74 | |||
75 | NJevent('layerBinding',this.container); | ||
76 | } | ||
77 | }, | ||
78 | |||
79 | |||
80 | handleBreadCrumbTrail: { | ||
81 | value: function(event) { | ||
82 | var newLength, revaluatedLength, tmpvalue, i=0; | ||
83 | |||
84 | newLength = this.containerElements.length; | ||
85 | |||
86 | while(i < newLength ) { | ||
87 | if(this.containerElements[i].selected){ | ||
88 | tmpvalue = i ; | ||
89 | break; | ||
90 | } | ||
91 | |||
92 | i++; | ||
93 | } | ||
94 | |||
95 | for(i = newLength -1 ; i >= 1 ; i--) { | ||
96 | if(tmpvalue!==i) { | ||
97 | this.containerElements.pop(); | ||
98 | } else { | ||
99 | break; | ||
100 | } | ||
101 | } | ||
102 | |||
103 | revaluatedLength = this.containerElements.length; | ||
104 | this.application.ninja.currentSelectedContainer = this.containerElements[revaluatedLength-1].element; | ||
105 | |||
106 | } | ||
107 | } | ||
108 | |||
109 | |||
110 | }); | ||