예제 #1
0
def expand_item( accum_ids, asset_def, images_dct, movies_dct, movie_panels_dct, click_panels_dct, slide_shows_dct, cpo_dct ):

        asset_name = asset_def["asset_name"]
	item_def = slide_shows_dct[asset_name]

	# prep some global action functions...
	action_scripts = {}	
	action_dct = {}
	for pagekey2 in item_def.keys():
		funcname = "func_%s_%s" % ( asset_name, pagekey2 )
		action_scripts[funcname] = None;
		action_dct[funcname] = pagekey2
	funcname = "func_%s_off " % ( asset_name )
	action_scripts[funcname] = None

	# accumulate the child elements...
	tot_style = ""
	tot_content = ""
	tot_top_script = ""
	all_on = ""
	all_off = ""
	init_script = False

	# NOTE: WE DONT DO SCRIPTS TIL END...

	# insert parent div...
	tot_style += common.emit_line("#%s {" % asset_name)
	tot_style += common.emit_line(" visibility:inherit;")
	tot_style += common.emit_line("}")
	tot_content += common.emit_line("<div id=%s >" % asset_name )

	dopage=1
	while (True):
		if not item_def.has_key( str(dopage) ):
			#print "WARNING: breaking at ", dopage
			break

		# Create a div for each slide in slide show...	
		divname = "%s_%d" % ( asset_name, dopage )
		accum_ids.append(divname)
		style  = ""
		style += common.emit_line("#%s {" % divname )
		style += common.emit_line(" top:0px;")
		style += common.emit_line(" left:0px;")
		if dopage==1:
			style += common.emit_line(" visibility:inherit;")
		else:
			style += common.emit_line(" visibility:inherit;")
		style += common.emit_line("}")
		tot_style += style
		tot_content  += common.emit_line("<div id=%s >" % divname)
	
		# Accumulate the scriptlet to turn each slide item on/off for this page...
		tot_onscrl = "document.getElementById('%s').style.visibility='visible';" % divname
		tot_offscrl = "document.getElementById('%s').style.visibility='hidden';" % divname
		cp_init = ""
	
		pagedef = item_def[str(dopage)]
		for page_item in pagedef:
			page_asset_name = page_item["asset_name"]
		
			print "SLIDE SHOW name=%s page=%d asset_name=%s" % (asset_name, dopage, page_asset_name )
	
			if ( page_asset_name.startswith("img") ):

				# determine script, ahref, if any...
				script = None
				ahref = None
				exturl = None
				if page_item.has_key("link") and page_item["link"]!="":
					link = page_item["link"]
					if link.startswith("page"):
						ltype,parm = link.split(":")
						funcname = "func_%s_%s" % ( asset_name, parm )
						test = action_scripts[funcname]
						script = "%s ();" % funcname
					elif link.startswith("url"):
						idx = link.find(":")+1
						url = link[idx:]
						ahref = url
		                        elif link.startswith("nurl:"):
                                        	idx = link.find(":") + 1
                                        	ahref = link[idx:]
                                        	exturl = True
					else:
						print "ERROR: gen_slide_show: unknown link type", ltype
						sys.exit(1)

				# determine init vis, if any...
                        	init_vis = None
                        	if page_item.has_key("init") and page_item["init"]!="":
                                	init_vis = page_item["init"]
	
				style, content, top_script, scriptlet_dct = gen_images.expand_item( \
					accum_ids, page_item, images_dct, script, init_vis, ahref, exturl )
				tot_style += style
				tot_content += content
				tot_top_script += top_script
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]

			elif page_asset_name.startswith("cp"):
	
                        	print "GEN SLIDE SHOW - CALLING GEN CLICK PANEL", page_asset_name, page_item, "cp->", str(click_panels_dct.keys()), \
					len(click_panels_dct.keys()), len(cpo_dct.keys())
                        	style, content, top_script, scriptlet_dct  = \
					gen_click_panels.expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct, click_panels_dct, cpo_dct )
			
				print "cp on->", scriptlet_dct['on']
	
				tot_style += style
				tot_content += content
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]
				tot_top_script += top_script
			
				# total hack...
				if page_asset_name == "cp_char_dev_1":
					cp_init += "cpo1_11_desel_click();"
				else:
					cp_init += "cpo2_11_desel_click();"

			elif ( page_asset_name.startswith("mp") ):
				
				style, content,scriptlet_dct = gen_movie_panels.expand_item( accum_ids, page_item, images_dct, \
					movies_dct, movie_panels_dct )
				tot_style += style
				tot_content += content
				tot_onscrl += scriptlet_dct["on"]
				tot_offscrl += scriptlet_dct["off"]
			
			#elif ( page_asset_name.startswith("ss") ):
			#style, content = gen_slide_show.expand_item( accum_ids, page_item, images_dct, movies_dct, movie_panels_dct ) 
			#tot_style += style
			#tot_content += content

			else:
				print "ERROR: gen_slide_shows: Cannot process->", page_item
				sys.exit(1)

		tot_content  += common.emit_line("</div>")

		# deal with action scripts for this page...
        	funcname = "func_%s_%d" % ( asset_name, dopage )
		#THISISHERE !action_scripts[funcname] = tot_onscrl
		action_scripts[funcname] = tot_offscrl + tot_onscrl + cp_init
		
		all_on += tot_onscrl
		all_off+= tot_offscrl

		# the init script is first page...
		if init_script == False:
			init_script = "%s ();" % funcname 

		dopage += 1

	# end parent div...
	tot_content += common.emit_line("</div>")

	# accumulate the scriptlet dct for this control...
	scriptlet_dct = {}
	scriptlet_dct['on'] = all_off + init_script
	scriptlet_dct['off'] = all_off

	# we do this in query respond func below...
	#scriptlet_dct['init'] = all_off + init_script;
	default_init = all_off + init_script

	# finalize the global action script dct for this control...
	# create an all off...
        funcname = "func_%s_off " % ( asset_name )
        action_scripts[funcname] = all_off

	# add to header scripts...	
	for item in action_scripts.keys():
		#funcdef = "function %s () { %s; }" % (item, "alert('s');" + all_off + action_scripts[item] + "alert('e');")
		funcdef = "function %s () { %s; }" % (item, all_off + action_scripts[item] )
		tot_top_script += "\n\n" + funcdef

	# create an if else ladder to query param responder...
	ifelse = ""
	for item in action_scripts.keys():
		if not action_dct.has_key(item): continue
		pg = action_dct[item]
		ifelse += \
			"var opt = keyValuePair[1];\n" + \
			"if ( opt == '%s' )\n" % pg + \
			"{\n" + \
				" %s();\n" % item + \
			"}\n" 
	detect_query_func = \
		"function %s_respond()\n{\n" % asset_name + \
		"var querystring = unescape(location.search);\n" + \
		"if (querystring)\n" + \
		"{\n" + \
        		"querystring = querystring.substring(1);\n" + \
        		"var pairs = querystring.split('&');\n" + \
        		"if ( pairs.length>0 )\n" + \
        		"{\n" + \
                		"var keyValuePair = pairs[0].split('=');\n" + \
                		"if (( keyValuePair[0]=='page'))\n" + \
				"{\n" + \
                        		ifelse + \
				"}\n" + \
			"}\n" + \
		"}\n" + \
		"else\n" + \
		"{\n" + \
			default_init + \
		"}\n" + \
		"}"
	tot_top_script += detect_query_func

	scriptlet_dct['init'] = "%s_respond();" % asset_name

        return [ tot_style, tot_content, tot_top_script, scriptlet_dct ]
