X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=blobdiff_plain;f=app%2Fassets%2Fjavascripts%2Fmodels%2Fpanel_picture.js.coffee;h=962f2f58980e38d3842507d3b0f20f1451f872ef;hp=1dcb93e2505971877db3bf02e63fd0181096920c;hb=d7c8065be895b67dc453b0e11ad0f259f1ca6706;hpb=26485fdc94aad6e87484cfe8c31a71996dbee375 diff --git a/app/assets/javascripts/models/panel_picture.js.coffee b/app/assets/javascripts/models/panel_picture.js.coffee index 1dcb93e2..962f2f58 100644 --- a/app/assets/javascripts/models/panel_picture.js.coffee +++ b/app/assets/javascripts/models/panel_picture.js.coffee @@ -1,70 +1,64 @@ -class PanelPicture extends Element - @single: () -> +class Pettanr.PanelPicture extends Peta.Element + + @singular: () -> 'PanelPicture' @plural: () -> 'PanelPictures' - @colum_structures: -> - {} - defaults: { - x: 11 + id: null } - initialize: () -> - confirm("Welcome to this world") + @pick_item_name: () -> + 'resource_picture' + + @traceable_item_names: () -> + ['ground_picture', 'picture'] + + pick: (picked_item) -> + { + picture_id: picked_item.get('picture_id'), + width: picked_item.get('width'), + height: picked_item.get('height') + } - @test: () -> - confirm( @single()) - confirm( @plural() ) - confirm( @class_name() ) - confirm( @element_name() ) - confirm( @table_name() ) - confirm( @path_name() ) - confirm( @colum_structures() ) - - has_picture: () -> + @trace_routes: () -> + { + resource_picture: ['picture', 'resource_picture_picture', 'resource_picture'] + symbol: 'picture' + } + + @has_picture: () -> true - has_part: () -> - false + flip: () -> + v = if @get('height') > 0 + '' + else + 'v' + h = if @get('width') > 0 + '' + else + 'h' + res = v + h + res = res # format of /1.png?subdir=v + # res += '/' unless res.empty? # format of /v/1.png + res + + filename: (picture) -> + q = if _.isEmpty(@flip()) + '' + else + '?subdir=' + @flip() + picture.filename() + q + + r_url: (picture) -> + '/pictures/' + @filename(picture) + + element_face: () -> + new Pettanr.Views.PanelPicture.ElementFace({element: this}) - extend_column: () -> - null + initialize: (attr, options) -> + super(attr, options) - test: () -> - confirm( @has_picture() ) - confirm( @has_part() ) - confirm( @parts() ) - confirm( @has_helper('column_name') ) - confirm( @element_name() ) - confirm( @extend_column() ) - confirm( @extend_element_name() ) - confirm( @find_configurations(window.configurations,'v') ) - confirm( @new_index() ) - confirm( @set_new_index(3) ) - confirm( @set_new_panel('v') ) - confirm( @get_new_panel() ) - confirm( '@get_panel()' ) - confirm( @get_panel() ) - confirm( @tag_id('c') ) - confirm( @field_tag_id('f') ) - confirm( @tag_panel_id() ) - confirm( @tag_element_id() ) - confirm( @tag_element_type() ) - confirm( @tag_new_index() ) - confirm( @path_name() ) - confirm( @form_template() ) - confirm( @scenario_template() ) - confirm( @element_face_template() ) - confirm( @form_helper_template('colum_name') ) - confirm( @tag_attributes('column') ) - confirm( @field_tag_attributes('column', 0, {}) ) - confirm( @any_tag_attributes('name', {}) ) - confirm( @select_tag_attributes(true, 'column', 0) ) - confirm( @tag_attr('column', {}) ) - confirm( @field_tag_attr('column', 1, {}) ) - confirm( @any_tag_attr('name', {}) ) - -@PanelPicture = PanelPicture