small changes, also de-tabbed and unix fomatted
This commit is contained in:
+64
-69
@@ -1,84 +1,79 @@
|
||||
<?PHP
|
||||
/**
|
||||
* Library functions for using ajax with moodle
|
||||
**/
|
||||
<?PHP
|
||||
/**
|
||||
* Library functions for using ajax with moodle
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
*Print require statements for javascript libraries
|
||||
*Takes in an array of either full paths or shortnames and it will translate them to full paths
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
*Print require statements for javascript libraries
|
||||
*Takes in an array of either full paths or shortnames and it will translate them to full paths
|
||||
**/
|
||||
|
||||
function print_require_js($list){
|
||||
global $CFG;
|
||||
|
||||
//list of shortname to filepath translations
|
||||
function print_require_js($list){
|
||||
global $CFG;
|
||||
|
||||
//list of shortname to filepath translations
|
||||
$translatelist = Array(
|
||||
"yui_yahoo" => "/lib/yui/yahoo/yahoo.js",
|
||||
"yui_dom" => "/lib/yui/dom/dom.js",
|
||||
"yui_event" => "/lib/yui/event/event.js",
|
||||
"yui_dragdrop" => "/lib/yui/dragdrop/dragdrop.js",
|
||||
"yui_logger" => "/lib/yui/logger/logger.js",
|
||||
"yui_connection" => "/lib/yui/connection/connection.js",
|
||||
"ajaxcourse_blocks" => "/lib/ajax/block_classes.js",
|
||||
"ajaxcourse_sections" => "/lib/ajax/section-resource_classes.js",
|
||||
"ajaxcourse_topic" => "/course/format/topicsajax/ajaxcourse-topics.js",
|
||||
"ajaxcourse_week" => "/course/format/weeksajax/ajaxcourse-weeks.js"
|
||||
);
|
||||
|
||||
|
||||
for ($i=0;$i<count($list);$i++) {
|
||||
if ($translatelist[$list[$i]]) {
|
||||
echo "<script language='JavaScript' type='text/javascript' src='".$CFG->wwwroot.''.$translatelist[$list[$i]]."'></script>\n\r";
|
||||
} else {
|
||||
echo "<script language='JavaScript' type='text/javascript' src='".$CFG->wwwroot.''.$list[$i]."'></script>\n\r";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//used to create view of document to be passed to javascript on pageload
|
||||
class jsportal{
|
||||
|
||||
"yui_yahoo" => "/lib/yui/yahoo/yahoo.js",
|
||||
"yui_dom" => "/lib/yui/dom/dom.js",
|
||||
"yui_event" => "/lib/yui/event/event.js",
|
||||
"yui_dragdrop" => "/lib/yui/dragdrop/dragdrop.js",
|
||||
"yui_logger" => "/lib/yui/logger/logger.js",
|
||||
"yui_connection" => "/lib/yui/connection/connection.js",
|
||||
"ajaxcourse_blocks" => "/lib/ajax/block_classes.js",
|
||||
"ajaxcourse_sections" => "/lib/ajax/section-resource_classes.js",
|
||||
"ajaxcourse_topic" => "/course/format/topicsajax/ajaxcourse-topics.js",
|
||||
"ajaxcourse_week" => "/course/format/weeksajax/ajaxcourse-weeks.js"
|
||||
);
|
||||
|
||||
|
||||
for($i=0;$i<count($list);$i++)
|
||||
if($translatelist[$list[$i]])
|
||||
echo "<script language='JavaScript' type='text/javascript' src='".$CFG->wwwroot.''.$translatelist[$list[$i]]."'></script>\n\r";
|
||||
else
|
||||
echo "<script language='JavaScript' type='text/javascript' src='".$CFG->wwwroot.''.$list[$i]."'></script>\n\r";
|
||||
|
||||
}
|
||||
|
||||
//used to create view of document to be passed to javascript on pageload
|
||||
class jsportal{
|
||||
|
||||
var $currentblocksection = null;
|
||||
var $blocks = array();
|
||||
var $sections = array();
|
||||
|
||||
var $blocks = Array();
|
||||
var $blocksoutput = '';
|
||||
var $output = '';
|
||||
|
||||
|
||||
//takes id of block and adds it
|
||||
function block_add($id,$hidden=false){
|
||||
$hidden_binary = 0;
|
||||
|
||||
if ($hidden) {
|
||||
$hidden_binary = 1;
|
||||
}
|
||||
|
||||
|
||||
if($hidden)
|
||||
$hidden_binary = 1;
|
||||
|
||||
$this->blocks[count($this->blocks)] = Array($this->currentblocksection,$id,$hidden_binary);
|
||||
}
|
||||
|
||||
|
||||
function print_javascript($id) {
|
||||
global $CFG;
|
||||
|
||||
$blocksoutput = '';
|
||||
for ($i=0;$i<count($this->blocks);$i++){
|
||||
|
||||
|
||||
function print_javascript($id){
|
||||
$blocksoutput = $output = '';
|
||||
for($i=0;$i<count($this->blocks);$i++){
|
||||
$blocksoutput.="['".$this->blocks[$i][0]."','".$this->blocks[$i][1]."','".$this->blocks[$i][2]."']";
|
||||
if ($i != (count($this->blocks)-1)) {
|
||||
if($i != (count($this->blocks)-1))
|
||||
$blocksoutput.=",";
|
||||
}
|
||||
}
|
||||
|
||||
$output ="<script language='javascript'>\r";
|
||||
}
|
||||
|
||||
global $CFG;
|
||||
$output .="<script language='javascript'>\r";
|
||||
$output .=" main.portal.id = ".$id."\r";
|
||||
$output .=" main.portal.blocks = new Array(".$blocksoutput.");\r";
|
||||
$output .=" main.portal.wwwroot = '".$CFG->wwwroot."';\r";
|
||||
$output .=" onload.load()\r";
|
||||
$output .=" main.process_blocks();\r";
|
||||
$output .=" main.portal.blocks = new Array(".$blocksoutput.");\r";
|
||||
$output .=" main.portal.wwwroot = '".$CFG->wwwroot."';\r";
|
||||
$output .=" onload.load()\r";
|
||||
$output .=" main.process_blocks();\r";
|
||||
$output .="</script>";
|
||||
|
||||
echo $output;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+28
-30
@@ -6,8 +6,8 @@
|
||||
*/
|
||||
|
||||
|
||||
//set Drag and Drop to Intersect mode:
|
||||
YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
|
||||
//set Drag and Drop to Intersect mode:
|
||||
YAHOO.util.DDM.mode = YAHOO.util.DDM.INTERSECT;
|
||||
|
||||
/*
|
||||
* class for draggable block, extends YAHOO.util.DDProxy
|
||||
@@ -17,6 +17,8 @@ function block_class(id,group,config){
|
||||
}
|
||||
YAHOO.extend(block_class, YAHOO.util.DDProxy);
|
||||
|
||||
block_class.prototype.debug = true;
|
||||
|
||||
block_class.prototype.init_block = function(id, sGroup, config){
|
||||
if (!id) { return; }
|
||||
|
||||
@@ -39,7 +41,7 @@ block_class.prototype.init_block = function(id, sGroup, config){
|
||||
// specify that this is not currently a drop target
|
||||
this.isTarget = false;
|
||||
|
||||
this.region = YAHOO.util.Region.getRegion(this.getEl());
|
||||
this.region = YAHOO.util.Region.getRegion(this.getEl());
|
||||
|
||||
this.type = block_class.TYPE;
|
||||
|
||||
@@ -49,8 +51,6 @@ block_class.prototype.init_block = function(id, sGroup, config){
|
||||
this.originalClass = this.getEl().className;
|
||||
|
||||
this.init_buttons();
|
||||
|
||||
this.debug = false;
|
||||
}
|
||||
|
||||
block_class.prototype.startDrag = function(x, y) {
|
||||
@@ -143,12 +143,12 @@ block_class.prototype.resetTargets = function() {
|
||||
}
|
||||
|
||||
block_class.prototype.move_block = function(columnid){
|
||||
|
||||
if(this.debug)YAHOO.log("Dropped on "+columnid[0]);
|
||||
//var column = YAHOO.util.DDM.getDDById(columnid[0].);
|
||||
column = columnid[0];
|
||||
column = columnid[0];
|
||||
var inserttarget = this.find_target(column);
|
||||
|
||||
if(this.debug)YAHOO.log("moving "+this.getEl().id+" before "+inserttarget.getEl().id+" - parentNode="+this.getEl().parentNode.id);
|
||||
if(this.debug && inserttarget != null)YAHOO.log("moving "+this.getEl().id+" before "+inserttarget.getEl().id+" - parentNode="+this.getEl().parentNode.id);
|
||||
|
||||
|
||||
//remove from document
|
||||
@@ -252,6 +252,8 @@ function column_class(id,group,config,ident){
|
||||
}
|
||||
YAHOO.extend(column_class, YAHOO.util.DDTarget);
|
||||
|
||||
column_class.prototype.debug = true;
|
||||
|
||||
column_class.prototype.init_column = function(id, group,config,ident){
|
||||
if (!id) { return; }
|
||||
|
||||
@@ -259,14 +261,14 @@ column_class.prototype.init_column = function(id, group,config,ident){
|
||||
this.blocks = new Array();
|
||||
this.ident = ident;
|
||||
|
||||
// YAHOO.log("init_column "+id+"-"+el.id);
|
||||
// YAHOO.log("init_column "+id+"-"+el.id);
|
||||
this.region = YAHOO.util.Region.getRegion(id);
|
||||
|
||||
this.debug = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
column_class.prototype.find_sub_collision = function(dragRegion){
|
||||
if(this.debug)YAHOO.log("Finding Collisions on "+this.getEl().id+" with "+this.blocks.length+" blocks");
|
||||
//find collisions with sub_elements(blocks), return array of collisions with regions of collision
|
||||
var collisions = new Array();
|
||||
for(i=0;i<this.blocks.length;i++){
|
||||
@@ -296,20 +298,14 @@ column_class.prototype.insert_block = function(el,targetel){
|
||||
tempStore = this.blocks[i];
|
||||
this.blocks[i] = nextStore;
|
||||
nextStore = tempStore;
|
||||
|
||||
if(nextStore != null)
|
||||
nextStore.update_index(i+1,this.ident);
|
||||
|
||||
|
||||
|
||||
}else if(this.blocks[i] == targetel){
|
||||
found = true;
|
||||
nextStore = this.blocks[i];
|
||||
this.blocks[i] = el;
|
||||
blockcount++;
|
||||
|
||||
this.blocks[i].update_index(i,this.ident);
|
||||
nextStore.update_index(i+1,this.ident);
|
||||
}
|
||||
}
|
||||
this.blocks[i].update_index(i,this.ident);
|
||||
}
|
||||
|
||||
if(!found){//insert at end
|
||||
@@ -331,18 +327,20 @@ column_class.prototype.remove_block = function(el){
|
||||
var blockcount = this.blocks.length;
|
||||
var found = false;
|
||||
for(var i=0;i<blockcount;i++){
|
||||
if(found){
|
||||
this.blocks[i-1] = this.blocks[i];
|
||||
if(i==blockcount-1){
|
||||
this.blocks = this.blocks.slice(0,-1);
|
||||
blockcount--;
|
||||
}
|
||||
this.blocks[i-1].update_index(i-1,this.ident);
|
||||
}else if(this.blocks[i]==el){
|
||||
found = true;
|
||||
if(this.blocks[i]==el || found){
|
||||
if(!found)
|
||||
found = true;
|
||||
|
||||
if(i < blockcount-1){
|
||||
this.blocks[i+1].update_index(i,this.ident);
|
||||
this.blocks[i] = this.blocks[i+1];
|
||||
}else{
|
||||
this.blocks.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
YAHOO.log("column "+this.indent+" has "+blockcount+"blocks");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user