class PettanrPictureSizeHelper
confirm_confirm_confirm = () ->
confirm( )
@WritingFormat = window.PettanrWritingFormat
@refresh_picture = (e, w, h) ->
if w and h
sd = ''
if h < 0
sd += 'v'
if w < 0
sd += 'h'
if sd.length > 0
sd += '/'
pid = parseInt(e.attr('picture_id')).toString()
ext = e.attr('ext')
src = '/pictures/' + sd + pid + '.' + ext
e.attr('src', src)
@add_helper = () ->
editor = window.PettanrEditor
$('.panel_picture_width_tool').map ->
$(@).html('')
$('.panel_picture_height_tool').map ->
$(@).html('')
$('.wreverse').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'width')
w = -f.val()
f.val(w)
f = $(trace + 'height')
h = f.val()
PettanrPictureSizeHelper.refresh_picture($(trace + 'img'), w, h)
$('.wdouble').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'width')
w = f.val() * 2
f.val(w)
$(trace + 'img').width(Math.abs(w))
$(trace + 'img').parent().width(Math.abs(w))
$('.whalf').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'width')
w = Math.floor(f.val() / 2)
f.val(w)
$(trace + 'img').width(Math.abs(w))
$(trace + 'img').parent().width(Math.abs(w))
$('.hreverse').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'height')
h = -f.val()
f.val(h)
f = $(trace + 'width')
w = f.val()
PettanrPictureSizeHelper.refresh_picture($(trace + 'img'), w, h)
$('.hdouble').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'height')
h = f.val() * 2
f.val(h)
$(trace + 'img').height(Math.abs(h))
$(trace + 'img').parent().height(Math.abs(h))
$('.hhalf').click ->
d = $(@).parent()
trace = editor.element_tag_id(d)
f = $(trace + 'height')
h = Math.floor(f.val() / 2)
f.val(h)
$(trace + 'img').height(Math.abs(h))
$(trace + 'img').parent().height(Math.abs(h))
@PettanrPictureSizeHelper = PettanrPictureSizeHelper