Commit 507a9061 authored by Richard Mansfield's avatar Richard Mansfield
Browse files
parents e648e2a3 510243e7
......@@ -43,7 +43,8 @@ MochiKit.MochiKit.SUBMODULES = [
"Color",
"Signal",
"Position",
"Visual"
"Visual",
"DragAndDrop"
];
if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') {
......
......@@ -36,14 +36,27 @@ if (typeof(MochiKit.Selector) == 'undefined') {
}
MochiKit.Selector.NAME = "MochiKit.Selector";
MochiKit.Selector.VERSION = "1.4";
MochiKit.Selector.__repr__ = function () {
return "[" + this.NAME + " " + this.VERSION + "]";
};
MochiKit.Selector.toString = function () {
return this.__repr__();
};
MochiKit.Selector.EXPORT = [
"Selector",
"findChildElements",
"findDocElements",
"$$"
];
MochiKit.Selector.EXPORT_OK = [
];
MochiKit.Selector.Selector = function (expression) {
this.params = {classNames: [], pseudoClassNames: []};
this.expression = expression.toString().replace(/(^\s+|\s+$)/g, '');
......@@ -69,6 +82,7 @@ MochiKit.Selector.Selector.prototype = {
abort('empty expression');
}
var repr = MochiKit.Base.repr;
var params = this.params;
var expr = this.expression;
var match, modifier, clause, rest;
......@@ -113,6 +127,7 @@ MochiKit.Selector.Selector.prototype = {
/** @id MochiKit.Selector.Selector.prototype.buildMatchExpression */
buildMatchExpression: function () {
var repr = MochiKit.Base.repr;
var params = this.params;
var conditions = [];
var clause, i;
......@@ -390,11 +405,27 @@ MochiKit.Base.update(MochiKit.Selector, {
}
}, expression.replace(/(^\s+|\s+$)/g, '').split(/\s+/), [null]);
}, expressions));
}
},
findDocElements: function () {
return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments);
},
__new__: function () {
var m = MochiKit.Base;
this.$$ = this.findDocElements;
this.EXPORT_TAGS = {
":common": this.EXPORT,
":all": m.concat(this.EXPORT, this.EXPORT_OK)
};
m.nameFunctions(this);
}
});
function $$() {
return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments);
}
MochiKit.Selector.__new__();
MochiKit.Base._exportSymbols(this, MochiKit.Selector);
......@@ -175,7 +175,7 @@ MochiKit.Base.update(MochiKit.Style, {
var self = MochiKit.Style;
if (o == 1) {
var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|Safari|KHTML/.test(navigator.userAgent));
elem.style[name] = toSet ? 0.999999 : 1.0;
elem.style["opacity"] = toSet ? 0.999999 : 1.0;
if (/MSIE/.test(navigator.userAgent)) {
elem.style['filter'] =
self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '');
......@@ -184,7 +184,7 @@ MochiKit.Base.update(MochiKit.Style, {
if (o < 0.00001) {
o = 0;
}
elem.style[name] = o;
elem.style["opacity"] = o;
if (/MSIE/.test(navigator.userAgent)) {
elem.style['filter'] =
self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + o * 100 + ')';
......
......@@ -254,3 +254,15 @@ function toggleChecked(c) {
return false;
}
function expandDownToViewport(element, width) {
var viewport = getViewportDimensions();
var position = getElementPosition(element);
var newheight = new Dimensions(width, viewport.h - position.y - 2);
if ($('footer')) {
newheight.h -= getElementDimensions('footer').h + 8;
}
setElementDimensions(element, newheight);
}
......@@ -182,18 +182,89 @@ function template_locate($templatename, $fetchdb=true) {
*
* @param array $template a parsed template see {@link template_parse}
* @param mode either TEMPLATE_RENDER_READONLY or TEMPLATE_RENDER_EDITMODE
* @param array
*
* @returns string the html of the rendered template
*/
function template_render($template, $mode) {
$td = $template['parseddata'];
function template_render($template, $mode, $data=array()) {
if (isset($template['parseddata'])) {
$td = $template['parseddata'];
}
else {
$td = $template['cacheddata'];
}
$droplist = array();
$html = '';
foreach ($td as $t) {
if ($t['type'] == 'html') {
echo $t['content'];
$html .= $t['content'];
}
else {
// @todo call something depending on mode
if ($mode == TEMPLATE_RENDER_READONLY) {
$html .= 'READONLY';
}
else {
$t = $t['data'];
if ( isset($t['format']) && $t['format'] == 'label' ) {
$html .= '<input type="hidden" id=>';
}
else {
log_debug($t);
$classes = array('block');
#if ( $t['format'] == '
$droplist[$t['id']] = array('render_full');
// build opening div tag
if (isset($t['width']) && isset($t['height'])) {
$html .= '<div style="width: ' . $t['width'] . 'px;height: ' . $t['height'] . 'px;"';
}
else {
$html .= '<div';
}
$html .= ' id="' . $t['id'] . '"';
$html .= ' class="' . join(' ',$classes) . '"';
$html .= '>';
$html .= '<i>' . get_string('empty_block', 'view') . '</i>';
$html .= '</div>';
}
}
}
}
$droplist = json_encode($droplist);
$spinner_url = json_encode(theme_get_image_path('loading.gif'));
$wwwroot = get_config('wwwroot');
$javascript = <<<EOF
<script type="text/javascript">
var droplist = $droplist;
function blockdrop(element, target) {
replaceChildNodes(target, IMG({ src: {$spinner_url} }));
var d = loadJSONDoc({$wwwroot});
}
addLoadEvent(function () {
for ( id in droplist ) {
new Droppable(id, {
accept: droplist[id],
ondrop: blockdrop,
hoverclass: 'block_targetted',
activeclass: 'block_potential'
});
}
});
</script>
EOF;
return $javascript . $html;
}
?>
/*
* MARTYNS CREATEVIEW WIZARD STYLES
* these can be replaced with something similar that looks less suck
*/
div#tree, div#template {
margin-top: 20px;
}
div#tree {
overflow: auto;
float: left;
width: 400px;
border: thin dashed red;
border-right: thin solid #000;
}
div#template {
overflow: auto;
border: thin dashed red;
float: left;
width: 30%;
}
.render_metadata, .render_full, .render_listitem, .render_children {
cursor: move;
}
div.block {
border: 2px solid transparent;
}
div.block_potential {
border: 2px solid #008800;
}
div.block_targetted {
border: 2px solid #00ff00;
}
/*
* END MARTYNS STYLES FOR CREATEVIEW WIZARD
*/
This diff is collapsed.
div#tree, div#template {
border: thin dotted red;
}
div#tree {
overflow: auto;
float: left;
width: 400px;
}
div#template {
overflow: auto;
float: left;
width: 50%;
}
.render_metadata, .render_full, .render_listitem, .render_children {
cursor: move;
}
......@@ -15,6 +15,7 @@
{foreach from=$HEADERS item=header}{$header}{/foreach}
{/strip}
<link rel="stylesheet" type="text/css" href="{$THEMEURL}style/style.css">
<link rel="stylesheet" type="text/css" href="{$THEMEURL}style/dev.css">
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
</head>
<body>
......@@ -67,4 +68,4 @@
{/if}
{insert name="messages"}
\ No newline at end of file
......@@ -7,39 +7,67 @@ class="cnr-bl"><span class="cnr-br">
<h2>{str tag=createviewstep3}</h2>
<table border="1">
<tr>
<td><div id="tree">Artefact Tree</div></td>
<td>Template
<form action="" method="post">
<input type="submit" name="cancel" value="{str tag=cancel}">
<input type="submit" name="back" value="{str tag=back}">
<input type="submit" name="submit" value="{str tag=next}">
</form>
</td>
</tr>
</table>
{literal}
<style type="text/css">
</style>
{/literal}
<div id="tree">Artefact Tree</div>
<div id="template">
{$template}
<form action="" method="post">
<input type="submit" name="cancel" value="{str tag=cancel}">
<input type="submit" name="back" value="{str tag=back}">
<input type="submit" name="submit" value="{str tag=next}">
</form>
</div>
<script type="text/javascript">
{$rootinfo}
{literal}
function treeItemFormat(data, tree) {
var item = LI({'id': data.id});
if (data.container) {
var toggleLink = SPAN({'id': data.id + '_toggle'}, tree.getExpandLink(item));
appendChildNodes(item, toggleLink, ' ');
}
if (!data.title) {
data.title = '';
}
var title = SPAN({title: data.title}, data.text);
appendChildNodes(item, title);
forEach(tree.statevars, function(j) {
if (typeof(data[j]) != 'undefined') {
item.setAttribute(j, data[j]);
}
});
addElementClass(title, 'render_children');
new Draggable(title, {
'starteffect': function (element) {
element.oldParentNode = element.parentNode;
element.oldNextSibling = element.nextSibling;
appendChildNodes('header', element)
},
'endeffect': function (element) {
if(element.oldNextSibling) {
insertSiblingNodesBefore(element.oldNextSibling, element)
}
else {
appendChildNodes(element.oldParentNode, element);
}
},
'reverteffect': function (element, top_offset, left_offset) {
return new MochiKit.Visual.Move(element, {x: -left_offset, y: -top_offset, duration: 0.0});
},
'ghosting': true,
'revert': true
});
return item;
}
......@@ -50,8 +78,11 @@ tree.setFormatCallback(treeItemFormat);
tree.statevars.push('pluginname');
tree.statevars.push('parent');
addLoadEvent(function () {
swapDOM('tree', tree.render());
appendChildNodes('tree', tree.render());
expandDownToViewport('tree', 300);
expandDownToViewport('template', getViewportDimensions().w - 350);
});
{/literal}
</script>
......
......@@ -17,6 +17,7 @@ use Data::Dumper;
use Getopt::Declare;
use Mahara::Config;
use Mahara::RandomData;
use JSON;
use WWW::Mechanize;
my $args = Getopt::Declare->new(q(
......@@ -40,6 +41,8 @@ croak 'You must insert some users so groups can have members (specify with -nu)'
croak 'You must specify a user to create the groups for with -u' if (!defined $args->{-u} and $args->{-ng} > 0);
my $randomdata;
my $json_response;
if ($args->{-nu} or $args->{-ng}) {
$args->{-mc} ||= qq{$FindBin::Bin/../htdocs/config.php};
my $config = Mahara::Config->new($args->{-mc});
......@@ -70,13 +73,20 @@ my $components = /var todo = \[(".*",?)+\]/s;
my @things = split(/","/, substr($1, 1, -1));
for my $thing (@things) {
debug("Installing $thing...");
# @todo check for errors
$m->get($CFG->{url} . 'admin/upgrade.json.php?name=' . $thing);
$json_response = my_jsonToObj($m->content());
unless ( $json_response->{success} ) {
croak qq{Failed to install $thing} . Dumper($json_response);
}
}
# Request the core data page
debug("Installing core data...");
$m->get($CFG->{url} . 'admin/upgrade.json.php?install=1');
$json_response = my_jsonToObj($m->content());
unless ( $json_response->{success} ) {
croak qq{Failed to install core data:} . Dumper($json_response);
}
# Install done, now Log in
debug("Logging in...");
......@@ -110,3 +120,13 @@ else {
sub debug {
print shift() . "\n" if $CFG->{debug};
}
sub my_jsonToObj {
my $data = shift;
$data = eval { jsonToObj($data); };
croak q{Failed to parse JSON data} unless defined $data;
return $data;
}
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