本文整理汇总了Python中pyasm.web.DivWdg.add_named_listener方法的典型用法代码示例。如果您正苦于以下问题:Python DivWdg.add_named_listener方法的具体用法?Python DivWdg.add_named_listener怎么用?Python DivWdg.add_named_listener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyasm.web.DivWdg
的用法示例。
在下文中一共展示了DivWdg.add_named_listener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_action_html
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_named_listener [as 别名]
def get_action_html(my):
search_key = SearchKey.get_by_sobject(my.sobjects[0], use_id=True)
search_type = my.sobjects[0].get_base_search_type()
div = DivWdg(css='centered')
# construct the bvr
element_names = my.element_names[:]
for element_name in my.skipped_element_names:
element_names.remove(element_name)
bvr = {
'type': 'click_up',
'mode': my.mode,
'element_names': element_names,
'search_key': search_key,
'input_prefix': my.input_prefix,
'view': my.view
}
if my.mode == 'insert':
bvr['refresh'] = 'true'
# for adding parent relationship in EditCmd
if my.parent_key:
bvr['parent_key'] = my.parent_key
hidden_div = DivWdg()
hidden_div.add_style("display: none")
div.add(hidden_div)
hidden = TextAreaWdg("__data__")
hidden_div.add(hidden)
hidden.set_value( jsondumps(bvr) )
show_action = my.kwargs.get("show_action")
if show_action in [False, 'false']:
return div
div.add_styles('height: 35px; margin-top: 5px;')
div.add_named_listener('close_EditWdg', '''
var popup = spt.popup.get_popup( $('edit_popup') );
if (popup != null) {
spt.popup.destroy(popup);
}
''')
# custom callbacks
cbjs_cancel = my.kwargs.get('cbjs_cancel')
if not cbjs_cancel:
cbjs_cancel = '''
spt.named_events.fire_event('preclose_edit_popup', {});
spt.named_events.fire_event('close_EditWdg', {})
'''
# custom callbacks
cbjs_insert_path = my.kwargs.get('cbjs_%s_path' % my.mode)
cbjs_insert = None
if cbjs_insert_path:
script_obj = CustomScript.get_by_path(cbjs_insert_path)
if script_obj:
cbjs_insert = script_obj.get_value("script")
# get it inline
if not cbjs_insert:
cbjs_insert = my.kwargs.get('cbjs_%s' % my.mode)
# use a default
if not cbjs_insert:
mode_label = my.mode.capitalize()
cbjs_insert = '''
spt.app_busy.show("%sing items", "");
spt.edit.edit_form_cbk(evt, bvr);
spt.app_busy.hide();
'''%mode_label
save_event = my.kwargs.get('save_event')
if not save_event:
save_event = div.get_unique_event("save")
bvr['save_event'] = save_event
bvr['named_event'] = 'edit_pressed'
bvr['cbjs_action'] = cbjs_insert
ok_btn_label = my.mode.capitalize()
if ok_btn_label == 'Edit':
ok_btn_label = 'Save'
if ok_btn_label == 'Insert':
ok_btn_label = 'Add'
#.........这里部分代码省略.........
示例2: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_named_listener [as 别名]
def get_display(my):
search_type_obj = SearchType.get(my.search_type)
sobj_title = search_type_obj.get_title()
my.color_mode = my.kwargs.get("color_mode")
if not my.color_mode:
my.color_mode = "default"
top_div = my.top
top_div.add_class("spt_edit_top")
if not my.is_refresh:
my.set_as_panel(top_div)
content_div = DivWdg()
content_div.add_class("spt_edit_top")
content_div.add_class("spt_edit_form_top")
content_div.set_attr("spt_search_key", my.search_key)
if not Container.get_dict("JSLibraries", "spt_edit"):
content_div.add_behavior( {
'type': 'load',
'cbjs_action': my.get_onload_js()
} )
layout_view = my.kwargs.get("layout_view")
if layout_view:
layout_wdg = my.get_custom_layout_wdg(layout_view)
content_div.add(layout_wdg)
return content_div
# add close listener
# NOTE: this is an absolute search, but is here for backwards
# compatibility
content_div.add_named_listener('close_EditWdg', '''
var popup = bvr.src_el.getParent( ".spt_popup" );
if (popup)
spt.popup.close(popup);
''')
attrs = my.config.get_view_attributes()
default_access = attrs.get("access")
if not default_access:
default_access = "edit"
project_code = Project.get_project_code()
security = Environment.get_security()
base_key = search_type_obj.get_base_key()
key = {
'search_type': base_key,
'project': project_code
}
access = security.check_access("sobject", key, "edit", default=default_access)
if not access:
my.is_disabled = True
else:
my.is_disabled = False
disable_wdg = None
if my.is_disabled:
# TODO: This overlay doesn't work in IE, size, position,
# and transparency all fail.
disable_wdg = DivWdg(id='edit_wdg')
disable_wdg.add_style("position: absolute")
disable_wdg.add_style("height: 90%")
disable_wdg.add_style("width: 100%")
disable_wdg.add_style("left: 0px")
#disable_wdg.add_style("bottom: 0px")
#disable_wdg.add_style("top: 0px")
disable_wdg.add_style("opacity: 0.2")
disable_wdg.add_style("background: #fff")
#disable_wdg.add_style("-moz-opacity: 0.2")
disable_wdg.add_style("filter: Alpha(opacity=20)")
disable_wdg.add("<center>EDIT DISABLED</center>")
content_div.add(disable_wdg)
attrs = my.config.get_view_attributes()
inner = DivWdg()
content_div.add(inner)
menu = my.get_header_context_menu()
menus = [menu.get_data()]
menus_in = {
'HEADER_CTX': menus,
}
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
#.........这里部分代码省略.........
示例3: get_example_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_named_listener [as 别名]
def get_example_display(self):
div = DivWdg()
# ---------------------------------------------------------------------------------------------------------
self.setup_next_example(div,"Demonstrates the adding of a 'listen' type behavior Named Event in Javascript " \
"dynamically")
dummy_listener_div = DivWdg()
dummy_listener_div.set_id("dummy_listener_div")
dummy_listener_div.set_style("border: 1px solid #000000; background: #AAAAAA; color: #000000; " \
"width: 1000px; padding: 10px;")
dummy_listener_div.add("This DIV has no listener on it, add one dynamically by running:<br/><br/>" \
"<pre>\n spt.named_events.add_listener( $('dummy_listener_div'), 'mike_test_event', " \
"{ 'cbjs_action': 'bvr.src_el.setStyle(\"background-color\",\"red\");' } );\n" \
" spt.named_events.fire_event('mike_test_event',{});\n" \
"</pre><br/>" \
"in the TACTIC Script Editor.")
div.add( dummy_listener_div )
# ---------------------------------------------------------------------------------------------------------
self.setup_next_example(div,"Demonstrates the firing of an SPT Named Event for 'listen' type behavior. This " \
"example also shows the adding of stacked 'listen' type behaviors on a single " \
"element listening for a single event name (allowing 2 actions to occur on the " \
"firing of one event name)" )
named_event_name = 'SingleNamedEvent'
named_fire_div = DivWdg()
named_fire_div.set_id( "%s_Firer" % named_event_name )
named_fire_div.set_style("border: 1px solid #000000; background: #AAAAAA; color: #000000; width: 200px; " \
"cursor: pointer; padding: 4px;")
named_fire_div.add("Click me to Fire an SPT Named Event!")
named_fire_div.add_behavior( {'type': 'click',
'cbjs_action': 'spt.named_events.fire_event("%s",bvr);' % named_event_name,
'cbfn_preprocess': 'spt.ui_play.named_event_fire_preprocess',
'cbfn_postprocess': 'spt.ui_play.named_event_fire_postprocess'} )
div.add( named_fire_div )
div.add( '<br/>' )
named_listener_div = DivWdg()
named_listener_div.set_style("border: 1px solid #000000; background: #0000AA; width: 200px; padding: 4px;")
named_listener_div.add("Listening for an SPT Named Event!")
named_listener_div.add_behavior( {'type': 'listen', 'event_name': named_event_name,
'cbjs_action': 'alert("Named event [%s] has fired!");' % named_event_name} )
# show ability to stack more call-backs on the same event for the same element ...
named_listener_div.add_behavior( {'type': 'listen', 'event_name': named_event_name,
'cbjs_action': 'bvr.src_el.setStyle("background-color","red");'} )
div.add( named_listener_div )
# ---------------------------------------------------------------------------------------------------------
self.setup_next_example( div, "Demonstrates the ability for a single Named Event 'listen' behavior to listen to " \
"multiple event names, but execute a single call-back" )
event_name_list = [
'MultipleNamedEvents_Event_One',
'MultipleNamedEvents_Event_Two',
'MultipleNamedEvents_Event_Three',
'MultipleNamedEvents_Event_Four'
]
named_listener_div = DivWdg()
named_listener_div.set_id( "MultiNamedEventListenerDiv" )
named_listener_div.set_style("border: 1px solid #000000; background: #005500; width: 300px; padding: 4px;")
named_listener_div.add("Listening on MULTIPLE SPT Named Events!")
named_listener_div.add_behavior( {'type': 'listen', 'event_name': event_name_list,
'cbfn_action': 'spt.ui_play.named_event_listen_cbk'} )
div.add( named_listener_div )
div.add( '<br/>' )
for event_name in event_name_list:
named_fire_div = DivWdg()
named_fire_div.set_id( "%s_Firer" % event_name )
named_fire_div.set_style("border: 1px solid #000000; background: #AAAAAA; color: #000000; width: 200px; " \
"cursor: pointer; padding: 4px;")
named_fire_div.add("Click me to Fire '%s'!" % event_name)
behavior = {'type': 'click', 'cb_fire_named_event': event_name}
if event_name.endswith( "_One" ):
behavior['cbjs_preprocess'] = 'log.debug(">>> Ran cbjs_preprocess!");'
behavior['cbjs_postprocess'] = 'log.debug(">>> Ran cbjs_postprocess!");'
named_fire_div.add_behavior( behavior )
div.add( named_fire_div )
div.add( '<br/>' )
# ------------------------------------------------------------------------------------------------------------
self.setup_next_example( div, "Demonstrates the use of the convenience short cut for adding a 'listen' " \
"type behavior by using HtmlElement.add_named_listener() method" )
# Add a div to click on to fire the desired named event ...
#.........这里部分代码省略.........
示例4: get_display
# 需要导入模块: from pyasm.web import DivWdg [as 别名]
# 或者: from pyasm.web.DivWdg import add_named_listener [as 别名]
def get_display(my):
search_type_obj = SearchType.get(my.search_type)
sobj_title = search_type_obj.get_title()
my.color_mode = my.kwargs.get("color_mode")
if not my.color_mode:
my.color_mode = "default"
top_div = my.top
top_div.add_class("spt_edit_top")
if not my.is_refresh:
my.set_as_panel(top_div)
content_div = DivWdg()
content_div.add_class("spt_edit_top")
content_div.add_class("spt_edit_form_top")
content_div.set_attr("spt_search_key", my.search_key)
if not Container.get_dict("JSLibraries", "spt_edit"):
content_div.add_behavior( {
'type': 'load',
'cbjs_action': my.get_onload_js()
} )
layout_view = my.kwargs.get("layout_view")
if layout_view:
layout_wdg = my.get_custom_layout_wdg(layout_view)
content_div.add(layout_wdg)
return content_div
# add close listener
# NOTE: this is an absolute search, but is here for backwards
# compatibility
content_div.add_named_listener('close_EditWdg', '''
var popup = bvr.src_el.getParent( ".spt_popup" );
if (popup)
spt.popup.close(popup);
''')
attrs = my.config.get_view_attributes()
default_access = attrs.get("access")
if not default_access:
default_access = "edit"
project_code = Project.get_project_code()
security = Environment.get_security()
base_key = search_type_obj.get_base_key()
key = {
'search_type': base_key,
'project': project_code
}
access = security.check_access("sobject", key, "edit", default=default_access)
if not access:
my.is_disabled = True
else:
my.is_disabled = False
disable_wdg = None
if my.is_disabled:
# TODO: This overlay doesn't work in IE, size, position,
# and transparency all fail.
disable_wdg = DivWdg(id='edit_wdg')
disable_wdg.add_style("position: absolute")
disable_wdg.add_style("height: 90%")
disable_wdg.add_style("width: 100%")
disable_wdg.add_style("left: 0px")
#disable_wdg.add_style("bottom: 0px")
#disable_wdg.add_style("top: 0px")
disable_wdg.add_style("opacity: 0.2")
disable_wdg.add_style("background: #fff")
#disable_wdg.add_style("-moz-opacity: 0.2")
disable_wdg.add_style("filter: Alpha(opacity=20)")
disable_wdg.add("<center>EDIT DISABLED</center>")
content_div.add(disable_wdg)
attrs = my.config.get_view_attributes()
#inner doesn't get styled.
inner = DivWdg()
content_div.add(inner)
menu = my.get_header_context_menu()
menus = [menu.get_data()]
menus_in = {
'HEADER_CTX': menus,
}
SmartMenu.attach_smart_context_menu( inner, menus_in, False )
#insert the header before body into inner
#.........这里部分代码省略.........