##// END OF EJS Templates
Added tabindex property on wiki toolbar buttons and 'new category' link....
Jean-Philippe Lang -
r1073:d5b9dedca229
parent child
Show More
@@ -1,58 +1,58
1 1 <%= error_messages_for 'issue' %>
2 2 <div class="box">
3 3
4 4 <% if @issue.new_record? %>
5 5 <p><%= f.select :tracker_id, @project.trackers.collect {|t| [t.name, t.id]}, :required => true %></p>
6 6 <%= observe_field :issue_tracker_id, :url => { :action => :new },
7 7 :update => :content,
8 8 :with => "Form.serialize('issue-form')" %>
9 9 <% end %>
10 10
11 11 <div class="splitcontentleft">
12 12 <% if @issue.new_record? %>
13 13 <p><%= f.select :status_id, (@allowed_statuses.collect {|p| [p.name, p.id]}), :required => true %></p>
14 14 <% else %>
15 15 <p><label><%= l(:field_status) %></label> <%= @issue.status.name %></p>
16 16 <% end %>
17 17
18 18 <p><%= f.select :priority_id, (@priorities.collect {|p| [p.name, p.id]}), :required => true %></p>
19 19 <p><%= f.select :assigned_to_id, (@issue.assignable_users.collect {|m| [m.name, m.id]}), :include_blank => true %></p>
20 20 <p><%= f.select :category_id, (@project.issue_categories.collect {|c| [c.name, c.id]}), :include_blank => true %>
21 21 <%= prompt_to_remote(l(:label_issue_category_new),
22 22 l(:label_issue_category_new), 'category[name]',
23 23 {:controller => 'projects', :action => 'add_issue_category', :id => @project},
24 :class => 'small') if authorize_for('projects', 'add_issue_category') %></p>
24 :class => 'small', :tabindex => 199) if authorize_for('projects', 'add_issue_category') %></p>
25 25 </div>
26 26
27 27 <div class="splitcontentright">
28 28 <p><%= f.text_field :start_date, :size => 10 %><%= calendar_for('issue_start_date') %></p>
29 29 <p><%= f.text_field :due_date, :size => 10 %><%= calendar_for('issue_due_date') %></p>
30 30 <p><%= f.text_field :estimated_hours, :size => 3 %> <%= l(:field_hours) %></p>
31 31 <p><%= f.select :done_ratio, ((0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %></p>
32 32 </div>
33 33
34 34 <p><%= f.text_field :subject, :size => 80, :required => true %></p>
35 35 <p><%= f.text_area :description, :required => true,
36 36 :cols => 60,
37 37 :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
38 38 :accesskey => accesskey(:edit),
39 39 :class => 'wiki-edit' %></p>
40 40 <p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
41 41
42 42 <%= render :partial => 'form_custom_fields', :locals => {:values => @custom_values} %>
43 43
44 44 <% if @issue.new_record? %>
45 45 <p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
46 46 <%= image_to_function "add.png", "addFileField();return false" %></label>
47 47 <%= file_field_tag 'attachments[]', :size => 30 %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
48 48 <% end %>
49 49 </div>
50 50
51 51 <%= wikitoolbar_for 'issue_description' %>
52 52
53 53 <% content_for :header_tags do %>
54 54 <%= javascript_include_tag 'calendar/calendar' %>
55 55 <%= javascript_include_tag "calendar/lang/calendar-#{current_language}.js" %>
56 56 <%= javascript_include_tag 'calendar/calendar-setup' %>
57 57 <%= stylesheet_link_tag 'calendar' %>
58 58 <% end %>
@@ -1,525 +1,526
1 1 /* ***** BEGIN LICENSE BLOCK *****
2 2 * This file is part of DotClear.
3 3 * Copyright (c) 2005 Nicolas Martin & Olivier Meunier and contributors. All
4 4 * rights reserved.
5 5 *
6 6 * DotClear is free software; you can redistribute it and/or modify
7 7 * it under the terms of the GNU General Public License as published by
8 8 * the Free Software Foundation; either version 2 of the License, or
9 9 * (at your option) any later version.
10 10 *
11 11 * DotClear is distributed in the hope that it will be useful,
12 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 14 * GNU General Public License for more details.
15 15 *
16 16 * You should have received a copy of the GNU General Public License
17 17 * along with DotClear; if not, write to the Free Software
18 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 19 *
20 20 * ***** END LICENSE BLOCK *****
21 21 */
22 22
23 23 /* Modified by JP LANG for textile formatting */
24 24
25 25 function jsToolBar(textarea) {
26 26 if (!document.createElement) { return; }
27 27
28 28 if (!textarea) { return; }
29 29
30 30 if ((typeof(document["selection"]) == "undefined")
31 31 && (typeof(textarea["setSelectionRange"]) == "undefined")) {
32 32 return;
33 33 }
34 34
35 35 this.textarea = textarea;
36 36
37 37 this.editor = document.createElement('div');
38 38 this.editor.className = 'jstEditor';
39 39
40 40 this.textarea.parentNode.insertBefore(this.editor,this.textarea);
41 41 this.editor.appendChild(this.textarea);
42 42
43 43 this.toolbar = document.createElement("div");
44 44 this.toolbar.className = 'jstElements';
45 45 this.editor.parentNode.insertBefore(this.toolbar,this.editor);
46 46
47 47 // Dragable resizing (only for gecko)
48 48 if (this.editor.addEventListener)
49 49 {
50 50 this.handle = document.createElement('div');
51 51 this.handle.className = 'jstHandle';
52 52 var dragStart = this.resizeDragStart;
53 53 var This = this;
54 54 this.handle.addEventListener('mousedown',function(event) { dragStart.call(This,event); },false);
55 55 // fix memory leak in Firefox (bug #241518)
56 56 window.addEventListener('unload',function() {
57 57 var del = This.handle.parentNode.removeChild(This.handle);
58 58 delete(This.handle);
59 59 },false);
60 60
61 61 this.editor.parentNode.insertBefore(this.handle,this.editor.nextSibling);
62 62 }
63 63
64 64 this.context = null;
65 65 this.toolNodes = {}; // lorsque la toolbar est dessinΓ©e , cet objet est garni
66 66 // de raccourcis vers les Γ©lΓ©ments DOM correspondants aux outils.
67 67 }
68 68
69 69 function jsButton(title, fn, scope, className) {
70 70 if(typeof jsToolBar.strings == 'undefined') {
71 71 this.title = title || null;
72 72 } else {
73 73 this.title = jsToolBar.strings[title] || title || null;
74 74 }
75 75 this.fn = fn || function(){};
76 76 this.scope = scope || null;
77 77 this.className = className || null;
78 78 }
79 79 jsButton.prototype.draw = function() {
80 80 if (!this.scope) return null;
81 81
82 82 var button = document.createElement('button');
83 83 button.setAttribute('type','button');
84 button.tabIndex = 200;
84 85 if (this.className) button.className = this.className;
85 86 button.title = this.title;
86 87 var span = document.createElement('span');
87 88 span.appendChild(document.createTextNode(this.title));
88 89 button.appendChild(span);
89 90
90 91 if (this.icon != undefined) {
91 92 button.style.backgroundImage = 'url('+this.icon+')';
92 93 }
93 94 if (typeof(this.fn) == 'function') {
94 95 var This = this;
95 96 button.onclick = function() { try { This.fn.apply(This.scope, arguments) } catch (e) {} return false; };
96 97 }
97 98 return button;
98 99 }
99 100
100 101 function jsSpace(id) {
101 102 this.id = id || null;
102 103 this.width = null;
103 104 }
104 105 jsSpace.prototype.draw = function() {
105 106 var span = document.createElement('span');
106 107 if (this.id) span.id = this.id;
107 108 span.appendChild(document.createTextNode(String.fromCharCode(160)));
108 109 span.className = 'jstSpacer';
109 110 if (this.width) span.style.marginRight = this.width+'px';
110 111
111 112 return span;
112 113 }
113 114
114 115 function jsCombo(title, options, scope, fn, className) {
115 116 this.title = title || null;
116 117 this.options = options || null;
117 118 this.scope = scope || null;
118 119 this.fn = fn || function(){};
119 120 this.className = className || null;
120 121 }
121 122 jsCombo.prototype.draw = function() {
122 123 if (!this.scope || !this.options) return null;
123 124
124 125 var select = document.createElement('select');
125 126 if (this.className) select.className = className;
126 127 select.title = this.title;
127 128
128 129 for (var o in this.options) {
129 130 //var opt = this.options[o];
130 131 var option = document.createElement('option');
131 132 option.value = o;
132 133 option.appendChild(document.createTextNode(this.options[o]));
133 134 select.appendChild(option);
134 135 }
135 136
136 137 var This = this;
137 138 select.onchange = function() {
138 139 try {
139 140 This.fn.call(This.scope, this.value);
140 141 } catch (e) { alert(e); }
141 142
142 143 return false;
143 144 }
144 145
145 146 return select;
146 147 }
147 148
148 149
149 150 jsToolBar.prototype = {
150 151 base_url: '',
151 152 mode: 'wiki',
152 153 elements: {},
153 154
154 155 getMode: function() {
155 156 return this.mode;
156 157 },
157 158
158 159 setMode: function(mode) {
159 160 this.mode = mode || 'wiki';
160 161 },
161 162
162 163 switchMode: function(mode) {
163 164 mode = mode || 'wiki';
164 165 this.draw(mode);
165 166 },
166 167
167 168 button: function(toolName) {
168 169 var tool = this.elements[toolName];
169 170 if (typeof tool.fn[this.mode] != 'function') return null;
170 171 var b = new jsButton(tool.title, tool.fn[this.mode], this, 'jstb_'+toolName);
171 172 if (tool.icon != undefined) b.icon = tool.icon;
172 173 return b;
173 174 },
174 175 space: function(toolName) {
175 176 var tool = new jsSpace(toolName)
176 177 if (this.elements[toolName].width !== undefined)
177 178 tool.width = this.elements[toolName].width;
178 179 return tool;
179 180 },
180 181 combo: function(toolName) {
181 182 var tool = this.elements[toolName];
182 183 var length = tool[this.mode].list.length;
183 184
184 185 if (typeof tool[this.mode].fn != 'function' || length == 0) {
185 186 return null;
186 187 } else {
187 188 var options = {};
188 189 for (var i=0; i < length; i++) {
189 190 var opt = tool[this.mode].list[i];
190 191 options[opt] = tool.options[opt];
191 192 }
192 193 return new jsCombo(tool.title, options, this, tool[this.mode].fn);
193 194 }
194 195 },
195 196 draw: function(mode) {
196 197 this.setMode(mode);
197 198
198 199 // Empty toolbar
199 200 while (this.toolbar.hasChildNodes()) {
200 201 this.toolbar.removeChild(this.toolbar.firstChild)
201 202 }
202 203 this.toolNodes = {}; // vide les raccourcis DOM/**/
203 204
204 205 // Draw toolbar elements
205 206 var b, tool, newTool;
206 207
207 208 for (var i in this.elements) {
208 209 b = this.elements[i];
209 210
210 211 var disabled =
211 212 b.type == undefined || b.type == ''
212 213 || (b.disabled != undefined && b.disabled)
213 214 || (b.context != undefined && b.context != null && b.context != this.context);
214 215
215 216 if (!disabled && typeof this[b.type] == 'function') {
216 217 tool = this[b.type](i);
217 218 if (tool) newTool = tool.draw();
218 219 if (newTool) {
219 220 this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
220 221 this.toolbar.appendChild(newTool);
221 222 }
222 223 }
223 224 }
224 225 },
225 226
226 227 singleTag: function(stag,etag) {
227 228 stag = stag || null;
228 229 etag = etag || stag;
229 230
230 231 if (!stag || !etag) { return; }
231 232
232 233 this.encloseSelection(stag,etag);
233 234 },
234 235
235 236 encloseLineSelection: function(prefix, suffix, fn) {
236 237 this.textarea.focus();
237 238
238 239 prefix = prefix || '';
239 240 suffix = suffix || '';
240 241
241 242 var start, end, sel, scrollPos, subst, res;
242 243
243 244 if (typeof(document["selection"]) != "undefined") {
244 245 sel = document.selection.createRange().text;
245 246 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
246 247 start = this.textarea.selectionStart;
247 248 end = this.textarea.selectionEnd;
248 249 scrollPos = this.textarea.scrollTop;
249 250 // go to the start of the line
250 251 start = this.textarea.value.substring(0, start).replace(/[^\r\n]*$/g,'').length;
251 252 // go to the end of the line
252 253 end = this.textarea.value.length - this.textarea.value.substring(end, this.textarea.value.length).replace(/^[^\r\n]*/, '').length;
253 254 sel = this.textarea.value.substring(start, end);
254 255 }
255 256
256 257 if (sel.match(/ $/)) { // exclude ending space char, if any
257 258 sel = sel.substring(0, sel.length - 1);
258 259 suffix = suffix + " ";
259 260 }
260 261
261 262 if (typeof(fn) == 'function') {
262 263 res = (sel) ? fn.call(this,sel) : fn('');
263 264 } else {
264 265 res = (sel) ? sel : '';
265 266 }
266 267
267 268 subst = prefix + res + suffix;
268 269
269 270 if (typeof(document["selection"]) != "undefined") {
270 271 document.selection.createRange().text = subst;
271 272 var range = this.textarea.createTextRange();
272 273 range.collapse(false);
273 274 range.move('character', -suffix.length);
274 275 range.select();
275 276 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
276 277 this.textarea.value = this.textarea.value.substring(0, start) + subst +
277 278 this.textarea.value.substring(end);
278 279 if (sel) {
279 280 this.textarea.setSelectionRange(start + subst.length, start + subst.length);
280 281 } else {
281 282 this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
282 283 }
283 284 this.textarea.scrollTop = scrollPos;
284 285 }
285 286 },
286 287
287 288 encloseSelection: function(prefix, suffix, fn) {
288 289 this.textarea.focus();
289 290
290 291 prefix = prefix || '';
291 292 suffix = suffix || '';
292 293
293 294 var start, end, sel, scrollPos, subst, res;
294 295
295 296 if (typeof(document["selection"]) != "undefined") {
296 297 sel = document.selection.createRange().text;
297 298 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
298 299 start = this.textarea.selectionStart;
299 300 end = this.textarea.selectionEnd;
300 301 scrollPos = this.textarea.scrollTop;
301 302 sel = this.textarea.value.substring(start, end);
302 303 }
303 304
304 305 if (sel.match(/ $/)) { // exclude ending space char, if any
305 306 sel = sel.substring(0, sel.length - 1);
306 307 suffix = suffix + " ";
307 308 }
308 309
309 310 if (typeof(fn) == 'function') {
310 311 res = (sel) ? fn.call(this,sel) : fn('');
311 312 } else {
312 313 res = (sel) ? sel : '';
313 314 }
314 315
315 316 subst = prefix + res + suffix;
316 317
317 318 if (typeof(document["selection"]) != "undefined") {
318 319 document.selection.createRange().text = subst;
319 320 var range = this.textarea.createTextRange();
320 321 range.collapse(false);
321 322 range.move('character', -suffix.length);
322 323 range.select();
323 324 // this.textarea.caretPos -= suffix.length;
324 325 } else if (typeof(this.textarea["setSelectionRange"]) != "undefined") {
325 326 this.textarea.value = this.textarea.value.substring(0, start) + subst +
326 327 this.textarea.value.substring(end);
327 328 if (sel) {
328 329 this.textarea.setSelectionRange(start + subst.length, start + subst.length);
329 330 } else {
330 331 this.textarea.setSelectionRange(start + prefix.length, start + prefix.length);
331 332 }
332 333 this.textarea.scrollTop = scrollPos;
333 334 }
334 335 },
335 336
336 337 stripBaseURL: function(url) {
337 338 if (this.base_url != '') {
338 339 var pos = url.indexOf(this.base_url);
339 340 if (pos == 0) {
340 341 url = url.substr(this.base_url.length);
341 342 }
342 343 }
343 344
344 345 return url;
345 346 }
346 347 };
347 348
348 349 /** Resizer
349 350 -------------------------------------------------------- */
350 351 jsToolBar.prototype.resizeSetStartH = function() {
351 352 this.dragStartH = this.textarea.offsetHeight + 0;
352 353 };
353 354 jsToolBar.prototype.resizeDragStart = function(event) {
354 355 var This = this;
355 356 this.dragStartY = event.clientY;
356 357 this.resizeSetStartH();
357 358 document.addEventListener('mousemove', this.dragMoveHdlr=function(event){This.resizeDragMove(event);}, false);
358 359 document.addEventListener('mouseup', this.dragStopHdlr=function(event){This.resizeDragStop(event);}, false);
359 360 };
360 361
361 362 jsToolBar.prototype.resizeDragMove = function(event) {
362 363 this.textarea.style.height = (this.dragStartH+event.clientY-this.dragStartY)+'px';
363 364 };
364 365
365 366 jsToolBar.prototype.resizeDragStop = function(event) {
366 367 document.removeEventListener('mousemove', this.dragMoveHdlr, false);
367 368 document.removeEventListener('mouseup', this.dragStopHdlr, false);
368 369 };
369 370
370 371 // Elements definition ------------------------------------
371 372
372 373 // strong
373 374 jsToolBar.prototype.elements.strong = {
374 375 type: 'button',
375 376 title: 'Strong',
376 377 fn: {
377 378 wiki: function() { this.singleTag('*') }
378 379 }
379 380 }
380 381
381 382 // em
382 383 jsToolBar.prototype.elements.em = {
383 384 type: 'button',
384 385 title: 'Italic',
385 386 fn: {
386 387 wiki: function() { this.singleTag("_") }
387 388 }
388 389 }
389 390
390 391 // ins
391 392 jsToolBar.prototype.elements.ins = {
392 393 type: 'button',
393 394 title: 'Underline',
394 395 fn: {
395 396 wiki: function() { this.singleTag('+') }
396 397 }
397 398 }
398 399
399 400 // del
400 401 jsToolBar.prototype.elements.del = {
401 402 type: 'button',
402 403 title: 'Deleted',
403 404 fn: {
404 405 wiki: function() { this.singleTag('-') }
405 406 }
406 407 }
407 408
408 409 // quote
409 410 jsToolBar.prototype.elements.quote = {
410 411 type: 'button',
411 412 title: 'Inline quote',
412 413 fn: {
413 414 wiki: function() { this.singleTag('??') }
414 415 }
415 416 }
416 417
417 418 // code
418 419 jsToolBar.prototype.elements.code = {
419 420 type: 'button',
420 421 title: 'Code',
421 422 fn: {
422 423 wiki: function() { this.singleTag('@') }
423 424 }
424 425 }
425 426
426 427 // spacer
427 428 jsToolBar.prototype.elements.space1 = {type: 'space'}
428 429
429 430 // headings
430 431 jsToolBar.prototype.elements.h1 = {
431 432 type: 'button',
432 433 title: 'Heading 1',
433 434 fn: {
434 435 wiki: function() {
435 436 this.encloseLineSelection('h1. ', '',function(str) {
436 437 str = str.replace(/^h\d+\.\s+/, '')
437 438 return str;
438 439 });
439 440 }
440 441 }
441 442 }
442 443 jsToolBar.prototype.elements.h2 = {
443 444 type: 'button',
444 445 title: 'Heading 2',
445 446 fn: {
446 447 wiki: function() {
447 448 this.encloseLineSelection('h2. ', '',function(str) {
448 449 str = str.replace(/^h\d+\.\s+/, '')
449 450 return str;
450 451 });
451 452 }
452 453 }
453 454 }
454 455 jsToolBar.prototype.elements.h3 = {
455 456 type: 'button',
456 457 title: 'Heading 3',
457 458 fn: {
458 459 wiki: function() {
459 460 this.encloseLineSelection('h3. ', '',function(str) {
460 461 str = str.replace(/^h\d+\.\s+/, '')
461 462 return str;
462 463 });
463 464 }
464 465 }
465 466 }
466 467
467 468 // spacer
468 469 jsToolBar.prototype.elements.space2 = {type: 'space'}
469 470
470 471 // ul
471 472 jsToolBar.prototype.elements.ul = {
472 473 type: 'button',
473 474 title: 'Unordered list',
474 475 fn: {
475 476 wiki: function() {
476 477 this.encloseLineSelection('','',function(str) {
477 478 str = str.replace(/\r/g,'');
478 479 return str.replace(/(\n|^)[#-]?\s*/g,"$1* ");
479 480 });
480 481 }
481 482 }
482 483 }
483 484
484 485 // ol
485 486 jsToolBar.prototype.elements.ol = {
486 487 type: 'button',
487 488 title: 'Ordered list',
488 489 fn: {
489 490 wiki: function() {
490 491 this.encloseLineSelection('','',function(str) {
491 492 str = str.replace(/\r/g,'');
492 493 return str.replace(/(\n|^)[*-]?\s*/g,"$1# ");
493 494 });
494 495 }
495 496 }
496 497 }
497 498
498 499 // pre
499 500 jsToolBar.prototype.elements.pre = {
500 501 type: 'button',
501 502 title: 'Preformatted text',
502 503 fn: {
503 504 wiki: function() { this.encloseLineSelection('<pre>\n', '\n</pre>') }
504 505 }
505 506 }
506 507
507 508 // spacer
508 509 jsToolBar.prototype.elements.space3 = {type: 'space'}
509 510
510 511 // wiki page
511 512 jsToolBar.prototype.elements.link = {
512 513 type: 'button',
513 514 title: 'Wiki link',
514 515 fn: {
515 516 wiki: function() { this.encloseSelection("[[", "]]") }
516 517 }
517 518 }
518 519 // image
519 520 jsToolBar.prototype.elements.img = {
520 521 type: 'button',
521 522 title: 'Image',
522 523 fn: {
523 524 wiki: function() { this.encloseSelection("!", "!") }
524 525 }
525 526 }
General Comments 0
You need to be logged in to leave comments. Login now