Commit 745679ea authored by Richard Mansfield's avatar Richard Mansfield Committed by Gerrit Code Review
Browse files

Merge changes I7a5e6448,Ie1ba5cb8

* changes:
  Remove plans block javascript from template (bug #1002168)
  Use get_all_blocktype_javascript in 5 files:
parents fc289843 f4cc34f0
......@@ -16,3 +16,13 @@ function TaskPager(blockid) {
paginatorProxy.addObserver(self);
connect(self, 'pagechanged', partial(rewriteTaskTitles, blockid));
}
var taskPagers = [];
function initNewPlansBlock(blockid) {
if ($('plans_page_container_' + blockid)) {
new Paginator('block' + blockid + '_pagination', 'tasktable_' + blockid, 'artefact/plans/viewtasks.json.php', null);
taskPagers.push(new TaskPager(blockid));
}
rewriteTaskTitles(blockid);
}
......@@ -59,7 +59,7 @@ class PluginBlocktypePlans extends PluginBlocktype {
return array(
array(
'file' => 'js/plansblock.js',
'initjs' => "rewriteTaskTitles($blockid);",
'initjs' => "initNewPlansBlock($blockid);",
)
);
}
......
......@@ -14,20 +14,8 @@
</tbody>
</table>
{if $tasks.pagination}
<div id="plans_page_container_{$blockid}" class="hidden">{$tasks.pagination|safe}</div>
<div id="plans_page_container_{$blockid}" class="nojs-hidden-block">{$tasks.pagination|safe}</div>
{/if}
{if $tasks.pagination_js}
<script>
{literal}
addLoadEvent(function() {{/literal}
{$tasks.pagination_js|safe}
removeElementClass('plans_page_container_{$blockid}', 'hidden');
{literal}}{/literal});
var taskPager_{$blockid} = new TaskPager({$blockid});
addLoadEvent(partial(rewriteTaskTitles, {$blockid}));
</script>
{/if} {* pagination_js *}
{else}
<p>{str tag='notasks' section='artefact.plans'}</p>
{/if}
......
......@@ -88,7 +88,9 @@ if ($group->public) {
}
$javascript = array('paginator');
$javascript = array_merge($javascript, $view->get_blocktype_javascript());
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$smarty = smarty(
$javascript,
......@@ -96,6 +98,7 @@ $smarty = smarty(
array(),
array('stylesheets' => array('style/views.css'))
);
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('viewid', $view->get('id'));
$smarty->assign('viewcontent', $viewcontent);
$smarty->assign('group', $group);
......
......@@ -48,7 +48,9 @@ if ($USER->is_logged_in()) {
$view = $USER->get_view_by_type('dashboard');
$javascript = array('paginator');
$javascript = array_merge($javascript, $view->get_blocktype_javascript());
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$stylesheets = array('<link rel="stylesheet" type="text/css" href="' . get_config('wwwroot') . 'theme/views.css">');
$smarty = smarty(
$javascript,
......@@ -80,7 +82,7 @@ addLoadEvent(function () {
});
JAVASCRIPT;
$smarty->assign('INLINEJAVASCRIPT', $js);
$smarty->assign('INLINEJAVASCRIPT', $js . $inlinejs);
}
$smarty->assign('dashboardview', true);
......
......@@ -92,7 +92,9 @@ if (!$restrictedview) {
}
$javascript = array('paginator', 'lib/pieforms/static/core/pieforms.js', 'artefact/resume/resumeshowhide.js');
$javascript = array_merge($javascript, $view->get_blocktype_javascript());
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
// Set up theme
$viewtheme = $view->get('theme');
......@@ -261,6 +263,8 @@ if ($userid != $USER->get('id') && $USER->is_admin_for_user($user) && is_null($U
}
$smarty->assign('loginas', $loginas);
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$smarty->assign('institutions', get_institution_string_for_user($userid));
$smarty->assign('canmessage', $loggedinid != $userid && can_send_message($loggedinid, $userid));
$smarty->assign('USERID', $userid);
......
......@@ -148,7 +148,9 @@ if ($viewtheme && !isset($allowedthemes[$viewtheme])) {
}
$javascript = array('views', 'tinymce', 'paginator', 'tablerenderer', 'artefact/file/js/filebrowser.js', 'lib/pieforms/static/core/pieforms.js');
$javascript = array_merge($javascript, $view->get_blocktype_javascript());
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$smarty = smarty($javascript, $stylesheets, false, $extraconfig);
......@@ -192,8 +194,9 @@ $smarty->assign('new', $new);
$smarty->assign('profile', $profile);
$smarty->assign('dashboard', $dashboard);
if (get_config('blockeditormaxwidth')) {
$smarty->assign('INLINEJAVASCRIPT', 'config.blockeditormaxwidth = true;');
$inlinejs .= 'config.blockeditormaxwidth = true;';
}
$smarty->assign('INLINEJAVASCRIPT', $inlinejs);
$viewtype = $view->get('type');
$viewtitle = $view->get('title');
$owner = $view->get('owner');
......
......@@ -173,7 +173,9 @@ function releaseview_submit() {
}
$javascript = array('paginator', 'viewmenu', 'artefact/resume/resumeshowhide.js');
$javascript = array_merge($javascript, $view->get_blocktype_javascript());
$blocktype_js = $view->get_all_blocktype_javascript();
$javascript = array_merge($javascript, $blocktype_js['jsfiles']);
$inlinejs = "addLoadEvent( function() {\n" . join("\n", $blocktype_js['initjs']) . "\n});";
$extrastylesheets = array('style/views.css');
......@@ -249,7 +251,7 @@ if ($collection) {
}
}
$smarty->assign('INLINEJAVASCRIPT', $javascript);
$smarty->assign('INLINEJAVASCRIPT', $javascript . $inlinejs);
$smarty->assign('new', $new);
$smarty->assign('viewid', $viewid);
$smarty->assign('viewtype', $viewtype);
......
Supports Markdown
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