From 6a46d65df0817f2aa24babdfecd30199554ad5e8 Mon Sep 17 00:00:00 2001 From: Josh de Leeuw Date: Wed, 18 Feb 2015 16:18:41 -0500 Subject: [PATCH] fix raphael -> snapsvg --- plugins/jspsych-palmer.js | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/plugins/jspsych-palmer.js b/plugins/jspsych-palmer.js index 2abaac96..0987ea48 100644 --- a/plugins/jspsych-palmer.js +++ b/plugins/jspsych-palmer.js @@ -145,7 +145,7 @@ for (var i = 0; i < lines.length; i++) { var line = paper.path("M" + circles[lines[i][0]].attr("cx") + " " + circles[lines[i][0]].attr("cy") + "L" + circles[lines[i][1]].attr("cx") + " " + circles[lines[i][1]].attr("cy")).attr("stroke-width", "8").attr("stroke", "#000"); - line.hide(); + line.attr({ visibility: 'hidden' }); lineElements.push(line); lineIsVisible.push(0); } @@ -170,12 +170,12 @@ function toggle_line(the_line) { if (the_line > -1) { if (lineIsVisible[the_line] === 0) { - lineElements[the_line].show(); - lineElements[the_line].toBack(); + lineElements[the_line].attr({ visibility: 'visible' }); + lineElements[the_line].prependTo(paper); lineIsVisible[the_line] = 1; } else { - lineElements[the_line].hide(); - lineElements[the_line].toBack(); + lineElements[the_line].attr({ visibility: 'hidden' }); + lineElements[the_line].prependTo(paper); lineIsVisible[the_line] = 0; } } @@ -295,7 +295,9 @@ var size = grid_spacing * (square_size + 1); // create a div to hold the generated svg object - var stim_div = $('body').append(''); + var stim_div = $('body').append($('
')); + + $('#jspsych-palmer-container').append(''); // create the snap object var paper = Snap("#jspsych-palmer-temp-stim"); @@ -348,7 +350,9 @@ for (var i = 0; i < lines.length; i++) { var line = paper.path("M" + circles[lines[i][0]].attr("cx") + " " + circles[lines[i][0]].attr("cy") + "L" + circles[lines[i][1]].attr("cx") + " " + circles[lines[i][1]].attr("cy")).attr("stroke-width", "8").attr("stroke", "#000"); - line.hide(); + line.attr({ + visibility: 'hidden' + }); lineElements.push(line); lineIsVisible.push(0); } @@ -360,12 +364,12 @@ function toggle_line(the_line) { if (the_line > -1) { if (lineIsVisible[the_line] === 0) { - lineElements[the_line].show(); - lineElements[the_line].toBack(); + lineElements[the_line].attr({ visibility: 'visible' }); + lineElements[the_line].prependTo(paper); lineIsVisible[the_line] = 1; } else { - lineElements[the_line].hide(); - lineElements[the_line].toBack(); + lineElements[the_line].attr({ visibility: 'hidden' }); + lineElements[the_line].prependTo(paper); lineIsVisible[the_line] = 0; } } @@ -381,9 +385,9 @@ } - var svg = $("#jspsych-palmer-temp-stim").html(); + var svg = $("#jspsych-palmer-container").html(); - $('#jspsych-palmer-temp-stim').remove(); + $('#jspsych-palmer-container').remove(); return svg; };