diff --git modules/image/image.admin.css modules/image/image.admin.css index f5aa597..eaeb18b 100644 --- modules/image/image.admin.css +++ modules/image/image.admin.css @@ -49,13 +49,101 @@ 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 { - border: 1px solid #CCC; +.image-anchor table tr, +.image-anchor table td { + border: 1px solid #ccc; +} +.image-crop-widget table { + height: 90px; + width: 90px; +} +.image-crop-widget td { + cursor: pointer; +} +.image-crop-widget input { + display: none; + visibility: hidden; +} +/* selected */ +.image-crop-widget .left-top td.left-top, +.image-crop-widget .center-top td.center-top, +.image-crop-widget .right-top td.right-top, +.image-crop-widget .left-center td.left-center, +.image-crop-widget .center-center td.center-center, +.image-crop-widget .right-center td.right-center, +.image-crop-widget .left-bottom td.left-bottom, +.image-crop-widget .center-bottom td.center-bottom, +.image-crop-widget .right-bottom td.right-bottom { + background: #ccc; +} +/* north */ +.image-crop-widget .left-center td.left-top, +.image-crop-widget .center-center td.center-top, +.image-crop-widget .right-center td.right-top, +.image-crop-widget .left-bottom td.left-center, +.image-crop-widget .center-bottom td.center-center, +.image-crop-widget .right-bottom td.right-center { + background: url(images/cropping-arrows.png) no-repeat -60px 0; +} +/* north-east */ +.image-crop-widget .left-center td.center-top, +.image-crop-widget .center-center td.right-top, +.image-crop-widget .left-bottom td.center-center, +.image-crop-widget .center-bottom td.right-center { + background: url(images/cropping-arrows.png) no-repeat -90px 0; +} +/* east */ +.image-crop-widget .left-top td.center-top, +.image-crop-widget .center-top td.right-top, +.image-crop-widget .left-center td.center-center, +.image-crop-widget .center-center td.right-center, +.image-crop-widget .left-bottom td.center-bottom, +.image-crop-widget .center-bottom td.right-bottom { + background: url(images/cropping-arrows.png) no-repeat -120px 0; +} +/* south-east */ +.image-crop-widget .left-top td.center-center, +.image-crop-widget .center-top td.right-center, +.image-crop-widget .left-center td.center-bottom, +.image-crop-widget .center-center td.right-bottom { + background: url(images/cropping-arrows.png) no-repeat -150px 0; +} +/* south */ +.image-crop-widget .left-top td.left-center, +.image-crop-widget .center-top td.center-center, +.image-crop-widget .right-top td.right-center, +.image-crop-widget .left-center td.left-bottom, +.image-crop-widget .center-center td.center-bottom, +.image-crop-widget .right-center td.right-bottom { + background: url(images/cropping-arrows.png) no-repeat -180px 0; +} +/* south-west */ +.image-crop-widget .center-top td.left-center, +.image-crop-widget .right-top td.center-center, +.image-crop-widget .center-center td.left-bottom, +.image-crop-widget .right-center td.center-bottom { + background: url(images/cropping-arrows.png) no-repeat -210px 0; +} +/* west */ +.image-crop-widget .center-top td.left-top, +.image-crop-widget .right-top td.center-top, +.image-crop-widget .center-center td.left-center, +.image-crop-widget .right-center td.center-center, +.image-crop-widget .center-bottom td.left-bottom, +.image-crop-widget .right-bottom td.center-bottom { + background: url(images/cropping-arrows.png) no-repeat 0 0; +} +/* north-west */ +.image-crop-widget .center-center td.left-top, +.image-crop-widget .right-center td.center-top, +.image-crop-widget .center-bottom td.left-center, +.image-crop-widget .right-bottom td.center-center { + background: url(images/cropping-arrows.png) no-repeat -30px 0; } diff --git modules/image/image.admin.inc modules/image/image.admin.inc index 64b17d7..4d5f557 100644 --- modules/image/image.admin.inc +++ modules/image/image.admin.inc @@ -492,6 +492,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' => '', @@ -735,14 +737,14 @@ function theme_image_anchor($element) { foreach (element_children($element) 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 % 3 == 3 - 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..87e6550 --- /dev/null +++ modules/image/image.js @@ -0,0 +1,15 @@ +// $Id: +(function ($) { + Drupal.behaviors.imageCropAnchor = { + attach: function (context) { + $('.image-anchor').addClass('image-crop-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', $(this).attr('class')); + $(this).find('input').attr('checked', 'checked'); + }); + } + }; +})(jQuery); diff --git modules/image/images/cropping-arrows.png modules/image/images/cropping-arrows.png new file mode 100644 index 0000000..4861555 Binary files /dev/null and modules/image/images/cropping-arrows.png differ