예제 #2
0
def gen_page( accum_ids, page_name, page_def, movies_dct, images_dct, menus_dct, movie_panels_dct, click_panels_dct, slide_shows_dct, embeds_dct, cpo_dct ):
	
	print "MAIN - GEN PAGE ITEMS->", page_def, [ a["asset_name"] for a in page_def ]

	accum_body = ""
	accum_style = ""
	accum_top_script = ""
	accum_load_script = ""

	# create a master subpage div...
	#accum_body += "<div id=\"dmaster\" style=\"visibility:hidden;\" >"

	for item in page_def:

		scriptlet_dct = {}
		top_script = ""
		style = ""
		content = ""

		asset_name = item["asset_name"]

		if asset_name.startswith("mov"):

			print "MAIN - CALLING GEN MOV", asset_name, item
			style, content, scriptlet_dct = gen_movies.expand_item( accum_ids, item, images_dct, movies_dct )

		elif asset_name.startswith("img"):
			
			print "MAIN - CALLING GEN IMG", asset_name, item

                        # determine the script, if any...
                        script = None
                        ahref = None
			exturl = False
                        if item.has_key("link") and item["link"]!="":
                                link = item["link"]
                                if link.startswith("option:"):
                                        ltype,parm = link.split(":")
                                        funcname = "func_%s_%s" % (menu_name, parm)
                                        test = action_scripts[funcname]
                                        script = "%s ();" % funcname
                                elif link.startswith("url:"):
                                        idx = link.find(":") + 1
                                        ahref = link[idx:]
				elif link.startswith("nurl:"):
					idx = link.find(":") + 1
					ahref = link[idx:]
					exturl = True
                                elif link.startswith("mss"):
                                        idx = link.find(":") + 1
                                        page_name = gen_multipage_slideshow.get_link( item, is_dct,"first")
                                        print "PAGEN->", page_name
                                        ahref = page_name
                                else:
                                        print "ERROR: gen_menus: Unknown link type", asset_name, item
                                        sys.exit(1)

			style, content, top_script, scriptlet_dct = gen_images.expand_item( accum_ids, item, images_dct, script, None, \
				ahref, exturl )
 
		elif asset_name.startswith("embed"):

			print "MAIN - CALLING GEN EMBED", asset_name, item
			style, content, top_script, scriptlet_dct = gen_embeds.expand_item( accum_ids, item, embeds_dct )

		elif asset_name.startswith("menu"):

			print "MAIN - CALLING GEN MENUS EXPAND", asset_name, item
			style, content, top_script, scriptlet_dct  = gen_menus.expand_item( accum_ids, item, images_dct, menus_dct, \
				slide_shows_dct, movies_dct, movie_panels_dct, image_sets_dct, click_panels_dct, cpo_dct )
 
		elif asset_name.startswith("cp"):

			print "MAIN - CALLING GEN CLICK PANEL", asset_name, item, len(click_panels_dct.keys()), len(cpo_dct.keys())
			style, content, top_script, scriptlet_dct  = gen_click_panels.expand_item( accum_ids, item, images_dct, \
				movies_dct, movie_panels_dct, click_panels_dct, cpo_dct )

			print "CP SCRIPTLET INIT->", scriptlet_dct['init']

		elif asset_name.startswith("ss"):

			print "MAIN - CALLING GEN SS", asset_name, item
			style, content, top_script, scriptlet_dct = \
				gen_slide_shows.expand_item( accum_ids, item, images_dct, movies_dct, movie_panels_dct, \
				click_panels_dct, slide_shows_dct, cpo_dct )

			print "SS SCRIPTLET INIT->",scriptlet_dct['init']
		else:

			print "ERROR: gen_page: Unknown asset type->", asset_name
			sys.exit(1)

		accum_style += style
		accum_body += content
		accum_top_script += top_script
		accum_load_script += scriptlet_dct["init"]

        #accum_body += "</div>"

	return accum_style, accum_body, accum_top_script, accum_load_script