| | | | |
| | |
| PHP Code Flüsterer Registriert seit: 21.08.2005 Beiträge: 4682 PHP-Kenntnisse: Fortgeschritten | |
| | |
| Supermoderator HD Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Habe ich auch gemerkt. Ist aber nur eine Frage der Referenz durch getElementByid(), da der Editor im Bearbeitungsmodus eine andere ID hat. Durch ein binäres OR dürfte das gemacht sein.
__________________ Refining Linux Advent Calendar series “24 Outstanding ZSH Gems” |
| | |
| | |
| Supermoderator HD Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Du könntest einen weiteren Event-Handler für den Button erstellen.
__________________ Refining Linux Advent Calendar series “24 Outstanding ZSH Gems” |
| | |
| | |
| Supermoderator HD Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Grummel vBulletin mal wieder… Sie besitzen aber alle eine name-Attribut, dass den Text vB::QuickEdit::<postid> enthält. Mit indexOf() oder substr() könnte man in Verbindung mit getAttribute('name') was anstellen. Ich glaube, ich kümmere mich gleich mal darum. Muss eh noch die Moderatorenphrasen in den Editor einfügen.
__________________ Refining Linux Advent Calendar series “24 Outstanding ZSH Gems” |
| | |
| | |
| Supermoderator HD Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | So, puh… Bah, ich hasse vBulletin-Scripting! Die beiden Editoren sind zwar total ähnlich vom Aussehen, aber total unterschiedlich vom Aufbau. Ich poste hier einfach mal den Code, wie er jetzt bei mir ist mitsamt allen Buttons: Code: // @name vBulletin-Editor-Hack
// @namespace vbulletin
// @description Erweitert den vBulletin-Standardeditor um einige nützliche Funktionen
// @include http://www.php.de/
// ==/UserScript==
// This Script is not crossbrowser compatible, only
// designed for Firefox with Greasemonkey!
// first: change small bottom editor
if (document.getElementById('vB_Editor_QR')) {
VB_changeEditor(
document.getElementById('vB_Editor_QR'),
document.getElementById('vB_Editor_QR').getElementsByTagName('textarea')[0]
);
}
// dynamic displayed post edit editor
// each edit editor has another ID so VB_editCount will count the edits
var VB_editCount = 0;
// attach event listeners to edit buttons
var VB_editButtons = document.getElementsByTagName('a');
for (var VB_e in VB_editButtons) {
if (VB_editButtons[VB_e].getAttribute('name') &&
VB_editButtons[VB_e].getAttribute('name').indexOf('vB::QuickEdit::') == 0) {
VB_editButtons[VB_e].addEventListener('mouseup', function()
{
// set a timeout because the editor is loaded by AJAX
setTimeout(function()
{
VB_editCount++;
var eEl = document.getElementById('vB_Editor_QE_' + VB_editCount + '_controls');
var tEl = eEl.parentNode.getElementsByTagName('textarea')[0];
VB_changeEditor(eEl, tEl);
}, 1000);
}, false);
}
}
// set buttons to display in the editor
// to do this pass an array to the __init() method. Each array element contains
// a literal object:
// 0 : {
// title : text for title attribute (optional),
// action : callback or anonymous function for action performed on click,
// icon : {
// src : path to the icon file,
// alt : alternate text for the icon (optional)
// },
// text : instead of specifying an icon you can also pass a text
// }
function VB_changeEditor(editorElement, textareaElement)
{
var VB_obj = new VB_CEditorExtension(editorElement, textareaElement);
VB_obj.__init({
0 : {
title : 'Code einfügen [code]',
action : function()
{
VB_obj.insertText('[code]', '[/code]');
},
icon : {
src : 'http://www.php.de/images/editor/code.gif',
alt : '[code]'
}
},
1 : {
title : 'PHP-Code einfügen [php]',
action : function()
{
VB_obj.insertText('[php]', '[/php]');
},
icon : {
src : 'http://www.php.de/images/editor/php.gif',
alt : '[php]'
}
},
2 : {
title : '[wiki]-Code einfügen',
action : function()
{
VB_obj.insertText('[wiki]', '[/wiki]');
},
icon : {
src : 'http://www.php.de/images/buttons/wiki.gif',
alt : '[wiki]'
}
},
3 : {
title : '[man]-Code einfügen',
action : function()
{
VB_obj.insertText('[man]', '[/man]');
},
icon : {
src : 'http://www.php.de/images/buttons/man.gif',
alt : '[man]'
}
},
4 : null,
5 : {
title : 'Beitrag editiert',
action : function()
{
VB_obj.insertText('[b][color="DarkRed"]Beitrag editiert:[/color][/b]\n[i][…] ', '[/i]');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture15-post-edited.png',
alt : 'Beitrag editiert'
}
},
6 : {
title : 'Thread bitte als [Erledigt] markieren',
action : function()
{
VB_obj.insertText('Dann den Thread bitte noch als [Erledigt] markieren. Danke!', '');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture16-done.png',
alt : 'Thread bitte als [Erledigt] markieren'
}
},
7 : {
title : 'Bitte [php]-Tags statt [man]-Tags verwenden',
action : function()
{
VB_obj.insertText('Für das Highlighting von PHP-Code sind die [php]-Tags und nicht die [man]-Tags zuständig. Bitte ändere das noch.', '');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture17-no-man-use-php.png',
alt : 'Bitte [php]-Tags statt [man]-Tags verwenden'
}
},
8 : null,
9 : {
title : 'Mod: Thema verschoben',
action : function()
{
VB_obj.insertText('[b][color="DarkRed"]Themenmoderation:[/color][/b]\n[i][→] Verschoben von ', '[/i]');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture23-mod-thread-moved.png',
alt : 'Mod: Thema verschoben'
}
},
10 : {
title : 'Mod: Thema geschlossen',
action : function()
{
VB_obj.insertText('[b][color="DarkRed"]Themenmoderation:[/color][/b]\n[i][Ω] Thema geschlossen[/i]', '');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture22-mod-thread-closed.png',
alt : 'Mod: Thema geschlossen'
}
},
11 : {
title : 'Mod: Beitrag editiert',
action : function()
{
VB_obj.insertText('[b][color="DarkRed"]Beitragsmoderation (Manko10):[/color][/b]\n[i][‼] ', '[/i]');
},
icon : {
src : 'http://www.php.de/members/manko10-albums-editor-icons-picture21-mod-post-edited.png',
alt : 'Mod: Beitrag editiert'
}
}
});
}
// pseudo class for changing the editor
function VB_CEditorExtension(editorElement, textareaElement)
{
this.editorElement = editorElement;
this.textareaElement = textareaElement;
// initialize editor change
this.__init = function(buttons)
{
var newRow = this.addNewRow();
this.processButtons(newRow, buttons);
}
// adds a new row to the editor buttons table
this.addNewRow = function()
{
if (!this.editorElement) {
return;
}
var table = this.editorElement.getElementsByTagName('tbody')[0];
var tr = document.createElement('tr');
return table.appendChild(tr);
}
// inserts the buttons
this.processButtons = function(row, buttons)
{
if (!this.editorElement) {
return;
}
var td = document.createElement('td');
for (var b in buttons) {
// if separator
if (!buttons[b]) {
var sep = document.createElement('img');
sep.setAttribute('src', 'http://www.php.de/images/editor/separator.gif');
sep.setAttribute('alt', 'Separator');
td.appendChild(sep);
continue;
}
var span = document.createElement('span');
// icon
if (buttons[b].icon && buttons[b].icon.src) {
var img = document.createElement('img');
img.setAttribute('src', buttons[b].icon.src);
if (buttons[b].icon.alt) {
img.setAttribute('alt', buttons[b].icon.alt);
} else {
img.setAttribute('alt', '');
}
span.appendChild(img);
} else if (buttons[b].text) {
// no icon? then use text
span.appendChild(document.createTextNode(buttons[b].text));
} else {
// no text? nothing to do!
continue;
}
// title tooltip
if (buttons[b].title) {
span.setAttribute('title', buttons[b].title);
}
// action
if (buttons[b].action) {
span.addEventListener('click', buttons[b].action, false);
}
span.setAttribute('class', 'imagebutton');
span.setAttribute('style', 'cursor: default; border: medium none; padding: 1px; background: rgb(225, 225, 226) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: rgb(0, 0, 0);');
// generate vBulletin hover style
span.addEventListener('mouseover', function(ev)
{
ev.target.setAttribute('style', 'cursor: default; border: 1px solid rgb(49, 106, 197); padding: 0px; background: rgb(193, 210, 238) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: rgb(0, 0, 0);');
ev.stopPropagation();
}, false);
span.addEventListener('mouseout', function(ev)
{
ev.target.setAttribute('style', 'cursor: default; border: medium none; padding: 1px; background: rgb(225, 225, 226) none repeat scroll 0% 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: rgb(0, 0, 0);');
ev.stopPropagation();
}, false);
td.appendChild(span);
}
row.appendChild(td);
td.setAttribute('colspan', '15');
}
// this method is not used by the class itself but you can use this on click
// events to insert some text into the editor
this.insertText = function(startTag, endTag)
{
if (!this.editorElement || !this.textareaElement) {
return;
}
this.textareaElement.focus();
// save current scrolling position
var scrollTop = this.textareaElement.scrollTop;
var scrollLeft = this.textareaElement.scrollLeft;
var start = this.textareaElement.selectionStart;
var end = this.textareaElement.selectionEnd;
var insText = this.textareaElement.value.substring(start, end);
this.textareaElement.value = this.textareaElement.value.substr(0, start) + startTag + insText + endTag + this.textareaElement.value.substr(end);
var pos;
if (insText.length == 0) {
pos = start + startTag.length;
} else {
pos = start + startTag.length + insText.length + endTag.length;
}
this.textareaElement.selectionStart = pos;
this.textareaElement.selectionEnd = pos;
// reset scrolling
this.textareaElement.scrollTop = scrollTop;
this.textareaElement.scrollLeft = scrollLeft;
}
}
[…] Vertauschung korrigiert Beitrag editiert #2: […] Beachtung der Scrollposition hinzugefügt Beitrag editiert #3: […] Tooltip korrigiert
__________________ Refining Linux Advent Calendar series “24 Outstanding ZSH Gems” Geändert von Manko10 (22.10.2008 um 16:43 Uhr). |
| | |
| | |
| Erfahrener Benutzer Registriert seit: 01.12.2003
Beiträge: 2.555
PHP-Kenntnisse: Anfänger ![]() | gehört zwar nicht wirklich hier her, aber was haltet Ihr davon, bei den ganzen js und css Beiträgen im Wiki jeweils auch ein Beispiel anzeigen zu lassen. Siehe SELFHTML 8.1.2 (HTML-Dateien selbst erstellen) die ja immer einen Beispiel Link haben Siehe Anzeigebeispiel: So sieht's aus
__________________ Gruß JEGO Ein PHP Script tut, was Du schreibst, nicht was Du willst. |
| | |
| | |
| Supermoderator HD Registriert seit: 16.03.2008
Beiträge: 8.425
PHP-Kenntnisse: Fortgeschritten ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | @cycap: lade dir die Firefox-Erweiterung Greasemonkey herunter und erstelle ein neues Benutzerskript für php.de mit dem Skript von mir als Inhalt. @JEGO: Okay, so sieht es aus:
__________________ Refining Linux Advent Calendar series “24 Outstanding ZSH Gems” |
| | |
|
| Themen-Optionen | |
| Thema bewerten | |
|
|
Ähnliche Themen | ||||
| Thema | Autor | Forum | Antworten | Letzter Beitrag |
| [Erledigt] Phrase: "Das PHP.de Wiki für registrierte Mitglieder" | Manko10 | Wiki Diskussionsforum | 5 | 26.08.2008 22:14 |
| Bug in der Wiki? | Freeaak | Board-Support | 14 | 26.08.2008 22:09 |
| PHP.de Wiki Mitmachen und Entwickeln | hoefti | Wiki Diskussionsforum | 0 | 24.08.2008 14:02 |
| suche ein Wiki | Crypi | Off-Topic Diskussionen | 5 | 07.06.2007 12:05 |
| Wiki von Mediawiki runterladen | FBI | Off-Topic Diskussionen | 5 | 03.02.2006 15:23 |
| Wiki spielt mir einen Streich bei Funpic | PHP Tipps 2005-2 | 5 | 08.06.2005 13:30 | |
| php wiki mit ssl | PHP Tipps 2005 | 1 | 20.05.2005 23:06 | |
| Wiki Parser Klassen, etc. gesucht. | PHP Tipps 2005 | 6 | 05.05.2005 15:54 | |
| Besucher kamen über folgende Suchanfragen bei Google auf diese Seite |
| darkred firefox icon, close.png red firefox, css title attribute timeout, selfhtml tbody \-moz\, greasemonkey dynamische id getelementbyid, ev.stoppropagation |