

@presentation.render_for(BoardBackground)
@presentation.render_for(BoardBackground, model='edit')
def render_board_background_edit(self, h, comp, *args):
    'Render the background configuration panel'
    if self._changed():
        h.head.javascript(h.generate_id(), ('YAHOO.kansha.app.setBoardBackgroundImage(%s, %s);YAHOO.kansha.app.setTitleColor(%s)' % (ajax.py2js((self.board.background_image_url or ''), h), ajax.py2js(self.board.background_image_position, h), ajax.py2js((self.board.title_color or ''), h))))
        self._changed(False)
    with h.div(class_='panel-section background'):
        (h << h.div(_('Background image'), class_='panel-section-title'))
        with h.div:
            with h.div:
                v_file = var.Var()
                submit_id = h.generate_id('attach_submit')
                input_id = h.generate_id('attach_input')
                (h << h.label((h.i(class_='icon-file'), _('Choose an image')), class_='btn', for_=input_id))
                with h.form(class_='hidden'):
                    (h << h.script(("\n                function valueChanged(e) {\n                    if (YAHOO.kansha.app.checkFileSize(this, %(max_size)s)) {\n                        YAHOO.util.Dom.get(%(submit_id)s).click();\n                    } else {\n                        alert(%(error)s);\n                    }\n                }\n\n                YAHOO.util.Event.onDOMReady(function() {\n                    YAHOO.util.Event.on(%(input_id)s, 'change', valueChanged);\n                });" % {
                        'max_size': ajax.py2js(self.board.background_max_size, h),
                        'input_id': ajax.py2js(input_id, h),
                        'submit_id': ajax.py2js(submit_id, h),
                        'error': ajax.py2js(_('Max file size exceeded'), h).decode('UTF-8'),
                    })))
                    (h << h.input(id=input_id, class_='hidden', type='file', name='file', multiple='multiple', maxlength='100').action(v_file))
                    (h << h.input(id=submit_id, class_='hidden', type='submit').action((lambda : self.set_background(v_file()))))
            with h.div:
                ((h << _('or')) << ' ')
                (h << h.a(_('Reset background')).action(self.reset_background))
        with h.div:
            with h.span(class_='text-center'):
                (h << component.Component(self.board, model='background_image'))
        with h.div:
            input_id = h.generate_id()
            submit_id = h.generate_id('image_position_submit')
            (h << h.script(("YAHOO.util.Event.onDOMReady(function() {\n                YAHOO.util.Event.on(%(input_id)s, 'change', function() { YAHOO.util.Dom.get(%(submit_id)s).click(); });\n            });" % {
                'input_id': ajax.py2js(input_id, h),
                'submit_id': ajax.py2js(submit_id, h),
            })))
            with h.form:
                (h << h.label(_('Image position'), for_=input_id))
                with h.select(id_=input_id).action(self.background_position):
                    for (value, name) in self.get_available_background_positions():
                        (h << h.option(name, value=value).selected(self.background_position()))
                (h << h.input(class_='hidden', id_=submit_id, type='submit').action(self.set_background_position))
    with h.div(class_='panel-section background'):
        (h << h.div(_('Board title color'), class_='panel-section-title'))
        with h.div:
            with h.div:
                (h << comp.render(h, model='title-color-edit'))
            with h.div:
                ((h << _('or')) << ' ')
                (h << h.a(_('Reset to default color')).action(self.reset_color))
    return h.root

dataset/ETHPy150Open Net-ng/kansha/kansha/board/view.py render_board_background_edit/original