WordPress/wp-admin/js/revisions.min.js

1 line
10 KiB
JavaScript
Raw Normal View History

window.wp=window.wp||{};(function(a){wp.revisions={views:{},Model:Backbone.Model.extend({idAttribute:"ID",urlRoot:ajaxurl+"?action=revisions-data&compare_to="+wpRevisionsSettings.post_id+"&show_autosaves=false&show_split_view=true&nonce="+wpRevisionsSettings.nonce,defaults:{ID:0,revision_date_author:"",revisiondiff:'<div class="diff-loading"><div class="spinner"></div></div>',restoreaction:"",revision_from_date_author:"",revision_toload:false},url:function(){return this.urlRoot+"&single_revision_id="+this.id}}),app:_.extend({},Backbone.Events),App:Backbone.Router.extend({_revisionDifflView:null,_revisions:null,_left_handle_revisions:null,_right_handle_revisions:null,_revisionsInteractions:null,_revisionsOptions:null,_left_diff:0,_right_diff:1,_autosaves:false,_show_split_view:true,_compareoneortwo:1,_left_model_loading:false,_right_model_loading:false,routes:{},viewrevision:function(b){},reload_toload_revisions:function(d,e){var b=this;var f=d.where({revision_toload:true});var c=0;_.each(f,function(g){g.urlRoot=d.url;_.delay(function(){g.fetch({update:true,add:false,remove:false,success:function(h){if(h.get("ID")===b._revisions.at(b._right_diff-1).get("ID")){b._revisionView.render()}}})},c);c=c+200})},start_left_model_loading:function(){this._left_model_loading=true;a(".revisiondiffcontainer").addClass("leftmodelloading")},stop_left_model_loading:function(){this._left_model_loading=false;a(".revisiondiffcontainer").removeClass("leftmodelloading")},start_right_model_loading:function(){this._right_model_loading=true;a(".revisiondiffcontainer").addClass("rightmodelloading")},stop_right_model_loading:function(){this._right_model_loading=false;a(".revisiondiffcontainer").removeClass("rightmodelloading")},reloadmodel:function(){if(2===this._compareoneortwo){this.reloadleftright()}else{this.reloadmodelsingle()}},reloadmodelsingle:function(){var b=this;b._revisions.url=ajaxurl+"?action=revisions-data&compare_to="+wpRevisionsSettings.post_id+"&show_autosaves="+b._autosaves+"&show_split_view="+REVAPP._show_split_view+"&nonce="+wpRevisionsSettings.nonce;b.start_right_model_loading();this._revisions.fetch({success:function(){b.stop_right_model_loading();var c=b._revisions.length;if(b._right_diff>c){b._right_diff=c}b._revisionView.render();b.reload_toload_revisions(b._revisions);a("#slider").slider("option","max",c-1)},error:function(){b.stop_right_model_loading()}})},reloadleft:function(){var b=this;b.start_left_model_loading();b._left_handle_revisions=new wp.revisions.Collection();b._left_handle_revisions.url=ajaxurl+"?action=revisions-data&compare_to="+b._revisions.at(b._right_diff-1).get("ID")+"&post_id="+wpRevisionsSettings.post_id+"&show_autosaves="+b._autosaves+"&show_split_view="+b._show_split_view+"&nonce="+wpRevisionsSettings.nonce+"&right_handle_at="+(b._right_diff);b._left_handle_revisions.fetch({success:function(){b.stop_left_model_loading();b.reload_toload_revisions(b._left_handle_revisions)},error:function(){b.stop_left_model_loading()}})},reloadright:function(){var b=this;b.start_right_model_loading();b._right_handle_revisions=new wp.revisions.Collection();if(0===b._left_diff){b._right_handle_revisions.url=ajaxurl+"?action=revisions-data&compare_to="+wpRevisionsSettings.post_id+"&post_id="+wpRevisionsSettings.post_id+"&show_autosaves="+b._autosaves+"&show_split_view="+b._show_split_view+"&nonce="+wpRevisionsSettings.nonce}else{b._right_handle_revisions.url=ajaxurl+"?action=revisions-data&compare_to="+b._revisions.at(b._left_diff-1).get("ID")+"&post_id="+wpRevisionsSettings.post_id+"&show_autosaves="+b._autosaves+"&show_split_view="+b._show_split_view+"&nonce="+wpRevisionsSettings.nonce+"&left_handle_at="+(b._left_diff)}b._right_handle_revisions.fetch({success:function(){b.stop_right_model_loading();b.reload_toload_revisions(b._right_handle_revisions)},error:function(c){b.stop_right_model_loading()}})},reloadleftright:function(){this.reloadleft();this.reloadright()},initialize:function(c){var b=this;if(this._revisions===null){b._autosaves="";b._revisions=new wp.revisions.Collection();b.start_right_model_loading();b._r