/* _________________________________________________________________________________________________ pz.widgetcodeconfigurator _________________________________________________________________________________________________ version 0.01 _________________________________________________________________________________________________ */ jQuery.fn.pzWidgetCodeConfigurator = function(oSettings) { return this.each( function() { if(oSettings==undefined) oSettings={}; var _this = jQuery(this); var _minHeight = oSettings._minHeight || 1; var _popupWidth = 500; var _embedHeight = 0; var _isChatDisabled = "false"; var _linkHorizontalLayout = $('a.horizontalLayout', _this); var _linkVerticalLayout = $('a.verticalLayout', _this); var _inputHeight = $('input.inputHeight', _this); if(parseInt(_inputHeight.val()) < _minHeight) _inputHeight.val(_minHeight); var _inputBgColor = $('input.inputBgColor', _this); var _textEmbedCode = $('textarea.textEmbedCode', _this); var _inputExternalID = $('input.inputExternalID', _this); var _inputMajorReleaseIDPublicReceiver = $('input.inputMajorReleaseIDPublicReceiver', _this); var _inputMajorReleaseIDPrivate = $('input.inputMajorReleaseIDPrivate', _this); var _inputWidgetLayout = $('input.inputWidgetLayout', _this); var _btnPreview = $('a.btnPreview', _this); var _checkboxShowPublicChat = $('input.showPublicChat', _this); validate(); _linkVerticalLayout.click(function(){ _inputWidgetLayout.val("vertical"); validate(); return false; }); _linkHorizontalLayout.click(function(){ _inputWidgetLayout.val("horizontal"); validate(); return false; }); _inputHeight.change(function(){ /* check minheight (if empty / if height < minheight) check here, not in validate-fn!! */ if(_inputHeight.val()=='') _inputHeight.val(_minHeight); if(parseInt(_inputHeight.val())<_minHeight) _inputHeight.val(_minHeight); validate(); }); _inputHeight.keyup(function(){ validate(); }); _inputBgColor.change(function(){ validate(); }); _textEmbedCode.mousedown(function(){ validate(); }); _textEmbedCode.click(function(){ _textEmbedCode.focus(); _textEmbedCode.select(); }); _checkboxShowPublicChat.change(function(){ validate(); }); _btnPreview.click(function(){ var _windowParams = 'width='+_popupWidth+',height='+_embedHeight+',left=0,top=0'; var _widgetPreviewWindow = window.open('','widgetPreviewWindow', _windowParams); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln('peoplezapping.com | Preview Widget'); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln(getEmbedCode()); _widgetPreviewWindow.document.writeln(''); _widgetPreviewWindow.document.writeln(''); }); function getEmbedCode(){ /* get height of each module */ var publicModuleHeight = _embedHeight; var privateModuleHeight = _embedHeight; //if(_alignment == "vertical"){ if(_inputWidgetLayout.val()=="vertical"){ publicModuleHeight = Math.floor((_embedHeight-5)/2); privateModuleHeight = (_embedHeight-5)-publicModuleHeight; } /* get bgColor */ var bgColor = _inputBgColor.val(); var _flashvar = ''; /* build embed code */ //var ln = '\n'; var ln = ' '; var sourcePublicReceiverSWF = 'http://www.peoplezapping.com/?cmd=_getPZModule&p=6f403e015d6348f54b9d108887f5efd1079ce07d&extPlaceID='+_inputExternalID.val()+'&isChatDisabled='+_isChatDisabled+'&bgColor=0x'+bgColor; var codePublicModule=''+ln +''+ln +_flashvar+ln +''+ln +''+ln +''+ln +''+ln +''+ln +''+ln +''; var sourcePrivateSWF = 'http://www.peoplezapping.com/?cmd=_getPZModule&p=86f801a389789e712b02b443361145467bbb1f16&extPlaceID='+_inputExternalID.val()+'&bgColor=0x'+bgColor; var codePrivateModule=''+ln +''+ln +''+ln +''+ln +''+ln +''+ln +''+ln +''+ln +''; var code=''; if(_inputWidgetLayout.val()=="vertical"){ code = '' +'' +'' +'' +'' +'' +'' +'' +'' +'' +'
' + codePublicModule +'
' +'
 
' +'
' + codePrivateModule +'
'; }else{ code = '' +'' +'' +'' +'' +'' +'
' + codePublicModule +'' +'
 
' +'
' + codePrivateModule +'
'; } return code; } function validate(){ /* check bgcolor */ if(_inputBgColor.val()=='') _inputBgColor.val('ffffff'); /* first remove 'act' from links */ _linkHorizontalLayout.removeClass('act'); _linkVerticalLayout.removeClass('act'); /* add 'act' (optional) to link */ if(_inputWidgetLayout.val()=="vertical"){ _linkVerticalLayout.addClass('act'); }else{ _linkHorizontalLayout.addClass('act'); } /* set member _embedHeight */ _embedHeight = parseInt(_inputHeight.val()); /* insert embed code */ _textEmbedCode.val(getEmbedCode()); /* set isChatDisabled */ if(_checkboxShowPublicChat.val()) { if(_checkboxShowPublicChat.attr('checked')) { _isChatDisabled = "false"; } else { _isChatDisabled = "true"; } } } } ) };