diff --git a/wp-includes/css/media-views.min.css b/wp-includes/css/media-views.min.css index e69de29bb2..231e2c171a 100644 --- a/wp-includes/css/media-views.min.css +++ b/wp-includes/css/media-views.min.css @@ -0,0 +1 @@ +.media-modal{position:fixed;top:60px;left:60px;right:60px;bottom:60px;background:#fff;z-index:125000}.media-modal-backdrop{position:fixed;top:0;left:0;right:0;bottom:0;background:#000;opacity:.8;z-index:120000}.media-modal-header{position:absolute;top:0;left:0;right:0;height:28px;background:#f1f1f1}.media-modal-header h3{float:left;padding:0 0 0 10px;margin:0;line-height:28px}.media-modal-close{float:right;padding-right:10px;line-height:28px}.media-modal-content{position:absolute;top:28px;left:0;right:0;bottom:0;overflow:auto}.media-workspace{position:relative;width:100%;height:100%}.upload-attachments{position:absolute;top:0;left:0;bottom:0;width:180px;margin:10px;text-align:center;border:3px dashed #dfdfdf;background:#fff;z-index:100}.upload-attachments h3{font-size:18px;font-weight:200;color:#777;padding:40px 0 0;margin:0}.upload-attachments span{display:block;color:#777;margin:10px 0}.upload-attachments a{display:inline-block;margin:0 auto}.drag-over .upload-attachments{width:auto;right:0;border-color:#83b4d8}.existing-attachments{position:absolute;top:0;left:200px;right:0;bottom:0}.attachments{width:100%;height:100%}.attachments-header{position:absolute;top:0;left:0;right:0;height:50px;background:#fff}.attachments-header h3{float:left;margin:0;padding:0 0 0 10px;line-height:50px;font-size:18px;font-weight:200}.attachments-header input{float:right;margin-top:10px;margin-right:10px}.attachments ul{position:absolute;top:50px;left:0;right:0;bottom:0;overflow:auto;margin:0 10px 20px}.attachment{position:relative;float:left;width:200px;height:200px;padding:0;margin:0 10px 20px;border:1px solid #dfdfdf}.attachment:hover{border-color:#d54e21}.attachment.selected{border-color:#21759b}.attachment-thumbnail{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden}.attachment img{display:block;max-height:200px;max-width:200px;position:absolute;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);-moz-transform:translate(-50%,-50%);-ms-transform:translate(-50%,-50%);-o-transform:translate(-50%,-50%);transform:translate(-50%,-50%);margin:0 auto;box-shadow:inset 0 0 0 1px rgba(0,0,0,0.4)}.media-progress-bar{position:relative;height:8px;width:70%;margin:10px auto;padding:2px;border:2px solid #dfdfdf;border-radius:8px}.media-progress-bar div{height:8px;min-width:8px;width:0;background:#dfdfdf;border-radius:10px;-webkit-transition:width 200ms;-moz-transition:width 200ms;-ms-transition:width 200ms;-o-transition:width 200ms;transition:width 200ms}.attachment-thumbnail .media-progress-bar{position:absolute;top:50%;left:15%;width:70%;margin:-8px 0 0 -4px}.upload-attachments .media-progress-bar{margin-top:80px;display:none}.uploading .upload-attachments .media-progress-bar{display:block} \ No newline at end of file diff --git a/wp-includes/js/media-models.min.js b/wp-includes/js/media-models.min.js index e69de29bb2..4b12ca09bb 100644 --- a/wp-includes/js/media-models.min.js +++ b/wp-includes/js/media-models.min.js @@ -0,0 +1 @@ +if(typeof wp==="undefined"){var wp={}}(function(d){var e=wp.media={model:{},view:{},controller:{}},c,b,a;_.extend(e,{template:_.memoize(function(g){var f;return function(h){f=f||_.template(d("#tmpl-"+g).html());return f(h)}}),post:function(g,f){return e.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 d.Deferred(function(h){if(f.success){h.done(f.success)}if(f.error){h.fail(f.error)}delete f.success;delete f.error;d.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=e.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 e.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=e.model.Attachments=Backbone.Collection.extend({model:c,initialize:function(g,f){f=f||{};this.filters=f.filters||{};if(f.watch){this.watch(f.watch)}if(f.mirror){this.mirror(f.mirror)}},validate:function(f){return _.all(this.filters,function(g){return !!g.call(this,f)},this)},changed:function(g,f){if(this.validate(g)){this.add(g)}else{this.remove(g)}return this},watch:function(f){f.on("add change",this.changed,this)},unwatch:function(f){f.off("add change",this.changed,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))})}});b.all=new b();e.query=(function(){var f=[];return function(h,g){h=_.defaults(h||{},a.defaultArgs);var i=_.find(f,function(j){return _.isEqual(j.args,h)});if(!i){i=new a([],_.extend(g||{},{args:h}));f.push(i)}return i}}());a=e.model.Query=b.extend({initialize:function(i,f){var g,h=a.defaultArgs;f=f||{};b.prototype.initialize.apply(this,arguments);this.args=_.defaults(f.args||{},h);this.args.order=this.args.order.toUpperCase();if("DESC"!==this.args.order&&"ASC"!==this.args.order){this.args.order=h.order.toUpperCase()}g={allowed:["name","author","date","title","modified","parent","ID"],keymap:{ID:"id",parent:"uploadedTo"}};if(!_.contains(g.allowed,this.args.orderby)){this.args.orderby=h.orderby}this.orderkey=g.keymap[this.args.orderby]||this.args.orderby;this.hasMore=true;this.created=new Date();this.filters.order=function(j){if(this.length){return 1!==this.comparator(j,this.last())}else{if("DESC"===this.args.order&&("date"===this.orderkey||"modified"===this.orderkey)){return j.get(this.orderkey)>=this.created}}return false};if(this.args.s){this.filters.search=function(j){return _.any(["title","filename","description","caption","name"],function(k){var l=j.get(k);return l&&-1!==l.search(this.args.s)},this)}}this.watch(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.lengthj?-1:1)}else{return h>g?-1:1}};return function(i,h){var j=this.orderkey,g=this.args.order,k=i.cid,l=h.cid;i=i.get(j);h=h.get(j);if("date"===j||"modified"===j){i=i||new Date();h=h||new Date()}return("DESC"===g)?f(i,h,k,l):f(h,i,l,k)}}())},{defaultArgs:{posts_per_page:40,orderby:"date",order:"DESC"}})}(jQuery)); \ No newline at end of file diff --git a/wp-includes/js/media-views.min.js b/wp-includes/js/media-views.min.js index e69de29bb2..a1d2b24085 100644 --- a/wp-includes/js/media-views.min.js +++ b/wp-includes/js/media-views.min.js @@ -0,0 +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},initialize:function(){this.createSelection();this.modal=new e.view.Modal({controller:this});this.workspace=new e.view.Workspace({controller: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))}})},render:function(){this.workspace.render();this.modal.content(this.workspace).attach();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.$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.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.attachmentsView=new e.view.Attachments({controller:this.controller,directions:"Select stuff.",collection:new b(null,{mirror:e.query()})});this.$content=d('
');this.$content.append(this.attachmentsView.$el);this.pending=new b([],{query:false});this.pending.on("add remove reset change:percent",function(){this.$el.toggleClass("uploading",!!this.pending.length);if(!this.$bar||!this.pending.length){return}this.$bar.width((this.pending.reduce(function(f,g){if(g.get("uploading")){return f+(g.get("percent")||0)}else{return f+100}},0)/this.pending.length)+"%")},this)},render:function(){this.attachmentsView.render();this.$el.html(this.template(this.options)).append(this.$content);this.$bar=this.$(".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"),added:function(g){g.attachment=c.create(_.extend({file:g,uploading:true,date:new Date()},_.pick(g,"loaded","size","percent")));f.pending.add(g.attachment)},progress:function(g){g.attachment.set(_.pick(g,"loaded","percent"))},success:function(i,h){var g;_.each(["file","loaded","size","uploading","percent"],function(j){h.attachment.unset(j)});h.attachment.set("id",i.id);c.get(i.id,h.attachment).fetch();g=f.pending.all(function(j){return !j.get("uploading")});if(g){f.pending.reset()}},error:function(i,g,h){h.attachment.destroy()}},this.options.uploader))}});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("