User:BZPN/PNHelper.js: Difference between revisions
From Test Wiki
Content deleted Content added
No edit summary Tag: Reverted |
No edit summary Tag: Reverted |
||
| Line 11: | Line 11: | ||
// Funkcja tworząca okno dialogowe |
// Funkcja tworząca okno dialogowe |
||
function createDialog() { |
function createDialog() { |
||
var dialog = new OO.ui. |
var dialog = new OO.ui.ProcessDialog({ |
||
size: 'large' |
size: 'large', |
||
| ⚫ | |||
}); |
}); |
||
| Line 39: | Line 40: | ||
title: 'Podkreślenie' |
title: 'Podkreślenie' |
||
}); |
}); |
||
| ⚫ | |||
icon: 'strikethrough', |
|||
title: 'Przekreślenie' |
|||
| ⚫ | |||
var subscriptButton = new OO.ui.ButtonWidget({ |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
var superscriptButton = new OO.ui.ButtonWidget({ |
|||
| ⚫ | |||
| ⚫ | |||
}); |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
}); |
}); |
||
var editButtons = new OO.ui.ButtonGroupWidget({ |
|||
items: [boldButton, italicButton, underlineButton, strikethroughButton, subscriptButton, superscriptButton, linkButton] |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
}); |
}); |
||
| Line 64: | Line 75: | ||
italicButton.on('click', function() { wrapSelection("''", "''"); }); |
italicButton.on('click', function() { wrapSelection("''", "''"); }); |
||
underlineButton.on('click', function() { wrapSelection("<u>", "</u>"); }); |
underlineButton.on('click', function() { wrapSelection("<u>", "</u>"); }); |
||
strikethroughButton.on('click', function() { wrapSelection("<s>", "</s>"); }); |
|||
subscriptButton.on('click', function() { wrapSelection("<sub>", "</sub>"); }); |
|||
// Funkcja dodawania linków |
|||
superscriptButton.on('click', function() { wrapSelection("<sup>", "</sup>"); }); |
|||
| ⚫ | |||
var selectedText = descriptionInput.$input[0].value.substring( |
var selectedText = descriptionInput.$input[0].value.substring( |
||
descriptionInput.$input[0].selectionStart, |
descriptionInput.$input[0].selectionStart, |
||
| Line 72: | Line 84: | ||
); |
); |
||
if (selectedText) { |
if (selectedText) { |
||
| ⚫ | |||
// Proste automatyczne wyszukiwanie - używamy zaznaczonego tekstu jako tytułu strony |
|||
| ⚫ | |||
| ⚫ | |||
} else { |
} else { |
||
alert('Zaznacz tekst, aby dodać link.'); |
alert('Zaznacz tekst, aby dodać link.'); |
||
| Line 81: | Line 91: | ||
// Konfiguracja okna dialogowego |
// Konfiguracja okna dialogowego |
||
dialog.$body.append( |
|||
new OO.ui.FieldsetLayout({ |
|||
| ⚫ | |||
items: [ |
items: [ |
||
new OO.ui.FieldLayout(titleInput, { |
new OO.ui.FieldLayout(titleInput, { |
||
label: 'Tytuł', |
label: 'Tytuł zadania', |
||
align: 'top' |
align: 'top' |
||
}), |
}), |
||
new OO.ui.FieldLayout(editButtons, { |
new OO.ui.FieldLayout(editButtons, { |
||
label: 'Edycja tekstu', |
label: 'Edycja tekstu', |
||
| ⚫ | |||
| ⚫ | |||
new OO.ui.FieldLayout(addLinkButton, { |
|||
align: 'top' |
align: 'top' |
||
}), |
}), |
||
new OO.ui.FieldLayout(descriptionInput, { |
new OO.ui.FieldLayout(descriptionInput, { |
||
label: 'Opis', |
label: 'Opis zadania', |
||
align: 'top' |
align: 'top' |
||
}) |
}) |
||
] |
] |
||
}) |
}).$element |
||
); |
|||
| ⚫ | |||
// Przyciski akcji |
|||
dialog.actions = [ |
|||
{ action: 'cancel', label: 'Anuluj', flags: ['safe', 'close'] }, |
|||
{ action: 'submit', label: 'Zapisz', flags: ['primary', 'progressive'] } |
|||
]; |
|||
| ⚫ | |||
// Obsługa akcji |
|||
| ⚫ | |||
flags: ['primary', 'progressive'] |
|||
if (action === 'submit') { |
|||
return new OO.ui.Process(function () { |
|||
| ⚫ | |||
| ⚫ | |||
}); |
|||
} |
|||
return dialog.parent.getActionProcess.call(this, action); |
|||
}; |
}; |
||
| Line 120: | Line 131: | ||
$('body').append(windowManager.$element); |
$('body').append(windowManager.$element); |
||
windowManager.addWindows([dialog]); |
windowManager.addWindows([dialog]); |
||
windowManager.openWindow(dialog |
windowManager.openWindow(dialog); |
||
// Obsługa zamykania okna |
|||
| ⚫ | |||
| ⚫ | |||
if (data && data.action === 'submit') { |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
} |
} |
||