From: jordan Date: Sun, 3 Jul 2011 00:50:16 +0000 (+0000) Subject: OSQA-465, be able to embed YouTube videos. Adding a new setting to the View Settings... X-Git-Tag: live~215 X-Git-Url: https://git.openstreetmap.org./osqa.git/commitdiff_plain/4da66439c7e1cd073b2f97466208730cf5db9dff OSQA-465, be able to embed YouTube videos. Adding a new setting to the View Settings set. If the option is activated we load the jQuery ViewBox plugin and apply it to all YouTube links. git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@1098 0cfe37f9-358a-4d5e-be75-b63607b5c754 --- diff --git a/forum/settings/view.py b/forum/settings/view.py index 5ebd228..14b3aad 100644 --- a/forum/settings/view.py +++ b/forum/settings/view.py @@ -4,6 +4,11 @@ from django.utils.translation import ugettext_lazy as _ """ view settings """ VIEW_SET = SettingSet('view', _('View settings'), _("Set up how certain parts of the site are displayed."), 20) +EMBED_YOUTUBE_VIDEOS = Setting('EMBED_YOUTUBE_VIDEOS', True, VIEW_SET, dict( +label = _("Embed YouTube Videos"), +help_text = _("If you check this YouTube videos will be embedded"), +required=False)) + SUMMARY_LENGTH = Setting('SUMMARY_LENGTH', 300, VIEW_SET, dict( label = _("Summary Length"), help_text = _("The number of characters that are going to be displayed in order to get the content summary."))) diff --git a/forum/skins/default/media/js/viewbox.css b/forum/skins/default/media/js/viewbox.css new file mode 100644 index 0000000..dd39a14 --- /dev/null +++ b/forum/skins/default/media/js/viewbox.css @@ -0,0 +1,137 @@ +/* Miniatury */ +.thumbdiv { + float:left; + position:relative; +} +.thumbdiv .title { + position:absolute; + padding:2px; + font-size:1.0em; + color:#fff; + background:#000; + border-top:solid 1px #000; + opacity:0.8; + bottom:14px; + left:8px; + right:9px; +} +/* VIEWBOX */ +#viewbox { + position:fixed; + height:100%; + width:100%; + top:0; + left:0; + background:#383739; + z-index:2190; + overflow:auto; +} +.vb_wrap { + position:absolute; + padding:10px; + height:20px; + width:20px; + background-image:url(img/ViewBox_bg.png); + background-color:#0f0e0e; + overflow:visible; + z-index:2200; + margin:0 auto; + top:0; + left:0; + border-radius:10px; + box-shadow: 4px 4px 7px #000; +} +.vb_wrap .content { + position:relative; + overflow:visible; +} +.vb_wrap .number { + position:absolute; + top:-32px; + left:1px; + font-size:0.9em; + color:#0c0c0c; +} +.vb_wrap .close { + position:absolute; + top:-40px; + right:-7px; + background:url(img/viewbox_close.png) top left no-repeat; + height:30px; + width:30px; +} +* html .vb_wrap .close { + top:-26px; + right:7px; +} +.vb_wrap .next { + position:absolute; + right:-60px; + background:url(img/ViewBox_next.png) top left no-repeat; + height:50px; + width:50px; + z-index:2190; +} +.vb_wrap .prev { + position:absolute; + left:-59px; + background:url(img/ViewBox_prev.png) top right no-repeat; + height:50px; + width:50px; + z-index:2190; +} +.vb_wrap .close a, .next a, .prev a { + display:block; + height:100%; + width:100%; + text-indent:-777em; + outline:none; +} +.vb_wrap h1 { + margin:5px 0px 8px; + padding-bottom:3px; + letter-spacing:1.3px; + font-family:Arial, Helvetica, sans-serif; + font-size:0.9em; + color:#cdcdcd; + border-bottom:solid 1px #7e7e7e; + +} +.vb_wrap p { + font-family:Arial, Helvetica, sans-serif; + font-size:0.8em; + text-align:justify; + color:#e5e5e5; +} +.vb_wrap .text { + position:absolute; + background: url(img/ViewBox_bg.png) top left repeat; + border-top:solid 1px #121212; + bottom:0; left:0; + padding:5px; + width:99%; + z-index:2110; +} +* html .vb_wrap .text { + background-image:none; + background-color:#0f0e0e; +} +.vb_wrap .image { + z-index:2220; +} +.vb_wrap .text h1 { + margin:2px; + padding:1px; + color:#919191; + z-index:2230; +} +.vb_wrap .text .description { + position:relative; + bottom:0px; + left:0px; + padding:2px 2px; + font-family:Arial, Helvetica, sans-serif; + font-size:0.8em; + z-index:2260; + color:#949494; +} diff --git a/forum/skins/default/media/js/viewbox_min.js b/forum/skins/default/media/js/viewbox_min.js new file mode 100644 index 0000000..4916f87 --- /dev/null +++ b/forum/skins/default/media/js/viewbox_min.js @@ -0,0 +1 @@ +eval(function(p,a,c,k,e,r){e=function(c){return(c35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(k($){$.3y.Y=k(g){g=$.4l({G:4j,w:4h,C:4f,r:[],o:0,4d:1,2K:1,32:1,2j:0,2m:0,1W:"#4c",2t:5,2C:1,1T:0,1R:0,2J:0,1N:0,2Q:1,2W:1,2X:1,2Y:"c",34:"p",2b:"n",2k:1},g);B h=$(J);B j;k 2v(){2y(J,h);u 1g}k 2y(a,b){g.r.R=0;g.o=0;m(b.R==1){g.r.2M(1s 1E(a.19("V"),a.19("T"),$(a).13("14").1h("2e")))}M{45(B i=0;i1V 1m3Y");$("#Y, .8, .8 .l, .8 .l .Z, .8 .l .12").O();m(g.2W){1l()}$(".8 .12").1x().1Q("1c",k(){1S();u 1g});$(".8 .Z").1x().1Q("1c",k(){1m();u 1g});36();$("#Y").Q("3U",0.7).17(g.G/1.6,k(){y=1w();m($(P).1r()==0){m(g.w>y[0]*1.3){j=y[0]/9}M{j=y[0]/2.2}}M{j=$(P).1r()+y[0]/2.3}$(".8").Q({U:j+(g.w/2),1k:y[1]});$(".8").17(g.G/1.2,k(){$(J).1J({s:g.w,t:g.C,U:j,1k:y[1]-g.C/2},g.G/1.2,k(){1u();$(".8 .l").11(3P).17(g.G/1.5)})})});$("#Y, .8 .l .1V a").1c(k(){20();u 1g})}k 1u(){m(1F(g.r[g.o][0])){2S(g.r[g.o][0])}m(1G(g.r[g.o][0])){1H(g.r[g.o][0])}m(1I(g.r[g.o][0])){2Z(g.r[g.o][0])}m(1K(g.r[g.o][0])){33(g.r[g.o][0])}m(1L(g.r[g.o][0])){35(g.r[g.o][0])}m(1M(g.r[g.o][0])){38(g.r[g.o][0])}m(3a(g.r[g.o][0])){3b(g.r[g.o][0])}m(3c(g.r[g.o][0])){3d(g.r[g.o][0])}}k 1F(a){u(a.H("3O",".")>0||a.H("3N",".")>0||a.H("3L",".")>0)&&a.H("2c",".")<0}k 1G(a){u a.H("2d",".")>0}k 1I(a){u a.H("1i",".")>0}k 1K(a){u a.H("2c",".")>0||a.H("3H",".")>0||a.H("3F",".")>0}k 1L(a){u a.H("3B","/")>0&&a.H("3A",".")>0}k 1M(a){u g.2j!=0||a.H("1X",".")>0}k 3a(a){u g.2m!=0||a.H("#")>=0}k 3c(a){u g.1T!=0||a.H("3z",".")>0||a.H("4m",".")>0}k 2S(b){$(".8 .l").z("<14 />");$(".8 .S").O();m(g.32){$(".8").z("")}B c=1s 2o();c.2p=k(){$(".8 .S 14").1h("W",c.W);y=1w();B a,X;m(y[0]*1.4>c.s||y[1]*1.4>c.t){g.w=a=c.s;g.C=X=c.t}M{m(!g.2K){B d=c.t-(y[1]*1.6)-1t;g.w=a=(c.s-d);g.C=X=(c.t-d)}M{m(c.sy[0]){B d=c.s-(y[0]*1.6)-1t;g.w=a=(c.s-d);g.C=X=(c.t/(c.s/(c.s-d)))}M{g.w=a=(c.s/(c.t/(c.t-d)));g.C=X=(c.t-d)}}m(c.s>c.t){B d=c.s-(y[0]*1.6)-1t;g.w=a=(c.s-d);g.C=X=(c.t/(c.s/(c.s-d)))}}}2u(a,X);$(".8 .2n").18();c.2p=k(){}};c.W=b;B e=g.r[g.o][2];B f=g.r[g.o][1];2x(f,e)}k 2x(a,b){m(a){$(".8 .l .S").z("<2z>"+a+"");$(".8 .l .16").O();$(".8").2A(k(){$(".8 .l .16").1v(I,I).11(1e).2E(1e)},k(){$(".8 .l .16").1v(I,I).11(1e).2F(3x)})}m(b){$(".8 .l .16").z(""+b+"")}u 1g}k 1H(a){$(".8 .l").z("");1O="1P://3v.2d.1d/v/"+a.2O(31,42)+"&3n=1&3m=1&3l=3k&3j=0";$(".8 .E").z("<15 W=\'"+1O+"\' 1C=\'22/x-23-24\' 1A=\'1B\' 1b=\'I\' t=\'"+g.C+"\' s=\'"+g.w+"\'>")}k 2Z(a){$(".8 .l").z("");26=a.2O(21,29);$(".8 .E").z("<15 W=\'1P://1i.1d/3g.1a?3f="+26+"&D;30=1i.1d&D;2V=1&D;2U=1&D;2T=0&D;1y=&D;2R=1\' 1C=\'22/x-23-24\' 1b=\'I\' 1A=\'1B\' t=\'"+g.C+"\' s=\'"+g.w+"\'>")}k 33(a){$(".8 .l").z("");$(\'.8 .E\').z(" ")}k 35(a){$(".8 .l").z("<1q t="+g.C+" s="+g.w+" 2i=\'0\' 2h=\'3C\' 3D=\'0\' 3E=\'0\' W=\'"+a+"&D;2g=15\'><3G /><2f>")}k 38(a){$(".8 .l").z("");$(".8 .l .l").Q("1U",g.1W).O();$(".8 .l .l").z("<1q 3M=\'0\' W=\'"+a+"\' 2h=\'2a\' 2i=\'0\' s=\'"+g.w+"\' t=\'"+g.C+"\' >")}k 1l(){m(g.o!=0){$(".8 .12").Q("U",g.w/2).3h()}M{$(".8 .12").O()}m(g.o!=g.r.R-1){$(".8 .Z").Q("U",g.w/2).3h()}M{$(".8 .Z").O()}1o()}k 3b(a){25();$(".8 .l .l").z($(a).1X())}k 3d(b){25();$.1T({1C:(!g.1R)?"3Q":g.1R,3R:b,2l:g.2J,3S:(!g.1N)?(k(a){$("8 .l .l").1X(a)}):g.1N})}k 25(){$(".8").Q("1U-1y","3T");$(".8 .l .28").O();B a=(g.2C)?"2a":"3V";$(".8 .l").z("");$(".8 .l .l").Q({1U:g.1W,3W:g.2t,3X:a});$(".8 .l .l").s(g.w-10)}k 36(){m(g.2X){$(P.1n).1x().1Q("3Z",k(a){m($.40.41){1Y=a.1j}M{1Y=a.1j}1p=46.47(1Y).48();m(a.1j==37||1p==g.34){1S()}m(a.1j==39||1p==g.2b){1m()}m(a.1j==27||1p==g.2Y){20()}})}}k 1S(){m(g.o!=0){$(".8 .l").1f(g.G/1.4,k(){$(".8 .l .S, .l .E").18();g.o=g.o-1;1o();1u();$(J).17(g.G/1.2);1l()})}}k 1m(){m(g.o!=g.r.R-1){$(".8 .l").1f(g.G/1.4,k(){$(".8 .l .S, .8 .l .E").18();g.o=g.o+1;1o();1u();$(J).17(g.G/1.2);1l()})}}k 1o(){m(g.2k){$(".8 .l .28").18();m(g.r.R!=0){k 3e(){m(1F(g.r[g.o][0])){u"2o "}m(1G(g.r[g.o][0])||1I(g.r[g.o][0])){u"1H "}m(1K(g.r[g.o][0])){u"49 "}m(1L(g.r[g.o][0])){u"4a "}m(1M(g.r[g.o][0])){u"4b "}}$(".8 .l").z(""+3e()+(g.o+1)+" / "+g.r.R+"")}}}k 2u(a,b,c){B d=$(".8").s();B e=$(".8").t();$(".8").1J({1k:P.1n.2s/2-b/2,U:2D(a,b),t:b,s:a},g.G/1.5);$(".8 14").1h({s:a,t:b});$(".8 .S").O().11(g.G/1.1).17(4e);$(".8 .Z, .8 .12").Q("U",a/2)}k 2D(a,b){m(a+y[0]/2.3>y[0]*2){u $(P).1r()+(y[0]/9)}M{u $(P).1r()+(y[0]/2)}}k 20(){B a=1w();g.r.R=0;g.o=0;$(".8 .l").1f(g.G/1.6,k(){$(".8").1J({1k:a[1],U:a[0]/2+j,s:2B,t:2B},g.G/1.3,k(){$(J).1f(g.G/1.2,k(){$(J).18();$("#Y").1f(g.G/1.5,k(){$("#Y").18()})})})})}k 1w(){B a=1s 1E;a[0]=P.1n.4g/2;a[1]=P.1n.2s/2;u a}m(g.2Q){2I.4i(h,k(){B a=$(J).1h("T");m(a!=""){$(J).13("14").1Z("a").4k("");$(J).1Z(".1D").z(""+a+"");$(J).1Z(".1D").13(".T").O()}});$(".1D").2A(k(){$(J).13(".T").1v(I,I).11(2q).2E(1e)},k(){$(J).13(".T").1v(I,I).11(2q).2F(1e)})}u J.1x(\'1c\').1c(2v)}})(2I);',62,271,'||||||||vb_wrap||||||||||||function|content|if||arrayActEl||div|arrayEl|height|width|return||heightWindow||arraySizeBrowser|append|class|var|widthWindow|amp|object|param|Speed|indexOf|true|this|name|value|else|player|hide|document|css|length|image|title|top|href|src|Width|viewbox|next||delay|prev|children|img|embed|text|fadeIn|remove|getAttribute|swf|allowfullscreen|click|com|200|fadeOut|false|attr|vimeo|keyCode|left|NextAndPrev|Next|documentElement|NumberElement|KeyCode|iframe|scrollTop|new|65|setElement|stop|sizeBrowser|unbind|color|movie|allowscriptaccess|always|type|thumbdiv|Array|nImg|nYT|Film|nV|animate|nPlayer|nMaps|nFrame|ajaxSuccess|hrefY|http|bind|ajaxType|Prev|ajax|background|close|inlineBg|html|codeAscii|parent|closeWindow||application|shockwave|flash|ChangeStyle|hrefV||number||auto|keyNext|mp3|youtube|alt|small|output|scrolling|frameborder|frame|numberEl|data|inline|preloader|Image|onload|150|createView|clientWidth|inlinePadding|resizeWindow|_clickEl|id|Description|_viewbox|h1|hover|50|inlineScroll|topToresize|slideDown|slideUp|zip|modieus|jQuery|ajaxData|visibleIMG|skin|push|file|substring|flashvars|titleThumb|fullscreen|Img|show_portrait|show_byline|show_title|navigation|keyboard|keyClose|Vimeo|server||preloaderIMG|Player|keyPrev|GoogleMaps|keyboardNav||FrameObj||nInline|Inline|nAjax|Ajax|Words|clip_id|moogaloop|show|allowFullScreen|showsearch|related|feature|loop|autoplay|classid|clsid|D27CDB6E|AE6D|11cf|96B8|444553540000|www|description|180|fn|txt|google|map|no|marginheight|marginwidth|avi|br|vmw|style|0000FF|align|gif|hspace|png|jpg|290|GET|url|success|transparent|opacity|hidden|padding|overflow|Previous|keyup|browser|msie||body|while|for|String|fromCharCode|toLowerCase|Item|Map|Page|fff|IMG|300|650|clientHeight|450|each|400|wrap|extend|js'.split('|'),0,{})) \ No newline at end of file diff --git a/forum/skins/default/media/js/youtube.js b/forum/skins/default/media/js/youtube.js new file mode 100644 index 0000000..989b553 --- /dev/null +++ b/forum/skins/default/media/js/youtube.js @@ -0,0 +1,6 @@ +$().ready(function(){ + // Embed YouTube videos + $('a[href*="youtube.com"]').viewbox({ + widthWindow: 900 + }); +}); \ No newline at end of file diff --git a/forum/skins/default/templates/question.html b/forum/skins/default/templates/question.html index 9eff07c..4583518 100644 --- a/forum/skins/default/templates/question.html +++ b/forum/skins/default/templates/question.html @@ -21,6 +21,12 @@ + + {% if embed_youtube_videos %} + + + + {% endif %} {% endif %}