diff --git modules/image/image.admin.css modules/image/image.admin.css index c279458..0928e7a 100644 --- modules/image/image.admin.css +++ modules/image/image.admin.css @@ -49,13 +49,54 @@ div.image-style-preview div.preview-image div.height span { /** * Image anchor element. */ -table.image-anchor { +.image-anchor table { width: auto; } -table.image-anchor tr.even, -table.image-anchor tr.odd { +.image-anchor table tr.even, +.image-anchor table tr.odd { background: none; } -table.image-anchor td { +.image-anchor table td { border: 1px solid #CCC; } + +.image-anchor table.with-widget { + background: url(images/arrows-sprite.png) no-repeat 0 0; + height: 90px; + width: 90px; +} +.image-anchor table.with-widget td { + border: none; + cursor: pointer; +} +.image-anchor table.with-widget input { + display: none; + visibility: hidden; +} +.image-anchor table.left-top { + background-position: -91px 0; +} +.image-anchor table.center-top { + background-position: -182px 0; +} +.image-anchor table.right-top { + background-position: -273px 0; +} +.image-anchor table.left-center { + background-position: -728px 0; +} +.image-anchor table.center-center { + background-position: 0 0; +} +.image-anchor table.right-center { + background-position: -364px 0; +} +.image-anchor table.left-bottom { + background-position: -637px 0; +} +.image-anchor table.center-bottom { + background-position: -546px 0; +} +table.right-bottom { + background-position: -455px 0; +} diff --git modules/image/image.admin.inc modules/image/image.admin.inc index 84ebb88..6753d76 100644 --- modules/image/image.admin.inc +++ modules/image/image.admin.inc @@ -496,6 +496,8 @@ function image_scale_form($data) { * The current configuration for this crop effect. */ function image_crop_form($data) { + drupal_add_js(drupal_get_path('module', 'image') . '/image.js'); + $data += array( 'width' => '', 'height' => '', @@ -738,14 +740,14 @@ function theme_image_anchor($element) { foreach ($element_children as $n => $key) { $element[$key]['#attributes']['title'] = $element[$key]['#title']; unset($element[$key]['#title']); - $row[] = drupal_render($element[$key]); + $row[] = array('data' => drupal_render($element[$key]), 'class' => $key); if ($n % $size == $size - 1) { $rows[] = $row; $row = array(); } } - return theme('table', array(), $rows, array('class' => 'image-anchor')); + return '
' . theme('table', array(), $rows, array('class' => $element['#default_value'])) . '
'; } /** diff --git modules/image/image.js modules/image/image.js new file mode 100644 index 0000000..2bfc373 --- /dev/null +++ modules/image/image.js @@ -0,0 +1,15 @@ +// $Id: +(function ($) { + Drupal.behaviors.imageCropAnchor = { + attach: function (context) { + $('.image-anchor table').addClass('with-widget'); + // Change class of image anchor widget table on click so that the + // appropriate background-position is used and toggle the radio button + // contained by the clicked td. + $('.image-anchor table td').click(function() { + $('.image-anchor table').attr('class', 'with-widget ' + $(this).attr('class')); + $(this).find('input').attr('checked', 'checked'); + }); + } + }; +})(jQuery); diff --git modules/image/images/arrows-sprite.png modules/image/images/arrows-sprite.png new file mode 100644 index 0000000..bcddfdf Binary files /dev/null and modules/image/images/arrows-sprite.png differ