Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 3400 Bytes
1 | if(typeof(relative_url_root) === 'undefined'){ relative_url_root = ''} |
2 | |
3 | var TabControlBehavior = Behavior.create({ |
4 | initialize: function() { |
5 | new TabControl(this.element); |
6 | } |
7 | }); |
8 | |
9 | var TabControl = Class.create({ |
10 | initialize: function(element) { |
11 | this.element = $(element); |
12 | TabControls[this.element.identify()] = this; |
13 | this.tabs = $A(); |
14 | this.tabContainer = this.element.down('.tabs'); |
15 | this.tabContainer.observe('click', this.ontabclick.bind(this)); |
16 | this.updateTabs(); |
17 | this.autoSelect(); |
18 | }, |
19 | |
20 | updateTabs: function() { |
21 | this.element.select('.page').each(function(page) { |
22 | if (!this.findTabByPage(page)) this.addTab(page); |
23 | }.bind(this)); |
24 | }, |
25 | |
26 | addTab: function(page) { |
27 | var tab = new TabControl.Tab(page); |
28 | this.tabs.push(tab); |
29 | this.tabContainer.insert({bottom: tab}); |
30 | $('page_part_index_field').setValue(this.tabs.length); |
31 | page.hide(); |
32 | }, |
33 | |
34 | removeSelected: function() { |
35 | var tab = this.selected; |
36 | var index = this.tabs.indexOf(tab); |
37 | var newSelectedTab = this.tabs[index-1]; |
38 | var idInput = tab.page.down('.id_input'); |
39 | var deleteInput = tab.page.down('.delete_input'); |
40 | deleteInput.setValue('true'); |
41 | tab.remove(); |
42 | this.tabs = this.tabs.without(tab); |
43 | this.element.insert(idInput).insert(deleteInput); |
44 | this.select(newSelectedTab || this.tabs.first()); |
45 | }, |
46 | |
47 | select: function(tab) { |
48 | if (this.selected) this.selected.unselect(); |
49 | this.selected = tab; |
50 | tab.select(); |
51 | cookie = Cookie.set('current_tab', tab.caption, 24, '/admin'); |
52 | }, |
53 | |
54 | autoSelect: function() { |
55 | if (!this.tabs.any()) return; |
56 | var caption = Cookie.get('current_tab'); |
57 | var tab = this.findTabByCaption(caption); |
58 | this.select(tab || this.tabs.first()); |
59 | }, |
60 | |
61 | ontabclick: function(event) { |
62 | var e = event.findElement('.tab'); |
63 | if (e) { |
64 | var tab = this.findTabByElement(e); |
65 | if (tab) { |
66 | if (event.target.hasClassName('close')) { |
67 | if (confirm('Remove the "' + tab.caption + '" part?')) { |
68 | var lastSelected = this.selected; |
69 | this.select(tab); |
70 | this.removeSelected(); |
71 | if (lastSelected != tab) this.select(lastSelected); |
72 | } |
73 | } else { |
74 | this.select(tab); |
75 | } |
76 | event.stop(); |
77 | } |
78 | } |
79 | }, |
80 | |
81 | findTabByCaption: function(caption) { |
82 | return this.tabs.detect(function(tab) { return tab.caption == caption }); |
83 | }, |
84 | |
85 | findTabByPage: function(page) { |
86 | return this.tabs.detect(function(tab) { return tab.page == page }); |
87 | }, |
88 | |
89 | findTabByElement: function(element) { |
90 | return this.tabs.detect(function(tab) { return tab.element == element }); |
91 | } |
92 | }); |
93 | |
94 | TabControl.Tab = Class.create({ |
95 | initialize: function(page) { |
96 | this.page = page; |
97 | this.caption = page.readAttribute('data-caption'); |
98 | }, |
99 | |
100 | select: function() { |
101 | this.page.show(); |
102 | this.element.addClassName('here'); |
103 | }, |
104 | |
105 | unselect: function() { |
106 | this.page.hide(); |
107 | this.element.removeClassName('here'); |
108 | }, |
109 | |
110 | remove: function() { |
111 | this.page.remove(); |
112 | this.element.remove(); |
113 | }, |
114 | |
115 | toElement: function() { |
116 | this.element = $a({'href': '#', 'class': 'tab'}, $span(this.caption), $img({'src': relative_url_root + '/images/admin/tab_close.png', 'class': 'close', 'alt': 'Remove part', 'title': 'Remove part'})).addClassName('tab'); |
117 | return this.element; |
118 | } |
119 | }); |
120 | |
121 | var TabControls = {}; |