]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/media-models.min.js
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-includes / js / media-models.min.js
index 04bc333c6eec33f7dd7c0a54f865a40aea4829a2..28473d98187d8ff4b9604d92d42d40dd1697568a 100644 (file)
@@ -1 +1 @@
-window.wp=window.wp||{};(function(f){var d,c,a,e,b,g;g=wp.media=function(h){var i=g.view.MediaFrame,j;if(!i){return}h=_.defaults(h||{},{frame:"select"});if("select"===h.frame&&i.Select){j=new i.Select(h)}else{if("post"===h.frame&&i.Post){j=new i.Post(h)}}delete h.frame;return j};_.extend(g,{model:{},view:{},controller:{},frames:{}});b=g.model.l10n=typeof _wpMediaModelsL10n==="undefined"?{}:_wpMediaModelsL10n;g.model.settings=b.settings||{};delete b.settings;e=function(i,h,j,k){if(_.isEqual(i,h)){return j===k?0:(j>k?-1:1)}else{return i>h?-1:1}};_.extend(g,{template:wp.template,post:wp.ajax.post,ajax:wp.ajax.send,fit:function(l){var i=l.width,h=l.height,k=l.maxWidth,j=l.maxHeight,m;if(!_.isUndefined(k)&&!_.isUndefined(j)){m=(i/h>k/j)?"width":"height"}else{if(_.isUndefined(j)){m="width"}else{if(_.isUndefined(k)&&h>j){m="height"}}}if("width"===m&&i>k){return{width:k,height:Math.round(k*h/i)}}else{if("height"===m&&h>j){return{width:Math.round(j*i/h),height:j}}else{return{width:i,height:h}}}},truncate:function(h,j,i){j=j||30;i=i||"&hellip;";if(h.length<=j){return h}return h.substr(0,j/2)+i+h.substr(-1*j/2)}});g.attachment=function(h){return d.get(h)};d=g.model.Attachment=Backbone.Model.extend({sync:function(j,i,h){if(_.isUndefined(this.id)){return f.Deferred().rejectWith(this).promise()}if("read"===j){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:"get-attachment",id:this.id});return g.ajax(h)}else{if("update"===j){if(!this.get("nonces")||!this.get("nonces").update){return f.Deferred().rejectWith(this).promise()}h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:"save-attachment",id:this.id,nonce:this.get("nonces").update,post_id:g.model.settings.post.id});if(i.hasChanged()){h.data.changes={};_.each(i.changed,function(l,k){h.data.changes[k]=this.get(k)},this)}return g.ajax(h)}else{if("delete"===j){h=h||{};if(!h.wait){this.destroyed=true}h.context=this;h.data=_.extend(h.data||{},{action:"delete-post",id:this.id,_wpnonce:this.get("nonces")["delete"]});return g.ajax(h).done(function(){this.destroyed=true}).fail(function(){this.destroyed=false})}else{return Backbone.Model.prototype.sync.apply(this,arguments)}}}},parse:function(i,h){if(!i){return i}i.date=new Date(i.date);i.modified=new Date(i.modified);return i},saveCompat:function(j,i){var h=this;if(!this.get("nonces")||!this.get("nonces").update){return f.Deferred().rejectWith(this).promise()}return g.post("save-attachment-compat",_.defaults({id:this.id,nonce:this.get("nonces").update,post_id:g.model.settings.post.id},j)).done(function(m,k,l){h.set(h.parse(m,l),i)})}},{create:function(h){return c.all.push(h)},get:_.memoize(function(i,h){return c.all.push(h||{id:i})})});c=g.model.Attachments=Backbone.Collection.extend({model:d,initialize:function(i,h){h=h||{};this.props=new Backbone.Model();this.filters=h.filters||{};this.props.on("change",this._changeFilteredProps,this);this.props.on("change:order",this._changeOrder,this);this.props.on("change:orderby",this._changeOrderby,this);this.props.on("change:query",this._changeQuery,this);this.props.set(_.defaults(h.props||{}));if(h.observe){this.observe(h.observe)}},_changeOrder:function(i,h){if(this.comparator){this.sort()}},_changeOrderby:function(h,i){if(this.comparator&&this.comparator!==c.comparator){return}if(i&&"post__in"!==i){this.comparator=c.comparator}else{delete this.comparator}},_changeQuery:function(h,i){if(i){this.props.on("change",this._requery,this);this._requery()}else{this.props.off("change",this._requery,this)}},_changeFilteredProps:function(i,h){if(this.props.get("query")){return}var j=_.chain(i.changed).map(function(l,n){var m=c.filters[n],k=i.get(n);if(!m){return}if(k&&!this.filters[n]){this.filters[n]=m}else{if(!k&&this.filters[n]===m){delete this.filters[n]}else{return}}return true},this).any().value();if(!j){return}if(!this._source){this._source=new c(this.models)}this.reset(this._source.filter(this.validator,this))},validateDestroyed:false,validator:function(h){if(!this.validateDestroyed&&h.destroyed){return false}return _.all(this.filters,function(j,i){return !!j.call(this,h)},this)},validate:function(k,i){var j=this.validator(k),h=!!this.get(k.cid);if(!j&&h){this.remove(k,i)}else{if(j&&!h){this.add(k,i)}}return this},validateAll:function(h,i){i=i||{};_.each(h.models,function(j){this.validate(j,{silent:true})},this);if(!i.silent){this.trigger("reset",this,i)}return this},observe:function(h){this.observers=this.observers||[];this.observers.push(h);h.on("add change remove",this._validateHandler,this);h.on("reset",this._validateAllHandler,this);this.validateAll(h);return this},unobserve:function(h){if(h){h.off(null,null,this);this.observers=_.without(this.observers,h)}else{_.each(this.observers,function(i){i.off(null,null,this)},this);delete this.observers}return this},_validateHandler:function(j,h,i){i=h===this.mirroring?i:{silent:i&&i.silent};return this.validate(j,i)},_validateAllHandler:function(h,i){return this.validateAll(h,i)},mirror:function(h){if(this.mirroring&&this.mirroring===h){return this}this.unmirror();this.mirroring=h;this.reset([],{silent:true});this.observe(h);return this},unmirror:function(){if(!this.mirroring){return}this.unobserve(this.mirroring);delete this.mirroring},more:function(j){var i=f.Deferred(),k=this.mirroring,h=this;if(!k||!k.more){return i.resolveWith(this).promise()}k.more(j).done(function(){if(this===h.mirroring){i.resolveWith(this)}});return i.promise()},hasMore:function(){return this.mirroring?this.mirroring.hasMore():false},parse:function(i,h){if(!_.isArray(i)){i=[i]}return _.map(i,function(j){var m,l,k;if(j instanceof Backbone.Model){m=j.get("id");j=j.attributes}else{m=j.id}l=d.get(m);k=l.parse(j,h);if(!_.isEqual(l.attributes,k)){l.set(k)}return l})},_requery:function(){if(this.props.get("query")){this.mirror(a.get(this.props.toJSON()))}},saveMenuOrder:function(){if("menuOrder"!==this.props.get("orderby")){return}var h=this.chain().filter(function(i){return !_.isUndefined(i.id)}).map(function(j,i){i=i+1;j.set("menuOrder",i);return[j.id,i]}).object().value();if(_.isEmpty(h)){return}return g.post("save-attachment-order",{nonce:g.model.settings.post.nonce,post_id:g.model.settings.post.id,attachments:h})}},{comparator:function(j,i,k){var l=this.props.get("orderby"),h=this.props.get("order")||"DESC",m=j.cid,n=i.cid;j=j.get(l);i=i.get(l);if("date"===l||"modified"===l){j=j||new Date();i=i||new Date()}if(k&&k.ties){m=n=null}return("DESC"===h)?e(j,i,m,n):e(i,j,n,m)},filters:{search:function(h){if(!this.props.get("search")){return true}return _.any(["title","filename","description","caption","name"],function(i){var j=h.get(i);return j&&-1!==j.search(this.props.get("search"))},this)},type:function(i){var h=this.props.get("type");return !h||-1!==h.indexOf(i.get("type"))},uploadedTo:function(i){var h=this.props.get("uploadedTo");if(_.isUndefined(h)){return true}return h===i.get("uploadedTo")}}});c.all=new c();g.query=function(h){return new c(null,{props:_.extend(_.defaults(h||{},{orderby:"date"}),{query:true})})};a=g.model.Query=c.extend({initialize:function(j,h){var i;h=h||{};c.prototype.initialize.apply(this,arguments);this.args=h.args;this._hasMore=true;this.created=new Date();this.filters.order=function(m){var l=this.props.get("orderby"),k=this.props.get("order");if(!this.comparator){return true}if(this.length){return 1!==this.comparator(m,this.last(),{ties:true})}else{if("DESC"===k&&("date"===l||"modified"===l)){return m.get(l)>=this.created}else{if("ASC"===k&&"menuOrder"===l){return m.get(l)===0}}}return false};i=["s","order","orderby","posts_per_page","post_mime_type","post_parent"];if(wp.Uploader&&_(this.args).chain().keys().difference(i).isEmpty().value()){this.observe(wp.Uploader.queue)}},hasMore:function(){return this._hasMore},more:function(h){var i=this;if(this._more&&"pending"===this._more.state()){return this._more}if(!this.hasMore()){return f.Deferred().resolveWith(this).promise()}h=h||{};h.remove=false;return this._more=this.fetch(h).done(function(j){if(_.isEmpty(j)||-1===this.args.posts_per_page||j.length<this.args.posts_per_page){i._hasMore=false}})},sync:function(k,i,h){var j;if("read"===k){h=h||{};h.context=this;h.data=_.extend(h.data||{},{action:"query-attachments",post_id:g.model.settings.post.id});args=_.clone(this.args);if(-1!==args.posts_per_page){args.paged=Math.floor(this.length/args.posts_per_page)+1}h.data.query=args;return g.ajax(h)}else{j=c.prototype.sync?c.prototype:Backbone;return j.sync.apply(this,arguments)}}},{defaultProps:{orderby:"date",order:"DESC"},defaultArgs:{posts_per_page:40},orderby:{allowed:["name","author","date","title","modified","uploadedTo","id","post__in","menuOrder"],valuemap:{id:"ID",uploadedTo:"parent",menuOrder:"menu_order ID"}},propmap:{search:"s",type:"post_mime_type",perPage:"posts_per_page",menuOrder:"menu_order",uploadedTo:"post_parent"},get:(function(){var h=[];return function(k,j){var i={},m=a.orderby,n=a.defaultProps,l;delete k.query;_.defaults(k,n);k.order=k.order.toUpperCase();if("DESC"!==k.order&&"ASC"!==k.order){k.order=n.order.toUpperCase()}if(!_.contains(m.allowed,k.orderby)){k.orderby=n.orderby}_.each(k,function(o,p){if(_.isNull(o)){return}i[a.propmap[p]||p]=o});_.defaults(i,a.defaultArgs);i.orderby=m.valuemap[k.orderby]||k.orderby;l=_.find(h,function(o){return _.isEqual(o.args,i)});if(!l){l=new a([],_.extend(j||{},{props:k,args:i}));h.push(l)}return l}}())});g.model.Selection=c.extend({initialize:function(i,h){c.prototype.initialize.apply(this,arguments);this.multiple=h&&h.multiple;this.on("add remove reset",_.bind(this.single,this,false))},add:function(i,h){if(!this.multiple){this.remove(this.models)}return c.prototype.add.call(this,i,h)},single:function(h){var i=this._single;if(h){this._single=h}if(this._single&&!this.get(this._single.cid)){delete this._single}this._single=this._single||this.last();if(this._single!==i){if(i){i.trigger("selection:unsingle",i,this);if(!this.get(i.cid)){this.trigger("selection:unsingle",i,this)}}if(this._single){this._single.trigger("selection:single",this._single,this)}}return this._single}});f(window).on("unload",function(){window.wp=null})}(jQuery));
\ No newline at end of file
+window.wp=window.wp||{},function(a){var b,c,d,e,f,g;g=wp.media=function(a){var b,c=g.view.MediaFrame;if(c)return a=_.defaults(a||{},{frame:"select"}),"select"===a.frame&&c.Select?b=new c.Select(a):"post"===a.frame&&c.Post&&(b=new c.Post(a)),delete a.frame,b},_.extend(g,{model:{},view:{},controller:{},frames:{}}),f=g.model.l10n="undefined"==typeof _wpMediaModelsL10n?{}:_wpMediaModelsL10n,g.model.settings=f.settings||{},delete f.settings,e=function(a,b,c,d){return _.isEqual(a,b)?c===d?0:c>d?-1:1:a>b?-1:1},_.extend(g,{template:wp.template,post:wp.ajax.post,ajax:wp.ajax.send,fit:function(a){var b,c=a.width,d=a.height,e=a.maxWidth,f=a.maxHeight;return _.isUndefined(e)||_.isUndefined(f)?_.isUndefined(f)?b="width":_.isUndefined(e)&&d>f&&(b="height"):b=c/d>e/f?"width":"height","width"===b&&c>e?{width:e,height:Math.round(e*d/c)}:"height"===b&&d>f?{width:Math.round(f*c/d),height:f}:{width:c,height:d}},truncate:function(a,b,c){return b=b||30,c=c||"&hellip;",a.length<=b?a:a.substr(0,b/2)+c+a.substr(-1*b/2)}}),g.attachment=function(a){return b.get(a)},b=g.model.Attachment=Backbone.Model.extend({sync:function(b,c,d){return _.isUndefined(this.id)?a.Deferred().rejectWith(this).promise():"read"===b?(d=d||{},d.context=this,d.data=_.extend(d.data||{},{action:"get-attachment",id:this.id}),g.ajax(d)):"update"===b?this.get("nonces")&&this.get("nonces").update?(d=d||{},d.context=this,d.data=_.extend(d.data||{},{action:"save-attachment",id:this.id,nonce:this.get("nonces").update,post_id:g.model.settings.post.id}),c.hasChanged()&&(d.data.changes={},_.each(c.changed,function(a,b){d.data.changes[b]=this.get(b)},this)),g.ajax(d)):a.Deferred().rejectWith(this).promise():"delete"===b?(d=d||{},d.wait||(this.destroyed=!0),d.context=this,d.data=_.extend(d.data||{},{action:"delete-post",id:this.id,_wpnonce:this.get("nonces")["delete"]}),g.ajax(d).done(function(){this.destroyed=!0}).fail(function(){this.destroyed=!1})):Backbone.Model.prototype.sync.apply(this,arguments)},parse:function(a){return a?(a.date=new Date(a.date),a.modified=new Date(a.modified),a):a},saveCompat:function(b,c){var d=this;return this.get("nonces")&&this.get("nonces").update?g.post("save-attachment-compat",_.defaults({id:this.id,nonce:this.get("nonces").update,post_id:g.model.settings.post.id},b)).done(function(a,b,e){d.set(d.parse(a,e),c)}):a.Deferred().rejectWith(this).promise()}},{create:function(a){return c.all.push(a)},get:_.memoize(function(a,b){return c.all.push(b||{id:a})})}),c=g.model.Attachments=Backbone.Collection.extend({model:b,initialize:function(a,b){b=b||{},this.props=new Backbone.Model,this.filters=b.filters||{},this.props.on("change",this._changeFilteredProps,this),this.props.on("change:order",this._changeOrder,this),this.props.on("change:orderby",this._changeOrderby,this),this.props.on("change:query",this._changeQuery,this),this.props.set(_.defaults(b.props||{})),b.observe&&this.observe(b.observe)},_changeOrder:function(){this.comparator&&this.sort()},_changeOrderby:function(a,b){this.comparator&&this.comparator!==c.comparator||(b&&"post__in"!==b?this.comparator=c.comparator:delete this.comparator)},_changeQuery:function(a,b){b?(this.props.on("change",this._requery,this),this._requery()):this.props.off("change",this._requery,this)},_changeFilteredProps:function(a){if(!this.props.get("query")){var b=_.chain(a.changed).map(function(b,d){var e=c.filters[d],f=a.get(d);if(e){if(f&&!this.filters[d])this.filters[d]=e;else{if(f||this.filters[d]!==e)return;delete this.filters[d]}return!0}},this).any().value();b&&(this._source||(this._source=new c(this.models)),this.reset(this._source.filter(this.validator,this)))}},validateDestroyed:!1,validator:function(a){return!this.validateDestroyed&&a.destroyed?!1:_.all(this.filters,function(b){return!!b.call(this,a)},this)},validate:function(a,b){var c=this.validator(a),d=!!this.get(a.cid);return!c&&d?this.remove(a,b):c&&!d&&this.add(a,b),this},validateAll:function(a,b){return b=b||{},_.each(a.models,function(a){this.validate(a,{silent:!0})},this),b.silent||this.trigger("reset",this,b),this},observe:function(a){return this.observers=this.observers||[],this.observers.push(a),a.on("add change remove",this._validateHandler,this),a.on("reset",this._validateAllHandler,this),this.validateAll(a),this},unobserve:function(a){return a?(a.off(null,null,this),this.observers=_.without(this.observers,a)):(_.each(this.observers,function(a){a.off(null,null,this)},this),delete this.observers),this},_validateHandler:function(a,b,c){return c=b===this.mirroring?c:{silent:c&&c.silent},this.validate(a,c)},_validateAllHandler:function(a,b){return this.validateAll(a,b)},mirror:function(a){return this.mirroring&&this.mirroring===a?this:(this.unmirror(),this.mirroring=a,this.reset([],{silent:!0}),this.observe(a),this)},unmirror:function(){this.mirroring&&(this.unobserve(this.mirroring),delete this.mirroring)},more:function(b){var c=a.Deferred(),d=this.mirroring,e=this;return d&&d.more?(d.more(b).done(function(){this===e.mirroring&&c.resolveWith(this)}),c.promise()):c.resolveWith(this).promise()},hasMore:function(){return this.mirroring?this.mirroring.hasMore():!1},parse:function(a,c){return _.isArray(a)||(a=[a]),_.map(a,function(a){var d,e,f;return a instanceof Backbone.Model?(d=a.get("id"),a=a.attributes):d=a.id,e=b.get(d),f=e.parse(a,c),_.isEqual(e.attributes,f)||e.set(f),e})},_requery:function(){this.props.get("query")&&this.mirror(d.get(this.props.toJSON()))},saveMenuOrder:function(){if("menuOrder"===this.props.get("orderby")){var a=this.chain().filter(function(a){return!_.isUndefined(a.id)}).map(function(a,b){return b+=1,a.set("menuOrder",b),[a.id,b]}).object().value();if(!_.isEmpty(a))return g.post("save-attachment-order",{nonce:g.model.settings.post.nonce,post_id:g.model.settings.post.id,attachments:a})}}},{comparator:function(a,b,c){var d=this.props.get("orderby"),f=this.props.get("order")||"DESC",g=a.cid,h=b.cid;return a=a.get(d),b=b.get(d),("date"===d||"modified"===d)&&(a=a||new Date,b=b||new Date),c&&c.ties&&(g=h=null),"DESC"===f?e(a,b,g,h):e(b,a,h,g)},filters:{search:function(a){return this.props.get("search")?_.any(["title","filename","description","caption","name"],function(b){var c=a.get(b);return c&&-1!==c.search(this.props.get("search"))},this):!0},type:function(a){var b=this.props.get("type");return!b||-1!==b.indexOf(a.get("type"))},uploadedTo:function(a){var b=this.props.get("uploadedTo");return _.isUndefined(b)?!0:b===a.get("uploadedTo")}}}),c.all=new c,g.query=function(a){return new c(null,{props:_.extend(_.defaults(a||{},{orderby:"date"}),{query:!0})})},d=g.model.Query=c.extend({initialize:function(a,b){var d;b=b||{},c.prototype.initialize.apply(this,arguments),this.args=b.args,this._hasMore=!0,this.created=new Date,this.filters.order=function(a){var b=this.props.get("orderby"),c=this.props.get("order");return this.comparator?this.length?1!==this.comparator(a,this.last(),{ties:!0}):"DESC"!==c||"date"!==b&&"modified"!==b?"ASC"===c&&"menuOrder"===b?0===a.get(b):!1:a.get(b)>=this.created:!0},d=["s","order","orderby","posts_per_page","post_mime_type","post_parent"],wp.Uploader&&_(this.args).chain().keys().difference(d).isEmpty().value()&&this.observe(wp.Uploader.queue)},hasMore:function(){return this._hasMore},more:function(b){var c=this;return this._more&&"pending"===this._more.state()?this._more:this.hasMore()?(b=b||{},b.remove=!1,this._more=this.fetch(b).done(function(a){(_.isEmpty(a)||-1===this.args.posts_per_page||a.length<this.args.posts_per_page)&&(c._hasMore=!1)})):a.Deferred().resolveWith(this).promise()},sync:function(a,b,d){var e,f;return"read"===a?(d=d||{},d.context=this,d.data=_.extend(d.data||{},{action:"query-attachments",post_id:g.model.settings.post.id}),e=_.clone(this.args),-1!==e.posts_per_page&&(e.paged=Math.floor(this.length/e.posts_per_page)+1),d.data.query=e,g.ajax(d)):(f=c.prototype.sync?c.prototype:Backbone,f.sync.apply(this,arguments))}},{defaultProps:{orderby:"date",order:"DESC"},defaultArgs:{posts_per_page:40},orderby:{allowed:["name","author","date","title","modified","uploadedTo","id","post__in","menuOrder"],valuemap:{id:"ID",uploadedTo:"parent",menuOrder:"menu_order ID"}},propmap:{search:"s",type:"post_mime_type",perPage:"posts_per_page",menuOrder:"menu_order",uploadedTo:"post_parent"},get:function(){var a=[];return function(b,c){var e,f={},g=d.orderby,h=d.defaultProps;return delete b.query,_.defaults(b,h),b.order=b.order.toUpperCase(),"DESC"!==b.order&&"ASC"!==b.order&&(b.order=h.order.toUpperCase()),_.contains(g.allowed,b.orderby)||(b.orderby=h.orderby),_.each(b,function(a,b){_.isNull(a)||(f[d.propmap[b]||b]=a)}),_.defaults(f,d.defaultArgs),f.orderby=g.valuemap[b.orderby]||b.orderby,e=_.find(a,function(a){return _.isEqual(a.args,f)}),e||(e=new d([],_.extend(c||{},{props:b,args:f})),a.push(e)),e}}()}),g.model.Selection=c.extend({initialize:function(a,b){c.prototype.initialize.apply(this,arguments),this.multiple=b&&b.multiple,this.on("add remove reset",_.bind(this.single,this,!1))},add:function(a,b){return this.multiple||this.remove(this.models),c.prototype.add.call(this,a,b)},single:function(a){var b=this._single;return a&&(this._single=a),this._single&&!this.get(this._single.cid)&&delete this._single,this._single=this._single||this.last(),this._single!==b&&(b&&(b.trigger("selection:unsingle",b,this),this.get(b.cid)||this.trigger("selection:unsingle",b,this)),this._single&&this._single.trigger("selection:single",this._single,this)),this._single}}),a(window).on("unload",function(){window.wp=null})}(jQuery);
\ No newline at end of file