Manipulate[
Plot[{Sign[Sin[x]+p[[1]]]*PeriodicExtension[k[[1]],x],Evaluate[p[[3]]k[[2]]+Sum[k[[3]]p[[2]] Sin[n x]+k[[4]] p[[3]]Cos[n x],{n,1,m}]]},{x,-r,r}, Axes->{True,True}, PlotStyle->{{Thickness[0.005],Black},{Thickness[0.003],Blue}} ,ImageSize->{500,400},ImagePadding->30,PlotRange->All],
{{k,{Abs[Sign[#]]&,1,2((1-(-1)^n)/(Pi n)),0},"function"},{{Abs[Sign[#]]&,1,2((1-(-1)^n)/(Pi n)),0}->"step",{Abs[#]&,Pi/2,2(-1)^(n+1)/n,2(-1+(-1)^n)/(n^2*Pi)}->"sawtooth",
{Abs[#]^2&,((π^2)/3),2((-2+(2-(π^2) (n^2)) (-1)^n)/(Pi (n^3))),((4 (((-1))^n))/(n^2))}->"parabola",
{(Abs[#]-Pi )(Abs[#]+Pi)(Abs[#]-1)&,((2 (π^2))/3)-((π^3)/4),2((n (2+(π^2) (n^2))+2 (-1+3 π) n (-1)^n)/(Pi (n^4))),2((6+(π^2) (n^2)+2 (-3-π (n^2)+(π^2) (n^2)) (-1)^n)/(Pi (n^4)))}->"cubic",
{Sin[Abs[#]]&,2/Pi,KroneckerDelta[n,1],If[n==1,0,2/Pi*((1+(-1)^n)/(1-(n^2)))]}->"sin"}},
{{p,{0,1,0},"series type"}, {{0,1,0}->"odd", {2,0,1}->"even"}},
{{m,0,"number of terms"},0,50,1,Appearance->"Labeled"},
{{r,Pi,"x range"},Pi,5*Pi,Pi,Appearance->"Labeled"},
Initialization:>{(PeriodicExtension[g_,x_]:=If[Abs[x]<Pi,g[x],PeriodicExtension[g,x-2Sign[x]Pi]])}]