2013-08-07 07:49:02 +02:00
|
|
|
!function(a){var b={};wp.media.string={props:function(a,b){var c,d,e,f,g,h=wp.media.view.settings.defaultProps;return g=function(a){return"image"!==a.type||a.alt||(a.alt=a.caption||a.title||"",a.alt=a.alt.replace(/<\/?[^>]+>/g,""),a.alt=a.alt.replace(/[\r\n]+/g," ")),a},a=a?_.clone(a):{},b&&b.type&&(a.type=b.type),"image"===a.type&&(a=_.defaults(a||{},{align:h.align||getUserSetting("align","none"),size:h.size||getUserSetting("imgsize","medium"),url:"",classes:[]})),b?(a.title=a.title||b.title,c=a.link||h.link||getUserSetting("urlbutton","file"),"file"===c||"embed"===c?d=b.url:"post"===c?d=b.link:"custom"===c&&(d=a.linkUrl),a.linkUrl=d||"","image"===b.type?(a.classes.push("wp-image-"+b.id),f=b.sizes,e=f&&f[a.size]?f[a.size]:b,_.extend(a,_.pick(b,"align","caption","alt"),{width:e.width,height:e.height,src:e.url,captionId:"attachment_"+b.id})):"video"===b.type||"audio"===b.type?_.extend(a,_.pick(b,"title","type","icon","mime")):(a.title=a.title||b.filename,a.rel=a.rel||"attachment wp-att-"+b.id),g(a)):g(a)},link:function(a,b){var c;return a=wp.media.string.props(a,b),c={tag:"a",content:a.title,attrs:{href:a.linkUrl}},a.rel&&(c.attrs.rel=a.rel),wp.html.string(c)},audio:function(a,b){return wp.media.string._audioVideo("audio",a,b)},video:function(a,b){return wp.media.string._audioVideo("video",a,b)},_audioVideo:function(a,b,c){var d,e,f;return b=wp.media.string.props(b,c),"embed"!==b.link?wp.media.string.link(b):(d={},"video"===a&&(c.width&&(d.width=c.width),c.height&&(d.height=c.height)),f=c.filename.split(".").pop(),_.contains(wp.media.view.settings.embedExts,f)?(d[f]=c.url,e=wp.shortcode.string({tag:a,attrs:d})):wp.media.string.link(b))},image:function(a,b){var c,d,e,f,g={};return a=wp.media.string.props(a,b),d=a.classes||[],g.src="undefined"!=typeof b?b.url:a.url,_.extend(g,_.pick(a,"width","height","alt")),a.align&&!a.caption&&d.push("align"+a.align),a.size&&d.push("size-"+a.size),g["class"]=_.compact(d).join(" "),c={tag:"img",attrs:g,single:!0},a.linkUrl&&(c={tag:"a",attrs:{href:a.linkUrl},content:c}),f=wp.html.string(c),a.caption&&(e={},g.width&&(e.width=g.width),a.captionId&&(e.id=a.captionId),a.align&&(e.align="align"+a.align),f=wp.shortcode.string({tag:"caption",attrs:e,content:f+" "+a.caption})),f}},wp.media.gallery=function(){var a={};return{defaults:{order:"ASC",id:wp.media.view.settings.post.id,itemtag:"dl",icontag:"dt",captiontag:"dd",columns:"3",link:"post",size:"thumbnail",orderby:"menu_order ID"},attachments:function(b){var c,d,e,f,g=b.string(),h=a[g];return delete a[g],h?h:(c=_.defaults(b.attrs.named,wp.media.gallery.defaults),d=_.pick(c,"orderby","order"),d.type="image",d.perPage=-1,"rand"===c.orderby&&(c._orderbyRandom=!0),(!c.orderby||/^menu_order(?: ID)?$/i.test(c.orderby))&&(d.orderby="menuOrder"),c.ids?(d.post__in=c.ids.split(","),d.orderby="post__in"):c.include&&(d.post__in=c.include.split(",")),c.exclude&&(d.post__not_in=c.exclude.split(",")),d.post__in||(d.uploadedTo=c.id),f=_.omit(c,"id","ids","include","exclude","orderby","order"),e=wp.media.query(d),e.gallery=new Backbone.Model(f),e)},shortcode:function(b){var c,d,e=b.props.toJSON(),f=_.pick(e,"orderby","order");return b.gallery&&_.extend(f,b.gallery.toJSON()),f.ids=b.pluck("id"),e.uploadedTo&&(f.id=e.uploadedTo),f._orderbyRandom&&(f.orderby="rand"),delete f._orderbyRandom,f.ids&&"post__in"===f.orderby&&delete f.orderby,_.each(wp.media.gallery.defaults,function(a,b){a===f[b]&&delete f[b]}),c=new wp.shortcode({tag:"gallery",attrs:f,type:"single"}),d=new wp.media.model.Attachments(b.models,{props:e}),d.gallery=b.gallery,a[c.string()]=d,c},edit:function(a){var b,c,d=wp.shortcode.next("gallery",a),e=wp.media.gallery.defaults.id;if(d&&d.content===a)return d=d.shortcode,_.isUndefined(d.get("id"))&&!_.isUndefined(e)&&d.set("id",e),b=wp.media.gallery.attachments(d),c=new wp.media.model.Selection(b.models,{props:b.props.toJSON(),multiple:!0}),c.gallery=b.gallery,c.more().done(function(){c.props.set({query:!1}),c.unmirror(),c.props.unset("orderby")}),this.frame&&this.frame.dispose(),this.frame=wp.media({frame:"post",state:"gallery-edit",title:wp.media.vi
|