1 /* Dynamic images, change class */
7 .addEvent('domready', function()
13 $$('*.dynamic_img').addEvents(
17 'mouseenter': function()
21 this.addClass('over');
25 'mouseleave': function()
29 this.removeClass('over');
31 this.removeClass('clicked');
35 'mousedown': function()
39 this.removeClass('over');
41 this.addClass('clicked');
55 'mousedown': function()
59 var tbody
= this.getParent('thead').getNext('tbody');
61 tbody
.toggleClass('hide');
63 if (tbody
.hasClass('hide'))
67 document
.cookie
= 't3' + this.getParent('table')
69 .getProperty('id') + '=1; expires=Wed, 1 Jan 2020 00:00:00 GMT';
71 this.removeClass('opened');
73 this.addClass('closed');
81 document
.cookie
= 't3' + this.getParent('table')
83 .getProperty('id') + '=1; expires=Thu, 01-Jan-1970 00:00:01 GMT';
85 this.removeClass('closed');
87 this.addClass('opened');
97 $$('table.row_table_data tbody tr').addEvents(
101 'mouseenter': function()
105 this.addClass('hlight');
109 'mouseleave': function()
113 this.removeClass('hlight');
117 'mousedown': function()
121 this.toggleClass('marked');
135 if (Browser
.Engine
.trident
) // für IE
141 * Element Erweiterungen
151 insertAtCursor: function(value
, select
)
155 var pos
= this.getSelectedRange();
161 if (pos
.start
== 0 && pos
.end
== 0)
167 sel
= document
.selection
.createRange();
181 var text
= this.get('value');
183 this.set('value', text
.substring(0, pos
.start
) + value
+ text
.substring(pos
.end
, text
.length
));
185 if ($pick(select
, true))
189 this.selectRange(pos
.start
, pos
.start
+ value
.length
);
197 this.setCaretPosition(pos
.start
+ value
.length
);
209 insertAroundCursor: function(options
, select
)
227 var value
= this.getSelectedText() || options
.defaultMiddle
;
229 var pos
= this.getSelectedRange();
235 if (pos
.start
== 0 && pos
.end
== 0)
241 sel
= document
.selection
.createRange();
243 sel
.text
= options
.before
+ options
.after
;
255 var text
= this.get('value');
257 if (pos
.start
== pos
.end
)
261 this.set('value', text
.substring(0, pos
.start
) + options
.before
+ value
+ options
.after
+ text
.substring(pos
.end
, text
.length
));
263 this.selectRange(pos
.start
+ options
.before
.length
, pos
.end
+ options
.before
.length
+ value
.length
);
271 var current
= text
.substring(pos
.start
, pos
.end
);
273 this.set('value', text
.substring(0, pos
.start
) + options
.before
+ current
+ options
.after
+ text
.substring(pos
.end
, text
.length
));
275 var selStart
= pos
.start
+ options
.before
.length
;
279 if ($pick(select
, true))
283 this.selectRange(selStart
, selStart
+ current
.length
);
291 this.setCaretPosition(selStart
+ text
.length
);
307 var BBEditor
= new Class ({
317 Binds
: ['fetchPreview', 'showToolbarWindow', 'insertTag', 'insertSingleTag', 'insertSmilieTag', 'hideToolbarWindow', 'showPreview', 'hidePreview'],
323 * Initialisiert den Editor
327 initialize: function(textAreaId
) {
333 this.id
= textAreaId
;
335 this.textArea
= $(textAreaId
);
337 this.toolbar
= $(textAreaId
+ '_toolbar');
339 this.preview
= $(textAreaId
+ '_preview');
345 this.preview
.setStyle('display', 'none');
351 $(textAreaId
+ '_previewButton').addEvent('click', this.fetchPreview
);
353 $(textAreaId
+ '_resourceButton').addEvent('click', this.showToolbarWindow
);
355 $(textAreaId
+ '_smilieButton').addEvent('click', this.showToolbarWindow
);
357 $(textAreaId
+ '_troopButton').addEvent('click', this.showToolbarWindow
);
359 $(textAreaId
).addEvent('click', this.hideToolbarWindow
);
361 this.addEvent($(textAreaId
+ '_toolbar'), this.insertTag
);
363 this.addEvent($(textAreaId
+ '_resources'), this.insertTag
);
365 this.addEvent($(textAreaId
+ '_smilies'), this.insertTag
);
367 this.addEvent($(textAreaId
+ '_troops'), this.insertTag
);
375 * Fügt den klickbaren Objekten die Events hinzu
379 * @param object containerObjekt
381 * @param string callback
385 addEvent: function(div
, call
) {
387 var childen
= div
.getChildren();
389 for (i
= 0; i
< childen
.length
; i
++) {
391 if ($(childen
[i
]).get('bbTag')) {
393 $(childen
[i
]).addEvent('click', call
);
405 * Fügt einen ausgewählten Tag in die
415 insertTag: function(Event
) {
419 var link
= $(Event
.target
.parentNode
);
421 var tag
= link
.get('bbTag');
425 switch (link
.get('bbType')) {
431 this.textArea
.insertAroundCursor({before
: '[' + tag
+ ']', after
: '[/' + tag
+ ']'});
439 this.textArea
.insertAtCursor(tag
, false);
447 this.textArea
.insertAtCursor('[' + link
.get('bbTag') + ']', false);
459 * Zeigt ein Unterfenster der Toolbar
469 showToolbarWindow: function(Event
) {
471 var targetDiv
= Event
.target
.parentNode
;
473 var window
= $(this.id
+ '_' + targetDiv
.get('bbWin'));
479 if (window
.getStyle('display') == 'block') {
487 this.hideToolbarWindow();
493 window
.fade('hide').fade('in');
495 window
.setStyle('display', 'block');
505 * Versteckt die Fenster der Toolbar
513 hideToolbarWindow: function() {
515 var childen
= $(this.id
+ '_toolbarWindows').getChildren();
517 for (i
= 0; i
< childen
.length
; i
++) {
519 $(childen
[i
]).setStyle('display', 'none');
529 * Holt die Vorschau vom Server
537 fetchPreview: function(Event
) {
539 if (this.textArea
.getStyle('display') == 'none' || this.textArea
.value
.length
< 1) {
549 var jsonRequest
= new Request
.JSON({
553 url
: 'ajax.php?f=bb',
563 text
: this.textArea
.value
567 onSuccess
: this.showPreview
583 * @param string textAreaId
587 showPreview: function(data
) {
589 if (data
.error
== true) {
591 alert(data
.errorMsg
);
597 this.preview
.innerHTML
= data
.text
;
599 this.preview
.setStyle('display','block');
601 this.textArea
.setStyle('display','none');
611 * Versteckt die Vorschau
615 * @param string textAreaId
619 hidePreview: function() {
621 this.preview
.setStyle('display','none');
623 this.textArea
.setStyle('display','inline');
635 var attackSysbolState
= new Array();
639 function getAttackSymbolState(id
)
643 var state
= attackSysbolState
[id
];
651 state
= new Object();
659 var imgClass
= $('markSybol_'+id
).get('class');
663 var color
= imgClass
.substr(imgClass
.lastIndexOf('_')+1, 11);
699 state
.oldType
= type
;
705 attackSysbolState
[id
] = state
;
717 function drawAttackSymbol(id
)
721 var state
= getAttackSymbolState(id
);
741 img
= 'img/green.gif';
749 img
= 'img/yellow.gif';
765 img
= 'img/grey.gif';
773 $('markSybol_'+id
).set('class', 'attack_symbol_'+color
);
779 function markAttackSymbol(id
)
785 var state
= getAttackSymbolState(id
);
791 drawAttackSymbol(id
);
795 if (state
.isSaving
!= true)
799 state
.isSaving
= true;
807 if (state
.type
!= state
.oldType
)
811 var jsonRequest
= new Request
.JSON(
817 url
: 'ajax.php?f=vp&id='+id
+'&state='+state
.type
,
819 onSuccess: function(data
)
823 var state
= getAttackSymbolState(data
.id
);
827 state
.isSaving
= false;
831 state
.type
= data
.type
;
833 state
.oldType
= data
.type
;
837 drawAttackSymbol(data
.id
);
851 state
.isSaving
= false;