/[drupal]/contributions/modules/ubrowser/ubrowser.js
ViewVC logotype

Contents of /contributions/modules/ubrowser/ubrowser.js

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Mon Feb 11 18:26:51 2008 UTC (21 months, 2 weeks ago) by rszrama
Branch: MAIN
CVS Tags: DRUPAL-5--1-4, DRUPAL-5--1-3, HEAD
Branch point for: DRUPAL-5
Changes since 1.4: +0 -0 lines
File MIME type: text/javascript
Updates to translation strings.
1 // $Id$
2
3 // Used to return the uBrowser div to normal if it's closed.
4 var oldcontents = null;
5
6 // Used to keep from performing the same search twice in a row.
7 var lastsearch = '';
8
9 /**
10 * Load uBrowser into the div specified by selector..
11 */
12 function display_ubrowser(basepath, settings) {
13 if (oldcontents == null) {
14 oldcontents = $(settings['div']).html();
15 }
16
17 $.post(basepath + '?q=ubrowser/main', settings,
18 function(contents) {
19 $(settings['div']).empty().addClass(settings['class']).append(contents);
20 }
21 );
22
23 return false;
24 }
25
26 /**
27 * Load the uBrowser based on the builder.
28 */
29 function build_ubrowser(basepath, code_id) {
30 var filter = '';
31 $('#filter-checkboxes .form-checkbox').each(
32 function() {
33 if (this.checked) {
34 if (filter == '') {
35 filter = this.id.substring(16);
36 }
37 else {
38 filter += ',' + this.id.substring(16);
39 }
40 }
41 }
42 );
43
44 var settings = {
45 'div' : $('#edit-ubb-div').val(),
46 'class' : $('#edit-ubb-class').val(),
47 'vid' : $('#edit-ubb-vid').val(),
48 'nids' : ($('#edit-ubb-nids:checked').val() !== null) ? 'true' : 'false',
49 'search' : ($('#edit-ubb-search:checked').val() !== null) ? 'true' : 'false',
50 'view' : ($('#edit-ubb-view:checked').val() !== null) ? 'true' : 'false',
51 'window' : ($('#edit-ubb-window:checked').val() !== null) ? 'new' : 'current',
52 'close' : ($('#edit-ubb-close:checked').val() !== null) ? 'true' : 'false',
53 'multi' : ($('#edit-ubb-multi:checked').val() !== null) ? 'true' : 'false',
54 'categ' : $('#edit-ubb-categ').val(),
55 'nodesg' : $('#edit-ubb-nodesg').val(),
56 'nodepl' : $('#edit-ubb-nodepl').val(),
57 'filter' : filter,
58 'select' : $('#edit-ubb-select').val()
59 }
60
61 display_ubrowser(basepath, settings);
62
63 // Create the code output for admin/content/browse.
64 if (code_id != null) {
65 var output = "<?php\n\n$settings = array(\n";
66 output += " 'div' => '" + settings['div'] + "',\n";
67 output += " 'class' => '" + settings['class'] + "',\n";
68 output += " 'vid' => " + settings['vid'] + ",\n";
69 output += " 'nids' => '" + settings['nids'] + "',\n";
70 output += " 'search' => '" + settings['search'] + "',\n";
71 output += " 'view' => '" + settings['view'] + "',\n";
72 output += " 'window' => '" + settings['window'] + "',\n";
73 output += " 'close' => '" + settings['close'] + "',\n";
74 output += " 'multi' => '" + settings['multi'] + "',\n";
75 output += " 'categ' => '" + settings['categ'] + "',\n";
76 output += " 'nodesg' => '" + settings['nodesg'] + "',\n";
77 output += " 'nodepl' => '" + settings['nodepl'] + "',\n";
78 output += " 'filter' => '" + settings['filter'] + "',\n";
79 output += " 'select' => \"" + settings['select'] + "\",\n";
80 output += ");\n\nprint ubrowser($settings, '" + settings['div'].replace(/#/, '') + "');\n\n?>"
81
82 $(code_id).html(output);
83 }
84
85 return false;
86 }
87
88 /**
89 * Load the node select box when you click on a category term.
90 */
91 function load_node_select(tid, basepath) {
92 if (parseInt(tid) < 0) {
93 return false;
94 }
95
96 lastsearch = '';
97 var settings = {
98 'multi' : $('#edit-ub-multi').val(),
99 'filter' : $('#edit-ub-filter').val(),
100 'categ' : $('#edit-ub-categ').val(),
101 'nodesg' : $('#edit-ub-nodesg').val(),
102 'nodepl' : $('#edit-ub-nodepl').val()
103 };
104
105 $.post(basepath + '?q=ubrowser/nodes/' + tid + $('#edit-ub-nids').val(), settings,
106 function(contents) {
107 $('#ubrowser-nodes').empty().append(contents);
108 $('#edit-unid').dblclick( function () { ubrowser_action_select(); } );
109 }
110 );
111 }
112
113 /**
114 * Execute the search without browsing away on accident.
115 */
116 function ubrowser_search_submit() {
117 $('#usearch_submit').click();
118
119 return false;
120 }
121
122 /**
123 * Load the node select box with the search results when you click Search.
124 */
125 function load_node_search(basepath) {
126 var settings = {
127 'keys' : $('#edit-usearch-keys').val(),
128 'nids' : $('#edit-ub-nids').val(),
129 'filter' : $('#edit-ub-filter').val(),
130 'categ' : $('#edit-ub-categ').val(),
131 'nodesg' : $('#edit-ub-nodesg').val(),
132 'nodepl' : $('#edit-ub-nodepl').val()
133 };
134
135 // Don't update the search if the search keys haven't changed since last time.
136 if (settings['keys'] == lastsearch) {
137 return false;
138 }
139 lastsearch = settings['keys'];
140
141 $.post(basepath + '?q=ubrowser/nodesearch', settings,
142 function(contents) {
143 if (contents != '') {
144 $('#ubrowser-nodes').empty().append(contents);
145 $('#edit-unid').dblclick( function () { ubrowser_action_select(); } );
146 }
147 }
148 );
149
150 return false;
151 }
152
153 /**
154 * Browse to the selected node when the view button is clicked.
155 */
156 function ubrowser_action_view(basepath) {
157 // Don't go if they haven't selected an actual node yet.
158 var nid = $('#edit-unid').val();
159 if (parseInt(nid) > 0) {
160 var url = basepath + '?q=' + $('#edit-unid-path-' + nid).val();
161 if ($('#edit-ub-window').val() == 'new') {
162 window.open(url);
163 }
164 else {
165 window.location = url;
166 }
167 }
168
169 return false;
170 }
171
172 /**
173 * Execute the Javascript defined for the select button.
174 */
175 function ubrowser_action_select() {
176 eval($('#edit-ub-select').val());
177
178 return false;
179 }
180
181 /**
182 * Close the uBrowser, emptying it and removing its class.
183 */
184 function ubrowser_action_close() {
185 var ub_div = $('#edit-ub-div').val();
186 var ub_class = $('#edit-ub-class').val();
187
188 $(ub_div).empty().html(oldcontents);
189
190 if (ub_class !== '') {
191 $(ub_div).removeClass(ub_class);
192 }
193
194 return false;
195 }

  ViewVC Help
Powered by ViewVC 1.1.2