diff --git a/css/focal_point.css b/css/focal_point.css index 3d90a8f..469fd3b 100644 --- a/css/focal_point.css +++ b/css/focal_point.css @@ -4,7 +4,6 @@ cursor: move; } .focal-point-indicator:after { - /*content: '⌖';*/ content: '+'; color: white; cursor: move; @@ -25,4 +24,14 @@ } .focal-point-preview-link { display: block; + direction: initial; + text-align: center; +} +.focal-point-preview-link:before { + content: "\1F50D"; + font-size: x-large; + vertical-align: middle; +} +.focal-point-preview-link:hover { + text-decoration: none; } diff --git a/js/focal_point.js b/js/focal_point.js index b02ff23..f5368c6 100644 --- a/js/focal_point.js +++ b/js/focal_point.js @@ -22,10 +22,12 @@ $(".focal-point-indicator", context).once('focal-point-indicator').each(function() { // Set some variables for the different pieces at play. + // @todo: replace calls to siblings() with something more reliable. var $indicator = $(this); var $img = $(this).siblings('img'); + var $previewLink = $(this).siblings('.focal-point-preview-link'); var $field = $("." + $(this).attr('data-selector')); - var fp = new Drupal.FocalPoint($indicator, $img, $field); + var fp = new Drupal.FocalPoint($indicator, $img, $field, $previewLink); // Set the position of the indicator on image load and any time the // field value changes. We use a bit of hackery to make certain that the @@ -54,13 +56,16 @@ * The image jQuery object to which the indicator is attached. * @param $field array * The field jQuery object where the position can be found. + * @param $previewLink object + * The previewLink jQuery object. */ - Drupal.FocalPoint = function($indicator, $img, $field) { + Drupal.FocalPoint = function($indicator, $img, $field, $previewLink) { var self = this; this.$indicator = $indicator; this.$img = $img; this.$field = $field; + this.$previewLink = $previewLink; // Make the focal point indicator draggable and tell it to update the // appropriate field when it is moved by the user. @@ -102,7 +107,7 @@ // Wrap the focal point indicator and thumbnail image in a div so that // everything still works with RTL languages. - this.$indicator.add(this.$img).wrapAll("
"); + this.$indicator.add(this.$img).add(this.$previewLink).wrapAll(""); }; /** diff --git a/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php b/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php index a3f64a9..24be101 100644 --- a/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php +++ b/src/Plugin/Field/FieldWidget/FocalPointImageWidget.php @@ -60,10 +60,10 @@ class FocalPointImageWidget extends ImageWidget { $preview_focal_point_value = str_replace(',', 'x', $default_focal_point_value); $preview_link = [ '#type' => 'link', - '#title' => t('Image Preview'), + '#title' => t('Preview'), '#url' => new Url('focal_point.preview', ['fid' => $fid,'focal_point_value' => $preview_focal_point_value]), '#attributes' => [ - 'class' => array('focal_point_preview_link'), + 'class' => array('focal-point-preview-link'), 'data-selector' => $element_selector, 'data-field-name' => $element['#field_name'], 'target' => '_blank'