Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 381
- Log:
Radiant is now packaged as a Gem - see Changeset #373, Changeset #374,
Changeset #375, Changeset #376, Changeset #377, Changeset #378,
Changeset #379 and Changeset #380. The application part of Radiant is
now mostly empty; it exists to provide a structure which hooks into the
gem and which provides a framework for extensions. Included in this big
changeset are all the deletions, additions and changes needed to go from
the old ROOL customised Radiant to a new ROOL customised Radiant, which
includes several custom extensions adapted from the old Radiant
modifications and requires Radiant 0.9.1 to be installed as a gem.
- Author:
- rool
- Date:
- Mon Mar 21 14:01:18 +0000 2011
- Size:
- 4024 Bytes
1 | /* |
2 | * sitemap.js |
3 | * |
4 | * depends on: prototype.js and lowpro.js |
5 | * |
6 | * Used by Radiant to create the expandable sitemap. |
7 | * |
8 | * To use, simply add the following lines to application.js: |
9 | * |
10 | * Event.addBehavior({ |
11 | * 'table#site_map': SiteMapBehavior() |
12 | * }); |
13 | * |
14 | */ |
15 | |
16 | var SiteMapBehavior = Behavior.create({ |
17 | initialize: function() { |
18 | this.readExpandedCookie(); |
19 | }, |
20 | |
21 | onclick: function(event) { |
22 | if (this.isExpander(event.target)) { |
23 | var row = event.findElement('tr'); |
24 | if (this.hasChildren(row)) { |
25 | this.toggleBranch(row, event.target); |
26 | } |
27 | } |
28 | }, |
29 | |
30 | hasChildren: function(row) { |
31 | return !row.hasClassName('no_children'); |
32 | }, |
33 | |
34 | isExpander: function(element) { |
35 | return element.match('img.expander'); |
36 | }, |
37 | |
38 | isExpanded: function(row) { |
39 | return row.hasClassName('children_visible'); |
40 | }, |
41 | |
42 | isRow: function(element) { |
43 | return element && element.tagName && element.match('tr'); |
44 | }, |
45 | |
46 | extractLevel: function(row) { |
47 | if (/level_(\d+)/i.test(row.className)) |
48 | return RegExp.$1.toInteger(); |
49 | }, |
50 | |
51 | extractPageId: function(row) { |
52 | if (/page_(\d+)/i.test(row.id)) |
53 | return RegExp.$1.toInteger(); |
54 | }, |
55 | |
56 | getExpanderImageForRow: function(row) { |
57 | return row.down('img'); |
58 | }, |
59 | |
60 | readExpandedCookie: function() { |
61 | var matches = document.cookie.match(/expanded_rows=(.+?);/); |
62 | this.expandedRows = matches ? decodeURIComponent(matches[1]).split(',') : []; |
63 | }, |
64 | |
65 | saveExpandedCookie: function() { |
66 | document.cookie = "expanded_rows=" + encodeURIComponent(this.expandedRows.uniq().join(",")) + "; path=/admin"; |
67 | }, |
68 | |
69 | persistCollapsed: function(row) { |
70 | var pageId = this.extractPageId(row); |
71 | this.expandedRows = this.expandedRows.without(pageId); |
72 | this.saveExpandedCookie(); |
73 | }, |
74 | |
75 | persistExpanded: function(row) { |
76 | this.expandedRows.push(this.extractPageId(row)); |
77 | this.saveExpandedCookie(); |
78 | }, |
79 | |
80 | toggleExpanded: function(row, img) { |
81 | if (!img) img = this.getExpanderImageForRow(row); |
82 | if (this.isExpanded(row)) { |
83 | img.src = img.src.replace('collapse', 'expand'); |
84 | row.removeClassName('children_visible'); |
85 | row.addClassName('children_hidden'); |
86 | this.persistCollapsed(row); |
87 | } else { |
88 | img.src = img.src.replace('expand', 'collapse'); |
89 | row.removeClassName('children_hidden'); |
90 | row.addClassName('children_visible'); |
91 | this.persistExpanded(row); |
92 | } |
93 | }, |
94 | |
95 | hideBranch: function(parent, img) { |
96 | var level = this.extractLevel(parent), row = parent.next(); |
97 | while (this.isRow(row) && this.extractLevel(row) > level) { |
98 | row.hide(); |
99 | row = row.next(); |
100 | } |
101 | this.toggleExpanded(parent, img); |
102 | }, |
103 | |
104 | showBranch: function(parent, img) { |
105 | var level = this.extractLevel(parent), row = parent.next(), |
106 | children = false, expandLevels = [level + 1]; |
107 | |
108 | while (this.isRow(row)) { |
109 | var currentLevel = this.extractLevel(row); |
110 | if (currentLevel <= level) break; |
111 | children = true; |
112 | if (currentLevel < expandLevels.last()) expandLevels.pop(); |
113 | if (expandLevels.include(currentLevel)) { |
114 | row.show(); |
115 | if (this.isExpanded(row)) expandLevels.push(currentLevel + 1); |
116 | } |
117 | row = row.next(); |
118 | } |
119 | if (!children) this.getBranch(parent); |
120 | this.toggleExpanded(parent, img); |
121 | }, |
122 | |
123 | getBranch: function(row) { |
124 | var id = this.extractPageId(row); |
125 | var level = this.extractLevel(row); |
126 | var spinner = $('busy_' + id); |
127 | |
128 | new Ajax.Updater( |
129 | row, |
130 | '../admin/pages/' + id + '/children/?level=' + level, |
131 | { |
132 | insertion: "after", |
133 | method: "get", |
134 | onLoading: function() { spinner.show(); this.updating = true }.bind(this), |
135 | onComplete: function() { spinner.fade(); this.updating = false }.bind(this) |
136 | } |
137 | ); |
138 | }, |
139 | |
140 | toggleBranch: function(row, img) { |
141 | if (!this.updating) { |
142 | if (this.isExpanded(row)) { |
143 | this.hideBranch(row, img); |
144 | } else { |
145 | this.showBranch(row, img); |
146 | } |
147 | } |
148 | } |
149 | }); |