From Design pattern
Jump to: navigation, search
Line 1: Line 1:
$.import_js('http://kimsungi.cafe24.com/temp/toc.js');
+
$("#mw-content-text h3").each(function(){
  
 +
$(this).wrap("<div class=example></div>");
 +
var ex_div=$(this).closest("DIV");
 +
//ex_div.css("border","1px solid red");
 +
//console.log(ex_div);
 +
while(ex_div.next().length && !ex_div.next().prop("tagName").match(/h3|h2|div/i)){
 +
nextobj=ex_div.next();
 +
//console.log(nextobj.prop("tagName"));
 +
ex_div.append(nextobj);
 +
}
 +
 +
});
 +
 +
$("div.example").each(function(){
 +
 +
var video=$("iframe,object",this);
 +
if(video.length){
 +
//console.log(video.eq(0),video.eq(0).prop("clientWidth"));
 +
if(video.eq(0).prop("clientWidth")<=300){
 +
video.insertAfter($("h3",this));
 +
$(this).css("width",300).css("float","left").css("margin","0 30px 0 0");
 +
 +
//console.log($(this).next().prop("className"));
 +
if($(this).next().prop("className")!="example") $(this).after("<br clear=both>");
 +
}else {
 +
$(this).before("<br clear=both>");
 +
 +
}
 +
}
  
$(document).ready(function() {
 
    $('element selector').toc1();
 
 
});
 
});

Revision as of 17:28, 30 May 2014

$("#mw-content-text h3").each(function(){

$(this).wrap("<div class=example></div>");
var ex_div=$(this).closest("DIV");
//ex_div.css("border","1px solid red");
//console.log(ex_div);
while(ex_div.next().length && !ex_div.next().prop("tagName").match(/h3|h2|div/i)){
	nextobj=ex_div.next();
	//console.log(nextobj.prop("tagName"));
ex_div.append(nextobj);
}

});

$("div.example").each(function(){

var video=$("iframe,object",this);
if(video.length){
	//console.log(video.eq(0),video.eq(0).prop("clientWidth"));
if(video.eq(0).prop("clientWidth")<=300){
	video.insertAfter($("h3",this));
	$(this).css("width",300).css("float","left").css("margin","0 30px 0 0");

	//console.log($(this).next().prop("className"));
	if($(this).next().prop("className")!="example") $(this).after("<br clear=both>");
}else {
$(this).before("<br clear=both>");

}
}

});