Commit 8c65c976 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

View preview on copy view page

parent 71bd99e7
......@@ -268,5 +268,6 @@ $string['listviews'] = 'List Views';
$string['nocopyableviewsfound'] = 'No Views that you can copy';
$string['noownersfound'] = 'No owners found';
$string['displayingviewsby'] = 'Displaying Views by %s';
$string['closepreview'] = 'Close Preview';
?>
......@@ -1579,7 +1579,24 @@ button#dosearch {
text-align: center;
margin-top: 10px;
}
#viewpreview {
position: absolute;
border: 10px solid #eee;
background-color: #fff;
}
#viewpreviewinner {
border: 1px solid #ccc;
padding: 5px;
}
#viewpreviewclose {
width: 100%;
text-align: center;
border-bottom: 1px solid #ccc;
padding-bottom: 5px;
}
#viewpreviewcontent {
margin-top: 5px;
}
/* MY PORTFOLIO > MY FILES */
#uploader {
......
......@@ -12,7 +12,7 @@
{foreach from=$results item=row}
<tr class="r{cycle values=0,1}">
<td>
<a href="{$WWWROOT}view/view.php?id={$row.id|escape}" target="_blank">{$row.title|escape}</a>
<a class="viewlink" href="{$WWWROOT}view/view.php?id={$row.id|escape}" target="_blank">{$row.title|escape}</a>
</td>
<td>
{$row.sharedby|escape}
......
<h2>{$viewtitle}{if $ownername} {str tag=by section=view} {$ownername}{/if}</h2>
<p class="view-description">{$viewdescription}</p>
<div id="view" class="cb">
<div id="bottom-pane">
<div id="column-container">
{$viewcontent}
<div class="cb">
</div>
</div>
</div>
</div>
......@@ -61,7 +61,9 @@ if (!($group || $institution)) {
}
View::get_templatesearch_data($views);
$strclose = json_encode(get_string('closepreview','view'));
$js = <<<EOF
preview = DIV({'id':'viewpreview', 'class':'hidden'}, DIV({'id':'viewpreviewinner'}, DIV({'id':'viewpreviewclose'}, A({'href':'','id':'closepreview'}, {$strclose})), DIV({'id':'viewpreviewcontent'})));
ownerlist = new SearchTable('viewownersearch');
templatelist = new SearchTable('templatesearch');
addLoadEvent(function() {
......@@ -82,10 +84,37 @@ addLoadEvent(function() {
});
};
ownerlist.rewriteOther();
templatelist.rewriteOther = function () {
forEach(getElementsByTagAndClassName('a', 'viewlink', 'templatesearch'), function(i) {
disconnectAll(i);
connect(i, 'onclick', function (e) {
e.stop();
var href = getNodeAttribute(this, 'href');
var params = parseQueryString(href.substring(href.indexOf('?')+1, href.length));
sendjsonrequest('viewcontent.json.php', params, 'POST', function(data) {
$('viewpreviewcontent').innerHTML = data.html;
var vdim = getViewportDimensions();
var vpos = getViewportPosition();
var offset = 16; // Left border & padding of preview container elements (@todo: use getStyle()?)
setElementDimensions(preview, {'w':vdim.w - 200});
setElementPosition(preview, {'x':vpos.x+100-offset, 'y':vpos.y+200});
showElement(preview);
});
});
});
};
templatelist.rewriteOther();
appendChildNodes(getFirstElementByTagAndClassName('body'), preview);
connect('closepreview', 'onclick', function (e) {e.stop(); fade(preview, {'duration':0.2});});
});
EOF;
$smarty = smarty(array('searchtable'));
$smarty = smarty(
array('searchtable'),
array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">'),
array(),
array('stylesheets' => array('style/views.css'))
);
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('heading', TITLE);
$smarty->assign('owners', $owners);
......
<?php
/**
* Mahara: Electronic portfolio, weblog, resume builder and social networking
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package mahara
* @subpackage core
* @author Catalyst IT Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('JSON', 1);
require(dirname(dirname(__FILE__)) . '/init.php');
require_once(get_config('libroot') . 'view.php');
$id = param_integer('id');
if (!can_view_view($id)) {
json_reply('local', get_string('accessdenied', 'error'));
}
$view = new View($id);
$smarty = smarty_core();
$smarty->assign('viewtitle', $view->get('title'));
$smarty->assign('ownername', $view->formatted_owner());
$smarty->assign('viewdescription', $view->get('description'));
$smarty->assign('viewcontent', $view->build_columns());
ob_start();
$smarty->display('view/viewcontent.tpl');
$html = ob_get_contents();
ob_end_clean();
json_reply(false, array(
'message' => null,
'html' => $html,
));
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment