Skip to content

Instantly share code, notes, and snippets.

@wyldrodney
Created April 11, 2012 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wyldrodney/2358211 to your computer and use it in GitHub Desktop.
Save wyldrodney/2358211 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
$('iframe', top.document).load(function() {
// this.style.height = this.contentWindow.document.body.offsetHeight + 'px'; //autoheight
var nodes = $('#wizard-controller > input').attr('value').split(',');
var iframeDoc = window.frames[0].document;
var list = $(iframeDoc).contents().find('*');
setNodesCounter();
for(var i = 0; i < nodes.length; i++) {
$(nodes[i], iframeDoc).toggleClass("wizard-selected");
}
$(list).bind('click', function() {
toggleNode($(this));
return false;
});
$(list).bind('mouseover', function(event) {
event.stopPropagation();
$(this).addClass("wizard-hover");
});
$(list).bind('mouseout', function(event) {
event.stopPropagation();
$(this).removeClass("wizard-hover");
});
function toggleNode(node) {
var csspath = $(node).getPath().replace(/\.wizard-hover/g, "");;
var find = nodes.indexOf(csspath);
if (find == -1) {
nodes = nodes.concat(csspath);
} else {
delete nodes[find];
}
$('#wizard-controller > input').attr('value', nodes);
node.toggleClass("wizard-selected");
setNodesCounter();
}
function setNodesCounter() {
var nodes = $('#wizard-controller > input').attr('value').split(',');
var cnt = 0;
for(var i = 0; i < nodes.length; i++) {
if (nodes[i].length != 0) { cnt++; }
}
$('#wizard-controller .label-info strong').text(cnt);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment