Ejemplo n.º 1
0
        protected function do_render()
        {
            ?>
			<script type="text/javascript">
				NelioABHomeUrl = "<?php 
            echo home_url();
            ?>
";
			</script>
			<form id="<?php 
            echo $this->get_form_name();
            ?>
" method="post" class="nelio-exp-form">
				<input type="hidden" name="nelioab_save_exp_post" value="true" />
				<input type="hidden" name="<?php 
            echo $this->get_form_name();
            ?>
" value="true" />
				<input type="hidden" name="exp_id" id="exp_id" value="<?php 
            echo $this->basic_info['id'];
            ?>
" />
				<input type="hidden" name="nelioab_exp_type" value="<?php 
            echo $this->get_alt_exp_type();
            ?>
" />
				<input type="hidden" name="content_to_edit" id="content_to_edit" />
				<input type="hidden" name="other_names" id="other_names" value="<?php 
            $aux = $this->basic_info;
            echo rawurlencode(json_encode($aux['otherNames']));
            ?>
" />
				<input type="hidden" name="action" id="action" value="none" />

				<script type="text/javascript">var nelioabBasicInfo = <?php 
            echo json_encode($this->basic_info);
            ?>
;</script>

				<input type="hidden" name="nelioab_alternatives" id="nelioab_alternatives" value="<?php 
            echo rawurlencode(json_encode($this->alternatives));
            ?>
" />

				<input type="hidden" name="nelioab_goals" id="nelioab_goals" value="<?php 
            echo rawurlencode(json_encode($this->goals));
            ?>
" />

				<h3 id="exp-tabs" class="nav-tab-wrapper" style="margin:0em;padding:0em;padding-left:2em;margin-bottom:2em;"><?php 
            $active = ' nav-tab-active';
            foreach ($this->tabs as $tab) {
                printf('<span id="tab-%1$s" class="nav-tab%3$s">%2$s</span>', $tab['id'], $tab['name'], $active);
                $active = '';
            }
            ?>
</h3>

				<div>
					<div id="set-of-content-blocks"><?php 
            $invisible = '';
            foreach ($this->tabs as $tab) {
                printf('<div id="content-%s" style="%s" class="alt-exp-content-block">', $tab['id'], $invisible);
                call_user_func($tab['callback']);
                echo '</div>';
                $invisible = 'display:none;';
            }
            ?>
					</div>

					<div id="controllers" style="height:4em;">
						<a href="javascript:;" class="button previous" style="float:left;"><?php 
            _e('Previous', 'nelioab');
            ?>
</a>
						<a href="javascript:;" class="button next" style="float:right;"><?php 
            _e('Next', 'nelioab');
            ?>
</a>
						<a href="javascript:;" class="button button-primary save" style="float:right;display:none;"><?php 
            $this->get_save_experiment_name();
            ?>
</a>
					</div>
				</div>
				<?php 
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            NelioABHtmlGenerator::print_unsaved_changes_control('#controllers .button-primary.save, .row-actions .edit-content');
            ?>
				<script type="text/javascript">
					<?php 
            $this->print_params_for_required_scripts();
            ?>
					(function() {
						// Prepare the scripts
						var scripts = [];
						<?php 
            foreach ($this->get_required_scripts() as $script) {
                ?>
							scripts.push('<?php 
                echo $script;
                ?>
');
						<?php 
            }
            ?>

						// Prepare a function for setting up the alternatives table
						var setupAlternativesTable = function() {
							<?php 
            $this->print_code_for_setup_alternative_table();
            ?>
							NelioABEditExperiment.useTab(jQuery('#exp-tabs .nav-tab-active').attr('id'));
						};

						// Load scripts one by one and, once they're ready, prepare the table
						var loadScript = function( current ) {
							if ( current == scripts.length ) {
								setupAlternativesTable();
							}
							else {
								jQuery.getScript(scripts[current], function() {
									++current;
									loadScript( current );
								});
							}
						};
						loadScript( 0 );
					})();
				</script>
			</form>

			<?php 
        }
        protected function do_render()
        {
            ?>
			<form class="nelio-exp-form" id="<?php 
            echo $this->get_form_name();
            ?>
" method="post" style="max-width:750px;">
				<input type="hidden" name="nelioab_save_exp_post" value="true" />
				<input type="hidden" name="<?php 
            echo $this->get_form_name();
            ?>
" value="true" />
				<input type="hidden" name="nelioab_exp_type" value="<?php 
            echo NelioABExperiment::HEATMAP_EXP;
            ?>
" />
				<input type="hidden" name="action" id="action" value="none" />
				<input type="hidden" name="exp_id" id="exp_id" value="<?php 
            echo $this->basic_info['id'];
            ?>
" />
				<input type="hidden" name="other_names" id="other_names" value="<?php 
            echo rawurlencode(json_encode($this->other_names));
            ?>
" />
				<?php 
            $this->make_section(__('Basic Information', 'nelioab'), $this->get_basic_info_elements(), '<label class="mandatory">Required field</label>');
            ?>
			</form>
			<?php 
            $this->print_validator_js();
            require_once NELIOAB_UTILS_DIR . '/html-generator.php';
            NelioABHtmlGenerator::print_unsaved_changes_control('.actions .nelioab-js-button');
        }