Exemple #1
0
    /**
     * Display navigation
     */
    protected function displayNavigation()
    {
        $Code = '<div id="ajax-navigation" class="panel">';
        $Code .= '<div class="panel-heading">';
        $Code .= '<h1>' . __('Multi editor') . '</h1>';
        $Code .= '</div>';
        $Code .= '<div class="panel-content">';
        $Code .= '<table class="multi-edit-table fullwidth zebra-style"><tbody>';
        foreach (self::$IDs as $i => $ID) {
            $Preview = new Preview(new Activity\Object($this->fetchActivity($ID)));
            $Code .= '<tr id="multi-edit-' . $ID . '" class="link ' . ($i == 0 ? ' highlight' : '') . ' show-on-hover-parent">';
            $Code .= '<td class="multi-edit-sport-icon c"><span class="link show-on-hover multi-edit-remove-link">' . Icon::$CROSS_SMALL . '</span>' . $Preview->sportIcon() . '</td>';
            $Code .= '<td>' . $Preview->dateAndSmallTime() . '<br><small>' . $Preview->durationAndDistance() . '</small></td>';
            $Code .= '<td class="multi-edit-icon">' . $Preview->hrIcon() . '</td>';
            $Code .= '<td class="multi-edit-icon">' . $Preview->splitsIcon() . '</td>';
            $Code .= '<td class="multi-edit-icon">' . $Preview->mapIcon() . '</td>';
            $Code .= '</tr>';
        }
        $Code .= '</tbody></table>';
        $Code .= '</div>';
        $Code .= '</div>';
        echo Ajax::wrapJS('$(\'#ajax-navigation\').remove();$(\'#ajax-outer\').append(\'' . $Code . '\')');
        echo Ajax::wrapJSasFunction('$("#ajax-navigation tr.link").click(function(e){
	$("#ajax-navigation tr.link.highlight").removeClass("highlight").addClass("edited");
	$(this).removeClass("edited").addClass("highlight");
	Runalyze.Overlay.load( "' . Linker::EDITOR_URL . '?mode=multi&id=" + $(this).attr("id").substr(11) );
});');
        echo Ajax::wrapJSasFunction('$("#ajax-navigation .multi-edit-remove-link").click(function(e){
	$(this).parent().parent().remove();
	e.stopPropagation();
});');
    }
 /**
  * Display formular
  */
 protected function displayFormular()
 {
     $this->Formular->display();
     echo Ajax::wrapJSasFunction('$(\'#prognosis-calculator .hide-on-model-change:not(.only-' . $_POST['model'] . ')\').closest(\'div\').hide();');
 }
    /**
     * Display uploader 
     */
    protected function displayImportUploader()
    {
        $JScode = '
			new qq.FineUploaderBasic({
				button: $("#file-upload")[0],
				request: {
					endpoint: \'' . $_SERVER['SCRIPT_NAME'] . '?hideHtmlHeader=true&id=' . $this->id() . '&json=true\'
				},
				callbacks: {
					onError: function(id, name, errorReason, xhr) {
						$("#upload-container").append(\'<p class="error appended-by-uploader">\'+errorReason+\'</p>\').removeClass("loading");
					},
					onSubmit: function(id, fileName) {
						$("#upload-container").addClass("loading");
					},
					onComplete: function(id, fileName, responseJSON) {
						$(".appended-by-uploader").remove();
						$("#pluginTool").loadDiv(\'' . $_SERVER['SCRIPT_NAME'] . '?id=' . $this->id() . '&file=\'+encodeURIComponent(fileName));

						if (!responseJSON.success) {
							if (responseJSON.error == "")
								responseJSON.error = \'An unknown error occured.\';
							$("#pluginTool").append(\'<p class="error appended-by-uploader">\'+fileName+\': \'+responseJSON.error+\'</p>\');
							$("#upload-container").removeClass("loading");
						}
					}
				}
			});';
        $Text = '<div id="upload-container" style="margin-bottom:5px;"><div class="c button" id="file-upload">' . __('Upload file') . '</div></div>';
        $Text .= Ajax::wrapJSasFunction($JScode);
        $Text .= HTML::info(__('Allowed file extension: *.json.gz'));
        $Text .= HTML::warning(__('All shared links will be invalid if you (re-)import activities and overwrite all existing activities!'));
        $Text .= HTML::warning(__('The file has to be created with the same version of Runalyze!<br>' . 'You won\'t be able to import a file from an older version.'));
        $Text .= HTML::warning(__('The importer will not change existing data for equipment, sport types or activity types.<br>' . 'You have to make these changes by hand or delete the existing data in advance.'));
        $Fieldset = new FormularFieldset(__('Import data'));
        $Fieldset->setCollapsed();
        $Fieldset->addBlock($Text);
        $Formular = new Formular();
        $Formular->setId('backup-import');
        $Formular->addFieldset($Fieldset);
        $Formular->display();
    }
 /**
  * @return string
  */
 protected function getJS()
 {
     return Ajax::wrapJSasFunction('$("input.delete-checkbox").change(function(){$(this).parent().parent().toggleClass("ERROR unimportant")});');
 }
echo Icon::$REFRESH;
?>
</span>
		</small>

<?php 
if (!$this->visible) {
    ?>
		<div id="iframe-spacer" style="width:490px;height:310px;">
			<em><?php 
    _e('Move your mouse here to start loading the communicator.');
    ?>
</em>
		</div>
<?php 
    echo Ajax::wrapJSasFunction('$("#iframe-spacer").hover(function(){
			$(\'<iframe src="call/call.garminCommunicator.php" id="GCapi" name="GCapi" width="490px" height="310px"></iframe>\').insertAfter($("#iframe-spacer"));
			$("#iframe-spacer").remove();
		});');
} else {
    ?>
		<iframe src="call/call.garminCommunicator.php" id="GCapi" name="GCapi" width="490px" height="310px"></iframe>
<?php 
}
?>
	</div>
<p class="info"><?php 
printf(__('Due to security reasons browser manufacturers will drop support for plugins like the Garmin Communicator. A <a href="%s">reinstall</a> may work, but we have documented an alternative way to import the original files at %s. '), 'http://help.runalyze.com/en/latest/knowledge-base.html#get-the-garmin-communicator-running-in-firefox-version-43', '<a href="http://help.runalyze.com/en/latest/starting-guide/import.html#garmin">help.runalyze.com</a>');
?>
</p>