24 from zope.dublincore.interfaces import IZopeDublinCore |
24 from zope.dublincore.interfaces import IZopeDublinCore |
25 from zope.interface import Interface, implementer |
25 from zope.interface import Interface, implementer |
26 from zope.schema import Bool, Int |
26 from zope.schema import Bool, Int |
27 from zope.schema.fieldproperty import FieldProperty |
27 from zope.schema.fieldproperty import FieldProperty |
28 |
28 |
|
29 from pyams_file import _ |
29 from pyams_file.image import ThumbnailGeometry |
30 from pyams_file.image import ThumbnailGeometry |
30 from pyams_file.interfaces import IFileInfo, IFileModifierForm, IImage, IMediaWidget, IResponsiveImage, ISVGImage, \ |
31 from pyams_file.interfaces import IFileInfo, IFileModifierForm, IImage, IMediaWidget, IResponsiveImage, ISVGImage, \ |
31 IThumbnailForm, IThumbnailer, IThumbnails |
32 IThumbnailForm, IThumbnailGeometry, IThumbnailer, IThumbnails |
32 from pyams_file.zmi import FileModifierAction |
33 from pyams_file.zmi import FileModifierAction |
33 from pyams_form.form import DialogDisplayForm, ajax_config |
34 from pyams_form.form import DialogDisplayForm, ajax_config |
34 from pyams_form.help import FormHelp |
35 from pyams_form.help import FormHelp |
35 from pyams_form.interfaces.form import IFormHelp, IWidgetsPrefixViewletsManager |
36 from pyams_form.interfaces.form import IFormHelp, IWidgetsPrefixViewletsManager |
36 from pyams_form.schema import CloseButton |
37 from pyams_form.schema import CloseButton |
46 from pyams_utils.request import check_request |
47 from pyams_utils.request import check_request |
47 from pyams_utils.url import absolute_url |
48 from pyams_utils.url import absolute_url |
48 from pyams_viewlet.viewlet import Viewlet, viewlet_config |
49 from pyams_viewlet.viewlet import Viewlet, viewlet_config |
49 from pyams_zmi.form import AdminDialogEditForm |
50 from pyams_zmi.form import AdminDialogEditForm |
50 from pyams_zmi.layer import IAdminLayer |
51 from pyams_zmi.layer import IAdminLayer |
51 |
|
52 from pyams_file import _ |
|
53 |
52 |
54 |
53 |
55 # |
54 # |
56 # SVG utilities |
55 # SVG utilities |
57 # |
56 # |
291 geometry = ThumbnailGeometry() |
290 geometry = ThumbnailGeometry() |
292 geometry.x1 = int(self.request.params.get('selection.x1')) |
291 geometry.x1 = int(self.request.params.get('selection.x1')) |
293 geometry.y1 = int(self.request.params.get('selection.y1')) |
292 geometry.y1 = int(self.request.params.get('selection.y1')) |
294 geometry.x2 = int(self.request.params.get('selection.x2')) |
293 geometry.x2 = int(self.request.params.get('selection.x2')) |
295 geometry.y2 = int(self.request.params.get('selection.y2')) |
294 geometry.y2 = int(self.request.params.get('selection.y2')) |
296 IThumbnails(self.context).set_geometry(self.selection_name, geometry) |
295 if not geometry.is_empty(): |
|
296 IThumbnails(self.context).set_geometry(self.selection_name, geometry) |
|
297 return {IThumbnailGeometry: ('x1', 'y1', 'x2', 'y2')} |
297 |
298 |
298 def get_ajax_output(self, changes): |
299 def get_ajax_output(self, changes): |
299 return { |
300 if changes: |
300 'status': 'success', |
301 return { |
301 'message': self.request.localizer.translate(self.successMessage) |
302 'status': 'success', |
302 } |
303 'message': self.request.localizer.translate(self.successMessage) |
|
304 } |
|
305 else: |
|
306 return { |
|
307 'status': 'info', |
|
308 'message': self.request.localizer.translate(self.noChangesMessage) |
|
309 } |
303 |
310 |
304 |
311 |
305 @viewlet_config(name='thumbnail.selection.widgets-prefix', context=IImage, layer=IAdminLayer, |
312 @viewlet_config(name='thumbnail.selection.widgets-prefix', context=IImage, layer=IAdminLayer, |
306 view=ImageSelectionThumbnailEditForm, manager=IWidgetsPrefixViewletsManager) |
313 view=ImageSelectionThumbnailEditForm, manager=IWidgetsPrefixViewletsManager) |
307 @template_config(template='templates/image-selection.pt') |
314 @template_config(template='templates/image-selection.pt') |