当前位置: 首页>>代码示例>>Python>>正文


Python HtmlElement.add_behavior方法代码示例

本文整理汇总了Python中pyasm.web.HtmlElement.add_behavior方法的典型用法代码示例。如果您正苦于以下问题:Python HtmlElement.add_behavior方法的具体用法?Python HtmlElement.add_behavior怎么用?Python HtmlElement.add_behavior使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyasm.web.HtmlElement的用法示例。


在下文中一共展示了HtmlElement.add_behavior方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DynByFoundValueSmartSelectWdg

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_behavior [as 别名]
class DynByFoundValueSmartSelectWdg(BaseRefreshWdg):

    def get_args_keys(self):
        return {
        }


    def init(self):

        list_item_table = ''
        self.full_item_list = []
        if self.kwargs.has_key( 'list_item_table' ):
            list_item_table = self.kwargs.get( 'list_item_table' )
            expr = '@SOBJECT(MMS/%s)' % list_item_table
            parser = ExpressionParser()
            self.full_item_list = parser.eval(expr)

        self.el_name = ''
        if self.kwargs.has_key( 'element_name' ):
            self.el_name = self.kwargs.get( 'element_name' )

        self.input_el_name = ''
        if self.kwargs.has_key( 'input_element_to_find' ):
            self.input_el_name = self.kwargs.get( 'input_element_to_find' )

        self.col_to_match = ''
        if self.kwargs.has_key( 'column_to_match_value' ):
            self.col_to_match = self.kwargs.get( 'column_to_match_value' )

        self.col_for_label = ''
        if self.kwargs.has_key( 'column_for_label' ):
            self.col_for_label = self.kwargs.get( 'column_for_label' )

        self.select_element = HtmlElement('select')


    def force_default_context_menu(self):
        pass


    def add_behavior(self, bvr):
        self.select_element.add_behavior( bvr )


    def add_no_option(self, sel_el):
        option = HtmlElement('option')
        option.set_attr( "value", "" )
        option.add( "-- No Options Found --" )
        sel_el.add( option )

        option = HtmlElement('option')
        option.set_attr( "value", "" )
        no_value_label = "-- No Filter Value Found --"
        if self.kwargs.get('no_value_found_label'):
            no_value_label = self.kwargs.get('no_value_found_label')
        option.add( no_value_label )
        sel_el.add( option )


    def get_display(self):
        
        sel_el = self.select_element

        sel_el.add_class("inputfield")
        sel_el.add_class("spt_input")
        sel_el.set_attr("name", self.el_name)

        # NOTE: make this javascript dynamic (much less effecient), but need
        # to isolate for now and will optimize if necessary
        sel_el.add_behavior( {
            'type': 'load',
            'cbjs_action': self.get_onload_js()
        } )



        options_arr = []

        '''
        self.add_no_option( sel_el )
        '''
        options_arr.append( "||%s" % ("-- No Options Found --") )
        no_value_label = "-- No Filter Value Found --"
        if self.kwargs.get('no_value_found_label'):
            no_value_label = self.kwargs.get('no_value_found_label')
        options_arr.append( "||%s" % (no_value_label) )

        if self.full_item_list and self.el_name and self.input_el_name and self.col_to_match and self.col_for_label:
            for item in self.full_item_list:
                '''
                option = HtmlElement('option')
                label = item.get_value(self.col_for_label)
                option.set_attr( "value", label )
                option.add( label )

                option.add_class( "match_%s" % item.get_value( self.col_to_match ) )

                sel_el.add( option )
                '''
                match_tag = item.get_value( self.col_to_match )
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:smart_select_wdg.py

示例2: TopWdg

# 需要导入模块: from pyasm.web import HtmlElement [as 别名]
# 或者: from pyasm.web.HtmlElement import add_behavior [as 别名]
class TopWdg(Widget):

    def __init__(self, **kwargs):
        self.kwargs = kwargs
        super(TopWdg, self).__init__()



    def init(self):
        self.body = HtmlElement("body")
        Container.put("TopWdg::body", self.body)

        self.top = DivWdg()
        self.body.add(self.top)
        self.top.add_class("spt_top")
        Container.put("TopWdg::top", self.top)


        self.body.add_attr("ondragover", "return false;")
        self.body.add_attr("ondragleave", "return false;")
        self.body.add_attr("ondrop", "return false;")

        self.body.add_behavior( {
            'type': 'load',
            'cbjs_action': '''

            var el = bvr.src_el;

            el.spt_window_active = true;

            if (document.addEventListener) {
                document.addEventListener("visibilitychange", function() {
                    el.spt_window_active = ! document.hidden;
                } );
            }
            else {
                window.onfocus = function() {
                    bvr.src_el.spt_window_active = true;
                }

                window.onblur = function() {
                    bvr.src_el.spt_window_active = false;
                }
            }

            '''
        } )

        self.add_top_behaviors()



        
        click_div = DivWdg()
        self.top.add(click_div)
        click_div.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
        spt.body = {};

        spt.body.is_active = function() {
            return $(document.body).spt_window_active;
        }

        spt.body.focus_elements = [];
        spt.body.add_focus_element = function(el) {
            spt.body.focus_elements.push(el);
        }

        spt.body.remove_focus_element = function(el) {
            var index = spt.body.focus_elements.indexOf(el);
            if (index != -1) {
                spt.body.focus_elements.splice(index, 1);
            }
        }

        // find all of the registered popups and close them
        // NOTE: logic can handle more than 1 focus element should it happen ...
        spt.body.hide_focus_elements = function(evt) {
            var mouse = evt.client;
            var target = evt.target;


            
            var targets = [];
            var count = 0;
            while (target) {
                targets.push(target);
                if (spt.has_class(target, 'spt_activator')) {
                    act_el = target.dialog;
                    if (act_el) {
                        targets.push(act_el);
                        break;
                    }
                }


                // if target is an smenu, then return
                if (spt.has_class(target, 'SPT_SMENU')) {
                    return;
#.........这里部分代码省略.........
开发者ID:mincau,项目名称:TACTIC,代码行数:103,代码来源:top_wdg.py


注:本文中的pyasm.web.HtmlElement.add_behavior方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。