WordPress.org

Make WordPress Core

Changeset 21899


Ignore:
Timestamp:
09/18/2012 09:59:34 PM (9 years ago)
Author:
bumpbot
Message:

Compress scripts/styles: 3.5-alpha-21899.

Location:
trunk/wp-includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/media-models.min.js

    r21879 r21899  
    1 if(typeof wp==="undefined"){var wp={}}(function(d){var c,b,a;media=wp.media=function(e){if(media.controller.Workflow){return new media.controller.Workflow(e).attach().render()}};_.extend(media,{model:{},view:{},controller:{}});_.extend(media,{template:_.memoize(function(f){var e;return function(g){e=e||_.template(d("#tmpl-"+f).html());return e(g)}}),post:function(f,e){return media.ajax({data:_.isObject(f)?f:_.extend(e||{},{action:f})})},ajax:function(f,e){if(_.isObject(f)){e=f}else{e=e||{};e.data=_.extend(e.data||{},{action:f})}e=_.defaults(e||{},{type:"POST",url:ajaxurl,context:this});return d.Deferred(function(g){if(e.success){g.done(e.success)}if(e.error){g.fail(e.error)}delete e.success;delete e.error;d.ajax(e).done(function(h){if(_.isObject(h)&&!_.isUndefined(h.success)){g[h.success?"resolveWith":"rejectWith"](this,[h.data])}else{g.rejectWith(this,[h])}}).fail(function(){g.rejectWith(this,arguments)})}).promise()}});c=media.model.Attachment=Backbone.Model.extend({sync:function(g,f,e){if("read"===g){e=e||{};e.context=this;e.data=_.extend(e.data||{},{action:"get-attachment",id:this.id});return media.ajax(e)}else{return Backbone.sync.apply(this,arguments)}},parse:function(f,e){f.date=new Date(f.date);f.modified=new Date(f.modified);return f}},{create:function(e){return b.all.push(e)},get:_.memoize(function(f,e){return b.all.push(e||{id:f})})});b=media.model.Attachments=Backbone.Collection.extend({model:c,initialize:function(f,e){e=e||{};this.filters=e.filters||{};if(e.observe){this.observe(e.observe)}if(e.mirror){this.mirror(e.mirror)}},validator:function(e){return _.all(this.filters,function(f){return !!f.call(this,e)},this)},validate:function(f,e){return this[this.validator(f)?"add":"remove"](f,e)},observe:function(e){e.on("add change",this.validate,this)},unobserve:function(e){e.off("add change",this.validate,this)},mirror:function(e){if(this.mirroring&&this.mirroring===e){return}this.unmirror();this.mirroring=e;this.reset(e.models);e.on("add",this._mirrorAdd,this);e.on("remove",this._mirrorRemove,this);e.on("reset",this._mirrorReset,this)},unmirror:function(){if(!this.mirroring){return}this.mirroring.off("add",this._mirrorAdd,this);this.mirroring.off("remove",this._mirrorRemove,this);this.mirroring.off("reset",this._mirrorReset,this);delete this.mirroring},_mirrorAdd:function(g,e,f){this.add(g,{at:f.index})},_mirrorRemove:function(e){this.remove(e)},_mirrorReset:function(e){this.reset(e.models)},more:function(e){if(this.mirroring&&this.mirroring.more){return this.mirroring.more(e)}},parse:function(f,e){return _.map(f,function(g){var h=c.get(g.id);return h.set(h.parse(g,e))})}});b.all=new b();media.query=(function(){var e=[];return function(g,f){g=_.defaults(g||{},a.defaultArgs);var h=_.find(e,function(i){return _.isEqual(i.args,g)});if(!h){h=new a([],_.extend(f||{},{args:g}));e.push(h)}return h}}());a=media.model.Query=b.extend({initialize:function(h,e){var f,g=a.defaultArgs;e=e||{};b.prototype.initialize.apply(this,arguments);this.args=_.defaults(e.args||{},g);this.args.order=this.args.order.toUpperCase();if("DESC"!==this.args.order&&"ASC"!==this.args.order){this.args.order=g.order.toUpperCase()}f={allowed:["name","author","date","title","modified","parent","ID"],keymap:{ID:"id",parent:"uploadedTo"}};if(!_.contains(f.allowed,this.args.orderby)){this.args.orderby=g.orderby}this.orderkey=f.keymap[this.args.orderby]||this.args.orderby;this.hasMore=true;this.created=new Date();this.filters.order=function(i){if(this.length){return 1!==this.comparator(i,this.last())}else{if("DESC"===this.args.order&&("date"===this.orderkey||"modified"===this.orderkey)){return i.get(this.orderkey)>=this.created}}return false};if(this.args.s){this.filters.search=function(i){return _.any(["title","filename","description","caption","name"],function(j){var k=i.get(j);return k&&-1!==k.search(this.args.s)},this)}}this.observe(b.all)},more:function(e){var f=this;if(!this.hasMore){return}e=e||{};e.add=true;return this.fetch(e).done(function(g){if(_.isEmpty(g)||g.length<this.args.posts_per_page){f.hasMore=false}})},sync:function(h,f,e){var g;if("read"===h){e=e||{};e.context=this;e.data=_.extend(e.data||{},{action:"query-attachments"});args=_.clone(this.args);args.paged=Math.floor(this.length/args.posts_per_page)+1;e.data.query=args;return media.ajax(e)}else{g=b.prototype.sync?b.prototype:Backbone;return g.sync.apply(this,arguments)}},comparator:(function(){var e=function(g,f,h,i){if(_.isEqual(g,f)){return h===i?0:(h>i?-1:1)}else{return g>f?-1:1}};return function(h,g){var i=this.orderkey,f=this.args.order,j=h.cid,k=g.cid;h=h.get(i);g=g.get(i);if("date"===i||"modified"===i){h=h||new Date();g=g||new Date()}return("DESC"===f)?e(h,g,j,k):e(g,h,k,j)}}())},{defaultArgs:{posts_per_page:40,orderby:"date",order:"DESC"}})}(jQuery));
     1if(typeof wp==="undefined"){var wp={}}(function(e){var c,b,a,d;media=wp.media=function(f){if(media.controller.Workflow){return new media.controller.Workflow(f).attach().render()}};_.extend(media,{model:{},view:{},controller:{}});d=function(g,f,h,i){if(_.isEqual(g,f)){return h===i?0:(h>i?-1:1)}else{return g>f?-1:1}};_.extend(media,{template:_.memoize(function(g){var f;return function(h){f=f||_.template(e("#tmpl-"+g).html());return f(h)}}),post:function(g,f){return media.ajax({data:_.isObject(g)?g:_.extend(f||{},{action:g})})},ajax:function(g,f){if(_.isObject(g)){f=g}else{f=f||{};f.data=_.extend(f.data||{},{action:g})}f=_.defaults(f||{},{type:"POST",url:ajaxurl,context:this});return e.Deferred(function(h){if(f.success){h.done(f.success)}if(f.error){h.fail(f.error)}delete f.success;delete f.error;e.ajax(f).done(function(i){if(_.isObject(i)&&!_.isUndefined(i.success)){h[i.success?"resolveWith":"rejectWith"](this,[i.data])}else{h.rejectWith(this,[i])}}).fail(function(){h.rejectWith(this,arguments)})}).promise()}});c=media.model.Attachment=Backbone.Model.extend({sync:function(h,g,f){if("read"===h){f=f||{};f.context=this;f.data=_.extend(f.data||{},{action:"get-attachment",id:this.id});return media.ajax(f)}else{return Backbone.sync.apply(this,arguments)}},parse:function(g,f){g.date=new Date(g.date);g.modified=new Date(g.modified);return g}},{create:function(f){return b.all.push(f)},get:_.memoize(function(g,f){return b.all.push(f||{id:g})})});b=media.model.Attachments=Backbone.Collection.extend({model:c,initialize:function(g,f){f=f||{};this.props=new Backbone.Model();this.filters=f.filters||{};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.on("change:search",this._changeSearch,this);this.props.set(_.defaults(f.props||{},{order:"DESC"}));if(f.observe){this.observe(f.observe)}},_changeOrder:function(g,f){if(this.comparator){this.sort()}},_changeOrderby:function(f,g){if(this.comparator&&this.comparator!==b.comparator){return}if(g){this.comparator=b.comparator}else{delete this.comparator}},_changeQuery:function(f,g){if(g){this.props.on("change",this._requery,this);this._requery()}else{this.props.off("change",this._requery,this)}},_changeSearch:function(f,g){if(this.props.get("search")===g){return}if(g&&!this.filters.search){this.filters.search=b.filters.search}else{if(!g&&this.filters.search===b.filters.search){delete this.filters.search}}if(!this.props.get("source")){this.props.set("source",new b(this.models))}this.reset(this.props.get("source").filter(this.validator))},validator:function(f){return _.all(this.filters,function(h,g){return !!h.call(this,f)},this)},validate:function(g,f){return this[this.validator(g)?"add":"remove"](g,f)},observe:function(f){f.on("add change",this.validate,this)},unobserve:function(f){f.off("add change",this.validate,this)},mirror:function(f){if(this.mirroring&&this.mirroring===f){return}this.unmirror();this.mirroring=f;this.reset(f.models);f.on("add",this._mirrorAdd,this);f.on("remove",this._mirrorRemove,this);f.on("reset",this._mirrorReset,this)},unmirror:function(){if(!this.mirroring){return}this.mirroring.off("add",this._mirrorAdd,this);this.mirroring.off("remove",this._mirrorRemove,this);this.mirroring.off("reset",this._mirrorReset,this);delete this.mirroring},_mirrorAdd:function(h,f,g){this.add(h,{at:g.index})},_mirrorRemove:function(f){this.remove(f)},_mirrorReset:function(f){this.reset(f.models)},more:function(f){if(this.mirroring&&this.mirroring.more){return this.mirroring.more(f)}},parse:function(g,f){return _.map(g,function(h){var i=c.get(h.id);return i.set(i.parse(h,f))})},_requery:function(){if(this.props.get("query")){this.mirror(a.get(this.props.toJSON()))}}},{comparator:function(h,g){var i=this.props.get("orderby"),f=this.props.get("order"),j=h.cid,k=g.cid;h=h.get(i);g=g.get(i);if("date"===i||"modified"===i){h=h||new Date();g=g||new Date()}return("DESC"===f)?d(h,g,j,k):d(g,h,k,j)},filters:{search:function(f){if(!this.searching){return true}return _.any(["title","filename","description","caption","name"],function(g){var h=f.get(g);return h&&-1!==h.search(this.searching)},this)}}});b.all=new b();media.query=function(f){return new b(null,{props:_.extend(_.defaults(f||{},{orderby:"date"}),{query:true})})};a=media.model.Query=b.extend({initialize:function(g,f){f=f||{};b.prototype.initialize.apply(this,arguments);this.args=f.args;this.hasMore=true;this.created=new Date();this.filters.order=function(h){if(!this.comparator){return true}if(this.length){return 1!==this.comparator(h,this.last())}else{if("DESC"===this.args.order&&("date"===this.args.orderby||"modified"===this.args.orderby)){return h.get(this.args.orderby)>=this.created}}return false};this.observe(b.all)},more:function(f){var g=this;if(!this.hasMore){return}f=f||{};f.add=true;return this.fetch(f).done(function(h){if(_.isEmpty(h)||h.length<this.args.posts_per_page){g.hasMore=false}})},sync:function(i,g,f){var h;if("read"===i){f=f||{};f.context=this;f.data=_.extend(f.data||{},{action:"query-attachments"});args=_.clone(this.args);args.paged=Math.floor(this.length/args.posts_per_page)+1;f.data.query=args;return media.ajax(f)}else{h=b.prototype.sync?b.prototype:Backbone;return h.sync.apply(this,arguments)}}},{defaultArgs:{posts_per_page:40,orderby:"date",order:"DESC"},orderby:{allowed:["name","author","date","title","modified","parent","ID"],keymap:{id:"ID",uploadedTo:"parent"}},propmap:{search:"s"},get:(function(){var f=[];return function(i,h){var g={},k=a.orderby,l=a.defaultArgs,j;_.each(i,function(m,n){g[a.propmap[n]||n]=m});_.defaults(g,l);g.order=g.order.toUpperCase();if("DESC"!==g.order&&"ASC"!==g.order){g.order=l.order.toUpperCase()}g.orderby=k.keymap[g.orderby]||g.orderby;if(!_.contains(k.allowed,g.orderby)){g.orderby=l.orderby}j=_.find(f,function(m){return _.isEqual(m.args,g)});if(!j){j=new a([],_.extend(h||{},{args:g}));f.push(j)}return j}}())})}(jQuery));
  • trunk/wp-includes/js/media-views.min.js

    r21879 r21899  
    1 (function(d){var e=wp.media,c=e.model.Attachment,b=e.model.Attachments,a=e.model.Query;e.controller.Workflow=Backbone.Model.extend({defaults:{multiple:false,view:"library"},initialize:function(){this.createSelection();this._views={};this._pending={};this.modal=new e.view.Modal({controller:this});this.add("library",e.view.Workspace)},add:function(g,f){this.remove(g);if(_.isFunction(f)){f={view:f}}this._pending[g]=f;this.trigger("add add:"+g,f);return this},view:function(g){var f;g=g||this.get("view");f=this._pending[g];if(!this._views[g]&&f){this._views[g]=new f.view(_.extend({controller:this},f.options||{}));delete this._pending[g];this.trigger("init init:"+g,this._views[g])}return this._views[g]},remove:function(f){delete this._views[f];delete this._pending[f];this.trigger("remove remove:"+f);return this},render:function(h,g){var f;h=h||this.get("view");if(g){this.add(h,g)}f=this.view(h);if(!f){return}f.render();this.modal.content(f);return this},createSelection:function(){var f=this;this.selection=new b();_.extend(this.selection,{add:function(h,g){if(!f.get("multiple")){h=_.isArray(h)?_.first(h):h;this.clear(g)}return b.prototype.add.call(this,h,g)},clear:function(g){return this.remove(this.models,g)},reset:function(h,g){return this.clear(g).add(h,g)},has:function(g){return !!(this.getByCid(g.cid)||this.get(g.id))}})}});_.each(["attach","detach","open","close"],function(f){e.controller.Workflow.prototype[f]=function(){this.modal[f].apply(this.modal,arguments);return this}});e.view.Modal=Backbone.View.extend({tagName:"div",template:e.template("media-modal"),events:{"click .media-modal-backdrop, .media-modal-close":"closeHandler"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{title:"",container:document.body})},render:function(){this.options.$content=this.options.$content||d("<div />");this.options.$content.detach();this.$el.html(this.template(this.options));this.$(".media-modal-content").append(this.options.$content);return this},attach:function(){this.$el.appendTo(this.options.container)},detach:function(){this.$el.detach()},open:function(){this.$el.show()},close:function(){this.$el.hide()},closeHandler:function(f){f.preventDefault();this.close()},content:function(f){this.options.$content=(f instanceof Backbone.View)?f.$el:f;return this.render()},title:function(f){this.options.title=f;return this.render()}});e.view.Toolbar=Backbone.View.extend({tagName:"div",className:"media-toolbar",initialize:function(){this._views={};this.$primary=d('<div class="media-toolbar-primary" />').prependTo(this.$el);this.$secondary=d('<div class="media-toolbar-secondary" />').prependTo(this.$el);if(this.options.items){_.each(this.options.items,function(f,g){this.add(g,f,{silent:true})},this);this.render()}},render:function(){var f=_.chain(this._views).sortBy(function(g){return g.options.priority||10}).groupBy(function(g){return(g.options.priority||10)>0?"primary":"secondary"}).value();d(_.pluck(this._views,"el")).detach();this.$primary.html(_.pluck(f.primary,"el"));this.$secondary.html(_.pluck(f.secondary,"el"));return this},add:function(h,f,g){if(!(f instanceof Backbone.View)){f.classes=[h].concat(f.classes||[]);f=new e.view.Button(f).render()}this._views[h]=f;if(!g||!g.silent){this.render()}return this},remove:function(g,f){delete this._views[g];if(!f||!f.silent){this.render()}return this}});e.view.Button=Backbone.View.extend({tagName:"a",className:"media-button",attributes:{href:"#"},events:{click:"click"},initialize:function(){_.defaults(this.options,{style:"secondary",text:"",classes:[]})},render:function(){var f=[this.className];if(this.options.style){f.push("button-"+this.options.style)}f=f.concat(this.options.classes);this.el.className=f.join(" ");this.$el.text(this.options.text);return this},click:function(f){f.preventDefault();if(this.options.click){this.options.click.apply(this,arguments)}}});e.view.Workspace=Backbone.View.extend({tagName:"div",className:"media-workspace",template:e.template("media-workspace"),events:{dragenter:"maybeInitUploader",mouseenter:"maybeInitUploader"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{selectOne:false,uploader:{}});this.$content=d('<div class="existing-attachments" />');if(this.controller.get("multiple")){this.initToolbarView()}this.attachmentsView=new e.view.Attachments({controller:this.controller,directions:"Select stuff.",collection:new b(null,{mirror:e.query()})});this.$content.append(this.attachmentsView.$el);wp.Uploader.queue.on("add remove reset change:percent",this.renderUploadProgress,this)},render:function(){this.attachmentsView.render();this.renderUploadProgress();this.$el.html(this.template(this.options)).append(this.$content);this.$bar=this.$(".upload-attachments .media-progress-bar div");return this},maybeInitUploader:function(){var f=this;if(this.uploader||!this.$el.closest("body").length){return}this.uploader=new wp.Uploader(_.extend({container:this.$el,dropzone:this.$el,browser:this.$(".upload-attachments a")},this.options.uploader))},renderUploadProgress:function(){var f=wp.Uploader.queue;this.$el.toggleClass("uploading",!!f.length);if(!this.$bar||!f.length){return}this.$bar.width((f.reduce(function(g,h){if(h.get("uploading")){return g+(h.get("percent")||0)}else{return g+100}},0)/f.length)+"%")},initToolbarView:function(){this.toolbarView=new e.view.Toolbar({items:{"selection-preview":new e.view.SelectionPreview({controller:this.controller,collection:this.controller.selection,priority:-40}),"insert-into-post":{style:"primary",text:"Insert into post",priority:40},"create-new-gallery":{style:"primary",text:"Create a new gallery",priority:30},"add-to-gallery":{text:"Add to gallery",priority:20}}});this.controller.selection.on("add remove",function(){this.$el.toggleClass("with-toolbar",!!this.controller.selection.length)},this);this.$content.append(this.toolbarView.$el)}});e.view.Attachments=Backbone.View.extend({tagName:"div",className:"attachments",template:e.template("attachments"),events:{"keyup input":"search"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{refreshSensitivity:200,refreshThreshold:3});_.each(["add","remove"],function(f){this.collection.on(f,function(i,g,h){this[f](i,h.index)},this)},this);this.collection.on("reset",this.refresh,this);this.$list=d("<ul />");this.list=this.$list[0];this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value();this.$list.on("scroll.attachments",this.scroll)},render:function(){this.$el.html(this.template(this.options)).append(this.$list);this.refresh();return this},refresh:function(){if(!this.collection.length){this.collection.more();this.$list.empty();return this}this.$list.html(this.collection.map(function(f){return new e.view.Attachment({controller:this.controller,model:f}).render().$el},this));this.scroll();return this},add:function(i,g){var f,h;f=new e.view.Attachment({controller:this.controller,model:i}).render();h=this.$list.children();if(h.length>g){h.eq(g).before(f.$el)}else{this.$list.append(f.$el)}},remove:function(h,f){var g=this.$list.children();if(g.length){g.eq(f).detach()}},scroll:function(f){if(!this.$list.is(":visible")){return}if(this.list.scrollHeight<this.list.scrollTop+(this.list.clientHeight*this.options.refreshThreshold)){this.collection.more()}},search:function(g){var f=_.clone(this.collection.mirroring.args);if(f.s===g.target.value){return}if(g.target.value){f.s=g.target.value}else{delete f.s}this.collection.mirror(e.query(f))}});e.view.Attachment=Backbone.View.extend({tagName:"li",className:"attachment",template:e.template("attachment"),events:{click:"toggleSelection"},initialize:function(){this.controller=this.options.controller;this.model.on("change:sizes change:uploading",this.render,this);this.model.on("change:percent",this.progress,this);this.model.on("add",this.select,this);this.model.on("remove",this.deselect,this)},render:function(){var g=this.model.toJSON(),f={thumbnail:"image"===g.type?g.url:g.icon,uploading:g.uploading,orientation:g.orientation||"landscape",type:g.type,subtype:g.subtype};if(g.sizes&&g.sizes.medium){f.orientation=g.sizes.medium.orientation;f.thumbnail=g.sizes.medium.url}this.$el.html(this.template(f));if(g.uploading){this.$bar=this.$(".media-progress-bar div")}else{delete this.$bar}if(this.controller.selection.has(this.model)){this.select()}return this},progress:function(){if(this.$bar&&this.$bar.length){this.$bar.width(this.model.get("percent")+"%")}},toggleSelection:function(g){var f=this.controller.selection;f[f.has(this.model)?"remove":"add"](this.model)},select:function(f,g){if(g&&g!==this.controller.selection){return}this.$el.addClass("selected")},deselect:function(f,g){if(g&&g!==this.controller.selection){return}this.$el.removeClass("selected")}});e.view.SelectionPreview=Backbone.View.extend({tagName:"div",className:"selection-preview",template:e.template("media-selection-preview"),events:{"click .clear-selection":"clear"},initialize:function(){this.controller=this.options.controller;this.collection.on("add change:url remove",this.render,this);this.render()},render:function(){var f={},i,h,g;if(!this.collection.length){this.$el.empty();return this}f.count=this.collection.length;i=this.collection.first();h=i.get("sizes");if("image"===i.get("type")){f.thumbnail=(h&&h.thumbnail)?h.thumbnail.url:i.get("url")}else{f.thumbnail=i.get("icon")}this.$el.html(this.template(f));return this},clear:function(f){f.preventDefault();this.collection.clear()}})}(jQuery));
     1(function(d){var e=wp.media,c=e.model.Attachment,b=e.model.Attachments,a=e.model.Query;e.controller.Workflow=Backbone.Model.extend({defaults:{multiple:false,view:"library"},initialize:function(){this.createSelection();this._views={};this._pending={};this.modal=new e.view.Modal({controller:this});this.add("library",e.view.Workspace)},add:function(g,f){this.remove(g);if(_.isFunction(f)){f={view:f}}this._pending[g]=f;this.trigger("add add:"+g,f);return this},view:function(g){var f;g=g||this.get("view");f=this._pending[g];if(!this._views[g]&&f){this._views[g]=new f.view(_.extend({controller:this},f.options||{}));delete this._pending[g];this.trigger("init init:"+g,this._views[g])}return this._views[g]},remove:function(f){delete this._views[f];delete this._pending[f];this.trigger("remove remove:"+f);return this},render:function(h,g){var f;h=h||this.get("view");if(g){this.add(h,g)}f=this.view(h);if(!f){return}f.render();this.modal.content(f);return this},createSelection:function(){var f=this;this.selection=new b();_.extend(this.selection,{add:function(h,g){if(!f.get("multiple")){h=_.isArray(h)?_.first(h):h;this.clear(g)}return b.prototype.add.call(this,h,g)},clear:function(g){return this.remove(this.models,g)},reset:function(h,g){return this.clear(g).add(h,g)},has:function(g){return !!(this.getByCid(g.cid)||this.get(g.id))}})}});_.each(["attach","detach","open","close"],function(f){e.controller.Workflow.prototype[f]=function(){this.modal[f].apply(this.modal,arguments);return this}});e.view.Modal=Backbone.View.extend({tagName:"div",template:e.template("media-modal"),events:{"click .media-modal-backdrop, .media-modal-close":"closeHandler"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{title:"",container:document.body})},render:function(){this.options.$content=this.options.$content||d("<div />");this.options.$content.detach();this.$el.html(this.template(this.options));this.$(".media-modal-content").append(this.options.$content);return this},attach:function(){this.$el.appendTo(this.options.container)},detach:function(){this.$el.detach()},open:function(){this.$el.show()},close:function(){this.$el.hide()},closeHandler:function(f){f.preventDefault();this.close()},content:function(f){this.options.$content=(f instanceof Backbone.View)?f.$el:f;return this.render()},title:function(f){this.options.title=f;return this.render()}});e.view.Toolbar=Backbone.View.extend({tagName:"div",className:"media-toolbar",initialize:function(){this._views={};this.$primary=d('<div class="media-toolbar-primary" />').prependTo(this.$el);this.$secondary=d('<div class="media-toolbar-secondary" />').prependTo(this.$el);if(this.options.items){_.each(this.options.items,function(f,g){this.add(g,f,{silent:true})},this);this.render()}},render:function(){var f=_.chain(this._views).sortBy(function(g){return g.options.priority||10}).groupBy(function(g){return(g.options.priority||10)>0?"primary":"secondary"}).value();d(_.pluck(this._views,"el")).detach();this.$primary.html(_.pluck(f.primary,"el"));this.$secondary.html(_.pluck(f.secondary,"el"));return this},add:function(h,f,g){if(!(f instanceof Backbone.View)){f.classes=[h].concat(f.classes||[]);f=new e.view.Button(f).render()}this._views[h]=f;if(!g||!g.silent){this.render()}return this},remove:function(g,f){delete this._views[g];if(!f||!f.silent){this.render()}return this}});e.view.Button=Backbone.View.extend({tagName:"a",className:"media-button",attributes:{href:"#"},events:{click:"click"},initialize:function(){_.defaults(this.options,{style:"secondary",text:"",classes:[]})},render:function(){var f=[this.className];if(this.options.style){f.push("button-"+this.options.style)}f=f.concat(this.options.classes);this.el.className=f.join(" ");this.$el.text(this.options.text);return this},click:function(f){f.preventDefault();if(this.options.click){this.options.click.apply(this,arguments)}}});e.view.Workspace=Backbone.View.extend({tagName:"div",className:"media-workspace",template:e.template("media-workspace"),events:{dragenter:"maybeInitUploader",mouseenter:"maybeInitUploader"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{selectOne:false,uploader:{}});this.$content=d('<div class="existing-attachments" />');if(this.controller.get("multiple")){this.initToolbarView()}this.attachmentsView=new e.view.Attachments({controller:this.controller,directions:"Select stuff.",collection:e.query()});this.$content.append(this.attachmentsView.$el);wp.Uploader.queue.on("add remove reset change:percent",this.renderUploadProgress,this)},render:function(){this.attachmentsView.render();this.renderUploadProgress();this.$el.html(this.template(this.options)).append(this.$content);this.$bar=this.$(".upload-attachments .media-progress-bar div");return this},maybeInitUploader:function(){var f=this;if(this.uploader||!this.$el.closest("body").length){return}this.uploader=new wp.Uploader(_.extend({container:this.$el,dropzone:this.$el,browser:this.$(".upload-attachments a")},this.options.uploader))},renderUploadProgress:function(){var f=wp.Uploader.queue;this.$el.toggleClass("uploading",!!f.length);if(!this.$bar||!f.length){return}this.$bar.width((f.reduce(function(g,h){if(h.get("uploading")){return g+(h.get("percent")||0)}else{return g+100}},0)/f.length)+"%")},initToolbarView:function(){this.toolbarView=new e.view.Toolbar({items:{"selection-preview":new e.view.SelectionPreview({controller:this.controller,collection:this.controller.selection,priority:-40}),"insert-into-post":{style:"primary",text:"Insert into post",priority:40},"create-new-gallery":{style:"primary",text:"Create a new gallery",priority:30},"add-to-gallery":{text:"Add to gallery",priority:20}}});this.controller.selection.on("add remove",function(){this.$el.toggleClass("with-toolbar",!!this.controller.selection.length)},this);this.$content.append(this.toolbarView.$el)}});e.view.Attachments=Backbone.View.extend({tagName:"div",className:"attachments",template:e.template("attachments"),events:{"keyup input":"search"},initialize:function(){this.controller=this.options.controller;_.defaults(this.options,{refreshSensitivity:200,refreshThreshold:3});_.each(["add","remove"],function(f){this.collection.on(f,function(i,g,h){this[f](i,h.index)},this)},this);this.collection.on("reset",this.refresh,this);this.$list=d("<ul />");this.list=this.$list[0];this.scroll=_.chain(this.scroll).bind(this).throttle(this.options.refreshSensitivity).value();this.$list.on("scroll.attachments",this.scroll)},render:function(){this.$el.html(this.template(this.options)).append(this.$list);this.refresh();return this},refresh:function(){if(!this.collection.length){this.collection.more();this.$list.empty();return this}this.$list.html(this.collection.map(function(f){return new e.view.Attachment({controller:this.controller,model:f}).render().$el},this));this.scroll();return this},add:function(i,g){var f,h;f=new e.view.Attachment({controller:this.controller,model:i}).render();h=this.$list.children();if(h.length>g){h.eq(g).before(f.$el)}else{this.$list.append(f.$el)}},remove:function(h,f){var g=this.$list.children();if(g.length){g.eq(f).detach()}},scroll:function(f){if(!this.$list.is(":visible")){return}if(this.list.scrollHeight<this.list.scrollTop+(this.list.clientHeight*this.options.refreshThreshold)){this.collection.more()}},search:function(g){var f=this.collection.props;if(g.target.value){f.set("search",g.target.value)}else{f.unset("search")}}});e.view.Attachment=Backbone.View.extend({tagName:"li",className:"attachment",template:e.template("attachment"),events:{click:"toggleSelection"},initialize:function(){this.controller=this.options.controller;this.model.on("change:sizes change:uploading",this.render,this);this.model.on("change:percent",this.progress,this);this.model.on("add",this.select,this);this.model.on("remove",this.deselect,this)},render:function(){var g=this.model.toJSON(),f={thumbnail:"image"===g.type?g.url:g.icon,uploading:g.uploading,orientation:g.orientation||"landscape",type:g.type,subtype:g.subtype};if(g.sizes&&g.sizes.medium){f.orientation=g.sizes.medium.orientation;f.thumbnail=g.sizes.medium.url}this.$el.html(this.template(f));if(g.uploading){this.$bar=this.$(".media-progress-bar div")}else{delete this.$bar}if(this.controller.selection.has(this.model)){this.select()}return this},progress:function(){if(this.$bar&&this.$bar.length){this.$bar.width(this.model.get("percent")+"%")}},toggleSelection:function(g){var f=this.controller.selection;f[f.has(this.model)?"remove":"add"](this.model)},select:function(f,g){if(g&&g!==this.controller.selection){return}this.$el.addClass("selected")},deselect:function(f,g){if(g&&g!==this.controller.selection){return}this.$el.removeClass("selected")}});e.view.SelectionPreview=Backbone.View.extend({tagName:"div",className:"selection-preview",template:e.template("media-selection-preview"),events:{"click .clear-selection":"clear"},initialize:function(){this.controller=this.options.controller;this.collection.on("add change:url remove",this.render,this);this.render()},render:function(){var f={},i,h,g;if(!this.collection.length){this.$el.empty();return this}f.count=this.collection.length;i=this.collection.first();h=i.get("sizes");if("image"===i.get("type")){f.thumbnail=(h&&h.thumbnail)?h.thumbnail.url:i.get("url")}else{f.thumbnail=i.get("icon")}this.$el.html(this.template(f));return this},clear:function(f){f.preventDefault();this.collection.clear()}})}(jQuery));
  • trunk/wp-includes/version.php

    r21895 r21899  
    55 * @global string $wp_version
    66 */
    7 $wp_version = '3.5-alpha-21895';
     7$wp_version = '3.5-alpha-21899';
    88
    99/**
Note: See TracChangeset for help on using the changeset viewer.