mirror of
https://github.com/processwire/processwire.git
synced 2025-08-13 18:24:57 +02:00
Add PR #38 which adds an edit-link-text feature to ProcessPageEditLink, via @rolandtoth
This commit is contained in:
@@ -173,6 +173,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set link text
|
||||||
|
var linkText = ($existingLink && $existingLink.text().length) ? $existingLink.text() : selectionText;
|
||||||
|
|
||||||
|
if(nodeName !== 'img' && linkText.length) {
|
||||||
|
modalUrl += '&text=' + encodeURIComponent(linkText);
|
||||||
|
}
|
||||||
|
|
||||||
// labels
|
// labels
|
||||||
var insertLinkLabel = ProcessWire.config.InputfieldCKEditor.pwlink.label;
|
var insertLinkLabel = ProcessWire.config.InputfieldCKEditor.pwlink.label;
|
||||||
var cancelLabel = ProcessWire.config.InputfieldCKEditor.pwlink.cancel;
|
var cancelLabel = ProcessWire.config.InputfieldCKEditor.pwlink.cancel;
|
||||||
@@ -184,7 +191,10 @@
|
|||||||
var $i = $iframe.contents();
|
var $i = $iframe.contents();
|
||||||
var $a = jQuery(jQuery("#link_markup", $i).text());
|
var $a = jQuery(jQuery("#link_markup", $i).text());
|
||||||
if($a.attr('href') && $a.attr('href').length) {
|
if($a.attr('href') && $a.attr('href').length) {
|
||||||
$a.html(selectionText);
|
// $a.html(selectionText);
|
||||||
|
if(!$a.text().length) {
|
||||||
|
$a.html(selectionText);
|
||||||
|
}
|
||||||
var html = jQuery("<div />").append($a).html();
|
var html = jQuery("<div />").append($a).html();
|
||||||
editor.insertHtml(html);
|
editor.insertHtml(html);
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -22,6 +22,7 @@ $(document).ready(function() {
|
|||||||
var $fileSelect = $("#link_page_file");
|
var $fileSelect = $("#link_page_file");
|
||||||
var $anchorSelect = $("#link_page_anchor");
|
var $anchorSelect = $("#link_page_anchor");
|
||||||
var $linkPageURL = $("#link_page_url_input");
|
var $linkPageURL = $("#link_page_url_input");
|
||||||
|
var $linkText = $("#link_text");
|
||||||
|
|
||||||
$linkPageURL.val($("#link_page_url").val()); // copy from hidden
|
$linkPageURL.val($("#link_page_url").val()); // copy from hidden
|
||||||
|
|
||||||
@@ -153,6 +154,10 @@ $(document).ready(function() {
|
|||||||
$link.attr('title', val);
|
$link.attr('title', val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($linkText.length && $linkText.val().length) {
|
||||||
|
$link.text($linkText.val());
|
||||||
|
}
|
||||||
|
|
||||||
var $linkRel = $("#link_rel");
|
var $linkRel = $("#link_rel");
|
||||||
if($linkRel.length && $linkRel.val().length) {
|
if($linkRel.length && $linkRel.val().length) {
|
||||||
$link.attr('rel', $linkRel.val());
|
$link.attr('rel', $linkRel.val());
|
||||||
@@ -307,10 +312,12 @@ $(document).ready(function() {
|
|||||||
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
$linkPageURL.change();
|
$linkPageURL.change();
|
||||||
|
$linkText.change();
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
$(":input").change(updateLinkPreview);
|
$(":input").change(updateLinkPreview);
|
||||||
$("#link_title").keydown(function(event) { updateLinkPreview(); });
|
$("#link_title").keydown(function(event) { updateLinkPreview(); });
|
||||||
|
$linkText.keyup(function(event) { updateLinkPreview(); });
|
||||||
|
|
||||||
// when header is clicked, open up the pageList right away
|
// when header is clicked, open up the pageList right away
|
||||||
$(".InputfieldInteger .InputfieldHeader").click(function() {
|
$(".InputfieldInteger .InputfieldHeader").click(function() {
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -24,7 +24,7 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
|
|||||||
return array(
|
return array(
|
||||||
'title' => 'Page Edit Link',
|
'title' => 'Page Edit Link',
|
||||||
'summary' => 'Provides a link capability as used by some Fieldtype modules (like rich text editors).',
|
'summary' => 'Provides a link capability as used by some Fieldtype modules (like rich text editors).',
|
||||||
'version' => 108,
|
'version' => 109,
|
||||||
'permanent' => true,
|
'permanent' => true,
|
||||||
'permission' => 'page-edit',
|
'permission' => 'page-edit',
|
||||||
'icon' => 'link',
|
'icon' => 'link',
|
||||||
@@ -152,6 +152,9 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
|
|||||||
$currentValue = '';
|
$currentValue = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$currentText = $this->wire()->input->get('text');
|
||||||
|
$currentText = $currentText === null ? '' : $this->wire()->sanitizer->text($currentText);
|
||||||
|
|
||||||
/** @var InputfieldForm $form */
|
/** @var InputfieldForm $form */
|
||||||
$form = $this->modules->get("InputfieldForm");
|
$form = $this->modules->get("InputfieldForm");
|
||||||
$form->attr('id', 'ProcessPageEditLinkForm');
|
$form->attr('id', 'ProcessPageEditLinkForm');
|
||||||
@@ -165,6 +168,16 @@ class ProcessPageEditLink extends Process implements ConfigurableModule {
|
|||||||
$fieldset->addClass('WireTab');
|
$fieldset->addClass('WireTab');
|
||||||
$form->add($fieldset);
|
$form->add($fieldset);
|
||||||
|
|
||||||
|
if($currentText) {
|
||||||
|
/** @var InputfieldText $field */
|
||||||
|
$field = $this->modules->get("InputfieldText");
|
||||||
|
$field->label = $this->_('Link text');
|
||||||
|
$field->icon = 'pencil-square';
|
||||||
|
$field->attr('id+name', 'link_text');
|
||||||
|
$field->val($currentText);
|
||||||
|
$fieldset->add($field);
|
||||||
|
}
|
||||||
|
|
||||||
/** @var InputfieldPageAutocomplete $field */
|
/** @var InputfieldPageAutocomplete $field */
|
||||||
$field = $this->modules->get("InputfieldPageAutocomplete");
|
$field = $this->modules->get("InputfieldPageAutocomplete");
|
||||||
$field->label = $this->_('Link to URL');
|
$field->label = $this->_('Link to URL');
|
||||||
|
Reference in New Issue
Block a user